]> icculus.org git repositories - mikachu/openbox.git/blob - otk/otk_test.cc
erm
[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
27   foo.resize(600, 500);
28   foo.setTexture(my_style->getTitleFocus());
29   foo.setUnfocusTexture(my_style->getTitleUnfocus());
30
31   foo.setBevelWidth(2);
32   foo.setDirection(otk::OtkWidget::Horizontal);
33
34   otk::OtkFocusWidget left(&foo);
35   otk::OtkFocusWidget right(&foo);
36
37   left.setDirection(otk::OtkWidget::Horizontal);
38   left.setStretchableVert(true);
39   left.setStretchableHorz(true);
40   left.setTexture(my_style->getTitleFocus());
41   left.setUnfocusTexture(my_style->getTitleUnfocus());
42  
43   right.setDirection(otk::OtkWidget::Vertical);
44   right.setBevelWidth(10);
45   right.setStretchableVert(true);
46   right.setWidth(300);
47   right.setTexture(my_style->getTitleFocus());
48   right.setUnfocusTexture(my_style->getTitleUnfocus());
49
50   otk::OtkButton iconb(&left);
51   otk::OtkFocusWidget label(&left);
52   otk::OtkButton maxb(&left);
53   otk::OtkButton closeb(&left);
54   
55   // fixed size
56   iconb.setText("foo");
57   iconb.press();
58
59   // fix width to 60 and let the height be calculated by its parent
60   //label.setHeight(20);
61   label.setStretchableVert(true);
62   label.setStretchableHorz(true);
63   label.setTexture(my_style->getLabelFocus());
64   label.setUnfocusTexture(my_style->getLabelUnfocus());
65
66   // fixed size
67   maxb.setText("bar");
68
69   // fixed size
70   closeb.setText("fuubar");
71
72   otk::OtkFocusWidget rblef(&right);
73   otk::OtkButton rbutt1(&right);
74   otk::OtkButton rbutt2(&right);
75
76   rblef.setStretchableHorz(true);
77   rblef.setHeight(50);
78   rblef.setTexture(my_style->getHandleFocus());
79   rblef.setUnfocusTexture(my_style->getHandleUnfocus());
80   
81   rbutt1.setText("this is fucking tight");
82   rbutt2.setText("heh, WOOP");
83
84   // will recursively unfocus its children
85   //foo.unfocus();
86   foo.update();
87   foo.show();
88
89   while (1) {
90     if (XPending(otk::OBDisplay::display)) {
91       XEvent e;
92       XNextEvent(otk::OBDisplay::display, &e);
93       if (e.type == Expose) {
94         foo.expose(e.xexpose);
95       } else if (e.type == ConfigureNotify) {
96         foo.configure(e.xconfigure);
97       }
98     } 
99   }
100
101   delete my_style;
102   delete tm;
103   delete ctrl;
104
105   otk::OBDisplay::destroy();
106
107   return 0;
108 }