view include/App.h @ 4:c6dce2064bfb

Works so far
author Eris Caffee <discordia@eldalin.com>
date Sun, 15 Apr 2012 01:52:09 -0500
parents
children 008e28de2870
line source
1 #include <map>
2 #include <string>
4 #include <X11/Xlib.h>
6 ////////////////////////////////////////////////////////////////////////////////
7 class App
8 {
9 public:
11 /////////////////////////////////////
12 class BitMap
13 {
14 public:
15 BitMap(const std::string & file);
16 ~BitMap();
18 void make_pixmap(Display * dpy, Drawable d);
20 // Yeah, it's all public here. Keeping it simple.
21 std::string name;
22 unsigned int width;
23 unsigned int height;
24 unsigned char * data;
25 Pixmap pixmap;
27 private:
28 BitMap(const App::BitMap & b);
30 int read_from_file(const std::string & file);
31 };
33 /////////////////////////////////////
34 typedef struct
35 {
36 public:
37 std::string name;
38 Window win;
39 App::BitMap * icon;
40 } WindowData;
42 /////////////////////////////////////
44 typedef std::pair<std::string, App::WindowData *> win_pair;
45 typedef std::map<std::string, App::WindowData *> WindowMap;
47 App(const std::string & appname);
48 ~App();
50 static int x_error_handler(Display * dpy, XErrorEvent *err);
52 void create_window(const std::string& win_name,
53 int x, int y,
54 unsigned int width, unsigned int height,
55 App::BitMap * icon);
57 inline int display_height(void) const
58 { return DisplayHeight(dpy, DefaultScreen(dpy)); };
60 inline int display_width(void) const
61 { return DisplayWidth(dpy, DefaultScreen(dpy)); };
63 private:
64 App();
65 App(const App & a);
67 Display * dpy;
68 WindowMap windows;
69 };