all repos — fluxbox @ 3b330a5f6225f48f299371d5154bfb89db495903

custom fork of the fluxbox windowmanager

signed/unsigned warnings
fluxgen fluxgen
commit

3b330a5f6225f48f299371d5154bfb89db495903

parent

e072c2c7444cab25d0795c23a0d6eff112c7d3b8

2 files changed, 113 insertions(+), 114 deletions(-)

jump to
M src/Basemenu.ccsrc/Basemenu.cc

@@ -22,7 +22,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Basemenu.cc,v 1.12 2002/03/19 14:30:42 fluxgen Exp $ +// $Id: Basemenu.cc,v 1.13 2002/03/20 14:10:03 fluxgen Exp $ // stupid macros needed to access some functions in version 2 of the GNU C // library

@@ -236,8 +236,8 @@ return menuitems.size();

} -int Basemenu::remove(int index) { - if (index < 0 || index >= menuitems.size()) { +int Basemenu::remove(unsigned int index) { + if (index >= menuitems.size()) { #ifdef DEBUG std::cout << "Bad index (" << index << ") given to Basemenu::remove()" << " -- should be between 0 and " << menuitems.size()-1

@@ -264,9 +264,9 @@

delete item; } - if (which_sub == index) + if (static_cast<unsigned int>(which_sub) == index) which_sub = -1; - else if (which_sub > index) + else if (static_cast<unsigned int>(which_sub) > index) which_sub--; return menuitems.size();

@@ -426,13 +426,14 @@ XClearWindow(display, menu.frame);

if (title_vis && visible) redrawTitle(); - int i = 0; - for (i = 0; visible && i < menuitems.size(); i++) - if (i == which_sub) { + unsigned int i = 0; + for (i = 0; visible && i < menuitems.size(); i++) { + if (i == (unsigned int)which_sub) { drawItem(i, True, 0); drawSubmenu(i); } else drawItem(i, False, 0); + } if (parent && visible) parent->drawSubmenu(parent->which_sub);

@@ -541,15 +542,16 @@ text, len);

} -void Basemenu::drawSubmenu(int index) { - if (which_sub >= 0 && which_sub != index) { +void Basemenu::drawSubmenu(unsigned int index) { + if (which_sub >= 0 && static_cast<unsigned int>(which_sub) != index && + static_cast<unsigned int>(which_sub) < menuitems.size()) { BasemenuItem *itmp = menuitems[which_sub]; if (! itmp->submenu()->isTorn()) itmp->submenu()->internal_hide(); } - if (index >= 0 && index < menuitems.size()) { + if (index < menuitems.size()) { BasemenuItem *item = menuitems[index]; if (item->submenu() && visible && (! item->submenu()->isTorn()) && item->isEnabled()) {

@@ -648,26 +650,26 @@ }

} -Bool Basemenu::hasSubmenu(int index) { - if ((index >= 0) && (index < menuitems.size())) +bool Basemenu::hasSubmenu(unsigned int index) { + if (index < menuitems.size()) if (menuitems[index]->submenu()) - return True; + return true; else - return False; + return false; else - return False; + return false; } -void Basemenu::drawItem(int index, Bool highlight, Bool clear, +void Basemenu::drawItem(unsigned int index, bool highlight, bool clear, int x, int y, unsigned int w, unsigned int h) { - if (index < 0 || index > menuitems.size()) return; + if (index >= menuitems.size()) return; BasemenuItem *item = menuitems[index]; if (! item) return; - Bool dotext = True, dohilite = True, dosel = True; + bool dotext = true, dohilite = true, dosel = true; const char *text = item->label(); int sbl = index / menu.persub, i = index - (sbl * menu.persub); int item_x = (sbl * menu.item_w), item_y = (i * menu.item_h);

@@ -843,39 +845,39 @@ else menu.label = 0;

} -void Basemenu::setItemSelected(int index, Bool sel) { - if (index < 0 || index >= menuitems.size()) return; +void Basemenu::setItemSelected(unsigned int index, bool sel) { + if (index >= menuitems.size()) return; BasemenuItem *item = find(index); if (! item) return; item->setSelected(sel); - if (visible) drawItem(index, (index == which_sub), True); + if (visible) drawItem(index, (index == (unsigned int)which_sub), true); } -Bool Basemenu::isItemSelected(int index) { - if (index < 0 || index >= menuitems.size()) return False; +bool Basemenu::isItemSelected(unsigned int index) { + if (index >= menuitems.size()) return false; BasemenuItem *item = find(index); - if (! item) return False; + if (! item) return false; return item->isSelected(); } -void Basemenu::setItemEnabled(int index, Bool enable) { - if (index < 0 || index >= menuitems.size()) return; +void Basemenu::setItemEnabled(unsigned int index, bool enable) { + if (index >= menuitems.size()) return; BasemenuItem *item = find(index); if (! item) return; item->setEnabled(enable); - if (visible) drawItem(index, (index == which_sub), True); + if (visible) drawItem(index, (index == static_cast<unsigned int>(which_sub)), True); } -Bool Basemenu::isItemEnabled(int index) { +bool Basemenu::isItemEnabled(unsigned int index) { if (index < 0 || index >= menuitems.size()) return False; BasemenuItem *item = find(index);

@@ -890,7 +892,7 @@ if (be->window == menu.frame) {

int sbl = (be->x / menu.item_w), i = (be->y / menu.item_h); int w = (sbl * menu.persub) + i; - if (w < menuitems.size() && w >= 0) { + if (w < static_cast<int>(menuitems.size()) && w >= 0) { which_press = i; which_sbl = sbl;

@@ -933,7 +935,7 @@ ix = sbl * menu.item_w, iy = i * menu.item_h,

w = (sbl * menu.persub) + i, p = (which_sbl * menu.persub) + which_press; - if (w < menuitems.size() && w >= 0) { + if (w < static_cast<int>(menuitems.size()) && w >= 0) { drawItem(p, (p == which_sub), True); if (p == w && isItemEnabled(w)) {

@@ -979,7 +981,7 @@ int sbl = (me->x / menu.item_w), i = (me->y / menu.item_h),

w = (sbl * menu.persub) + i; if ((i != which_press || sbl != which_sbl) && - (w < menuitems.size() && w >= 0)) { + (w < static_cast<int>(menuitems.size()) && w >= 0)) { if (which_press != -1 && which_sbl != -1) { int p = (which_sbl * menu.persub) + which_press; BasemenuItem *item = menuitems[p];

@@ -1029,7 +1031,7 @@ int i, ii;

for (i = sbl; i <= sbl_d; i++) { // set the iterator to the first item in the sublevel needing redrawing int index = id + i * menu.persub; - if (index < menuitems.size() && index >= 0) { + if (index < static_cast<int>(menuitems.size()) && index >= 0) { Menuitems::iterator it = menuitems.begin() + index; Menuitems::iterator it_end = menuitems.end(); for (ii = id; ii <= id_d && it != it_end; ++it, ii++) {
M src/Basemenu.hhsrc/Basemenu.hh

@@ -22,10 +22,10 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING

// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Basemenu.hh,v 1.7 2002/02/17 19:00:04 fluxgen Exp $ +// $Id: Basemenu.hh,v 1.8 2002/03/20 14:10:03 fluxgen Exp $ -#ifndef BASEMENU_HH -#define BASEMENU_HH +#ifndef BASEMENU_HH +#define BASEMENU_HH #include <X11/Xlib.h> #include <vector>

@@ -40,103 +40,100 @@ class BImageControl;

class BScreen; class Basemenu { -private: - typedef std::vector<BasemenuItem *> Menuitems; - Menuitems menuitems; - Fluxbox *fluxbox; - Basemenu *parent; - BImageControl *image_ctrl; - BScreen *screen; +public: + explicit Basemenu(BScreen *); + virtual ~Basemenu(void); - Bool moving, visible, movable, torn, internal_menu, title_vis, shifted, - hide_tree; - Display *display; - int which_sub, which_press, which_sbl, alignment; + inline const Bool &isTorn(void) const { return torn; } + inline const Bool &isVisible(void) const { return visible; } - struct _menu { - Pixmap frame_pixmap, title_pixmap, hilite_pixmap, sel_pixmap; - Window window, frame, title; + inline BScreen *getScreen(void) const { return screen; } - char *label; - int x, y, x_move, y_move, x_shift, y_shift, sublevels, persub, minsub, - grab_x, grab_y; - unsigned int width, height, title_h, frame_h, item_w, item_h, bevel_w, - bevel_h; - } menu; + inline const Window &getWindowID(void) const { return menu.window; } + inline const char *getLabel(void) const { return menu.label; } -protected: - inline BasemenuItem *find(int index) { return menuitems[index]; } - inline void setTitleVisibility(Bool b) { title_vis = b; } - inline void setMovable(Bool b) { movable = b; } - inline void setHideTree(Bool h) { hide_tree = h; } - inline void setMinimumSublevels(int m) { menu.minsub = m; } + int insert(const char *, int = 0, const char * = (const char *) 0, int = -1); + int insert(const char **, int = -1, int = 0); + int insert(const char *, Basemenu *, int = -1); + int remove(unsigned int item); - virtual void itemSelected(int, int) = 0; - virtual void drawItem(int, Bool = False, Bool = False, - int = -1, int = -1, unsigned int = 0, unsigned int = 0); - virtual void redrawTitle(); - virtual void internal_hide(void); + inline const int &getX(void) const { return menu.x; } + inline const int &getY(void) const { return menu.y; } + inline int getCount(void) { return menuitems.size(); } + inline const int &getCurrentSubmenu(void) const { return which_sub; } + inline const unsigned int &getWidth(void) const { return menu.width; } + inline const unsigned int &getHeight(void) const { return menu.height; } + inline const unsigned int &getTitleHeight(void) const { return menu.title_h; } -public: - Basemenu(BScreen *); - virtual ~Basemenu(void); + inline void setInternalMenu(void) { internal_menu = True; } + inline void setAlignment(int a) { alignment = a; } + inline void setTorn(void) { torn = True; } + inline void removeParent(void) { if (internal_menu) parent = (Basemenu *) 0; } - inline const Bool &isTorn(void) const { return torn; } - inline const Bool &isVisible(void) const { return visible; } + bool hasSubmenu(unsigned int index); + bool isItemSelected(unsigned int index); + bool isItemEnabled(unsigned int index); - inline BScreen *getScreen(void) { return screen; } + void buttonPressEvent(XButtonEvent *); + void buttonReleaseEvent(XButtonEvent *); + void motionNotifyEvent(XMotionEvent *); + void enterNotifyEvent(XCrossingEvent *); + void leaveNotifyEvent(XCrossingEvent *); + void exposeEvent(XExposeEvent *); + void reconfigure(void); + void setLabel(const char *n); + void move(int, int); + void update(void); + void setItemSelected(unsigned int index, bool val); + void setItemEnabled(unsigned int, bool val); - inline const Window &getWindowID(void) const { return menu.window; } + virtual void drawSubmenu(unsigned int index); + virtual void show(void); + virtual void hide(void); - inline const char *getLabel(void) const { return menu.label; } + enum { ALIGNDONTCARE = 1, ALIGNTOP, ALIGNBOTTOM }; + enum { RIGHT = 1, LEFT }; + enum { EMPTY = 0, SQUARE, TRIANGLE, DIAMOND }; - int insert(const char *, int = 0, const char * = (const char *) 0, int = -1); - int insert(const char **, int = -1, int = 0); - int insert(const char *, Basemenu *, int = -1); - int remove(int); +private: + typedef std::vector<BasemenuItem *> Menuitems; + Menuitems menuitems; + Fluxbox *fluxbox; + Basemenu *parent; + BImageControl *image_ctrl; + BScreen *screen; - inline const int &getX(void) const { return menu.x; } - inline const int &getY(void) const { return menu.y; } - inline int getCount(void) { return menuitems.size(); } - inline const int &getCurrentSubmenu(void) const { return which_sub; } + Bool moving, visible, movable, torn, internal_menu, title_vis, shifted, + hide_tree; + Display *display; + int which_sub, which_press, which_sbl, alignment; - inline const unsigned int &getWidth(void) const { return menu.width; } - inline const unsigned int &getHeight(void) const { return menu.height; } - inline const unsigned int &getTitleHeight(void) const { return menu.title_h; } + struct _menu { + Pixmap frame_pixmap, title_pixmap, hilite_pixmap, sel_pixmap; + Window window, frame, title; - inline void setInternalMenu(void) { internal_menu = True; } - inline void setAlignment(int a) { alignment = a; } - inline void setTorn(void) { torn = True; } - inline void removeParent(void) - { if (internal_menu) parent = (Basemenu *) 0; } + char *label; + int x, y, x_move, y_move, x_shift, y_shift, sublevels, persub, minsub, + grab_x, grab_y; + unsigned int width, height, title_h, frame_h, item_w, item_h, bevel_w, + bevel_h; + } menu; - Bool hasSubmenu(int); - Bool isItemSelected(int); - Bool isItemEnabled(int); - void buttonPressEvent(XButtonEvent *); - void buttonReleaseEvent(XButtonEvent *); - void motionNotifyEvent(XMotionEvent *); - void enterNotifyEvent(XCrossingEvent *); - void leaveNotifyEvent(XCrossingEvent *); - void exposeEvent(XExposeEvent *); - void reconfigure(void); - void setLabel(const char *n); - void move(int, int); - void update(void); - void setItemSelected(int, Bool); - void setItemEnabled(int, Bool); +protected: + inline BasemenuItem *find(unsigned int index) { return menuitems[index]; } + inline void setTitleVisibility(bool b) { title_vis = b; } + inline void setMovable(bool b) { movable = b; } + inline void setHideTree(bool h) { hide_tree = h; } + inline void setMinimumSublevels(int m) { menu.minsub = m; } - virtual void drawSubmenu(int); - virtual void show(void); - virtual void hide(void); - - enum { ALIGNDONTCARE = 1, ALIGNTOP, ALIGNBOTTOM }; - enum { RIGHT = 1, LEFT }; - enum { EMPTY = 0, SQUARE, TRIANGLE, DIAMOND }; - + virtual void itemSelected(int, int) = 0; + virtual void drawItem(unsigned int index, bool highlight= false, bool clear= false, + int x= -1, int y= -1, unsigned int width= 0, unsigned int height= 0); + virtual void redrawTitle(); + virtual void internal_hide(void); }; class BasemenuItem {