2015-11-15 19:46:33 +01:00
|
|
|
// File: fcheckmenuitem.cpp
|
|
|
|
// Provides: class FCheckMenuItem
|
|
|
|
|
|
|
|
#include "fcheckmenuitem.h"
|
|
|
|
#include "fmenu.h"
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
// class FCheckMenuItem
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
|
|
|
|
// constructor and destructor
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FCheckMenuItem::FCheckMenuItem (FWidget* parent)
|
|
|
|
: FMenuItem(parent)
|
|
|
|
{
|
|
|
|
init (parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FCheckMenuItem::FCheckMenuItem (FString& txt, FWidget* parent)
|
|
|
|
: FMenuItem(txt, parent)
|
|
|
|
{
|
|
|
|
init (parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FCheckMenuItem::FCheckMenuItem (const std::string& txt, FWidget* parent)
|
|
|
|
: FMenuItem(txt, parent)
|
|
|
|
{
|
|
|
|
init (parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FCheckMenuItem::FCheckMenuItem (const char* txt, FWidget* parent)
|
|
|
|
: FMenuItem(txt, parent)
|
|
|
|
{
|
|
|
|
init (parent);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
FCheckMenuItem::~FCheckMenuItem() // destructor
|
|
|
|
{ }
|
|
|
|
|
|
|
|
|
|
|
|
// private methods of FCheckMenuItem
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FCheckMenuItem::init (FWidget* parent)
|
|
|
|
{
|
|
|
|
checkable = 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);
|
2016-07-09 00:01:59 +02:00
|
|
|
|
2016-10-17 08:44:38 +02:00
|
|
|
if ( menu_ptr )
|
|
|
|
menu_ptr->has_checkable_items = true;
|
2015-11-15 19:46:33 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FCheckMenuItem::processToggle()
|
|
|
|
{
|
|
|
|
emitCallback("toggled");
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------
|
|
|
|
void FCheckMenuItem::processClicked()
|
|
|
|
{
|
|
|
|
checked = not checked;
|
|
|
|
processToggle();
|
|
|
|
emitCallback("clicked");
|
|
|
|
}
|