annotate src/ui.hh @ 0:6ee11bf9e3ea

Initial revision
author jcid
date Sun, 07 Oct 2007 00:36:34 +0200
parents
children 571f09e42ab6
rev   line source
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1 #ifndef __UI_HH__
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
2 #define __UI_HH__
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
3
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
4 // UI for dillo --------------------------------------------------------------
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
5
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
6 #include <fltk/Window.h>
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
7 #include <fltk/Widget.h>
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
8 #include <fltk/Button.h>
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
9 #include <fltk/Input.h>
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
10 #include <fltk/PackedGroup.h>
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
11 #include <fltk/Output.h>
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
12 #include <fltk/xpmImage.h>
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
13
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
14 using namespace fltk;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
15
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
16 // Panel sizes
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
17 enum { P_tiny = 0, P_small, P_medium, P_large };
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
18
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
19 typedef enum {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
20 UI_BACK = 0,
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
21 UI_FORW,
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
22 UI_HOME,
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
23 UI_RELOAD,
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
24 UI_SAVE,
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
25 UI_STOP,
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
26 UI_BOOK,
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
27 UI_CLEAR,
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
28 UI_SEARCH
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
29 } UIButton;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
30
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
31 //
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
32 // UI class definition -------------------------------------------------------
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
33 //
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
34 class UI : public fltk::Window {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
35 Group *TopGroup;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
36 Button *Back, *Forw, *Home, *Reload, *Save, *Stop, *Bookmarks,
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
37 *Clear, *Search, *FullScreen, *BugMeter;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
38 Input *Location;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
39 Widget *PProg, *IProg;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
40 Image *ImgLeftIns, *ImgLeftSens, *ImgRightIns, *ImgRightSens,
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
41 *ImgStopIns, *ImgStopSens, *ImgFullScreenOn, *ImgFullScreenOff,
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
42 *ImgMeterOK, *ImgMeterBug;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
43 Group *Panel, *StatusPanel;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
44 Widget *Main;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
45 Output *Status;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
46
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
47 int MainIdx;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
48 // Panel customization variables
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
49 int PanelSize, CuteColor, Small_Icons;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
50 int xpos, bw, bh, fh, lh, lbl, pr_w;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
51
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
52 // TODO: Hack for fullscreen mode
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
53 int Panel_h, Status_h;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
54
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
55 PackedGroup *make_toolbar(int tw, int th);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
56 PackedGroup *make_location();
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
57 PackedGroup *make_progress_bars(int wide, int thin_up);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
58 Group *make_menu(int tiny);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
59 Group *make_panel(int ww);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
60
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
61
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
62 public:
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
63
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
64 UI(int w, int h, const char* label = 0);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
65 ~UI() {} // TODO: implement destructor
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
66
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
67 // To manage what events to catch and which to let pass
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
68 int handle(int event);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
69
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
70 const char *get_location();
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
71 void set_location(const char *str);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
72 void focus_location();
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
73 void set_status(const char *str);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
74 void set_page_prog(size_t nbytes, int cmd);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
75 void set_img_prog(int n_img, int t_img, int cmd);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
76 void set_bug_prog(int n_bug);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
77 void set_render_layout(Widget &nw);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
78 void set_page_title(const char *label);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
79 void customize(int flags);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
80 void button_set_sens(UIButton btn, int sens);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
81 void paste_url();
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
82
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
83 // Workaround functions for a non-working replace() in FLTK2
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
84 void set_render_layout_begin() {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
85 TopGroup->remove(MainIdx);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
86 TopGroup->remove(TopGroup->find(StatusPanel));
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
87 delete(Main);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
88 Main = NULL;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
89 TopGroup->begin();
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
90 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
91 void set_render_layout_end() {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
92 TopGroup->resizable(TopGroup->child(MainIdx));
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
93 Main = TopGroup->child(MainIdx);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
94 TopGroup->add(*StatusPanel);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
95 TopGroup->end();
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
96 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
97 int panel_h() { return Panel->h(); };
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
98 int status_h() { return Status->h(); };
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
99 Widget *fullscreen_button() { return FullScreen; }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
100 void fullscreen_toggle() { FullScreen->do_callback(); }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
101
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
102 // Hooks to method callbacks
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
103 void panel_cb_i();
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
104 void color_change_cb_i();
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
105 void toggle_cb_i();
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
106 void fullscreen_cb_i();
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
107 };
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
108
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
109 #endif // __UI_HH__