]> Dogcows Code - chaz/openbox/blob - otk/application.cc
add rendercolor class, with a cache of gcs for the colors
[chaz/openbox] / otk / application.cc
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
2
3 #ifdef HAVE_CONFIG_H
4 # include "../config.h"
5 #endif
6
7 #include "application.hh"
8 #include "eventhandler.hh"
9 #include "widget.hh"
10 #include "timer.hh"
11 #include "property.hh"
12 #include "rendercolor.hh"
13
14 extern "C" {
15 #ifdef HAVE_STDLIB_H
16 # include <stdlib.h>
17 #endif
18 }
19
20 #include <iostream>
21
22 namespace otk {
23
24 Application::Application(int argc, char **argv)
25 : EventDispatcher(),
26 _display(),
27 _dockable(false),
28 _appwidget_count(0)
29 {
30 (void)argc;
31 (void)argv;
32
33 const ScreenInfo *s_info = _display.screenInfo(DefaultScreen(*_display));
34
35 Timer::initialize();
36 RenderColor::initialize();
37 Property::initialize();
38 _img_ctrl = new ImageControl(s_info, True, 4, 5, 200);
39 _style_conf = new Configuration(False);
40 _style = new Style(_img_ctrl);
41
42 loadStyle();
43 }
44
45 Application::~Application()
46 {
47 delete _style_conf;
48 delete _img_ctrl;
49 delete _style;
50 RenderColor::destroy();
51 Timer::destroy();
52 }
53
54 void Application::loadStyle(void)
55 {
56 // find the style name as a property
57 std::string style = "/usr/local/share/openbox/styles/artwiz";
58 _style_conf->setFile(style);
59 if (!_style_conf->load()) {
60 std::cerr << "ERROR: Unable to load style \"" << style << "\".\n";
61 ::exit(1);
62 }
63 _style->load(*_style_conf);
64 }
65
66 void Application::run(void)
67 {
68 if (_appwidget_count <= 0) {
69 std::cerr << "ERROR: No main widgets exist. You must create and show() " <<
70 "an AppWidget for the Application before calling " <<
71 "Application::run().\n";
72 ::exit(1);
73 }
74
75 while (_appwidget_count > 0) {
76 dispatchEvents();
77 Timer::dispatchTimers(); // fire pending events
78 }
79 }
80
81 }
This page took 0.03828 seconds and 4 git commands to generate.