aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2004-05-02 21:08:28 (GMT)
committerfluxgen <fluxgen>2004-05-02 21:08:28 (GMT)
commit49162b5bf5159b512eaf1fbe91cc6c5587fbd491 (patch)
treecd2baa9806a7108843515f83c2e6eff48b2c5860 /src
parent1f88db4fd64fb918ed5b6f0694b8ebb6dedc5f26 (diff)
downloadfluxbox_paul-49162b5bf5159b512eaf1fbe91cc6c5587fbd491.zip
fluxbox_paul-49162b5bf5159b512eaf1fbe91cc6c5587fbd491.tar.bz2
using MenuCreator to create window menu
Diffstat (limited to 'src')
-rw-r--r--src/Window.cc91
1 files changed, 35 insertions, 56 deletions
diff --git a/src/Window.cc b/src/Window.cc
index 8c6e07c..6630226 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: Window.cc,v 1.284 2004/04/30 13:48:58 rathnor Exp $ 25// $Id: Window.cc,v 1.285 2004/05/02 21:08:28 fluxgen Exp $
26 26
27#include "Window.hh" 27#include "Window.hh"
28 28
@@ -31,23 +31,20 @@
31#include "fluxbox.hh" 31#include "fluxbox.hh"
32#include "Screen.hh" 32#include "Screen.hh"
33#include "FbWinFrameTheme.hh" 33#include "FbWinFrameTheme.hh"
34#include "MenuTheme.hh"
35#include "FbAtoms.hh" 34#include "FbAtoms.hh"
36#include "RootTheme.hh" 35#include "RootTheme.hh"
37#include "Workspace.hh" 36#include "Workspace.hh"
38#include "LayerMenu.hh"
39#include "FbWinFrame.hh" 37#include "FbWinFrame.hh"
40#include "WinButton.hh" 38#include "WinButton.hh"
41#include "WinButtonTheme.hh" 39#include "WinButtonTheme.hh"
42#include "SendToMenu.hh"
43#include "Remember.hh" 40#include "Remember.hh"
41#include "MenuCreator.hh"
44 42
45#include "FbTk/StringUtil.hh"
46#include "FbTk/TextButton.hh" 43#include "FbTk/TextButton.hh"
47#include "FbTk/Compose.hh" 44#include "FbTk/Compose.hh"
48#include "FbTk/EventManager.hh" 45#include "FbTk/EventManager.hh"
49#include "FbTk/MultiButtonMenuItem.hh"
50#include "FbTk/KeyUtil.hh" 46#include "FbTk/KeyUtil.hh"
47#include "FbTk/SimpleCommand.hh"
51 48
52#ifdef HAVE_CONFIG_H 49#ifdef HAVE_CONFIG_H
53#include "config.h" 50#include "config.h"
@@ -250,10 +247,6 @@ private:
250 247
251}; 248};
252 249
253template <>
254void LayerMenuItem<FluxboxWindow>::click(int button, int time) {
255 m_object->moveToLayer(m_layernum);
256}
257 250
258int FluxboxWindow::s_num_grabs = 0; 251int FluxboxWindow::s_num_grabs = 0;
259 252
@@ -275,8 +268,7 @@ FluxboxWindow::FluxboxWindow(WinClient &client, FbWinFrameTheme &tm,
275 m_attaching_tab(0), 268 m_attaching_tab(0),
276 m_screen(client.screen()), 269 m_screen(client.screen()),
277 display(FbTk::App::instance()->display()), 270 display(FbTk::App::instance()->display()),
278 m_windowmenu(client.screen().menuTheme(), client.screen().imageControl(), 271 m_windowmenu(MenuCreator::createMenu("", client.screenNumber())),
279 *client.screen().layerManager().getLayer(Fluxbox::instance()->getMenuLayer())),
280 m_button_grab_x(0), m_button_grab_y(0), 272 m_button_grab_x(0), m_button_grab_y(0),
281 m_last_move_x(0), m_last_move_y(0), 273 m_last_move_x(0), m_last_move_y(0),
282 m_last_resize_h(1), m_last_resize_w(1), 274 m_last_resize_h(1), m_last_resize_w(1),
@@ -568,14 +560,14 @@ void FluxboxWindow::init() {
568 setState(m_current_state); 560 setState(m_current_state);
569 561
570 // add extra menus 562 // add extra menus
571 addExtraMenu("Send To...", new SendToMenu(*this)); 563 /* addExtraMenu("Send To...", new SendToMenu(*this));
572 addExtraMenu("Layer...", 564 addExtraMenu("Layer...",
573 new LayerMenu<FluxboxWindow>(screen().menuTheme(), 565 new LayerMenu<FluxboxWindow>(screen().menuTheme(),
574 screen().imageControl(), 566 screen().imageControl(),
575 *screen().layerManager().getLayer(Fluxbox::instance()->getMenuLayer()), 567 *screen().layerManager().getLayer(Fluxbox::instance()->getMenuLayer()),
576 this, 568 this,
577 false)); 569 false));
578 570 */
579 // the layermenu will get deleted as an extra menu 571 // the layermenu will get deleted as an extra menu
580 // don't call setupWindow here as the addExtraMenu call should 572 // don't call setupWindow here as the addExtraMenu call should
581 573
@@ -1020,7 +1012,7 @@ void FluxboxWindow::reconfigure() {
1020 1012
1021 frame().reconfigure(); 1013 frame().reconfigure();
1022 1014
1023 m_windowmenu.reconfigure(); 1015 menu().reconfigure();
1024 1016
1025} 1017}
1026 1018
@@ -1277,7 +1269,7 @@ void FluxboxWindow::hide() {
1277#ifdef DEBUG 1269#ifdef DEBUG
1278 cerr<<__FILE__<<"("<<__FUNCTION__<<")["<<this<<"]"<<endl; 1270 cerr<<__FILE__<<"("<<__FUNCTION__<<")["<<this<<"]"<<endl;
1279#endif // DEBUG 1271#endif // DEBUG
1280 m_windowmenu.hide(); 1272 menu().hide();
1281 frame().hide(); 1273 frame().hide();
1282} 1274}
1283 1275
@@ -1390,7 +1382,7 @@ void FluxboxWindow::withdraw() {
1390 1382
1391 frame().hide(); 1383 frame().hide();
1392 1384
1393 m_windowmenu.hide(); 1385 menu().hide();
1394} 1386}
1395 1387
1396/** 1388/**
@@ -1969,19 +1961,19 @@ void FluxboxWindow::showMenu(int menu_x, int menu_y) {
1969 int head = screen().getHead(menu_x, menu_y); 1961 int head = screen().getHead(menu_x, menu_y);
1970 1962
1971 // but not under screen 1963 // but not under screen
1972 if (menu_y + m_windowmenu.height() >= screen().maxBottom(head)) 1964 if (menu_y + menu().height() >= screen().maxBottom(head))
1973 menu_y = screen().maxBottom(head) - m_windowmenu.height() - 1 - m_windowmenu.fbwindow().borderWidth(); 1965 menu_y = screen().maxBottom(head) - menu().height() - 1 - menu().fbwindow().borderWidth();
1974 1966
1975 if (menu_x < static_cast<signed>(screen().maxLeft(head))) 1967 if (menu_x < static_cast<signed>(screen().maxLeft(head)))
1976 menu_x = screen().maxLeft(head); 1968 menu_x = screen().maxLeft(head);
1977 else if (menu_x + static_cast<signed>(m_windowmenu.width()) >= static_cast<signed>(screen().maxRight(head))) 1969 else if (menu_x + static_cast<signed>(menu().width()) >= static_cast<signed>(screen().maxRight(head)))
1978 menu_x = screen().maxRight(head) - m_windowmenu.width() - 1; 1970 menu_x = screen().maxRight(head) - menu().width() - 1;
1979 1971
1980 1972
1981 m_windowmenu.move(menu_x, menu_y); 1973 menu().move(menu_x, menu_y);
1982 m_windowmenu.show(); 1974 menu().show();
1983 m_windowmenu.raise(); 1975 menu().raise();
1984 m_windowmenu.grabInputFocus(); 1976 menu().grabInputFocus();
1985} 1977}
1986 1978
1987/** 1979/**
@@ -1989,8 +1981,8 @@ void FluxboxWindow::showMenu(int menu_x, int menu_y) {
1989 if it's already visible it'll be hidden 1981 if it's already visible it'll be hidden
1990 */ 1982 */
1991void FluxboxWindow::popupMenu() { 1983void FluxboxWindow::popupMenu() {
1992 if (m_windowmenu.isVisible()) { 1984 if (menu().isVisible()) {
1993 m_windowmenu.hide(); 1985 menu().hide();
1994 return; 1986 return;
1995 } 1987 }
1996 1988
@@ -2838,8 +2830,8 @@ void FluxboxWindow::startMoving(Window win) {
2838 ButtonReleaseMask, GrabModeAsync, GrabModeAsync, 2830 ButtonReleaseMask, GrabModeAsync, GrabModeAsync,
2839 screen().rootWindow().window(), frame().theme().moveCursor(), CurrentTime); 2831 screen().rootWindow().window(), frame().theme().moveCursor(), CurrentTime);
2840 2832
2841 if (m_windowmenu.isVisible()) 2833 if (menu().isVisible())
2842 m_windowmenu.hide(); 2834 menu().hide();
2843 2835
2844 fluxbox->maskWindowEvents(screen().rootWindow().window(), this); 2836 fluxbox->maskWindowEvents(screen().rootWindow().window(), this);
2845 2837
@@ -3504,35 +3496,22 @@ void FluxboxWindow::setupWindow() {
3504 menu().removeAll(); // clear old items 3496 menu().removeAll(); // clear old items
3505 menu().disableTitle(); // not titlebar 3497 menu().disableTitle(); // not titlebar
3506 3498
3507 // set new menu items 3499 if (!screen().windowMenuFilename().empty()) {
3508 menu().insert("Shade", shade_cmd); 3500 MenuCreator::createFromFile(screen().windowMenuFilename(), menu(), *this);
3509 menu().insert("Stick", stick_cmd); 3501 } else {
3510 // create maximize item with: 3502 MenuCreator::createWindowMenuItem("shade", "", menu(), *this);
3511 // button1: Maximize normal 3503 MenuCreator::createWindowMenuItem("stick", "", menu(), *this);
3512 // button2: Maximize Vertical 3504 MenuCreator::createWindowMenuItem("maximize", "", menu(), *this);
3513 // button3: Maximize Horizontal 3505 MenuCreator::createWindowMenuItem("iconify", "", menu(), *this);
3514 FbTk::MultiButtonMenuItem *maximize_item = new FbTk::MultiButtonMenuItem(3, "Maximize"); 3506 MenuCreator::createWindowMenuItem("raise", "", menu(), *this);
3515 maximize_item->setCommand(1, maximize_cmd); 3507 MenuCreator::createWindowMenuItem("lower", "", menu(), *this);
3516 maximize_item->setCommand(2, maximize_vert_cmd); 3508 MenuCreator::createWindowMenuItem("sendto", "", menu(), *this);
3517 maximize_item->setCommand(3, maximize_horiz_cmd); 3509 MenuCreator::createWindowMenuItem("layer", "", menu(), *this);
3518 menu().insert(maximize_item); 3510 MenuCreator::createWindowMenuItem("extramenus", "", menu(), *this);
3519 menu().insert("Iconify", iconify_cmd); 3511 MenuCreator::createWindowMenuItem("separator", "", menu(), *this);
3520 menu().insert("Raise", raise_cmd); 3512 MenuCreator::createWindowMenuItem("close", "", menu(), *this);
3521 menu().insert("Lower", lower_cmd);
3522
3523
3524
3525 ExtraMenus::iterator it = m_extramenus.begin();
3526 ExtraMenus::iterator it_end = m_extramenus.end();
3527 for (; it != it_end; ++it) {
3528 it->second->disableTitle(); // be sure there is no title
3529 menu().insert(it->first, it->second);
3530 } 3513 }
3531 3514
3532
3533 menu().insert("---");
3534 menu().insert("Close", close_cmd);
3535
3536 menu().reconfigure(); // update graphics 3515 menu().reconfigure(); // update graphics
3537} 3516}
3538 3517