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> 2015-11-08 Markus Gans <guru.mail@muenster.de>
* Activate the previous window in case if the menu is open and * Activate the previous window in case if the menu is open and
the mouse click has activated no window. the mouse click has activated no window.

View File

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

View File

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

View File

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

View File

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

View File

@ -171,160 +171,188 @@ class fc
// keyboard - single keys // keyboard - single keys
enum keys enum keys
{ {
Fkey_erase = 0x0000008, Fckey_at = 0x0000000, // control-@
Fkey_tab = 0x0000009, Fckey_a = 0x0000001, // control-a
Fkey_return = 0x000000d, Fckey_b = 0x0000002, // control-b
Fkey_escape = 0x000001b, Fckey_c = 0x0000003, // control-c
Fkey_space = 0x0000020, Fckey_d = 0x0000004, // control-d
Fkey_backspace = 0x1000100, Fckey_e = 0x0000005, // control-e
Fkey_catab = 0x1000101, Fckey_f = 0x0000006, // control-f
Fkey_clear = 0x1000102, Fckey_g = 0x0000007, // control-g
Fkey_ctab = 0x1000103, Fkey_erase = 0x0000008, // control-h
Fkey_dc = 0x1000104, Fkey_tab = 0x0000009, // control-i
Fkey_dl = 0x1000105, Fckey_j = 0x000000a, // control-j
Fkey_down = 0x1000106, Fckey_h = 0x000000b, // control-k
Fkey_eic = 0x1000107, Fckey_l = 0x000000c, // control-l
Fkey_eol = 0x1000108, Fkey_return = 0x000000d, // control-m
Fkey_eos = 0x1000109, Fckey_n = 0x000000e, // control-n
Fkey_f0 = 0x100010a, Fckey_o = 0x000000f, // control-o
Fkey_f1 = 0x100010b, Fckey_p = 0x0000010, // control-p
Fkey_f2 = 0x100010c, Fckey_q = 0x0000011, // control-q
Fkey_f3 = 0x100010d, Fckey_r = 0x0000012, // control-r
Fkey_f4 = 0x100010e, Fckey_s = 0x0000013, // control-s
Fkey_f5 = 0x100010f, Fckey_t = 0x0000014, // control-t
Fkey_f6 = 0x1000110, Fckey_u = 0x0000015, // control-u
Fkey_f7 = 0x1000111, Fckey_v = 0x0000016, // control-v
Fkey_f8 = 0x1000112, Fckey_w = 0x0000017, // control-w
Fkey_f9 = 0x1000113, Fckey_x = 0x0000018, // control-x
Fkey_f10 = 0x1000114, Fckey_y = 0x0000019, // control-y
Fkey_home = 0x1000115, Fckey_z = 0x000001a, // control-t
Fkey_ic = 0x1000116, // insert key Fkey_escape = 0x000001b, // control-[
Fkey_il = 0x1000117, Fckey_backslash = 0x000001c, // control-'\'
Fkey_left = 0x1000118, Fckey_right_square_bracket = 0x000001d, // control-]
Fkey_ll = 0x1000119, Fckey_caret = 0x000001e, // control-^
Fkey_npage = 0x100011a, Fckey_underscore = 0x000001f, // control-_
Fkey_ppage = 0x100011b, Fkey_space = 0x0000020,
Fkey_right = 0x100011c, Fkey_backspace = 0x1000100,
Fkey_sf = 0x100011d, Fkey_catab = 0x1000101,
Fkey_sr = 0x100011e, Fkey_clear = 0x1000102,
Fkey_stab = 0x100011f, Fkey_ctab = 0x1000103,
Fkey_up = 0x1000120, Fkey_dc = 0x1000104,
Fkey_a1 = 0x1000121, Fkey_dl = 0x1000105,
Fkey_a3 = 0x1000122, Fkey_down = 0x1000106,
Fkey_b2 = 0x1000123, Fkey_eic = 0x1000107,
Fkey_c1 = 0x1000124, Fkey_eol = 0x1000108,
Fkey_c3 = 0x1000125, Fkey_eos = 0x1000109,
Fkey_btab = 0x1000126, Fkey_f0 = 0x100010a,
Fkey_beg = 0x1000127, Fkey_f1 = 0x100010b,
Fkey_cancel = 0x1000128, Fkey_f2 = 0x100010c,
Fkey_close = 0x1000129, Fkey_f3 = 0x100010d,
Fkey_command = 0x100012a, Fkey_f4 = 0x100010e,
Fkey_copy = 0x100012b, Fkey_f5 = 0x100010f,
Fkey_create = 0x100012c, Fkey_f6 = 0x1000110,
Fkey_end = 0x100012d, Fkey_f7 = 0x1000111,
Fkey_enter = 0x100012e, Fkey_f8 = 0x1000112,
Fkey_exit = 0x100012f, Fkey_f9 = 0x1000113,
Fkey_find = 0x1000130, Fkey_f10 = 0x1000114,
Fkey_help = 0x1000131, Fkey_home = 0x1000115,
Fkey_mark = 0x1000132, Fkey_ic = 0x1000116, // insert key
Fkey_message = 0x1000133, Fkey_il = 0x1000117,
Fkey_move = 0x1000134, Fkey_left = 0x1000118,
Fkey_next = 0x1000135, Fkey_ll = 0x1000119,
Fkey_open = 0x1000136, Fkey_npage = 0x100011a,
Fkey_options = 0x1000137, Fkey_ppage = 0x100011b,
Fkey_previous = 0x1000138, Fkey_right = 0x100011c,
Fkey_print = 0x1000139, Fkey_sf = 0x100011d,
Fkey_redo = 0x100013a, Fkey_sr = 0x100011e,
Fkey_reference = 0x100013b, Fkey_stab = 0x100011f,
Fkey_refresh = 0x100013c, Fkey_up = 0x1000120,
Fkey_replace = 0x100013d, Fkey_a1 = 0x1000121,
Fkey_restart = 0x100013e, Fkey_a3 = 0x1000122,
Fkey_resume = 0x100013f, Fkey_b2 = 0x1000123,
Fkey_save = 0x1000140, Fkey_c1 = 0x1000124,
Fkey_suspend = 0x1000141, Fkey_c3 = 0x1000125,
Fkey_undo = 0x1000142, Fkey_btab = 0x1000126,
Fkey_sbeg = 0x1000143, Fkey_beg = 0x1000127,
Fkey_scancel = 0x1000144, Fkey_cancel = 0x1000128,
Fkey_scommand = 0x1000145, Fkey_close = 0x1000129,
Fkey_scopy = 0x1000146, Fkey_command = 0x100012a,
Fkey_screate = 0x1000147, Fkey_copy = 0x100012b,
Fkey_sdc = 0x1000148, Fkey_create = 0x100012c,
Fkey_sdl = 0x1000149, Fkey_end = 0x100012d,
Fkey_select = 0x100014a, Fkey_enter = 0x100012e,
Fkey_send = 0x100014b, Fkey_exit = 0x100012f,
Fkey_seol = 0x100014c, Fkey_find = 0x1000130,
Fkey_sexit = 0x100014d, Fkey_help = 0x1000131,
Fkey_sfind = 0x100014e, Fkey_mark = 0x1000132,
Fkey_shelp = 0x100014f, Fkey_message = 0x1000133,
Fkey_shome = 0x1000150, Fkey_move = 0x1000134,
Fkey_sic = 0x1000151, Fkey_next = 0x1000135,
Fkey_sleft = 0x1000152, Fkey_open = 0x1000136,
Fkey_smessage = 0x1000153, Fkey_options = 0x1000137,
Fkey_smove = 0x1000154, Fkey_previous = 0x1000138,
Fkey_snext = 0x1000155, Fkey_print = 0x1000139,
Fkey_soptions = 0x1000156, Fkey_redo = 0x100013a,
Fkey_sprevious = 0x1000157, Fkey_reference = 0x100013b,
Fkey_sprint = 0x1000158, Fkey_refresh = 0x100013c,
Fkey_sredo = 0x1000159, Fkey_replace = 0x100013d,
Fkey_sreplace = 0x100015a, Fkey_restart = 0x100013e,
Fkey_sright = 0x100015b, Fkey_resume = 0x100013f,
Fkey_srsume = 0x100015c, Fkey_save = 0x1000140,
Fkey_ssave = 0x100015d, Fkey_suspend = 0x1000141,
Fkey_ssuspend = 0x100015e, Fkey_undo = 0x1000142,
Fkey_sundo = 0x100015f, Fkey_sbeg = 0x1000143,
Fkey_f11 = 0x1000160, Fkey_scancel = 0x1000144,
Fkey_f12 = 0x1000161, Fkey_scommand = 0x1000145,
Fkey_f13 = 0x1000162, Fkey_scopy = 0x1000146,
Fkey_f14 = 0x1000163, Fkey_screate = 0x1000147,
Fkey_f15 = 0x1000164, Fkey_sdc = 0x1000148,
Fkey_f16 = 0x1000165, Fkey_sdl = 0x1000149,
Fkey_f17 = 0x1000166, Fkey_select = 0x100014a,
Fkey_f18 = 0x1000167, Fkey_send = 0x100014b,
Fkey_f19 = 0x1000168, Fkey_seol = 0x100014c,
Fkey_f20 = 0x1000169, Fkey_sexit = 0x100014d,
Fkey_f21 = 0x100016a, Fkey_sfind = 0x100014e,
Fkey_f22 = 0x100016b, Fkey_shelp = 0x100014f,
Fkey_f23 = 0x100016c, Fkey_shome = 0x1000150,
Fkey_f24 = 0x100016d, Fkey_sic = 0x1000151,
Fkey_f25 = 0x100016e, Fkey_sleft = 0x1000152,
Fkey_f26 = 0x100016f, Fkey_smessage = 0x1000153,
Fkey_f27 = 0x1000170, Fkey_smove = 0x1000154,
Fkey_f28 = 0x1000171, Fkey_snext = 0x1000155,
Fkey_f29 = 0x1000172, Fkey_soptions = 0x1000156,
Fkey_f30 = 0x1000173, Fkey_sprevious = 0x1000157,
Fkey_f31 = 0x1000174, Fkey_sprint = 0x1000158,
Fkey_f32 = 0x1000175, Fkey_sredo = 0x1000159,
Fkey_f33 = 0x1000176, Fkey_sreplace = 0x100015a,
Fkey_f34 = 0x1000177, Fkey_sright = 0x100015b,
Fkey_f35 = 0x1000178, Fkey_srsume = 0x100015c,
Fkey_f36 = 0x1000179, Fkey_ssave = 0x100015d,
Fkey_f37 = 0x100017a, Fkey_ssuspend = 0x100015e,
Fkey_f38 = 0x100017b, Fkey_sundo = 0x100015f,
Fkey_f39 = 0x100017c, Fkey_f11 = 0x1000160,
Fkey_f40 = 0x100017d, Fkey_f12 = 0x1000161,
Fkey_f41 = 0x100017e, Fkey_f13 = 0x1000162,
Fkey_f42 = 0x100017f, Fkey_f14 = 0x1000163,
Fkey_f43 = 0x1000180, Fkey_f15 = 0x1000164,
Fkey_f44 = 0x1000181, Fkey_f16 = 0x1000165,
Fkey_f45 = 0x1000182, Fkey_f17 = 0x1000166,
Fkey_f46 = 0x1000183, Fkey_f18 = 0x1000167,
Fkey_f47 = 0x1000184, Fkey_f19 = 0x1000168,
Fkey_f48 = 0x1000185, Fkey_f20 = 0x1000169,
Fkey_f49 = 0x1000186, Fkey_f21 = 0x100016a,
Fkey_f50 = 0x1000187, Fkey_f22 = 0x100016b,
Fkey_f51 = 0x1000188, Fkey_f23 = 0x100016c,
Fkey_f52 = 0x1000189, Fkey_f24 = 0x100016d,
Fkey_f53 = 0x100018a, Fkey_f25 = 0x100016e,
Fkey_f54 = 0x100018b, Fkey_f26 = 0x100016f,
Fkey_f55 = 0x100018c, Fkey_f27 = 0x1000170,
Fkey_f56 = 0x100018d, Fkey_f28 = 0x1000171,
Fkey_f57 = 0x100018e, Fkey_f29 = 0x1000172,
Fkey_f58 = 0x100018f, Fkey_f30 = 0x1000173,
Fkey_f59 = 0x1000190, Fkey_f31 = 0x1000174,
Fkey_f60 = 0x1000191, Fkey_f32 = 0x1000175,
Fkey_f61 = 0x1000192, Fkey_f33 = 0x1000176,
Fkey_f62 = 0x1000193, Fkey_f34 = 0x1000177,
Fkey_f63 = 0x1000194 Fkey_f35 = 0x1000178,
Fkey_f36 = 0x1000179,
Fkey_f37 = 0x100017a,
Fkey_f38 = 0x100017b,
Fkey_f39 = 0x100017c,
Fkey_f40 = 0x100017d,
Fkey_f41 = 0x100017e,
Fkey_f42 = 0x100017f,
Fkey_f43 = 0x1000180,
Fkey_f44 = 0x1000181,
Fkey_f45 = 0x1000182,
Fkey_f46 = 0x1000183,
Fkey_f47 = 0x1000184,
Fkey_f48 = 0x1000185,
Fkey_f49 = 0x1000186,
Fkey_f50 = 0x1000187,
Fkey_f51 = 0x1000188,
Fkey_f52 = 0x1000189,
Fkey_f53 = 0x100018a,
Fkey_f54 = 0x100018b,
Fkey_f55 = 0x100018c,
Fkey_f56 = 0x100018d,
Fkey_f57 = 0x100018e,
Fkey_f58 = 0x100018f,
Fkey_f59 = 0x1000190,
Fkey_f60 = 0x1000191,
Fkey_f61 = 0x1000192,
Fkey_f62 = 0x1000193,
Fkey_f63 = 0x1000194
}; };
// keyboard - modifier key combinations // keyboard - modifier key combinations
@ -438,6 +466,7 @@ class fc
Fkey_mouse = 0x2000020, // xterm mouse Fkey_mouse = 0x2000020, // xterm mouse
Fkey_extended_mouse = 0x2000021, // SGR extended mouse Fkey_extended_mouse = 0x2000021, // SGR extended mouse
Fkey_urxvt_mouse = 0x2000022, // urxvt mouse extension Fkey_urxvt_mouse = 0x2000022, // urxvt mouse extension
Fmkey_meta = 0x20000e0, // meta key offset
Fmkey_space = 0x2000100, // M-' ' Fmkey_space = 0x2000100, // M-' '
Fmkey_bang = 0x2000101, // M-! Fmkey_bang = 0x2000101, // M-!
Fmkey_quotes = 0x2000102, // M-" Fmkey_quotes = 0x2000102, // M-"

View File

@ -415,10 +415,37 @@ keyname;
static keyname FkeyName[] = static keyname FkeyName[] =
{ {
{ fc::Fkey_erase , "Backspace" }, { fc::Fckey_at , "Ctrl+@" },
{ fc::Fkey_tab , "Tab" }, { fc::Fckey_a , "Ctrl+a" },
{ fc::Fkey_return , "Return" }, { fc::Fckey_b , "Ctrl+b" },
{ fc::Fkey_escape , "Esc" }, { 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_space , "Space" },
{ fc::Fkey_backspace , "Backspace" }, { fc::Fkey_backspace , "Backspace" },
{ fc::Fkey_catab , "Clear-All-Tabs" }, { fc::Fkey_catab , "Clear-All-Tabs" },

View File

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

View File

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

View File

@ -22,7 +22,7 @@ FMenuItem::FMenuItem (FWidget* parent)
, 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)
{ {
@ -38,7 +38,7 @@ FMenuItem::FMenuItem (FString& txt, FWidget* parent)
, 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)
{ {
@ -54,7 +54,7 @@ FMenuItem::FMenuItem (const std::string& txt, FWidget* parent)
, 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)
{ {
@ -70,13 +70,59 @@ FMenuItem::FMenuItem (const char* txt, FWidget* parent)
, checked(false) , checked(false)
, text_length(0) , text_length(0)
, hotkey(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) , menu(0)
, super_menu(0) , super_menu(0)
{ {
init (parent); 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 FMenuItem::~FMenuItem() // destructor
{ } { }
@ -88,14 +134,21 @@ void FMenuItem::init (FWidget* parent)
{ {
text_length = text.getLength(); text_length = text.getLength();
hotkey = hotKey(); hotkey = hotKey();
if ( hotkey ) if ( hotkey )
text_length--; text_length--;
setGeometry (1,1,int(text_length+2),1, false); setGeometry (1,1,int(text_length+2),1, false);
if ( parent ) if ( parent )
{ {
setSuperMenu(parent); FMenuList* menu_list;
FMenuList* menu_list = dynamic_cast<FMenuList*>(parent); setSuperMenu (parent);
if ( accel_key )
addAccelerator (accel_key);
menu_list = dynamic_cast<FMenuList*>(parent);
if ( menu_list ) if ( menu_list )
menu_list->insert(this); menu_list->insert(this);
@ -106,7 +159,8 @@ void FMenuItem::init (FWidget* parent)
menubar_ptr->menu_dimension(); menubar_ptr->menu_dimension();
// Meta + hotkey // Meta + hotkey
menubar_ptr->addAccelerator (0x20000e0+tolower(hotkey), this); if ( hotkey )
menubar_ptr->addAccelerator (fc::Fmkey_meta + tolower(hotkey), this);
this->addCallback this->addCallback
( (
@ -125,8 +179,6 @@ void FMenuItem::init (FWidget* parent)
if ( menu_ptr ) if ( menu_ptr )
menu_ptr->menu_dimension(); menu_ptr->menu_dimension();
//addAccelerator (accel_key, this);
this->addCallback this->addCallback
( (
"activate", "activate",
@ -204,6 +256,64 @@ void FMenuItem::processClicked()
} }
// public methods of FMenuItem // 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) void FMenuItem::onKeyPress (FKeyEvent* ev)
{ {
@ -377,6 +487,8 @@ void FMenuItem::onAccel (FAccelEvent* ev)
ev->accept(); ev->accept();
} }
} }
else
processClicked();
} }
} }
@ -418,7 +530,7 @@ bool FMenuItem::setEnable (bool on)
if ( super && isMenuBar(super) ) if ( super && isMenuBar(super) )
{ {
// Meta + hotkey // Meta + hotkey
super->addAccelerator (0x20000e0+tolower(hotkey), this); super->addAccelerator (fc::Fmkey_meta + tolower(hotkey), this);
} }
} }
else else
@ -509,24 +621,24 @@ void FMenuItem::unsetSelected()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FMenuItem::openMenu() void FMenuItem::openMenu()
{ {
FMenu* menu; FMenu* submenu;
FMenu* open_menu; FMenu* open_menu;
if ( hasMenu() ) if ( hasMenu() )
{ {
menu = getMenu(); submenu = getMenu();
if ( ! menu->isVisible() ) if ( ! submenu->isVisible() )
{ {
open_menu = static_cast<FMenu*>(getOpenMenu()); open_menu = static_cast<FMenu*>(getOpenMenu());
if ( open_menu && open_menu != menu ) if ( open_menu && open_menu != submenu )
open_menu->hide(); open_menu->hide();
setOpenMenu(menu); setOpenMenu(submenu);
menu->setVisible(); submenu->setVisible();
menu->show(); submenu->show();
menu->raiseWindow(menu); submenu->raiseWindow(submenu);
menu->redraw(); submenu->redraw();
updateTerminal(); updateTerminal();
flush_out(); flush_out();
} }

View File

@ -49,7 +49,7 @@ class FMenuItem : public FWidget
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;
@ -71,8 +71,17 @@ class FMenuItem : public FWidget
FMenuItem (FString&, FWidget* = 0); FMenuItem (FString&, FWidget* = 0);
FMenuItem (const std::string&, FWidget* = 0); FMenuItem (const std::string&, FWidget* = 0);
FMenuItem (const char*, 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(); 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 onKeyPress (FKeyEvent*);
void onMouseDown (FMouseEvent*); void onMouseDown (FMouseEvent*);
void onMouseUp (FMouseEvent*); void onMouseUp (FMouseEvent*);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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