2 // Copyright (c) 2001 Sean 'Shaleh' Perry <shaleh@debian.org>
3 // Copyright (c) 1997 - 2000 Brad Hughes (bhughes@tcac.net)
5 // Permission is hereby granted, free of charge, to any person obtaining a
6 // copy of this software and associated documentation files (the "Software"),
7 // to deal in the Software without restriction, including without limitation
8 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 // and/or sell copies of the Software, and to permit persons to whom the
10 // Software is furnished to do so, subject to the following conditions:
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 // DEALINGS IN THE SOFTWARE.
23 // stupid macros needed to access some functions in version 2 of the GNU C
30 # include "../config.h"
31 #endif // HAVE_CONFIG_H
35 #include <X11/keysym.h>
48 Slit::Slit(BScreen
&scr
, Resource
&conf
) : openbox(scr
.getOpenbox()),
49 screen(scr
), config(conf
)
53 display
= screen
.getBaseDisplay().getXDisplay();
54 frame
.window
= frame
.pixmap
= None
;
56 timer
= new BTimer(openbox
, *this);
57 timer
->setTimeout(openbox
.getAutoRaiseDelay());
58 timer
->fireOnce(True
);
60 slitmenu
= new Slitmenu(*this);
62 XSetWindowAttributes attrib
;
63 unsigned long create_mask
= CWBackPixmap
| CWBackPixel
| CWBorderPixel
|
64 CWColormap
| CWOverrideRedirect
| CWEventMask
;
65 attrib
.background_pixmap
= None
;
66 attrib
.background_pixel
= attrib
.border_pixel
=
67 screen
.getBorderColor()->getPixel();
68 attrib
.colormap
= screen
.getColormap();
69 attrib
.override_redirect
= True
;
70 attrib
.event_mask
= SubstructureRedirectMask
| ButtonPressMask
|
71 EnterWindowMask
| LeaveWindowMask
;
73 frame
.area
= Rect(0, 0, 1, 1);
76 XCreateWindow(display
, screen
.getRootWindow(),
77 frame
.area
.x(), frame
.area
.y(),
78 frame
.area
.w(), frame
.area
.h(), screen
.getBorderWidth(),
79 screen
.getDepth(), InputOutput
, screen
.getVisual(),
80 create_mask
, &attrib
);
81 openbox
.saveSlitSearch(frame
.window
, this);
90 if (timer
->isTiming()) timer
->stop();
97 screen
.getImageControl()->removeImage(frame
.pixmap
);
99 openbox
.removeSlitSearch(frame
.window
);
101 XDestroyWindow(display
, frame
.window
);
107 void Slit::addClient(Window w
) {
110 if (openbox
.validateWindow(w
)) {
111 SlitClient
*client
= new SlitClient
;
112 client
->client_window
= w
;
114 XWMHints
*wmhints
= XGetWMHints(display
, w
);
117 if ((wmhints
->flags
& IconWindowHint
) &&
118 (wmhints
->icon_window
!= None
)) {
119 XMoveWindow(display
, client
->client_window
, screen
.size().w() + 10,
120 screen
.size().h() + 10);
121 XMapWindow(display
, client
->client_window
);
123 client
->icon_window
= wmhints
->icon_window
;
124 client
->window
= client
->icon_window
;
126 client
->icon_window
= None
;
127 client
->window
= client
->client_window
;
132 client
->icon_window
= None
;
133 client
->window
= client
->client_window
;
136 XWindowAttributes attrib
;
137 if (XGetWindowAttributes(display
, client
->window
, &attrib
)) {
138 client
->width
= attrib
.width
;
139 client
->height
= attrib
.height
;
141 client
->width
= client
->height
= 64;
144 XSetWindowBorderWidth(display
, client
->window
, 0);
146 XSelectInput(display
, frame
.window
, NoEventMask
);
147 XSelectInput(display
, client
->window
, NoEventMask
);
149 XReparentWindow(display
, client
->window
, frame
.window
, 0, 0);
150 XMapRaised(display
, client
->window
);
151 XChangeSaveSet(display
, client
->window
, SetModeInsert
);
153 XSelectInput(display
, frame
.window
, SubstructureRedirectMask
|
154 ButtonPressMask
| EnterWindowMask
| LeaveWindowMask
);
155 XSelectInput(display
, client
->window
, StructureNotifyMask
|
156 SubstructureNotifyMask
| EnterWindowMask
);
159 clientList
.push_back(client
);
161 openbox
.saveSlitSearch(client
->client_window
, this);
162 openbox
.saveSlitSearch(client
->icon_window
, this);
170 void Slit::removeClient(SlitClient
*client
, Bool remap
) {
171 openbox
.removeSlitSearch(client
->client_window
);
172 openbox
.removeSlitSearch(client
->icon_window
);
174 clientList
.remove(client
);
176 screen
.removeNetizen(client
->window
);
178 if (remap
&& openbox
.validateWindow(client
->window
)) {
179 XSelectInput(display
, frame
.window
, NoEventMask
);
180 XSelectInput(display
, client
->window
, NoEventMask
);
181 XReparentWindow(display
, client
->window
, screen
.getRootWindow(),
182 client
->x
, client
->y
);
183 XChangeSaveSet(display
, client
->window
, SetModeDelete
);
184 XSelectInput(display
, frame
.window
, SubstructureRedirectMask
|
185 ButtonPressMask
| EnterWindowMask
| LeaveWindowMask
);
190 client
= (SlitClient
*) 0;
194 void Slit::removeClient(Window w
, Bool remap
) {
199 slitClientList::iterator it
;
200 for (it
= clientList
.begin(); it
!= clientList
.end(); it
++)
201 if ((*it
)->window
== w
) {
202 removeClient(*it
, remap
);
213 void Slit::setOnTop(bool b
) {
216 s
<< "session.screen" << screen
.getScreenNumber() << ".slit.onTop" << ends
;
217 config
.setValue(s
.str(), m_ontop
? "True" : "False");
218 s
.rdbuf()->freeze(0);
221 void Slit::setAutoHide(bool b
) {
224 s
<< "session.screen" << screen
.getScreenNumber() << ".slit.autoHide" << ends
;
225 config
.setValue(s
.str(), m_autohide
? "True" : "False");
226 s
.rdbuf()->freeze(0);
229 void Slit::setPlacement(int p
) {
232 s
<< "session.screen" << screen
.getScreenNumber() << ".slit.placement"
234 const char *placement
;
235 switch (m_placement
) {
236 case TopLeft
: placement
= "TopLeft"; break;
237 case CenterLeft
: placement
= "CenterLeft"; break;
238 case BottomLeft
: placement
= "BottomLeft"; break;
239 case TopCenter
: placement
= "TopCenter"; break;
240 case BottomCenter
: placement
= "BottomCenter"; break;
241 case TopRight
: placement
= "TopRight"; break;
242 case BottomRight
: placement
= "BottomRight"; break;
243 case CenterRight
: default: placement
= "CenterRight"; break;
245 config
.setValue(s
.str(), placement
);
246 s
.rdbuf()->freeze(0);
249 void Slit::setDirection(int d
) {
252 s
<< "session.screen" << screen
.getScreenNumber() << ".slit.direction"
254 config
.setValue(s
.str(),
255 m_direction
== Horizontal
? "Horizontal" : "Vertical");
256 s
.rdbuf()->freeze(0);
261 setAutoHide(m_autohide
);
262 setPlacement(m_placement
);
263 setDirection(m_direction
);
267 std::ostrstream rscreen
, rname
, rclass
;
270 rscreen
<< "session.screen" << screen
.getScreenNumber() << '.' << ends
;
272 rname
<< rscreen
.str() << "slit.placement" << ends
;
273 rclass
<< rscreen
.str() << "Slit.Placement" << ends
;
274 if (config
.getValue(rname
.str(), rclass
.str(), s
)) {
275 if (0 == strncasecmp(s
.c_str(), "TopLeft", s
.length()))
276 m_placement
= TopLeft
;
277 else if (0 == strncasecmp(s
.c_str(), "CenterLeft", s
.length()))
278 m_placement
= CenterLeft
;
279 else if (0 == strncasecmp(s
.c_str(), "BottomLeft", s
.length()))
280 m_placement
= BottomLeft
;
281 else if (0 == strncasecmp(s
.c_str(), "TopCenter", s
.length()))
282 m_placement
= TopCenter
;
283 else if (0 == strncasecmp(s
.c_str(), "BottomCenter", s
.length()))
284 m_placement
= BottomCenter
;
285 else if (0 == strncasecmp(s
.c_str(), "TopRight", s
.length()))
286 m_placement
= TopRight
;
287 else if (0 == strncasecmp(s
.c_str(), "BottomRight", s
.length()))
288 m_placement
= BottomRight
;
289 else if (0 == strncasecmp(s
.c_str(), "CenterRight", s
.length()))
290 m_placement
= CenterRight
;
292 m_placement
= CenterRight
;
294 rname
.seekp(0); rclass
.seekp(0);
295 rname
.rdbuf()->freeze(0); rclass
.rdbuf()->freeze(0);
296 rname
<< rscreen
.str() << "slit.direction" << ends
;
297 rclass
<< rscreen
.str() << "Slit.Direction" << ends
;
298 if (config
.getValue(rname
.str(), rclass
.str(), s
)) {
299 if (0 == strncasecmp(s
.c_str(), "Horizontal", s
.length()))
300 m_direction
= Horizontal
;
301 else if (0 == strncasecmp(s
.c_str(), "Vertical", s
.length()))
302 m_direction
= Vertical
;
304 m_direction
= Vertical
;
306 rname
.seekp(0); rclass
.seekp(0);
307 rname
.rdbuf()->freeze(0); rclass
.rdbuf()->freeze(0);
308 rname
<< rscreen
.str() << "slit.onTop" << ends
;
309 rclass
<< rscreen
.str() << "Slit.OnTop" << ends
;
310 if (config
.getValue(rname
.str(), rclass
.str(), b
))
315 rname
.seekp(0); rclass
.seekp(0);
316 rname
.rdbuf()->freeze(0); rclass
.rdbuf()->freeze(0);
317 rname
<< rscreen
.str() << "slit.autoHide" << ends
;
318 rclass
<< rscreen
.str() << "Slit.AutoHide" << ends
;
319 if (config
.getValue(rname
.str(), rclass
.str(), b
))
320 m_hidden
= m_autohide
= b
;
322 m_hidden
= m_autohide
= false;
324 rscreen
.rdbuf()->freeze(0);
325 rname
.rdbuf()->freeze(0); rclass
.rdbuf()->freeze(0);
328 void Slit::reconfigure(void) {
329 frame
.area
.setSize(0, 0);
330 slitClientList::const_iterator it
;
332 switch (m_direction
) {
334 for (it
= clientList
.begin(); it
!= clientList
.end(); it
++) {
335 frame
.area
.setH(frame
.area
.h() + (*it
)->height
+ screen
.getBevelWidth());
337 if (frame
.area
.w() < (*it
)->width
)
338 frame
.area
.setW((*it
)->width
);
341 if (frame
.area
.w() < 1)
344 frame
.area
.setW(frame
.area
.w() + (screen
.getBevelWidth() * 2));
346 if (frame
.area
.h() < 1)
349 frame
.area
.setH(frame
.area
.h() + screen
.getBevelWidth());
354 for (it
= clientList
.begin(); it
!= clientList
.end(); it
++) {
355 frame
.area
.setW(frame
.area
.w() + (*it
)->width
+ screen
.getBevelWidth());
357 if (frame
.area
.h() < (*it
)->height
)
358 frame
.area
.setH((*it
)->height
);
361 if (frame
.area
.w() < 1)
364 frame
.area
.setW(frame
.area
.w() + screen
.getBevelWidth());
366 if (frame
.area
.h() < 1)
369 frame
.area
.setH(frame
.area
.h() + (screen
.getBevelWidth() * 2));
376 XSetWindowBorderWidth(display
,frame
.window
, screen
.getBorderWidth());
377 XSetWindowBorder(display
, frame
.window
,
378 screen
.getBorderColor()->getPixel());
380 if (! clientList
.size())
381 XUnmapWindow(display
, frame
.window
);
383 XMapWindow(display
, frame
.window
);
385 Pixmap tmp
= frame
.pixmap
;
386 BImageControl
*image_ctrl
= screen
.getImageControl();
387 BTexture
*texture
= &(screen
.getToolbarStyle()->toolbar
);
388 if (texture
->getTexture() == (BImage_Flat
| BImage_Solid
)) {
390 XSetWindowBackground(display
, frame
.window
,
391 texture
->getColor()->getPixel());
393 frame
.pixmap
= image_ctrl
->renderImage(frame
.area
.w(), frame
.area
.h(),
395 XSetWindowBackgroundPixmap(display
, frame
.window
, frame
.pixmap
);
397 if (tmp
) image_ctrl
->removeImage(tmp
);
398 XClearWindow(display
, frame
.window
);
402 switch (m_direction
) {
405 y
= screen
.getBevelWidth();
407 for (it
= clientList
.begin(); it
!= clientList
.end(); it
++) {
408 x
= (frame
.area
.w() - (*it
)->width
) / 2;
410 XMoveResizeWindow(display
, (*it
)->window
, x
, y
,
411 (*it
)->width
, (*it
)->height
);
412 XMapWindow(display
, (*it
)->window
);
414 // for ICCCM compliance
419 event
.type
= ConfigureNotify
;
421 event
.xconfigure
.display
= display
;
422 event
.xconfigure
.event
= (*it
)->window
;
423 event
.xconfigure
.window
= (*it
)->window
;
424 event
.xconfigure
.x
= x
;
425 event
.xconfigure
.y
= y
;
426 event
.xconfigure
.width
= (*it
)->width
;
427 event
.xconfigure
.height
= (*it
)->height
;
428 event
.xconfigure
.border_width
= 0;
429 event
.xconfigure
.above
= frame
.window
;
430 event
.xconfigure
.override_redirect
= False
;
432 XSendEvent(display
, (*it
)->window
, False
, StructureNotifyMask
, &event
);
434 y
+= (*it
)->height
+ screen
.getBevelWidth();
440 x
= screen
.getBevelWidth();
443 for (it
= clientList
.begin(); it
!= clientList
.end(); it
++) {
444 y
= (frame
.area
.h() - (*it
)->height
) / 2;
446 XMoveResizeWindow(display
, (*it
)->window
, x
, y
,
447 (*it
)->width
, (*it
)->height
);
448 XMapWindow(display
, (*it
)->window
);
450 // for ICCCM compliance
455 event
.type
= ConfigureNotify
;
457 event
.xconfigure
.display
= display
;
458 event
.xconfigure
.event
= (*it
)->window
;
459 event
.xconfigure
.window
= (*it
)->window
;
460 event
.xconfigure
.x
= x
;
461 event
.xconfigure
.y
= y
;
462 event
.xconfigure
.width
= (*it
)->width
;
463 event
.xconfigure
.height
= (*it
)->height
;
464 event
.xconfigure
.border_width
= 0;
465 event
.xconfigure
.above
= frame
.window
;
466 event
.xconfigure
.override_redirect
= False
;
468 XSendEvent(display
, (*it
)->window
, False
, StructureNotifyMask
, &event
);
470 x
+= (*it
)->width
+ screen
.getBevelWidth();
476 slitmenu
->reconfigure();
480 void Slit::reposition(void) {
481 // place the slit in the appropriate place
482 switch (m_placement
) {
484 frame
.area
.setOrigin(0, 0);
485 if (m_direction
== Vertical
) {
486 frame
.hidden
= Point(screen
.getBevelWidth() - screen
.getBorderWidth()
487 - frame
.area
.w(), 0);
489 frame
.hidden
= Point(0, screen
.getBevelWidth() - screen
.getBorderWidth()
495 frame
.area
.setOrigin(0, (screen
.size().h() - frame
.area
.h()) / 2);
496 frame
.hidden
= Point(screen
.getBevelWidth() - screen
.getBorderWidth()
497 - frame
.area
.w(), frame
.area
.y());
501 frame
.area
.setOrigin(0, screen
.size().h() - frame
.area
.h()
502 - (screen
.getBorderWidth() * 2));
503 if (m_direction
== Vertical
)
504 frame
.hidden
= Point(screen
.getBevelWidth() - screen
.getBorderWidth()
505 - frame
.area
.w(), frame
.area
.y());
507 frame
.hidden
= Point(0, screen
.size().h() - screen
.getBevelWidth()
508 - screen
.getBorderWidth());
512 frame
.area
.setOrigin((screen
.size().w() - frame
.area
.w()) / 2, 0);
513 frame
.hidden
= Point(frame
.area
.x(), screen
.getBevelWidth()
514 - screen
.getBorderWidth() - frame
.area
.h());
518 frame
.area
.setOrigin((screen
.size().w() - frame
.area
.w()) / 2,
519 screen
.size().h() - frame
.area
.h()
520 - (screen
.getBorderWidth() * 2));
521 frame
.hidden
= Point(frame
.area
.x(), screen
.size().h()
522 - screen
.getBevelWidth() - screen
.getBorderWidth());
526 frame
.area
.setOrigin(screen
.size().w() - frame
.area
.w()
527 - (screen
.getBorderWidth() * 2), 0);
528 if (m_direction
== Vertical
)
529 frame
.hidden
= Point(screen
.size().w() - screen
.getBevelWidth()
530 - screen
.getBorderWidth(), 0);
532 frame
.hidden
= Point(frame
.area
.x(), screen
.getBevelWidth()
533 - screen
.getBorderWidth() - frame
.area
.h());
538 frame
.area
.setOrigin(screen
.size().w() - frame
.area
.w()
539 - (screen
.getBorderWidth() * 2),
540 (screen
.size().h() - frame
.area
.h()) / 2);
541 frame
.hidden
= Point(screen
.size().w() - screen
.getBevelWidth()
542 - screen
.getBorderWidth(), frame
.area
.y());
546 frame
.area
.setOrigin(screen
.size().w() - frame
.area
.w()
547 - (screen
.getBorderWidth() * 2),
548 screen
.size().h() - frame
.area
.h()
549 - (screen
.getBorderWidth() * 2));
550 if (m_direction
== Vertical
)
551 frame
.hidden
= Point(screen
.size().w() - screen
.getBevelWidth()
552 - screen
.getBorderWidth(), frame
.area
.y());
554 frame
.hidden
= Point(frame
.area
.x(), screen
.size().h() -
555 screen
.getBevelWidth() - screen
.getBorderWidth());
559 Toolbar
*tbar
= screen
.getToolbar();
560 int sw
= frame
.area
.w() + (screen
.getBorderWidth() * 2),
561 sh
= frame
.area
.h() + (screen
.getBorderWidth() * 2),
562 tw
= tbar
->area().w() + screen
.getBorderWidth(),
563 th
= tbar
->area().h() + screen
.getBorderWidth();
565 if (tbar
->area().x() < frame
.area
.x() + sw
&&
566 tbar
->area().x() + tw
> frame
.area
.x() &&
567 tbar
->area().y() < frame
.area
.y() + sh
&&
568 tbar
->area().y() + th
> frame
.area
.y()) {
569 if (frame
.area
.y() < th
) {
570 frame
.area
.setY(frame
.area
.y() + tbar
->getExposedHeight());
571 if (m_direction
== Vertical
)
572 frame
.hidden
.setY(frame
.hidden
.y() + tbar
->getExposedHeight());
574 frame
.hidden
.setY(frame
.area
.y());
576 frame
.area
.setY(frame
.area
.y() - tbar
->getExposedHeight());
577 if (m_direction
== Vertical
)
578 frame
.hidden
.setY(frame
.area
.y() - tbar
->getExposedHeight());
580 frame
.hidden
.setY(frame
.area
.y());
585 XMoveResizeWindow(display
, frame
.window
, frame
.hidden
.x(),
586 frame
.hidden
.y(), frame
.area
.w(), frame
.area
.h());
588 XMoveResizeWindow(display
, frame
.window
, frame
.area
.x(),
589 frame
.area
.y(), frame
.area
.w(), frame
.area
.h());
593 void Slit::shutdown(void) {
594 while (clientList
.size())
595 removeClient(clientList
.front());
599 void Slit::buttonPressEvent(XButtonEvent
*e
) {
600 if (e
->window
!= frame
.window
) return;
602 if (e
->button
== Button1
&& !m_ontop
) {
603 Window w
[1] = { frame
.window
};
604 screen
.raiseWindows(w
, 1);
605 } else if (e
->button
== Button2
&& !m_ontop
) {
606 XLowerWindow(display
, frame
.window
);
607 } else if (e
->button
== Button3
) {
608 if (! slitmenu
->isVisible()) {
611 x
= e
->x_root
- (slitmenu
->getWidth() / 2);
612 y
= e
->y_root
- (slitmenu
->getHeight() / 2);
616 else if (x
+ slitmenu
->getWidth() > screen
.size().w())
617 x
= screen
.size().w() - slitmenu
->getWidth();
621 else if (y
+ slitmenu
->getHeight() > screen
.size().h())
622 y
= screen
.size().h() - slitmenu
->getHeight();
624 slitmenu
->move(x
, y
);
633 void Slit::enterNotifyEvent(XCrossingEvent
*) {
638 if (! timer
->isTiming()) timer
->start();
640 if (timer
->isTiming()) timer
->stop();
645 void Slit::leaveNotifyEvent(XCrossingEvent
*) {
650 if (timer
->isTiming()) timer
->stop();
651 } else if (! slitmenu
->isVisible()) {
652 if (!timer
->isTiming()) timer
->start();
657 void Slit::configureRequestEvent(XConfigureRequestEvent
*e
) {
660 if (openbox
.validateWindow(e
->window
)) {
666 xwc
.width
= e
->width
;
667 xwc
.height
= e
->height
;
668 xwc
.border_width
= 0;
669 xwc
.sibling
= e
->above
;
670 xwc
.stack_mode
= e
->detail
;
672 XConfigureWindow(display
, e
->window
, e
->value_mask
, &xwc
);
674 slitClientList::iterator it
= clientList
.begin();
675 for (; it
!= clientList
.end(); it
++) {
676 SlitClient
*client
= *it
;
677 if (client
->window
== e
->window
)
678 if (client
->width
!= ((unsigned) e
->width
) ||
679 client
->height
!= ((unsigned) e
->height
)) {
680 client
->width
= (unsigned) e
->width
;
681 client
->height
= (unsigned) e
->height
;
694 void Slit::timeout(void) {
695 m_hidden
= !m_hidden
;
697 XMoveWindow(display
, frame
.window
, frame
.hidden
.x(), frame
.hidden
.y());
699 XMoveWindow(display
, frame
.window
, frame
.area
.x(), frame
.area
.y());
703 Slitmenu::Slitmenu(Slit
&sl
) : Basemenu(sl
.screen
), slit(sl
) {
704 setLabel(i18n
->getMessage(SlitSet
, SlitSlitTitle
, "Slit"));
707 directionmenu
= new Directionmenu(*this);
708 placementmenu
= new Placementmenu(*this);
710 insert(i18n
->getMessage(CommonSet
, CommonDirectionTitle
, "Direction"),
712 insert(i18n
->getMessage(CommonSet
, CommonPlacementTitle
, "Placement"),
714 insert(i18n
->getMessage(CommonSet
, CommonAlwaysOnTop
, "Always on top"), 1);
715 insert(i18n
->getMessage(CommonSet
, CommonAutoHide
, "Auto hide"), 2);
722 void Slitmenu::setValues() {
723 setItemSelected(2, slit
.onTop());
724 setItemSelected(3, slit
.autoHide());
728 Slitmenu::~Slitmenu(void) {
729 delete directionmenu
;
730 delete placementmenu
;
734 void Slitmenu::itemSelected(int button
, int index
) {
738 BasemenuItem
*item
= find(index
);
741 switch (item
->function()) {
742 case 1: { // always on top
743 bool change
= ((slit
.onTop()) ? false : true);
744 slit
.setOnTop(change
);
745 setItemSelected(2, change
);
747 if (slit
.onTop()) slit
.screen
.raiseWindows((Window
*) 0, 0);
751 case 2: { // auto hide
752 Bool change
= ((slit
.autoHide()) ? false : true);
753 slit
.setAutoHide(change
);
754 setItemSelected(3, change
);
762 void Slitmenu::internal_hide(void) {
763 Basemenu::internal_hide();
769 void Slitmenu::reconfigure(void) {
771 directionmenu
->reconfigure();
772 placementmenu
->reconfigure();
774 Basemenu::reconfigure();
778 Slitmenu::Directionmenu::Directionmenu(Slitmenu
&sm
)
779 : Basemenu(sm
.slit
.screen
), slitmenu(sm
) {
780 setLabel(i18n
->getMessage(SlitSet
, SlitSlitDirection
, "Slit Direction"));
783 insert(i18n
->getMessage(CommonSet
, CommonDirectionHoriz
, "Horizontal"),
785 insert(i18n
->getMessage(CommonSet
, CommonDirectionVert
, "Vertical"),
794 void Slitmenu::Directionmenu::setValues() {
795 if (slitmenu
.slit
.direction() == Slit::Horizontal
)
796 setItemSelected(0, True
);
798 setItemSelected(1, True
);
801 void Slitmenu::Directionmenu::reconfigure() {
806 void Slitmenu::Directionmenu::itemSelected(int button
, int index
) {
810 BasemenuItem
*item
= find(index
);
813 slitmenu
.slit
.setDirection(item
->function());
815 if (item
->function() == Slit::Horizontal
) {
816 setItemSelected(0, True
);
817 setItemSelected(1, False
);
819 setItemSelected(0, False
);
820 setItemSelected(1, True
);
824 slitmenu
.slit
.reconfigure();
828 Slitmenu::Placementmenu::Placementmenu(Slitmenu
&sm
)
829 : Basemenu(sm
.slit
.screen
), slitmenu(sm
) {
831 setLabel(i18n
->getMessage(SlitSet
, SlitSlitPlacement
, "Slit Placement"));
832 setMinimumSublevels(3);
835 insert(i18n
->getMessage(CommonSet
, CommonPlacementTopLeft
, "Top Left"),
837 insert(i18n
->getMessage(CommonSet
, CommonPlacementCenterLeft
, "Center Left"),
839 insert(i18n
->getMessage(CommonSet
, CommonPlacementBottomLeft
, "Bottom Left"),
841 insert(i18n
->getMessage(CommonSet
, CommonPlacementTopCenter
, "Top Center"),
844 insert(i18n
->getMessage(CommonSet
, CommonPlacementBottomCenter
,
847 insert(i18n
->getMessage(CommonSet
, CommonPlacementTopRight
, "Top Right"),
849 insert(i18n
->getMessage(CommonSet
, CommonPlacementCenterRight
,
852 insert(i18n
->getMessage(CommonSet
, CommonPlacementBottomRight
,
860 void Slitmenu::Placementmenu::itemSelected(int button
, int index
) {
864 BasemenuItem
*item
= find(index
);
865 if (! (item
&& item
->function())) return;
867 slitmenu
.slit
.setPlacement(item
->function());
869 slitmenu
.slit
.reconfigure();