Improve menu accelerator keys

This commit is contained in:
Markus Gans 2015-11-12 01:33:16 +01:00
parent df83751be2
commit 6fd2e7c650
20 changed files with 500 additions and 325 deletions

View File

@ -1,3 +1,6 @@
2015-11-12 Markus Gans <guru.mail@muenster.de>
* Improve menu accelerator keys
2015-11-08 Markus Gans <guru.mail@muenster.de>
* Activate the previous window in case if the menu is open and
the mouse click has activated no window.

View File

@ -286,7 +286,7 @@ void FApplication::processKeyboardEvent()
if ( key != NEED_MORE_DATA )
{
if ( key == 0x0c ) // Ctrl-L (redraw the screen)
if ( key == fc::Fckey_l ) // Ctrl-L (redraw the screen)
redraw();
if ( key == fc::Fkey_mouse )

View File

@ -124,7 +124,7 @@ class FApplication : public FWidget
bool KeyPressed();
ssize_t readKey();
void processKeyboardEvent();
void getX11ButtonState (int button);
void getX11ButtonState (int);
bool parseX11Mouse();
bool parseSGRMouse();
bool parseUrxvtMouse();

View File

@ -51,7 +51,7 @@ FButton::FButton (const FString& txt, FWidget* parent)
//----------------------------------------------------------------------
FButton::~FButton() // destructor
{
delAccelerator (this);
delAccelerator();
delAllTimer();
}
@ -103,16 +103,16 @@ void FButton::setHotkeyAccelerator()
{
if ( isalpha(hotkey) || isdigit(hotkey) )
{
addAccelerator (tolower(hotkey), this);
addAccelerator (toupper(hotkey), this);
addAccelerator (tolower(hotkey));
addAccelerator (toupper(hotkey));
// Meta + hotkey
addAccelerator (0x20000e0+tolower(hotkey), this);
addAccelerator (fc::Fmkey_meta + tolower(hotkey));
}
else
addAccelerator (getHotkey(), this);
addAccelerator (getHotkey());
}
else
delAccelerator(this);
delAccelerator();
}
//----------------------------------------------------------------------
@ -120,7 +120,7 @@ inline void FButton::detectHotkey()
{
if ( isEnabled() )
{
delAccelerator (this);
delAccelerator();
setHotkeyAccelerator();
}
}
@ -499,7 +499,7 @@ bool FButton::setEnable (bool on)
else
{
flags &= ~ACTIVE;
delAccelerator (this);
delAccelerator();
}
updateButtonColor();
return on;

View File

@ -179,16 +179,16 @@ void FButtonGroup::setHotkeyAccelerator()
{
if ( isalpha(hotkey) || isdigit(hotkey) )
{
addAccelerator (tolower(hotkey), this);
addAccelerator (toupper(hotkey), this);
addAccelerator (tolower(hotkey));
addAccelerator (toupper(hotkey));
// Meta + hotkey
addAccelerator (0x20000e0 + tolower(hotkey), this);
addAccelerator (fc::Fmkey_meta + tolower(hotkey));
}
else
addAccelerator (getHotkey(), this);
addAccelerator (getHotkey());
}
else
delAccelerator(this);
delAccelerator();
}
//----------------------------------------------------------------------
@ -528,7 +528,7 @@ bool FButtonGroup::setEnable (bool on)
else
{
flags &= ~ACTIVE;
delAccelerator (this);
delAccelerator();
}
return on;
}
@ -549,7 +549,7 @@ void FButtonGroup::setText (const FString& txt)
text = txt;
if ( isEnabled() )
{
delAccelerator (this);
delAccelerator();
setHotkeyAccelerator();
}
}

View File

@ -171,10 +171,38 @@ class fc
// keyboard - single keys
enum keys
{
Fkey_erase = 0x0000008,
Fkey_tab = 0x0000009,
Fkey_return = 0x000000d,
Fkey_escape = 0x000001b,
Fckey_at = 0x0000000, // control-@
Fckey_a = 0x0000001, // control-a
Fckey_b = 0x0000002, // control-b
Fckey_c = 0x0000003, // control-c
Fckey_d = 0x0000004, // control-d
Fckey_e = 0x0000005, // control-e
Fckey_f = 0x0000006, // control-f
Fckey_g = 0x0000007, // control-g
Fkey_erase = 0x0000008, // control-h
Fkey_tab = 0x0000009, // control-i
Fckey_j = 0x000000a, // control-j
Fckey_h = 0x000000b, // control-k
Fckey_l = 0x000000c, // control-l
Fkey_return = 0x000000d, // control-m
Fckey_n = 0x000000e, // control-n
Fckey_o = 0x000000f, // control-o
Fckey_p = 0x0000010, // control-p
Fckey_q = 0x0000011, // control-q
Fckey_r = 0x0000012, // control-r
Fckey_s = 0x0000013, // control-s
Fckey_t = 0x0000014, // control-t
Fckey_u = 0x0000015, // control-u
Fckey_v = 0x0000016, // control-v
Fckey_w = 0x0000017, // control-w
Fckey_x = 0x0000018, // control-x
Fckey_y = 0x0000019, // control-y
Fckey_z = 0x000001a, // control-t
Fkey_escape = 0x000001b, // control-[
Fckey_backslash = 0x000001c, // control-'\'
Fckey_right_square_bracket = 0x000001d, // control-]
Fckey_caret = 0x000001e, // control-^
Fckey_underscore = 0x000001f, // control-_
Fkey_space = 0x0000020,
Fkey_backspace = 0x1000100,
Fkey_catab = 0x1000101,
@ -438,6 +466,7 @@ class fc
Fkey_mouse = 0x2000020, // xterm mouse
Fkey_extended_mouse = 0x2000021, // SGR extended mouse
Fkey_urxvt_mouse = 0x2000022, // urxvt mouse extension
Fmkey_meta = 0x20000e0, // meta key offset
Fmkey_space = 0x2000100, // M-' '
Fmkey_bang = 0x2000101, // M-!
Fmkey_quotes = 0x2000102, // M-"

View File

@ -415,10 +415,37 @@ keyname;
static keyname FkeyName[] =
{
{ fc::Fkey_erase , "Backspace" },
{ fc::Fkey_tab , "Tab" },
{ fc::Fkey_return , "Return" },
{ fc::Fkey_escape , "Esc" },
{ fc::Fckey_at , "Ctrl+@" },
{ fc::Fckey_a , "Ctrl+a" },
{ fc::Fckey_b , "Ctrl+b" },
{ fc::Fckey_c , "Ctrl+c" },
{ fc::Fckey_d , "Ctrl+d" },
{ fc::Fckey_e , "Ctrl+e" },
{ fc::Fckey_f , "Ctrl+f" },
{ fc::Fckey_g , "Ctrl+g" },
{ fc::Fkey_erase , "Backspace" }, // Ctrl+h
{ fc::Fkey_tab , "Tab" }, // Ctrl+i
{ fc::Fckey_h , "Ctrl+k" },
{ fc::Fckey_l , "Ctrl+l" },
{ fc::Fkey_return , "Return" }, // Ctrl+m
{ fc::Fckey_n , "Ctrl+n" },
{ fc::Fckey_o , "Ctrl+o" },
{ fc::Fckey_p , "Ctrl+p" },
{ fc::Fckey_q , "Ctrl+q" },
{ fc::Fckey_r , "Ctrl+r" },
{ fc::Fckey_s , "Ctrl+s" },
{ fc::Fckey_t , "Ctrl+t" },
{ fc::Fckey_u , "Ctrl+u" },
{ fc::Fckey_v , "Ctrl+v" },
{ fc::Fckey_w , "Ctrl+w" },
{ fc::Fckey_x , "Ctrl+x" },
{ fc::Fckey_y , "Ctrl+y" },
{ fc::Fckey_z , "Ctrl+t" },
{ fc::Fkey_escape , "Esc" }, // Ctrl+[
{ fc::Fckey_backslash , "Ctrl+\\" },
{ fc::Fckey_right_square_bracket, "Ctrl+]" },
{ fc::Fckey_caret , "Ctrl+^" },
{ fc::Fckey_underscore , "Ctrl+_" },
{ fc::Fkey_space , "Space" },
{ fc::Fkey_backspace , "Backspace" },
{ fc::Fkey_catab , "Clear-All-Tabs" },

View File

@ -47,7 +47,7 @@ FLabel::FLabel (const FString& txt, FWidget* parent)
//----------------------------------------------------------------------
FLabel::~FLabel() // destructor
{
delAccelerator (this);
delAccelerator();
}
@ -118,16 +118,16 @@ void FLabel::setHotkeyAccelerator()
{
if ( isalpha(hotkey) || isdigit(hotkey) )
{
addAccelerator (tolower(hotkey), this);
addAccelerator (toupper(hotkey), this);
addAccelerator (tolower(hotkey));
addAccelerator (toupper(hotkey));
// Meta + hotkey
addAccelerator (0x20000e0 + tolower(hotkey), this);
addAccelerator (fc::Fmkey_meta + tolower(hotkey));
}
else
addAccelerator (getHotkey(), this);
addAccelerator (getHotkey());
}
else
delAccelerator(this);
delAccelerator();
}
//----------------------------------------------------------------------
@ -391,7 +391,7 @@ void FLabel::onAccel (FAccelEvent* ev)
void FLabel::cb_accel_widget_destroyed (FWidget*, void*)
{
accel_widget = 0;
delAccelerator (this);
delAccelerator();
}
//----------------------------------------------------------------------
@ -449,7 +449,7 @@ bool FLabel::setEnable (bool on)
else
{
flags &= ~ACTIVE;
delAccelerator (this);
delAccelerator();
}
return on;
}
@ -472,7 +472,7 @@ void FLabel::setText (const FString& txt)
if ( isEnabled() )
{
delAccelerator (this);
delAccelerator();
setHotkeyAccelerator();
}
}

View File

@ -47,7 +47,7 @@ void FMenuBar::init()
setGeometry (1, 1, getColumnNumber(), 1, false);
getRootWidget()->setTopPadding(1, true);
setMenuBar(this);
addAccelerator (fc::Fkey_f10, this);
addAccelerator (fc::Fkey_f10);
foregroundColor = wc.menu_active_fg;
backgroundColor = wc.menu_active_bg;
window_object = true;
@ -208,7 +208,7 @@ bool FMenuBar::hotkeyMenu (FKeyEvent*& ev)
int hotkey = (*iter)->getHotkey();
int key = ev->key();
if ( 0x20000e0+tolower(hotkey) == key )
if ( fc::Fmkey_meta + tolower(hotkey) == key )
{
FMenuItem* sel_item = getSelectedItem();

View File

@ -22,7 +22,7 @@ FMenuItem::FMenuItem (FWidget* parent)
, checked(false)
, text_length(0)
, hotkey(0)
//, accel_key(0)
, accel_key(0)
, menu(0)
, super_menu(0)
{
@ -38,7 +38,7 @@ FMenuItem::FMenuItem (FString& txt, FWidget* parent)
, checked(false)
, text_length(0)
, hotkey(0)
//, accel_key(0)
, accel_key(0)
, menu(0)
, super_menu(0)
{
@ -54,7 +54,7 @@ FMenuItem::FMenuItem (const std::string& txt, FWidget* parent)
, checked(false)
, text_length(0)
, hotkey(0)
//, accel_key(0)
, accel_key(0)
, menu(0)
, super_menu(0)
{
@ -70,13 +70,59 @@ FMenuItem::FMenuItem (const char* txt, FWidget* parent)
, checked(false)
, text_length(0)
, hotkey(0)
//, accel_key(0)
, accel_key(0)
, menu(0)
, super_menu(0)
{
init (parent);
}
//----------------------------------------------------------------------
FMenuItem::FMenuItem (int k, FString& txt, FWidget* parent)
: FWidget(parent)
, text(txt)
, selected(false)
, separator(false)
, checked(false)
, text_length(0)
, hotkey(0)
, accel_key(k)
, menu(0)
, super_menu(0)
{
init (parent);
}
//----------------------------------------------------------------------
FMenuItem::FMenuItem (int k, const std::string& txt, FWidget* parent)
: FWidget(parent)
, text(txt)
, selected(false)
, separator(false)
, checked(false)
, text_length(0)
, hotkey(0)
, accel_key(k)
, menu(0)
, super_menu(0)
{
init (parent);
}
//----------------------------------------------------------------------
FMenuItem::FMenuItem (int k, const char* txt, FWidget* parent)
: FWidget(parent)
, text(txt)
, selected(false)
, separator(false)
, checked(false)
, text_length(0)
, hotkey(0)
, accel_key(k)
, menu(0)
, super_menu(0)
{
init (parent);
}
//----------------------------------------------------------------------
FMenuItem::~FMenuItem() // destructor
{ }
@ -88,14 +134,21 @@ void FMenuItem::init (FWidget* parent)
{
text_length = text.getLength();
hotkey = hotKey();
if ( hotkey )
text_length--;
setGeometry (1,1,int(text_length+2),1, false);
if ( parent )
{
setSuperMenu(parent);
FMenuList* menu_list = dynamic_cast<FMenuList*>(parent);
FMenuList* menu_list;
setSuperMenu (parent);
if ( accel_key )
addAccelerator (accel_key);
menu_list = dynamic_cast<FMenuList*>(parent);
if ( menu_list )
menu_list->insert(this);
@ -106,7 +159,8 @@ void FMenuItem::init (FWidget* parent)
menubar_ptr->menu_dimension();
// Meta + hotkey
menubar_ptr->addAccelerator (0x20000e0+tolower(hotkey), this);
if ( hotkey )
menubar_ptr->addAccelerator (fc::Fmkey_meta + tolower(hotkey), this);
this->addCallback
(
@ -125,8 +179,6 @@ void FMenuItem::init (FWidget* parent)
if ( menu_ptr )
menu_ptr->menu_dimension();
//addAccelerator (accel_key, this);
this->addCallback
(
"activate",
@ -204,6 +256,64 @@ void FMenuItem::processClicked()
}
// public methods of FMenuItem
//----------------------------------------------------------------------
void FMenuItem::addAccelerator (int key, FWidget* obj)
{
FWidget* super = super_menu;
while ( super && strncmp ( super->getClassName()
, const_cast<char*>("FMenu"), 5) == 0 )
{
super = super->parentWidget();
}
if ( super )
{
FWidget* window = FWindow::getWindowWidget(super);
accelerator accel = { key, obj };
if ( ! window )
window = getRootWidget();
if ( window && window->accelerator_list )
window->accelerator_list->push_back(accel);
}
}
//----------------------------------------------------------------------
void FMenuItem::delAccelerator (FWidget* obj)
{
FWidget* super = super_menu;
while ( super && strncmp ( super->getClassName()
, const_cast<char*>("FMenu"), 5) == 0 )
{
super = super->parentWidget();
}
if ( super )
{
FWidget* window = FWindow::getWindowWidget(super);
if ( ! window )
window = getRootWidget();
if ( window
&& window->accelerator_list
&& ! window->accelerator_list->empty() )
{
FWidget::Accelerators::iterator iter;
iter = window->accelerator_list->begin();
while ( iter != window->accelerator_list->end() )
{
if ( iter->object == obj )
iter = window->accelerator_list->erase(iter);
else
++iter;
}
}
}
}
//----------------------------------------------------------------------
void FMenuItem::onKeyPress (FKeyEvent* ev)
{
@ -377,6 +487,8 @@ void FMenuItem::onAccel (FAccelEvent* ev)
ev->accept();
}
}
else
processClicked();
}
}
@ -418,7 +530,7 @@ bool FMenuItem::setEnable (bool on)
if ( super && isMenuBar(super) )
{
// Meta + hotkey
super->addAccelerator (0x20000e0+tolower(hotkey), this);
super->addAccelerator (fc::Fmkey_meta + tolower(hotkey), this);
}
}
else
@ -509,24 +621,24 @@ void FMenuItem::unsetSelected()
//----------------------------------------------------------------------
void FMenuItem::openMenu()
{
FMenu* menu;
FMenu* submenu;
FMenu* open_menu;
if ( hasMenu() )
{
menu = getMenu();
submenu = getMenu();
if ( ! menu->isVisible() )
if ( ! submenu->isVisible() )
{
open_menu = static_cast<FMenu*>(getOpenMenu());
if ( open_menu && open_menu != menu )
if ( open_menu && open_menu != submenu )
open_menu->hide();
setOpenMenu(menu);
setOpenMenu(submenu);
menu->setVisible();
menu->show();
menu->raiseWindow(menu);
menu->redraw();
submenu->setVisible();
submenu->show();
submenu->raiseWindow(submenu);
submenu->redraw();
updateTerminal();
flush_out();
}

View File

@ -49,7 +49,7 @@ class FMenuItem : public FWidget
bool checked;
uInt text_length;
int hotkey;
//int accel_key;
int accel_key;
FMenu* menu;
FWidget* super_menu;
@ -71,8 +71,17 @@ class FMenuItem : public FWidget
FMenuItem (FString&, FWidget* = 0);
FMenuItem (const std::string&, FWidget* = 0);
FMenuItem (const char*, FWidget* = 0);
FMenuItem (int, FString&, FWidget* = 0);
FMenuItem (int, const std::string&, FWidget* = 0);
FMenuItem (int, const char*, FWidget* = 0);
virtual ~FMenuItem();
// make every addAccelerator from FWidget available
using FWidget::addAccelerator;
void addAccelerator (int, FWidget*);
// make every delAccelerator from FWidget available
using FWidget::delAccelerator;
void delAccelerator (FWidget*);
void onKeyPress (FKeyEvent*);
void onMouseDown (FMouseEvent*);
void onMouseUp (FMouseEvent*);

View File

@ -97,8 +97,6 @@ void FMenuList::remove (FMenuItem* i)
{
std::vector<FMenuItem*>::iterator iter;
//delAccelerator (i);
if ( itemlist.empty() )
return;

View File

@ -100,8 +100,8 @@ inline FMenuItem* FMenuList::getSelectedItem() const
{ return selectedItem; }
//----------------------------------------------------------------------
inline void FMenuList::setSelectedItem (FMenuItem* item)
{ selectedItem = item; }
inline void FMenuList::setSelectedItem (FMenuItem* menuitem)
{ selectedItem = menuitem; }
//----------------------------------------------------------------------
inline bool FMenuList::hasSelectedItem() const

View File

@ -81,8 +81,8 @@ class FObject
void delChild (FObject*);
int numOfChildren() const;
static void getCurrentTime (timeval&);
int addTimer (int interval);
bool delTimer (int id);
int addTimer (int);
bool delTimer (int);
bool delAllTimer();
virtual bool event (FEvent*);

View File

@ -62,7 +62,7 @@ FStatusKey::~FStatusKey() // destructor
{
if ( statusbar() )
statusbar()->remove(this);
delAccelerator(this);
delAccelerator();
}

View File

@ -72,13 +72,13 @@ class FString
mutable char* c_string;
private:
inline void initLength (uInt);
inline void _replace (const wchar_t*);
inline void _insert (uInt, uInt, const wchar_t*);
inline void _remove (uInt, uInt);
inline char* wc_to_c_str (const wchar_t* s) const;
inline wchar_t* c_to_wc_str (const char* s) const;
inline wchar_t* extractToken (wchar_t**, const wchar_t*, const wchar_t*);
void initLength (uInt);
void _replace (const wchar_t*);
void _insert (uInt, uInt, const wchar_t*);
void _remove (uInt, uInt);
char* wc_to_c_str (const wchar_t*) const;
wchar_t* c_to_wc_str (const char*) const;
wchar_t* extractToken (wchar_t**, const wchar_t*, const wchar_t*);
public:
FString (); // constructor

View File

@ -56,7 +56,7 @@ FToggleButton::FToggleButton ( const FString& txt, FWidget* parent )
//----------------------------------------------------------------------
FToggleButton::~FToggleButton() // destructor
{
delAccelerator(this);
delAccelerator();
if ( group() )
group()->remove(this);
if ( hasFocus() )
@ -137,16 +137,16 @@ void FToggleButton::setHotkeyAccelerator()
{
if ( isalpha(hotkey) || isdigit(hotkey) )
{
addAccelerator (tolower(hotkey), this);
addAccelerator (toupper(hotkey), this);
addAccelerator (tolower(hotkey));
addAccelerator (toupper(hotkey));
// Meta + hotkey
addAccelerator (0x20000e0 + tolower(hotkey), this);
addAccelerator (fc::Fmkey_meta + tolower(hotkey));
}
else
addAccelerator (getHotkey(), this);
addAccelerator (getHotkey());
}
else
delAccelerator(this);
delAccelerator();
}
//----------------------------------------------------------------------
@ -406,7 +406,7 @@ bool FToggleButton::setEnable(bool on)
else
{
flags &= ~ACTIVE;
delAccelerator (this);
delAccelerator();
foregroundColor = wc.toggle_button_inactive_fg;
backgroundColor = wc.toggle_button_inactive_bg;
}
@ -625,7 +625,7 @@ void FToggleButton::setText (FString txt)
setWidth(button_width + int(text.getLength()));
if ( isEnabled() )
{
delAccelerator (this);
delAccelerator();
setHotkeyAccelerator();
}
}

View File

@ -1072,20 +1072,6 @@ void FWidget::emitCallback (FString emit_signal)
}
}
//----------------------------------------------------------------------
void FWidget::addAccelerator (int key)
{
FWidget* window = FWindow::getWindowWidget(this);
accelerator accel = { key, this };
if ( ! window )
window = getRootWidget();
if ( window == statusbar || window == menubar )
window = FWindow::getWindowWidget(parentWidget());
if ( window && window->accelerator_list )
window->accelerator_list->push_back(accel);
}
//----------------------------------------------------------------------
void FWidget::addAccelerator (int key, FWidget* obj)
{

View File

@ -358,9 +358,10 @@ class FWidget : public FObject, public FTerm
void delCallback (FWidget*);
void emitCallback (FString);
void addAccelerator (int key);
void addAccelerator (int, FWidget*);
void delAccelerator (FWidget*);
void addAccelerator (int);
virtual void addAccelerator (int, FWidget*);
void delAccelerator ();
virtual void delAccelerator (FWidget*);
virtual void redraw();
virtual void resize();
@ -434,7 +435,7 @@ class FWidget : public FObject, public FTerm
virtual void setGeometry (const FRect&, bool = true);
virtual void setGeometry (int, int, int, int, bool = true);
virtual void move (const FPoint&);
virtual void move (int x, int y);
virtual void move (int, int);
int getFlags() const;
bool setCursor();
@ -509,6 +510,14 @@ inline void FWidget::clearStatusbarMessage()
inline FString FWidget::getStatusbarMessage()
{ return statusbar_message; }
//----------------------------------------------------------------------
inline void FWidget::addAccelerator (int key)
{ addAccelerator (key, this); }
//----------------------------------------------------------------------
inline void FWidget::delAccelerator()
{ delAccelerator(this); }
//----------------------------------------------------------------------
inline bool FWidget::setVisible()
{ return visible = true; }

View File

@ -193,50 +193,52 @@ MyDialog::MyDialog (FWidget* parent)
, myList()
{
// menu bar
FMenuBar* Menubar = new FMenuBar(this);
FMenuBar* Menubar = new FMenuBar (this);
// menu bar items
FMenu* File = new FMenu("&File", Menubar);
File->setStatusbarMessage("File management commands");
FMenu* Edit = new FMenu("&Edit", Menubar);
Edit->setStatusbarMessage("Cut-and-paste editing commands");
FMenu* View = new FMenu("&View", Menubar);
View->setStatusbarMessage("Show internal informations");
FMenuItem* Options = new FMenuItem("&Options", Menubar);
Options->setStatusbarMessage("Set program defaults");
FMenu* File = new FMenu ("&File", Menubar);
File->setStatusbarMessage ("File management commands");
FMenu* Edit = new FMenu ("&Edit", Menubar);
Edit->setStatusbarMessage ("Cut-and-paste editing commands");
FMenu* View = new FMenu ("&View", Menubar);
View->setStatusbarMessage ("Show internal informations");
FMenuItem* Options = new FMenuItem ("&Options", Menubar);
Options->setStatusbarMessage ("Set program defaults");
Options->setDisable();
FMenuItem* Help = new FMenuItem("&Help", Menubar);
Help->setStatusbarMessage("Show version and copyright information");
FMenuItem* Help = new FMenuItem ("&Help", Menubar);
Help->setStatusbarMessage ("Show version and copyright information");
// "File" menu items
FMenuItem* Open = new FMenuItem("&Open...", File);
Open->setStatusbarMessage("Locate and open a text file");
FMenuItem* Line1 = new FMenuItem(File);
FMenuItem* Open = new FMenuItem ("&Open...", File);
Open->addAccelerator (fc::Fckey_o); // Ctrl + O
Open->setStatusbarMessage ("Locate and open a text file");
FMenuItem* Line1 = new FMenuItem (File);
Line1->setSeparator();
FMenuItem* Quit = new FMenuItem("&Quit", File);
Quit->setStatusbarMessage("Exit the program");
FMenuItem* Quit = new FMenuItem ("&Quit", File);
Quit->addAccelerator (fc::Fmkey_x); // Meta/Alt + X
Quit->setStatusbarMessage ("Exit the program");
// "Edit" menu items
FMenuItem* Undo = new FMenuItem("Undo", Edit);
FMenuItem* Undo = new FMenuItem ("Undo", Edit);
Undo->setDisable();
FMenuItem* Redo = new FMenuItem("Redo", Edit);
FMenuItem* Redo = new FMenuItem ("Redo", Edit);
Redo->setDisable();
FMenuItem* Line2 = new FMenuItem(Edit);
FMenuItem* Line2 = new FMenuItem (Edit);
Line2->setSeparator();
FMenuItem* Cut = new FMenuItem("Cu&t", Edit);
Cut->setStatusbarMessage("Remove the input text and put it in the clipboard");
FMenuItem* Copy = new FMenuItem("&Copy", Edit);
Copy->setStatusbarMessage("Copy the input text into the clipboad");
FMenuItem* Paste = new FMenuItem("&Paste", Edit);
Paste->setStatusbarMessage("Insert text form clipboard");
FMenuItem* Clear = new FMenuItem("C&lear", Edit);
Clear->setStatusbarMessage("Delete input text");
FMenuItem* Cut = new FMenuItem (fc::Fckey_x, "Cu&t", Edit);
Cut->setStatusbarMessage ("Remove the input text and put it in the clipboard");
FMenuItem* Copy = new FMenuItem (fc::Fckey_c, "&Copy", Edit);
Copy->setStatusbarMessage ("Copy the input text into the clipboad");
FMenuItem* Paste = new FMenuItem (fc::Fckey_v, "&Paste", Edit);
Paste->setStatusbarMessage ("Insert text form clipboard");
FMenuItem* Clear = new FMenuItem ("C&lear", Edit);
Clear->setStatusbarMessage ("Delete input text");
// "View" menu items
FMenuItem* Env = new FMenuItem("&Terminal info...", View);
Env->setStatusbarMessage("Informations about this terminal");
FMenuItem* Drive = new FMenuItem("&Drive symbols...", View);
Drive->setStatusbarMessage("Show drive symbols");
FMenuItem* Env = new FMenuItem ("&Terminal info...", View);
Env->setStatusbarMessage ("Informations about this terminal");
FMenuItem* Drive = new FMenuItem ("&Drive symbols...", View);
Drive->setStatusbarMessage ("Show drive symbols");
// Menu function callbacks
Open->addCallback
@ -286,125 +288,125 @@ MyDialog::MyDialog (FWidget* parent)
);
// Buttons
FButton* MyButton1 = new FButton(this);
FButton* MyButton1 = new FButton (this);
MyButton1->setGeometry(3, 3, 5, 1);
MyButton1->setText(L"&SIN");
MyButton1->setStatusbarMessage("Sine function");
MyButton1->setText (L"&SIN");
MyButton1->setStatusbarMessage ("Sine function");
MyButton1->setNoUnderline();
MyButton1->setFlat();
MyButton1->setDoubleFlatLine(fc::bottom);
MyButton1->setDoubleFlatLine (fc::bottom);
FButton* MyButton2 = new FButton(this);
FButton* MyButton2 = new FButton (this);
MyButton2->setGeometry(3, 5, 5, 1);
MyButton2->setText(L"&COS");
MyButton2->setStatusbarMessage("Cosine function");
MyButton2->setText (L"&COS");
MyButton2->setStatusbarMessage ("Cosine function");
MyButton2->setNoUnderline();
MyButton2->setFlat();
MyButton2->setDoubleFlatLine(fc::top);
FButton* MyButton3 = new FButton(this);
FButton* MyButton3 = new FButton (this);
MyButton3->setGeometry(10, 3, 5, 3);
MyButton3->setText(L"&=");
MyButton3->setStatusbarMessage("Equal");
MyButton3->setText (L"&=");
MyButton3->setStatusbarMessage ("Equal");
MyButton3->setNoUnderline();
MyButton3->setFlat();
// Radio buttons in a group
FButtonGroup* radioButtonGroup = new FButtonGroup("Button", this);
FButtonGroup* radioButtonGroup = new FButtonGroup ("Button", this);
radioButtonGroup->setGeometry(3, 8, 14, 4);
//radioButtonGroup->unsetBorder();
FRadioButton* radio1 = new FRadioButton("E&nable", radioButtonGroup);
FRadioButton* radio1 = new FRadioButton ("E&nable", radioButtonGroup);
radio1->setGeometry(1, 1, 7, 1);
radio1->setStatusbarMessage("Enable button Test");
radio1->setStatusbarMessage ("Enable button Test");
FRadioButton* radio2 = new FRadioButton(radioButtonGroup);
FRadioButton* radio2 = new FRadioButton (radioButtonGroup);
radio2->setGeometry(1, 2, 7, 1);
radio2->setText("&Disable");
radio2->setStatusbarMessage("Disable button Test");
radio2->setText ("&Disable");
radio2->setStatusbarMessage ("Disable button Test");
radio2->setChecked();
//radio2->setDisable();
// Checkboxes in a group
FButtonGroup* checkButtonGroup = new FButtonGroup("Options", this);
FButtonGroup* checkButtonGroup = new FButtonGroup ("Options", this);
checkButtonGroup->setGeometry(3, 12, 14, 4);
FCheckBox* check1 = new FCheckBox("&Bitmode", checkButtonGroup);
FCheckBox* check1 = new FCheckBox ("&Bitmode", checkButtonGroup);
check1->setGeometry(1, 1, 7, 1);
check1->setNoUnderline();
FCheckBox* check2 = new FCheckBox("&8-Bit", checkButtonGroup);
FCheckBox* check2 = new FCheckBox ("&8-Bit", checkButtonGroup);
check2->setGeometry(1, 2, 7, 1);
check2->setChecked();
check2->setNoUnderline();
// A text input field
FLineEdit* MyLineEdit = new FLineEdit(this);
FLineEdit* MyLineEdit = new FLineEdit (this);
MyLineEdit->setGeometry(22, 1, 10, 1);
MyLineEdit->setText( FString("EnTry").toLower());
MyLineEdit->setLabelText(L"&Input:");
MyLineEdit->setStatusbarMessage("Press Enter to set the title");
MyLineEdit->setText (FString("EnTry").toLower());
MyLineEdit->setLabelText (L"&Input:");
MyLineEdit->setStatusbarMessage ("Press Enter to set the title");
MyLineEdit->setShadow();
// Buttons
FButton* MyButton4 = new FButton(this);
FButton* MyButton4 = new FButton (this);
MyButton4->setGeometry(20, 8, 12, 1);
MyButton4->setText(L"&Get input");
MyButton4->setStatusbarMessage("Take text from input field");
MyButton4->setText (L"&Get input");
MyButton4->setStatusbarMessage ("Take text from input field");
MyButton4->setShadow();
MyButton4->setFocus();
FButton* MyButton5 = new FButton(this);
FButton* MyButton5 = new FButton (this);
MyButton5->setGeometry(20, 11, 12, 1);
MyButton5->setText(L"&Test");
MyButton5->setStatusbarMessage("Progressbar testing dialog");
MyButton5->setText (L"&Test");
MyButton5->setStatusbarMessage ("Progressbar testing dialog");
MyButton5->setShadow();
MyButton5->setDisable();
FButton* MyButton6 = new FButton(this);
FButton* MyButton6 = new FButton (this);
MyButton6->setGeometry(20, 14, 12, 1);
MyButton6->setText(L"&Quit");
MyButton6->setStatusbarMessage("Exit the program");
MyButton6->setText (L"&Quit");
MyButton6->setStatusbarMessage ("Exit the program");
MyButton6->setShadow();
MyButton6->addAccelerator('x');
// A multiple selection listbox
myList = new FListBox(this);
myList = new FListBox (this);
myList->setGeometry(38, 1, 14, 17);
myList->setText("Items");
myList->setStatusbarMessage("99 items in a list");
myList->setText ("Items");
myList->setStatusbarMessage ("99 items in a list");
myList->setMultiSelection();
for (int z=1; z < 100; z++)
myList->insert( FString().setNumber(z) + L" placeholder" );
myList->insert (FString().setNumber(z) + L" placeholder");
// Text labels
FLabel* headline = new FLabel(this);
FLabel* headline = new FLabel (this);
headline->setGeometry(21, 3, 10, 1);
headline->setText(L"List items");
headline->setText (L"List items");
headline->setEmphasis();
headline->setAlignment(fc::alignCenter);
headline->setAlignment (fc::alignCenter);
FLabel* tagged = new FLabel(L"Tagged:", this);
FLabel* tagged = new FLabel (L"Tagged:", this);
tagged->setGeometry(21, 4, 7, 1);
FLabel* tagged_count = new FLabel(this);
tagged_count->setGeometry(29, 4, 5, 1);
tagged_count->setNumber(0);
FLabel* sum = new FLabel(L"Sum:", this);
FLabel* sum = new FLabel (L"Sum:", this);
sum->setGeometry(21, 5, 7, 3);
sum->setAlignment(fc::alignRight);
sum->setAlignment (fc::alignRight);
FLabel* sum_count = new FLabel(this);
FLabel* sum_count = new FLabel (this);
sum_count->setGeometry(29, 5, 5, 3);
sum_count->setNumber(myList->count());
sum_count->setNumber (myList->count());
// Statusbar at the bottom
FStatusBar* statusbar = new FStatusBar(this);
FStatusBar* statusbar = new FStatusBar (this);
// Statusbar keys
FStatusKey* key_F1 = new FStatusKey(fc::Fkey_f1, "About", statusbar);
FStatusKey* key_F2 = new FStatusKey(fc::Fkey_f2, "View", statusbar);
FStatusKey* key_F3 = new FStatusKey(fc::Fkey_f3, "Quit", statusbar);
FStatusKey* key_F1 = new FStatusKey (fc::Fkey_f1, "About", statusbar);
FStatusKey* key_F2 = new FStatusKey (fc::Fkey_f2, "View", statusbar);
FStatusKey* key_F3 = new FStatusKey (fc::Fkey_f3, "Quit", statusbar);
// Add some function callbacks
MyButton1->addCallback