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