diff --git a/.gitignore b/.gitignore index c2a1d486..3d2958c1 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,12 @@ *.gcno *.gcda _configs.sed -config.* +config.guess +config.h +config.log +config.lt +config.status +config.sub Makefile libtool /autom4te.cache diff --git a/config.h.in b/config.h.in new file mode 100644 index 00000000..44727074 --- /dev/null +++ b/config.h.in @@ -0,0 +1,110 @@ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you have the header file. */ +#undef HAVE_CMATH + +/* Define to 1 if you have the header file. */ +#undef HAVE_CSIGNAL + +/* Define to 1 if you have the header file. */ +#undef HAVE_CSTDLIB + +/* Define to 1 if you have the header file. */ +#undef HAVE_DLFCN_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_FCNTL_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_LANGINFO_H + +/* Define to 1 if GPM mouse is enabled */ +#undef HAVE_LIBGPM + +/* Define to 1 if you have the header file. */ +#undef HAVE_LINUX_FB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_LIST + +/* Define to 1 if you have the header file. */ +#undef HAVE_MAP + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_QUEUE + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_IO_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_KD_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TIME_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_TERMIOS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_TERM_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_VECTOR + +/* Define to the sub-directory in which libtool stores uninstalled libraries. + */ +#undef LT_OBJDIR + +/* Name of package */ +#undef PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the home page for this package. */ +#undef PACKAGE_URL + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Version number of package */ +#undef VERSION diff --git a/src/fbutton.cpp b/src/fbutton.cpp index 95a1046a..27a461f3 100644 --- a/src/fbutton.cpp +++ b/src/fbutton.cpp @@ -436,7 +436,7 @@ void FButton::hide() } //---------------------------------------------------------------------- -bool FButton::setNoUnderline(bool on) +bool FButton::setNoUnderline (bool on) { if ( on ) this->flags |= NO_UNDERLINE; @@ -446,7 +446,7 @@ bool FButton::setNoUnderline(bool on) } //---------------------------------------------------------------------- -bool FButton::setEnable(bool on) +bool FButton::setEnable (bool on) { FWidget::setEnable(on); @@ -465,7 +465,7 @@ bool FButton::setEnable(bool on) } //---------------------------------------------------------------------- -bool FButton::setFocus(bool on) +bool FButton::setFocus (bool on) { FWidget::setFocus(on); @@ -496,7 +496,7 @@ bool FButton::setFocus(bool on) } //---------------------------------------------------------------------- -bool FButton::setFlat(bool on) +bool FButton::setFlat (bool on) { if ( on ) this->flags |= FLAT; @@ -506,7 +506,7 @@ bool FButton::setFlat(bool on) } //---------------------------------------------------------------------- -bool FButton::setShadow(bool on) +bool FButton::setShadow (bool on) { if ( on && Encoding != fc::VT100 && Encoding != fc::ASCII ) this->flags |= SHADOW; @@ -516,7 +516,7 @@ bool FButton::setShadow(bool on) } //---------------------------------------------------------------------- -bool FButton::setDown(bool on) +bool FButton::setDown (bool on) { if ( button_down != on ) { diff --git a/src/fconfig.h b/src/fconfig.h index fcb80772..6bbb1b4f 100644 --- a/src/fconfig.h +++ b/src/fconfig.h @@ -1,6 +1,6 @@ #ifndef _SRC_FCONFIG_H #define _SRC_FCONFIG_H 1 - + /* src/fconfig.h. Generated automatically at end of configure. */ /* config.h. Generated from config.h.in by configure. */ /* config.h.in. Generated from configure.ac by autoheader. */ @@ -171,6 +171,6 @@ #ifndef F_VERSION #define F_VERSION "0.1.1" #endif - + /* once: _SRC_FCONFIG_H */ #endif diff --git a/src/fdialog.cpp b/src/fdialog.cpp index e99cc6ec..84174bc9 100644 --- a/src/fdialog.cpp +++ b/src/fdialog.cpp @@ -567,6 +567,10 @@ void FDialog::onWindowInactive (FEvent*) void FDialog::onWindowRaised (FEvent*) { widgetList::const_iterator iter, end; + + if ( ! isVisible() || ! isShown() ) + return; + putArea (getGlobalPos(), vwin); if ( ! window_list ) diff --git a/src/fmenu.cpp b/src/fmenu.cpp index ae7275db..31a3e028 100644 --- a/src/fmenu.cpp +++ b/src/fmenu.cpp @@ -44,8 +44,7 @@ FMenu::~FMenu() const FRect& geometry = getGeometryGlobalShadow(); restoreVTerm (geometry); - parentWidget()->redraw(); // ???? - + if ( vwin != 0 ) { if ( vwin->changes != 0 ) @@ -61,6 +60,7 @@ FMenu::~FMenu() //---------------------------------------------------------------------- void FMenu::init() { + current = 0; width = 10; height = 2; xmin = 1; @@ -76,22 +76,48 @@ void FMenu::init() bottom_padding = 1; right_padding = 1; createArea (vwin); - setGeometry (1, 1, 10, 2, false); // initialize geometry values - ignore_padding = true; + setGeometry (1, 1 , 10, 2, false); // initialize geometry values window_object = true; addWindow(this); - setActiveWindow(this); - + + foregroundColor = wc.menu_active_fg; + backgroundColor = wc.menu_active_bg; + FWidget* old_focus = FWidget::getFocusWidget(); if ( old_focus ) { setFocus(); old_focus->redraw(); } - + item->setMenu(this); } +//---------------------------------------------------------------------- +void FMenu::menu_dimension() +{ + std::vector::const_iterator iter, end; + iter = itemlist.begin(); + end = itemlist.end(); + maxItemWidth = 0; + + // find the max item width + while ( iter != end ) + { + FString item_text = (*iter)->getText(); + uInt len = item_text.getLength(); + + if ( item_text.includes(L'&') ) // item has a hotkey '&' + len--; + + if ( len > maxItemWidth ) + maxItemWidth = len; + ++iter; + } + + setGeometry (xpos, ypos, maxItemWidth + 4, count() + 2); +} + //---------------------------------------------------------------------- bool FMenu::isMenuBar (FWidget* w) const { @@ -138,22 +164,92 @@ void FMenu::draw() if ( itemlist.empty() ) return; + if ( current < 1 ) + { + current = 1; + itemlist[0]->setSelected(); + } + + menu_dimension(); + // fill the background setColor (foregroundColor, backgroundColor); setUpdateVTerm(false); clrscr(); drawBorder(); - + drawItems(); setUpdateVTerm(true); } +//---------------------------------------------------------------------- +void FMenu::drawBorder() +{ + int x1, x2, y1, y2; + x1 = xpos+xmin-1; + x2 = xpos+xmin-2+width; + y1 = ypos+ymin-1; + y2 = ypos+ymin-2+height; + + if ( isNewFont() ) + { + gotoxy (x1, y1); + print (fc::NF_border_corner_upper_left); // ⎡ + for (int x=x1+1; x < x2; x++) + print (fc::NF_border_line_upper); // ¯ + print (fc::NF_rev_border_corner_upper_right); // ⎤ + + for (int y=y1+1; y <= y2; y++) + { + gotoxy (x1, y); + // border left ⎸ + print (fc::NF_border_line_left); + gotoxy (x2, y); + // border right⎹ + print (fc::NF_rev_border_line_right); + } + if ( (flags & SHADOW) == 0 ) + { + gotoxy (x1, y2); + // lower left corner border ⎣ + print (fc::NF_border_corner_lower_left); + for (int x=1; x < width-1; x++) // low line _ + print (fc::NF_border_line_bottom); + gotoxy (x2, y2); + // lower right corner border ⎦ + print (fc::NF_rev_border_corner_lower_right); + } + } + else + { + gotoxy (x1, y1); + print (fc::BoxDrawingsDownAndRight); // ┌ + for (int x=x1+1; x < x2; x++) + print (fc::BoxDrawingsHorizontal); // ─ + print (fc::BoxDrawingsDownAndLeft); // ┐ + + gotoxy (x1, y2); + print (fc::BoxDrawingsUpAndRight); // └ + for (int x=x1+1; x < x2; x++) + print (fc::BoxDrawingsHorizontal); // ─ + print (fc::BoxDrawingsUpAndLeft); // ┘ + + for (int y=y1+1; y < y2; y++) + { + gotoxy (x1, y); + print (fc::BoxDrawingsVertical); // │ + gotoxy (x2, y); + print (fc::BoxDrawingsVertical); // │ + } + } +} + //---------------------------------------------------------------------- void FMenu::drawItems() { std::vector::const_iterator iter, end; - int y = 1; + int y = 0; iter = itemlist.begin(); end = itemlist.end(); @@ -190,7 +286,7 @@ void FMenu::drawItems() foregroundColor = wc.menu_inactive_fg; backgroundColor = wc.menu_inactive_bg; } - gotoxy (xpos+xmin+1, ypos+ymin+y); + gotoxy (xpos+xmin, ypos+ymin+y); setColor (foregroundColor, backgroundColor); print (' '); @@ -226,6 +322,12 @@ void FMenu::drawItems() print (item_text[z]); } + if ( isSelected ) + { + for (uInt i=to_char; i <= maxItemWidth; i++) + print (' '); + } + if ( isActive && isSelected ) setReverse(false); delete[] item_text; @@ -401,6 +503,18 @@ void FMenu::setGeometry (int xx, int yy, int ww, int hh, bool adjust) resizeArea (vwin); } +//---------------------------------------------------------------------- +void FMenu::insert (FMenuItem* item) +{ + FMenuList::insert(item); +} + +//---------------------------------------------------------------------- +void FMenu::remove (FMenuItem* item) +{ + FMenuList::remove(item); +} + //---------------------------------------------------------------------- void FMenu::cb_menuitem_activated (FWidget* widget, void*) { diff --git a/src/fmenu.h b/src/fmenu.h index 16bf864c..5ea1e86a 100644 --- a/src/fmenu.h +++ b/src/fmenu.h @@ -20,17 +20,22 @@ class FMenu : public FWindow, public FMenuList private: FMenuItem* item; FMenuList* super_menu; - bool mouse_down; + uInt maxItemWidth; + int current; + bool mouse_down; private: FMenu (const FMenu&); FMenu& operator = (const FMenu&); void init(); + void menu_dimension(); bool isMenuBar (FWidget*) const; + FMenuList* superMenu() const; void setSuperMenu (FMenuList*); int getHotkeyPos (wchar_t*&, wchar_t*&, uInt); void draw(); + void drawBorder(); void drawItems(); void processActivate(); @@ -63,6 +68,8 @@ class FMenu : public FWindow, public FMenuList void setText (FString&); void setText (const std::string&); void setText (const char*); + void insert (FMenuItem*); + void remove (FMenuItem*); void cb_menuitem_activated (FWidget*, void*); }; #pragma pack(pop) diff --git a/src/fmenubar.cpp b/src/fmenubar.cpp index 0b870f00..aa3e0238 100644 --- a/src/fmenubar.cpp +++ b/src/fmenubar.cpp @@ -42,8 +42,8 @@ void FMenuBar::init() getRootWidget()->setTopPadding(1, true); x = -1; setMenuBar(this); - foregroundColor = wc.statusbar_fg; - backgroundColor = wc.statusbar_bg; + foregroundColor = wc.menu_active_fg; + backgroundColor = wc.menu_active_bg; window_object = true; mouse_down = false; ignore_padding = true; diff --git a/src/fmenuitem.cpp b/src/fmenuitem.cpp index 565d4149..65b36be9 100644 --- a/src/fmenuitem.cpp +++ b/src/fmenuitem.cpp @@ -1,6 +1,7 @@ // fmenuitem.cpp // class FMenuItem +#include "fmenu.h" #include "fmenubar.h" #include "fmenuitem.h" #include "fmenulist.h" @@ -55,20 +56,38 @@ void FMenuItem::init (FWidget* parent) menu = 0; setGeometry (1,1,1,1); - if ( parent && isMenuBar(parent) ) + if ( parent ) { - setSuperMenu( dynamic_cast(parent) ); - superMenu()->insert(this); - - //addAccelerator (item->getKey(), item); - - this->addCallback - ( - "activate", - (FWidget*)superMenu(), - reinterpret_cast(&FMenuBar::cb_item_activated), - null - ); + if ( isMenuBar(parent) ) // Parent is menubar + { + setSuperMenu( dynamic_cast(parent) ); + superMenu()->insert(this); + + //addAccelerator (item->getKey(), item); + + this->addCallback + ( + "activate", + (FWidget*)superMenu(), + reinterpret_cast(&FMenuBar::cb_item_activated), + null + ); + } + else if ( isMenu(parent) ) // Parent is menu + { + setSuperMenu( dynamic_cast(parent) ); + superMenu()->insert(this); + + //addAccelerator (item->getKey(), item); + + this->addCallback + ( + "activate", + (FWidget*)superMenu(), + reinterpret_cast(&FMenu::cb_menuitem_activated), + null + ); + } } } @@ -95,6 +114,13 @@ bool FMenuItem::isMenuBar (FWidget* w) const const_cast("FMenuBar") ) == 0 ); } +//---------------------------------------------------------------------- +bool FMenuItem::isMenu (FWidget* w) const +{ + return bool ( strcmp ( w->getClassName(), + const_cast("FMenu") ) == 0 ); +} + //---------------------------------------------------------------------- FMenuList* FMenuItem::superMenu() const { diff --git a/src/fmenuitem.h b/src/fmenuitem.h index 1f4aaa83..bc20bac4 100644 --- a/src/fmenuitem.h +++ b/src/fmenuitem.h @@ -19,15 +19,15 @@ class FMenuList; class FMenuItem : public FWidget { private: - FString text; - bool active; - bool selected; - bool separator; - bool checked; - int hotkey; - //int accel_key; - FMenu* menu; - FMenuList* super_menu; + FString text; + bool active; + bool selected; + bool separator; + bool checked; + int hotkey; + //int accel_key; + FMenu* menu; + FMenuList* super_menu; private: FMenuItem (const FMenuItem&); @@ -35,6 +35,7 @@ class FMenuItem : public FWidget void init (FWidget*); uChar getHotkey(); bool isMenuBar (FWidget*) const; + bool isMenu (FWidget*) const; FMenuList* superMenu() const; void setSuperMenu (FMenuList*); void processActivate(); @@ -47,26 +48,26 @@ class FMenuItem : public FWidget FMenuItem (const char*, FWidget* parent=0); virtual ~FMenuItem(); - void onAccel (FAccelEvent*); - FString getText() const; - void setActive(); - void unsetActive(); - bool isActivated() const; - void setSelected(); - void unsetSelected(); - bool isSelected() const; - void setSeparator(); - void unsetSeparator(); - bool isSeparator() const; - void setChecked(); - void unsetChecked(); - bool isChecked() const; - bool hasHotkey() const; - void setMenu(FMenu*); - bool hasMenu() const; - void setText (FString&); - void setText (const std::string&); - void setText (const char*); + void onAccel (FAccelEvent*); + FString getText() const; + void setActive(); + void unsetActive(); + bool isActivated() const; + void setSelected(); + void unsetSelected(); + bool isSelected() const; + void setSeparator(); + void unsetSeparator(); + bool isSeparator() const; + void setChecked(); + void unsetChecked(); + bool isChecked() const; + bool hasHotkey() const; + void setMenu(FMenu*); + bool hasMenu() const; + void setText (FString&); + void setText (const std::string&); + void setText (const char*); private: friend class FMenuList; diff --git a/src/fmenulist.h b/src/fmenulist.h index 526c5229..09d64973 100644 --- a/src/fmenulist.h +++ b/src/fmenulist.h @@ -41,17 +41,17 @@ class FMenuList virtual ~FMenuList(); virtual const char* getClassName() const; - uInt count() const; - FMenuItem* item (int) const; - void activateItem (int); - void deactivateItem (int); - bool isSelected (int) const; - bool hasSelectedItem(); + uInt count() const; + FMenuItem* item (int) const; + void activateItem (int); + void deactivateItem (int); + bool isSelected (int) const; + bool hasSelectedItem(); - void insert (FMenuItem*); - void remove (FMenuItem*); - void remove (int); - void clear(); + virtual void insert (FMenuItem*); + virtual void remove (FMenuItem*); + void remove (int); + void clear(); }; #pragma pack(pop) diff --git a/src/fwidget.cpp b/src/fwidget.cpp index c7bcd73e..96152c13 100644 --- a/src/fwidget.cpp +++ b/src/fwidget.cpp @@ -1408,7 +1408,7 @@ bool FWidget::setFocus(bool on) { bool has_raised = window->raiseWindow(); FWindow::setActiveWindow(window); - if ( has_raised ) + if ( has_raised && window->isVisible() && window->isShown() ) window->redraw(); } window->setFocusWidget(this);