Support for the menu key
This commit is contained in:
parent
825e7fc959
commit
60fe968ce0
|
@ -1,3 +1,6 @@
|
|||
2015-10-29 Markus Gans <guru.mail@muenster.de>
|
||||
* Support for the menu key
|
||||
|
||||
2015-10-23 Markus Gans <guru.mail@muenster.de>
|
||||
* Color setting improvements
|
||||
|
||||
|
|
1
doc/TODO
1
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"
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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+\"" },
|
||||
|
|
285
src/fmenu.cpp
285
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<FMenuItem*>::const_iterator iter, end;
|
||||
iter = itemlist.begin();
|
||||
end = itemlist.end();
|
||||
|
||||
while ( iter != end )
|
||||
{
|
||||
if ( (*iter)->isSelected() )
|
||||
{
|
||||
FMenuItem* next;
|
||||
std::vector<FMenuItem*>::const_iterator next_element;
|
||||
|
||||
next_element = iter;
|
||||
do
|
||||
{
|
||||
++next_element;
|
||||
if ( next_element == itemlist.end() )
|
||||
next_element = itemlist.begin();
|
||||
next = static_cast<FMenuItem*>(*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<FMenuItem*>::const_iterator iter, begin;
|
||||
iter = itemlist.end();
|
||||
begin = itemlist.begin();
|
||||
|
||||
do
|
||||
{
|
||||
--iter;
|
||||
if ( (*iter)->isSelected() )
|
||||
{
|
||||
FMenuItem* prev;
|
||||
std::vector<FMenuItem*>::const_iterator prev_element;
|
||||
|
||||
prev_element = iter;
|
||||
do
|
||||
{
|
||||
if ( prev_element == itemlist.begin() )
|
||||
prev_element = itemlist.end();
|
||||
--prev_element;
|
||||
prev = static_cast<FMenuItem*>(*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<FMenuBar*>(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,13 +450,21 @@ 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 )
|
||||
drawSeparator(y);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( is_enabled )
|
||||
{
|
||||
if ( is_selected )
|
||||
{
|
||||
foregroundColor = wc.menu_active_focus_fg;
|
||||
backgroundColor = wc.menu_active_focus_bg;
|
||||
|
@ -396,13 +510,13 @@ void FMenu::drawItems()
|
|||
item_text[z] = L' ';
|
||||
}
|
||||
}
|
||||
if ( (z == hotkeypos) && is_Active && ! is_Selected )
|
||||
if ( (z == hotkeypos) && is_enabled && ! is_selected )
|
||||
{
|
||||
setColor (wc.menu_hotkey_fg, wc.menu_hotkey_bg);
|
||||
if ( ! is_NoUnderline )
|
||||
if ( ! is_noUnderline )
|
||||
setUnderline();
|
||||
print (item_text[z]);
|
||||
if ( ! is_NoUnderline )
|
||||
if ( ! is_noUnderline )
|
||||
unsetUnderline();
|
||||
setColor (foregroundColor, backgroundColor);
|
||||
}
|
||||
|
@ -410,21 +524,42 @@ void FMenu::drawItems()
|
|||
print (item_text[z]);
|
||||
}
|
||||
|
||||
if ( is_Selected )
|
||||
if ( is_selected )
|
||||
{
|
||||
for (uInt i=uInt(to_char); i < maxItemWidth-1; i++)
|
||||
print (' ');
|
||||
}
|
||||
|
||||
if ( isMonochron() && is_Active && is_Selected )
|
||||
if ( isMonochron() && is_enabled && is_selected )
|
||||
setReverse(true);
|
||||
delete[] item_text;
|
||||
|
||||
}
|
||||
if ( has_focus && statusBar() )
|
||||
{
|
||||
FString msg = (*iter)->getStatusbarMessage();
|
||||
FString curMsg = statusBar()->getMessage();
|
||||
if ( curMsg != msg )
|
||||
{
|
||||
statusBar()->setMessage(msg);
|
||||
statusBar()->drawMessage();
|
||||
}
|
||||
}
|
||||
++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();
|
||||
|
@ -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*)
|
||||
{
|
||||
|
|
58
src/fmenu.h
58
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); }
|
||||
|
|
|
@ -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();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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*);
|
||||
|
|
|
@ -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<FMenu*>(super_menu);
|
||||
if ( sm )
|
||||
sm->onKeyPress(ev);
|
||||
}
|
||||
|
||||
if ( isMenuBar(super_menu) )
|
||||
{
|
||||
FMenuBar* mb = dynamic_cast<FMenuBar*>(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<FMenuBar*>(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<FWidget*>(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();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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@
|
||||
|
|
|
@ -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();
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
|
|
86
test/ui.cpp
86
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*);
|
||||
|
@ -197,14 +198,19 @@ MyDialog::MyDialog (FWidget* parent)
|
|||
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();
|
||||
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
|
||||
(
|
||||
|
@ -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<FWidget::data_ptr>(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<FWidget::data_ptr>(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<FWidget::data_ptr>(MyButton4)
|
||||
dynamic_cast<FWidget::data_ptr>(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())
|
||||
" Mode: " + FString(getEncoding()) + "\n"
|
||||
"Colors: " + FString().setNumber(getMaxColor())
|
||||
, FMessageBox::Ok, 0, 0, this );
|
||||
info1.setHeadline("Terminal:");
|
||||
info1.exec();
|
||||
} // end of scope => delete info1
|
||||
}
|
||||
|
||||
FString line(15, wchar_t(fc::BoxDrawingsHorizontal));
|
||||
//----------------------------------------------------------------------
|
||||
void MyDialog::cb_drives (FWidget*, void*)
|
||||
{
|
||||
FMessageBox info2 ( "Drive symbols"
|
||||
, "Generic: \n\n"
|
||||
"Network: \n\n"
|
||||
|
|
Loading…
Reference in New Issue