signed/unsigned warnings
This commit is contained in:
parent
e072c2c744
commit
3b330a5f62
2 changed files with 122 additions and 123 deletions
|
@ -22,7 +22,7 @@
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// 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
|
// stupid macros needed to access some functions in version 2 of the GNU C
|
||||||
// library
|
// library
|
||||||
|
@ -236,8 +236,8 @@ int Basemenu::insert(const char **ulabel, int pos, int function) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int Basemenu::remove(int index) {
|
int Basemenu::remove(unsigned int index) {
|
||||||
if (index < 0 || index >= menuitems.size()) {
|
if (index >= menuitems.size()) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
std::cout << "Bad index (" << index << ") given to Basemenu::remove()"
|
std::cout << "Bad index (" << index << ") given to Basemenu::remove()"
|
||||||
<< " -- should be between 0 and " << menuitems.size()-1
|
<< " -- should be between 0 and " << menuitems.size()-1
|
||||||
|
@ -264,9 +264,9 @@ int Basemenu::remove(int index) {
|
||||||
delete item;
|
delete item;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (which_sub == index)
|
if (static_cast<unsigned int>(which_sub) == index)
|
||||||
which_sub = -1;
|
which_sub = -1;
|
||||||
else if (which_sub > index)
|
else if (static_cast<unsigned int>(which_sub) > index)
|
||||||
which_sub--;
|
which_sub--;
|
||||||
|
|
||||||
return menuitems.size();
|
return menuitems.size();
|
||||||
|
@ -426,13 +426,14 @@ void Basemenu::update(void) {
|
||||||
|
|
||||||
if (title_vis && visible) redrawTitle();
|
if (title_vis && visible) redrawTitle();
|
||||||
|
|
||||||
int i = 0;
|
unsigned int i = 0;
|
||||||
for (i = 0; visible && i < menuitems.size(); i++)
|
for (i = 0; visible && i < menuitems.size(); i++) {
|
||||||
if (i == which_sub) {
|
if (i == (unsigned int)which_sub) {
|
||||||
drawItem(i, True, 0);
|
drawItem(i, True, 0);
|
||||||
drawSubmenu(i);
|
drawSubmenu(i);
|
||||||
} else
|
} else
|
||||||
drawItem(i, False, 0);
|
drawItem(i, False, 0);
|
||||||
|
}
|
||||||
|
|
||||||
if (parent && visible)
|
if (parent && visible)
|
||||||
parent->drawSubmenu(parent->which_sub);
|
parent->drawSubmenu(parent->which_sub);
|
||||||
|
@ -541,15 +542,16 @@ void Basemenu::redrawTitle(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Basemenu::drawSubmenu(int index) {
|
void Basemenu::drawSubmenu(unsigned int index) {
|
||||||
if (which_sub >= 0 && which_sub != 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];
|
BasemenuItem *itmp = menuitems[which_sub];
|
||||||
|
|
||||||
if (! itmp->submenu()->isTorn())
|
if (! itmp->submenu()->isTorn())
|
||||||
itmp->submenu()->internal_hide();
|
itmp->submenu()->internal_hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index >= 0 && index < menuitems.size()) {
|
if (index < menuitems.size()) {
|
||||||
BasemenuItem *item = menuitems[index];
|
BasemenuItem *item = menuitems[index];
|
||||||
if (item->submenu() && visible && (! item->submenu()->isTorn()) &&
|
if (item->submenu() && visible && (! item->submenu()->isTorn()) &&
|
||||||
item->isEnabled()) {
|
item->isEnabled()) {
|
||||||
|
@ -648,26 +650,26 @@ void Basemenu::drawSubmenu(int index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Bool Basemenu::hasSubmenu(int index) {
|
bool Basemenu::hasSubmenu(unsigned int index) {
|
||||||
if ((index >= 0) && (index < menuitems.size()))
|
if (index < menuitems.size())
|
||||||
if (menuitems[index]->submenu())
|
if (menuitems[index]->submenu())
|
||||||
return True;
|
return true;
|
||||||
else
|
else
|
||||||
return False;
|
return false;
|
||||||
else
|
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)
|
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];
|
BasemenuItem *item = menuitems[index];
|
||||||
if (! item) return;
|
if (! item) return;
|
||||||
|
|
||||||
Bool dotext = True, dohilite = True, dosel = True;
|
bool dotext = true, dohilite = true, dosel = true;
|
||||||
const char *text = item->label();
|
const char *text = item->label();
|
||||||
int sbl = index / menu.persub, i = index - (sbl * menu.persub);
|
int sbl = index / menu.persub, i = index - (sbl * menu.persub);
|
||||||
int item_x = (sbl * menu.item_w), item_y = (i * menu.item_h);
|
int item_x = (sbl * menu.item_w), item_y = (i * menu.item_h);
|
||||||
|
@ -843,39 +845,39 @@ void Basemenu::setLabel(const char *l) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Basemenu::setItemSelected(int index, Bool sel) {
|
void Basemenu::setItemSelected(unsigned int index, bool sel) {
|
||||||
if (index < 0 || index >= menuitems.size()) return;
|
if (index >= menuitems.size()) return;
|
||||||
|
|
||||||
BasemenuItem *item = find(index);
|
BasemenuItem *item = find(index);
|
||||||
if (! item) return;
|
if (! item) return;
|
||||||
|
|
||||||
item->setSelected(sel);
|
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) {
|
bool Basemenu::isItemSelected(unsigned int index) {
|
||||||
if (index < 0 || index >= menuitems.size()) return False;
|
if (index >= menuitems.size()) return false;
|
||||||
|
|
||||||
BasemenuItem *item = find(index);
|
BasemenuItem *item = find(index);
|
||||||
if (! item) return False;
|
if (! item) return false;
|
||||||
|
|
||||||
return item->isSelected();
|
return item->isSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Basemenu::setItemEnabled(int index, Bool enable) {
|
void Basemenu::setItemEnabled(unsigned int index, bool enable) {
|
||||||
if (index < 0 || index >= menuitems.size()) return;
|
if (index >= menuitems.size()) return;
|
||||||
|
|
||||||
BasemenuItem *item = find(index);
|
BasemenuItem *item = find(index);
|
||||||
if (! item) return;
|
if (! item) return;
|
||||||
|
|
||||||
item->setEnabled(enable);
|
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;
|
if (index < 0 || index >= menuitems.size()) return False;
|
||||||
|
|
||||||
BasemenuItem *item = find(index);
|
BasemenuItem *item = find(index);
|
||||||
|
@ -890,7 +892,7 @@ void Basemenu::buttonPressEvent(XButtonEvent *be) {
|
||||||
int sbl = (be->x / menu.item_w), i = (be->y / menu.item_h);
|
int sbl = (be->x / menu.item_w), i = (be->y / menu.item_h);
|
||||||
int w = (sbl * menu.persub) + i;
|
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_press = i;
|
||||||
which_sbl = sbl;
|
which_sbl = sbl;
|
||||||
|
|
||||||
|
@ -933,7 +935,7 @@ void Basemenu::buttonReleaseEvent(XButtonEvent *re) {
|
||||||
w = (sbl * menu.persub) + i,
|
w = (sbl * menu.persub) + i,
|
||||||
p = (which_sbl * menu.persub) + which_press;
|
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);
|
drawItem(p, (p == which_sub), True);
|
||||||
|
|
||||||
if (p == w && isItemEnabled(w)) {
|
if (p == w && isItemEnabled(w)) {
|
||||||
|
@ -979,7 +981,7 @@ void Basemenu::motionNotifyEvent(XMotionEvent *me) {
|
||||||
w = (sbl * menu.persub) + i;
|
w = (sbl * menu.persub) + i;
|
||||||
|
|
||||||
if ((i != which_press || sbl != which_sbl) &&
|
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) {
|
if (which_press != -1 && which_sbl != -1) {
|
||||||
int p = (which_sbl * menu.persub) + which_press;
|
int p = (which_sbl * menu.persub) + which_press;
|
||||||
BasemenuItem *item = menuitems[p];
|
BasemenuItem *item = menuitems[p];
|
||||||
|
@ -1029,7 +1031,7 @@ void Basemenu::exposeEvent(XExposeEvent *ee) {
|
||||||
for (i = sbl; i <= sbl_d; i++) {
|
for (i = sbl; i <= sbl_d; i++) {
|
||||||
// set the iterator to the first item in the sublevel needing redrawing
|
// set the iterator to the first item in the sublevel needing redrawing
|
||||||
int index = id + i * menu.persub;
|
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 = menuitems.begin() + index;
|
||||||
Menuitems::iterator it_end = menuitems.end();
|
Menuitems::iterator it_end = menuitems.end();
|
||||||
for (ii = id; ii <= id_d && it != it_end; ++it, ii++) {
|
for (ii = id; ii <= id_d && it != it_end; ++it, ii++) {
|
||||||
|
|
177
src/Basemenu.hh
177
src/Basemenu.hh
|
@ -22,10 +22,10 @@
|
||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// 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
|
#ifndef BASEMENU_HH
|
||||||
#define BASEMENU_HH
|
#define BASEMENU_HH
|
||||||
|
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -40,103 +40,100 @@ class BImageControl;
|
||||||
class BScreen;
|
class BScreen;
|
||||||
|
|
||||||
class Basemenu {
|
class Basemenu {
|
||||||
|
public:
|
||||||
|
explicit Basemenu(BScreen *);
|
||||||
|
virtual ~Basemenu(void);
|
||||||
|
|
||||||
|
inline const Bool &isTorn(void) const { return torn; }
|
||||||
|
inline const Bool &isVisible(void) const { return visible; }
|
||||||
|
|
||||||
|
inline BScreen *getScreen(void) const { return screen; }
|
||||||
|
|
||||||
|
inline const Window &getWindowID(void) const { return menu.window; }
|
||||||
|
|
||||||
|
inline const char *getLabel(void) const { return menu.label; }
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
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; }
|
||||||
|
|
||||||
|
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; }
|
||||||
|
|
||||||
|
bool hasSubmenu(unsigned int index);
|
||||||
|
bool isItemSelected(unsigned int index);
|
||||||
|
bool isItemEnabled(unsigned int index);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
virtual void drawSubmenu(unsigned int index);
|
||||||
|
virtual void show(void);
|
||||||
|
virtual void hide(void);
|
||||||
|
|
||||||
|
enum { ALIGNDONTCARE = 1, ALIGNTOP, ALIGNBOTTOM };
|
||||||
|
enum { RIGHT = 1, LEFT };
|
||||||
|
enum { EMPTY = 0, SQUARE, TRIANGLE, DIAMOND };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::vector<BasemenuItem *> Menuitems;
|
typedef std::vector<BasemenuItem *> Menuitems;
|
||||||
Menuitems menuitems;
|
Menuitems menuitems;
|
||||||
Fluxbox *fluxbox;
|
Fluxbox *fluxbox;
|
||||||
Basemenu *parent;
|
Basemenu *parent;
|
||||||
BImageControl *image_ctrl;
|
BImageControl *image_ctrl;
|
||||||
BScreen *screen;
|
BScreen *screen;
|
||||||
|
|
||||||
Bool moving, visible, movable, torn, internal_menu, title_vis, shifted,
|
Bool moving, visible, movable, torn, internal_menu, title_vis, shifted,
|
||||||
hide_tree;
|
hide_tree;
|
||||||
Display *display;
|
Display *display;
|
||||||
int which_sub, which_press, which_sbl, alignment;
|
int which_sub, which_press, which_sbl, alignment;
|
||||||
|
|
||||||
struct _menu {
|
struct _menu {
|
||||||
Pixmap frame_pixmap, title_pixmap, hilite_pixmap, sel_pixmap;
|
Pixmap frame_pixmap, title_pixmap, hilite_pixmap, sel_pixmap;
|
||||||
Window window, frame, title;
|
Window window, frame, title;
|
||||||
|
|
||||||
char *label;
|
char *label;
|
||||||
int x, y, x_move, y_move, x_shift, y_shift, sublevels, persub, minsub,
|
int x, y, x_move, y_move, x_shift, y_shift, sublevels, persub, minsub,
|
||||||
grab_x, grab_y;
|
grab_x, grab_y;
|
||||||
unsigned int width, height, title_h, frame_h, item_w, item_h, bevel_w,
|
unsigned int width, height, title_h, frame_h, item_w, item_h, bevel_w,
|
||||||
bevel_h;
|
bevel_h;
|
||||||
} menu;
|
} menu;
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
inline BasemenuItem *find(int index) { return menuitems[index]; }
|
inline BasemenuItem *find(unsigned int index) { return menuitems[index]; }
|
||||||
inline void setTitleVisibility(Bool b) { title_vis = b; }
|
inline void setTitleVisibility(bool b) { title_vis = b; }
|
||||||
inline void setMovable(Bool b) { movable = b; }
|
inline void setMovable(bool b) { movable = b; }
|
||||||
inline void setHideTree(Bool h) { hide_tree = h; }
|
inline void setHideTree(bool h) { hide_tree = h; }
|
||||||
inline void setMinimumSublevels(int m) { menu.minsub = m; }
|
inline void setMinimumSublevels(int m) { menu.minsub = m; }
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
|
|
||||||
public:
|
|
||||||
Basemenu(BScreen *);
|
|
||||||
virtual ~Basemenu(void);
|
|
||||||
|
|
||||||
inline const Bool &isTorn(void) const { return torn; }
|
|
||||||
inline const Bool &isVisible(void) const { return visible; }
|
|
||||||
|
|
||||||
inline BScreen *getScreen(void) { return screen; }
|
|
||||||
|
|
||||||
inline const Window &getWindowID(void) const { return menu.window; }
|
|
||||||
|
|
||||||
inline const char *getLabel(void) const { return menu.label; }
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
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; }
|
|
||||||
|
|
||||||
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; }
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
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 {
|
class BasemenuItem {
|
||||||
|
|
Loading…
Reference in a new issue