1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2 // Slitmenu.cc for Blackbox - an X11 Window Manager
3 // Copyright (c) 2001 - 2005 Sean 'Shaleh' Perry <shaleh@debian.org>
4 // Copyright (c) 1997 - 2000, 2002 - 2005
5 // Bradley T Hughes <bhughes at trolltech.com>
7 // Permission is hereby granted, free of charge, to any person obtaining a
8 // copy of this software and associated documentation files (the "Software"),
9 // to deal in the Software without restriction, including without limitation
10 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 // and/or sell copies of the Software, and to permit persons to whom the
12 // Software is furnished to do so, subject to the following conditions:
14 // The above copyright notice and this permission notice shall be included in
15 // all copies or substantial portions of the Software.
17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 // DEALINGS IN THE SOFTWARE.
25 #include "Slitmenu.hh"
32 class SlitDirectionmenu
: public bt::Menu
{
34 SlitDirectionmenu(bt::Application
&app
, unsigned int screen
,
40 void itemClicked(unsigned int id
, unsigned int button
);
47 class SlitPlacementmenu
: public bt::Menu
{
49 SlitPlacementmenu(bt::Application
&app
, unsigned int screen
,
55 void itemClicked(unsigned int id
, unsigned int button
);
69 Slitmenu::Slitmenu(bt::Application
&app
, unsigned int screen
, BScreen
*bscreen
)
70 : bt::Menu(app
, screen
), _bscreen(bscreen
)
72 setTitle(bt::toUnicode("Slit Options"));
75 insertItem(bt::toUnicode("Direction"), new SlitDirectionmenu(app
, screen
, bscreen
),
77 insertItem(bt::toUnicode("Placement"), new SlitPlacementmenu(app
, screen
, bscreen
),
80 insertItem(bt::toUnicode("Always on top"), AlwaysOnTop
);
81 insertItem(bt::toUnicode("Auto hide"), AutoHide
);
85 void Slitmenu::refresh(void) {
86 const SlitOptions
&options
= _bscreen
->resource().slitOptions();
87 setItemChecked(AlwaysOnTop
, options
.always_on_top
);
88 setItemChecked(AutoHide
, options
.auto_hide
);
92 void Slitmenu::itemClicked(unsigned int id
, unsigned int button
) {
96 Slit
*slit
= _bscreen
->slit();
97 SlitOptions
&options
=
98 const_cast<SlitOptions
&>(_bscreen
->resource().slitOptions());
102 options
.always_on_top
= !options
.always_on_top
;
103 _bscreen
->saveResource();
105 StackingList::Layer new_layer
= (options
.always_on_top
106 ? StackingList::LayerAbove
107 : StackingList::LayerNormal
);
108 _bscreen
->stackingList().changeLayer(slit
, new_layer
);
109 _bscreen
->restackWindows();
114 options
.auto_hide
= !options
.auto_hide
;
115 _bscreen
->saveResource();
117 slit
->toggleAutoHide();
126 SlitDirectionmenu::SlitDirectionmenu(bt::Application
&app
, unsigned int screen
,
128 : bt::Menu(app
, screen
), _bscreen(bscreen
)
130 setTitle(bt::toUnicode("Slit Direction"));
133 insertItem(bt::toUnicode("Horizontal"), Slit::Horizontal
);
134 insertItem(bt::toUnicode("Vertical"), Slit::Vertical
);
138 void SlitDirectionmenu::refresh(void) {
139 const SlitOptions
&options
=_bscreen
->resource().slitOptions();
140 setItemChecked(Slit::Horizontal
, options
.direction
== Slit::Horizontal
);
141 setItemChecked(Slit::Vertical
, options
.direction
== Slit::Vertical
);
145 void SlitDirectionmenu::itemClicked(unsigned int id
, unsigned int button
) {
149 Slit
*slit
= _bscreen
->slit();
150 SlitOptions
&options
=
151 const_cast<SlitOptions
&>(_bscreen
->resource().slitOptions());
153 options
.direction
= id
;
154 _bscreen
->saveResource();
160 SlitPlacementmenu::SlitPlacementmenu(bt::Application
&app
, unsigned int screen
,
162 : bt::Menu(app
, screen
), _bscreen(bscreen
)
164 setTitle(bt::toUnicode("Slit Placement"));
167 insertItem(bt::toUnicode("Top Left"), Slit::TopLeft
);
168 insertItem(bt::toUnicode("Center Left"), Slit::CenterLeft
);
169 insertItem(bt::toUnicode("Bottom Left"), Slit::BottomLeft
);
171 insertItem(bt::toUnicode("Top Center"), Slit::TopCenter
);
172 insertItem(bt::toUnicode("Bottom Center"), Slit::BottomCenter
);
174 insertItem(bt::toUnicode("Top Right"), Slit::TopRight
);
175 insertItem(bt::toUnicode("Center Right"), Slit::CenterRight
);
176 insertItem(bt::toUnicode("Bottom Right"), Slit::BottomRight
);
180 void SlitPlacementmenu::refresh(void) {
181 const SlitOptions
&options
= _bscreen
->resource().slitOptions();
182 setItemChecked(Slit::TopLeft
, options
.placement
== Slit::TopLeft
);
183 setItemChecked(Slit::CenterLeft
, options
.placement
== Slit::CenterLeft
);
184 setItemChecked(Slit::BottomLeft
, options
.placement
== Slit::BottomLeft
);
185 setItemChecked(Slit::TopCenter
, options
.placement
== Slit::TopCenter
);
186 setItemChecked(Slit::BottomCenter
, options
.placement
== Slit::BottomCenter
);
187 setItemChecked(Slit::TopRight
, options
.placement
== Slit::TopRight
);
188 setItemChecked(Slit::CenterRight
, options
.placement
== Slit::CenterRight
);
189 setItemChecked(Slit::BottomRight
, options
.placement
== Slit::BottomRight
);
193 void SlitPlacementmenu::itemClicked(unsigned int id
, unsigned int button
) {
197 Slit
*slit
= _bscreen
->slit();
198 SlitOptions
&options
=
199 const_cast<SlitOptions
&>(_bscreen
->resource().slitOptions());
201 options
.placement
= id
;
202 _bscreen
->saveResource();