Add new classes FCheckMenuItem and FRadioMenuItem

This commit is contained in:
Markus Gans 2015-11-15 19:46:33 +01:00
parent ca60b762a7
commit 0c0453eb79
22 changed files with 649 additions and 224 deletions

View File

@ -1,3 +1,7 @@
2015-11-12 Markus Gans <guru.mail@muenster.de>
* Add two new classes FCheckMenuItem and FRadioMenuItem
for menu check marks and menu option marks (bullets)
2015-11-12 Markus Gans <guru.mail@muenster.de> 2015-11-12 Markus Gans <guru.mail@muenster.de>
* Improve menu accelerator keys * Improve menu accelerator keys
* Shows accelerator keys on the right side of the FMenu. * Shows accelerator keys on the right side of the FMenu.

View File

@ -171,15 +171,19 @@ Class digramm
: : ▲ 1: └──┤ FMessageBox ├----: : : ▲ 1: └──┤ FMessageBox ├----:
: : │ : └─────────────┘ : : : │ : └─────────────┘ :
: : │ └------------------------------: : : │ └------------------------------:
: : └───────────────────┐ ┌──────────┐ : : : └───────────────┐ ┌──────────┐ :
: : │ ┌───┤ FMenuBar │ : : : │ ┌───┤ FMenuBar │ :
: : ├───┤ └──────────┘ : : : ┌───────────┐ └─────┤ └──────────┘ :
: : ┌───────────┐ │ │ ┌───────┐ : : : │ FMenuList │◄──────────┤ ┌───────┐ :
: : │ FMenuList │◄───┘ └───┤ FMenu │ : : : └────┬──────┘ └───┤ FMenu │ :
: : └─────┬─────┘ └───────┘ : : : : └───────┘ :
: : : ┌───────────┐ : : : 1: ┌────────────────┐* :
: : └------------------┤ FMenuItem │ : : : : *┌───────────┐ ┌──┤ FCheckMenuItem ├-┐ :
: : └───────────┘ : : : ├--┤ FMenuItem │◄─┤ └────────────────┘ : :
: : : └───────────┘ │ ┌────────────────┐*: :
: : : └──┤ FRadioMenuItem ├-┤ :
: : : └────────────────┘ : :
: : └---------------------------------------┘ :
: └---------------------------------------------------┘ : └---------------------------------------------------┘
: *┌────────┐ : *┌────────┐
:---┤ FPoint │ :---┤ FPoint │

View File

@ -74,15 +74,19 @@
: : ▲ 1: └──┤ FMessageBox ├----: : : ▲ 1: └──┤ FMessageBox ├----:
: : │ : └─────────────┘ : : : │ : └─────────────┘ :
: : │ └------------------------------: : : │ └------------------------------:
: : └───────────────────┐ ┌──────────┐ : : : └───────────────┐ ┌──────────┐ :
: : │ ┌───┤ FMenuBar │ : : : │ ┌───┤ FMenuBar │ :
: : ├───┤ └──────────┘ : : : ┌───────────┐ └─────┤ └──────────┘ :
: : ┌───────────┐ │ │ ┌───────┐ : : : │ FMenuList │◄──────────┤ ┌───────┐ :
: : │ FMenuList │◄───┘ └───┤ FMenu │ : : : └────┬──────┘ └───┤ FMenu │ :
: : └─────┬─────┘ └───────┘ : : : : └───────┘ :
: : : ┌───────────┐ : : : 1: ┌────────────────┐* :
: : └------------------┤ FMenuItem │ : : : : *┌───────────┐ ┌──┤ FCheckMenuItem ├-┐ :
: : └───────────┘ : : : ├--┤ FMenuItem │◄─┤ └────────────────┘ : :
: : : └───────────┘ │ ┌────────────────┐*: :
: : : └──┤ FRadioMenuItem ├-┤ :
: : : └────────────────┘ : :
: : └---------------------------------------┘ :
: └---------------------------------------------------┘ : └---------------------------------------------------┘
: *┌────────┐ : *┌────────┐
:---┤ FPoint │ :---┤ FPoint │

View File

@ -26,6 +26,8 @@ libfinal_la_SOURCES = \
fmenu.cpp \ fmenu.cpp \
fmenubar.cpp \ fmenubar.cpp \
fmenuitem.cpp \ fmenuitem.cpp \
fradiomenuitem.cpp \
fcheckmenuitem.cpp \
fmenulist.cpp \ fmenulist.cpp \
fdialog.cpp \ fdialog.cpp \
fwindow.cpp \ fwindow.cpp \
@ -64,6 +66,8 @@ finalcutinclude_HEADERS = \
fmenu.h \ fmenu.h \
fmenubar.h \ fmenubar.h \
fmenuitem.h \ fmenuitem.h \
fradiomenuitem.h \
fcheckmenuitem.h \
fmenulist.h \ fmenulist.h \
fmessagebox.h \ fmessagebox.h \
fobject.h \ fobject.h \

View File

@ -7,33 +7,38 @@ VERSION = "0.1.1"
MAJOR := $(shell echo ${VERSION} | cut -d. -f1) MAJOR := $(shell echo ${VERSION} | cut -d. -f1)
LIBDIR = /usr/local/lib64 LIBDIR = /usr/local/lib64
INCLUDEDIR = /usr/local/include/final INCLUDEDIR = /usr/local/include/final
INCLUDE_HEADERS = fapp.h \ INCLUDE_HEADERS = \
fbuttongroup.h \ fapp.h \
fbutton.h \ fbuttongroup.h \
fcheckbox.h \ fbutton.h \
fswitch.h \ fcheckbox.h \
fdialog.h \ fswitch.h \
fevent.h \ fdialog.h \
ffiledialog.h \ fevent.h \
final.h \ ffiledialog.h \
flabel.h \ final.h \
flineedit.h \ flabel.h \
flistbox.h \ flineedit.h \
fmessagebox.h \ flistbox.h \
fobject.h \ fmenu.h \
foptimove.h \ fmenubar.h \
fpoint.h \ fradiomenuitem.h \
fprogressbar.h \ fcheckmenuitem.h \
fradiobutton.h \ fmessagebox.h \
frect.h \ fobject.h \
fscrollbar.h \ foptimove.h \
fstatusbar.h \ fpoint.h \
fstring.h \ fprogressbar.h \
fterm.h \ fradiobutton.h \
ftextview.h \ frect.h \
ftogglebutton.h \ fscrollbar.h \
fwidget.h \ fstatusbar.h \
fwindow.h fstring.h \
fterm.h \
ftextview.h \
ftogglebutton.h \
fwidget.h \
fwindow.h
# compiler parameter # compiler parameter
CXX = clang++ CXX = clang++
@ -45,32 +50,39 @@ GPM = -D F_HAVE_LIBGPM
VER = -D F_VERSION=$(VERSION) VER = -D F_VERSION=$(VERSION)
RM = rm -f RM = rm -f
LIB = libfinal.so LIB = libfinal.so
OBJS = fstring.o \ OBJS = \
fpoint.o \ fstring.o \
frect.o \ fpoint.o \
fscrollbar.o \ frect.o \
fprogressbar.o \ fscrollbar.o \
flineedit.o \ fprogressbar.o \
fbutton.o \ flineedit.o \
fbuttongroup.o \ fbutton.o \
ftogglebutton.o \ fbuttongroup.o \
fradiobutton.o \ ftogglebutton.o \
fcheckbox.o \ fradiobutton.o \
fswitch.o \ fcheckbox.o \
flabel.o \ fswitch.o \
flistbox.o \ flabel.o \
fdialog.o \ flistbox.o \
fwindow.o \ fmenu.o \
fmessagebox.o \ fmenubar.o \
ffiledialog.o \ fmenuitem.o \
ftextview.o \ fradiomenuitem.o \
fstatusbar.o \ fcheckmenuitem.o \
fterm.o \ fmenulist.o \
fevent.o \ fdialog.o \
foptimove.o \ fwindow.o \
fapp.o \ fmessagebox.o \
fwidget.o \ ffiledialog.o \
fobject.o ftextview.o \
fstatusbar.o \
fterm.o \
fevent.o \
foptimove.o \
fapp.o \
fwidget.o \
fobject.o
TERMCAP := $(shell test -n "$$(ldd {/usr,}/lib64/libncursesw.so.5 2>/dev/null | grep libtinfo)" && echo "-ltinfo" || echo "-lncurses") TERMCAP := $(shell test -n "$$(ldd {/usr,}/lib64/libncursesw.so.5 2>/dev/null | grep libtinfo)" && echo "-ltinfo" || echo "-lncurses")

View File

@ -7,33 +7,38 @@ VERSION = "0.1.1"
MAJOR := $(shell echo ${VERSION} | cut -d. -f1) MAJOR := $(shell echo ${VERSION} | cut -d. -f1)
LIBDIR = /usr/local/lib64 LIBDIR = /usr/local/lib64
INCLUDEDIR = /usr/local/include/final INCLUDEDIR = /usr/local/include/final
INCLUDE_HEADERS = fapp.h \ INCLUDE_HEADERS = \
fbuttongroup.h \ fapp.h \
fbutton.h \ fbuttongroup.h \
fcheckbox.h \ fbutton.h \
fswitch.h \ fcheckbox.h \
fdialog.h \ fswitch.h \
fevent.h \ fdialog.h \
ffiledialog.h \ fevent.h \
final.h \ ffiledialog.h \
flabel.h \ final.h \
flineedit.h \ flabel.h \
flistbox.h \ flineedit.h \
fmessagebox.h \ flistbox.h \
fobject.h \ fmenu.h \
foptimove.h \ fmenubar.h \
fpoint.h \ fradiomenuitem.h \
fprogressbar.h \ fcheckmenuitem.h \
fradiobutton.h \ fmessagebox.h \
frect.h \ fobject.h \
fscrollbar.h \ foptimove.h \
fstatusbar.h \ fpoint.h \
fstring.h \ fprogressbar.h \
fterm.h \ fradiobutton.h \
ftextview.h \ frect.h \
ftogglebutton.h \ fscrollbar.h \
fwidget.h \ fstatusbar.h \
fwindow.h fstring.h \
fterm.h \
ftextview.h \
ftogglebutton.h \
fwidget.h \
fwindow.h
# compiler parameter # compiler parameter
CXX = g++ CXX = g++
@ -45,32 +50,39 @@ GPM = -D F_HAVE_LIBGPM
VER = -D F_VERSION=$(VERSION) VER = -D F_VERSION=$(VERSION)
RM = rm -f RM = rm -f
LIB = libfinal.so LIB = libfinal.so
OBJS = fstring.o \ OBJS = \
fpoint.o \ fstring.o \
frect.o \ fpoint.o \
fscrollbar.o \ frect.o \
fprogressbar.o \ fscrollbar.o \
flineedit.o \ fprogressbar.o \
fbutton.o \ flineedit.o \
fbuttongroup.o \ fbutton.o \
ftogglebutton.o \ fbuttongroup.o \
fradiobutton.o \ ftogglebutton.o \
fcheckbox.o \ fradiobutton.o \
fswitch.o \ fcheckbox.o \
flabel.o \ fswitch.o \
flistbox.o \ flabel.o \
fdialog.o \ flistbox.o \
fwindow.o \ fmenu.o \
fmessagebox.o \ fmenubar.o \
ffiledialog.o \ fmenuitem.o \
ftextview.o \ fradiomenuitem.o \
fstatusbar.o \ fcheckmenuitem.o \
fterm.o \ fmenulist.o \
fevent.o \ fdialog.o \
foptimove.o \ fwindow.o \
fapp.o \ fmessagebox.o \
fwidget.o \ ffiledialog.o \
fobject.o ftextview.o \
fstatusbar.o \
fterm.o \
fevent.o \
foptimove.o \
fapp.o \
fwidget.o \
fobject.o
TERMCAP := $(shell test -n "$$(ldd {/usr,}/lib64/libncursesw.so.5 2>/dev/null | grep libtinfo)" && echo "-ltinfo" || echo "-lncurses") TERMCAP := $(shell test -n "$$(ldd {/usr,}/lib64/libncursesw.so.5 2>/dev/null | grep libtinfo)" && echo "-ltinfo" || echo "-lncurses")

View File

@ -132,9 +132,10 @@ am_libfinal_la_OBJECTS = fstring.lo fpoint.lo frect.lo fscrollbar.lo \
fprogressbar.lo flineedit.lo fbutton.lo fbuttongroup.lo \ fprogressbar.lo flineedit.lo fbutton.lo fbuttongroup.lo \
ftogglebutton.lo fradiobutton.lo fcheckbox.lo fswitch.lo \ ftogglebutton.lo fradiobutton.lo fcheckbox.lo fswitch.lo \
flabel.lo flistbox.lo fmenu.lo fmenubar.lo fmenuitem.lo \ flabel.lo flistbox.lo fmenu.lo fmenubar.lo fmenuitem.lo \
fmenulist.lo fdialog.lo fwindow.lo fmessagebox.lo \ fradiomenuitem.lo fcheckmenuitem.lo fmenulist.lo fdialog.lo \
ffiledialog.lo ftextview.lo fstatusbar.lo fterm.lo fevent.lo \ fwindow.lo fmessagebox.lo ffiledialog.lo ftextview.lo \
foptimove.lo fapp.lo fwidget.lo fobject.lo fstatusbar.lo fterm.lo fevent.lo foptimove.lo fapp.lo \
fwidget.lo fobject.lo
libfinal_la_OBJECTS = $(am_libfinal_la_OBJECTS) libfinal_la_OBJECTS = $(am_libfinal_la_OBJECTS)
AM_V_lt = $(am__v_lt_@AM_V@) AM_V_lt = $(am__v_lt_@AM_V@)
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
@ -389,6 +390,8 @@ libfinal_la_SOURCES = \
fmenu.cpp \ fmenu.cpp \
fmenubar.cpp \ fmenubar.cpp \
fmenuitem.cpp \ fmenuitem.cpp \
fradiomenuitem.cpp \
fcheckmenuitem.cpp \
fmenulist.cpp \ fmenulist.cpp \
fdialog.cpp \ fdialog.cpp \
fwindow.cpp \ fwindow.cpp \
@ -425,6 +428,8 @@ finalcutinclude_HEADERS = \
fmenu.h \ fmenu.h \
fmenubar.h \ fmenubar.h \
fmenuitem.h \ fmenuitem.h \
fradiomenuitem.h \
fcheckmenuitem.h \
fmenulist.h \ fmenulist.h \
fmessagebox.h \ fmessagebox.h \
fobject.h \ fobject.h \
@ -526,6 +531,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fbutton.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fbutton.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fbuttongroup.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fbuttongroup.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fcheckbox.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fcheckbox.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fcheckmenuitem.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fdialog.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fdialog.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fevent.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fevent.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ffiledialog.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ffiledialog.Plo@am__quote@
@ -542,6 +548,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fpoint.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fpoint.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fprogressbar.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fprogressbar.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fradiobutton.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fradiobutton.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fradiomenuitem.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/frect.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/frect.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fscrollbar.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fscrollbar.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstatusbar.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fstatusbar.Plo@am__quote@

View File

@ -107,7 +107,8 @@ static uInt character[][fc::NUM_OF_ENCODINGS] =
{0x1ae9, 0, 0xe9, 0}, // ◤ - NF_rev_down_pointing_triangle2 {0x1ae9, 0, 0xe9, 0}, // ◤ - NF_rev_down_pointing_triangle2
{0x1af4, 0, 0xf4, 0}, // ] - NF_rev_menu_button3 {0x1af4, 0, 0xf4, 0}, // ] - NF_rev_menu_button3
{0x1af5, 0, 0xf5, 0}, // ] - NF_shadow_box_right {0x1af5, 0, 0xf5, 0}, // ] - NF_shadow_box_right
{0x1afb, 0, 0xfb, 0} // ✓ - NF_check_mark {0x1afb, 0, 0xfb, 0}, // ✓ - NF_check_mark
{0x221a, 0, 0xfb, 'x'} // √ - square root
}; };
const int lastCharItem = int(sizeof(character) / sizeof(character[0])) - 1; const int lastCharItem = int(sizeof(character) / sizeof(character[0])) - 1;

74
src/fcheckmenuitem.cpp Normal file
View File

@ -0,0 +1,74 @@
// 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;
if ( parent )
{
if ( isMenu(parent) ) // Parent is menu
{
FMenu* menu_ptr = dynamic_cast<FMenu*>(parent);
if ( menu_ptr )
menu_ptr->has_checkable_items = true;
}
}
}
//----------------------------------------------------------------------
void FCheckMenuItem::processToggle()
{
emitCallback("toggled");
}
//----------------------------------------------------------------------
void FCheckMenuItem::processClicked()
{
checked = not checked;
processToggle();
emitCallback("clicked");
}

66
src/fcheckmenuitem.h Normal file
View File

@ -0,0 +1,66 @@
// File: fcheckmenuitem.h
// Provides: class FCheckMenuItem
//
// Inheritance diagram
// ═══════════════════
//
// ▕▔▔▔▔▔▔▔▔▔▏ ▕▔▔▔▔▔▔▔▔▔▏
// ▕ FObject ▏ ▕ FTerm ▏
// ▕▁▁▁▁▁▁▁▁▁▏ ▕▁▁▁▁▁▁▁▁▁▏
// ▲ ▲
// │ │
// └─────┬─────┘
// │
// ▕▔▔▔▔▔▔▔▔▔▏
// ▕ FWidget ▏
// ▕▁▁▁▁▁▁▁▁▁▏
// ▲
// │
// ▕▔▔▔▔▔▔▔▔▔▔▔▏
// ▕ FMenuItem ▏
// ▕▁▁▁▁▁▁▁▁▁▁▁▏
// ▲
// │
// ▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏* 1▕▔▔▔▔▔▔▔▏
// ▕ FCheckMenuItem ▏- - - - -▕ FMenu ▏
// ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏ ▕▁▁▁▁▁▁▁▏
#ifndef _FCHECKMENUITEM_H
#define _FCHECKMENUITEM_H
#include "fmenuitem.h"
//----------------------------------------------------------------------
// class FCheckMenuItem
//----------------------------------------------------------------------
#pragma pack(push)
#pragma pack(1)
class FCheckMenuItem : public FMenuItem
{
private:
FCheckMenuItem (const FCheckMenuItem&);
FCheckMenuItem& operator = (const FCheckMenuItem&);
void init (FWidget*);
void processToggle();
void processClicked();
public:
explicit FCheckMenuItem (FWidget* = 0);
FCheckMenuItem (FString&, FWidget* = 0);
FCheckMenuItem (const std::string&, FWidget* = 0);
FCheckMenuItem (const char*, FWidget* = 0);
virtual ~FCheckMenuItem();
const char* getClassName() const;
};
#pragma pack(pop)
// FCheckMenuItem inline functions
//----------------------------------------------------------------------
inline const char* FCheckMenuItem::getClassName() const
{ return "FCheckMenuItem"; }
#endif // _FCHECKMENUITEM_H

View File

@ -165,7 +165,8 @@ class fc
NF_rev_down_pointing_triangle2 = 0x1ae9, // ◤ NF_rev_down_pointing_triangle2 = 0x1ae9, // ◤
NF_rev_menu_button3 = 0x1af4, // ] NF_rev_menu_button3 = 0x1af4, // ]
NF_shadow_box_right = 0x1af5, // ] NF_shadow_box_right = 0x1af5, // ]
NF_check_mark = 0x1afb // ✓ NF_check_mark = 0x1afb, // ✓
SquareRoot = 0x221a // √
}; };
// keyboard - single keys // keyboard - single keys

View File

@ -22,6 +22,8 @@
#include "fmenu.h" #include "fmenu.h"
#include "fmenubar.h" #include "fmenubar.h"
#include "fmenuitem.h" #include "fmenuitem.h"
#include "fcheckmenuitem.h"
#include "fradiomenuitem.h"
#include "fstatusbar.h" #include "fstatusbar.h"
#include "fscrollbar.h" #include "fscrollbar.h"
#include "fprogressbar.h" #include "fprogressbar.h"

View File

@ -17,6 +17,7 @@ FMenu::FMenu(FWidget* parent)
, super_menu(0) , super_menu(0)
, maxItemWidth(0) , maxItemWidth(0)
, mouse_down(false) , mouse_down(false)
, has_checkable_items(false)
{ {
init(parent); init(parent);
} }
@ -28,6 +29,7 @@ FMenu::FMenu (FString& txt, FWidget* parent)
, super_menu(0) , super_menu(0)
, maxItemWidth(0) , maxItemWidth(0)
, mouse_down(false) , mouse_down(false)
, has_checkable_items(false)
{ {
item = new FMenuItem(txt, parent); item = new FMenuItem(txt, parent);
init(parent); init(parent);
@ -40,6 +42,7 @@ FMenu::FMenu (const std::string& txt, FWidget* parent)
, super_menu(0) , super_menu(0)
, maxItemWidth(0) , maxItemWidth(0)
, mouse_down(false) , mouse_down(false)
, has_checkable_items(false)
{ {
item = new FMenuItem(txt, parent); item = new FMenuItem(txt, parent);
init(parent); init(parent);
@ -52,6 +55,7 @@ FMenu::FMenu (const char* txt, FWidget* parent)
, super_menu(0) , super_menu(0)
, maxItemWidth(0) , maxItemWidth(0)
, mouse_down(false) , mouse_down(false)
, has_checkable_items(false)
{ {
item = new FMenuItem(txt, parent); item = new FMenuItem(txt, parent);
init(parent); init(parent);
@ -141,6 +145,9 @@ void FMenu::menu_dimension()
item_width += accel_len + 2; item_width += accel_len + 2;
} }
if ( has_checkable_items )
item_width++;
if ( item_width > maxItemWidth ) if ( item_width > maxItemWidth )
maxItemWidth = item_width; maxItemWidth = item_width;
@ -178,6 +185,13 @@ bool FMenu::isMenu (FWidget* w) const
, const_cast<char*>("FMenu") ) == 0 ); , const_cast<char*>("FMenu") ) == 0 );
} }
//----------------------------------------------------------------------
bool FMenu::isRadioMenuItem (FWidget* w) const
{
return bool ( strcmp ( w->getClassName()
, const_cast<char*>("FRadioMenuItem") ) == 0 );
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenu::hideSubMenus() void FMenu::hideSubMenus()
{ {
@ -483,11 +497,14 @@ void FMenu::drawMenuShadow()
void FMenu::drawItems() void FMenu::drawItems()
{ {
std::vector<FMenuItem*>::const_iterator iter, end; std::vector<FMenuItem*>::const_iterator iter, end;
int c = 0;
int y = 0; int y = 0;
iter = itemlist.begin(); iter = itemlist.begin();
end = itemlist.end(); end = itemlist.end();
if ( has_checkable_items )
c = 1;
while ( iter != end ) while ( iter != end )
{ {
wchar_t* src; wchar_t* src;
@ -498,6 +515,9 @@ void FMenu::drawItems()
int hotkeypos, to_char; int hotkeypos, to_char;
int accel_key = (*iter)->accel_key; int accel_key = (*iter)->accel_key;
bool is_enabled = (*iter)->isEnabled(); bool is_enabled = (*iter)->isEnabled();
bool is_checked = (*iter)->isChecked();
bool is_checkable = (*iter)->checkable;
bool is_radio_btn = (*iter)->radio_button;
bool is_selected = (*iter)->isSelected(); bool is_selected = (*iter)->isSelected();
bool is_noUnderline = (((*iter)->getFlags() & NO_UNDERLINE) != 0); bool is_noUnderline = (((*iter)->getFlags() & NO_UNDERLINE) != 0);
bool is_separator = (*iter)->isSeparator(); bool is_separator = (*iter)->isSeparator();
@ -534,6 +554,34 @@ void FMenu::drawItems()
} }
gotoxy (xpos+xmin, ypos+ymin+y); gotoxy (xpos+xmin, ypos+ymin+y);
setColor (foregroundColor, backgroundColor); setColor (foregroundColor, backgroundColor);
if ( has_checkable_items )
{
if ( is_checkable )
{
if ( is_checked )
{
if ( is_radio_btn )
{
print (fc::Bullet);
}
else
{
if ( isNewFont() )
print (fc::NF_check_mark);
else
print (fc::SquareRoot);
}
}
else
{
setColor (wc.menu_inactive_fg, backgroundColor);
print ('-');
setColor (foregroundColor, backgroundColor);
}
}
else
print (' ');
}
print (' '); print (' ');
txt = (*iter)->getText(); txt = (*iter)->getText();
@ -587,18 +635,18 @@ void FMenu::drawItems()
{ {
FString accel_name (getKeyName(accel_key)); FString accel_name (getKeyName(accel_key));
int accel_len = int(accel_name.getLength()); int accel_len = int(accel_name.getLength());
int len = maxItemWidth - (to_char + accel_len + 2); int len = maxItemWidth - (to_char + accel_len + c + 2);
if ( len > 0 ) if ( len > 0 )
{ {
FString line(len, wchar_t(' ')); FString spaces (len, wchar_t(' '));
print (line + accel_name); print (spaces + accel_name);
to_char = maxItemWidth - 2; to_char = maxItemWidth - (c + 2);
} }
} }
if ( is_selected ) if ( is_selected )
{ {
for (uInt i=uInt(to_char); i < maxItemWidth-1; i++) for (uInt i=uInt(to_char+c); i < maxItemWidth-1; i++)
print (' '); print (' ');
} }
@ -950,6 +998,7 @@ void FMenu::onMouseMove (FMouseEvent* ev)
ev = new FMouseEvent (MouseMove_Event, p, g, b); ev = new FMouseEvent (MouseMove_Event, p, g, b);
setClickedWidget(menubar); setClickedWidget(menubar);
FMenuBar* mbar = reinterpret_cast<FMenuBar*>(menubar); FMenuBar* mbar = reinterpret_cast<FMenuBar*>(menubar);
mbar->mouse_down = true;
mbar->onMouseMove(ev); mbar->onMouseMove(ev);
delete ev; delete ev;
} }
@ -1042,6 +1091,34 @@ void FMenu::cb_menuitem_activated (FWidget* widget, void*)
} }
} }
//----------------------------------------------------------------------
void FMenu::cb_menuitem_toggled (FWidget* widget, void*)
{
FMenuItem* menuitem = static_cast<FMenuItem*>(widget);
std::vector<FMenuItem*>::const_iterator iter, end;
if ( ! has_checkable_items )
return;
if ( ! menuitem->isChecked() )
return;
if ( itemlist.empty() )
return;
iter = itemlist.begin();
end = itemlist.end();
while ( iter != end )
{
if ( (*iter) != menuitem
&& (*iter)->isChecked()
&& isRadioMenuItem(*iter) )
{
(*iter)->unsetChecked();
}
++iter;
}
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FMenu::setTransparentShadow (bool on) bool FMenu::setTransparentShadow (bool on)
{ {
@ -1065,13 +1142,3 @@ bool FMenu::setTransparentShadow (bool on)
return on; return on;
} }
//----------------------------------------------------------------------
void FMenu::cb_menuitem_deactivated (FWidget* widget, void*)
{
FMenuItem* menuitem = static_cast<FMenuItem*>(widget);
if ( menuitem->hasMenu() )
{
//beep();
}
}

View File

@ -8,15 +8,15 @@
// ▕ FObject ▏ ▕ FTerm ▏ // ▕ FObject ▏ ▕ FTerm ▏
// ▕▁▁▁▁▁▁▁▁▁▏ ▕▁▁▁▁▁▁▁▁▁▏ // ▕▁▁▁▁▁▁▁▁▁▏ ▕▁▁▁▁▁▁▁▁▁▏
// ▲ ▲ // ▲ ▲
// │ │ // │ │ *▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏
// └─────┬─────┘ // └─────┬─────┘ ┌ - -▕ FRadioMenuItem ▏
// │ // │ : ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏
// ▕▔▔▔▔▔▔▔▔▔▏ // ▕▔▔▔▔▔▔▔▔▔▏ :
// ▕ FWidget ▏ // ▕ FWidget ▏ : *▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏
// ▕▁▁▁▁▁▁▁▁▁▏ // ▕▁▁▁▁▁▁▁▁▁▏ ├ - -▕ FCheckMenuItem ▏
// ▲ // ▲ : ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏
// │ // │ 1 :
// ▕▔▔▔▔▔▔▔▔▔▏ ▕▔▔▔▔▔▔▔▔▔▔▔▏ ▕▔▔▔▔▔▔▔▔▔▔▔▏ // ▕▔▔▔▔▔▔▔▔▔▏ ▕▔▔▔▔▔▔▔▔▔▔▔▏- ┘ ▕▔▔▔▔▔▔▔▔▔▔▔▏
// ▕ FWindow ▏ ▕ FMenuList ▏- - - -▕ FMenuItem ▏ // ▕ FWindow ▏ ▕ FMenuList ▏- - - -▕ FMenuItem ▏
// ▕▁▁▁▁▁▁▁▁▁▏ ▕▁▁▁▁▁▁▁▁▁▁▁▏1 *▕▁▁▁▁▁▁▁▁▁▁▁▏ // ▕▁▁▁▁▁▁▁▁▁▏ ▕▁▁▁▁▁▁▁▁▁▁▁▏1 *▕▁▁▁▁▁▁▁▁▁▁▁▏
// ▲ ▲ 1: // ▲ ▲ 1:
@ -50,6 +50,7 @@ class FMenu : public FWindow, public FMenuList
FWidget* super_menu; FWidget* super_menu;
uInt maxItemWidth; uInt maxItemWidth;
bool mouse_down; bool mouse_down;
bool has_checkable_items;
private: private:
FMenu (const FMenu&); FMenu (const FMenu&);
@ -58,6 +59,7 @@ class FMenu : public FWindow, public FMenuList
void menu_dimension(); void menu_dimension();
bool isMenuBar (FWidget*) const; bool isMenuBar (FWidget*) const;
bool isMenu (FWidget*) const; bool isMenu (FWidget*) const;
bool isRadioMenuItem (FWidget*) const;
FWidget* getSuperMenu() const; FWidget* getSuperMenu() const;
void setSuperMenu (FWidget*); void setSuperMenu (FWidget*);
void hideSubMenus(); void hideSubMenus();
@ -116,12 +118,14 @@ class FMenu : public FWindow, public FMenuList
void setText (const std::string&); void setText (const std::string&);
void setText (const char*); void setText (const char*);
void cb_menuitem_activated (FWidget*, void*); void cb_menuitem_activated (FWidget*, void*);
void cb_menuitem_deactivated (FWidget*, void*); void cb_menuitem_toggled (FWidget*, void*);
private: private:
friend class FApplication; friend class FApplication;
friend class FCheckMenuItem;
friend class FMenuBar; friend class FMenuBar;
friend class FMenuItem; friend class FMenuItem;
friend class FRadioMenuItem;
}; };
#pragma pack(pop) #pragma pack(pop)

View File

@ -442,6 +442,21 @@ void FMenuBar::adjustSize()
FWidget::adjustSize(); FWidget::adjustSize();
} }
//----------------------------------------------------------------------
void FMenuBar::leaveMenuBar()
{
resetMenu();
redraw();
activatePrevWindow();
getActiveWindow()->getFocusWidget()->setFocus();
getActiveWindow()->redraw();
if ( statusBar() )
statusBar()->drawMessage();
updateTerminal();
flush_out();
drop_down = false;
}
// public methods of FMenuBar // public methods of FMenuBar
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuBar::onKeyPress (FKeyEvent* ev) void FMenuBar::onKeyPress (FKeyEvent* ev)
@ -494,16 +509,7 @@ void FMenuBar::onKeyPress (FKeyEvent* ev)
case fc::Fkey_escape: case fc::Fkey_escape:
case fc::Fkey_escape_mintty: case fc::Fkey_escape_mintty:
resetMenu(); leaveMenuBar();
redraw();
activatePrevWindow();
getActiveWindow()->getFocusWidget()->setFocus();
getActiveWindow()->redraw();
if ( statusBar() )
statusBar()->drawMessage();
updateTerminal();
flush_out();
drop_down = false;
ev->accept(); ev->accept();
break; break;
@ -519,11 +525,7 @@ void FMenuBar::onMouseDown (FMouseEvent* ev)
{ {
mouse_down = false; mouse_down = false;
if ( ! itemlist.empty() ) if ( ! itemlist.empty() )
{ leaveMenuBar();
unselectItem();
redraw();
drop_down = false;
}
return; return;
} }
@ -675,6 +677,8 @@ void FMenuBar::onMouseUp (FMouseEvent* ev)
} }
++iter; ++iter;
} }
if ( ! hasSelectedItem() )
leaveMenuBar();
} }
} }
} }
@ -827,11 +831,6 @@ void FMenuBar::setGeometry (int xx, int yy, int ww, int hh, bool adjust)
resizeArea (vmenubar); resizeArea (vmenubar);
} }
//----------------------------------------------------------------------
void FMenuBar::cb_item_activated (FWidget*, void*)
{
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuBar::cb_item_deactivated (FWidget* widget, void*) void FMenuBar::cb_item_deactivated (FWidget* widget, void*)
{ {

View File

@ -61,6 +61,7 @@ class FMenuBar : public FWindow, public FMenuList
void draw(); void draw();
void drawItems(); void drawItems();
void adjustSize(); void adjustSize();
void leaveMenuBar();
public: public:
explicit FMenuBar (FWidget* = 0); // constructor explicit FMenuBar (FWidget* = 0); // constructor
@ -77,7 +78,6 @@ class FMenuBar : public FWindow, public FMenuList
// make every setGeometry from FWidget available // make every setGeometry from FWidget available
using FWidget::setGeometry; using FWidget::setGeometry;
void setGeometry (int, int, int, int, bool = true); void setGeometry (int, int, int, int, bool = true);
void cb_item_activated (FWidget*, void*);
void cb_item_deactivated (FWidget*, void*); void cb_item_deactivated (FWidget*, void*);
private: private:

View File

@ -19,12 +19,14 @@ FMenuItem::FMenuItem (FWidget* parent)
, text() , text()
, selected(false) , selected(false)
, separator(false) , separator(false)
, checkable(false)
, checked(false) , checked(false)
, text_length(0) , text_length(0)
, hotkey(0) , hotkey(0)
, accel_key(0) , accel_key(0)
, menu(0) , menu(0)
, super_menu(0) , super_menu(0)
, radio_button(false)
{ {
init (parent); init (parent);
} }
@ -35,12 +37,14 @@ FMenuItem::FMenuItem (FString& txt, FWidget* parent)
, text(txt) , text(txt)
, selected(false) , selected(false)
, separator(false) , separator(false)
, checkable(false)
, checked(false) , checked(false)
, text_length(0) , text_length(0)
, hotkey(0) , hotkey(0)
, accel_key(0) , accel_key(0)
, menu(0) , menu(0)
, super_menu(0) , super_menu(0)
, radio_button(false)
{ {
init (parent); init (parent);
} }
@ -51,12 +55,14 @@ FMenuItem::FMenuItem (const std::string& txt, FWidget* parent)
, text(txt) , text(txt)
, selected(false) , selected(false)
, separator(false) , separator(false)
, checkable(false)
, checked(false) , checked(false)
, text_length(0) , text_length(0)
, hotkey(0) , hotkey(0)
, accel_key(0) , accel_key(0)
, menu(0) , menu(0)
, super_menu(0) , super_menu(0)
, radio_button(false)
{ {
init (parent); init (parent);
} }
@ -67,27 +73,32 @@ FMenuItem::FMenuItem (const char* txt, FWidget* parent)
, text(txt) , text(txt)
, selected(false) , selected(false)
, separator(false) , separator(false)
, checkable(false)
, checked(false) , checked(false)
, text_length(0) , text_length(0)
, hotkey(0) , hotkey(0)
, accel_key(0) , accel_key(0)
, menu(0) , menu(0)
, super_menu(0) , super_menu(0)
, radio_button(false)
{ {
init (parent); init (parent);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FMenuItem::FMenuItem (int k, FString& txt, FWidget* parent) FMenuItem::FMenuItem (int k, FString& txt, FWidget* parent)
: FWidget(parent) : FWidget(parent)
, text(txt) , text(txt)
, selected(false) , selected(false)
, separator(false) , separator(false)
, checkable(false)
, checked(false) , checked(false)
, text_length(0) , text_length(0)
, hotkey(0) , hotkey(0)
, accel_key(k) , accel_key(k)
, menu(0) , menu(0)
, super_menu(0) , super_menu(0)
, radio_button(false)
{ {
init (parent); init (parent);
} }
@ -98,12 +109,14 @@ FMenuItem::FMenuItem (int k, const std::string& txt, FWidget* parent)
, text(txt) , text(txt)
, selected(false) , selected(false)
, separator(false) , separator(false)
, checkable(false)
, checked(false) , checked(false)
, text_length(0) , text_length(0)
, hotkey(0) , hotkey(0)
, accel_key(k) , accel_key(k)
, menu(0) , menu(0)
, super_menu(0) , super_menu(0)
, radio_button(false)
{ {
init (parent); init (parent);
} }
@ -114,15 +127,18 @@ FMenuItem::FMenuItem (int k, const char* txt, FWidget* parent)
, text(txt) , text(txt)
, selected(false) , selected(false)
, separator(false) , separator(false)
, checkable(false)
, checked(false) , checked(false)
, text_length(0) , text_length(0)
, hotkey(0) , hotkey(0)
, accel_key(k) , accel_key(k)
, menu(0) , menu(0)
, super_menu(0) , super_menu(0)
, radio_button(false)
{ {
init (parent); init (parent);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FMenuItem::~FMenuItem() // destructor FMenuItem::~FMenuItem() // destructor
{ {
@ -164,15 +180,10 @@ void FMenuItem::init (FWidget* parent)
if ( hotkey ) if ( hotkey )
menubar_ptr->addAccelerator (fc::Fmkey_meta + tolower(hotkey), this); menubar_ptr->addAccelerator (fc::Fmkey_meta + tolower(hotkey), this);
this->addCallback
(
"activate",
_METHOD_CALLBACK (getSuperMenu(), &FMenuBar::cb_item_activated)
);
this->addCallback this->addCallback
( (
"deactivate", "deactivate",
_METHOD_CALLBACK (getSuperMenu(), &FMenuBar::cb_item_deactivated) _METHOD_CALLBACK (parent, &FMenuBar::cb_item_deactivated)
); );
} }
else if ( isMenu(parent) ) // Parent is menu else if ( isMenu(parent) ) // Parent is menu
@ -184,12 +195,7 @@ void FMenuItem::init (FWidget* parent)
this->addCallback this->addCallback
( (
"activate", "activate",
_METHOD_CALLBACK (getSuperMenu(), &FMenu::cb_menuitem_activated) _METHOD_CALLBACK (parent, &FMenu::cb_menuitem_activated)
);
this->addCallback
(
"deactivate",
_METHOD_CALLBACK (getSuperMenu(), &FMenu::cb_menuitem_deactivated)
); );
} }
} }
@ -225,20 +231,6 @@ uChar FMenuItem::hotKey()
return 0; return 0;
} }
//----------------------------------------------------------------------
bool FMenuItem::isMenuBar (FWidget* w) const
{
return bool ( strcmp ( w->getClassName()
, const_cast<char*>("FMenuBar") ) == 0 );
}
//----------------------------------------------------------------------
bool FMenuItem::isMenu (FWidget* w) const
{
return bool ( strcmp ( w->getClassName()
, const_cast<char*>("FMenu") ) == 0 );
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuItem::processActivate() void FMenuItem::processActivate()
{ {
@ -257,6 +249,23 @@ void FMenuItem::processClicked()
emitCallback("clicked"); emitCallback("clicked");
} }
// protected methods of FMenuItem
//----------------------------------------------------------------------
bool FMenuItem::isMenuBar (FWidget* w) const
{
return bool ( strcmp ( w->getClassName()
, const_cast<char*>("FMenuBar") ) == 0 );
}
//----------------------------------------------------------------------
bool FMenuItem::isMenu (FWidget* w) const
{
return bool ( strcmp ( w->getClassName()
, const_cast<char*>("FMenu") ) == 0 );
}
// public methods of FMenuItem // public methods of FMenuItem
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuItem::addAccelerator (int key, FWidget* obj) void FMenuItem::addAccelerator (int key, FWidget* obj)

View File

@ -16,11 +16,11 @@
// ▕▁▁▁▁▁▁▁▁▁▏ // ▕▁▁▁▁▁▁▁▁▁▏
// ▲ // ▲
// │ // │
// ▕▔▔▔▔▔▔▔▔▔▔▔▏1 *▕▔▔▔▔▔▔▔▏ // ▕▔▔▔▔▔▔▔▔▔▔▔▏* 1▕▔▔▔▔▔▔▔▏
// ▕ FMenuItem ▏-┬- - - -▕ FMenu ▏ // ▕ FMenuItem ▏-┬- - - -▕ FMenu ▏
// ▕▁▁▁▁▁▁▁▁▁▁▁▏ : ▕▁▁▁▁▁▁▁▏ // ▕▁▁▁▁▁▁▁▁▁▁▁▏ : ▕▁▁▁▁▁▁▁▏
// : // :
// : *▕▔▔▔▔▔▔▔▔▔▔▔▏ // : 1▕▔▔▔▔▔▔▔▔▔▔▔▏
// └- - - -▕ FMenuList ▏ // └- - - -▕ FMenuList ▏
// ▕▁▁▁▁▁▁▁▁▁▁▁▏ // ▕▁▁▁▁▁▁▁▁▁▁▁▏
@ -42,29 +42,33 @@ class FMenuList;
class FMenuItem : public FWidget class FMenuItem : public FWidget
{ {
private: protected:
FString text; FString text;
bool selected; bool selected;
bool separator; bool separator;
bool checkable;
bool checked; bool checked;
uInt text_length; uInt text_length;
int hotkey; int hotkey;
int accel_key; int accel_key;
FMenu* menu; FMenu* menu;
FWidget* super_menu; FWidget* super_menu;
bool radio_button;
private: private:
FMenuItem (const FMenuItem&); FMenuItem (const FMenuItem&);
FMenuItem& operator = (const FMenuItem&); FMenuItem& operator = (const FMenuItem&);
void init (FWidget*); void init (FWidget*);
uChar hotKey(); uChar hotKey();
void processActivate();
void processDeactivate();
virtual void processClicked();
protected:
bool isMenuBar (FWidget*) const; bool isMenuBar (FWidget*) const;
bool isMenu (FWidget*) const; bool isMenu (FWidget*) const;
FWidget* getSuperMenu() const; FWidget* getSuperMenu() const;
void setSuperMenu (FWidget*); void setSuperMenu (FWidget*);
void processActivate();
void processDeactivate();
void processClicked();
public: public:
explicit FMenuItem (FWidget* = 0); explicit FMenuItem (FWidget* = 0);
@ -75,6 +79,7 @@ class FMenuItem : public FWidget
FMenuItem (int, const std::string&, FWidget* = 0); FMenuItem (int, const std::string&, FWidget* = 0);
FMenuItem (int, const char*, FWidget* = 0); FMenuItem (int, const char*, FWidget* = 0);
virtual ~FMenuItem(); virtual ~FMenuItem();
const char* getClassName() const;
// make every addAccelerator from FWidget available // make every addAccelerator from FWidget available
using FWidget::addAccelerator; using FWidget::addAccelerator;
@ -125,6 +130,10 @@ class FMenuItem : public FWidget
// FMenuItem inline functions // FMenuItem inline functions
//----------------------------------------------------------------------
inline const char* FMenuItem::getClassName() const
{ return "FMenuItem"; }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline FWidget* FMenuItem::getSuperMenu() const inline FWidget* FMenuItem::getSuperMenu() const
{ return super_menu; } { return super_menu; }

View File

@ -7,7 +7,14 @@
// ▕▔▔▔▔▔▔▔▔▔▔▔▏1 *▕▔▔▔▔▔▔▔▔▔▔▔▏ // ▕▔▔▔▔▔▔▔▔▔▔▔▏1 *▕▔▔▔▔▔▔▔▔▔▔▔▏
// ▕ FMenuList ▏- - - -▕ FMenuItem ▏ // ▕ FMenuList ▏- - - -▕ FMenuItem ▏
// ▕▁▁▁▁▁▁▁▁▁▁▁▏ ▕▁▁▁▁▁▁▁▁▁▁▁▏ // ▕▁▁▁▁▁▁▁▁▁▁▁▏ ▕▁▁▁▁▁▁▁▁▁▁▁▏
// :1
// : *▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏
// ├- - - - - - -▕ FRadioMenuItem ▏
// : ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏
// :
// : *▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏
// └- - - - - - -▕ FCheckMenuItem ▏
// ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏
#ifndef _FMENULIST_H #ifndef _FMENULIST_H
#define _FMENULIST_H #define _FMENULIST_H
@ -15,18 +22,6 @@
#include "fmenuitem.h" #include "fmenuitem.h"
#include "fwidget.h" #include "fwidget.h"
/*
FWindow FMenuBar
FMenuList FMenu
:
----------------- FMenuItem
*/
//---------------------------------------------------------------------- //----------------------------------------------------------------------
// class FMenuList // class FMenuList

85
src/fradiomenuitem.cpp Normal file
View File

@ -0,0 +1,85 @@
// 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);
}
//----------------------------------------------------------------------
FRadioMenuItem::FRadioMenuItem (FString& txt, FWidget* parent)
: FMenuItem(txt, parent)
{
init (parent);
}
//----------------------------------------------------------------------
FRadioMenuItem::FRadioMenuItem (const std::string& txt, FWidget* parent)
: FMenuItem(txt, parent)
{
init (parent);
}
//----------------------------------------------------------------------
FRadioMenuItem::FRadioMenuItem (const char* txt, FWidget* parent)
: FMenuItem(txt, parent)
{
init (parent);
}
//----------------------------------------------------------------------
FRadioMenuItem::~FRadioMenuItem() // destructor
{ }
// private methods of FRadioMenuItem
//----------------------------------------------------------------------
void FRadioMenuItem::init (FWidget* parent)
{
checkable = true;
radio_button = true;
if ( parent )
{
if ( isMenu(parent) ) // Parent is menu
{
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)
);
}
}
}
//----------------------------------------------------------------------
void FRadioMenuItem::processToggle()
{
emitCallback("toggled");
}
//----------------------------------------------------------------------
void FRadioMenuItem::processClicked()
{
if ( ! checked )
{
checked = true;
processToggle();
}
emitCallback("clicked");
}

66
src/fradiomenuitem.h Normal file
View File

@ -0,0 +1,66 @@
// File: fradiomenuitem.h
// Provides: class FRadioMenuItem
//
// Inheritance diagram
// ═══════════════════
//
// ▕▔▔▔▔▔▔▔▔▔▏ ▕▔▔▔▔▔▔▔▔▔▏
// ▕ FObject ▏ ▕ FTerm ▏
// ▕▁▁▁▁▁▁▁▁▁▏ ▕▁▁▁▁▁▁▁▁▁▏
// ▲ ▲
// │ │
// └─────┬─────┘
// │
// ▕▔▔▔▔▔▔▔▔▔▏
// ▕ FWidget ▏
// ▕▁▁▁▁▁▁▁▁▁▏
// ▲
// │
// ▕▔▔▔▔▔▔▔▔▔▔▔▏
// ▕ FMenuItem ▏
// ▕▁▁▁▁▁▁▁▁▁▁▁▏
// ▲
// │
// ▕▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▏* 1▕▔▔▔▔▔▔▔▏
// ▕ FRadioMenuItem ▏- - - - -▕ FMenu ▏
// ▕▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▏ ▕▁▁▁▁▁▁▁▏
#ifndef _FRADIOMENUITEM_H
#define _FRADIOMENUITEM_H
#include "fmenuitem.h"
//----------------------------------------------------------------------
// class FRadioMenuItem
//----------------------------------------------------------------------
#pragma pack(push)
#pragma pack(1)
class FRadioMenuItem : public FMenuItem
{
private:
FRadioMenuItem (const FRadioMenuItem&);
FRadioMenuItem& operator = (const FRadioMenuItem&);
void init (FWidget*);
void processToggle();
void processClicked();
public:
explicit FRadioMenuItem (FWidget* = 0);
FRadioMenuItem (FString&, FWidget* = 0);
FRadioMenuItem (const std::string&, FWidget* = 0);
FRadioMenuItem (const char*, FWidget* = 0);
virtual ~FRadioMenuItem();
const char* getClassName() const;
};
#pragma pack(pop)
// FRadioMenuItem inline functions
//----------------------------------------------------------------------
inline const char* FRadioMenuItem::getClassName() const
{ return "FRadioMenuItem"; }
#endif // _FRADIOMENUITEM_H

View File

@ -24,7 +24,7 @@ FString::FString (int len)
, bufsize(0) , bufsize(0)
, c_string(0) , c_string(0)
{ {
if ( len >= 0 ) if ( len > 0 )
initLength(uInt(len)); initLength(uInt(len));
else else
initLength(0); initLength(0);
@ -47,7 +47,7 @@ FString::FString (int len, wchar_t c)
, bufsize(0) , bufsize(0)
, c_string(0) , c_string(0)
{ {
if ( len >= 0 ) if ( len > 0 )
_replace ( FString(uInt(len), c).string ); _replace ( FString(uInt(len), c).string );
else else
initLength(0); initLength(0);
@ -83,7 +83,7 @@ FString::FString (int len, char c)
bufsize = 0; bufsize = 0;
c_string = 0; c_string = 0;
if ( len >= 0 ) if ( len > 0 )
_replace ( FString(uInt(len), c).string ); _replace ( FString(uInt(len), c).string );
else else
initLength(0); initLength(0);