clean up
This commit is contained in:
parent
02253281ee
commit
45364e82b3
2 changed files with 265 additions and 281 deletions
424
src/Basemenu.cc
424
src/Basemenu.cc
|
@ -22,7 +22,7 @@
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// $Id: Basemenu.cc,v 1.19 2002/04/08 18:57:04 fluxgen Exp $
|
||||
// $Id: Basemenu.cc,v 1.20 2002/04/08 22:37:49 fluxgen Exp $
|
||||
|
||||
//use GNU extensions
|
||||
#ifndef _GNU_SOURCE
|
||||
|
@ -55,23 +55,23 @@ using namespace std;
|
|||
|
||||
static Basemenu *shown = (Basemenu *) 0;
|
||||
|
||||
Basemenu::Basemenu(BScreen *scrn) {
|
||||
screen = scrn;
|
||||
fluxbox = Fluxbox::instance();
|
||||
image_ctrl = screen->getImageControl();
|
||||
display = fluxbox->getXDisplay();
|
||||
parent = (Basemenu *) 0;
|
||||
alignment = ALIGNDONTCARE;
|
||||
Basemenu::Basemenu(BScreen *screen):
|
||||
m_fluxbox(Fluxbox::instance()),
|
||||
m_screen(screen),
|
||||
m_display(m_fluxbox->getXDisplay()),
|
||||
m_parent(0),
|
||||
m_image_ctrl(m_screen->getImageControl()),
|
||||
m_alignment(ALIGNDONTCARE) {
|
||||
|
||||
title_vis =
|
||||
movable =
|
||||
hide_tree = True;
|
||||
hide_tree = true;
|
||||
|
||||
shifted =
|
||||
internal_menu =
|
||||
moving =
|
||||
torn =
|
||||
visible = False;
|
||||
visible = false;
|
||||
|
||||
menu.x =
|
||||
menu.y =
|
||||
|
@ -89,35 +89,34 @@ Basemenu::Basemenu(BScreen *scrn) {
|
|||
menu.hilite_pixmap =
|
||||
menu.sel_pixmap = None;
|
||||
|
||||
menu.bevel_w = screen->getBevelWidth();
|
||||
menu.bevel_w = m_screen->getBevelWidth();
|
||||
|
||||
I18n *i18n = I18n::instance();
|
||||
|
||||
if (i18n->multibyte()) {
|
||||
menu.width = menu.title_h = menu.item_w = menu.frame_h =
|
||||
screen->getMenuStyle()->titlefont->getFontSetExtents()->max_ink_extent.height +
|
||||
m_screen->getMenuStyle()->titlefont->getFontSetExtents()->max_ink_extent.height +
|
||||
(menu.bevel_w * 2);
|
||||
} else {
|
||||
menu.width = menu.title_h = menu.item_w = menu.frame_h =
|
||||
screen->getMenuStyle()->titlefont->getFontStruct()->ascent +
|
||||
screen->getMenuStyle()->titlefont->getFontStruct()->descent +
|
||||
m_screen->getMenuStyle()->titlefont->getFontStruct()->ascent +
|
||||
m_screen->getMenuStyle()->titlefont->getFontStruct()->descent +
|
||||
(menu.bevel_w * 2);
|
||||
}
|
||||
menu.label = 0;
|
||||
|
||||
menu.sublevels =
|
||||
menu.persub =
|
||||
menu.minsub = 0;
|
||||
|
||||
if (i18n->multibyte()) {
|
||||
menu.item_h = screen->getMenuStyle()->framefont->getFontSetExtents()->max_ink_extent.height +
|
||||
menu.item_h = m_screen->getMenuStyle()->framefont->getFontSetExtents()->max_ink_extent.height +
|
||||
(menu.bevel_w);
|
||||
} else {
|
||||
menu.item_h = screen->getMenuStyle()->framefont->getFontStruct()->ascent +
|
||||
screen->getMenuStyle()->framefont->getFontStruct()->descent +
|
||||
menu.item_h = m_screen->getMenuStyle()->framefont->getFontStruct()->ascent +
|
||||
m_screen->getMenuStyle()->framefont->getFontStruct()->descent +
|
||||
(menu.bevel_w);
|
||||
}
|
||||
menu.height = menu.title_h + screen->getBorderWidth() + menu.frame_h;
|
||||
menu.height = menu.title_h + m_screen->getBorderWidth() + menu.frame_h;
|
||||
|
||||
//set attributes for menu window
|
||||
unsigned long attrib_mask = CWBackPixmap | CWBackPixel | CWBorderPixel |
|
||||
|
@ -125,77 +124,73 @@ Basemenu::Basemenu(BScreen *scrn) {
|
|||
XSetWindowAttributes attrib;
|
||||
attrib.background_pixmap = None;
|
||||
attrib.background_pixel = attrib.border_pixel =
|
||||
screen->getBorderColor()->getPixel();
|
||||
attrib.colormap = screen->getColormap();
|
||||
m_screen->getBorderColor()->getPixel();
|
||||
attrib.colormap = m_screen->getColormap();
|
||||
attrib.override_redirect = True;
|
||||
attrib.event_mask = ButtonPressMask | ButtonReleaseMask |
|
||||
ButtonMotionMask | ExposureMask;
|
||||
|
||||
//create menu window
|
||||
menu.window =
|
||||
XCreateWindow(display, screen->getRootWindow(), menu.x, menu.y, menu.width,
|
||||
menu.height, screen->getBorderWidth(), screen->getDepth(),
|
||||
InputOutput, screen->getVisual(), attrib_mask, &attrib);
|
||||
XCreateWindow(m_display, m_screen->getRootWindow(), menu.x, menu.y, menu.width,
|
||||
menu.height, m_screen->getBorderWidth(), m_screen->getDepth(),
|
||||
InputOutput, m_screen->getVisual(), attrib_mask, &attrib);
|
||||
|
||||
fluxbox->saveMenuSearch(menu.window, this);
|
||||
m_fluxbox->saveMenuSearch(menu.window, this);
|
||||
|
||||
//attibutes for title to menuwindow
|
||||
attrib_mask = CWBackPixmap | CWBackPixel | CWBorderPixel | CWEventMask;
|
||||
attrib.background_pixel = screen->getBorderColor()->getPixel();
|
||||
attrib.background_pixel = m_screen->getBorderColor()->getPixel();
|
||||
attrib.event_mask |= EnterWindowMask | LeaveWindowMask;
|
||||
//create menu title
|
||||
menu.title =
|
||||
XCreateWindow(display, menu.window, 0, 0, menu.width, menu.height, 0,
|
||||
screen->getDepth(), InputOutput, screen->getVisual(),
|
||||
XCreateWindow(m_display, menu.window, 0, 0, menu.width, menu.height, 0,
|
||||
m_screen->getDepth(), InputOutput, m_screen->getVisual(),
|
||||
attrib_mask, &attrib);
|
||||
fluxbox->saveMenuSearch(menu.title, this);
|
||||
m_fluxbox->saveMenuSearch(menu.title, this);
|
||||
|
||||
attrib.event_mask |= PointerMotionMask;
|
||||
menu.frame = XCreateWindow(display, menu.window, 0,
|
||||
menu.title_h + screen->getBorderWidth(),
|
||||
menu.frame = XCreateWindow(m_display, menu.window, 0,
|
||||
menu.title_h + m_screen->getBorderWidth(),
|
||||
menu.width, menu.frame_h, 0,
|
||||
screen->getDepth(), InputOutput,
|
||||
screen->getVisual(), attrib_mask, &attrib);
|
||||
fluxbox->saveMenuSearch(menu.frame, this);
|
||||
m_screen->getDepth(), InputOutput,
|
||||
m_screen->getVisual(), attrib_mask, &attrib);
|
||||
m_fluxbox->saveMenuSearch(menu.frame, this);
|
||||
|
||||
// even though this is the end of the constructor the menu is still not
|
||||
// completely created. items must be inserted and it must be update()'d
|
||||
}
|
||||
|
||||
|
||||
Basemenu::~Basemenu(void) {
|
||||
XUnmapWindow(display, menu.window);
|
||||
XUnmapWindow(m_display, menu.window);
|
||||
|
||||
if (shown && shown->getWindowID() == getWindowID())
|
||||
if (shown && shown->windowID() == windowID())
|
||||
shown = (Basemenu *) 0;
|
||||
|
||||
//TODO: this looks kind of strange
|
||||
int n = menuitems.size() - 1;
|
||||
for (int i = 0; i < n; ++i)
|
||||
remove(0);
|
||||
|
||||
if (menu.label)
|
||||
delete [] menu.label;
|
||||
|
||||
if (menu.title_pixmap)
|
||||
image_ctrl->removeImage(menu.title_pixmap);
|
||||
m_image_ctrl->removeImage(menu.title_pixmap);
|
||||
|
||||
if (menu.frame_pixmap)
|
||||
image_ctrl->removeImage(menu.frame_pixmap);
|
||||
m_image_ctrl->removeImage(menu.frame_pixmap);
|
||||
|
||||
if (menu.hilite_pixmap)
|
||||
image_ctrl->removeImage(menu.hilite_pixmap);
|
||||
m_image_ctrl->removeImage(menu.hilite_pixmap);
|
||||
|
||||
if (menu.sel_pixmap)
|
||||
image_ctrl->removeImage(menu.sel_pixmap);
|
||||
m_image_ctrl->removeImage(menu.sel_pixmap);
|
||||
|
||||
fluxbox->removeMenuSearch(menu.title);
|
||||
XDestroyWindow(display, menu.title);
|
||||
m_fluxbox->removeMenuSearch(menu.title);
|
||||
XDestroyWindow(m_display, menu.title);
|
||||
|
||||
fluxbox->removeMenuSearch(menu.frame);
|
||||
XDestroyWindow(display, menu.frame);
|
||||
m_fluxbox->removeMenuSearch(menu.frame);
|
||||
XDestroyWindow(m_display, menu.frame);
|
||||
|
||||
fluxbox->removeMenuSearch(menu.window);
|
||||
XDestroyWindow(display, menu.window);
|
||||
m_fluxbox->removeMenuSearch(menu.window);
|
||||
XDestroyWindow(m_display, menu.window);
|
||||
}
|
||||
|
||||
|
||||
|
@ -219,7 +214,7 @@ int Basemenu::insert(const char *label, Basemenu *submenu, int pos) {
|
|||
menuitems.insert(menuitems.begin() + pos, item);
|
||||
}
|
||||
|
||||
submenu->parent = this;
|
||||
submenu->m_parent = this;
|
||||
|
||||
return menuitems.size();
|
||||
}
|
||||
|
@ -265,21 +260,21 @@ void Basemenu::update(void) {
|
|||
I18n *i18n = I18n::instance();
|
||||
|
||||
if (i18n->multibyte()) {
|
||||
menu.item_h = screen->getMenuStyle()->framefont->getFontSetExtents()->max_ink_extent.height +
|
||||
menu.item_h = m_screen->getMenuStyle()->framefont->getFontSetExtents()->max_ink_extent.height +
|
||||
menu.bevel_w;
|
||||
menu.title_h = screen->getMenuStyle()->titlefont->getFontSetExtents()->max_ink_extent.height +
|
||||
menu.title_h = m_screen->getMenuStyle()->titlefont->getFontSetExtents()->max_ink_extent.height +
|
||||
(menu.bevel_w * 2);
|
||||
} else {
|
||||
menu.item_h = screen->getMenuStyle()->framefont->getFontStruct()->ascent +
|
||||
screen->getMenuStyle()->framefont->getFontStruct()->descent +
|
||||
menu.item_h = m_screen->getMenuStyle()->framefont->getFontStruct()->ascent +
|
||||
m_screen->getMenuStyle()->framefont->getFontStruct()->descent +
|
||||
menu.bevel_w;
|
||||
menu.title_h = screen->getMenuStyle()->titlefont->getFontStruct()->ascent +
|
||||
screen->getMenuStyle()->titlefont->getFontStruct()->descent +
|
||||
menu.title_h = m_screen->getMenuStyle()->titlefont->getFontStruct()->ascent +
|
||||
m_screen->getMenuStyle()->titlefont->getFontStruct()->descent +
|
||||
(menu.bevel_w * 2);
|
||||
}
|
||||
|
||||
if (title_vis) {
|
||||
const char *s = (menu.label) ? menu.label :
|
||||
const char *s = (menu.label!="") ? menu.label.c_str() :
|
||||
i18n->getMessage(
|
||||
FBNLS::BasemenuSet, FBNLS::BasemenuBlackboxMenu,
|
||||
"fluxbox Menu");
|
||||
|
@ -288,10 +283,10 @@ void Basemenu::update(void) {
|
|||
|
||||
if (i18n->multibyte()) {
|
||||
XRectangle ink, logical;
|
||||
XmbTextExtents(screen->getMenuStyle()->titlefont->getFontSet(), s, l, &ink, &logical);
|
||||
XmbTextExtents(m_screen->getMenuStyle()->titlefont->getFontSet(), s, l, &ink, &logical);
|
||||
menu.item_w = logical.width;
|
||||
} else
|
||||
menu.item_w = XTextWidth(screen->getMenuStyle()->titlefont->getFontStruct(), s, l);
|
||||
menu.item_w = XTextWidth(m_screen->getMenuStyle()->titlefont->getFontStruct(), s, l);
|
||||
|
||||
menu.item_w += (menu.bevel_w * 2);
|
||||
} else
|
||||
|
@ -303,15 +298,15 @@ void Basemenu::update(void) {
|
|||
for (; it != it_end; ++it) {
|
||||
BasemenuItem *itmp = (*it);
|
||||
|
||||
const char *s = itmp->label();
|
||||
int l = strlen(s);
|
||||
const char *s = itmp->label().c_str();
|
||||
int l = itmp->label().size();
|
||||
|
||||
if (i18n->multibyte()) {
|
||||
XRectangle ink, logical;
|
||||
XmbTextExtents(screen->getMenuStyle()->framefont->getFontSet(), s, l, &ink, &logical);
|
||||
XmbTextExtents(m_screen->getMenuStyle()->framefont->getFontSet(), s, l, &ink, &logical);
|
||||
ii = logical.width;
|
||||
} else
|
||||
ii = XTextWidth(screen->getMenuStyle()->framefont->getFontStruct(), s, l);
|
||||
ii = XTextWidth(m_screen->getMenuStyle()->framefont->getFontStruct(), s, l);
|
||||
|
||||
ii += (menu.bevel_w * 2) + (menu.item_h * 2);
|
||||
|
||||
|
@ -321,9 +316,9 @@ void Basemenu::update(void) {
|
|||
if (menuitems.size()) {
|
||||
menu.sublevels = 1;
|
||||
|
||||
while (((menu.item_h * (menuitems.size() + 1) / menu.sublevels)
|
||||
+ menu.title_h + screen->getBorderWidth()) >
|
||||
screen->getHeight())
|
||||
while (((menu.item_h * (menuitems.size() + 1) / menu.sublevels) +
|
||||
menu.title_h + m_screen->getBorderWidth()) >
|
||||
m_screen->getHeight())
|
||||
menu.sublevels++;
|
||||
|
||||
if (menu.sublevels < menu.minsub) menu.sublevels = menu.minsub;
|
||||
|
@ -339,7 +334,7 @@ void Basemenu::update(void) {
|
|||
if (! menu.width) menu.width = menu.item_w;
|
||||
|
||||
menu.frame_h = (menu.item_h * menu.persub);
|
||||
menu.height = ((title_vis) ? menu.title_h + screen->getBorderWidth() : 0) +
|
||||
menu.height = ((title_vis) ? menu.title_h + m_screen->getBorderWidth() : 0) +
|
||||
menu.frame_h;
|
||||
if (! menu.frame_h) menu.frame_h = 1;
|
||||
if (menu.height < 1) menu.height = 1;
|
||||
|
@ -348,41 +343,41 @@ void Basemenu::update(void) {
|
|||
BTexture *texture;
|
||||
if (title_vis) {
|
||||
tmp = menu.title_pixmap;
|
||||
texture = &(screen->getMenuStyle()->title);
|
||||
texture = &(m_screen->getMenuStyle()->title);
|
||||
if (texture->getTexture() == (BImage::FLAT | BImage::SOLID)) {
|
||||
menu.title_pixmap = None;
|
||||
XSetWindowBackground(display, menu.title,
|
||||
XSetWindowBackground(m_display, menu.title,
|
||||
texture->getColor()->getPixel());
|
||||
} else {
|
||||
menu.title_pixmap =
|
||||
image_ctrl->renderImage(menu.width, menu.title_h, texture);
|
||||
XSetWindowBackgroundPixmap(display, menu.title, menu.title_pixmap);
|
||||
m_image_ctrl->renderImage(menu.width, menu.title_h, texture);
|
||||
XSetWindowBackgroundPixmap(m_display, menu.title, menu.title_pixmap);
|
||||
}
|
||||
if (tmp) image_ctrl->removeImage(tmp);
|
||||
XClearWindow(display, menu.title);
|
||||
if (tmp) m_image_ctrl->removeImage(tmp);
|
||||
XClearWindow(m_display, menu.title);
|
||||
}
|
||||
|
||||
tmp = menu.frame_pixmap;
|
||||
texture = &(screen->getMenuStyle()->frame);
|
||||
texture = &(m_screen->getMenuStyle()->frame);
|
||||
if (texture->getTexture() == (BImage::FLAT | BImage::SOLID)) {
|
||||
menu.frame_pixmap = None;
|
||||
XSetWindowBackground(display, menu.frame,
|
||||
XSetWindowBackground(m_display, menu.frame,
|
||||
texture->getColor()->getPixel());
|
||||
} else {
|
||||
menu.frame_pixmap =
|
||||
image_ctrl->renderImage(menu.width, menu.frame_h, texture);
|
||||
XSetWindowBackgroundPixmap(display, menu.frame, menu.frame_pixmap);
|
||||
m_image_ctrl->renderImage(menu.width, menu.frame_h, texture);
|
||||
XSetWindowBackgroundPixmap(m_display, menu.frame, menu.frame_pixmap);
|
||||
}
|
||||
if (tmp) image_ctrl->removeImage(tmp);
|
||||
if (tmp) m_image_ctrl->removeImage(tmp);
|
||||
|
||||
tmp = menu.hilite_pixmap;
|
||||
texture = &(screen->getMenuStyle()->hilite);
|
||||
texture = &(m_screen->getMenuStyle()->hilite);
|
||||
if (texture->getTexture() == (BImage::FLAT | BImage::SOLID))
|
||||
menu.hilite_pixmap = None;
|
||||
else
|
||||
menu.hilite_pixmap =
|
||||
image_ctrl->renderImage(menu.item_w, menu.item_h, texture);
|
||||
if (tmp) image_ctrl->removeImage(tmp);
|
||||
m_image_ctrl->renderImage(menu.item_w, menu.item_h, texture);
|
||||
if (tmp) m_image_ctrl->removeImage(tmp);
|
||||
|
||||
tmp = menu.sel_pixmap;
|
||||
if (texture->getTexture() == (BImage::FLAT | BImage::SOLID))
|
||||
|
@ -390,23 +385,23 @@ void Basemenu::update(void) {
|
|||
else {
|
||||
int hw = menu.item_h / 2;
|
||||
menu.sel_pixmap =
|
||||
image_ctrl->renderImage(hw, hw, texture);
|
||||
m_image_ctrl->renderImage(hw, hw, texture);
|
||||
}
|
||||
if (tmp) image_ctrl->removeImage(tmp);
|
||||
if (tmp) m_image_ctrl->removeImage(tmp);
|
||||
|
||||
XResizeWindow(display, menu.window, menu.width, menu.height);
|
||||
XResizeWindow(m_display, menu.window, menu.width, menu.height);
|
||||
|
||||
if (title_vis)
|
||||
XResizeWindow(display, menu.title, menu.width, menu.title_h);
|
||||
XResizeWindow(m_display, menu.title, menu.width, menu.title_h);
|
||||
|
||||
XMoveResizeWindow(display, menu.frame, 0,
|
||||
XMoveResizeWindow(m_display, menu.frame, 0,
|
||||
((title_vis) ? menu.title_h +
|
||||
screen->getBorderWidth() : 0), menu.width,
|
||||
m_screen->getBorderWidth() : 0), menu.width,
|
||||
menu.frame_h);
|
||||
|
||||
XClearWindow(display, menu.window);
|
||||
XClearWindow(display, menu.title);
|
||||
XClearWindow(display, menu.frame);
|
||||
XClearWindow(m_display, menu.window);
|
||||
XClearWindow(m_display, menu.title);
|
||||
XClearWindow(m_display, menu.frame);
|
||||
|
||||
if (title_vis && visible) redrawTitle();
|
||||
|
||||
|
@ -419,19 +414,19 @@ void Basemenu::update(void) {
|
|||
drawItem(i, False, 0);
|
||||
}
|
||||
|
||||
if (parent && visible)
|
||||
parent->drawSubmenu(parent->which_sub);
|
||||
if (m_parent && visible)
|
||||
m_parent->drawSubmenu(m_parent->which_sub);
|
||||
|
||||
XMapSubwindows(display, menu.window);
|
||||
XMapSubwindows(m_display, menu.window);
|
||||
}
|
||||
|
||||
|
||||
void Basemenu::show(void) {
|
||||
XMapSubwindows(display, menu.window);
|
||||
XMapWindow(display, menu.window);
|
||||
XMapSubwindows(m_display, menu.window);
|
||||
XMapWindow(m_display, menu.window);
|
||||
visible = True;
|
||||
|
||||
if (! parent) {
|
||||
if (! m_parent) {
|
||||
if (shown && (! shown->torn))
|
||||
shown->hide();
|
||||
|
||||
|
@ -441,10 +436,10 @@ void Basemenu::show(void) {
|
|||
|
||||
|
||||
void Basemenu::hide(void) {
|
||||
if ((! torn) && hide_tree && parent && parent->isVisible()) {
|
||||
Basemenu *p = parent;
|
||||
if ((! torn) && hide_tree && m_parent && m_parent->isVisible()) {
|
||||
Basemenu *p = m_parent;
|
||||
|
||||
while (p->isVisible() && (! p->torn) && p->parent) p = p->parent;
|
||||
while (p->isVisible() && (! p->torn) && p->m_parent) p = p->m_parent;
|
||||
p->internal_hide();
|
||||
} else
|
||||
internal_hide();
|
||||
|
@ -457,24 +452,24 @@ void Basemenu::internal_hide(void) {
|
|||
tmp->submenu()->internal_hide();
|
||||
}
|
||||
|
||||
if (parent && (! torn)) {
|
||||
parent->drawItem(parent->which_sub, False, True);
|
||||
if (m_parent && (! torn)) {
|
||||
m_parent->drawItem(m_parent->which_sub, False, True);
|
||||
|
||||
parent->which_sub = -1;
|
||||
m_parent->which_sub = -1;
|
||||
} else if (shown && shown->menu.window == menu.window)
|
||||
shown = (Basemenu *) 0;
|
||||
|
||||
torn = visible = False;
|
||||
which_sub = which_press = which_sub = -1;
|
||||
|
||||
XUnmapWindow(display, menu.window);
|
||||
XUnmapWindow(m_display, menu.window);
|
||||
}
|
||||
|
||||
|
||||
void Basemenu::move(int x, int y) {
|
||||
menu.x = x;
|
||||
menu.y = y;
|
||||
XMoveWindow(display, menu.window, x, y);
|
||||
XMoveWindow(m_display, menu.window, x, y);
|
||||
if (which_sub != -1)
|
||||
drawSubmenu(which_sub);
|
||||
}
|
||||
|
@ -482,19 +477,19 @@ void Basemenu::move(int x, int y) {
|
|||
|
||||
void Basemenu::redrawTitle(void) {
|
||||
I18n *i18n = I18n::instance();
|
||||
char *text = (char *) ((menu.label) ? menu.label :
|
||||
const char *text = menu.label.size() ? menu.label.c_str() :
|
||||
i18n->getMessage(
|
||||
FBNLS::BasemenuSet, FBNLS::BasemenuBlackboxMenu,
|
||||
"fluxbox Menu"));
|
||||
"fluxbox Menu");
|
||||
int dx = menu.bevel_w, len = strlen(text);
|
||||
unsigned int l;
|
||||
|
||||
l = screen->getMenuStyle()->titlefont->getTextWidth(text, len);
|
||||
l = m_screen->getMenuStyle()->titlefont->getTextWidth(text, len);
|
||||
|
||||
l += (menu.bevel_w * 2);
|
||||
|
||||
//titlefont.justify
|
||||
switch (screen->getMenuStyle()->titlefont_justify) {
|
||||
switch (m_screen->getMenuStyle()->titlefont_justify) {
|
||||
case DrawUtil::Font::RIGHT:
|
||||
dx += menu.width - l;
|
||||
break;
|
||||
|
@ -507,13 +502,13 @@ void Basemenu::redrawTitle(void) {
|
|||
}
|
||||
|
||||
if (i18n->multibyte())
|
||||
XmbDrawString(display, menu.title, screen->getMenuStyle()->titlefont->getFontSet(),
|
||||
screen->getMenuStyle()->t_text_gc, dx, menu.bevel_w -
|
||||
screen->getMenuStyle()->titlefont->getFontSetExtents()->max_ink_extent.y,
|
||||
XmbDrawString(m_display, menu.title, m_screen->getMenuStyle()->titlefont->getFontSet(),
|
||||
m_screen->getMenuStyle()->t_text_gc, dx, menu.bevel_w -
|
||||
m_screen->getMenuStyle()->titlefont->getFontSetExtents()->max_ink_extent.y,
|
||||
text, len);
|
||||
else
|
||||
XDrawString(display, menu.title, screen->getMenuStyle()->t_text_gc, dx,
|
||||
screen->getMenuStyle()->titlefont->getFontStruct()->ascent + menu.bevel_w,
|
||||
XDrawString(m_display, menu.title, m_screen->getMenuStyle()->t_text_gc, dx,
|
||||
m_screen->getMenuStyle()->titlefont->getFontStruct()->ascent + menu.bevel_w,
|
||||
text, len);
|
||||
}
|
||||
|
||||
|
@ -532,27 +527,27 @@ void Basemenu::drawSubmenu(unsigned int index) {
|
|||
if (item->submenu() && visible && (! item->submenu()->isTorn()) &&
|
||||
item->isEnabled()) {
|
||||
|
||||
if (item->submenu()->parent != this)
|
||||
item->submenu()->parent = this;
|
||||
if (item->submenu()->m_parent != this)
|
||||
item->submenu()->m_parent = this;
|
||||
|
||||
int sbl = index / menu.persub, i = index - (sbl * menu.persub),
|
||||
x = menu.x +
|
||||
((menu.item_w * (sbl + 1)) + screen->getBorderWidth()), y;
|
||||
((menu.item_w * (sbl + 1)) + m_screen->getBorderWidth()), y;
|
||||
|
||||
if (alignment == ALIGNTOP) {
|
||||
if (m_alignment == ALIGNTOP) {
|
||||
y = (((shifted) ? menu.y_shift : menu.y) +
|
||||
((title_vis) ? menu.title_h + screen->getBorderWidth() : 0) -
|
||||
((title_vis) ? menu.title_h + m_screen->getBorderWidth() : 0) -
|
||||
((item->submenu()->title_vis) ?
|
||||
item->submenu()->menu.title_h + screen->getBorderWidth() : 0));
|
||||
item->submenu()->menu.title_h + m_screen->getBorderWidth() : 0));
|
||||
} else {
|
||||
y = (((shifted) ? menu.y_shift : menu.y) +
|
||||
(menu.item_h * i) +
|
||||
((title_vis) ? menu.title_h + screen->getBorderWidth() : 0) -
|
||||
((title_vis) ? menu.title_h + m_screen->getBorderWidth() : 0) -
|
||||
((item->submenu()->title_vis) ?
|
||||
item->submenu()->menu.title_h + screen->getBorderWidth() : 0));
|
||||
item->submenu()->menu.title_h + m_screen->getBorderWidth() : 0));
|
||||
}
|
||||
|
||||
if (alignment == ALIGNBOTTOM &&
|
||||
if (m_alignment == ALIGNBOTTOM &&
|
||||
(y + item->submenu()->menu.height) > ((shifted) ? menu.y_shift :
|
||||
menu.y) + menu.height) {
|
||||
y = (((shifted) ? menu.y_shift : menu.y) +
|
||||
|
@ -566,45 +561,45 @@ void Basemenu::drawSubmenu(unsigned int index) {
|
|||
head_h;
|
||||
|
||||
unsigned int head = 0;
|
||||
if (screen->hasXinerama()) {
|
||||
head = screen->getHead(menu.x, menu.y);
|
||||
head_x = screen->getHeadX(head);
|
||||
head_y = screen->getHeadY(head);
|
||||
head_w = screen->getHeadWidth(head);
|
||||
head_h = screen->getHeadHeight(head);
|
||||
if (m_screen->hasXinerama()) {
|
||||
head = m_screen->getHead(menu.x, menu.y);
|
||||
head_x = m_screen->getHeadX(head);
|
||||
head_y = m_screen->getHeadY(head);
|
||||
head_w = m_screen->getHeadWidth(head);
|
||||
head_h = m_screen->getHeadHeight(head);
|
||||
} else {
|
||||
head_w = screen->getWidth();
|
||||
head_h = screen->getHeight();
|
||||
head_w = m_screen->getWidth();
|
||||
head_h = m_screen->getHeight();
|
||||
}
|
||||
|
||||
if (static_cast<int>(x + item->submenu()->getWidth()) > static_cast<int>(head_x + head_w)) {
|
||||
if (static_cast<int>(x + item->submenu()->width()) > static_cast<int>(head_x + head_w)) {
|
||||
x = ((shifted) ? menu.x_shift : menu.x) -
|
||||
item->submenu()->getWidth() - screen->getBorderWidth();
|
||||
item->submenu()->width() - m_screen->getBorderWidth();
|
||||
}
|
||||
|
||||
if (x < head_x)
|
||||
x = head_x;
|
||||
|
||||
if (static_cast<int>(y + item->submenu()->getHeight()) > static_cast<int>(head_y + head_h)) {
|
||||
if (static_cast<int>(y + item->submenu()->height()) > static_cast<int>(head_y + head_h)) {
|
||||
y = head_y + head_h -
|
||||
item->submenu()->getHeight() - screen->getBorderWidth2x();
|
||||
item->submenu()->height() - m_screen->getBorderWidth2x();
|
||||
}
|
||||
|
||||
if (y < head_y)
|
||||
y = head_y;
|
||||
#else // !XINERAMA
|
||||
|
||||
if ((x + item->submenu()->getWidth()) > screen->getWidth()) {
|
||||
if ((x + item->submenu()->width()) > m_screen->width()) {
|
||||
x = ((shifted) ? menu.x_shift : menu.x) -
|
||||
item->submenu()->getWidth() - screen->getBorderWidth();
|
||||
item->submenu()->width() - m_screen->getBorderWidth();
|
||||
}
|
||||
|
||||
if (x < 0)
|
||||
x = 0;
|
||||
|
||||
if ((y + item->submenu()->getHeight()) > screen->getHeight()) {
|
||||
y = screen->getHeight() - item->submenu()->getHeight() -
|
||||
screen->getBorderWidth2x();
|
||||
if ((y + item->submenu()->getHeight()) > m_screen->getHeight()) {
|
||||
y = m_screen->getHeight() - item->submenu()->getHeight() -
|
||||
m_screen->getBorderWidth2x();
|
||||
}
|
||||
|
||||
if (y < 0)
|
||||
|
@ -626,14 +621,14 @@ void Basemenu::drawSubmenu(unsigned int index) {
|
|||
}
|
||||
|
||||
|
||||
bool Basemenu::hasSubmenu(unsigned int index) {
|
||||
if (index < menuitems.size())
|
||||
if (menuitems[index]->submenu())
|
||||
bool Basemenu::hasSubmenu(unsigned int index) const {
|
||||
if (index >= menuitems.size()) //boundary check
|
||||
return false;
|
||||
|
||||
if (!menuitems[index]->submenu()) //has submenu?
|
||||
return false;
|
||||
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -646,7 +641,7 @@ void Basemenu::drawItem(unsigned int index, bool highlight, bool clear,
|
|||
if (! item) return;
|
||||
|
||||
bool dotext = true, dohilite = true, dosel = true;
|
||||
const char *text = item->label();
|
||||
const char *text = item->label().c_str();
|
||||
int sbl = index / menu.persub, i = index - (sbl * menu.persub);
|
||||
int item_x = (sbl * menu.item_w), item_y = (i * menu.item_h);
|
||||
int hilite_x = item_x, hilite_y = item_y, hoff_x = 0, hoff_y = 0;
|
||||
|
@ -657,19 +652,19 @@ void Basemenu::drawItem(unsigned int index, bool highlight, bool clear,
|
|||
I18n *i18n = I18n::instance();
|
||||
|
||||
if (text) {
|
||||
text_w = screen->getMenuStyle()->framefont->getTextWidth(text, len);
|
||||
text_w = m_screen->getMenuStyle()->framefont->getTextWidth(text, len);
|
||||
|
||||
if (screen->getMenuStyle()->framefont->multibyte()) {
|
||||
if (m_screen->getMenuStyle()->framefont->multibyte()) {
|
||||
text_y = item_y + (menu.bevel_w / 2) -
|
||||
screen->getMenuStyle()->framefont->getFontSetExtents()->max_ink_extent.y;
|
||||
m_screen->getMenuStyle()->framefont->getFontSetExtents()->max_ink_extent.y;
|
||||
} else {
|
||||
text_y = item_y +
|
||||
screen->getMenuStyle()->framefont->getFontStruct()->ascent +
|
||||
m_screen->getMenuStyle()->framefont->getFontStruct()->ascent +
|
||||
(menu.bevel_w / 2);
|
||||
}
|
||||
|
||||
// framfont.justify
|
||||
switch(screen->getMenuStyle()->framefont_justify) {
|
||||
switch(m_screen->getMenuStyle()->framefont_justify) {
|
||||
case DrawUtil::Font::LEFT:
|
||||
text_x = item_x + menu.bevel_w + menu.item_h + 1;
|
||||
break;
|
||||
|
@ -686,23 +681,23 @@ void Basemenu::drawItem(unsigned int index, bool highlight, bool clear,
|
|||
}
|
||||
|
||||
GC gc =
|
||||
((highlight || item->isSelected()) ? screen->getMenuStyle()->h_text_gc :
|
||||
screen->getMenuStyle()->f_text_gc),
|
||||
((highlight || item->isSelected()) ? m_screen->getMenuStyle()->h_text_gc :
|
||||
m_screen->getMenuStyle()->f_text_gc),
|
||||
tgc =
|
||||
((highlight) ? screen->getMenuStyle()->h_text_gc :
|
||||
((item->isEnabled()) ? screen->getMenuStyle()->f_text_gc :
|
||||
screen->getMenuStyle()->d_text_gc));
|
||||
((highlight) ? m_screen->getMenuStyle()->h_text_gc :
|
||||
((item->isEnabled()) ? m_screen->getMenuStyle()->f_text_gc :
|
||||
m_screen->getMenuStyle()->d_text_gc));
|
||||
|
||||
sel_x = item_x;
|
||||
|
||||
if (screen->getMenuStyle()->bullet_pos == RIGHT)
|
||||
if (m_screen->getMenuStyle()->bullet_pos == RIGHT)
|
||||
sel_x += (menu.item_w - menu.item_h - menu.bevel_w);
|
||||
|
||||
sel_x += quarter_w;
|
||||
sel_y = item_y + quarter_w;
|
||||
|
||||
if (clear) {
|
||||
XClearArea(display, menu.frame, item_x, item_y, menu.item_w, menu.item_h,
|
||||
XClearArea(m_display, menu.frame, item_x, item_y, menu.item_w, menu.item_h,
|
||||
False);
|
||||
} else if (! (x == y && y == -1 && w == h && h == 0)) {
|
||||
// calculate the which part of the hilite to redraw
|
||||
|
@ -733,45 +728,45 @@ void Basemenu::drawItem(unsigned int index, bool highlight, bool clear,
|
|||
|
||||
if (dohilite && highlight && (menu.hilite_pixmap != ParentRelative)) {
|
||||
if (menu.hilite_pixmap) {
|
||||
XCopyArea(display, menu.hilite_pixmap, menu.frame,
|
||||
screen->getMenuStyle()->hilite_gc, hoff_x, hoff_y,
|
||||
XCopyArea(m_display, menu.hilite_pixmap, menu.frame,
|
||||
m_screen->getMenuStyle()->hilite_gc, hoff_x, hoff_y,
|
||||
hilite_w, hilite_h, hilite_x, hilite_y);
|
||||
} else {
|
||||
XFillRectangle(display, menu.frame,
|
||||
screen->getMenuStyle()->hilite_gc,
|
||||
XFillRectangle(m_display, menu.frame,
|
||||
m_screen->getMenuStyle()->hilite_gc,
|
||||
hilite_x, hilite_y, hilite_w, hilite_h);
|
||||
}
|
||||
} else if (dosel && item->isSelected() &&
|
||||
(menu.sel_pixmap != ParentRelative)) {
|
||||
if (menu.sel_pixmap) {
|
||||
XCopyArea(display, menu.sel_pixmap, menu.frame,
|
||||
screen->getMenuStyle()->hilite_gc, 0, 0,
|
||||
XCopyArea(m_display, menu.sel_pixmap, menu.frame,
|
||||
m_screen->getMenuStyle()->hilite_gc, 0, 0,
|
||||
half_w, half_w, sel_x, sel_y);
|
||||
} else {
|
||||
XFillRectangle(display, menu.frame,
|
||||
screen->getMenuStyle()->hilite_gc,
|
||||
XFillRectangle(m_display, menu.frame,
|
||||
m_screen->getMenuStyle()->hilite_gc,
|
||||
sel_x, sel_y, half_w, half_w);
|
||||
}
|
||||
}
|
||||
|
||||
if (dotext && text) {
|
||||
if (i18n->multibyte()) {
|
||||
XmbDrawString(display, menu.frame, screen->getMenuStyle()->framefont->getFontSet(),
|
||||
XmbDrawString(m_display, menu.frame, m_screen->getMenuStyle()->framefont->getFontSet(),
|
||||
tgc, text_x, text_y, text, len);
|
||||
} else
|
||||
XDrawString(display, menu.frame, tgc, text_x, text_y, text, len);
|
||||
XDrawString(m_display, menu.frame, tgc, text_x, text_y, text, len);
|
||||
}
|
||||
|
||||
if (dosel && item->submenu()) {
|
||||
switch (screen->getMenuStyle()->bullet) {
|
||||
switch (m_screen->getMenuStyle()->bullet) {
|
||||
case SQUARE:
|
||||
XDrawRectangle(display, menu.frame, gc, sel_x, sel_y, half_w, half_w);
|
||||
XDrawRectangle(m_display, menu.frame, gc, sel_x, sel_y, half_w, half_w);
|
||||
break;
|
||||
|
||||
case TRIANGLE:
|
||||
XPoint tri[3];
|
||||
|
||||
if (screen->getMenuStyle()->bullet_pos == RIGHT) {
|
||||
if (m_screen->getMenuStyle()->bullet_pos == RIGHT) {
|
||||
tri[0].x = sel_x + quarter_w - 2;
|
||||
tri[0].y = sel_y + quarter_w - 2;
|
||||
tri[1].x = 4;
|
||||
|
@ -787,7 +782,7 @@ void Basemenu::drawItem(unsigned int index, bool highlight, bool clear,
|
|||
tri[2].y = -4;
|
||||
}
|
||||
|
||||
XFillPolygon(display, menu.frame, gc, tri, 3, Convex,
|
||||
XFillPolygon(m_display, menu.frame, gc, tri, 3, Convex,
|
||||
CoordModePrevious);
|
||||
break;
|
||||
|
||||
|
@ -803,7 +798,7 @@ void Basemenu::drawItem(unsigned int index, bool highlight, bool clear,
|
|||
dia[3].x = -3;
|
||||
dia[3].y = 3;
|
||||
|
||||
XFillPolygon(display, menu.frame, gc, dia, 4, Convex,
|
||||
XFillPolygon(m_display, menu.frame, gc, dia, 4, Convex,
|
||||
CoordModePrevious);
|
||||
break;
|
||||
}
|
||||
|
@ -812,11 +807,8 @@ void Basemenu::drawItem(unsigned int index, bool highlight, bool clear,
|
|||
|
||||
|
||||
void Basemenu::setLabel(const char *l) {
|
||||
if (menu.label)
|
||||
delete [] menu.label;
|
||||
|
||||
if (l) menu.label = StringUtil::strdup(l);
|
||||
else menu.label = 0;
|
||||
//we don't want 0 to std::string
|
||||
menu.label = l ? l : "";
|
||||
}
|
||||
|
||||
|
||||
|
@ -831,7 +823,7 @@ void Basemenu::setItemSelected(unsigned int index, bool sel) {
|
|||
}
|
||||
|
||||
|
||||
bool Basemenu::isItemSelected(unsigned int index) {
|
||||
bool Basemenu::isItemSelected(unsigned int index) const{
|
||||
if (index >= menuitems.size()) return false;
|
||||
|
||||
BasemenuItem *item = find(index);
|
||||
|
@ -852,11 +844,11 @@ void Basemenu::setItemEnabled(unsigned int index, bool enable) {
|
|||
}
|
||||
|
||||
|
||||
bool Basemenu::isItemEnabled(unsigned int index) {
|
||||
if (index < 0 || index >= menuitems.size()) return False;
|
||||
bool Basemenu::isItemEnabled(unsigned int index) const {
|
||||
if (index >= menuitems.size()) return false;
|
||||
|
||||
BasemenuItem *item = find(index);
|
||||
if (! item) return False;
|
||||
if (! item) return false;
|
||||
|
||||
return item->isEnabled();
|
||||
}
|
||||
|
@ -930,9 +922,9 @@ void Basemenu::motionNotifyEvent(XMotionEvent *me) {
|
|||
if (me->window == menu.title && (me->state & Button1Mask)) {
|
||||
if (movable) {
|
||||
if (! moving) {
|
||||
if (parent && (! torn)) {
|
||||
parent->drawItem(parent->which_sub, False, True);
|
||||
parent->which_sub = -1;
|
||||
if (m_parent && (! torn)) {
|
||||
m_parent->drawItem(m_parent->which_sub, False, True);
|
||||
m_parent->which_sub = -1;
|
||||
}
|
||||
|
||||
moving = torn = True;
|
||||
|
@ -943,7 +935,7 @@ void Basemenu::motionNotifyEvent(XMotionEvent *me) {
|
|||
menu.x = me->x_root - menu.x_move,
|
||||
menu.y = me->y_root - menu.y_move;
|
||||
|
||||
XMoveWindow(display, menu.window, menu.x, menu.y);
|
||||
XMoveWindow(m_display, menu.window, menu.x, menu.y);
|
||||
|
||||
if (which_sub >= 0)
|
||||
drawSubmenu(which_sub);
|
||||
|
@ -1023,27 +1015,27 @@ void Basemenu::exposeEvent(XExposeEvent *ee) {
|
|||
|
||||
void Basemenu::enterNotifyEvent(XCrossingEvent *ce) {
|
||||
#ifdef XINERAMA
|
||||
int head = screen->hasXinerama() ? screen->getCurrHead() : 0;
|
||||
int head = m_screen->hasXinerama() ? m_screen->getCurrHead() : 0;
|
||||
|
||||
if (ce->window == menu.frame) {
|
||||
menu.x_shift = menu.x, menu.y_shift = menu.y;
|
||||
if (menu.x + menu.width >
|
||||
(screen->getHeadX(head) + screen->getHeadWidth(head))) {
|
||||
menu.x_shift = screen->getHeadX(head) + screen->getHeadWidth(head) -
|
||||
menu.width - screen->getBorderWidth2x();
|
||||
(m_screen->getHeadX(head) + m_screen->getHeadWidth(head))) {
|
||||
menu.x_shift = m_screen->getHeadX(head) + m_screen->getHeadWidth(head) -
|
||||
menu.width - m_screen->getBorderWidth2x();
|
||||
shifted = True;
|
||||
} else if (menu.x < screen->getHeadX(head)) {
|
||||
menu.x_shift = screen->getHeadX(head);
|
||||
} else if (menu.x < m_screen->getHeadX(head)) {
|
||||
menu.x_shift = m_screen->getHeadX(head);
|
||||
shifted = True;
|
||||
}
|
||||
|
||||
if (menu.y + menu.height >
|
||||
(screen->getHeadY(head) + screen->getHeadHeight(head))) {
|
||||
menu.y_shift = screen->getHeadY(head) + screen->getHeadHeight(head) -
|
||||
menu.height - screen->getBorderWidth2x();
|
||||
(m_screen->getHeadY(head) + m_screen->getHeadHeight(head))) {
|
||||
menu.y_shift = m_screen->getHeadY(head) + m_screen->getHeadHeight(head) -
|
||||
menu.height - m_screen->getBorderWidth2x();
|
||||
shifted = True;
|
||||
} else if (menu.y + (signed) menu.title_h < screen->getHeadY(head)) {
|
||||
menu.y_shift = screen->getHeadY(head);
|
||||
} else if (menu.y + (signed) menu.title_h < m_screen->getHeadY(head)) {
|
||||
menu.y_shift = m_screen->getHeadY(head);
|
||||
shifted = True;
|
||||
}
|
||||
|
||||
|
@ -1051,21 +1043,21 @@ void Basemenu::enterNotifyEvent(XCrossingEvent *ce) {
|
|||
|
||||
if (ce->window == menu.frame) {
|
||||
menu.x_shift = menu.x, menu.y_shift = menu.y;
|
||||
if (menu.x + menu.width > screen->getWidth()) {
|
||||
menu.x_shift = screen->getWidth() - menu.width -
|
||||
screen->getBorderWidth();
|
||||
if (menu.x + menu.width > m_screen->getWidth()) {
|
||||
menu.x_shift = m_screen->getWidth() - menu.width -
|
||||
m_screen->getBorderWidth();
|
||||
shifted = True;
|
||||
} else if (menu.x < 0) {
|
||||
menu.x_shift = -screen->getBorderWidth();
|
||||
menu.x_shift = -m_screen->getBorderWidth();
|
||||
shifted = True;
|
||||
}
|
||||
|
||||
if (menu.y + menu.height > screen->getHeight()) {
|
||||
menu.y_shift = screen->getHeight() - menu.height -
|
||||
screen->getBorderWidth();
|
||||
if (menu.y + menu.height > m_screen->getHeight()) {
|
||||
menu.y_shift = m_screen->getHeight() - menu.height -
|
||||
m_screen->getBorderWidth();
|
||||
shifted = True;
|
||||
} else if (menu.y + (signed) menu.title_h < 0) {
|
||||
menu.y_shift = -screen->getBorderWidth();
|
||||
menu.y_shift = -m_screen->getBorderWidth();
|
||||
shifted = True;
|
||||
}
|
||||
|
||||
|
@ -1076,7 +1068,7 @@ void Basemenu::enterNotifyEvent(XCrossingEvent *ce) {
|
|||
menu.x = menu.x_shift; // need to do this to avoid jumping beetween heads
|
||||
menu.y = menu.y_shift;
|
||||
#endif // XINERAMA
|
||||
XMoveWindow(display, menu.window, menu.x_shift, menu.y_shift);
|
||||
XMoveWindow(m_display, menu.window, menu.x_shift, menu.y_shift);
|
||||
}
|
||||
|
||||
if (which_sub >= 0) {
|
||||
|
@ -1108,7 +1100,7 @@ void Basemenu::leaveNotifyEvent(XCrossingEvent *ce) {
|
|||
}
|
||||
|
||||
if (shifted) {
|
||||
XMoveWindow(display, menu.window, menu.x, menu.y);
|
||||
XMoveWindow(m_display, menu.window, menu.x, menu.y);
|
||||
shifted = False;
|
||||
|
||||
if (which_sub >= 0) drawSubmenu(which_sub);
|
||||
|
@ -1118,12 +1110,12 @@ void Basemenu::leaveNotifyEvent(XCrossingEvent *ce) {
|
|||
|
||||
|
||||
void Basemenu::reconfigure(void) {
|
||||
XSetWindowBackground(display, menu.window,
|
||||
screen->getBorderColor()->getPixel());
|
||||
XSetWindowBorder(display, menu.window,
|
||||
screen->getBorderColor()->getPixel());
|
||||
XSetWindowBorderWidth(display, menu.window, screen->getBorderWidth());
|
||||
XSetWindowBackground(m_display, menu.window,
|
||||
m_screen->getBorderColor()->getPixel());
|
||||
XSetWindowBorder(m_display, menu.window,
|
||||
m_screen->getBorderColor()->getPixel());
|
||||
XSetWindowBorderWidth(m_display, menu.window, m_screen->getBorderWidth());
|
||||
|
||||
menu.bevel_w = screen->getBevelWidth();
|
||||
menu.bevel_w = m_screen->getBevelWidth();
|
||||
update();
|
||||
}
|
||||
|
|
114
src/Basemenu.hh
114
src/Basemenu.hh
|
@ -22,7 +22,7 @@
|
|||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
|
||||
// $Id: Basemenu.hh,v 1.11 2002/04/03 23:08:19 fluxgen Exp $
|
||||
// $Id: Basemenu.hh,v 1.12 2002/04/08 22:37:49 fluxgen Exp $
|
||||
|
||||
#ifndef BASEMENU_HH
|
||||
#define BASEMENU_HH
|
||||
|
@ -31,90 +31,82 @@
|
|||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
// forward declarations
|
||||
class Basemenu;
|
||||
class BasemenuItem;
|
||||
|
||||
class Fluxbox;
|
||||
class BImageControl;
|
||||
class BScreen;
|
||||
|
||||
class Basemenu {
|
||||
public:
|
||||
explicit Basemenu(BScreen *);
|
||||
virtual ~Basemenu(void);
|
||||
enum Alignment{ ALIGNDONTCARE = 1, ALIGNTOP, ALIGNBOTTOM };
|
||||
enum { RIGHT = 1, LEFT };
|
||||
enum { EMPTY = 0, SQUARE, TRIANGLE, DIAMOND };
|
||||
|
||||
inline const Bool &isTorn(void) const { return torn; }
|
||||
inline const Bool &isVisible(void) const { return visible; }
|
||||
explicit Basemenu(BScreen *screen);
|
||||
virtual ~Basemenu();
|
||||
|
||||
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 * = 0, int = -1);
|
||||
|
||||
int insert(const char *, Basemenu *, int = -1);
|
||||
//manipulators
|
||||
int insert(const char *label, int function= 0, const char *exec = 0, int pos = -1);
|
||||
int insert(const char *label, Basemenu *submenu, int pos= -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);
|
||||
|
||||
inline void setInternalMenu() { internal_menu = true; }
|
||||
inline void setAlignment(Alignment a) { m_alignment = a; }
|
||||
inline void setTorn() { torn = true; }
|
||||
inline void removeParent() { if (internal_menu) m_parent = 0; }
|
||||
void buttonPressEvent(XButtonEvent *);
|
||||
void buttonReleaseEvent(XButtonEvent *);
|
||||
void motionNotifyEvent(XMotionEvent *);
|
||||
void enterNotifyEvent(XCrossingEvent *);
|
||||
void leaveNotifyEvent(XCrossingEvent *);
|
||||
void exposeEvent(XExposeEvent *);
|
||||
void reconfigure(void);
|
||||
void reconfigure();
|
||||
void setLabel(const char *n);
|
||||
void move(int, int);
|
||||
void update(void);
|
||||
void move(int x, int y);
|
||||
void update();
|
||||
void setItemSelected(unsigned int index, bool val);
|
||||
void setItemEnabled(unsigned int, bool val);
|
||||
|
||||
void setItemEnabled(unsigned int index, bool val);
|
||||
virtual void drawSubmenu(unsigned int index);
|
||||
virtual void show(void);
|
||||
virtual void hide(void);
|
||||
virtual void show();
|
||||
virtual void hide();
|
||||
|
||||
enum { ALIGNDONTCARE = 1, ALIGNTOP, ALIGNBOTTOM };
|
||||
enum { RIGHT = 1, LEFT };
|
||||
enum { EMPTY = 0, SQUARE, TRIANGLE, DIAMOND };
|
||||
//accessors
|
||||
inline bool isTorn() const { return torn; }
|
||||
inline bool isVisible() const { return visible; }
|
||||
inline BScreen *screen() const { return m_screen; }
|
||||
inline const Window windowID() const { return menu.window; }
|
||||
inline const std::string &label() const { return menu.label; }
|
||||
inline int x() const { return menu.x; }
|
||||
inline int y() const { return menu.y; }
|
||||
inline unsigned int width() const { return menu.width; }
|
||||
inline unsigned int height() const { return menu.height; }
|
||||
inline unsigned int numberOfItems() const { return menuitems.size(); }
|
||||
inline int currentSubmenu() const { return which_sub; }
|
||||
inline unsigned int titleHeight() const { return menu.title_h; }
|
||||
bool hasSubmenu(unsigned int index) const;
|
||||
bool isItemSelected(unsigned int index) const;
|
||||
bool isItemEnabled(unsigned int index) const;
|
||||
|
||||
private:
|
||||
typedef std::vector<BasemenuItem *> Menuitems;
|
||||
Fluxbox *m_fluxbox;
|
||||
BScreen *m_screen;
|
||||
Display *m_display;
|
||||
Basemenu *m_parent;
|
||||
BImageControl *m_image_ctrl;
|
||||
Menuitems menuitems;
|
||||
Fluxbox *fluxbox;
|
||||
Basemenu *parent;
|
||||
BImageControl *image_ctrl;
|
||||
BScreen *screen;
|
||||
|
||||
Bool moving, visible, movable, torn, internal_menu, title_vis, shifted,
|
||||
bool moving, visible, movable, torn, internal_menu, title_vis, shifted,
|
||||
hide_tree;
|
||||
Display *display;
|
||||
int which_sub, which_press, which_sbl, alignment;
|
||||
|
||||
int which_sub, which_press, which_sbl;
|
||||
Alignment m_alignment;
|
||||
|
||||
struct _menu {
|
||||
Pixmap frame_pixmap, title_pixmap, hilite_pixmap, sel_pixmap;
|
||||
Window window, frame, title;
|
||||
|
||||
char *label;
|
||||
std::string 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,
|
||||
|
@ -123,7 +115,7 @@ private:
|
|||
|
||||
|
||||
protected:
|
||||
inline BasemenuItem *find(unsigned int index) { return menuitems[index]; }
|
||||
inline BasemenuItem *find(unsigned int index) const { 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; }
|
||||
|
@ -133,7 +125,7 @@ protected:
|
|||
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);
|
||||
virtual void internal_hide();
|
||||
};
|
||||
|
||||
class BasemenuItem {
|
||||
|
@ -159,14 +151,14 @@ public:
|
|||
, m_selected(false)
|
||||
{ }
|
||||
|
||||
inline const char *exec(void) const { return m_exec.c_str(); }
|
||||
inline const char *label(void) const { return m_label.c_str(); }
|
||||
inline int function(void) const { return m_function; }
|
||||
inline Basemenu *submenu(void) { return m_submenu; }
|
||||
inline const std::string &exec() const { return m_exec; }
|
||||
inline const std::string &label() const { return m_label; }
|
||||
inline int function() const { return m_function; }
|
||||
inline Basemenu *submenu() const { return m_submenu; }
|
||||
|
||||
inline bool isEnabled(void) const { return m_enabled; }
|
||||
inline bool isEnabled() const { return m_enabled; }
|
||||
inline void setEnabled(bool enabled) { m_enabled = enabled; }
|
||||
inline bool isSelected(void) const { return m_selected; }
|
||||
inline bool isSelected() const { return m_selected; }
|
||||
inline void setSelected(bool selected) { m_selected = selected; }
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in a new issue