]> icculus.org git repositories - mikachu/openbox.git/blob - otk/otk_test.cc
it resizes now
[mikachu/openbox.git] / otk / otk_test.cc
1 #include "focuswidget.hh"
2 #include "button.hh"
3 #include "display.hh"
4 #include "configuration.hh"
5 #include "timerqueuemanager.hh"
6 #include "image.hh"
7 #include "style.hh"
8 #include <iostream>
9
10 int main(void) {
11   otk::OBDisplay::initialize(NULL);
12   otk::Configuration style_conf(False);
13   otk::OBTimerQueueManager *tm = new otk::OBTimerQueueManager();
14   const otk::ScreenInfo *s_info =
15     otk::OBDisplay::screenInfo(DefaultScreen(otk::OBDisplay::display));
16   otk::BImageControl *ctrl = new otk::BImageControl(tm, s_info, True, 4, 5, 200);
17
18   otk::Style *my_style = new otk::Style(ctrl);
19
20   style_conf.setFile("/usr/local/share/openbox/styles/artwiz");
21   style_conf.load();
22
23   my_style->load(style_conf);
24
25   otk::OtkFocusWidget foo(my_style);
26   otk::OtkButton iconb(&foo);
27   otk::OtkFocusWidget label(&foo);
28   otk::OtkButton maxb(&foo);
29   otk::OtkButton closeb(&foo);
30
31   foo.setBevelWidth(2);
32   foo.setDirection(otk::OtkWidget::Vertical);
33   
34   foo.setHeight(400);
35   foo.setTexture(my_style->getTitleFocus());
36   foo.setUnfocusTexture(my_style->getTitleUnfocus());
37
38   // fixed size
39   iconb.setText("foo");
40   iconb.press();
41
42   // fix width to 60 and let the height be calculated by its parent
43   label.setWidth(60);
44   label.setStretchableVert(true);
45   label.setTexture(my_style->getLabelFocus());
46   label.setUnfocusTexture(my_style->getLabelUnfocus());
47
48   // fixed size
49   maxb.setText("bar");
50
51   // fixed size
52   closeb.setText("fuubar");
53
54   // will recursively unfocus its children
55   //foo.unfocus();
56   foo.update();
57   foo.show();
58
59   while (1) {
60     if (XPending(otk::OBDisplay::display)) {
61       XEvent e;
62       XNextEvent(otk::OBDisplay::display, &e);
63       if (e.type == Expose) {
64         foo.expose(e.xexpose);
65       } else if (e.type == ConfigureNotify) {
66         foo.configure(e.xconfigure);
67         label.hide();
68       }
69     } 
70   }
71
72   delete my_style;
73   delete tm;
74   delete ctrl;
75
76   otk::OBDisplay::destroy();
77
78   return 0;
79 }