diff --git a/ChangeLog b/ChangeLog index 98ae340d..a1714ee7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2015-10-29 Markus Gans + * Support for the menu key + 2015-10-23 Markus Gans * Color setting improvements diff --git a/doc/TODO b/doc/TODO index c5a2cdb1..0b47365f 100644 --- a/doc/TODO +++ b/doc/TODO @@ -4,7 +4,6 @@ Bugs Improvements ~~~~~~~~~~~~ -- Use only termpap variables for FTerm::hideCursor() - If t_exit_underline_mode == "\E[24m" -> implement t_exit_bold_mode with "\E[21m" -> implement t_exit_reverse_mode with "\E[27m" diff --git a/src/fdialog.cpp b/src/fdialog.cpp index 2bdb80fa..eeeb8f70 100644 --- a/src/fdialog.cpp +++ b/src/fdialog.cpp @@ -269,7 +269,7 @@ void FDialog::drawDialogShadow() if ( isNewFont() && ((flags & SCROLLABLE) == 0) ) { FTerm::char_data ch; - // left of the shaddow ▀▀ + // left of the shadow ▀▀ gotoxy (xpos+xmin-1, ypos+ymin-1+height); for (int x=0; x <= 1; x++) { @@ -289,7 +289,7 @@ void FDialog::drawDialogShadow() FTerm::char_data ch; ch = getCoveredCharacter (xpos+xmin-1, ypos+ymin-1+height, this); - // left of the shaddow ▀▀ + // left of the shadow ▀▀ gotoxy (xpos+xmin-1, ypos+ymin-1+height); if ( isNewFont() && ((flags & SCROLLABLE) == 0) ) @@ -608,7 +608,7 @@ void FDialog::onWindowRaised (FEvent*) if ( window_list->empty() ) return; - // redraw shaddow of the other windows + // redraw shadow of the other windows iter = window_list->begin(); end = window_list->end(); diff --git a/src/fenum.h b/src/fenum.h index 23f235bc..f79984bd 100644 --- a/src/fenum.h +++ b/src/fenum.h @@ -426,6 +426,14 @@ class fc Fcmkey_sdown = 0x150015d, // shifted control-M-Down Fcmkey_sright = 0x150015e, // shifted control-M-Right Fcmkey_sleft = 0x150015f, // shifted control-M-Left + Fkey_menu = 0x1600000, // menu + Fkey_smenu = 0x1600001, // shifted menu + Fckey_menu = 0x1600002, // control-menu + Fckey_smenu = 0x1600003, // shifted control-menu + Fmkey_menu = 0x1600004, // M-menu + Fmkey_smenu = 0x1600005, // shifted M-menu + Fcmkey_menu = 0x1600006, // control-M-menu + Fcmkey_smenu = 0x1600007, // shifted control-M-menu Fkey_escape_mintty = 0x200001b, // mintty Esc Fkey_mouse = 0x2000020, // xterm mouse Fkey_extended_mouse = 0x2000021, // SGR extended mouse diff --git a/src/fkey_map.h b/src/fkey_map.h index cb6e41a3..54abd12c 100644 --- a/src/fkey_map.h +++ b/src/fkey_map.h @@ -290,6 +290,17 @@ static metakeymap Fmetakey[] = { fc::Fcmkey_sdown , "\033[1;8B" }, // shift-ctrl-M-down { fc::Fcmkey_sright , "\033[1;8C" }, // shift-ctrl-M-right { fc::Fcmkey_sleft , "\033[1;8D" }, // shift-ctrl-M-left + { fc::Fkey_menu , "\033[29~" }, // menu + { fc::Fkey_smenu , "\033[29$" }, // shift-menu + { fc::Fkey_smenu , "\033[29;2~" }, // shift-menu + { fc::Fckey_menu , "\033[29^" }, // ctrl-menu + { fc::Fckey_menu , "\033[29;5~" }, // ctrl-menu + { fc::Fckey_smenu , "\033[29@" }, // shift-ctrl-menu + { fc::Fckey_smenu , "\033[29;6~" }, // shift-ctrl-menu + { fc::Fmkey_menu , "\033[29;3~" }, // M-menu + { fc::Fmkey_smenu , "\033[29;4~" }, // shift-M-menu + { fc::Fcmkey_menu , "\033[29;7~" }, // ctrl-M-menu + { fc::Fcmkey_smenu , "\033[29;8~" }, // shift-ctrl-M-menu { fc::Fkey_escape_mintty , "\033O["}, // mintty Esc { fc::Fmkey_space , "\033 " }, // M-' ' { fc::Fmkey_bang , "\033!" }, // M-! @@ -654,6 +665,14 @@ static keyname FkeyName[] = { fc::Fcmkey_sdown , "Shift+Ctrl+Meta+Down" }, { fc::Fcmkey_sright , "Shift+Ctrl+Meta+Right" }, { fc::Fcmkey_sleft , "Shift+Ctrl+Meta+Left" }, + { fc::Fkey_menu , "Menu" }, + { fc::Fkey_smenu , "Shift+Menu" }, + { fc::Fckey_menu , "Ctrl+Menu" }, + { fc::Fckey_smenu , "Shift+Ctrl+Menu" }, + { fc::Fmkey_menu , "Meta+Menu" }, + { fc::Fmkey_smenu , "Shift+Meta+Menu" }, + { fc::Fcmkey_menu , "Ctrl+Meta+Menu" }, + { fc::Fcmkey_smenu , "Shift+Ctrl+Meta+Menu" }, { fc::Fmkey_space , "Meta+Space" }, { fc::Fmkey_bang , "Meta+!" }, { fc::Fmkey_quotes , "Meta+\"" }, diff --git a/src/fmenu.cpp b/src/fmenu.cpp index 5875af79..8946d49f 100644 --- a/src/fmenu.cpp +++ b/src/fmenu.cpp @@ -1,8 +1,10 @@ // File: fmenu.cpp // Provides: class FMenu +#include "fapp.h" #include "fmenu.h" #include "fmessagebox.h" // <----- remove later +#include "fstatusbar.h" //---------------------------------------------------------------------- // class FMenu @@ -100,6 +102,7 @@ void FMenu::init(FWidget* parent) right_padding = 1; createArea (vwin); setGeometry (1, 1 , 10, 2, false); // initialize geometry values + setTransparentShadow(); window_object = true; addWindow(this); hide(); @@ -226,6 +229,103 @@ bool FMenu::containsMenuStructure (int x, int y) const return false; } +//---------------------------------------------------------------------- +bool FMenu::selectNextItem() +{ + std::vector::const_iterator iter, end; + iter = itemlist.begin(); + end = itemlist.end(); + + while ( iter != end ) + { + if ( (*iter)->isSelected() ) + { + FMenuItem* next; + std::vector::const_iterator next_element; + + next_element = iter; + do + { + ++next_element; + if ( next_element == itemlist.end() ) + next_element = itemlist.begin(); + next = static_cast(*next_element); + } while ( ! next->isEnabled() + || ! next->acceptFocus() + || ! next->isVisible() + || next->isSeparator() ); + if ( next == *iter ) + return false; + unselectItemInList(); + next->setSelected(); + next->setFocus(); + if ( statusBar() ) + statusBar()->drawMessage(); + selectedListItem = next; + redraw(); + break; + } + ++iter; + } + return true; +} + +//---------------------------------------------------------------------- +bool FMenu::selectPrevItem() +{ + std::vector::const_iterator iter, begin; + iter = itemlist.end(); + begin = itemlist.begin(); + + do + { + --iter; + if ( (*iter)->isSelected() ) + { + FMenuItem* prev; + std::vector::const_iterator prev_element; + + prev_element = iter; + do + { + if ( prev_element == itemlist.begin() ) + prev_element = itemlist.end(); + --prev_element; + prev = static_cast(*prev_element); + } while ( ! prev->isEnabled() + || ! prev->acceptFocus() + || ! prev->isVisible() + || prev->isSeparator() ); + if ( prev == *iter ) + return false; + unselectItemInList(); + prev->setSelected(); + prev->setFocus(); + if ( statusBar() ) + statusBar()->drawMessage(); + selectedListItem = prev; + redraw(); + break; + } + } while ( iter != begin ); + + return true; +} + +//---------------------------------------------------------------------- +void FMenu::keypressMenuBar (FKeyEvent* ev) +{ + FWidget* super = getSuperMenu(); + if ( super ) + { + if ( isMenuBar(super) ) + { + FMenuBar* mb = reinterpret_cast(super); + mb->onKeyPress(ev); + } + } +} + //---------------------------------------------------------------------- int FMenu::getHotkeyPos (wchar_t*& src, wchar_t*& dest, uInt length) { @@ -260,8 +360,8 @@ void FMenu::draw() drawItems(); if ( isMonochron() ) setReverse(false); - //if ( (flags & SHADOW) != 0 ) - // drawMenuShadow(); + if ( (flags & SHADOW) != 0 ) + drawMenuShadow(); setUpdateVTerm(true); } @@ -327,6 +427,12 @@ void FMenu::drawBorder() } } +//---------------------------------------------------------------------- +void FMenu::drawMenuShadow() +{ + drawShadow(); +} + //---------------------------------------------------------------------- void FMenu::drawItems() { @@ -344,87 +450,116 @@ void FMenu::drawItems() FString txt; uInt txt_length; int hotkeypos, to_char; - bool is_Active = (*iter)->isActivated(); - bool is_Selected = (*iter)->isSelected(); - bool is_NoUnderline = (((*iter)->getFlags() & NO_UNDERLINE) != 0); + bool is_enabled = (*iter)->isEnabled(); + bool has_focus = (*iter)->hasFocus(); + bool is_selected = (*iter)->isSelected(); + bool is_noUnderline = (((*iter)->getFlags() & NO_UNDERLINE) != 0); + bool is_separator = (*iter)->isSeparator(); - if ( is_Active ) + if ( is_separator ) { - if ( is_Selected ) - { - foregroundColor = wc.menu_active_focus_fg; - backgroundColor = wc.menu_active_focus_bg; - if ( isMonochron() ) - setReverse(false); - } - else - { - foregroundColor = wc.menu_active_fg; - backgroundColor = wc.menu_active_bg; - } + drawSeparator(y); } else { - foregroundColor = wc.menu_inactive_fg; - backgroundColor = wc.menu_inactive_bg; - } - gotoxy (xpos+xmin, ypos+ymin+y); - setColor (foregroundColor, backgroundColor); - print (' '); - - txt = (*iter)->getText(); - txt_length = uInt(txt.getLength()); - item_text = new wchar_t[txt_length+1](); - src = const_cast(txt.wc_str()); - dest = const_cast(item_text); - to_char = int(txt_length); - hotkeypos = getHotkeyPos (src, dest, txt_length); - - if ( hotkeypos != -1 ) - { - txt_length--; - to_char--; - } - - for (int z=0; z < to_char; z++) - { - if ( ! iswprint(wint_t(item_text[z])) ) + if ( is_enabled ) { - if ( ! isNewFont() && ( int(item_text[z]) < fc::NF_rev_left_arrow2 - || int(item_text[z]) > fc::NF_check_mark ) ) + if ( is_selected ) { - item_text[z] = L' '; + foregroundColor = wc.menu_active_focus_fg; + backgroundColor = wc.menu_active_focus_bg; + if ( isMonochron() ) + setReverse(false); + } + else + { + foregroundColor = wc.menu_active_fg; + backgroundColor = wc.menu_active_bg; } } - if ( (z == hotkeypos) && is_Active && ! is_Selected ) - { - setColor (wc.menu_hotkey_fg, wc.menu_hotkey_bg); - if ( ! is_NoUnderline ) - setUnderline(); - print (item_text[z]); - if ( ! is_NoUnderline ) - unsetUnderline(); - setColor (foregroundColor, backgroundColor); - } else - print (item_text[z]); - } + { + foregroundColor = wc.menu_inactive_fg; + backgroundColor = wc.menu_inactive_bg; + } + gotoxy (xpos+xmin, ypos+ymin+y); + setColor (foregroundColor, backgroundColor); + print (' '); - if ( is_Selected ) + txt = (*iter)->getText(); + txt_length = uInt(txt.getLength()); + item_text = new wchar_t[txt_length+1](); + src = const_cast(txt.wc_str()); + dest = const_cast(item_text); + to_char = int(txt_length); + hotkeypos = getHotkeyPos (src, dest, txt_length); + + if ( hotkeypos != -1 ) + { + txt_length--; + to_char--; + } + + for (int z=0; z < to_char; z++) + { + if ( ! iswprint(wint_t(item_text[z])) ) + { + if ( ! isNewFont() && ( int(item_text[z]) < fc::NF_rev_left_arrow2 + || int(item_text[z]) > fc::NF_check_mark ) ) + { + item_text[z] = L' '; + } + } + if ( (z == hotkeypos) && is_enabled && ! is_selected ) + { + setColor (wc.menu_hotkey_fg, wc.menu_hotkey_bg); + if ( ! is_noUnderline ) + setUnderline(); + print (item_text[z]); + if ( ! is_noUnderline ) + unsetUnderline(); + setColor (foregroundColor, backgroundColor); + } + else + print (item_text[z]); + } + + if ( is_selected ) + { + for (uInt i=uInt(to_char); i < maxItemWidth-1; i++) + print (' '); + } + + if ( isMonochron() && is_enabled && is_selected ) + setReverse(true); + delete[] item_text; + } + if ( has_focus && statusBar() ) { - for (uInt i=uInt(to_char); i < maxItemWidth-1; i++) - print (' '); + FString msg = (*iter)->getStatusbarMessage(); + FString curMsg = statusBar()->getMessage(); + if ( curMsg != msg ) + { + statusBar()->setMessage(msg); + statusBar()->drawMessage(); + } } - - if ( isMonochron() && is_Active && is_Selected ) - setReverse(true); - delete[] item_text; - ++iter; y++; } } +//---------------------------------------------------------------------- +inline void FMenu::drawSeparator(int y) +{ + gotoxy (xpos+xmin-1, ypos+ymin+y); + setColor (wc.menu_active_fg, wc.menu_active_bg); + print(fc::BoxDrawingsVerticalAndRight); + FString line(width-2, wchar_t(fc::BoxDrawingsHorizontal)); + print (line); + print(fc::BoxDrawingsVerticalAndLeft); +} + //---------------------------------------------------------------------- void FMenu::processActivate() { @@ -433,6 +568,86 @@ void FMenu::processActivate() // public methods of FMenu +//---------------------------------------------------------------------- +void FMenu::onKeyPress (FKeyEvent* ev) +{ + switch ( ev->key() ) + { + case fc::Fkey_return: + case fc::Fkey_enter: + if ( hasSelectedListItem() ) + { + FMenuItem* sel_item = selectedListItem; + unselectItemInList(); + hide(); + hideSuperMenus(); + sel_item->processClicked(); + } + ev->accept(); + break; + + case fc::Fkey_up: + selectPrevItem(); + ev->accept(); + break; + + case fc::Fkey_down: + selectNextItem(); + ev->accept(); + break; + + case fc::Fkey_left: + if ( selectedListItem->hasMenu() ) + { + FMenu* sub_menu = selectedListItem->getMenu(); + if ( sub_menu->isVisible() ) + hideSubMenus(); + else + keypressMenuBar(ev); // select previous menu + ev->accept(); + } + else + keypressMenuBar(ev); // select previous menu + break; + + case fc::Fkey_right: + if ( selectedListItem->hasMenu() ) + { + FMenu* sub_menu = selectedListItem->getMenu(); + if ( ! sub_menu->isVisible() ) + { + // open sub menu + sub_menu->selectFirstItemInList(); + sub_menu->getSelectedListItem()->setFocus();; + sub_menu->setVisible(); + sub_menu->show(); + raiseWindow (sub_menu); + sub_menu->redraw(); + updateTerminal(); + flush_out(); + } + else + keypressMenuBar(ev); // select next menu + ev->accept(); + } + else + keypressMenuBar(ev); // select next menu + break; + + case fc::Fkey_escape: + case fc::Fkey_escape_mintty: + unselectItemInList(); + hide(); + hideSubMenus(); + hideSuperMenus(); + ev->accept(); + break; + + default: + break; + } +} + //---------------------------------------------------------------------- void FMenu::onMouseDown (FMouseEvent* ev) { @@ -473,10 +688,17 @@ void FMenu::onMouseDown (FMouseEvent* ev) && mouse_y == y && ! (*iter)->isSelected() ) { + FWidget* focused_widget = getFocusWidget(); + FFocusEvent out (FocusOut_Event); + FApplication::queueEvent(focused_widget, &out); if ( hasSelectedListItem() ) unselectItemInList(); - (*iter)->setSelected(); + (*iter)->setFocus(); + if ( focused_widget ) + focused_widget->redraw(); + if ( statusBar() ) + statusBar()->drawMessage(); selectedListItem = *iter; focus_changed = true; } @@ -577,9 +799,17 @@ FMessageBox::info (this, "Info", FString().sprintf("local(%d,%d) global(%d,%d)\n && mouse_x <= x2 && mouse_y == y ) { - if ( (*iter)->isActivated() && ! (*iter)->isSelected() ) + if ( (*iter)->isEnabled() && ! (*iter)->isSelected() ) { + FWidget* focused_widget = getFocusWidget(); + FFocusEvent out (FocusOut_Event); + FApplication::queueEvent(focused_widget, &out); (*iter)->setSelected(); + (*iter)->setFocus(); + if ( focused_widget ) + focused_widget->redraw(); + if ( statusBar() ) + statusBar()->drawMessage(); selectedListItem = *iter; focus_changed = true; } @@ -587,7 +817,7 @@ FMessageBox::info (this, "Info", FString().sprintf("local(%d,%d) global(%d,%d)\n else { if ( getGeometryGlobal().contains(ev->getGlobalPos()) - && (*iter)->isActivated() + && (*iter)->isEnabled() && (*iter)->isSelected() ) { (*iter)->unsetSelected(); @@ -706,7 +936,7 @@ void FMenu::cb_menuitem_activated (FWidget* widget, void*) menu->setVisible(); menu->show(); - raiseWindow(menu); + raiseWindow (menu); menu->redraw(); updateTerminal(); flush_out(); @@ -716,6 +946,29 @@ void FMenu::cb_menuitem_activated (FWidget* widget, void*) } } +//---------------------------------------------------------------------- +bool FMenu::setTransparentShadow (bool on) +{ + if ( on ) + { + flags |= SHADOW; + flags |= TRANS_SHADOW; + shadow.setPoint(2,1); + adjustWidgetSizeShadow = getGeometry() + getShadow(); + adjustWidgetSizeGlobalShadow = getGeometryGlobal() + getShadow(); + } + else + { + flags &= ~SHADOW; + flags &= ~TRANS_SHADOW; + shadow.setPoint(0,0); + adjustWidgetSizeShadow = getGeometry() + getShadow(); + adjustWidgetSizeGlobalShadow = getGeometryGlobal() + getShadow(); + } + resizeArea (vwin); + return on; +} + //---------------------------------------------------------------------- void FMenu::cb_menuitem_deactivated (FWidget* widget, void*) { diff --git a/src/fmenu.h b/src/fmenu.h index bc7701bb..497fae64 100644 --- a/src/fmenu.h +++ b/src/fmenu.h @@ -65,10 +65,15 @@ class FMenu : public FWindow, public FMenuList void hideSuperMenus(); bool containsMenuStructure (const FPoint&) const; bool containsMenuStructure (int, int) const; + bool selectNextItem(); + bool selectPrevItem(); + void keypressMenuBar (FKeyEvent*); int getHotkeyPos (wchar_t*&, wchar_t*&, uInt); void draw(); void drawBorder(); + void drawMenuShadow(); void drawItems(); + void drawSeparator(int); void processActivate(); public: @@ -79,30 +84,37 @@ class FMenu : public FWindow, public FMenuList virtual ~FMenu(); // destructor virtual const char* getClassName() const; + void onKeyPress (FKeyEvent*); void onMouseDown (FMouseEvent*); void onMouseUp (FMouseEvent*); void onMouseMove (FMouseEvent*); + void onAccel (FAccelEvent*); void show(); void hide(); // make every setGeometry from FWidget available using FWidget::setGeometry; void setGeometry (int, int, int, int, bool = true); FMenuItem* getItem() const; - - void onAccel (FAccelEvent*); FString getText() const; - void setActive(); - void unsetActive(); - bool isActivated() const; + bool setEnable(bool); + bool setEnable(); + bool unsetEnable(); + bool setDisable(); + bool isEnabled() const; void setSelected(); void unsetSelected(); bool isSelected() const; void selectFirstItemInList(); void unselectItemInList(); + FMenuItem* getSelectedListItem() const; bool hasSelectedListItem() const; bool hasHotkey() const; void setMenu (FMenu*); bool hasMenu() const; + bool setTransparentShadow (bool); + bool setTransparentShadow(); + bool unsetTransparentShadow(); + bool hasTransparentShadow(); void setText (FString&); void setText (const std::string&); void setText (const char*); @@ -146,16 +158,24 @@ inline FString FMenu::getText() const { return item->getText(); } //---------------------------------------------------------------------- -inline void FMenu::setActive() -{ item->setActive(); } +inline bool FMenu::setEnable(bool on) +{ return item->setEnable(on); } //---------------------------------------------------------------------- -inline void FMenu::unsetActive() -{ item->unsetActive(); } +inline bool FMenu::setEnable() +{ return item->setEnable(); } //---------------------------------------------------------------------- -inline bool FMenu::isActivated() const -{ return item->isActivated(); } +inline bool FMenu::unsetEnable() +{ return item->unsetEnable(); } + +//---------------------------------------------------------------------- +inline bool FMenu::setDisable() +{ return item->setDisable(); } + +//---------------------------------------------------------------------- +inline bool FMenu::isEnabled() const +{ return item->isEnabled(); } //---------------------------------------------------------------------- inline void FMenu::setSelected() @@ -169,6 +189,10 @@ inline void FMenu::unsetSelected() inline bool FMenu::isSelected() const { return item->isSelected(); } +//---------------------------------------------------------------------- +inline FMenuItem* FMenu::getSelectedListItem() const +{ return selectedListItem; } + //---------------------------------------------------------------------- inline bool FMenu::hasSelectedListItem() const { return selectedListItem; } @@ -185,6 +209,18 @@ inline void FMenu::setMenu (FMenu* m) inline bool FMenu::hasMenu() const { return item->hasMenu(); } +//---------------------------------------------------------------------- +inline bool FMenu::setTransparentShadow() +{ return setTransparentShadow(true); } + +//---------------------------------------------------------------------- +inline bool FMenu::unsetTransparentShadow() +{ return setTransparentShadow(false); } + +//---------------------------------------------------------------------- +inline bool FMenu::hasTransparentShadow() +{ return ((flags & TRANS_SHADOW) != 0); } + //---------------------------------------------------------------------- inline void FMenu::setText (FString& txt) { item->setText(txt); } diff --git a/src/fmenubar.cpp b/src/fmenubar.cpp index 5ed6f94a..78bf9719 100644 --- a/src/fmenubar.cpp +++ b/src/fmenubar.cpp @@ -150,7 +150,7 @@ void FMenuBar::drawItems() int hotkeypos, to_char; bool is_Active, is_Selected, is_NoUnderline; - is_Active = (*iter)->isActivated(); + is_Active = (*iter)->isEnabled(); is_Selected = (*iter)->isSelected(); is_NoUnderline = (((*iter)->getFlags() & NO_UNDERLINE) != 0); @@ -262,6 +262,26 @@ void FMenuBar::adjustSize() } // public methods of FMenuBar +//---------------------------------------------------------------------- +void FMenuBar::onKeyPress (FKeyEvent* ev) +{ + switch ( ev->key() ) + { + case fc::Fkey_left: + beep(); + ev->accept(); + break; + + case fc::Fkey_right: + beep(); + ev->accept(); + break; + + default: + break; + } +} + //---------------------------------------------------------------------- void FMenuBar::onMouseDown (FMouseEvent* ev) { @@ -318,9 +338,10 @@ void FMenuBar::onMouseDown (FMouseEvent* ev) && mouse_x <= x2 && mouse_y == 1 ) { - if ( (*iter)->isActivated() && ! (*iter)->isSelected() ) + if ( (*iter)->isEnabled() && ! (*iter)->isSelected() ) { (*iter)->setSelected(); + (*iter)->setFocus(); selectedMenuItem = *iter; focus_changed = true; } @@ -337,7 +358,7 @@ void FMenuBar::onMouseDown (FMouseEvent* ev) else { if ( mouse_y == 1 - && (*iter)->isActivated() + && (*iter)->isEnabled() && (*iter)->isSelected() ) { (*iter)->unsetSelected(); @@ -382,7 +403,7 @@ void FMenuBar::onMouseUp (FMouseEvent* ev) if ( mouse_x >= x1 && mouse_x <= x2 && mouse_y == 1 - && (*iter)->isActivated() + && (*iter)->isEnabled() && (*iter)->isSelected() ) { if ( (*iter)->hasMenu() ) @@ -391,6 +412,7 @@ void FMenuBar::onMouseUp (FMouseEvent* ev) if ( ! menu->hasSelectedListItem() ) { menu->selectFirstItemInList(); + menu->getSelectedListItem()->setFocus(); menu->redraw(); } } @@ -440,9 +462,10 @@ void FMenuBar::onMouseMove (FMouseEvent* ev) && mouse_x <= x2 && mouse_y == 1 ) { - if ( (*iter)->isActivated() && ! (*iter)->isSelected() ) + if ( (*iter)->isEnabled() && ! (*iter)->isSelected() ) { (*iter)->setSelected(); + (*iter)->setFocus(); selectedMenuItem = *iter; focus_changed = true; } @@ -459,7 +482,7 @@ void FMenuBar::onMouseMove (FMouseEvent* ev) else { if ( getGeometryGlobal().contains(ev->getGlobalPos()) - && (*iter)->isActivated() + && (*iter)->isEnabled() && (*iter)->isSelected() ) { (*iter)->unsetSelected(); @@ -543,7 +566,6 @@ void FMenuBar::cb_item_activated (FWidget* widget, void*) menu->redraw(); updateTerminal(); flush_out(); - } } } diff --git a/src/fmenubar.h b/src/fmenubar.h index 61396079..6a657280 100644 --- a/src/fmenubar.h +++ b/src/fmenubar.h @@ -64,6 +64,7 @@ class FMenuBar : public FWindow, public FMenuList virtual ~FMenuBar(); // destructor virtual const char* getClassName() const; + void onKeyPress (FKeyEvent*); void onMouseDown (FMouseEvent*); void onMouseUp (FMouseEvent*); void onMouseMove (FMouseEvent*); diff --git a/src/fmenuitem.cpp b/src/fmenuitem.cpp index 4d5527c6..a5fc2f2a 100644 --- a/src/fmenuitem.cpp +++ b/src/fmenuitem.cpp @@ -1,10 +1,12 @@ // File: fmenuitem.cpp // Provides: class FMenuItem +#include "fapp.h" #include "fmenu.h" #include "fmenubar.h" #include "fmenulist.h" #include "fmenuitem.h" +#include "fstatusbar.h" //---------------------------------------------------------------------- // class FMenuItem @@ -15,7 +17,6 @@ FMenuItem::FMenuItem (FWidget* parent) : FWidget(parent) , text() - , active(true) , selected(false) , separator(false) , checked(false) @@ -32,7 +33,6 @@ FMenuItem::FMenuItem (FWidget* parent) FMenuItem::FMenuItem (FString& txt, FWidget* parent) : FWidget(parent) , text(txt) - , active(true) , selected(false) , separator(false) , checked(false) @@ -49,7 +49,6 @@ FMenuItem::FMenuItem (FString& txt, FWidget* parent) FMenuItem::FMenuItem (const std::string& txt, FWidget* parent) : FWidget(parent) , text(txt) - , active(true) , selected(false) , separator(false) , checked(false) @@ -66,7 +65,6 @@ FMenuItem::FMenuItem (const std::string& txt, FWidget* parent) FMenuItem::FMenuItem (const char* txt, FWidget* parent) : FWidget(parent) , text(txt) - , active(true) , selected(false) , separator(false) , checked(false) @@ -108,7 +106,7 @@ void FMenuItem::init (FWidget* parent) menubar_ptr->menu_dimension(); // Meta + hotkey - addAccelerator (0x20000e0+tolower(hotkey), this); + menubar_ptr->addAccelerator (0x20000e0+tolower(hotkey), this); this->addCallback ( @@ -127,7 +125,7 @@ void FMenuItem::init (FWidget* parent) if ( super_menu_ptr ) super_menu_ptr->menu_dimension(); - //addAccelerator (item->getKey(), item); + //addAccelerator (accel_key, this); this->addCallback ( @@ -141,6 +139,11 @@ void FMenuItem::init (FWidget* parent) ); } } + if ( hasFocus() ) + flags = FOCUS; + + if ( isEnabled() ) + flags |= ACTIVE; } //---------------------------------------------------------------------- @@ -202,21 +205,22 @@ void FMenuItem::processClicked() // public methods of FMenuItem //---------------------------------------------------------------------- -void FMenuItem::onAccel (FAccelEvent* ev) +void FMenuItem::onKeyPress (FKeyEvent* ev) { - beep(); // activate by key - if ( isActivated() && ! isSelected() ) + if ( super_menu ) { - if ( super_menu && isMenuBar(super_menu) ) + if ( isMenu(super_menu) ) + { + FMenu* sm = dynamic_cast(super_menu); + if ( sm ) + sm->onKeyPress(ev); + } + + if ( isMenuBar(super_menu) ) { FMenuBar* mb = dynamic_cast(super_menu); if ( mb ) - { - setSelected(); - mb->selectedMenuItem = this; - mb->redraw(); - ev->accept(); - } + mb->onKeyPress(ev); } } } @@ -252,7 +256,6 @@ void FMenuItem::onMouseDown (FMouseEvent* ev) delete ev; } } - } } @@ -287,7 +290,6 @@ void FMenuItem::onMouseUp (FMouseEvent* ev) delete ev; } } - } } @@ -326,10 +328,118 @@ void FMenuItem::onMouseMove (FMouseEvent* ev) } } +//---------------------------------------------------------------------- +void FMenuItem::onAccel (FAccelEvent* ev) +{ + if ( isEnabled() && ! isSelected() ) + { + if ( super_menu && isMenuBar(super_menu) ) + { + FMenuBar* mb = dynamic_cast(super_menu); + if ( mb ) + { + if ( mb->selectedMenuItem ) + mb->selectedMenuItem->unsetSelected(); + setSelected(); + mb->selectedMenuItem = this; + mb->redraw(); + if ( menu && ! menu->hasSelectedListItem() ) + { + FWidget* focused_widget = static_cast(ev->focusedWidget()); + FFocusEvent out (FocusOut_Event); + FApplication::queueEvent(focused_widget, &out); + menu->selectFirstItemInList(); + menu->selectedListItem->setFocus(); + if ( focused_widget ) + focused_widget->redraw(); + menu->redraw(); + if ( statusBar() ) + statusBar()->drawMessage(); + } + ev->accept(); + } + } + } +} + +//---------------------------------------------------------------------- +void FMenuItem::onFocusIn (FFocusEvent*) +{ + if ( statusBar() ) + statusBar()->drawMessage(); +} + +//---------------------------------------------------------------------- +void FMenuItem::onFocusOut (FFocusEvent*) +{ + if ( statusBar() ) + { + statusBar()->clearMessage(); + statusBar()->drawMessage(); + } +} + +//---------------------------------------------------------------------- +bool FMenuItem::setEnable (bool on) +{ + FWidget::setEnable(on); + + FWidget* super = getSuperMenu(); + + if ( on ) + { + flags |= ACTIVE; + + if ( super && isMenuBar(super) ) + { + // Meta + hotkey + super->addAccelerator (0x20000e0+tolower(hotkey), this); + } + } + else + { + flags &= ~ACTIVE; + + if ( super && isMenuBar(super) ) + super->delAccelerator (this); + } + return on; +} + +//---------------------------------------------------------------------- +bool FMenuItem::setFocus (bool on) +{ + FWidget::setFocus(on); + + if ( on ) + { + flags |= FOCUS; + + if ( isEnabled() ) + { + /*if ( statusBar() ) + { + FString msg = getStatusbarMessage(); + FString curMsg = statusBar()->getMessage(); + if ( curMsg != msg ) + statusBar()->setMessage(msg); + }*/ + } + } + else + { + flags &= ~FOCUS; + + if ( isEnabled() && statusBar() ) + statusBar()->clearMessage(); + } + return on; +} + //---------------------------------------------------------------------- void FMenuItem::setSelected() { - if ( isActivated() ) + if ( isEnabled() ) { selected = true; processActivate(); diff --git a/src/fmenuitem.h b/src/fmenuitem.h index de1cb74e..2c67546d 100644 --- a/src/fmenuitem.h +++ b/src/fmenuitem.h @@ -44,7 +44,6 @@ class FMenuItem : public FWidget { private: FString text; - bool active; bool selected; bool separator; bool checked; @@ -74,14 +73,20 @@ class FMenuItem : public FWidget FMenuItem (const char*, FWidget* = 0); virtual ~FMenuItem(); - void onAccel (FAccelEvent*); + void onKeyPress (FKeyEvent*); void onMouseDown (FMouseEvent*); void onMouseUp (FMouseEvent*); void onMouseMove (FMouseEvent*); + void onAccel (FAccelEvent*); + void onFocusIn (FFocusEvent*); + void onFocusOut (FFocusEvent*); FString getText() const; - void setActive(); - void unsetActive(); - bool isActivated() const; + // make every setEnable from FWidget available + using FWidget::setEnable; + bool setEnable(bool); + bool setFocus(bool); + bool setFocus(); + bool unsetFocus(); void setSelected(); void unsetSelected(); bool isSelected() const; @@ -122,16 +127,12 @@ inline FString FMenuItem::getText() const { return text; } //---------------------------------------------------------------------- -inline void FMenuItem::setActive() -{ active = true; } +inline bool FMenuItem::setFocus() +{ return setFocus(true); } //---------------------------------------------------------------------- -inline void FMenuItem::unsetActive() -{ active = false; } - -//---------------------------------------------------------------------- -inline bool FMenuItem::isActivated() const -{ return active; } +inline bool FMenuItem::unsetFocus() +{ return setFocus(false); } //---------------------------------------------------------------------- inline bool FMenuItem::isSelected() const diff --git a/src/fmenulist.h b/src/fmenulist.h index 0cb25593..7d7700d3 100644 --- a/src/fmenulist.h +++ b/src/fmenulist.h @@ -51,8 +51,8 @@ class FMenuList uInt count() const; FMenuItem* item (int) const; - void activateItem (int); - void deactivateItem (int); + void enableItem (int); + void disableItem (int); bool isSelected (int) const; bool hasSelectedItem(); @@ -78,12 +78,12 @@ inline FMenuItem* FMenuList::item(int index) const { return itemlist[uInt(index-1)]; } //---------------------------------------------------------------------- -inline void FMenuList::activateItem (int index) -{ itemlist[uInt(index-1)]->setActive(); } +inline void FMenuList::enableItem (int index) +{ itemlist[uInt(index-1)]->setEnable(); } //---------------------------------------------------------------------- -inline void FMenuList::deactivateItem (int index) -{ itemlist[uInt(index-1)]->unsetActive(); } +inline void FMenuList::disableItem (int index) +{ itemlist[uInt(index-1)]->unsetEnable(); } //---------------------------------------------------------------------- inline bool FMenuList::isSelected(int index) const diff --git a/src/fprogressbar.cpp b/src/fprogressbar.cpp index 88019c6a..11958185 100644 --- a/src/fprogressbar.cpp +++ b/src/fprogressbar.cpp @@ -43,7 +43,7 @@ void FProgressbar::drawBar() { int i = 1; float length = float(BarLength*percentage)/100; - + gotoxy (xpos+xmin-1, ypos+ymin-1); if ( isMonochron() ) { diff --git a/src/fterm.cpp b/src/fterm.cpp index d34c65f6..eacccb22 100644 --- a/src/fterm.cpp +++ b/src/fterm.cpp @@ -1398,7 +1398,7 @@ void FTerm::init() xterm = true; else xterm = false; - + // Test for Linux console if ( strncmp(termtype, const_cast("linux"), 5) == 0 || strncmp(termtype, const_cast("con"), 3) == 0 ) @@ -1538,7 +1538,10 @@ void FTerm::init() if ( kde_konsole ) setKDECursor(fc::UnderlineCursor); - if ( max_color >= 16 && ! kde_konsole && ! tera_terminal ) + if ( max_color >= 16 + && ! cygwin_terminal + && ! kde_konsole + && ! tera_terminal ) { resetColorMap(); saveColorMap(); diff --git a/src/fwidget.cpp b/src/fwidget.cpp index edceaf09..15ae39ec 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -207,9 +207,9 @@ void FWidget::setColorTheme() wc.current_element_fg = fc::LightGray; wc.current_element_bg = fc::Blue; wc.current_inc_search_element_fg = fc::LightRed; - wc.selected_current_element_focus_fg = fc::LightBlue; + wc.selected_current_element_focus_fg = fc::LightCyan; wc.selected_current_element_focus_bg = fc::Blue; - wc.selected_current_element_fg = fc::Cyan; + wc.selected_current_element_fg = fc::LightBlue; wc.selected_current_element_bg = fc::Blue; wc.label_fg = fc::Black; wc.label_bg = fc::White; @@ -1074,7 +1074,7 @@ void FWidget::addAccelerator (int key) if ( ! window ) window = getRootWidget(); - if ( window == statusbar ) + if ( window == statusbar || window == menubar ) window = FWindow::getWindowWidget(parentWidget()); if ( window && window->accelerator_list ) window->accelerator_list->push_back(accel); @@ -1088,7 +1088,7 @@ void FWidget::addAccelerator (int key, FWidget* obj) if ( ! window ) window = getRootWidget(); - if ( window == statusbar ) + if ( window == statusbar || window == menubar ) window = FWindow::getWindowWidget(parentWidget()); if ( window && window->accelerator_list ) window->accelerator_list->push_back(accel); @@ -1101,7 +1101,7 @@ void FWidget::delAccelerator (FWidget* obj) if ( ! window ) window = getRootWidget(); - if ( window == statusbar ) + if ( window == statusbar || window == menubar ) window = FWindow::getWindowWidget(parentWidget()); if ( window && window->accelerator_list @@ -1329,6 +1329,30 @@ void FWidget::hide() } } +//---------------------------------------------------------------------- +bool FWidget::setEnable (bool on) +{ + return enable = (on) ? true : false; +} + +//---------------------------------------------------------------------- +bool FWidget::setEnable() +{ + return setEnable(true); +} + +//---------------------------------------------------------------------- +bool FWidget::unsetEnable() +{ + return setEnable(false); +} + +//---------------------------------------------------------------------- +bool FWidget::setDisable() +{ + return setEnable(false); +} + //---------------------------------------------------------------------- bool FWidget::focusFirstChild (void) { diff --git a/src/fwidget.h b/src/fwidget.h index d0681f26..ec2088d3 100644 --- a/src/fwidget.h +++ b/src/fwidget.h @@ -529,22 +529,6 @@ inline bool FWidget::isShown() const inline bool FWidget::isWindow() const { return window_object; } -//---------------------------------------------------------------------- -inline bool FWidget::setEnable (bool on) -{ return enable = (on) ? true : false; } - -//---------------------------------------------------------------------- -inline bool FWidget::setEnable() -{ return setEnable(true); } - -//---------------------------------------------------------------------- -inline bool FWidget::unsetEnable() -{ return setEnable(false); } - -//---------------------------------------------------------------------- -inline bool FWidget::setDisable() -{ return setEnable(false); } - //---------------------------------------------------------------------- inline bool FWidget::isEnabled() const { return enable; } diff --git a/test/Makefile.am b/test/Makefile.am index 92eb6bd7..2f6cfacb 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -13,6 +13,7 @@ noinst_PROGRAMS = \ mandelbrot \ calculator \ watch \ + keyboard \ timer \ ui @@ -23,6 +24,7 @@ string_operations_SOURCES = string-operations.cpp mandelbrot_SOURCES = mandelbrot.cpp calculator_SOURCES = calculator.cpp watch_SOURCES = watch.cpp +keyboard_SOURCES = keyboard.cpp timer_SOURCES = timer.cpp ui_SOURCES = ui.cpp diff --git a/test/Makefile.in b/test/Makefile.in index 5c08b674..f330ad18 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -84,7 +84,8 @@ build_triplet = @build@ host_triplet = @host@ noinst_PROGRAMS = hello$(EXEEXT) dialog$(EXEEXT) input-dialog$(EXEEXT) \ string-operations$(EXEEXT) mandelbrot$(EXEEXT) \ - calculator$(EXEEXT) watch$(EXEEXT) timer$(EXEEXT) ui$(EXEEXT) + calculator$(EXEEXT) watch$(EXEEXT) keyboard$(EXEEXT) \ + timer$(EXEEXT) ui$(EXEEXT) subdir = test DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \ $(top_srcdir)/depcomp @@ -116,6 +117,9 @@ hello_LDADD = $(LDADD) am_input_dialog_OBJECTS = input-dialog.$(OBJEXT) input_dialog_OBJECTS = $(am_input_dialog_OBJECTS) input_dialog_LDADD = $(LDADD) +am_keyboard_OBJECTS = keyboard.$(OBJEXT) +keyboard_OBJECTS = $(am_keyboard_OBJECTS) +keyboard_LDADD = $(LDADD) am_mandelbrot_OBJECTS = mandelbrot.$(OBJEXT) mandelbrot_OBJECTS = $(am_mandelbrot_OBJECTS) mandelbrot_LDADD = $(LDADD) @@ -166,13 +170,13 @@ am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) am__v_CXXLD_0 = @echo " CXXLD " $@; am__v_CXXLD_1 = SOURCES = $(calculator_SOURCES) $(dialog_SOURCES) $(hello_SOURCES) \ - $(input_dialog_SOURCES) $(mandelbrot_SOURCES) \ - $(string_operations_SOURCES) $(timer_SOURCES) $(ui_SOURCES) \ - $(watch_SOURCES) + $(input_dialog_SOURCES) $(keyboard_SOURCES) \ + $(mandelbrot_SOURCES) $(string_operations_SOURCES) \ + $(timer_SOURCES) $(ui_SOURCES) $(watch_SOURCES) DIST_SOURCES = $(calculator_SOURCES) $(dialog_SOURCES) \ - $(hello_SOURCES) $(input_dialog_SOURCES) $(mandelbrot_SOURCES) \ - $(string_operations_SOURCES) $(timer_SOURCES) $(ui_SOURCES) \ - $(watch_SOURCES) + $(hello_SOURCES) $(input_dialog_SOURCES) $(keyboard_SOURCES) \ + $(mandelbrot_SOURCES) $(string_operations_SOURCES) \ + $(timer_SOURCES) $(ui_SOURCES) $(watch_SOURCES) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ @@ -328,6 +332,7 @@ string_operations_SOURCES = string-operations.cpp mandelbrot_SOURCES = mandelbrot.cpp calculator_SOURCES = calculator.cpp watch_SOURCES = watch.cpp +keyboard_SOURCES = keyboard.cpp timer_SOURCES = timer.cpp ui_SOURCES = ui.cpp all: all-am @@ -390,6 +395,10 @@ input-dialog$(EXEEXT): $(input_dialog_OBJECTS) $(input_dialog_DEPENDENCIES) $(EX @rm -f input-dialog$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(input_dialog_OBJECTS) $(input_dialog_LDADD) $(LIBS) +keyboard$(EXEEXT): $(keyboard_OBJECTS) $(keyboard_DEPENDENCIES) $(EXTRA_keyboard_DEPENDENCIES) + @rm -f keyboard$(EXEEXT) + $(AM_V_CXXLD)$(CXXLINK) $(keyboard_OBJECTS) $(keyboard_LDADD) $(LIBS) + mandelbrot$(EXEEXT): $(mandelbrot_OBJECTS) $(mandelbrot_DEPENDENCIES) $(EXTRA_mandelbrot_DEPENDENCIES) @rm -f mandelbrot$(EXEEXT) $(AM_V_CXXLD)$(CXXLINK) $(mandelbrot_OBJECTS) $(mandelbrot_LDADD) $(LIBS) @@ -420,6 +429,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dialog.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hello.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/input-dialog.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/keyboard.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mandelbrot.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/string-operations.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timer.Po@am__quote@ diff --git a/test/keyboard.cpp b/test/keyboard.cpp new file mode 100644 index 00000000..d78273ce --- /dev/null +++ b/test/keyboard.cpp @@ -0,0 +1,58 @@ +// File: keyboard.cpp + +#include "final.h" + +//---------------------------------------------------------------------- +// class keyboard +//---------------------------------------------------------------------- + +class keyboard : public FWidget +{ + public: + explicit keyboard (FWidget* = 0); + protected: + void onKeyPress (FKeyEvent*); + void onAccel (FAccelEvent*); +}; + +//---------------------------------------------------------------------- +keyboard::keyboard (FWidget* parent) + : FWidget(parent) +{ + setColor(fc::LightGray, fc::Black); + clrscr(); + updateTerminal(); +} + +//---------------------------------------------------------------------- +void keyboard::onKeyPress (FKeyEvent* ev) +{ + int key_id = ev->key(); + ::printf("Key %s (id %d)\n\r", getKeyName(key_id).c_str(), key_id); +} + +//---------------------------------------------------------------------- +void keyboard::onAccel (FAccelEvent* ev) +{ + quit(); + ev->accept(); +} + + +//---------------------------------------------------------------------- +// main part +//---------------------------------------------------------------------- +int main (int argc, char* argv[]) +{ + FApplication app(argc, argv); + keyboard t(&app); + t.addAccelerator('q'); + app.setMainWidget(&t); + t.show(); + t.setTermXY(0,0); + t.flush_out(); + ::printf("---------------\n\r"); + ::printf("Press Q to quit\n\r"); + ::printf("---------------\n\r\n"); + return app.exec(); +} diff --git a/test/timer.cpp b/test/timer.cpp index 494d0d92..419a40ea 100644 --- a/test/timer.cpp +++ b/test/timer.cpp @@ -11,13 +11,13 @@ class timer : public FWidget public: explicit timer (FWidget* = 0); protected: - virtual void draw(); void onTimer (FTimerEvent*); void onAccel (FAccelEvent*); }; //---------------------------------------------------------------------- -timer::timer (FWidget* parent) : FWidget(parent) +timer::timer (FWidget* parent) + : FWidget(parent) { addTimer (60000); // 1-minute timer int id = addTimer (50); // 50-millisecond timer @@ -30,15 +30,6 @@ timer::timer (FWidget* parent) : FWidget(parent) updateTerminal(); } -//---------------------------------------------------------------------- -void timer::draw() -{ - setTermXY(1,2); - ::printf("---------------\n\r"); - ::printf("Press Q to quit\n\r"); - ::printf("---------------\n\r\n"); -} - //---------------------------------------------------------------------- void timer::onTimer (FTimerEvent* ev) { @@ -63,5 +54,10 @@ int main (int argc, char* argv[]) t.addAccelerator('q'); app.setMainWidget(&t); t.show(); + t.setTermXY(0,0); + t.flush_out(); + ::printf("---------------\n\r"); + ::printf("Press Q to quit\n\r"); + ::printf("---------------\n\r\n"); return app.exec(); } diff --git a/test/ui.cpp b/test/ui.cpp index a264c18a..7533d2d4 100644 --- a/test/ui.cpp +++ b/test/ui.cpp @@ -172,7 +172,8 @@ class MyDialog : public FDialog void onClose (FCloseEvent*); void cb_noFunctionMsg (FWidget*, void*); void cb_about (FWidget*, void*); - void cb_info (FWidget*, void*); + void cb_terminfo (FWidget*, void*); + void cb_drives (FWidget*, void*); void cb_input2buttonText (FWidget*, void*); void cb_setTitlebar (FWidget*, void*); void cb_ProgressBar (FWidget*, void*); @@ -192,19 +193,24 @@ MyDialog::MyDialog (FWidget* parent) , myList() { /* .--------------------------------------------. */ - /* v This Code is working in progress v * / + /* v This Code is working in progress v */ FMenuBar* Menubar = new FMenuBar(this); FMenu* File = new FMenu("&File", Menubar); + File->setStatusbarMessage("File management commands"); FMenu* Edit = new FMenu("&Edit", Menubar); FMenu* View = new FMenu("&View", Menubar); - FMenuItem* Options = new FMenuItem("&Options", Menubar); - Options->unsetActive(); + FMenuItem* Options = new FMenuItem("&Options", Menubar); + Options->setDisable(); FMenuItem* Help = new FMenuItem("&Help", Menubar); FMenuItem* Open = new FMenuItem("&Open...", File); + Open->setStatusbarMessage("Locate and open a text file"); + FMenuItem* Line = new FMenuItem(File); + Line->setSeparator(); FMenuItem* Quit = new FMenuItem("&Quit", File); + Quit->setStatusbarMessage("Exit the program"); FMenuItem* Cut = new FMenuItem("Cu&t", Edit); FMenuItem* Copy = new FMenuItem("&Copy", Edit); @@ -241,12 +247,12 @@ MyDialog::MyDialog (FWidget* parent) Env->addCallback ( "clicked", - _METHOD_CALLBACK (this, &MyDialog::cb_info) + _METHOD_CALLBACK (this, &MyDialog::cb_terminfo) ); Drive->addCallback ( "clicked", - _METHOD_CALLBACK (this, &MyDialog::cb_info) + _METHOD_CALLBACK (this, &MyDialog::cb_drives) ); Options->addCallback ( @@ -259,7 +265,7 @@ MyDialog::MyDialog (FWidget* parent) _METHOD_CALLBACK (this, &MyDialog::cb_about) ); - / * ^ This Code is working in progress ^ */ + /* ^ This Code is working in progress ^ */ /* '--------------------------------------------' */ FButton* MyButton1 = new FButton(this); @@ -289,7 +295,7 @@ MyDialog::MyDialog (FWidget* parent) radioButtonGroup->setGeometry(3, 8, 14, 4); //radioButtonGroup->unsetBorder(); - FRadioButton* radio1 = new FRadioButton("&Enable", radioButtonGroup); + FRadioButton* radio1 = new FRadioButton("E&nable", radioButtonGroup); radio1->setGeometry(1, 1, 7, 1); radio1->setStatusbarMessage("Enable button Test"); @@ -303,7 +309,7 @@ MyDialog::MyDialog (FWidget* parent) FButtonGroup* checkButtonGroup = new FButtonGroup("Options", this); checkButtonGroup->setGeometry(3, 12, 14, 4); - FCheckBox* check1 = new FCheckBox("&Fastmode", checkButtonGroup); + FCheckBox* check1 = new FCheckBox("&Bitmode", checkButtonGroup); check1->setGeometry(1, 1, 7, 1); check1->setNoUnderline(); @@ -313,38 +319,32 @@ MyDialog::MyDialog (FWidget* parent) check2->setNoUnderline(); FLineEdit* MyLineEdit = new FLineEdit(this); - MyLineEdit->setGeometry(21, 1, 10, 1); + MyLineEdit->setGeometry(22, 1, 10, 1); MyLineEdit->setText( FString("EnTry").toLower()); MyLineEdit->setLabelText(L"&Input:"); MyLineEdit->setStatusbarMessage("Press Enter to set the title"); MyLineEdit->setShadow(); FButton* MyButton4 = new FButton(this); - MyButton4->setGeometry(19, 8, 12, 1); - MyButton4->setText(L"&Test"); - MyButton4->setStatusbarMessage("Progressbar testing dialog"); + MyButton4->setGeometry(20, 8, 12, 1); + MyButton4->setText(L"&Get input"); + MyButton4->setStatusbarMessage("Take text from input field"); MyButton4->setShadow(); - MyButton4->setDisable(); + MyButton4->setFocus(); FButton* MyButton5 = new FButton(this); - MyButton5->setGeometry(19, 11, 12, 1); - MyButton5->setText(L"Environs"); - MyButton5->setStatusbarMessage("Show environment settings"); + MyButton5->setGeometry(20, 11, 12, 1); + MyButton5->setText(L"&Test"); + MyButton5->setStatusbarMessage("Progressbar testing dialog"); MyButton5->setShadow(); + MyButton5->setDisable(); FButton* MyButton6 = new FButton(this); - MyButton6->setGeometry(19, 14, 12, 1); - MyButton6->setText(L"&Get input"); - MyButton6->setStatusbarMessage("Take text from input field"); + MyButton6->setGeometry(20, 14, 12, 1); + MyButton6->setText(L"&Quit"); + MyButton6->setStatusbarMessage("Exit the program"); MyButton6->setShadow(); - MyButton6->setFocus(); - - FButton* MyButton7 = new FButton(this); - MyButton7->setGeometry(19, 17, 12, 1); - MyButton7->setText(L"&Quit"); - MyButton7->setStatusbarMessage("Exit the program"); - MyButton7->setShadow(); - MyButton7->addAccelerator('x'); + MyButton6->addAccelerator('x'); myList = new FListBox(this); myList->setGeometry(38, 1, 14, 17); @@ -355,24 +355,24 @@ MyDialog::MyDialog (FWidget* parent) myList->insert( FString().setNumber(z) + L" placeholder" ); FLabel* headline = new FLabel(this); - headline->setGeometry(20, 3, 10, 1); + headline->setGeometry(21, 3, 10, 1); headline->setText(L"List items"); headline->setEmphasis(); headline->setAlignment(fc::alignCenter); FLabel* tagged = new FLabel(L"Tagged:", this); - tagged->setGeometry(20, 4, 7, 1); + tagged->setGeometry(21, 4, 7, 1); FLabel* tagged_count = new FLabel(this); - tagged_count->setGeometry(28, 4, 5, 1); + tagged_count->setGeometry(29, 4, 5, 1); tagged_count->setNumber(0); FLabel* sum = new FLabel(L"Sum:", this); - sum->setGeometry(20, 5, 7, 3); + sum->setGeometry(21, 5, 7, 3); sum->setAlignment(fc::alignRight); FLabel* sum_count = new FLabel(this); - sum_count->setGeometry(28, 5, 5, 3); + sum_count->setGeometry(29, 5, 5, 3); sum_count->setNumber(myList->count()); FStatusBar* statusbar = new FStatusBar(this); @@ -401,23 +401,17 @@ MyDialog::MyDialog (FWidget* parent) MyButton4->addCallback ( "clicked", - _METHOD_CALLBACK (this, &MyDialog::cb_ProgressBar) + _METHOD_CALLBACK (this, &MyDialog::cb_input2buttonText), + dynamic_cast(MyLineEdit) ); MyButton5->addCallback ( "clicked", - _METHOD_CALLBACK (this, &MyDialog::cb_info) + _METHOD_CALLBACK (this, &MyDialog::cb_ProgressBar) ); MyButton6->addCallback - ( - "clicked", - _METHOD_CALLBACK (this, &MyDialog::cb_input2buttonText), - dynamic_cast(MyLineEdit) - ); - - MyButton7->addCallback ( "clicked", _METHOD_CALLBACK (this, &MyDialog::cb_exitApp) @@ -433,7 +427,7 @@ MyDialog::MyDialog (FWidget* parent) ( "toggled", _METHOD_CALLBACK (this, &MyDialog::cb_activateButton), - dynamic_cast(MyButton4) + dynamic_cast(MyButton5) ); myList->addCallback @@ -513,19 +507,21 @@ void MyDialog::cb_about (FWidget*, void*) } //---------------------------------------------------------------------- -void MyDialog::cb_info (FWidget*, void*) +void MyDialog::cb_terminfo (FWidget*, void*) { - { - FMessageBox info1 ( "Environment" - , " Type: " + FString(getTermType()) + "\n" - " Name: " + FString(getTermName()) + "\n" - " Mode: " + FString(getEncoding()) - , FMessageBox::Ok, 0, 0, this ); - info1.setHeadline("Terminal:"); - info1.exec(); - } // end of scope => delete info1 + FMessageBox info1 ( "Environment" + , " Type: " + FString(getTermType()) + "\n" + " Name: " + FString(getTermName()) + "\n" + " Mode: " + FString(getEncoding()) + "\n" + "Colors: " + FString().setNumber(getMaxColor()) + , FMessageBox::Ok, 0, 0, this ); + info1.setHeadline("Terminal:"); + info1.exec(); +} - FString line(15, wchar_t(fc::BoxDrawingsHorizontal)); +//---------------------------------------------------------------------- +void MyDialog::cb_drives (FWidget*, void*) +{ FMessageBox info2 ( "Drive symbols" , "Generic: \n\n" "Network: \n\n"