2002-05-25 00:29:44 +00:00
|
|
|
// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
|
|
|
|
// Configmenu.cc for Blackbox - An X11 Window Manager
|
|
|
|
// Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry <shaleh@debian.org>
|
2002-04-11 03:20:38 +00:00
|
|
|
// 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.
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "../config.h"
|
|
|
|
#endif // HAVE_CONFIG_H
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
#include "i18n.hh"
|
|
|
|
#include "Configmenu.hh"
|
|
|
|
#include "Image.hh"
|
|
|
|
#include "Toolbar.hh"
|
|
|
|
#include "Window.hh"
|
|
|
|
#include "Screen.hh"
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
Configmenu::Configmenu(BScreen *scr) : Basemenu(scr) {
|
|
|
|
setLabel(i18n(ConfigmenuSet, ConfigmenuConfigOptions, "Config options"));
|
2002-04-11 03:20:38 +00:00
|
|
|
setInternalMenu();
|
|
|
|
|
|
|
|
focusmenu = new Focusmenu(this);
|
|
|
|
placementmenu = new Placementmenu(this);
|
|
|
|
|
2002-05-16 22:35:59 +00:00
|
|
|
insert(i18n(ConfigmenuSet, ConfigmenuFocusModel,
|
|
|
|
"Focus Model"), focusmenu);
|
|
|
|
insert(i18n(ConfigmenuSet, ConfigmenuWindowPlacement,
|
|
|
|
"Window Placement"), placementmenu);
|
|
|
|
insert(i18n(ConfigmenuSet, ConfigmenuImageDithering,
|
|
|
|
"Image Dithering"), 1);
|
|
|
|
insert(i18n(ConfigmenuSet, ConfigmenuOpaqueMove,
|
|
|
|
"Opaque Window Moving"), 2);
|
|
|
|
insert(i18n(ConfigmenuSet, ConfigmenuFullMax,
|
|
|
|
"Full Maximization"), 3);
|
|
|
|
insert(i18n(ConfigmenuSet, ConfigmenuFocusNew,
|
|
|
|
"Focus New Windows"), 4);
|
|
|
|
insert(i18n(ConfigmenuSet, ConfigmenuFocusLast,
|
|
|
|
"Focus Last Window on Workspace"), 5);
|
2002-04-11 03:20:38 +00:00
|
|
|
update();
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
setItemSelected(2, getScreen()->getImageControl()->doDither());
|
|
|
|
setItemSelected(3, getScreen()->doOpaqueMove());
|
|
|
|
setItemSelected(4, getScreen()->doFullMax());
|
|
|
|
setItemSelected(5, getScreen()->doFocusNew());
|
|
|
|
setItemSelected(6, getScreen()->doFocusLast());
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
Configmenu::~Configmenu(void) {
|
2002-04-11 03:20:38 +00:00
|
|
|
delete focusmenu;
|
|
|
|
delete placementmenu;
|
|
|
|
}
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
void Configmenu::itemSelected(int button, unsigned int index) {
|
2002-04-11 03:20:38 +00:00
|
|
|
if (button != 1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
BasemenuItem *item = find(index);
|
|
|
|
|
|
|
|
if (!item->function())
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch(item->function()) {
|
|
|
|
case 1: { // dither
|
2002-05-25 00:29:44 +00:00
|
|
|
getScreen()->getImageControl()->
|
|
|
|
setDither((! getScreen()->getImageControl()->doDither()));
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
setItemSelected(index, getScreen()->getImageControl()->doDither());
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 2: { // opaque move
|
2002-05-25 00:29:44 +00:00
|
|
|
getScreen()->saveOpaqueMove((! getScreen()->doOpaqueMove()));
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
setItemSelected(index, getScreen()->doOpaqueMove());
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 3: { // full maximization
|
2002-05-25 00:29:44 +00:00
|
|
|
getScreen()->saveFullMax((! getScreen()->doFullMax()));
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
setItemSelected(index, getScreen()->doFullMax());
|
2002-04-11 03:20:38 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 4: { // focus new windows
|
2002-05-25 00:29:44 +00:00
|
|
|
getScreen()->saveFocusNew((! getScreen()->doFocusNew()));
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
setItemSelected(index, getScreen()->doFocusNew());
|
2002-04-11 03:20:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case 5: { // focus last window on workspace
|
2002-05-25 00:29:44 +00:00
|
|
|
getScreen()->saveFocusLast((! getScreen()->doFocusLast()));
|
|
|
|
setItemSelected(index, getScreen()->doFocusLast());
|
2002-04-16 20:22:01 +00:00
|
|
|
break;
|
|
|
|
}
|
2002-04-11 03:20:38 +00:00
|
|
|
} // switch
|
|
|
|
}
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
|
|
|
|
void Configmenu::reconfigure(void) {
|
2002-04-11 03:20:38 +00:00
|
|
|
focusmenu->reconfigure();
|
|
|
|
placementmenu->reconfigure();
|
|
|
|
|
|
|
|
Basemenu::reconfigure();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
Configmenu::Focusmenu::Focusmenu(Configmenu *cm) : Basemenu(cm->getScreen()) {
|
|
|
|
setLabel(i18n(ConfigmenuSet, ConfigmenuFocusModel, "Focus Model"));
|
2002-04-11 03:20:38 +00:00
|
|
|
setInternalMenu();
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
insert(i18n(ConfigmenuSet, ConfigmenuClickToFocus, "Click To Focus"), 1);
|
|
|
|
insert(i18n(ConfigmenuSet, ConfigmenuSloppyFocus, "Sloppy Focus"), 2);
|
|
|
|
insert(i18n(ConfigmenuSet, ConfigmenuAutoRaise, "Auto Raise"), 3);
|
|
|
|
insert(i18n(ConfigmenuSet, ConfigmenuClickRaise, "Click Raise"), 4);
|
2002-04-11 03:20:38 +00:00
|
|
|
update();
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
setItemSelected(0, (! getScreen()->isSloppyFocus()));
|
|
|
|
setItemSelected(1, getScreen()->isSloppyFocus());
|
|
|
|
setItemEnabled(2, getScreen()->isSloppyFocus());
|
|
|
|
setItemSelected(2, getScreen()->doAutoRaise());
|
|
|
|
setItemEnabled(3, getScreen()->isSloppyFocus());
|
|
|
|
setItemSelected(3, getScreen()->doClickRaise());
|
2002-04-17 23:07:11 +00:00
|
|
|
}
|
|
|
|
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
void Configmenu::Focusmenu::itemSelected(int button, unsigned int index) {
|
2002-04-11 03:20:38 +00:00
|
|
|
if (button != 1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
BasemenuItem *item = find(index);
|
|
|
|
|
|
|
|
if (!item->function())
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch (item->function()) {
|
|
|
|
case 1: // click to focus
|
2002-05-25 00:29:44 +00:00
|
|
|
getScreen()->toggleFocusModel(BScreen::ClickToFocus);
|
2002-04-11 03:20:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: // sloppy focus
|
2002-05-25 00:29:44 +00:00
|
|
|
getScreen()->toggleFocusModel(BScreen::SloppyFocus);
|
2002-04-11 03:20:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: // auto raise with sloppy focus
|
2002-05-25 00:29:44 +00:00
|
|
|
getScreen()->saveAutoRaise(! getScreen()->doAutoRaise());
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4: // click raise with sloppy focus
|
|
|
|
getScreen()->saveClickRaise(! getScreen()->doClickRaise());
|
|
|
|
getScreen()->updateFocusModel();
|
2002-04-11 03:20:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
setItemSelected(0, (! getScreen()->isSloppyFocus()));
|
|
|
|
setItemSelected(1, getScreen()->isSloppyFocus());
|
|
|
|
setItemEnabled(2, getScreen()->isSloppyFocus());
|
|
|
|
setItemSelected(2, getScreen()->doAutoRaise());
|
|
|
|
setItemEnabled(3, getScreen()->isSloppyFocus());
|
|
|
|
setItemSelected(3, getScreen()->doClickRaise());
|
2002-04-11 03:20:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
Configmenu::Placementmenu::Placementmenu(Configmenu *cm):
|
|
|
|
Basemenu(cm->getScreen()) {
|
|
|
|
setLabel(i18n(ConfigmenuSet, ConfigmenuWindowPlacement, "Window Placement"));
|
2002-04-11 03:20:38 +00:00
|
|
|
setInternalMenu();
|
2002-05-16 22:35:59 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
insert(i18n(ConfigmenuSet, ConfigmenuSmartRows, "Smart Placement (Rows)"),
|
2002-05-16 22:35:59 +00:00
|
|
|
BScreen::RowSmartPlacement);
|
2002-05-25 00:29:44 +00:00
|
|
|
insert(i18n(ConfigmenuSet, ConfigmenuSmartCols, "Smart Placement (Columns)"),
|
2002-05-16 22:35:59 +00:00
|
|
|
BScreen::ColSmartPlacement);
|
2002-05-25 00:29:44 +00:00
|
|
|
insert(i18n(ConfigmenuSet, ConfigmenuCascade, "Cascade Placement"),
|
|
|
|
BScreen::CascadePlacement);
|
|
|
|
insert(i18n(ConfigmenuSet, ConfigmenuLeftRight, "Left to Right"),
|
|
|
|
BScreen::LeftRight);
|
|
|
|
insert(i18n(ConfigmenuSet, ConfigmenuRightLeft, "Right to Left"),
|
|
|
|
BScreen::RightLeft);
|
|
|
|
insert(i18n(ConfigmenuSet, ConfigmenuTopBottom, "Top to Bottom"),
|
|
|
|
BScreen::TopBottom);
|
|
|
|
insert(i18n(ConfigmenuSet, ConfigmenuBottomTop, "Bottom to Top"),
|
|
|
|
BScreen::BottomTop);
|
2002-04-11 03:20:38 +00:00
|
|
|
update();
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
switch (getScreen()->getPlacementPolicy()) {
|
|
|
|
case BScreen::RowSmartPlacement:
|
|
|
|
setItemSelected(0, True);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case BScreen::ColSmartPlacement:
|
|
|
|
setItemSelected(1, True);
|
|
|
|
break;
|
2002-04-17 23:07:11 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
case BScreen::CascadePlacement:
|
|
|
|
setItemSelected(2, True);
|
|
|
|
break;
|
|
|
|
}
|
2002-04-28 00:11:19 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
bool rl = (getScreen()->getRowPlacementDirection() ==
|
2002-05-16 22:35:59 +00:00
|
|
|
BScreen::LeftRight),
|
2002-05-25 00:29:44 +00:00
|
|
|
tb = (getScreen()->getColPlacementDirection() ==
|
|
|
|
BScreen::TopBottom);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
setItemSelected(3, rl);
|
|
|
|
setItemSelected(4, ! rl);
|
|
|
|
|
|
|
|
setItemSelected(5, tb);
|
|
|
|
setItemSelected(6, ! tb);
|
2002-04-17 23:07:11 +00:00
|
|
|
}
|
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
|
|
|
|
void Configmenu::Placementmenu::itemSelected(int button, unsigned int index) {
|
2002-04-11 03:20:38 +00:00
|
|
|
if (button != 1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
BasemenuItem *item = find(index);
|
|
|
|
|
|
|
|
if (!item->function())
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch (item->function()) {
|
|
|
|
case BScreen::RowSmartPlacement:
|
2002-05-25 00:29:44 +00:00
|
|
|
getScreen()->savePlacementPolicy(item->function());
|
|
|
|
|
|
|
|
setItemSelected(0, True);
|
|
|
|
setItemSelected(1, False);
|
|
|
|
setItemSelected(2, False);
|
|
|
|
|
2002-04-11 03:20:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BScreen::ColSmartPlacement:
|
2002-05-25 00:29:44 +00:00
|
|
|
getScreen()->savePlacementPolicy(item->function());
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
setItemSelected(0, False);
|
|
|
|
setItemSelected(1, True);
|
|
|
|
setItemSelected(2, False);
|
2002-04-14 01:11:51 +00:00
|
|
|
|
2002-04-28 00:11:19 +00:00
|
|
|
break;
|
2002-04-14 01:11:51 +00:00
|
|
|
|
2002-05-25 00:29:44 +00:00
|
|
|
case BScreen::CascadePlacement:
|
|
|
|
getScreen()->savePlacementPolicy(item->function());
|
|
|
|
|
|
|
|
setItemSelected(0, False);
|
|
|
|
setItemSelected(1, False);
|
|
|
|
setItemSelected(2, True);
|
2002-04-11 03:20:38 +00:00
|
|
|
|
2002-04-28 12:12:24 +00:00
|
|
|
break;
|
|
|
|
|
2002-04-11 03:20:38 +00:00
|
|
|
case BScreen::LeftRight:
|
2002-05-25 00:29:44 +00:00
|
|
|
getScreen()->saveRowPlacementDirection(BScreen::LeftRight);
|
|
|
|
|
|
|
|
setItemSelected(3, True);
|
|
|
|
setItemSelected(4, False);
|
|
|
|
|
2002-04-11 03:20:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BScreen::RightLeft:
|
2002-05-25 00:29:44 +00:00
|
|
|
getScreen()->saveRowPlacementDirection(BScreen::RightLeft);
|
|
|
|
|
|
|
|
setItemSelected(3, False);
|
|
|
|
setItemSelected(4, True);
|
|
|
|
|
2002-04-11 03:20:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BScreen::TopBottom:
|
2002-05-25 00:29:44 +00:00
|
|
|
getScreen()->saveColPlacementDirection(BScreen::TopBottom);
|
|
|
|
|
|
|
|
setItemSelected(5, True);
|
|
|
|
setItemSelected(6, False);
|
|
|
|
|
2002-04-11 03:20:38 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case BScreen::BottomTop:
|
2002-05-25 00:29:44 +00:00
|
|
|
getScreen()->saveColPlacementDirection(BScreen::BottomTop);
|
|
|
|
|
|
|
|
setItemSelected(5, False);
|
|
|
|
setItemSelected(6, True);
|
|
|
|
|
2002-04-11 03:20:38 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|