2015-11-15 19:46:33 +01:00
|
|
|
// File: fradiomenuitem.cpp
|
|
|
|
// Provides: class FRadioMenuItem
|
|
|
|
|
|
|
|
#include "fradiomenuitem.h"
|
|
|
|
#include "fmenu.h"
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FRadioMenuItem
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// constructor and destructor
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FRadioMenuItem::FRadioMenuItem (FWidget* parent)
|
|
|
|
: FMenuItem(parent)
|
|
|
|
{
|
|
|
|
init (parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
2017-03-17 22:59:06 +01:00
|
|
|
FRadioMenuItem::FRadioMenuItem (const FString& txt, FWidget* parent)
|
2015-11-15 19:46:33 +01:00
|
|
|
: FMenuItem(txt, parent)
|
|
|
|
{
|
|
|
|
init (parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FRadioMenuItem::~FRadioMenuItem() // destructor
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
|
|
// private methods of FRadioMenuItem
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FRadioMenuItem::init (FWidget* parent)
|
|
|
|
{
|
|
|
|
checkable = true;
|
|
|
|
radio_button = true;
|
|
|
|
|
2016-10-17 08:44:38 +02:00
|
|
|
if ( ! parent )
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ( isMenu(parent) ) // Parent is menu
|
2015-11-15 19:46:33 +01:00
|
|
|
{
|
2016-10-17 08:44:38 +02:00
|
|
|
FMenu* menu_ptr = dynamic_cast<FMenu*>(parent);
|
|
|
|
|
|
|
|
if ( menu_ptr )
|
|
|
|
menu_ptr->has_checkable_items = true;
|
|
|
|
|
|
|
|
this->addCallback
|
|
|
|
(
|
|
|
|
"toggled",
|
|
|
|
_METHOD_CALLBACK (parent, &FMenu::cb_menuitem_toggled)
|
|
|
|
);
|
2015-11-15 19:46:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FRadioMenuItem::processToggle()
|
|
|
|
{
|
|
|
|
emitCallback("toggled");
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FRadioMenuItem::processClicked()
|
|
|
|
{
|
|
|
|
if ( ! checked )
|
|
|
|
{
|
|
|
|
checked = true;
|
|
|
|
processToggle();
|
|
|
|
}
|
|
|
|
|
|
|
|
emitCallback("clicked");
|
|
|
|
}
|