all repos — fluxbox @ 78f3ca5db6d9779c9c8ea1c5fe1feef942eb7236

custom fork of the fluxbox windowmanager

cleaning
fluxgen fluxgen
commit

78f3ca5db6d9779c9c8ea1c5fe1feef942eb7236

parent

996e30ef10f855d68799e4ad1a48639518783940

2 files changed, 132 insertions(+), 132 deletions(-)

jump to
M src/FbTk/Menu.ccsrc/FbTk/Menu.cc

@@ -1,5 +1,5 @@

// Menu.cc for FbTk - Fluxbox Toolkit -// Copyright (c) 2001 - 2004 Henrik Kinnunen (fluxgen at users.sourceforge.net) +// Copyright (c) 2001 - 2005 Henrik Kinnunen (fluxgen at users.sourceforge.net) // // Basemenu.cc for blackbox - an X11 Window manager // Copyright (c) 1997 - 2000 Brad Hughes (bhughes at tcac.net)

@@ -101,13 +101,13 @@

// make sure we get updated when the theme is reloaded tm.reconfigSig().attach(this); - title_vis = true; + m_title_vis = true; - shifted = - internal_menu = - moving = - torn = - visible = false; + m_shifted = + m_internal_menu = + m_moving = + m_torn = + m_visible = false;

@@ -116,9 +116,9 @@ menu.y_shift =

menu.x_move = menu.y_move = 0; - which_sub = - which_press = - which_sbl = -1; + m_which_sub = + m_which_press = + m_which_sbl = -1; menu.frame_pixmap = menu.title_pixmap =

@@ -237,11 +237,11 @@

if (item) { menuitems.erase(it); - if (!internal_menu && item->submenu() != 0) { + if (!m_internal_menu && item->submenu() != 0) { Menu *tmp = item->submenu(); // if menu is interal we should just hide it instead // if destroying it - if (! tmp->internal_menu) { + if (! tmp->m_internal_menu) { delete tmp; } else tmp->internal_hide();

@@ -251,10 +251,10 @@

delete item; } - if (static_cast<unsigned int>(which_sub) == index) - which_sub = -1; - else if (static_cast<unsigned int>(which_sub) > index) - which_sub--; + if (static_cast<unsigned int>(m_which_sub) == index) + m_which_sub = -1; + else if (static_cast<unsigned int>(m_which_sub) > index) + m_which_sub--; m_need_update = true; // we need to redraw the menu

@@ -277,7 +277,7 @@ menu.window.lower();

} void Menu::nextItem() { - int old_which_press = which_press; + int old_which_press = m_which_press; m_active_index = -1; if (validIndex(old_which_press) && menuitems[old_which_press] != 0) {

@@ -291,25 +291,25 @@ true, // clear

true); // transp } - // restore old in case we changed which_press - which_press = old_which_press + 1; - if (!validIndex(which_press)) - which_press = 0; + // restore old in case we changed m_which_press + m_which_press = old_which_press + 1; + if (!validIndex(m_which_press)) + m_which_press = 0; - if (menuitems[which_press] == 0) { + if (menuitems[m_which_press] == 0) { m_active_index = -1; return; } - if (!isItemSelectable(which_press)) { + if (!isItemSelectable(m_which_press)) { nextItem(); return; } - m_active_index = which_press; + m_active_index = m_which_press; - drawItem(which_press, + drawItem(m_which_press, true, // clear true); // transp

@@ -317,7 +317,7 @@ }

void Menu::prevItem() { - int old_which_press = which_press; + int old_which_press = m_which_press; m_active_index = -1; if (validIndex(old_which_press)) { if (menuitems[old_which_press]->submenu()) {

@@ -329,62 +329,62 @@ drawItem(old_which_press,

true, // clear true); // transp } - // restore old in case we changed which_press - which_press = old_which_press - 1; + // restore old in case we changed m_which_press + m_which_press = old_which_press - 1; - if (!validIndex(which_press)) - which_press = menuitems.size() - 1; + if (!validIndex(m_which_press)) + m_which_press = menuitems.size() - 1; - if (menuitems[which_press] == 0) { + if (menuitems[m_which_press] == 0) { m_active_index = -1; return; } - if (!isItemSelectable(which_press)) { + if (!isItemSelectable(m_which_press)) { prevItem(); return; } - m_active_index = which_press; + m_active_index = m_which_press; - drawItem(which_press, + drawItem(m_which_press, true, // clear true); // transp } void Menu::enterSubmenu() { - if (!validIndex(which_press)) + if (!validIndex(m_which_press)) return; - Menu *submenu = menuitems[which_press]->submenu(); + Menu *submenu = menuitems[m_which_press]->submenu(); if (submenu == 0) return; if (submenu->menuitems.size() == 0) return; - drawSubmenu(which_press); + drawSubmenu(m_which_press); submenu->grabInputFocus(); - submenu->which_press = -1; // so we land on 0 after nextItem() + submenu->m_which_press = -1; // so we land on 0 after nextItem() submenu->nextItem(); } void Menu::enterParent() { - if (!validIndex(which_press) || parent() == 0) + if (!validIndex(m_which_press) || parent() == 0) return; - Menu *submenu = menuitems[which_press]->submenu(); + Menu *submenu = menuitems[m_which_press]->submenu(); if (submenu) submenu->internal_hide(); m_active_index = -1; - drawItem(which_press, + drawItem(m_which_press, true, // clear true); // transp - which_press = -1; // dont select any in this + m_which_press = -1; // dont select any in this // hide self - visible = false; + m_visible = false; menu.window.hide(); // return focus to parent parent()->grabInputFocus();

@@ -399,7 +399,7 @@ setTitleVisibility(true);

} void Menu::updateMenu(int active_index) { - if (title_vis) { + if (m_title_vis) { menu.item_w = theme().titleFont().textWidth(menu.label.c_str(), menu.label.size());

@@ -439,7 +439,7 @@

int new_width = (menu.sublevels * menu.item_w); int new_height = menu.frame_h; - if (title_vis) + if (m_title_vis) new_height += theme().titleHeight() + ((menu.frame_h > 0)?menu.title.borderWidth():0);

@@ -456,7 +456,7 @@

menu.window.resize(new_width, new_height); Pixmap tmp = 0; - if (title_vis && m_need_update) { + if (m_title_vis && m_need_update) { tmp = menu.title_pixmap; const FbTk::Texture &tex = theme().titleTexture(); if (!tex.usePixmap()) {

@@ -547,12 +547,12 @@ m_image_ctrl.removeImage(tmp);

- if (title_vis) { + if (m_title_vis) { menu.title.moveResize(-menu.title.borderWidth(), -menu.title.borderWidth(), width() + menu.title.borderWidth(), theme().titleHeight()); } - menu.frame.moveResize(0, ((title_vis) ? menu.title.y() + menu.title.height() + + menu.frame.moveResize(0, ((m_title_vis) ? menu.title.y() + menu.title.height() + menu.title.borderWidth()*2 : 1), width(), menu.frame_h);

@@ -603,8 +603,8 @@ m_frame_pm.width(), m_frame_pm.height());

} - // if menu visible and title visible - if (title_vis && visible) + // if menu m_visible and title m_visible + if (m_title_vis && m_visible) redrawTitle(); if (active_index >= 0 || m_need_update) {

@@ -631,10 +631,10 @@

menu.window.showSubwindows(); menu.window.show(); raise(); - visible = true; + m_visible = true; if (! m_parent && shown != this) { - if (shown && (! shown->torn)) + if (shown && (! shown->m_torn)) shown->hide(); shown = this;

@@ -649,12 +649,12 @@ if (!isVisible())

return; - // if not torn and parent is visible, go to first parent + // if not m_torn and parent is m_visible, go to first parent // and hide it - if (!torn && m_parent && m_parent->isVisible()) { + if (!m_torn && m_parent && m_parent->isVisible()) { Menu *p = m_parent; - while ((! p->torn) && p->m_parent && p->m_parent->isVisible()) + while ((! p->m_torn) && p->m_parent && p->m_parent->isVisible()) p = p->m_parent; p->internal_hide();

@@ -686,8 +686,8 @@ }

void Menu::internal_hide() { - if (validIndex(which_sub)) { - MenuItem *tmp = menuitems[which_sub]; + if (validIndex(m_which_sub)) { + MenuItem *tmp = menuitems[m_which_sub]; tmp->submenu()->internal_hide(); }

@@ -700,8 +700,8 @@

if (shown && shown->menu.window == menu.window) shown = (Menu *) 0; - torn = visible = false; - which_sub = which_press = which_sub = -1; + m_torn = m_visible = false; + m_which_sub = m_which_press = m_which_sub = -1; menu.window.hide(); }

@@ -711,7 +711,7 @@ void Menu::move(int x, int y) {

if (x == this->x() && y == this->y()) return; - // if we're not visible and we do transparency + // if we're not m_visible and we do transparency // we need to update transparency when we call // show() next time if (alpha() < 255)

@@ -722,8 +722,8 @@

if (!isVisible()) return; - if (which_sub != -1) - drawSubmenu(which_sub); + if (m_which_sub != -1) + drawSubmenu(m_which_sub); if (alpha() < 255) { redrawTitle();

@@ -783,8 +783,8 @@ }

void Menu::drawSubmenu(unsigned int index) { - if (validIndex(which_sub) && static_cast<unsigned int>(which_sub) != index) { - MenuItem *itmp = menuitems[which_sub]; + if (validIndex(m_which_sub) && static_cast<unsigned int>(m_which_sub) != index) { + MenuItem *itmp = menuitems[m_which_sub]; if (! itmp->submenu()->isTorn()) itmp->submenu()->internal_hide();

@@ -794,7 +794,7 @@ if (index >= menuitems.size())

return; MenuItem *item = menuitems[index]; - if (item->submenu() && visible && (! item->submenu()->isTorn()) && + if (item->submenu() && m_visible && (! item->submenu()->isTorn()) && item->isEnabled()) { if (item->submenu()->m_parent != this)

@@ -807,29 +807,29 @@ int new_x = x() + ((menu.item_w * (sbl + 1)) + menu.window.borderWidth());

int new_y; if (m_alignment == ALIGNTOP) { - new_y = (((shifted) ? menu.y_shift : y()) + - ((title_vis) ? theme().titleHeight() + menu.title.borderWidth() : 0) - - ((item->submenu()->title_vis) ? + new_y = (((m_shifted) ? menu.y_shift : y()) + + ((m_title_vis) ? theme().titleHeight() + menu.title.borderWidth() : 0) - + ((item->submenu()->m_title_vis) ? item->submenu()->theme().titleHeight() + menu.window.borderWidth() : 0)); } else { - new_y = (((shifted) ? menu.y_shift : y()) + + new_y = (((m_shifted) ? menu.y_shift : y()) + (theme().itemHeight() * i) + - ((title_vis) ? theme().titleHeight() + menu.window.borderWidth() : 0) - - ((item->submenu()->title_vis) ? + ((m_title_vis) ? theme().titleHeight() + menu.window.borderWidth() : 0) - + ((item->submenu()->m_title_vis) ? item->submenu()->theme().titleHeight() + menu.window.borderWidth() : 0)); } if (m_alignment == ALIGNBOTTOM && - (new_y + item->submenu()->height()) > ((shifted) ? menu.y_shift : + (new_y + item->submenu()->height()) > ((m_shifted) ? menu.y_shift : y()) + height()) { - new_y = (((shifted) ? menu.y_shift : y()) + + new_y = (((m_shifted) ? menu.y_shift : y()) + height() - item->submenu()->height()); } int borderw = item->submenu()->fbwindow().borderWidth(); if ((new_x + item->submenu()->width()) + 2*borderw > m_screen_x + m_screen_width) { - new_x = ((shifted) ? menu.x_shift : x()) - + new_x = ((m_shifted) ? menu.x_shift : x()) - item->submenu()->width() - menu.window.borderWidth(); }

@@ -841,14 +841,14 @@ new_y = m_screen_y + m_screen_height - item->submenu()->height() -

menu.window.borderWidth() * 2; } - item->submenu()->moving = moving; - which_sub = index; + item->submenu()->m_moving = m_moving; + m_which_sub = index; if (new_y < m_screen_y) new_y = m_screen_y; item->submenu()->move(new_x, new_y); - if (! moving) + if (! m_moving) drawItem(index); if (! item->submenu()->isVisible()) {

@@ -858,7 +858,7 @@ }

} else - which_sub = -1; + m_which_sub = -1; }

@@ -1084,8 +1084,8 @@ int sbl = (be.x / menu.item_w), i = (be.y / theme().itemHeight());

int w = (sbl * menu.persub) + i; if (validIndex(w) && isItemSelectable(static_cast<unsigned int>(w))) { - which_press = i; - which_sbl = sbl; + m_which_press = i; + m_which_sbl = sbl; MenuItem *item = menuitems[w];

@@ -1108,11 +1108,11 @@

void Menu::buttonReleaseEvent(XButtonEvent &re) { if (re.window == menu.title) { - if (moving) { - moving = false; + if (m_moving) { + m_moving = false; - if (which_sub != -1) - drawSubmenu(which_sub); + if (m_which_sub != -1) + drawSubmenu(m_which_sub); if (alpha() < 255) { redrawTitle();

@@ -1136,7 +1136,7 @@

int sbl = (re.x / menu.item_w), i = (re.y / theme().itemHeight()), ix = sbl * menu.item_w, iy = i * theme().itemHeight(), w = (sbl * menu.persub) + i, - p = (which_sbl * menu.persub) + which_press; + p = (m_which_sbl * menu.persub) + m_which_press; if (validIndex(w) && isItemSelectable(static_cast<unsigned int>(w))) { if (p == w && isItemEnabled(w)) {

@@ -1160,19 +1160,19 @@ // if draging the with the titlebar:

if (me.window == menu.title && (me.state & Button1Mask)) { stopHide(); - if (! moving) { - // if not moving: start moving operation - if (m_parent && (! torn)) { - m_parent->drawItem(m_parent->which_sub, + if (! m_moving) { + // if not m_moving: start m_moving operation + if (m_parent && (! m_torn)) { + m_parent->drawItem(m_parent->m_which_sub, true, // clear true); // render transparency - m_parent->which_sub = -1; + m_parent->m_which_sub = -1; } - moving = torn = true; + m_moving = m_torn = true; - if (which_sub >= 0) - drawSubmenu(which_sub); + if (m_which_sub >= 0) + drawSubmenu(m_which_sub); } else { // we dont call ::move here 'cause we dont want to update transparency // while draging the menu (which is slow)

@@ -1206,7 +1206,7 @@ if (item->submenu()->isVisible() &&

!item->submenu()->isTorn()) { // setup hide timer for submenu item->submenu()->startHide(); - which_sub = -1; + m_which_sub = -1; } }

@@ -1215,8 +1215,8 @@

} - which_press = i; - which_sbl = sbl; + m_which_press = i; + m_which_sbl = sbl; m_active_index = -1;

@@ -1281,37 +1281,37 @@

menu.x_shift = x(), menu.y_shift = y(); if (x() + width() > m_screen_x + m_screen_width) { menu.x_shift = m_screen_x + m_screen_width - width() - 2*theme().borderWidth(); - shifted = true; + m_shifted = true; } else if (x() < 0) { menu.x_shift = 0; //-theme().borderWidth(); - shifted = true; + m_shifted = true; } if (y() + height() + 2*theme().borderWidth() > m_screen_height) { menu.y_shift = m_screen_height - height() - 2*theme().borderWidth(); - shifted = true; + m_shifted = true; } else if (y() + (signed) theme().titleHeight() < 0) { menu.y_shift = 0; // -theme().borderWidth();; - shifted = true; + m_shifted = true; } - if (shifted) + if (m_shifted) menu.window.move(menu.x_shift, menu.y_shift); - if (validIndex(which_sub)) { - MenuItem *tmp = menuitems[which_sub]; + if (validIndex(m_which_sub)) { + MenuItem *tmp = menuitems[m_which_sub]; if (tmp->submenu()->isVisible()) { int sbl = (ce.x / menu.item_w), i = (ce.y / theme().itemHeight()), w = (sbl * menu.persub) + i; - if (w != which_sub && (! tmp->submenu()->isTorn())) { + if (w != m_which_sub && (! tmp->submenu()->isTorn())) { tmp->submenu()->internal_hide(); - drawItem(which_sub, + drawItem(m_which_sub, true, // clear true); // transp - which_sub = -1; + m_which_sub = -1; } } }

@@ -1321,19 +1321,19 @@ void Menu::leaveNotifyEvent(XCrossingEvent &ce) {

if (menu.frame != ce.window) return; - if (which_press != -1 && which_sbl != -1 && menuitems.size() > 0) { - int p = (which_sbl * menu.persub) + which_press; + if (m_which_press != -1 && m_which_sbl != -1 && menuitems.size() > 0) { + int p = (m_which_sbl * menu.persub) + m_which_press; drawItem(p, true, // clear true); // transp - which_sbl = which_press = -1; + m_which_sbl = m_which_press = -1; } - if (shifted) { + if (m_shifted) { // menu.window.move(menu.x, menu.y); - shifted = false; + m_shifted = false; } }

@@ -1363,10 +1363,10 @@ hide();

break; case XK_Return: // send fake button 1 click - if (validIndex(which_press) && - isItemEnabled(which_press)) { - menuitems[which_press]->click(1, event.time); - itemSelected(1, which_press); + if (validIndex(m_which_press) && + isItemEnabled(m_which_press)) { + menuitems[m_which_press]->click(1, event.time); + itemSelected(1, m_which_press); m_need_update = true; updateMenu(); }

@@ -1419,11 +1419,11 @@ }

void Menu::openSubmenu() { - if (!isVisible() || ! validIndex(which_press) || - ! validIndex(which_sbl)) + if (!isVisible() || ! validIndex(m_which_press) || + ! validIndex(m_which_sbl)) return; - int item = which_sbl * menu.persub + which_press; + int item = m_which_sbl * menu.persub + m_which_press; if (!validIndex(item)) return;
M src/FbTk/Menu.hhsrc/FbTk/Menu.hh

@@ -77,10 +77,10 @@ /// remove an item

int remove(unsigned int item); /// remove all items void removeAll(); - inline void setInternalMenu(bool val = true) { internal_menu = val; } + inline void setInternalMenu(bool val = true) { m_internal_menu = val; } inline void setAlignment(Alignment a) { m_alignment = a; } - inline void setTorn() { torn = true; } - inline void removeParent() { if (internal_menu) m_parent = 0; } + inline void setTorn() { m_torn = true; } + inline void removeParent() { if (m_internal_menu) m_parent = 0; } /// raise this window virtual void raise(); /// lower this window

@@ -135,8 +135,8 @@ @name accessors

*/ //@{ inline int activeIndex() const { return m_active_index; } - inline bool isTorn() const { return torn; } - inline bool isVisible() const { return visible; } + inline bool isTorn() const { return m_torn; } + inline bool isVisible() const { return m_visible; } inline int screenNumber() const { return menu.window.screenNumber(); } inline Window window() const { return menu.window.window(); } inline FbWindow &fbwindow() { return menu.window; }

@@ -149,7 +149,7 @@ inline int y() const { return menu.window.y(); }

inline unsigned int width() const { return menu.window.width(); } inline unsigned int height() const { return menu.window.height(); } inline unsigned int numberOfItems() const { return menuitems.size(); } - inline int currentSubmenu() const { return which_sub; } + inline int currentSubmenu() const { return m_which_sub; } bool hasSubmenu(unsigned int index) const; bool isItemSelected(unsigned int index) const; bool isItemEnabled(unsigned int index) const;

@@ -170,7 +170,7 @@

protected: inline void setTitleVisibility(bool b) { - title_vis = b; m_need_update = true; + m_title_vis = b; m_need_update = true; if (!b) titleWindow().lower(); else

@@ -204,14 +204,14 @@ Menuitems menuitems;

int m_screen_x, m_screen_y; int m_screen_width, m_screen_height; - bool moving; ///< if we're moving/draging or not - bool visible; ///< menu visibility - bool torn; ///< torn from parent - bool internal_menu; ///< whether we should destroy this menu or if it's managed somewhere else - bool title_vis; ///< title visibility - bool shifted; ///< if the menu is shifted to the other side of the parent + bool m_moving; ///< if we're moving/draging or not + bool m_visible; ///< menu visibility + bool m_torn; ///< torn from parent + bool m_internal_menu; ///< whether we should destroy this menu or if it's managed somewhere else + bool m_title_vis; ///< title visibility + bool m_shifted; ///< if the menu is shifted to the other side of the parent - int which_sub, which_press, which_sbl; + int m_which_sub, m_which_press, m_which_sbl; Alignment m_alignment; struct _menu {