From 55b9d5ffb0c2fd52ff4bf3805840ca3ebf9083fa Mon Sep 17 00:00:00 2001 From: fluxgen Date: Sun, 12 Jan 2003 18:19:45 +0000 Subject: replaced by FbTk Menu --- src/Basemenu.cc | 1083 -------------------------------------------------- src/Basemenu.hh | 216 ---------- src/Windowmenu.cc | 303 -------------- src/Windowmenu.hh | 81 ---- src/Workspacemenu.cc | 79 ---- src/Workspacemenu.hh | 38 -- 6 files changed, 1800 deletions(-) delete mode 100644 src/Basemenu.cc delete mode 100644 src/Basemenu.hh delete mode 100644 src/Windowmenu.cc delete mode 100644 src/Windowmenu.hh delete mode 100644 src/Workspacemenu.cc delete mode 100644 src/Workspacemenu.hh diff --git a/src/Basemenu.cc b/src/Basemenu.cc deleted file mode 100644 index 6a663b3..0000000 --- a/src/Basemenu.cc +++ /dev/null @@ -1,1083 +0,0 @@ -// Basemenu.cc for Fluxbox Window manager -// Copyright (c) 2001 - 2002 Henrik Kinnunen (fluxgen@linuxmail.org) -// -// Basemenu.cc for blackbox - an X11 Window manager -// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// 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.41 2003/01/09 21:58:59 fluxgen Exp $ - -//use GNU extensions -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif // _GNU_SOURCE - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif // HAVE_CONFIG_H - -#include "i18n.hh" -#include "fluxbox.hh" -#include "Basemenu.hh" -#include "Screen.hh" -#include "ImageControl.hh" -#include "StringUtil.hh" -#include "FbWindow.hh" -#include "EventManager.hh" - -#include -#include -#include - - -#ifdef DEBUG -#include -using namespace std; -#endif //DEBUG - -static Basemenu *shown = 0; - -Basemenu::Basemenu(BScreen *screen): - m_screen(screen), - m_display(Fluxbox::instance()->getXDisplay()), - m_parent(0), - m_image_ctrl(screen->getImageControl()), - m_alignment(ALIGNDONTCARE) { - - title_vis = - movable = - hide_tree = true; - - shifted = - internal_menu = - moving = - torn = - visible = false; - - menu.x = - menu.y = - menu.x_shift = - menu.y_shift = - menu.x_move = - menu.y_move = 0; - - which_sub = - which_press = - which_sbl = -1; - - menu.frame_pixmap = - menu.title_pixmap = - menu.hilite_pixmap = - menu.sel_pixmap = None; - - menu.bevel_w = m_screen->getBevelWidth(); - - menu.width = menu.title_h = menu.item_w = menu.frame_h = - m_screen->getMenuStyle()->titlefont.height() + menu.bevel_w * 2; - - menu.sublevels = - menu.persub = - menu.minsub = 0; - - menu.item_h = m_screen->getMenuStyle()->framefont.height() + menu.bevel_w; - - menu.height = menu.title_h + m_screen->getBorderWidth() + menu.frame_h; - - //set attributes for menu window - unsigned long attrib_mask = CWBackPixmap | CWBackPixel | CWBorderPixel | - CWColormap | CWOverrideRedirect | CWEventMask; - XSetWindowAttributes attrib; - attrib.background_pixmap = None; - attrib.background_pixel = attrib.border_pixel = - m_screen->getBorderColor()->pixel(); - attrib.colormap = m_screen->colormap(); - attrib.override_redirect = True; - attrib.event_mask = ButtonPressMask | ButtonReleaseMask | - ButtonMotionMask | ExposureMask; - - //create menu window - menu.window = 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); - - FbTk::EventManager &evm = *FbTk::EventManager::instance(); - evm.add(*this, menu.window); - - //attibutes for title to menuwindow - attrib_mask = CWBackPixmap | CWBackPixel | CWBorderPixel | CWEventMask; - attrib.background_pixel = m_screen->getBorderColor()->pixel(); - attrib.event_mask |= EnterWindowMask | LeaveWindowMask; - //create menu title - menu.title = - XCreateWindow(m_display, menu.window.window(), 0, 0, menu.width, menu.height, 0, - m_screen->getDepth(), InputOutput, m_screen->getVisual(), - attrib_mask, &attrib); - evm.add(*this, menu.title); - - attrib.event_mask |= PointerMotionMask; - menu.frame = XCreateWindow(m_display, menu.window.window(), 0, - menu.title_h + m_screen->getBorderWidth(), - menu.width, menu.frame_h, 0, - m_screen->getDepth(), InputOutput, - m_screen->getVisual(), attrib_mask, &attrib); - evm.add(*this, menu.frame); -} - - -Basemenu::~Basemenu() { - menu.window.hide(); - - 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.title_pixmap) - m_image_ctrl->removeImage(menu.title_pixmap); - - if (menu.frame_pixmap) - m_image_ctrl->removeImage(menu.frame_pixmap); - - if (menu.hilite_pixmap) - m_image_ctrl->removeImage(menu.hilite_pixmap); - - if (menu.sel_pixmap) - m_image_ctrl->removeImage(menu.sel_pixmap); - - FbTk::EventManager &evm = *FbTk::EventManager::instance(); - evm.remove(menu.title); - evm.remove(menu.frame); - evm.remove(menu.window); - -} - - -int Basemenu::insert(const char *label, int function, const char *exec, int pos) { - BasemenuItem *item = new BasemenuItem(label, function, exec); - if (pos == -1) { - menuitems.push_back(item); - } else { - menuitems.insert(menuitems.begin() + pos, item); - } - - return menuitems.size(); -} - - -int Basemenu::insert(const char *label, Basemenu *submenu, int pos) { - BasemenuItem *item = new BasemenuItem(label, submenu); - if (pos == -1) { - menuitems.push_back(item); - } else { - menuitems.insert(menuitems.begin() + pos, item); - } - - submenu->m_parent = this; - - return 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() - << " inclusive." << std::endl; -#endif // DEBUG - return -1; - } - - Menuitems::iterator it = menuitems.begin() + index; - BasemenuItem *item = (*it); - - if (item) { - menuitems.erase(it); - if ((! internal_menu) && (item->submenu())) { - Basemenu *tmp = (Basemenu *) item->submenu(); - - if (! tmp->internal_menu) { - delete tmp; - } else - tmp->internal_hide(); - } - - delete item; - } - - if (static_cast(which_sub) == index) - which_sub = -1; - else if (static_cast(which_sub) > index) - which_sub--; - - return menuitems.size(); -} - -void Basemenu::raise() { - menu.window.raise(); -} - -void Basemenu::lower() { - menu.window.lower(); -} - -void Basemenu::update() { - I18n *i18n = I18n::instance(); - - menu.item_h = m_screen->getMenuStyle()->framefont.height() + menu.bevel_w; - menu.title_h = m_screen->getMenuStyle()->framefont.height() + menu.bevel_w*2; - - if (title_vis) { - const char *s = (menu.label!="") ? menu.label.c_str() : - i18n->getMessage( - FBNLS::BasemenuSet, FBNLS::BasemenuBlackboxMenu, - "fluxbox Menu"); - int l = strlen(s); - - menu.item_w = m_screen->getMenuStyle()->titlefont.textWidth(s, l); - - menu.item_w += (menu.bevel_w * 2); - } else - menu.item_w = 1; - - int ii = 0; - Menuitems::iterator it = menuitems.begin(); - Menuitems::iterator it_end = menuitems.end(); - for (; it != it_end; ++it) { - BasemenuItem *itmp = (*it); - - const char *s = itmp->label().c_str(); - int l = itmp->label().size(); - - ii = screen()->getMenuStyle()->framefont.textWidth(s, l); - - - ii += (menu.bevel_w * 2) + (menu.item_h * 2); - - menu.item_w = ((menu.item_w < (unsigned int) ii) ? ii : menu.item_w); - } - - if (menuitems.size()) { - menu.sublevels = 1; - - 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; - - menu.persub = menuitems.size() / menu.sublevels; - if (menuitems.size() % menu.sublevels) menu.persub++; - } else { - menu.sublevels = 0; - menu.persub = 0; - } - - menu.width = (menu.sublevels * (menu.item_w)); - if (! menu.width) menu.width = menu.item_w; - - menu.frame_h = (menu.item_h * menu.persub); - 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; - - Pixmap tmp; - if (title_vis) { - tmp = menu.title_pixmap; - const FbTk::Texture &tex = m_screen->getMenuStyle()->title; - if (tex.type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { - menu.title_pixmap = None; - menu.title.setBackgroundColor(tex.color()); - } else { - menu.title_pixmap = - m_image_ctrl->renderImage(menu.width, menu.title_h, tex); - menu.title.setBackgroundPixmap(menu.title_pixmap); - } - - if (tmp) - m_image_ctrl->removeImage(tmp); - - menu.title.clear(); - } - - tmp = menu.frame_pixmap; - const FbTk::Texture &frame_tex = m_screen->getMenuStyle()->frame; - if (frame_tex.type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) { - menu.frame_pixmap = None; - menu.frame.setBackgroundColor(frame_tex.color()); - } else { - menu.frame_pixmap = - m_image_ctrl->renderImage(menu.width, menu.frame_h, frame_tex); - menu.frame.setBackgroundPixmap(menu.frame_pixmap); - } - - if (tmp) - m_image_ctrl->removeImage(tmp); - - tmp = menu.hilite_pixmap; - const FbTk::Texture &hilite_tex = m_screen->getMenuStyle()->hilite; - if (hilite_tex.type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) - menu.hilite_pixmap = None; - else - menu.hilite_pixmap = - m_image_ctrl->renderImage(menu.item_w, menu.item_h, hilite_tex); - if (tmp) - m_image_ctrl->removeImage(tmp); - - tmp = menu.sel_pixmap; - if (hilite_tex.type() == (FbTk::Texture::FLAT | FbTk::Texture::SOLID)) - menu.sel_pixmap = None; - else { - int hw = menu.item_h / 2; - menu.sel_pixmap = - m_image_ctrl->renderImage(hw, hw, hilite_tex); - } - if (tmp) - m_image_ctrl->removeImage(tmp); - - menu.window.resize(menu.width, menu.height); - - if (title_vis) - menu.title.resize(menu.width, menu.title_h); - - menu.frame.moveResize(0, - ((title_vis) ? menu.title_h + - m_screen->getBorderWidth() : 0), menu.width, - menu.frame_h); - menu.window.clear(); - menu.title.clear(); - menu.frame.clear(); - - if (title_vis && visible) - redrawTitle(); - - 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 (m_parent && visible) - m_parent->drawSubmenu(m_parent->which_sub); - - XMapSubwindows(m_display, menu.window.window()); -} - - -void Basemenu::show() { - XMapSubwindows(m_display, menu.window.window()); - menu.window.show(); - visible = True; - - if (! m_parent) { - if (shown && (! shown->torn)) - shown->hide(); - - shown = this; - } - -} - - -void Basemenu::hide() { - if ((! torn) && hide_tree && m_parent && m_parent->isVisible()) { - Basemenu *p = m_parent; - - while (p->isVisible() && (! p->torn) && p->m_parent) - p = p->m_parent; - p->internal_hide(); - } else - internal_hide(); -} - - -void Basemenu::internal_hide() { - if (which_sub >= 0) { - BasemenuItem *tmp = menuitems[which_sub]; - tmp->submenu()->internal_hide(); - } - - if (m_parent && (! torn)) { - m_parent->drawItem(m_parent->which_sub, False, True); - - 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; - - menu.window.hide(); -} - - -void Basemenu::move(int x, int y) { - menu.x = x; - menu.y = y; - menu.window.move(x, y); - - if (which_sub != -1) - drawSubmenu(which_sub); -} - - -void Basemenu::redrawTitle() { - I18n *i18n = I18n::instance(); - const char *text = menu.label.size() ? menu.label.c_str() : - i18n->getMessage( - FBNLS::BasemenuSet, FBNLS::BasemenuBlackboxMenu, - "fluxbox Menu"); - int dx = menu.bevel_w, len = strlen(text); - unsigned int l = m_screen->getMenuStyle()->titlefont.textWidth(text, len) + menu.bevel_w*2; - - switch (m_screen->getMenuStyle()->titlefont_justify) { - case DrawUtil::Font::RIGHT: - dx += menu.width - l; - break; - - case DrawUtil::Font::CENTER: - dx += (menu.width - l) / 2; - break; - default: - break; - } - - m_screen->getMenuStyle()->titlefont.drawText( - menu.title.window(), // drawable - m_screen->getScreenNumber(), - m_screen->getMenuStyle()->t_text_gc, // graphic context - text, len, // text string with lenght - dx, m_screen->getMenuStyle()->titlefont.ascent() + menu.bevel_w); // position - - -} - - -void Basemenu::drawSubmenu(unsigned int index) { - if (which_sub >= 0 && static_cast(which_sub) != index && - static_cast(which_sub) < menuitems.size()) { - BasemenuItem *itmp = menuitems[which_sub]; - - if (! itmp->submenu()->isTorn()) - itmp->submenu()->internal_hide(); - } - - if (index < menuitems.size()) { - BasemenuItem *item = menuitems[index]; - if (item->submenu() && visible && (! item->submenu()->isTorn()) && - item->isEnabled()) { - - 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)) + m_screen->getBorderWidth()), y; - - if (m_alignment == ALIGNTOP) { - y = (((shifted) ? menu.y_shift : menu.y) + - ((title_vis) ? menu.title_h + m_screen->getBorderWidth() : 0) - - ((item->submenu()->title_vis) ? - 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 + m_screen->getBorderWidth() : 0) - - ((item->submenu()->title_vis) ? - item->submenu()->menu.title_h + m_screen->getBorderWidth() : 0)); - } - - if (m_alignment == ALIGNBOTTOM && - (y + item->submenu()->menu.height) > ((shifted) ? menu.y_shift : - menu.y) + menu.height) { - y = (((shifted) ? menu.y_shift : menu.y) + - menu.height - item->submenu()->menu.height); - } - -#ifdef XINERAMA - int head_x = 0, - head_y = 0, - head_w, - head_h; - - unsigned int head = 0; - 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 = m_screen->getWidth(); - head_h = m_screen->getHeight(); - } - - if (static_cast(x + item->submenu()->width()) > static_cast(head_x + head_w)) { - x = ((shifted) ? menu.x_shift : menu.x) - - item->submenu()->width() - m_screen->getBorderWidth(); - } - - if (x < head_x) - x = head_x; - - if (static_cast(y + item->submenu()->height()) > static_cast(head_y + head_h)) { - y = head_y + head_h - - item->submenu()->height() - m_screen->getBorderWidth2x(); - } - - if (y < head_y) - y = head_y; -#else // !XINERAMA - - if ((x + item->submenu()->width()) > m_screen->getWidth()) { - x = ((shifted) ? menu.x_shift : menu.x) - - item->submenu()->width() - m_screen->getBorderWidth(); - } - - if (x < 0) - x = 0; - - if ((y + item->submenu()->height()) > m_screen->getHeight()) { - y = m_screen->getHeight() - item->submenu()->height() - - m_screen->getBorderWidth2x(); - } - - if (y < 0) - y = 0; -#endif // XINERAMA - - item->submenu()->move(x, y); - if (! moving) - drawItem(index, True); - - if (! item->submenu()->isVisible()) - item->submenu()->show(); - - item->submenu()->moving = moving; - which_sub = index; - } else - which_sub = -1; - } -} - - -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; -} - - -void Basemenu::drawItem(unsigned int index, bool highlight, bool clear, - int x, int y, unsigned int w, unsigned int h) -{ - if (index >= menuitems.size() || menuitems.size() == 0) - return; - - BasemenuItem *item = menuitems[index]; - if (! item) return; - - bool dotext = true, dohilite = true, dosel = true; - 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; - int text_x = 0, text_y = 0, len = strlen(text), sel_x = 0, sel_y = 0; - unsigned int hilite_w = menu.item_w, hilite_h = menu.item_h, text_w = 0, text_h = 0; - unsigned int half_w = menu.item_h / 2, quarter_w = menu.item_h / 4; - - if (text) { - text_w = m_screen->getMenuStyle()->framefont.textWidth(text, len); - - text_y = item_y + menu.bevel_w/2 + m_screen->getMenuStyle()->framefont.ascent(); - - switch(m_screen->getMenuStyle()->framefont_justify) { - case DrawUtil::Font::LEFT: - text_x = item_x + menu.bevel_w + menu.item_h + 1; - break; - - case DrawUtil::Font::RIGHT: - text_x = item_x + menu.item_w - (menu.item_h + menu.bevel_w + text_w); - break; - default: //center - text_x = item_x + ((menu.item_w + 1 - text_w) / 2); - break; - } - - text_h = menu.item_h - menu.bevel_w; - } - - GC gc = - ((highlight || item->isSelected()) ? m_screen->getMenuStyle()->h_text_gc : - m_screen->getMenuStyle()->f_text_gc), - tgc = - ((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 (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(m_display, menu.frame.window(), 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 - if (! (std::max(item_x, x) <= (signed) std::min(item_x + menu.item_w, x + w) && - std::max(item_y, y) <= (signed) std::min(item_y + menu.item_h, y + h))) { - dohilite = False; - } else { - hilite_x = std::max(item_x, x); - hilite_y = std::max(item_y, y); - hilite_w = std::min(item_x + menu.item_w, x + w) - hilite_x; - hilite_h = std::min(item_y + menu.item_h, y + h) - hilite_y; - hoff_x = hilite_x % menu.item_w; - hoff_y = hilite_y % menu.item_h; - } - - // check if we need to redraw the text - int text_ry = item_y + (menu.bevel_w / 2); - if (! (std::max(text_x, x) <= (signed) std::min(text_x + text_w, x + w) && - std::max(text_ry, y) <= (signed) std::min(text_ry + text_h, y + h))) - dotext = False; - - // check if we need to redraw the select pixmap/menu bullet - if (! (std::max(sel_x, x) <= (signed) std::min(sel_x + half_w, x + w) && - std::max(sel_y, y) <= (signed) std::min(sel_y + half_w, y + h))) - dosel = False; - - } - - if (dohilite && highlight && (menu.hilite_pixmap != ParentRelative)) { - if (menu.hilite_pixmap) { - XCopyArea(m_display, menu.hilite_pixmap, menu.frame.window(), - m_screen->getMenuStyle()->hilite_gc, hoff_x, hoff_y, - hilite_w, hilite_h, hilite_x, hilite_y); - } else { - XFillRectangle(m_display, menu.frame.window(), - m_screen->getMenuStyle()->hilite_gc, - hilite_x, hilite_y, hilite_w, hilite_h); - } - } - - if (dosel && item->isSelected() && - (menu.sel_pixmap != ParentRelative)) { - if (menu.sel_pixmap) { - XCopyArea(m_display, highlight ? menu.frame_pixmap : menu.sel_pixmap, menu.frame.window(), - m_screen->getMenuStyle()->hilite_gc, 0, 0, - half_w, half_w, sel_x, sel_y); - } else { - XFillRectangle(m_display, menu.frame.window(), - m_screen->getMenuStyle()->hilite_gc, - sel_x, sel_y, half_w, half_w); - } - } - - if (dotext && text) { - m_screen->getMenuStyle()->framefont.drawText( - menu.frame.window(), // drawable - m_screen->getScreenNumber(), - tgc, - text, len, // text string and lenght - text_x, text_y); // position - - } - - if (dosel && item->submenu()) { - switch (m_screen->getMenuStyle()->bullet) { - case SQUARE: - XDrawRectangle(m_display, menu.frame.window(), gc, sel_x, sel_y, half_w, half_w); - break; - - case TRIANGLE: - XPoint tri[3]; - - 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; - tri[1].y = 2; - tri[2].x = -4; - tri[2].y = 2; - } else { - tri[0].x = sel_x + quarter_w - 2; - tri[0].y = item_y + half_w; - tri[1].x = 4; - tri[1].y = 2; - tri[2].x = 0; - tri[2].y = -4; - } - - XFillPolygon(m_display, menu.frame.window(), gc, tri, 3, Convex, - CoordModePrevious); - break; - - case DIAMOND: - XPoint dia[4]; - - dia[0].x = sel_x + quarter_w - 3; - dia[0].y = item_y + half_w; - dia[1].x = 3; - dia[1].y = -3; - dia[2].x = 3; - dia[2].y = 3; - dia[3].x = -3; - dia[3].y = 3; - - XFillPolygon(m_display, menu.frame.window(), gc, dia, 4, Convex, - CoordModePrevious); - break; - } - } -} - - -void Basemenu::setLabel(const char *labelstr) { - //make sure we don't send 0 to std::string - menu.label = (labelstr ? labelstr : ""); -} - - -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 == (unsigned int)which_sub), true); -} - - -bool Basemenu::isItemSelected(unsigned int index) const{ - if (index >= menuitems.size()) return false; - - const BasemenuItem *item = find(index); - if (!item) - return false; - - return item->isSelected(); -} - - -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 == static_cast(which_sub)), True); -} - - -bool Basemenu::isItemEnabled(unsigned int index) const { - if (index >= menuitems.size()) return false; - - BasemenuItem *item = find(index); - if (!item) - return false; - - return item->isEnabled(); -} - - -void Basemenu::buttonPressEvent(XButtonEvent &be) { - 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 < static_cast(menuitems.size()) && w >= 0) { - which_press = i; - which_sbl = sbl; - - BasemenuItem *item = menuitems[w]; - - if (item->submenu()) - drawSubmenu(w); - else - drawItem(w, (item->isEnabled()), true); - } - } else { - menu.x_move = be.x_root - menu.x; - menu.y_move = be.y_root - menu.y; - } -} - - -void Basemenu::buttonReleaseEvent(XButtonEvent &re) { - if (re.window == menu.title) { - if (moving) { - moving = false; - - if (which_sub >= 0) - drawSubmenu(which_sub); - } - - if (re.x >= 0 && re.x <= (signed) menu.width && - re.y >= 0 && re.y <= (signed) menu.title_h && - re.button == 3) - hide(); - - } else if (re.window == menu.frame && - re.x >= 0 && re.x < (signed) menu.width && - re.y >= 0 && re.y < (signed) menu.frame_h) { - - if (re.button == 3) { - hide(); - } else { - int sbl = (re.x / menu.item_w), i = (re.y / menu.item_h), - ix = sbl * menu.item_w, iy = i * menu.item_h, - w = (sbl * menu.persub) + i, - p = (which_sbl * menu.persub) + which_press; - - if (w < static_cast(menuitems.size()) && w >= 0) { - drawItem(p, (p == which_sub), True); - - if (p == w && isItemEnabled(w)) { - if (re.x > ix && re.x < (signed) (ix + menu.item_w) && - re.y > iy && re.y < (signed) (iy + menu.item_h)) { - itemSelected(re.button, w); - } - } - } else - drawItem(p, False, True); - - } - } -} - - -void Basemenu::motionNotifyEvent(XMotionEvent &me) { - if (me.window == menu.title && (me.state & Button1Mask)) { - if (movable) { - if (! moving) { - if (m_parent && (! torn)) { - m_parent->drawItem(m_parent->which_sub, false, true); - m_parent->which_sub = -1; - } - - moving = torn = True; - - if (which_sub >= 0) - drawSubmenu(which_sub); - } else { - menu.x = me.x_root - menu.x_move, - menu.y = me.y_root - menu.y_move; - - menu.window.move(menu.x, menu.y); - - if (which_sub >= 0) - drawSubmenu(which_sub); - } - } - } else if ((! (me.state & Button1Mask)) && me.window == menu.frame && - me.x >= 0 && me.x < (signed) menu.width && - me.y >= 0 && me.y < (signed) menu.frame_h) { - 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 < static_cast(menuitems.size()) && w >= 0)) { - if (which_press != -1 && which_sbl != -1) { - int p = (which_sbl * menu.persub) + which_press; - BasemenuItem *item = menuitems[p]; - - drawItem(p, False, True); - if (item->submenu()) { - if (item->submenu()->isVisible() && - (! item->submenu()->isTorn())) { - item->submenu()->internal_hide(); - which_sub = -1; - } - } - } - - which_press = i; - which_sbl = sbl; - - BasemenuItem *itmp = menuitems[w]; - - if (itmp->submenu()) - drawSubmenu(w); - else - drawItem(w, (itmp->isEnabled()), True); - } - } -} - - -void Basemenu::exposeEvent(XExposeEvent &ee) { - if (ee.window == menu.title) { - redrawTitle(); - } else if (ee.window == menu.frame) { - // this is a compilicated algorithm... lets do it step by step... - // first... we see in which sub level the expose starts... and how many - // items down in that sublevel - - int sbl = (ee.x / menu.item_w), id = (ee.y / menu.item_h), - // next... figure out how many sublevels over the redraw spans - sbl_d = ((ee.x + ee.width) / menu.item_w), - // then we see how many items down to redraw - id_d = ((ee.y + ee.height) / menu.item_h); - - if (id_d > menu.persub) id_d = menu.persub; - - // draw the sublevels and the number of items the exposure spans - 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 < static_cast(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++) { - int index = ii + (i * menu.persub); - // redraw the item - drawItem(index, (which_sub == index), true, - ee.x, ee.y, ee.width, ee.height); - } - } - } - } -} - - -void Basemenu::enterNotifyEvent(XCrossingEvent &ce) { - - #ifdef XINERAMA - 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 > - (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 < m_screen->getHeadX(head)) { - menu.x_shift = m_screen->getHeadX(head); - shifted = true; - } - - if (menu.y + menu.height > - (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 + static_cast(menu.title_h) < m_screen->getHeadY(head)) { - menu.y_shift = m_screen->getHeadY(head); - shifted = true; - } - -#else // !XINERAMA - - if (ce.window == menu.frame) { - menu.x_shift = menu.x, menu.y_shift = menu.y; - 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 = -m_screen->getBorderWidth(); - shifted = true; - } - - 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 = -m_screen->getBorderWidth(); - shifted = true; - } - -#endif // XINERAMA - - if (shifted) { -#ifdef XINERAMA - menu.x = menu.x_shift; // need to do this to avoid jumping beetween heads - menu.y = menu.y_shift; -#endif // XINERAMA - menu.window.move(menu.x_shift, menu.y_shift); - } - - if (which_sub >= 0 && static_cast(which_sub) < menuitems.size()) { - BasemenuItem *tmp = menuitems[which_sub]; - if (tmp->submenu()->isVisible()) { - int sbl = (ce.x / menu.item_w), i = (ce.y / menu.item_h), - w = (sbl * menu.persub) + i; - - if (w != which_sub && (! tmp->submenu()->isTorn())) { - tmp->submenu()->internal_hide(); - - drawItem(which_sub, false, true); - which_sub = -1; - } - } - } - } -} - -void Basemenu::leaveNotifyEvent(XCrossingEvent &ce) { - if (ce.window == menu.frame) { - if (which_press != -1 && which_sbl != -1 && menuitems.size() > 0) { - int p = (which_sbl * menu.persub) + which_press; - - drawItem(p, (p == which_sub), true); - - which_sbl = which_press = -1; - } - - if (shifted) { - menu.window.move(menu.x, menu.y); - shifted = false; - - if (which_sub >= 0) - drawSubmenu(which_sub); - } - } -} - - -void Basemenu::reconfigure() { - menu.window.setBackgroundColor(*m_screen->getBorderColor()); - menu.window.setBorderColor(*m_screen->getBorderColor()); - menu.window.setBorderWidth(m_screen->getBorderWidth()); - - menu.bevel_w = m_screen->getBevelWidth(); - update(); -} diff --git a/src/Basemenu.hh b/src/Basemenu.hh deleted file mode 100644 index c68dad5..0000000 --- a/src/Basemenu.hh +++ /dev/null @@ -1,216 +0,0 @@ -// Basemenu.hh for Fluxbox Window manager -// Copyright (c) 2001 - 2002 Henrik Kinnunen (fluxgen at linuxmail.org) -// -// Basemenu.hh for Blackbox - an X11 Window manager -// Copyright (c) 1997 - 2000 Brad Hughes (bhughes at tcac.net) -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// 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.23 2003/01/09 21:57:46 fluxgen Exp $ - -#ifndef BASEMENU_HH -#define BASEMENU_HH - -#include -#include -#include - -#include "FbWindow.hh" -#include "EventHandler.hh" - -class BasemenuItem; -class BScreen; - -namespace FbTk { -class ImageControl; -}; - -/** - Base class for menus -*/ -class Basemenu: public FbTk::EventHandler { -public: - enum Alignment{ ALIGNDONTCARE = 1, ALIGNTOP, ALIGNBOTTOM }; - enum { RIGHT = 1, LEFT }; - - /** - Bullet type - */ - enum { EMPTY = 0, SQUARE, TRIANGLE, DIAMOND }; - - explicit Basemenu(BScreen *screen); - virtual ~Basemenu(); - - /** - @name 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 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 raise(); - void lower(); - /** - @name event handlers - */ - //@{ - void buttonPressEvent(XButtonEvent &bp); - void buttonReleaseEvent(XButtonEvent &br); - void motionNotifyEvent(XMotionEvent &mn); - void enterNotifyEvent(XCrossingEvent &en); - void leaveNotifyEvent(XCrossingEvent &ce); - void exposeEvent(XExposeEvent &ee); - //@} - - void reconfigure(); - /// set label string - void setLabel(const char *labelstr); - /// move menu to x,y - void move(int x, int y); - void update(); - void setItemSelected(unsigned int index, bool val); - void setItemEnabled(unsigned int index, bool val); - virtual void drawSubmenu(unsigned int index); - virtual void show(); - virtual void hide(); - /*@}*/ - - /** - @name accessors - */ - //@{ - bool isTorn() const { return torn; } - bool isVisible() const { return visible; } - const BScreen *screen() const { return m_screen; } - BScreen *screen() { return m_screen; } - Window windowID() const { return menu.window.window(); } - const std::string &label() const { return menu.label; } - int x() const { return menu.x; } - int y() const { return menu.y; } - unsigned int width() const { return menu.width; } - unsigned int height() const { return menu.height; } - unsigned int numberOfItems() const { return menuitems.size(); } - int currentSubmenu() const { return which_sub; } - 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; - //@} - -protected: - - 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; } - inline void setMinimumSublevels(int m) { menu.minsub = m; } - - virtual void itemSelected(int button, unsigned int index) = 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(); - inline Basemenu *parent() { return m_parent; } - inline const Basemenu *parent() const { return m_parent; } - -private: - - typedef std::vector Menuitems; - BScreen *m_screen; - Display *m_display; - Basemenu *m_parent; - FbTk::ImageControl *m_image_ctrl; - Menuitems menuitems; - - bool moving, visible, movable, torn, internal_menu, title_vis, shifted, - hide_tree; - - int which_sub, which_press, which_sbl; - Alignment m_alignment; - - struct _menu { - Pixmap frame_pixmap, title_pixmap, hilite_pixmap, sel_pixmap; - FbTk::FbWindow window, frame, title; - - 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, - bevel_h; - } menu; - -}; - -/** - A menu item in Basemenu -*/ -class BasemenuItem { -public: - BasemenuItem( - const char *label, - int function, - const char *exec = (const char *) 0) - : m_label(label ? label : "") - , m_exec(exec ? exec : "") - , m_submenu(0) - , m_function(function) - , m_enabled(true) - , m_selected(false) - { } - - BasemenuItem(const char *label, Basemenu *submenu) - : m_label(label ? label : "") - , m_exec("") - , m_submenu(submenu) - , m_function(0) - , m_enabled(true) - , m_selected(false) - { } - - void setSelected(bool selected) { m_selected = selected; } - void setEnabled(bool enabled) { m_enabled = enabled; } - Basemenu *submenu() { return m_submenu; } - /** - @name accessors - */ - //@{ - const std::string &exec() const { return m_exec; } - const std::string &label() const { return m_label; } - int function() const { return m_function; } - const Basemenu *submenu() const { return m_submenu; } - bool isEnabled() const { return m_enabled; } - bool isSelected() const { return m_selected; } - //@} - -private: - std::string m_label; ///< label of this item - std::string m_exec; ///< command string to execute - Basemenu *m_submenu; ///< a submenu, 0 if we don't have one - int m_function; - bool m_enabled, m_selected; - - friend class Basemenu; -}; - - -#endif // BASEMENU_HH diff --git a/src/Windowmenu.cc b/src/Windowmenu.cc deleted file mode 100644 index 65655ce..0000000 --- a/src/Windowmenu.cc +++ /dev/null @@ -1,303 +0,0 @@ -// Windowmenu.cc for Fluxbox -// Copyright (c) 2001-2002 Henrik Kinnunen (fluxgen@linuxmail.org) -// Windowmenu.cc for Blackbox - an X11 Window manager -// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// 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: Windowmenu.cc,v 1.23 2003/01/05 22:31:36 fluxgen Exp $ - -//use GNU extensions -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif // _GNU_SOURCE - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif // HAVE_CONFIG_H - -#include "i18n.hh" -#include "fluxbox.hh" -#include "Screen.hh" -#include "Window.hh" -#include "Windowmenu.hh" -#include "Workspace.hh" - -#include - -Windowmenu::Windowmenu(FluxboxWindow &win) : Basemenu(win.getScreen()), - window(win), - screen(win.getScreen()), - sendToMenu(win), - sendGroupToMenu(win) { - - setTitleVisibility(False); - setMovable(False); - setInternalMenu(); - - I18n *i18n = I18n::instance(); - - using namespace FBNLS; - insert(i18n->getMessage( - WindowmenuSet, WindowmenuSendTo, - "Send To ..."), - &sendToMenu); - - insert(i18n->getMessage( - WindowmenuSet, WindowmenuSendGroupTo, - "Send Group To ..."), - &sendGroupToMenu); - - insert(i18n->getMessage( - WindowmenuSet, WindowmenuShade, - "Shade"), - BScreen::WINDOWSHADE); - insert(i18n->getMessage( - WindowmenuSet, WindowmenuIconify, - "Iconify"), - BScreen::WINDOWICONIFY); - insert(i18n->getMessage( - WindowmenuSet, WindowmenuMaximize, - "Maximize"), - BScreen::WINDOWMAXIMIZE); - insert(i18n->getMessage( - WindowmenuSet, WindowmenuRaise, - "Raise"), - BScreen::WINDOWRAISE); - insert(i18n->getMessage( - WindowmenuSet, WindowmenuLower, - "Lower"), - BScreen::WINDOWLOWER); - insert(i18n->getMessage( - WindowmenuSet, WindowmenuStick, - "Stick"), - BScreen::WINDOWSTICK); - insert(i18n->getMessage( - WindowmenuSet, WindowmenuKillClient, - "Kill Client"), - BScreen::WINDOWKILL); - insert(i18n->getMessage( - WindowmenuSet, WindowmenuClose, - "Close"), - BScreen::WINDOWCLOSE); - insert(i18n->getMessage( - WindowmenuSet, WindowmenuTab, - "Tab"), - BScreen::WINDOWTAB); - - update(); - - setItemEnabled(2, window.hasTitlebar()); - setItemEnabled(3, window.isIconifiable()); - setItemEnabled(4, window.isMaximizable()); - setItemEnabled(9, window.isClosable()); - setItemEnabled(10, window.isGroupable()); // tab option - -} - - -Windowmenu::~Windowmenu() { - -} - - -void Windowmenu::show() { - if (isItemEnabled(2)) - setItemSelected(2, window.isShaded()); - if (isItemEnabled(4)) - setItemSelected(4, window.isMaximized()); - if (isItemEnabled(7)) - setItemSelected(7, window.isStuck()); - - Basemenu::show(); -} - - -void Windowmenu::itemSelected(int button, unsigned int index) { - BasemenuItem *item = find(index); - hide(); - switch (item->function()) { - case BScreen::WINDOWSHADE: - if (window.isIconic()) - break; - - window.shade(); - if (window.hasTab()) - window.getTab()->shade(); - break; - - case BScreen::WINDOWICONIFY: - if (!window.isIconic()) - window.iconify(); - else - window.deiconify(); // restore window - - break; - - case BScreen::WINDOWMAXIMIZE: - window.maximize(); - break; - - case BScreen::WINDOWCLOSE: - window.close(); - break; - - case BScreen::WINDOWRAISE: - if (window.isIconic()) - break; - - if (window.hasTab()) - window.getTab()->raise(); //raise tabs - screen->getWorkspace(window.getWorkspaceNumber())->raiseWindow(&window); - break; - - case BScreen::WINDOWLOWER: - if (window.isIconic()) - break; - - screen->getWorkspace(window.getWorkspaceNumber())->lowerWindow(&window); - if (window.hasTab()) - window.getTab()->lower(); //lower tabs AND all it's windows - break; - - case BScreen::WINDOWSTICK: - window.stick(); - break; - - case BScreen::WINDOWKILL: - XKillClient(BaseDisplay::getXDisplay(), - window.getClientWindow()); - break; - case BScreen::WINDOWTAB: - window.setTab(!window.hasTab()); - break; - } -} - - -void Windowmenu::reconfigure() { - setItemEnabled(1, window.hasTitlebar()); - setItemEnabled(2, window.isIconifiable()); - setItemEnabled(3, window.isMaximizable()); - setItemEnabled(8, window.isClosable()); - setItemEnabled(10, window.isResizable()); // tab option only enabled if resizable - - sendToMenu.reconfigure(); - sendGroupToMenu.reconfigure(); - - Basemenu::reconfigure(); -} - - -Windowmenu::SendtoWorkspacemenu::SendtoWorkspacemenu(FluxboxWindow &win): Basemenu(win.getScreen()), - m_fbwindow(win) -{ - setTitleVisibility(false); - setMovable(false); - setInternalMenu(); - update(); -} - - -void Windowmenu::SendtoWorkspacemenu::itemSelected(int button, unsigned int index) { - if (button > 2) - return; - - if (index <= screen()->getCount()) { - - // no need to send it to a workspace it already exist on - if (index == screen()->getCurrentWorkspaceID()) - return; - - if (button == 1) { // send to workspace without changing workspace - screen()->sendToWorkspace(index, &m_fbwindow, false); - } else if (button == 2) { // send to workspace and change workspace - screen()->sendToWorkspace(index, &m_fbwindow, true); - } - } - - hide(); -} - - -void Windowmenu::SendtoWorkspacemenu::update() { - unsigned int i, r = numberOfItems(); - - if (numberOfItems() != 0) { - for (i = 0; i < r; ++i) - remove(0); - } - for (i = 0; i < screen()->getCount(); ++i) - insert(screen()->getWorkspace(i)->name().c_str()); - - Basemenu::update(); -} - - -void Windowmenu::SendtoWorkspacemenu::show() { - update(); - - Basemenu::show(); -} - -Windowmenu::SendGroupToWorkspacemenu:: -SendGroupToWorkspacemenu(FluxboxWindow &win):SendtoWorkspacemenu(win) -{ - -} - -void Windowmenu::SendGroupToWorkspacemenu::itemSelected(int button, unsigned int index) { - if (button > 2) - return; - - if (index <= screen()->getCount()) { - if (index == screen()->getCurrentWorkspaceID()) - return; - if (fbwin().isStuck()) - fbwin().stick(); - - // if the window is iconic, deiconify it - if (fbwin().isIconic()) - fbwin().deiconify(); - - if (button == 1) { - // TODO: use reassociateGroup from BScreen instead - if (fbwin().hasTab()) { - for (Tab *first = Tab::getFirst(fbwin().getTab()); - first!=0; first=first->next()) { - first->withdraw(); - first->getWindow()->withdraw(); - screen()->reassociateWindow(first->getWindow(), index, true); - - } - } else { - fbwin().withdraw(); - screen()->reassociateWindow(&fbwin(), index, true); - } - - } - - if (button == 2) - screen()->changeWorkspaceID(index); - } - hide(); -} - - - diff --git a/src/Windowmenu.hh b/src/Windowmenu.hh deleted file mode 100644 index 6e6e2d5..0000000 --- a/src/Windowmenu.hh +++ /dev/null @@ -1,81 +0,0 @@ -// Windowmenu.hh for Blackbox - an X11 Window manager -// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// 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. - -#ifndef WINDOWMENU_HH -#define WINDOWMENU_HH - -#include "Basemenu.hh" - -class FluxboxWindow; - - -class Windowmenu : public Basemenu { -public: - explicit Windowmenu(FluxboxWindow &fbwin); - virtual ~Windowmenu(); - - const Basemenu &getSendToMenu() const { return sendToMenu; } - Basemenu &getSendToMenu() { return sendToMenu; } - const Basemenu &getSendGroupToMenu() const { return sendGroupToMenu; } - Basemenu &getSendGroupToMenu() { return sendGroupToMenu; } - - void reconfigure(); - void setClosable(); - - virtual void show(); - -protected: - virtual void itemSelected(int button, unsigned int index); - -private: - FluxboxWindow &window; - BScreen *screen; - - - class SendtoWorkspacemenu : public Basemenu { - public: - SendtoWorkspacemenu(FluxboxWindow &win); - void update(); - - virtual void show(); - FluxboxWindow &fbwin() { return m_fbwindow; } - protected: - virtual void itemSelected(int button, unsigned int index); - private: - FluxboxWindow &m_fbwindow; - }; - - class SendGroupToWorkspacemenu : public SendtoWorkspacemenu { - public: - SendGroupToWorkspacemenu(FluxboxWindow &win); - - protected: - virtual void itemSelected(int button, unsigned int index); - - }; - - SendtoWorkspacemenu sendToMenu; - SendGroupToWorkspacemenu sendGroupToMenu; - -}; - - -#endif // WINDOWMENU_HH diff --git a/src/Workspacemenu.cc b/src/Workspacemenu.cc deleted file mode 100644 index c39c435..0000000 --- a/src/Workspacemenu.cc +++ /dev/null @@ -1,79 +0,0 @@ -// Workspacemenu.cc for Fluxbox -// Copyright (c) 2002 Henrik Kinnunen (fluxgen@linuxmail.org) -// Workspacemenu.cc for Blackbox - an X11 Window manager -// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// 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: Workspacemenu.cc,v 1.11 2002/12/01 13:42:06 rathnor Exp $ - -#include "Workspacemenu.hh" - -#include "i18n.hh" -#include "Screen.hh" -#include "Workspace.hh" -#include "fluxbox.hh" - -//use GNU extension -#ifndef _GNU_SOURCE -#define _GNU_SOURCE -#endif // _GNU_SOURCE - -#ifdef HAVE_CONFIG_H -#include "../config.h" -#endif // HAVE_CONFIG_H - -#include -#include - -Workspacemenu::Workspacemenu(BScreen *scrn) : Basemenu(scrn) { - - setInternalMenu(); - I18n *i18n = I18n::instance(); - using namespace FBNLS; - setLabel(i18n->getMessage( - WorkspacemenuSet, WorkspacemenuWorkspacesTitle, - "Workspaces")); - insert(i18n->getMessage( - WorkspacemenuSet, WorkspacemenuNewWorkspace, - "New Workspace")); - insert(i18n->getMessage( - WorkspacemenuSet, WorkspacemenuRemoveLast, - "Remove Last")); -} - - -void Workspacemenu::itemSelected(int button, unsigned int index) { - if (button == 1) { - if (index == 0) { - screen()->addWorkspace(); - Fluxbox::instance()->save_rc(); - } else if (index == 1) { - screen()->removeLastWorkspace(); - Fluxbox::instance()->save_rc(); - } else if ((screen()->getCurrentWorkspace()->workspaceID() != - (index - 2)) && ((index - 2) < screen()->getCount())) { - screen()->changeWorkspaceID(index - 2); - } - - if (! (screen()->getWorkspacemenu()->isTorn() || isTorn())) - hide(); - } -} - diff --git a/src/Workspacemenu.hh b/src/Workspacemenu.hh deleted file mode 100644 index e62022e..0000000 --- a/src/Workspacemenu.hh +++ /dev/null @@ -1,38 +0,0 @@ -// Workspacemenu.hh for Fluxbox -// Copyright (c) 2002 Henrik Kinnunen (fluxgen@linuxmail.org) -// WorkspaceMenu.hh for Blackbox - an X11 Window manager -// Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net) -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the "Software"), -// to deal in the Software without restriction, including without limitation -// the rights to use, copy, modify, merge, publish, distribute, sublicense, -// and/or sell copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// 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. - -#ifndef WORKSPACEMENU_HH -#define WORKSPACEMENU_HH - -#include "Basemenu.hh" - -class Workspacemenu : public Basemenu { -public: - Workspacemenu(BScreen *screen); - -protected: - virtual void itemSelected(int button, unsigned int index); - -}; - -#endif // WORKSPACEMENU_HH -- cgit v0.11.2