FbTk::Menu Class ReferenceBase class for menus.
More...
#include <Menu.hh>
Inheritance diagram for FbTk::Menu:
List of all members.
|
accessors |
|
bool | isTorn () const |
|
bool | isVisible () const |
|
int | screenNumber () const |
|
Window | window () const |
|
FbWindow & | fbwindow () |
|
const FbWindow & | fbwindow () const |
|
FbWindow & | titleWindow () |
|
FbWindow & | frameWindow () |
|
const std::string & | label () const |
|
int | x () const |
|
int | y () const |
|
unsigned int | width () const |
|
unsigned int | height () const |
|
unsigned int | numberOfItems () const |
|
int | currentSubmenu () const |
|
unsigned int | titleHeight () const |
|
bool | hasSubmenu (unsigned int index) const |
|
bool | isItemSelected (unsigned int index) const |
|
bool | isItemEnabled (unsigned int index) const |
|
const MenuTheme & | theme () const |
|
unsigned char | alpha () const |
|
const MenuItem * | find (unsigned int index) const |
| | menuitem at index
|
|
MenuItem * | find (unsigned int index) |
|
Menu * | focused () |
Public Types |
| enum | Alignment { ALIGNDONTCARE = 1,
ALIGNTOP,
ALIGNBOTTOM
} |
| enum | { RIGHT = 1,
LEFT
} |
| enum | { EMPTY = 0,
SQUARE,
TRIANGLE,
DIAMOND
} |
Public Member Functions |
|
| Menu (MenuTheme &tm, ImageControl &imgctrl) |
|
void | grabInputFocus () |
| | get input focus
|
|
virtual void | reconfigure () |
|
void | setLabel (const char *labelstr) |
| | set label string
|
|
void | move (int x, int y) |
| | move menu to x,y
|
|
void | update (int active_index=-1) |
|
void | setItemSelected (unsigned int index, bool val) |
|
void | setItemEnabled (unsigned int index, bool val) |
|
void | setMinimumSublevels (int m) |
|
virtual void | drawSubmenu (unsigned int index) |
| virtual void | show () |
| | show menu
|
|
virtual void | hide () |
| | hide menu
|
|
virtual void | clearWindow () |
|
|
int | insert (const char *label, RefCount< Command > &cmd, int pos=-1) |
| | add a menu item with a label and a command
|
|
int | insert (const char *label, int pos=-1) |
| | add empty menu item
|
|
int | insert (const char *label, Menu *submenu, int pos=-1) |
| | add submenu
|
|
int | insert (MenuItem *item, int pos=-1) |
| | add menu item
|
|
int | remove (unsigned int item) |
| | remove an item
|
|
void | removeAll () |
| | remove all items
|
|
void | setInternalMenu (bool val=true) |
|
void | setAlignment (Alignment a) |
|
void | setTorn () |
|
void | removeParent () |
|
virtual void | raise () |
| | raise this window
|
|
virtual void | lower () |
| | lower this window
|
|
void | nextItem () |
| | select next item
|
|
void | prevItem () |
| | select previous item
|
|
void | enterSubmenu () |
|
void | enterParent () |
|
void | disableTitle () |
|
void | enableTitle () |
|
| void | handleEvent (XEvent &event) |
|
void | buttonPressEvent (XButtonEvent &bp) |
|
void | buttonReleaseEvent (XButtonEvent &br) |
|
void | motionNotifyEvent (XMotionEvent &mn) |
|
void | enterNotifyEvent (XCrossingEvent &en) |
|
void | leaveNotifyEvent (XCrossingEvent &ce) |
|
void | exposeEvent (XExposeEvent &ee) |
|
void | keyPressEvent (XKeyEvent &ke) |
Protected Member Functions |
|
void | setTitleVisibility (bool b) |
|
void | setMovable (bool b) |
|
void | setHideTree (bool h) |
|
virtual void | itemSelected (int button, unsigned int index) |
| virtual void | drawItem (unsigned int index, bool highlight=false, bool clear=false, bool render_trans=true, int x=-1, int y=-1, unsigned int width=0, unsigned int height=0) |
|
virtual void | redrawTitle () |
|
virtual void | internal_hide () |
|
Menu * | parent () |
|
const Menu * | parent () const |
|
void | update (FbTk::Subject *) |
Detailed Description
Base class for menus.
Definition at line 51 of file Menu.hh.
Member Enumeration Documentation
|
|
Bullet type
Definition at line 59 of file Menu.hh.
00059 { EMPTY = 0, SQUARE, TRIANGLE, DIAMOND };
|
Member Function Documentation
| void FbTk::Menu::drawItem |
( |
unsigned int |
index, |
|
|
bool |
highlight = false, |
|
|
bool |
clear = false, |
|
|
bool |
render_trans = true, |
|
|
int |
x = -1, |
|
|
int |
y = -1, |
|
|
unsigned int |
w = 0, |
|
|
unsigned int |
h = 0 |
|
) |
[protected, virtual] |
|
|
|
! TODO: this is just temporarly and will be removed
Definition at line 732 of file Menu.cc.
References FbTk::Font::ascent(), FbTk::FbDrawable::copyArea(), FbTk::FbPixmap::drawable(), FbTk::FbDrawable::drawRectangle(), FbTk::FbDrawable::fillPolygon(), FbTk::FbDrawable::fillRectangle(), FbTk::GContext::gc(), FbTk::App::instance(), FbTk::MenuItem::isEnabled(), FbTk::MenuItem::isSelected(), FbTk::MenuItem::isToggleItem(), FbTk::MenuItem::label(), FbTk::GContext::setForeground(), FbTk::MenuItem::submenu(), and FbTk::Font::textWidth().
Referenced by nextItem(), and prevItem().
00733 {
00734 if (index >= menuitems.size() || menuitems.size() == 0 ||
00735 menu.persub == 0)
00736 return;
00737
00738 MenuItem *item = menuitems[index];
00739 if (! item) return;
00740
00741 bool dotext = true, dohilite = true, dosel = true;
00742 const char *text = item->label().c_str();
00743 int sbl = index / menu.persub, i = index - (sbl * menu.persub);
00744 int item_x = (sbl * menu.item_w), item_y = (i * menu.item_h);
00745 int hilite_x = item_x, hilite_y = item_y, hoff_x = 0, hoff_y = 0;
00746 int text_x = 0, text_y = 0, len = strlen(text), sel_x = 0, sel_y = 0;
00747 unsigned int hilite_w = menu.item_w, hilite_h = menu.item_h, text_w = 0, text_h = 0;
00748 unsigned int half_w = menu.item_h / 2, quarter_w = menu.item_h / 4;
00749 const FbTk::Font &font = m_theme.frameFont();
00750 if (text) {
00751 text_w = font.textWidth(text, len);
00752
00753 text_y = item_y + menu.bevel_w/2 + font.ascent();
00754
00755 switch(m_theme.frameFontJustify()) {
00756 case FbTk::LEFT:
00757 text_x = item_x + menu.bevel_w + menu.item_h + 1;
00758 break;
00759
00760 case FbTk::RIGHT:
00761 text_x = item_x + menu.item_w - (menu.item_h + menu.bevel_w + text_w);
00762 break;
00763 default:
00764 text_x = item_x + ((menu.item_w + 1 - text_w) / 2);
00765 break;
00766 }
00767
00768 text_h = menu.item_h - menu.bevel_w;
00769 }
00770
00771 GC gc =
00772 ((highlight || item->isSelected()) ? m_theme.hiliteTextGC().gc() :
00773 m_theme.frameTextGC().gc());
00774 const GContext &tgc =
00775 (highlight ? m_theme.hiliteTextGC() :
00776 (item->isEnabled() ? m_theme.frameTextGC() : m_theme.disableTextGC() ) );
00777
00778 sel_x = item_x;
00779
00780 if (m_theme.bulletPos() == FbTk::RIGHT)
00781 sel_x += (menu.item_w - menu.item_h - menu.bevel_w);
00782
00783 sel_x += quarter_w;
00784 sel_y = item_y + quarter_w;
00785
00786 if (clear) {
00787 FbTk::GContext def_gc(menu.frame.window());
00788 if (menu.frame_pixmap == 0) {
00789 def_gc.setForeground(m_theme.frameTexture().color());
00790 m_frame_pm.fillRectangle(def_gc.gc(), item_x, item_y, menu.item_w, menu.item_h);
00791
00792 } else {
00793
00794 m_frame_pm.copyArea(menu.frame_pixmap, def_gc.gc(),
00795 item_x, item_y,
00796 item_x, item_y,
00797 menu.item_w, menu.item_h);
00798 }
00799 } else if (! (x == y && y == -1 && w == h && h == 0)) {
00800
00801 if (! (std::max(item_x, x) <= (signed) std::min(item_x + menu.item_w, x + w) &&
00802 std::max(item_y, y) <= (signed) std::min(item_y + menu.item_h, y + h))) {
00803 dohilite = False;
00804 } else {
00805 hilite_x = std::max(item_x, x);
00806 hilite_y = std::max(item_y, y);
00807 hilite_w = std::min(item_x + menu.item_w, x + w) - hilite_x;
00808 hilite_h = std::min(item_y + menu.item_h, y + h) - hilite_y;
00809 hoff_x = hilite_x % menu.item_w;
00810 hoff_y = hilite_y % menu.item_h;
00811 }
00812
00813
00814 int text_ry = item_y + (menu.bevel_w / 2);
00815 if (! (std::max(text_x, x) <= (signed) std::min(text_x + text_w, x + w) &&
00816 std::max(text_ry, y) <= (signed) std::min(text_ry + text_h, y + h)))
00817 dotext = false;
00818
00819
00820 if (! (std::max(sel_x, x) <= (signed) std::min(sel_x + half_w, x + w) &&
00821 std::max(sel_y, y) <= (signed) std::min(sel_y + half_w, y + h)))
00822 dosel = false;
00823
00824 }
00825
00826 if (dohilite && highlight && (menu.hilite_pixmap != ParentRelative)) {
00827 if (menu.hilite_pixmap) {
00828 m_frame_pm.copyArea(menu.hilite_pixmap,
00829 m_theme.hiliteGC().gc(), hoff_x, hoff_y,
00830 hilite_x, hilite_y,
00831 hilite_w, hilite_h);
00832 } else {
00833 m_frame_pm.fillRectangle(m_theme.hiliteGC().gc(),
00834 hilite_x, hilite_y, hilite_w, hilite_h);
00835 }
00836
00837 }
00838
00839
00840 if (item->isToggleItem() && item->isSelected() &&
00841 menu.sel_pixmap != ParentRelative) {
00842 if (m_theme.selectedPixmap().pixmap().drawable()) {
00843
00844 XSetClipMask(FbTk::App::instance()->display(),
00845 gc,
00846 m_theme.selectedPixmap().mask().drawable());
00847 XSetClipOrigin(FbTk::App::instance()->display(),
00848 gc, sel_x, item_y);
00849
00850 m_frame_pm.copyArea(m_theme.selectedPixmap().pixmap().drawable(),
00851 gc,
00852 0, 0,
00853 sel_x, item_y,
00854 m_theme.selectedPixmap().width(),
00855 m_theme.selectedPixmap().height());
00856
00857 XSetClipMask(FbTk::App::instance()->display(),
00858 gc,
00859 None);
00860 } else {
00861 if (menu.sel_pixmap) {
00862 m_frame_pm.copyArea(highlight ? menu.frame_pixmap : menu.sel_pixmap,
00863 m_theme.hiliteGC().gc(),
00864 0, 0,
00865 sel_x, sel_y,
00866 half_w, half_w);
00867 } else {
00868 m_frame_pm.fillRectangle(m_theme.hiliteGC().gc(),
00869 sel_x, sel_y, half_w, half_w);
00870 }
00871 }
00872
00873 } else if (item->isToggleItem() && m_theme.unselectedPixmap().pixmap().drawable() != 0) {
00874
00875 XSetClipMask(FbTk::App::instance()->display(),
00876 gc,
00877 m_theme.unselectedPixmap().mask().drawable());
00878 XSetClipOrigin(FbTk::App::instance()->display(),
00879 gc, sel_x, item_y);
00880
00881 m_frame_pm.copyArea(m_theme.unselectedPixmap().pixmap().drawable(),
00882 gc,
00883 0, 0,
00884 sel_x, item_y,
00885 m_theme.unselectedPixmap().width(),
00886 m_theme.unselectedPixmap().height());
00887
00888 XSetClipMask(FbTk::App::instance()->display(),
00889 gc,
00890 None);
00891 }
00892
00893 if (dotext && text) {
00895
00896 if (strcmp(text, "---") == 0){
00897 m_frame_pm.drawRectangle(tgc.gc(),
00898 item_x + menu.bevel_w + menu.item_h + 1, item_y + (menu.item_h / 2),
00899 menu.item_w - ((menu.bevel_w + menu.item_h) * 2) - 1, 0);
00900 } else {
00901 m_theme.frameFont().drawText(m_frame_pm.drawable(),
00902 screenNumber(),
00903 tgc.gc(),
00904 text, len,
00905 text_x, text_y);
00906 }
00907 }
00908
00909 if (dosel && item->submenu()) {
00910 if (m_theme.bulletPixmap().pixmap().drawable() != 0) {
00911
00912 XSetClipMask(FbTk::App::instance()->display(),
00913 gc,
00914 m_theme.bulletPixmap().mask().drawable());
00915 XSetClipOrigin(FbTk::App::instance()->display(),
00916 gc, sel_x, item_y);
00917
00918 m_frame_pm.copyArea(m_theme.bulletPixmap().pixmap().drawable(),
00919 gc,
00920 0, 0,
00921 sel_x, item_y,
00922 m_theme.bulletPixmap().width(),
00923 m_theme.bulletPixmap().height());
00924
00925 XSetClipMask(FbTk::App::instance()->display(),
00926 gc,
00927 None);
00928 } else {
00929 switch (m_theme.bullet()) {
00930 case MenuTheme::SQUARE:
00931 m_frame_pm.drawRectangle(gc, sel_x, sel_y, half_w, half_w);
00932 break;
00933
00934 case MenuTheme::TRIANGLE:
00935 XPoint tri[3];
00936
00937 if (m_theme.bulletPos() == FbTk::RIGHT) {
00938 tri[0].x = sel_x + quarter_w - 2;
00939 tri[0].y = sel_y + quarter_w - 2;
00940 tri[1].x = 4;
00941 tri[1].y = 2;
00942 tri[2].x = -4;
00943 tri[2].y = 2;
00944 } else {
00945 tri[0].x = sel_x + quarter_w - 2;
00946 tri[0].y = item_y + half_w;
00947 tri[1].x = 4;
00948 tri[1].y = 2;
00949 tri[2].x = 0;
00950 tri[2].y = -4;
00951 }
00952
00953 m_frame_pm.fillPolygon(gc, tri, 3, Convex,
00954 CoordModePrevious);
00955 break;
00956
00957 case MenuTheme::DIAMOND:
00958 XPoint dia[4];
00959
00960 dia[0].x = sel_x + quarter_w - 3;
00961 dia[0].y = item_y + half_w;
00962 dia[1].x = 3;
00963 dia[1].y = -3;
00964 dia[2].x = 3;
00965 dia[2].y = 3;
00966 dia[3].x = -3;
00967 dia[3].y = 3;
00968
00969 m_frame_pm.fillPolygon(gc, dia, 4, Convex,
00970 CoordModePrevious);
00971 break;
00972 default:
00973 break;
00974 }
00975 }
00976 }
00977
00978 menu.frame.clearArea(item_x, item_y,
00979 menu.item_w, menu.item_h, False);
00980
00981
00982 menu.frame.updateTransparent(item_x, item_y,
00983 menu.item_w, menu.item_h);
00984
00985 }
|
| void FbTk::Menu::handleEvent |
( |
XEvent & |
event |
) |
[virtual] |
|
|
|
Events that don't have an specific event function
Reimplemented from FbTk::EventHandler.
Definition at line 1037 of file Menu.cc.
01037 {
01038 if (event.type == FocusOut) {
01039 if (s_focused == this)
01040 s_focused = 0;
01041 } else if (event.type == FocusIn) {
01042 if (s_focused != this)
01043 s_focused = this;
01044 }
01045 }
|
| void FbTk::Menu::show |
( |
|
) |
[virtual] |
|
|
|
show menu
! TODO, this should probably be done explicit if one don't want to raise
Definition at line 535 of file Menu.cc.
References hide(), raise(), and torn.
Referenced by FluxboxWindow::showMenu().
00535 {
00536 if (m_need_update)
00537 update();
00538 menu.window.showSubwindows();
00539 menu.window.show();
00541 raise();
00542 visible = true;
00543
00544 if (! m_parent && shown != this) {
00545 if (shown && (! shown->torn))
00546 shown->hide();
00547
00548 shown = this;
00549 }
00550
00551 }
|
The documentation for this class was generated from the following files:
Fluxbox CVS-Jan-2003
|
|
|