annotate src/ui.cc @ 2052:89af8495455f

remove use of Fl_Pack to avoid resizing issues CustGroup is split into CustGroupHorizontal and CustGroupVertical. CustGroupVertical is then used to replace Fl_Pack for TopGroup.
author Johannes Hofmann <Johannes.Hofmann@gmx.de>
date Thu, 26 May 2011 21:12:33 +0200
parents 8f021c978252
children d8eaa1203895
rev   line source
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
2 * File: ui.cc
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
3 *
35
d9e7b35430de Updated copyright lines
jcid
parents: 32
diff changeset
4 * Copyright (C) 2005-2007 Jorge Arellano Cid <jcid@dillo.org>
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
5 *
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
6 * This program is free software; you can redistribute it and/or modify
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
7 * it under the terms of the GNU General Public License as published by
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
8 * the Free Software Foundation; either version 3 of the License, or
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
9 * (at your option) any later version.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
10 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
11
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
12 // UI for Dillo
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
13
1525
3c683905dbe3 Added a help button. It tries a local help file then dillo.org's one.
corvid, jcid
parents: 1343
diff changeset
14 #include <unistd.h>
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
15 #include <stdio.h>
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
16
1064
485acc9e60e2 Added configurable keybindings! (in ~/.dillo/keysrc) # part1
Jorge Arellano Cid <jcid@dillo.org>
parents: 946
diff changeset
17 #include "keys.hh"
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
18 #include "ui.hh"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
19 #include "msg.h"
384
d33b55bb56c9 - Set menubar "close window" items from a timeout
jcid
parents: 383
diff changeset
20 #include "timeout.hh"
1103
94b9265663f6 New utility function: a_Utf8_end_of_char()
corvid <corvid@lavabit.com>
parents: 1102
diff changeset
21 #include "utf8.hh"
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
22
1822
a0ed332132e1 some more src/ui
corvid <corvid@lavabit.com>
parents: 1813
diff changeset
23 #include <FL/Fl.H>
a0ed332132e1 some more src/ui
corvid <corvid@lavabit.com>
parents: 1813
diff changeset
24 #include <FL/Fl_Pixmap.H>
a0ed332132e1 some more src/ui
corvid <corvid@lavabit.com>
parents: 1813
diff changeset
25 #include <FL/Fl_Box.H>
a0ed332132e1 some more src/ui
corvid <corvid@lavabit.com>
parents: 1813
diff changeset
26
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
27 // Include image data
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
28 #include "pixmaps.h"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
29 #include "uicmd.hh"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
30
374
fb3a62d1aab2 - Set UI's to share icons.
jcid
parents: 372
diff changeset
31 struct iconset {
1813
6a203275d317 a bit of src/ui
corvid <corvid@lavabit.com>
parents: 1806
diff changeset
32 Fl_Image *ImgMeterOK, *ImgMeterBug,
6a203275d317 a bit of src/ui
corvid <corvid@lavabit.com>
parents: 1806
diff changeset
33 *ImgHome, *ImgReload, *ImgSave, *ImgBook, *ImgTools,
1842
63bb7eefc5f6 deactivated toolbar buttons
corvid <corvid@lavabit.com>
parents: 1839
diff changeset
34 *ImgClear,*ImgSearch, *ImgHelp, *ImgLeft, *ImgLeftIn,
63bb7eefc5f6 deactivated toolbar buttons
corvid <corvid@lavabit.com>
parents: 1839
diff changeset
35 *ImgRight, *ImgRightIn, *ImgStop, *ImgStopIn;
374
fb3a62d1aab2 - Set UI's to share icons.
jcid
parents: 372
diff changeset
36 };
fb3a62d1aab2 - Set UI's to share icons.
jcid
parents: 372
diff changeset
37
fb3a62d1aab2 - Set UI's to share icons.
jcid
parents: 372
diff changeset
38 static struct iconset standard_icons = {
1822
a0ed332132e1 some more src/ui
corvid <corvid@lavabit.com>
parents: 1813
diff changeset
39 new Fl_Pixmap(mini_ok_xpm),
a0ed332132e1 some more src/ui
corvid <corvid@lavabit.com>
parents: 1813
diff changeset
40 new Fl_Pixmap(mini_bug_xpm),
a0ed332132e1 some more src/ui
corvid <corvid@lavabit.com>
parents: 1813
diff changeset
41 new Fl_Pixmap(home_xpm),
a0ed332132e1 some more src/ui
corvid <corvid@lavabit.com>
parents: 1813
diff changeset
42 new Fl_Pixmap(reload_xpm),
a0ed332132e1 some more src/ui
corvid <corvid@lavabit.com>
parents: 1813
diff changeset
43 new Fl_Pixmap(save_xpm),
a0ed332132e1 some more src/ui
corvid <corvid@lavabit.com>
parents: 1813
diff changeset
44 new Fl_Pixmap(bm_xpm),
a0ed332132e1 some more src/ui
corvid <corvid@lavabit.com>
parents: 1813
diff changeset
45 new Fl_Pixmap(tools_xpm),
a0ed332132e1 some more src/ui
corvid <corvid@lavabit.com>
parents: 1813
diff changeset
46 new Fl_Pixmap(new_s_xpm),
a0ed332132e1 some more src/ui
corvid <corvid@lavabit.com>
parents: 1813
diff changeset
47 new Fl_Pixmap(search_xpm),
a0ed332132e1 some more src/ui
corvid <corvid@lavabit.com>
parents: 1813
diff changeset
48 new Fl_Pixmap(help_xpm),
a0ed332132e1 some more src/ui
corvid <corvid@lavabit.com>
parents: 1813
diff changeset
49 new Fl_Pixmap(left_xpm),
1842
63bb7eefc5f6 deactivated toolbar buttons
corvid <corvid@lavabit.com>
parents: 1839
diff changeset
50 new Fl_Pixmap(left_i_xpm),
1822
a0ed332132e1 some more src/ui
corvid <corvid@lavabit.com>
parents: 1813
diff changeset
51 new Fl_Pixmap(right_xpm),
1842
63bb7eefc5f6 deactivated toolbar buttons
corvid <corvid@lavabit.com>
parents: 1839
diff changeset
52 new Fl_Pixmap(right_i_xpm),
1822
a0ed332132e1 some more src/ui
corvid <corvid@lavabit.com>
parents: 1813
diff changeset
53 new Fl_Pixmap(stop_xpm),
1842
63bb7eefc5f6 deactivated toolbar buttons
corvid <corvid@lavabit.com>
parents: 1839
diff changeset
54 new Fl_Pixmap(stop_i_xpm),
374
fb3a62d1aab2 - Set UI's to share icons.
jcid
parents: 372
diff changeset
55 };
fb3a62d1aab2 - Set UI's to share icons.
jcid
parents: 372
diff changeset
56
fb3a62d1aab2 - Set UI's to share icons.
jcid
parents: 372
diff changeset
57 static struct iconset small_icons = {
377
e22f6898fa6a - fix 2 for the iconset patch (smallicons)
jcid
parents: 375
diff changeset
58 standard_icons.ImgMeterOK,
e22f6898fa6a - fix 2 for the iconset patch (smallicons)
jcid
parents: 375
diff changeset
59 standard_icons.ImgMeterBug,
1822
a0ed332132e1 some more src/ui
corvid <corvid@lavabit.com>
parents: 1813
diff changeset
60 new Fl_Pixmap(home_s_xpm),
a0ed332132e1 some more src/ui
corvid <corvid@lavabit.com>
parents: 1813
diff changeset
61 new Fl_Pixmap(reload_s_xpm),
a0ed332132e1 some more src/ui
corvid <corvid@lavabit.com>
parents: 1813
diff changeset
62 new Fl_Pixmap(save_s_xpm),
a0ed332132e1 some more src/ui
corvid <corvid@lavabit.com>
parents: 1813
diff changeset
63 new Fl_Pixmap(bm_s_xpm),
a0ed332132e1 some more src/ui
corvid <corvid@lavabit.com>
parents: 1813
diff changeset
64 new Fl_Pixmap(tools_s_xpm),
a0ed332132e1 some more src/ui
corvid <corvid@lavabit.com>
parents: 1813
diff changeset
65 new Fl_Pixmap(new_s_xpm),
377
e22f6898fa6a - fix 2 for the iconset patch (smallicons)
jcid
parents: 375
diff changeset
66 standard_icons.ImgSearch,
1525
3c683905dbe3 Added a help button. It tries a local help file then dillo.org's one.
corvid, jcid
parents: 1343
diff changeset
67 standard_icons.ImgHelp,
1822
a0ed332132e1 some more src/ui
corvid <corvid@lavabit.com>
parents: 1813
diff changeset
68 new Fl_Pixmap(left_s_xpm),
1842
63bb7eefc5f6 deactivated toolbar buttons
corvid <corvid@lavabit.com>
parents: 1839
diff changeset
69 new Fl_Pixmap(left_si_xpm),
63bb7eefc5f6 deactivated toolbar buttons
corvid <corvid@lavabit.com>
parents: 1839
diff changeset
70 new Fl_Pixmap(right_i_xpm),
63bb7eefc5f6 deactivated toolbar buttons
corvid <corvid@lavabit.com>
parents: 1839
diff changeset
71 new Fl_Pixmap(right_si_xpm),
1822
a0ed332132e1 some more src/ui
corvid <corvid@lavabit.com>
parents: 1813
diff changeset
72 new Fl_Pixmap(stop_s_xpm),
1842
63bb7eefc5f6 deactivated toolbar buttons
corvid <corvid@lavabit.com>
parents: 1839
diff changeset
73 new Fl_Pixmap(stop_si_xpm),
374
fb3a62d1aab2 - Set UI's to share icons.
jcid
parents: 372
diff changeset
74 };
fb3a62d1aab2 - Set UI's to share icons.
jcid
parents: 372
diff changeset
75
fb3a62d1aab2 - Set UI's to share icons.
jcid
parents: 372
diff changeset
76
fb3a62d1aab2 - Set UI's to share icons.
jcid
parents: 372
diff changeset
77 static struct iconset *icons = &standard_icons;
fb3a62d1aab2 - Set UI's to share icons.
jcid
parents: 372
diff changeset
78
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
79 /*
382
jcid
parents: 381
diff changeset
80 * Local sub classes
jcid
parents: 381
diff changeset
81 */
jcid
parents: 381
diff changeset
82
jcid
parents: 381
diff changeset
83 //----------------------------------------------------------------------------
jcid
parents: 381
diff changeset
84
jcid
parents: 381
diff changeset
85 /*
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
86 * (Used to avoid certain shortcuts in the location bar)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
87 */
1813
6a203275d317 a bit of src/ui
corvid <corvid@lavabit.com>
parents: 1806
diff changeset
88 class CustInput : public Fl_Input {
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
89 public:
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 337
diff changeset
90 CustInput (int x, int y, int w, int h, const char* l=0) :
1813
6a203275d317 a bit of src/ui
corvid <corvid@lavabit.com>
parents: 1806
diff changeset
91 Fl_Input(x,y,w,h,l) {};
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
92 int handle(int e);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
93 };
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
94
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
95 /*
2032
1a32d5ed2cd7 Made KEYS_LEFT_TAB and KEYS_RIGHT_TAB no longer handled as a special case
Jorge Arellano Cid <jcid@dillo.org>
parents: 2024
diff changeset
96 * Disable keys: Up, Down, Page_Up, Page_Down, Tab and
1a32d5ed2cd7 Made KEYS_LEFT_TAB and KEYS_RIGHT_TAB no longer handled as a special case
Jorge Arellano Cid <jcid@dillo.org>
parents: 2024
diff changeset
97 * CTRL+{o,r,Home,End} SHIFT+{Left,Right}.
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
98 */
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 337
diff changeset
99 int CustInput::handle(int e)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
100 {
1791
corvid <corvid@lavabit.com>
parents: 1790
diff changeset
101 int k = Fl::event_key();
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
102
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 337
diff changeset
103 _MSG("CustInput::handle event=%d\n", e);
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 337
diff changeset
104
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 337
diff changeset
105 // We're only interested in some flags
1947
821e6262ead9 Keybindings and some variable name normalizations
Jorge Arellano Cid <jcid@dillo.org>
parents: 1945
diff changeset
106 unsigned modifier = Fl::event_state() & (FL_SHIFT | FL_CTRL | FL_ALT);
325
553e3b01eb5f - Fixed keyboard focus issues.
jcid
parents: 319
diff changeset
107
553e3b01eb5f - Fixed keyboard focus issues.
jcid
parents: 319
diff changeset
108 // Don't focus with arrow keys
1791
corvid <corvid@lavabit.com>
parents: 1790
diff changeset
109 if (e == FL_FOCUS &&
1790
45b10f359e51 keys and mouse buttons
corvid <corvid@lavabit.com>
parents: 1591
diff changeset
110 (k == FL_Up || k == FL_Down || k == FL_Left || k == FL_Right)) {
325
553e3b01eb5f - Fixed keyboard focus issues.
jcid
parents: 319
diff changeset
111 return 0;
1791
corvid <corvid@lavabit.com>
parents: 1790
diff changeset
112 } else if (e == FL_KEYBOARD) {
1948
caf71cd30ec8 Made the findbar operative again (it has tricks and workarounds)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1947
diff changeset
113 if (k == FL_Escape && modifier == 0) {
caf71cd30ec8 Made the findbar operative again (it has tricks and workarounds)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1947
diff changeset
114 // Let the parent group handle this Esc key
caf71cd30ec8 Made the findbar operative again (it has tricks and workarounds)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1947
diff changeset
115 return 0;
2032
1a32d5ed2cd7 Made KEYS_LEFT_TAB and KEYS_RIGHT_TAB no longer handled as a special case
Jorge Arellano Cid <jcid@dillo.org>
parents: 2024
diff changeset
116 } else if (modifier == FL_SHIFT) {
1a32d5ed2cd7 Made KEYS_LEFT_TAB and KEYS_RIGHT_TAB no longer handled as a special case
Jorge Arellano Cid <jcid@dillo.org>
parents: 2024
diff changeset
117 if (k == FL_Left || k == FL_Right) {
1a32d5ed2cd7 Made KEYS_LEFT_TAB and KEYS_RIGHT_TAB no longer handled as a special case
Jorge Arellano Cid <jcid@dillo.org>
parents: 2024
diff changeset
118 // Let these keys get to the UI
1a32d5ed2cd7 Made KEYS_LEFT_TAB and KEYS_RIGHT_TAB no longer handled as a special case
Jorge Arellano Cid <jcid@dillo.org>
parents: 2024
diff changeset
119 return 0;
1a32d5ed2cd7 Made KEYS_LEFT_TAB and KEYS_RIGHT_TAB no longer handled as a special case
Jorge Arellano Cid <jcid@dillo.org>
parents: 2024
diff changeset
120 }
1948
caf71cd30ec8 Made the findbar operative again (it has tricks and workarounds)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1947
diff changeset
121 } else if (modifier == FL_CTRL) {
2040
6c012332ba15 Bound CTRL+{a,e,d,k} in the location bar (for start,end,del,cut)
Jorge Arellano Cid <jcid@dillo.org>
parents: 2032
diff changeset
122 if (k == 'a' || k == 'e') {
6c012332ba15 Bound CTRL+{a,e,d,k} in the location bar (for start,end,del,cut)
Jorge Arellano Cid <jcid@dillo.org>
parents: 2032
diff changeset
123 position(k == 'a' ? 0 : size());
6c012332ba15 Bound CTRL+{a,e,d,k} in the location bar (for start,end,del,cut)
Jorge Arellano Cid <jcid@dillo.org>
parents: 2032
diff changeset
124 return 1;
6c012332ba15 Bound CTRL+{a,e,d,k} in the location bar (for start,end,del,cut)
Jorge Arellano Cid <jcid@dillo.org>
parents: 2032
diff changeset
125 } else if (k == 'k') {
6c012332ba15 Bound CTRL+{a,e,d,k} in the location bar (for start,end,del,cut)
Jorge Arellano Cid <jcid@dillo.org>
parents: 2032
diff changeset
126 cut(position(), size());
6c012332ba15 Bound CTRL+{a,e,d,k} in the location bar (for start,end,del,cut)
Jorge Arellano Cid <jcid@dillo.org>
parents: 2032
diff changeset
127 return 1;
6c012332ba15 Bound CTRL+{a,e,d,k} in the location bar (for start,end,del,cut)
Jorge Arellano Cid <jcid@dillo.org>
parents: 2032
diff changeset
128 } else if (k == 'd') {
6c012332ba15 Bound CTRL+{a,e,d,k} in the location bar (for start,end,del,cut)
Jorge Arellano Cid <jcid@dillo.org>
parents: 2032
diff changeset
129 cut(position(), position()+1);
6c012332ba15 Bound CTRL+{a,e,d,k} in the location bar (for start,end,del,cut)
Jorge Arellano Cid <jcid@dillo.org>
parents: 2032
diff changeset
130 return 1;
6c012332ba15 Bound CTRL+{a,e,d,k} in the location bar (for start,end,del,cut)
Jorge Arellano Cid <jcid@dillo.org>
parents: 2032
diff changeset
131 } else if (k == 'l') {
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 337
diff changeset
132 // Make text selected when already focused.
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 337
diff changeset
133 position(size(), 0);
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 337
diff changeset
134 return 1;
1947
821e6262ead9 Keybindings and some variable name normalizations
Jorge Arellano Cid <jcid@dillo.org>
parents: 1945
diff changeset
135 } else if (k == 'h' || k == 'o' || k == 'r' ||
821e6262ead9 Keybindings and some variable name normalizations
Jorge Arellano Cid <jcid@dillo.org>
parents: 1945
diff changeset
136 k == FL_Home || k == FL_End) {
821e6262ead9 Keybindings and some variable name normalizations
Jorge Arellano Cid <jcid@dillo.org>
parents: 1945
diff changeset
137 // Let these keys get to the UI
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 337
diff changeset
138 return 0;
378
003d3ebfd78d - Made SHIFT + {Left, Right} work even with findbar focused.
jcid
parents: 377
diff changeset
139 }
1951
36e6563b8daa Assorted minor changes (see verbose log)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1950
diff changeset
140 } else if (modifier == 0) {
36e6563b8daa Assorted minor changes (see verbose log)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1950
diff changeset
141 if (k == FL_Down || k == FL_Up ||
2032
1a32d5ed2cd7 Made KEYS_LEFT_TAB and KEYS_RIGHT_TAB no longer handled as a special case
Jorge Arellano Cid <jcid@dillo.org>
parents: 2024
diff changeset
142 k == FL_Page_Down || k == FL_Page_Up || k == FL_Tab) {
1951
36e6563b8daa Assorted minor changes (see verbose log)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1950
diff changeset
143 // Give up focus and honor the key
36e6563b8daa Assorted minor changes (see verbose log)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1950
diff changeset
144 a_UIcmd_focus_main_area(a_UIcmd_get_bw_by_widget(this));
36e6563b8daa Assorted minor changes (see verbose log)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1950
diff changeset
145 return 0;
36e6563b8daa Assorted minor changes (see verbose log)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1950
diff changeset
146 }
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 337
diff changeset
147 }
217
a27eafd634d1 - Made CTRL-l focus the location bar instead of popping up a dialog.
jcid
parents: 213
diff changeset
148 }
1947
821e6262ead9 Keybindings and some variable name normalizations
Jorge Arellano Cid <jcid@dillo.org>
parents: 1945
diff changeset
149
1813
6a203275d317 a bit of src/ui
corvid <corvid@lavabit.com>
parents: 1806
diff changeset
150 return Fl_Input::handle(e);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
151 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
152
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
153 //----------------------------------------------------------------------------
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
154
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
155 /*
1959
648b1506e9aa Introduced class CustLightButton for visual feedback on panel buttons
Jorge Arellano Cid <jcid@dillo.org>
parents: 1954
diff changeset
156 * A button that highlights on mouse over
648b1506e9aa Introduced class CustLightButton for visual feedback on panel buttons
Jorge Arellano Cid <jcid@dillo.org>
parents: 1954
diff changeset
157 */
648b1506e9aa Introduced class CustLightButton for visual feedback on panel buttons
Jorge Arellano Cid <jcid@dillo.org>
parents: 1954
diff changeset
158 class CustLightButton : public Fl_Button {
648b1506e9aa Introduced class CustLightButton for visual feedback on panel buttons
Jorge Arellano Cid <jcid@dillo.org>
parents: 1954
diff changeset
159 Fl_Color norm_color;
648b1506e9aa Introduced class CustLightButton for visual feedback on panel buttons
Jorge Arellano Cid <jcid@dillo.org>
parents: 1954
diff changeset
160 public:
648b1506e9aa Introduced class CustLightButton for visual feedback on panel buttons
Jorge Arellano Cid <jcid@dillo.org>
parents: 1954
diff changeset
161 CustLightButton(int x, int y, int w, int h, const char *l=0) :
648b1506e9aa Introduced class CustLightButton for visual feedback on panel buttons
Jorge Arellano Cid <jcid@dillo.org>
parents: 1954
diff changeset
162 Fl_Button(x,y,w,h,l) { norm_color = color(); };
648b1506e9aa Introduced class CustLightButton for visual feedback on panel buttons
Jorge Arellano Cid <jcid@dillo.org>
parents: 1954
diff changeset
163 virtual int handle(int e);
648b1506e9aa Introduced class CustLightButton for visual feedback on panel buttons
Jorge Arellano Cid <jcid@dillo.org>
parents: 1954
diff changeset
164 };
648b1506e9aa Introduced class CustLightButton for visual feedback on panel buttons
Jorge Arellano Cid <jcid@dillo.org>
parents: 1954
diff changeset
165
648b1506e9aa Introduced class CustLightButton for visual feedback on panel buttons
Jorge Arellano Cid <jcid@dillo.org>
parents: 1954
diff changeset
166 int CustLightButton::handle(int e)
648b1506e9aa Introduced class CustLightButton for visual feedback on panel buttons
Jorge Arellano Cid <jcid@dillo.org>
parents: 1954
diff changeset
167 {
648b1506e9aa Introduced class CustLightButton for visual feedback on panel buttons
Jorge Arellano Cid <jcid@dillo.org>
parents: 1954
diff changeset
168 if (active()) {
648b1506e9aa Introduced class CustLightButton for visual feedback on panel buttons
Jorge Arellano Cid <jcid@dillo.org>
parents: 1954
diff changeset
169 if (e == FL_ENTER) {
648b1506e9aa Introduced class CustLightButton for visual feedback on panel buttons
Jorge Arellano Cid <jcid@dillo.org>
parents: 1954
diff changeset
170 color(51); // {17,26,51}
648b1506e9aa Introduced class CustLightButton for visual feedback on panel buttons
Jorge Arellano Cid <jcid@dillo.org>
parents: 1954
diff changeset
171 redraw();
648b1506e9aa Introduced class CustLightButton for visual feedback on panel buttons
Jorge Arellano Cid <jcid@dillo.org>
parents: 1954
diff changeset
172 } else if (e == FL_LEAVE || e == FL_RELEASE) {
648b1506e9aa Introduced class CustLightButton for visual feedback on panel buttons
Jorge Arellano Cid <jcid@dillo.org>
parents: 1954
diff changeset
173 color(norm_color);
648b1506e9aa Introduced class CustLightButton for visual feedback on panel buttons
Jorge Arellano Cid <jcid@dillo.org>
parents: 1954
diff changeset
174 redraw();
648b1506e9aa Introduced class CustLightButton for visual feedback on panel buttons
Jorge Arellano Cid <jcid@dillo.org>
parents: 1954
diff changeset
175 }
648b1506e9aa Introduced class CustLightButton for visual feedback on panel buttons
Jorge Arellano Cid <jcid@dillo.org>
parents: 1954
diff changeset
176 }
648b1506e9aa Introduced class CustLightButton for visual feedback on panel buttons
Jorge Arellano Cid <jcid@dillo.org>
parents: 1954
diff changeset
177 return Fl_Button::handle(e);
648b1506e9aa Introduced class CustLightButton for visual feedback on panel buttons
Jorge Arellano Cid <jcid@dillo.org>
parents: 1954
diff changeset
178 }
648b1506e9aa Introduced class CustLightButton for visual feedback on panel buttons
Jorge Arellano Cid <jcid@dillo.org>
parents: 1954
diff changeset
179
648b1506e9aa Introduced class CustLightButton for visual feedback on panel buttons
Jorge Arellano Cid <jcid@dillo.org>
parents: 1954
diff changeset
180 //----------------------------------------------------------------------------
648b1506e9aa Introduced class CustLightButton for visual feedback on panel buttons
Jorge Arellano Cid <jcid@dillo.org>
parents: 1954
diff changeset
181
648b1506e9aa Introduced class CustLightButton for visual feedback on panel buttons
Jorge Arellano Cid <jcid@dillo.org>
parents: 1954
diff changeset
182 /*
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
183 * Used to handle "paste" within the toolbar's Clear button.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
184 */
1959
648b1506e9aa Introduced class CustLightButton for visual feedback on panel buttons
Jorge Arellano Cid <jcid@dillo.org>
parents: 1954
diff changeset
185 class CustPasteButton : public CustLightButton {
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
186 public:
1959
648b1506e9aa Introduced class CustLightButton for visual feedback on panel buttons
Jorge Arellano Cid <jcid@dillo.org>
parents: 1954
diff changeset
187 CustPasteButton(int x, int y, int w, int h, const char *l=0) :
648b1506e9aa Introduced class CustLightButton for visual feedback on panel buttons
Jorge Arellano Cid <jcid@dillo.org>
parents: 1954
diff changeset
188 CustLightButton(x,y,w,h,l) {};
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
189 int handle(int e);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
190 };
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
191
1959
648b1506e9aa Introduced class CustLightButton for visual feedback on panel buttons
Jorge Arellano Cid <jcid@dillo.org>
parents: 1954
diff changeset
192 int CustPasteButton::handle(int e)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
193 {
1791
corvid <corvid@lavabit.com>
parents: 1790
diff changeset
194 if (e == FL_PASTE) {
corvid <corvid@lavabit.com>
parents: 1790
diff changeset
195 const char* t = Fl::event_text();
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
196 if (t && *t) {
372
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 368
diff changeset
197 a_UIcmd_set_location_text(a_UIcmd_get_bw_by_widget(this), t);
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 368
diff changeset
198 a_UIcmd_open_urlstr(a_UIcmd_get_bw_by_widget(this), t);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
199 return 1;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
200 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
201 }
1959
648b1506e9aa Introduced class CustLightButton for visual feedback on panel buttons
Jorge Arellano Cid <jcid@dillo.org>
parents: 1954
diff changeset
202 return CustLightButton::handle(e);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
203 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
204
75
4dfc78307039 Made progress bars resize automatically.
jcid
parents: 72
diff changeset
205 //----------------------------------------------------------------------------
4dfc78307039 Made progress bars resize automatically.
jcid
parents: 72
diff changeset
206
4dfc78307039 Made progress bars resize automatically.
jcid
parents: 72
diff changeset
207 /*
4dfc78307039 Made progress bars resize automatically.
jcid
parents: 72
diff changeset
208 * Used to resize the progress boxes automatically.
4dfc78307039 Made progress bars resize automatically.
jcid
parents: 72
diff changeset
209 */
1813
6a203275d317 a bit of src/ui
corvid <corvid@lavabit.com>
parents: 1806
diff changeset
210 class CustProgressBox : public Fl_Box {
1222
deffd7fc6d52 Fixed CustProgressBox() for systems without weak symbols (wrong semantics)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1209
diff changeset
211 int padding;
75
4dfc78307039 Made progress bars resize automatically.
jcid
parents: 72
diff changeset
212 public:
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 337
diff changeset
213 CustProgressBox(int x, int y, int w, int h, const char *l=0) :
1813
6a203275d317 a bit of src/ui
corvid <corvid@lavabit.com>
parents: 1806
diff changeset
214 Fl_Box(x,y,w,h,l) { padding = 0; };
75
4dfc78307039 Made progress bars resize automatically.
jcid
parents: 72
diff changeset
215 void update_label(const char *lbl) {
2004
dec39f62be1c fl_measure expects w to be set
corvid <corvid@lavabit.com>
parents: 2003
diff changeset
216 int w = 0, h = 0;
75
4dfc78307039 Made progress bars resize automatically.
jcid
parents: 72
diff changeset
217 if (!padding) {
4dfc78307039 Made progress bars resize automatically.
jcid
parents: 72
diff changeset
218 copy_label("W");
4dfc78307039 Made progress bars resize automatically.
jcid
parents: 72
diff changeset
219 measure_label(w, h);
4dfc78307039 Made progress bars resize automatically.
jcid
parents: 72
diff changeset
220 padding = w > 2 ? w/2 : 1;
4dfc78307039 Made progress bars resize automatically.
jcid
parents: 72
diff changeset
221 }
4dfc78307039 Made progress bars resize automatically.
jcid
parents: 72
diff changeset
222 copy_label(lbl);
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
223 //measure_label(w,h);
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
224 //size(w+padding,this->h());
75
4dfc78307039 Made progress bars resize automatically.
jcid
parents: 72
diff changeset
225 }
4dfc78307039 Made progress bars resize automatically.
jcid
parents: 72
diff changeset
226 };
4dfc78307039 Made progress bars resize automatically.
jcid
parents: 72
diff changeset
227
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
228 //
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
229 // Toolbar buttons -----------------------------------------------------------
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
230 //
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
231 //static const char *button_names[] = {
827
d513abcd4949 Implemented the tools button with CSS options. Also removed nav.h from html.cc
Jorge Arellano Cid <jcid@dillo.org>
parents: 479
diff changeset
232 // "Back", "Forward", "Home", "Reload", "Save", "Stop", "Bookmarks", "Tools",
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
233 // "Clear", "Search"
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
234 //};
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
235
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
236
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
237 //
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
238 // Callback functions --------------------------------------------------------
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
239 //
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
240
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
241 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
242 * Callback for the search button.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
243 */
1813
6a203275d317 a bit of src/ui
corvid <corvid@lavabit.com>
parents: 1806
diff changeset
244 static void search_cb(Fl_Widget *wid, void *data)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
245 {
1843
8139561cd4cb more UI button event handling
corvid <corvid@lavabit.com>
parents: 1842
diff changeset
246 int b = Fl::event_button();
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
247
1843
8139561cd4cb more UI button event handling
corvid <corvid@lavabit.com>
parents: 1842
diff changeset
248 if (b == FL_LEFT_MOUSE) {
372
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 368
diff changeset
249 a_UIcmd_search_dialog(a_UIcmd_get_bw_by_widget(wid));
1843
8139561cd4cb more UI button event handling
corvid <corvid@lavabit.com>
parents: 1842
diff changeset
250 } else if (b == FL_MIDDLE_MOUSE) {
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
251 ((UI*)data)->color_change_cb_i();
1843
8139561cd4cb more UI button event handling
corvid <corvid@lavabit.com>
parents: 1842
diff changeset
252 } else if (b == FL_RIGHT_MOUSE) {
1978
3172b6199fd1 Disabled the right-click-over-search-button hook that changed panel size
Jorge Arellano Cid <jcid@dillo.org>
parents: 1977
diff changeset
253 // nothing ATM
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
254 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
255 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
256
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
257 /*
1525
3c683905dbe3 Added a help button. It tries a local help file then dillo.org's one.
corvid, jcid
parents: 1343
diff changeset
258 * Callback for the help button.
1591
cf7f2d3312fb trim some spaces
corvid <corvid@lavabit.com>
parents: 1584
diff changeset
259 */
1813
6a203275d317 a bit of src/ui
corvid <corvid@lavabit.com>
parents: 1806
diff changeset
260 static void help_cb(Fl_Widget *w, void *)
1525
3c683905dbe3 Added a help button. It tries a local help file then dillo.org's one.
corvid, jcid
parents: 1343
diff changeset
261 {
3c683905dbe3 Added a help button. It tries a local help file then dillo.org's one.
corvid, jcid
parents: 1343
diff changeset
262 char *path = dStrconcat(DILLO_DOCDIR, "user_help.html", NULL);
3c683905dbe3 Added a help button. It tries a local help file then dillo.org's one.
corvid, jcid
parents: 1343
diff changeset
263 BrowserWindow *bw = a_UIcmd_get_bw_by_widget(w);
3c683905dbe3 Added a help button. It tries a local help file then dillo.org's one.
corvid, jcid
parents: 1343
diff changeset
264
3c683905dbe3 Added a help button. It tries a local help file then dillo.org's one.
corvid, jcid
parents: 1343
diff changeset
265 if (access(path, R_OK) == 0) {
3c683905dbe3 Added a help button. It tries a local help file then dillo.org's one.
corvid, jcid
parents: 1343
diff changeset
266 char *urlstr = dStrconcat("file:", path, NULL);
3c683905dbe3 Added a help button. It tries a local help file then dillo.org's one.
corvid, jcid
parents: 1343
diff changeset
267 a_UIcmd_open_urlstr(bw, urlstr);
3c683905dbe3 Added a help button. It tries a local help file then dillo.org's one.
corvid, jcid
parents: 1343
diff changeset
268 dFree(urlstr);
3c683905dbe3 Added a help button. It tries a local help file then dillo.org's one.
corvid, jcid
parents: 1343
diff changeset
269 } else {
1579
1d38bc37ae03 Fix fullwindow start (from CLI and dillorc)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1559
diff changeset
270 MSG("Can't read local help file at \"%s\"."
1d38bc37ae03 Fix fullwindow start (from CLI and dillorc)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1559
diff changeset
271 " Getting remote help...\n", path);
1525
3c683905dbe3 Added a help button. It tries a local help file then dillo.org's one.
corvid, jcid
parents: 1343
diff changeset
272 a_UIcmd_open_urlstr(bw, "http://www.dillo.org/dillo2-help.html");
3c683905dbe3 Added a help button. It tries a local help file then dillo.org's one.
corvid, jcid
parents: 1343
diff changeset
273 }
3c683905dbe3 Added a help button. It tries a local help file then dillo.org's one.
corvid, jcid
parents: 1343
diff changeset
274 dFree(path);
3c683905dbe3 Added a help button. It tries a local help file then dillo.org's one.
corvid, jcid
parents: 1343
diff changeset
275 }
3c683905dbe3 Added a help button. It tries a local help file then dillo.org's one.
corvid, jcid
parents: 1343
diff changeset
276
3c683905dbe3 Added a help button. It tries a local help file then dillo.org's one.
corvid, jcid
parents: 1343
diff changeset
277 /*
400
31b866fdde87 - File menu as popup implementation.
jcid
parents: 393
diff changeset
278 * Callback for the File menu button.
31b866fdde87 - File menu as popup implementation.
jcid
parents: 393
diff changeset
279 */
1813
6a203275d317 a bit of src/ui
corvid <corvid@lavabit.com>
parents: 1806
diff changeset
280 static void filemenu_cb(Fl_Widget *wid, void *)
400
31b866fdde87 - File menu as popup implementation.
jcid
parents: 393
diff changeset
281 {
1843
8139561cd4cb more UI button event handling
corvid <corvid@lavabit.com>
parents: 1842
diff changeset
282 int b = Fl::event_button();
8139561cd4cb more UI button event handling
corvid <corvid@lavabit.com>
parents: 1842
diff changeset
283 if (b == FL_LEFT_MOUSE || b == FL_RIGHT_MOUSE) {
400
31b866fdde87 - File menu as popup implementation.
jcid
parents: 393
diff changeset
284 a_UIcmd_file_popup(a_UIcmd_get_bw_by_widget(wid), wid);
31b866fdde87 - File menu as popup implementation.
jcid
parents: 393
diff changeset
285 }
31b866fdde87 - File menu as popup implementation.
jcid
parents: 393
diff changeset
286 }
31b866fdde87 - File menu as popup implementation.
jcid
parents: 393
diff changeset
287
31b866fdde87 - File menu as popup implementation.
jcid
parents: 393
diff changeset
288 /*
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
289 * Callback for the location's clear-button.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
290 */
1813
6a203275d317 a bit of src/ui
corvid <corvid@lavabit.com>
parents: 1806
diff changeset
291 static void clear_cb(Fl_Widget *w, void *data)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
292 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
293 UI *ui = (UI*)data;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
294
1843
8139561cd4cb more UI button event handling
corvid <corvid@lavabit.com>
parents: 1842
diff changeset
295 int b = Fl::event_button();
8139561cd4cb more UI button event handling
corvid <corvid@lavabit.com>
parents: 1842
diff changeset
296 if (b == FL_LEFT_MOUSE) {
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
297 ui->set_location("");
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
298 ui->focus_location();
1843
8139561cd4cb more UI button event handling
corvid <corvid@lavabit.com>
parents: 1842
diff changeset
299 } if (b == FL_MIDDLE_MOUSE) {
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
300 ui->paste_url();
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
301 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
302 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
303
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
304 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
305 * Change the color of the location bar.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
306 *
1813
6a203275d317 a bit of src/ui
corvid <corvid@lavabit.com>
parents: 1806
diff changeset
307 static void color_change_cb(Fl_Widget *wid, void *data)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
308 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
309 ((UI*)data)->color_change_cb_i();
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
310 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
311 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
312
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
313
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
314 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
315 * Send the browser to the new URL in the location.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
316 */
1813
6a203275d317 a bit of src/ui
corvid <corvid@lavabit.com>
parents: 1806
diff changeset
317 static void location_cb(Fl_Widget *wid, void *data)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
318 {
1822
a0ed332132e1 some more src/ui
corvid <corvid@lavabit.com>
parents: 1813
diff changeset
319 Fl_Input *i = (Fl_Input*)wid;
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 337
diff changeset
320 UI *ui = (UI*)data;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
321
383
b619d3469c69 - insert workaround part2
jcid
parents: 382
diff changeset
322 _MSG("location_cb()\n");
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
323 /* This test is necessary because WHEN_ENTER_KEY also includes
41
jcid
parents: 35
diff changeset
324 * other events we're not interested in. For instance pressing
jcid
parents: 35
diff changeset
325 * The Back or Forward, buttons, or the first click on a rendered
jcid
parents: 35
diff changeset
326 * page. BUG: this must be investigated and reported to FLTK2 team */
1791
corvid <corvid@lavabit.com>
parents: 1790
diff changeset
327 if (Fl::event_key() == FL_Enter) {
372
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 368
diff changeset
328 a_UIcmd_open_urlstr(a_UIcmd_get_bw_by_widget(i), i->value());
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
329 }
217
a27eafd634d1 - Made CTRL-l focus the location bar instead of popping up a dialog.
jcid
parents: 213
diff changeset
330 if (ui->get_panelmode() == UI_TEMPORARILY_SHOW_PANELS) {
a27eafd634d1 - Made CTRL-l focus the location bar instead of popping up a dialog.
jcid
parents: 213
diff changeset
331 ui->set_panelmode(UI_HIDDEN);
a27eafd634d1 - Made CTRL-l focus the location bar instead of popping up a dialog.
jcid
parents: 213
diff changeset
332 }
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
333 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
334
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
335
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
336 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
337 * Callback handler for button press on the panel
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
338 */
1813
6a203275d317 a bit of src/ui
corvid <corvid@lavabit.com>
parents: 1806
diff changeset
339 static void b1_cb(Fl_Widget *wid, void *cb_data)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
340 {
4
9a9338f78888 +- Connected signals to <li> elements (fixes links within lists).
jcid
parents: 0
diff changeset
341 int bn = VOIDP2INT(cb_data);
1843
8139561cd4cb more UI button event handling
corvid <corvid@lavabit.com>
parents: 1842
diff changeset
342 int b = Fl::event_button();
8139561cd4cb more UI button event handling
corvid <corvid@lavabit.com>
parents: 1842
diff changeset
343 if (b >= FL_LEFT_MOUSE && b <= FL_RIGHT_MOUSE) {
8139561cd4cb more UI button event handling
corvid <corvid@lavabit.com>
parents: 1842
diff changeset
344 _MSG("[%s], mouse button %d was pressed\n", button_names[bn], b);
8139561cd4cb more UI button event handling
corvid <corvid@lavabit.com>
parents: 1842
diff changeset
345 _MSG("mouse button %d was pressed\n", b);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
346 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
347 switch (bn) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
348 case UI_BACK:
1843
8139561cd4cb more UI button event handling
corvid <corvid@lavabit.com>
parents: 1842
diff changeset
349 if (b == FL_LEFT_MOUSE) {
372
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 368
diff changeset
350 a_UIcmd_back(a_UIcmd_get_bw_by_widget(wid));
1843
8139561cd4cb more UI button event handling
corvid <corvid@lavabit.com>
parents: 1842
diff changeset
351 } else if (b == FL_RIGHT_MOUSE) {
372
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 368
diff changeset
352 a_UIcmd_back_popup(a_UIcmd_get_bw_by_widget(wid));
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
353 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
354 break;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
355 case UI_FORW:
1843
8139561cd4cb more UI button event handling
corvid <corvid@lavabit.com>
parents: 1842
diff changeset
356 if (b == FL_LEFT_MOUSE) {
372
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 368
diff changeset
357 a_UIcmd_forw(a_UIcmd_get_bw_by_widget(wid));
1843
8139561cd4cb more UI button event handling
corvid <corvid@lavabit.com>
parents: 1842
diff changeset
358 } else if (b == FL_RIGHT_MOUSE) {
372
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 368
diff changeset
359 a_UIcmd_forw_popup(a_UIcmd_get_bw_by_widget(wid));
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
360 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
361 break;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
362 case UI_HOME:
1843
8139561cd4cb more UI button event handling
corvid <corvid@lavabit.com>
parents: 1842
diff changeset
363 if (b == FL_LEFT_MOUSE) {
372
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 368
diff changeset
364 a_UIcmd_home(a_UIcmd_get_bw_by_widget(wid));
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
365 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
366 break;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
367 case UI_RELOAD:
1843
8139561cd4cb more UI button event handling
corvid <corvid@lavabit.com>
parents: 1842
diff changeset
368 if (b == FL_LEFT_MOUSE) {
372
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 368
diff changeset
369 a_UIcmd_reload(a_UIcmd_get_bw_by_widget(wid));
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
370 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
371 break;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
372 case UI_SAVE:
1843
8139561cd4cb more UI button event handling
corvid <corvid@lavabit.com>
parents: 1842
diff changeset
373 if (b == FL_LEFT_MOUSE) {
372
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 368
diff changeset
374 a_UIcmd_save(a_UIcmd_get_bw_by_widget(wid));
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
375 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
376 break;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
377 case UI_STOP:
1843
8139561cd4cb more UI button event handling
corvid <corvid@lavabit.com>
parents: 1842
diff changeset
378 if (b == FL_LEFT_MOUSE) {
372
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 368
diff changeset
379 a_UIcmd_stop(a_UIcmd_get_bw_by_widget(wid));
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
380 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
381 break;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
382 case UI_BOOK:
1843
8139561cd4cb more UI button event handling
corvid <corvid@lavabit.com>
parents: 1842
diff changeset
383 if (b == FL_LEFT_MOUSE) {
372
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 368
diff changeset
384 a_UIcmd_book(a_UIcmd_get_bw_by_widget(wid));
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
385 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
386 break;
827
d513abcd4949 Implemented the tools button with CSS options. Also removed nav.h from html.cc
Jorge Arellano Cid <jcid@dillo.org>
parents: 479
diff changeset
387 case UI_TOOLS:
1843
8139561cd4cb more UI button event handling
corvid <corvid@lavabit.com>
parents: 1842
diff changeset
388 if (b == FL_LEFT_MOUSE || b == FL_RIGHT_MOUSE) {
827
d513abcd4949 Implemented the tools button with CSS options. Also removed nav.h from html.cc
Jorge Arellano Cid <jcid@dillo.org>
parents: 479
diff changeset
389 a_UIcmd_tools(a_UIcmd_get_bw_by_widget(wid), wid);
d513abcd4949 Implemented the tools button with CSS options. Also removed nav.h from html.cc
Jorge Arellano Cid <jcid@dillo.org>
parents: 479
diff changeset
390 }
d513abcd4949 Implemented the tools button with CSS options. Also removed nav.h from html.cc
Jorge Arellano Cid <jcid@dillo.org>
parents: 479
diff changeset
391 break;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
392 default:
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
393 break;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
394 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
395 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
396
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
397 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
398 * Callback for the bug meter button.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
399 */
1813
6a203275d317 a bit of src/ui
corvid <corvid@lavabit.com>
parents: 1806
diff changeset
400 static void bugmeter_cb(Fl_Widget *wid, void *data)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
401 {
1843
8139561cd4cb more UI button event handling
corvid <corvid@lavabit.com>
parents: 1842
diff changeset
402 int b = Fl::event_button();
8139561cd4cb more UI button event handling
corvid <corvid@lavabit.com>
parents: 1842
diff changeset
403 if (b == FL_LEFT_MOUSE) {
372
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 368
diff changeset
404 a_UIcmd_view_page_bugs(a_UIcmd_get_bw_by_widget(wid));
1843
8139561cd4cb more UI button event handling
corvid <corvid@lavabit.com>
parents: 1842
diff changeset
405 } else if (b == FL_RIGHT_MOUSE) {
372
49886f14ffe1 - Committed the no bw as window user_data() patch.
jcid
parents: 368
diff changeset
406 a_UIcmd_bugmeter_popup(a_UIcmd_get_bw_by_widget(wid));
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
407 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
408 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
409
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
410 //////////////////////////////////////////////////////////////////////////////
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
411 // UI class methods
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
412 //
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
413
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
414 //----------------------------
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
415 // Panel construction methods
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
416 //----------------------------
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
417
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
418 /*
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
419 * Make a generic navigation button
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
420 */
1925
72bfd5e7edcd Added CustGroup class (it repositions child widgets when others are hidden)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1924
diff changeset
421 Fl_Button *UI::make_button(const char *label, Fl_Image *img, Fl_Image *deimg,
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
422 int b_n, int start)
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
423 {
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
424 if (start)
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
425 p_xpos = 0;
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
426
1959
648b1506e9aa Introduced class CustLightButton for visual feedback on panel buttons
Jorge Arellano Cid <jcid@dillo.org>
parents: 1954
diff changeset
427 Fl_Button *b = new CustLightButton(p_xpos, 0, bw, bh, (lbl) ? label : NULL);
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
428 if (img)
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
429 b->image(img);
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
430 if (deimg)
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
431 b->deimage(deimg);
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
432 b->callback(b1_cb, (void *)b_n);
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
433 b->clear_visible_focus();
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
434 b->labelsize(12);
1959
648b1506e9aa Introduced class CustLightButton for visual feedback on panel buttons
Jorge Arellano Cid <jcid@dillo.org>
parents: 1954
diff changeset
435 b->box(FL_FLAT_BOX);
648b1506e9aa Introduced class CustLightButton for visual feedback on panel buttons
Jorge Arellano Cid <jcid@dillo.org>
parents: 1954
diff changeset
436 b->down_box(FL_THIN_DOWN_FRAME);
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
437 p_xpos += bw;
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
438 return b;
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
439 }
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
440
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
441 /*
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
442 * Create the archetipic browser buttons
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
443 */
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
444 void UI::make_toolbar(int tw, int th)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
445 {
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
446 Back = make_button("Back", icons->ImgLeft, icons->ImgLeftIn, UI_BACK, 1);
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
447 Forw = make_button("Forw", icons->ImgRight, icons->ImgRightIn, UI_FORW);
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
448 Home = make_button("Home", icons->ImgHome, NULL, UI_HOME);
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
449 Reload = make_button("Reload", icons->ImgReload, NULL, UI_RELOAD);
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
450 Save = make_button("Save", icons->ImgSave, NULL, UI_SAVE);
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
451 Stop = make_button("Stop", icons->ImgStop, icons->ImgStopIn, UI_STOP);
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
452 Bookmarks = make_button("Book", icons->ImgBook, NULL, UI_BOOK);
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
453 Tools = make_button("Tools", icons->ImgTools, NULL, UI_TOOLS);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
454
1343
16ed4ed58863 only set tooltips for UI if prefs.show_tooltip set
corvid <corvid@lavabit.com>
parents: 1308
diff changeset
455 if (prefs.show_tooltip) {
16ed4ed58863 only set tooltips for UI if prefs.show_tooltip set
corvid <corvid@lavabit.com>
parents: 1308
diff changeset
456 Back->tooltip("Previous page");
16ed4ed58863 only set tooltips for UI if prefs.show_tooltip set
corvid <corvid@lavabit.com>
parents: 1308
diff changeset
457 Forw->tooltip("Next page");
16ed4ed58863 only set tooltips for UI if prefs.show_tooltip set
corvid <corvid@lavabit.com>
parents: 1308
diff changeset
458 Home->tooltip("Go to the Home page");
16ed4ed58863 only set tooltips for UI if prefs.show_tooltip set
corvid <corvid@lavabit.com>
parents: 1308
diff changeset
459 Reload->tooltip("Reload");
16ed4ed58863 only set tooltips for UI if prefs.show_tooltip set
corvid <corvid@lavabit.com>
parents: 1308
diff changeset
460 Save->tooltip("Save this page");
16ed4ed58863 only set tooltips for UI if prefs.show_tooltip set
corvid <corvid@lavabit.com>
parents: 1308
diff changeset
461 Stop->tooltip("Stop loading");
16ed4ed58863 only set tooltips for UI if prefs.show_tooltip set
corvid <corvid@lavabit.com>
parents: 1308
diff changeset
462 Bookmarks->tooltip("View bookmarks");
16ed4ed58863 only set tooltips for UI if prefs.show_tooltip set
corvid <corvid@lavabit.com>
parents: 1308
diff changeset
463 Tools->tooltip("Settings");
16ed4ed58863 only set tooltips for UI if prefs.show_tooltip set
corvid <corvid@lavabit.com>
parents: 1308
diff changeset
464 }
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
465 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
466
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
467 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
468 * Create the location box (Clear/Input/Search)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
469 */
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
470 void UI::make_location(int ww)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
471 {
1813
6a203275d317 a bit of src/ui
corvid <corvid@lavabit.com>
parents: 1806
diff changeset
472 Fl_Button *b;
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
473
1959
648b1506e9aa Introduced class CustLightButton for visual feedback on panel buttons
Jorge Arellano Cid <jcid@dillo.org>
parents: 1954
diff changeset
474 Clear = b = new CustPasteButton(p_xpos,0,16,lh,0);
374
fb3a62d1aab2 - Set UI's to share icons.
jcid
parents: 372
diff changeset
475 b->image(icons->ImgClear);
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 337
diff changeset
476 b->callback(clear_cb, this);
1813
6a203275d317 a bit of src/ui
corvid <corvid@lavabit.com>
parents: 1806
diff changeset
477 b->clear_visible_focus();
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
478 b->box(FL_THIN_UP_BOX);
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
479 p_xpos += b->w();
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
480
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
481 Fl_Input *i = Location = new CustInput(p_xpos,0,ww-p_xpos-32,lh,0);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
482 i->color(CuteColor);
1794
corvid <corvid@lavabit.com>
parents: 1791
diff changeset
483 i->when(FL_WHEN_ENTER_KEY);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
484 i->callback(location_cb, this);
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
485 p_xpos += i->w();
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
486
1959
648b1506e9aa Introduced class CustLightButton for visual feedback on panel buttons
Jorge Arellano Cid <jcid@dillo.org>
parents: 1954
diff changeset
487 Search = b = new CustLightButton(p_xpos,0,16,lh,0);
374
fb3a62d1aab2 - Set UI's to share icons.
jcid
parents: 372
diff changeset
488 b->image(icons->ImgSearch);
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 337
diff changeset
489 b->callback(search_cb, this);
1813
6a203275d317 a bit of src/ui
corvid <corvid@lavabit.com>
parents: 1806
diff changeset
490 b->clear_visible_focus();
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
491 b->box(FL_THIN_UP_BOX);
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
492 p_xpos += b->w();
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
493
1959
648b1506e9aa Introduced class CustLightButton for visual feedback on panel buttons
Jorge Arellano Cid <jcid@dillo.org>
parents: 1954
diff changeset
494 Help = b = new CustLightButton(p_xpos,0,16,lh,0);
1525
3c683905dbe3 Added a help button. It tries a local help file then dillo.org's one.
corvid, jcid
parents: 1343
diff changeset
495 b->image(icons->ImgHelp);
3c683905dbe3 Added a help button. It tries a local help file then dillo.org's one.
corvid, jcid
parents: 1343
diff changeset
496 b->callback(help_cb, this);
1813
6a203275d317 a bit of src/ui
corvid <corvid@lavabit.com>
parents: 1806
diff changeset
497 b->clear_visible_focus();
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
498 b->box(FL_THIN_UP_BOX);
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
499 p_xpos += b->w();
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
500
1343
16ed4ed58863 only set tooltips for UI if prefs.show_tooltip set
corvid <corvid@lavabit.com>
parents: 1308
diff changeset
501 if (prefs.show_tooltip) {
16ed4ed58863 only set tooltips for UI if prefs.show_tooltip set
corvid <corvid@lavabit.com>
parents: 1308
diff changeset
502 Clear->tooltip("Clear the URL box.\nMiddle-click to paste a URL.");
16ed4ed58863 only set tooltips for UI if prefs.show_tooltip set
corvid <corvid@lavabit.com>
parents: 1308
diff changeset
503 Location->tooltip("Location");
16ed4ed58863 only set tooltips for UI if prefs.show_tooltip set
corvid <corvid@lavabit.com>
parents: 1308
diff changeset
504 Search->tooltip("Search the Web");
1525
3c683905dbe3 Added a help button. It tries a local help file then dillo.org's one.
corvid, jcid
parents: 1343
diff changeset
505 Help->tooltip("Help");
1343
16ed4ed58863 only set tooltips for UI if prefs.show_tooltip set
corvid <corvid@lavabit.com>
parents: 1308
diff changeset
506 }
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
507 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
508
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
509 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
510 * Create the progress bars
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
511 */
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
512 void UI::make_progress_bars(int wide, int thin_up)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
513 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
514 // Images
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
515 IProg = new CustProgressBox(p_xpos,p_ypos,pw,bh);
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
516 IProg->labelsize(12);
1795
0099818bc45b some UI constants
corvid <corvid@lavabit.com>
parents: 1794
diff changeset
517 IProg->box(thin_up ? FL_THIN_UP_BOX : FL_EMBOSSED_BOX);
1823
ca17943888ad more src/ui
corvid <corvid@lavabit.com>
parents: 1822
diff changeset
518 IProg->labelcolor(FL_GRAY_RAMP + 2);
75
4dfc78307039 Made progress bars resize automatically.
jcid
parents: 72
diff changeset
519 IProg->update_label(wide ? "Images\n0 of 0" : "0 of 0");
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
520 p_xpos += pw;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
521 // Page
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
522 PProg = new CustProgressBox(p_xpos,p_ypos,pw,bh);
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
523 PProg->labelsize(12);
1795
0099818bc45b some UI constants
corvid <corvid@lavabit.com>
parents: 1794
diff changeset
524 PProg->box(thin_up ? FL_THIN_UP_BOX : FL_EMBOSSED_BOX);
1823
ca17943888ad more src/ui
corvid <corvid@lavabit.com>
parents: 1822
diff changeset
525 PProg->labelcolor(FL_GRAY_RAMP + 2);
75
4dfc78307039 Made progress bars resize automatically.
jcid
parents: 72
diff changeset
526 PProg->update_label(wide ? "Page\n0.0KB" : "0.0KB");
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
527 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
528
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
529 /*
400
31b866fdde87 - File menu as popup implementation.
jcid
parents: 393
diff changeset
530 * Create the "File" menu
31b866fdde87 - File menu as popup implementation.
jcid
parents: 393
diff changeset
531 * Static function for File menu callbacks.
384
d33b55bb56c9 - Set menubar "close window" items from a timeout
jcid
parents: 383
diff changeset
532 */
1813
6a203275d317 a bit of src/ui
corvid <corvid@lavabit.com>
parents: 1806
diff changeset
533 Fl_Widget *UI::make_filemenu_button()
384
d33b55bb56c9 - Set menubar "close window" items from a timeout
jcid
parents: 383
diff changeset
534 {
1813
6a203275d317 a bit of src/ui
corvid <corvid@lavabit.com>
parents: 1806
diff changeset
535 Fl_Button *btn;
2004
dec39f62be1c fl_measure expects w to be set
corvid <corvid@lavabit.com>
parents: 2003
diff changeset
536 int w = 0, h = 0, padding;
400
31b866fdde87 - File menu as popup implementation.
jcid
parents: 393
diff changeset
537
2052
89af8495455f remove use of Fl_Pack to avoid resizing issues
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 2042
diff changeset
538 FileButton = btn = new Fl_Button(p_xpos,0,bw,bh,"W");
1970
7bfc11c78869 Set FL_FREE_LABELTYPE to interpret symbols and draw shortcut (for "File" menu)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1967
diff changeset
539 btn->labeltype(FL_FREE_LABELTYPE);
400
31b866fdde87 - File menu as popup implementation.
jcid
parents: 393
diff changeset
540 btn->measure_label(w, h);
31b866fdde87 - File menu as popup implementation.
jcid
parents: 393
diff changeset
541 padding = w;
31b866fdde87 - File menu as popup implementation.
jcid
parents: 393
diff changeset
542 btn->copy_label(PanelSize == P_tiny ? "&F" : "&File");
31b866fdde87 - File menu as popup implementation.
jcid
parents: 393
diff changeset
543 btn->measure_label(w,h);
1967
fa525b466aef Fixed offset bugs with panel tiny and large (also fullscreen mode for large)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1959
diff changeset
544 h = (PanelSize == P_large) ? mh : (PanelSize == P_tiny) ? bh : lh;
fa525b466aef Fixed offset bugs with panel tiny and large (also fullscreen mode for large)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1959
diff changeset
545 btn->size(w+padding, h);
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
546 p_xpos += btn->w();
400
31b866fdde87 - File menu as popup implementation.
jcid
parents: 393
diff changeset
547 _MSG("UI::make_filemenu_button w=%d h=%d padding=%d\n", w, h, padding);
1944
3d6b3abb3b68 Minor fixes for panel_size=large
Jorge Arellano Cid <jcid@dillo.org>
parents: 1930
diff changeset
548 btn->box(PanelSize == P_large ? FL_THIN_UP_BOX : FL_THIN_UP_BOX);
400
31b866fdde87 - File menu as popup implementation.
jcid
parents: 393
diff changeset
549 btn->callback(filemenu_cb, this);
1343
16ed4ed58863 only set tooltips for UI if prefs.show_tooltip set
corvid <corvid@lavabit.com>
parents: 1308
diff changeset
550 if (prefs.show_tooltip)
16ed4ed58863 only set tooltips for UI if prefs.show_tooltip set
corvid <corvid@lavabit.com>
parents: 1308
diff changeset
551 btn->tooltip("File menu");
1822
a0ed332132e1 some more src/ui
corvid <corvid@lavabit.com>
parents: 1813
diff changeset
552 btn->clear_visible_focus();
1980
95f3007dbbfc Made button visibility prefs work again for: search, help and file menu
Jorge Arellano Cid <jcid@dillo.org>
parents: 1978
diff changeset
553 if (!prefs.show_filemenu)
400
31b866fdde87 - File menu as popup implementation.
jcid
parents: 393
diff changeset
554 btn->hide();
31b866fdde87 - File menu as popup implementation.
jcid
parents: 393
diff changeset
555 return btn;
384
d33b55bb56c9 - Set menubar "close window" items from a timeout
jcid
parents: 383
diff changeset
556 }
d33b55bb56c9 - Set menubar "close window" items from a timeout
jcid
parents: 383
diff changeset
557
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
558
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
559 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
560 * Create the control panel
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
561 */
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
562 void UI::make_panel(int ww)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
563 {
1813
6a203275d317 a bit of src/ui
corvid <corvid@lavabit.com>
parents: 1806
diff changeset
564 Fl_Widget *w;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
565
374
fb3a62d1aab2 - Set UI's to share icons.
jcid
parents: 372
diff changeset
566 if (Small_Icons)
fb3a62d1aab2 - Set UI's to share icons.
jcid
parents: 372
diff changeset
567 icons = &small_icons;
fb3a62d1aab2 - Set UI's to share icons.
jcid
parents: 372
diff changeset
568 else
fb3a62d1aab2 - Set UI's to share icons.
jcid
parents: 372
diff changeset
569 icons = &standard_icons;
930
b277eed3119c whitespace cleanup: 's/ +$//g'
Jorge Arellano Cid <jcid@dillo.org>
parents: 907
diff changeset
570
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
571 pw = 70;
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
572 p_xpos = p_ypos = 0;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
573 if (PanelSize == P_tiny) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
574 if (Small_Icons)
1947
821e6262ead9 Keybindings and some variable name normalizations
Jorge Arellano Cid <jcid@dillo.org>
parents: 1945
diff changeset
575 bw = 22, bh = 22, mh = 0, lh = 22, lbl = 0;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
576 else
1947
821e6262ead9 Keybindings and some variable name normalizations
Jorge Arellano Cid <jcid@dillo.org>
parents: 1945
diff changeset
577 bw = 28, bh = 28, mh = 0, lh = 28, lbl = 0;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
578 } else if (PanelSize == P_small) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
579 if (Small_Icons)
1947
821e6262ead9 Keybindings and some variable name normalizations
Jorge Arellano Cid <jcid@dillo.org>
parents: 1945
diff changeset
580 bw = 20, bh = 20, mh = 0, lh = 20, lbl = 0;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
581 else
1947
821e6262ead9 Keybindings and some variable name normalizations
Jorge Arellano Cid <jcid@dillo.org>
parents: 1945
diff changeset
582 bw = 28, bh = 28, mh = 0, lh = 28, lbl = 0;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
583 } else if (PanelSize == P_medium) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
584 if (Small_Icons)
1947
821e6262ead9 Keybindings and some variable name normalizations
Jorge Arellano Cid <jcid@dillo.org>
parents: 1945
diff changeset
585 bw = 42, bh = 36, mh = 0, lh = 22, lbl = 1;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
586 else
1947
821e6262ead9 Keybindings and some variable name normalizations
Jorge Arellano Cid <jcid@dillo.org>
parents: 1945
diff changeset
587 bw = 45, bh = 45, mh = 0, lh = 28, lbl = 1;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
588 } else { // P_large
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
589 if (Small_Icons)
1947
821e6262ead9 Keybindings and some variable name normalizations
Jorge Arellano Cid <jcid@dillo.org>
parents: 1945
diff changeset
590 bw = 42, bh = 36, mh = 22, lh = 22, lbl = 1;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
591 else
1947
821e6262ead9 Keybindings and some variable name normalizations
Jorge Arellano Cid <jcid@dillo.org>
parents: 1945
diff changeset
592 bw = 45, bh = 45, mh = 24, lh = 28, lbl = 1;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
593 }
1947
821e6262ead9 Keybindings and some variable name normalizations
Jorge Arellano Cid <jcid@dillo.org>
parents: 1945
diff changeset
594 nh = bh, fh = 28; sh = 20;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
595
1975
06bbf0f0df1c Switched make_panel() to use insert() instead of begin()/end() pairs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1972
diff changeset
596 current(0);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
597 if (PanelSize == P_tiny) {
2052
89af8495455f remove use of Fl_Pack to avoid resizing issues
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 2042
diff changeset
598 NavBar = new CustGroupHorizontal(0,0,ww,nh);
1927
e7abafb75d0e Made Dillo code follow my fltk1.3 UI prototype
Jorge Arellano Cid <jcid@dillo.org>
parents: 1925
diff changeset
599 NavBar->begin();
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
600 make_toolbar(ww,bh);
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
601 make_filemenu_button();
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
602 make_location(ww);
1927
e7abafb75d0e Made Dillo code follow my fltk1.3 UI prototype
Jorge Arellano Cid <jcid@dillo.org>
parents: 1925
diff changeset
603 NavBar->resizable(Location);
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
604 make_progress_bars(0,1);
1927
e7abafb75d0e Made Dillo code follow my fltk1.3 UI prototype
Jorge Arellano Cid <jcid@dillo.org>
parents: 1925
diff changeset
605 NavBar->box(FL_THIN_UP_FRAME);
e7abafb75d0e Made Dillo code follow my fltk1.3 UI prototype
Jorge Arellano Cid <jcid@dillo.org>
parents: 1925
diff changeset
606 NavBar->end();
2052
89af8495455f remove use of Fl_Pack to avoid resizing issues
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 2042
diff changeset
607 NavBar->rearrange();
1975
06bbf0f0df1c Switched make_panel() to use insert() instead of begin()/end() pairs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1972
diff changeset
608 TopGroup->insert(*NavBar,0);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
609 } else {
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
610 if (PanelSize == P_large) {
2052
89af8495455f remove use of Fl_Pack to avoid resizing issues
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 2042
diff changeset
611 MenuBar = new CustGroupHorizontal(0,0,ww,mh);
1967
fa525b466aef Fixed offset bugs with panel tiny and large (also fullscreen mode for large)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1959
diff changeset
612 MenuBar->begin();
fa525b466aef Fixed offset bugs with panel tiny and large (also fullscreen mode for large)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1959
diff changeset
613 MenuBar->box(FL_THIN_UP_BOX);
1927
e7abafb75d0e Made Dillo code follow my fltk1.3 UI prototype
Jorge Arellano Cid <jcid@dillo.org>
parents: 1925
diff changeset
614 Fl_Widget *bn = make_filemenu_button();
1967
fa525b466aef Fixed offset bugs with panel tiny and large (also fullscreen mode for large)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1959
diff changeset
615 MenuBar->add_resizable(*new Fl_Box(bn->w(),0,ww - bn->w(),mh));
fa525b466aef Fixed offset bugs with panel tiny and large (also fullscreen mode for large)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1959
diff changeset
616 MenuBar->end();
2052
89af8495455f remove use of Fl_Pack to avoid resizing issues
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 2042
diff changeset
617 MenuBar->rearrange();
1975
06bbf0f0df1c Switched make_panel() to use insert() instead of begin()/end() pairs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1972
diff changeset
618 TopGroup->insert(*MenuBar,0);
408
46ea0474adc6 . Minor update to README.
jcid
parents: 400
diff changeset
619
1944
3d6b3abb3b68 Minor fixes for panel_size=large
Jorge Arellano Cid <jcid@dillo.org>
parents: 1930
diff changeset
620 p_xpos = 0;
2052
89af8495455f remove use of Fl_Pack to avoid resizing issues
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 2042
diff changeset
621 LocBar = new CustGroupHorizontal(0,0,ww,lh);
1927
e7abafb75d0e Made Dillo code follow my fltk1.3 UI prototype
Jorge Arellano Cid <jcid@dillo.org>
parents: 1925
diff changeset
622 LocBar->begin();
e7abafb75d0e Made Dillo code follow my fltk1.3 UI prototype
Jorge Arellano Cid <jcid@dillo.org>
parents: 1925
diff changeset
623 make_location(ww);
1980
95f3007dbbfc Made button visibility prefs work again for: search, help and file menu
Jorge Arellano Cid <jcid@dillo.org>
parents: 1978
diff changeset
624 LocBar->resizable(Location);
1927
e7abafb75d0e Made Dillo code follow my fltk1.3 UI prototype
Jorge Arellano Cid <jcid@dillo.org>
parents: 1925
diff changeset
625 LocBar->end();
2052
89af8495455f remove use of Fl_Pack to avoid resizing issues
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 2042
diff changeset
626 LocBar->rearrange();
1975
06bbf0f0df1c Switched make_panel() to use insert() instead of begin()/end() pairs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1972
diff changeset
627 TopGroup->insert(*LocBar,1);
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
628 } else {
2052
89af8495455f remove use of Fl_Pack to avoid resizing issues
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 2042
diff changeset
629 LocBar = new CustGroupHorizontal(0,0,ww,lh);
1975
06bbf0f0df1c Switched make_panel() to use insert() instead of begin()/end() pairs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1972
diff changeset
630 LocBar->begin();
1925
72bfd5e7edcd Added CustGroup class (it repositions child widgets when others are hidden)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1924
diff changeset
631 p_xpos = 0;
400
31b866fdde87 - File menu as popup implementation.
jcid
parents: 393
diff changeset
632 make_filemenu_button();
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
633 make_location(ww);
1927
e7abafb75d0e Made Dillo code follow my fltk1.3 UI prototype
Jorge Arellano Cid <jcid@dillo.org>
parents: 1925
diff changeset
634 LocBar->resizable(Location);
e7abafb75d0e Made Dillo code follow my fltk1.3 UI prototype
Jorge Arellano Cid <jcid@dillo.org>
parents: 1925
diff changeset
635 LocBar->end();
2052
89af8495455f remove use of Fl_Pack to avoid resizing issues
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 2042
diff changeset
636 LocBar->rearrange();
1975
06bbf0f0df1c Switched make_panel() to use insert() instead of begin()/end() pairs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1972
diff changeset
637 TopGroup->insert(*LocBar,0);
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
638 }
930
b277eed3119c whitespace cleanup: 's/ +$//g'
Jorge Arellano Cid <jcid@dillo.org>
parents: 907
diff changeset
639
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
640 // Toolbar
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
641 p_ypos = 0;
2052
89af8495455f remove use of Fl_Pack to avoid resizing issues
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 2042
diff changeset
642 NavBar = new CustGroupHorizontal(0,0,ww,bh);
1927
e7abafb75d0e Made Dillo code follow my fltk1.3 UI prototype
Jorge Arellano Cid <jcid@dillo.org>
parents: 1925
diff changeset
643 NavBar->begin();
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
644 make_toolbar(ww,bh);
1929
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
645 w = new Fl_Box(p_xpos,0,ww-p_xpos-2*pw,bh);
1981
3640968ba259 Fixed a glitch with panel size change and redraw
Jorge Arellano Cid <jcid@dillo.org>
parents: 1980
diff changeset
646 w->box(FL_FLAT_BOX);
1927
e7abafb75d0e Made Dillo code follow my fltk1.3 UI prototype
Jorge Arellano Cid <jcid@dillo.org>
parents: 1925
diff changeset
647 NavBar->resizable(w);
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
648 p_xpos = ww - 2*pw;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
649 if (PanelSize == P_small) {
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
650 make_progress_bars(0,0);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
651 } else {
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
652 make_progress_bars(1,0);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
653 }
1927
e7abafb75d0e Made Dillo code follow my fltk1.3 UI prototype
Jorge Arellano Cid <jcid@dillo.org>
parents: 1925
diff changeset
654 NavBar->end();
2052
89af8495455f remove use of Fl_Pack to avoid resizing issues
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 2042
diff changeset
655 NavBar->rearrange();
1975
06bbf0f0df1c Switched make_panel() to use insert() instead of begin()/end() pairs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1972
diff changeset
656 TopGroup->insert(*NavBar,(MenuBar ? 2 : 1));
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
657 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
658 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
659
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
660 /*
946
f06d5c581f58 Moved creation of the UI's status panel into a function.
corvid <corvid@lavabit.com>
parents: 930
diff changeset
661 * Create the status panel
f06d5c581f58 Moved creation of the UI's status panel into a function.
corvid <corvid@lavabit.com>
parents: 930
diff changeset
662 */
1947
821e6262ead9 Keybindings and some variable name normalizations
Jorge Arellano Cid <jcid@dillo.org>
parents: 1945
diff changeset
663 void UI::make_status_bar(int ww, int wh)
946
f06d5c581f58 Moved creation of the UI's status panel into a function.
corvid <corvid@lavabit.com>
parents: 930
diff changeset
664 {
1945
b24a5b73ff10 Made the status bar visible and operative.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1944
diff changeset
665 const int bm_w = 20;
2052
89af8495455f remove use of Fl_Pack to avoid resizing issues
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 2042
diff changeset
666 StatusBar = new CustGroupHorizontal(0, wh-sh, ww, sh);
946
f06d5c581f58 Moved creation of the UI's status panel into a function.
corvid <corvid@lavabit.com>
parents: 930
diff changeset
667
1945
b24a5b73ff10 Made the status bar visible and operative.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1944
diff changeset
668 // Status box
b24a5b73ff10 Made the status bar visible and operative.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1944
diff changeset
669 StatusOutput = new Fl_Output(0, wh-sh, ww-bm_w, sh);
1952
fb462b4abcfa www.dillo.org status value
corvid <corvid@lavabit.com>
parents: 1951
diff changeset
670 StatusOutput->value("http://www.dillo.org");
1945
b24a5b73ff10 Made the status bar visible and operative.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1944
diff changeset
671 StatusOutput->labelsize(8);
b24a5b73ff10 Made the status bar visible and operative.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1944
diff changeset
672 StatusOutput->box(FL_THIN_DOWN_BOX);
b24a5b73ff10 Made the status bar visible and operative.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1944
diff changeset
673 StatusOutput->clear_visible_focus();
b24a5b73ff10 Made the status bar visible and operative.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1944
diff changeset
674 StatusOutput->color(FL_GRAY_RAMP + 18);
946
f06d5c581f58 Moved creation of the UI's status panel into a function.
corvid <corvid@lavabit.com>
parents: 930
diff changeset
675
1945
b24a5b73ff10 Made the status bar visible and operative.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1944
diff changeset
676 // Bug Meter
1959
648b1506e9aa Introduced class CustLightButton for visual feedback on panel buttons
Jorge Arellano Cid <jcid@dillo.org>
parents: 1954
diff changeset
677 BugMeter = new CustLightButton(ww-bm_w,wh-sh,bm_w,sh);
1945
b24a5b73ff10 Made the status bar visible and operative.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1944
diff changeset
678 BugMeter->image(icons->ImgMeterOK);
1950
cd551611000a Made the bug meter number&icon display correctly
Jorge Arellano Cid <jcid@dillo.org>
parents: 1948
diff changeset
679 BugMeter->box(FL_THIN_DOWN_BOX);
2042
8f021c978252 fix excessive redraws on pages with bugs
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 2040
diff changeset
680 BugMeter->align(FL_ALIGN_INSIDE | FL_ALIGN_TEXT_NEXT_TO_IMAGE);
1945
b24a5b73ff10 Made the status bar visible and operative.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1944
diff changeset
681 if (prefs.show_tooltip)
b24a5b73ff10 Made the status bar visible and operative.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1944
diff changeset
682 BugMeter->tooltip("Show HTML bugs\n(right-click for menu)");
b24a5b73ff10 Made the status bar visible and operative.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1944
diff changeset
683 BugMeter->callback(bugmeter_cb, this);
b24a5b73ff10 Made the status bar visible and operative.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1944
diff changeset
684 BugMeter->clear_visible_focus();
b24a5b73ff10 Made the status bar visible and operative.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1944
diff changeset
685
1947
821e6262ead9 Keybindings and some variable name normalizations
Jorge Arellano Cid <jcid@dillo.org>
parents: 1945
diff changeset
686 StatusBar->end();
821e6262ead9 Keybindings and some variable name normalizations
Jorge Arellano Cid <jcid@dillo.org>
parents: 1945
diff changeset
687 StatusBar->resizable(StatusOutput);
2052
89af8495455f remove use of Fl_Pack to avoid resizing issues
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 2042
diff changeset
688 StatusBar->rearrange();
946
f06d5c581f58 Moved creation of the UI's status panel into a function.
corvid <corvid@lavabit.com>
parents: 930
diff changeset
689 }
f06d5c581f58 Moved creation of the UI's status panel into a function.
corvid <corvid@lavabit.com>
parents: 930
diff changeset
690
f06d5c581f58 Moved creation of the UI's status panel into a function.
corvid <corvid@lavabit.com>
parents: 930
diff changeset
691 /*
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
692 * User Interface constructor
930
b277eed3119c whitespace cleanup: 's/ +$//g'
Jorge Arellano Cid <jcid@dillo.org>
parents: 907
diff changeset
693 */
1928
261762bef174 Part of the UI wasn't visible. This minor changes fix it.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1927
diff changeset
694 UI::UI(int x, int y, int ui_w, int ui_h, const char* label, const UI *cur_ui) :
2052
89af8495455f remove use of Fl_Pack to avoid resizing issues
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 2042
diff changeset
695 CustGroupVertical(x, y, ui_w, ui_h, label)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
696 {
438
29c514f5ce00 - Added the "middle_click_drags_page" dillorc option.
jcid
parents: 408
diff changeset
697 PointerOnLink = FALSE;
29c514f5ce00 - Added the "middle_click_drags_page" dillorc option.
jcid
parents: 408
diff changeset
698
1967
fa525b466aef Fixed offset bugs with panel tiny and large (also fullscreen mode for large)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1959
diff changeset
699 MenuBar = LocBar = NavBar = StatusBar = NULL;
1953
808ca0de6d8f Made fullscreen work again (Ctrl+Space)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1952
diff changeset
700
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 337
diff changeset
701 Tabs = NULL;
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 337
diff changeset
702 TabTooltip = NULL;
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
703 TopGroup = this;
2012
bfb8bc9ddf62 Avoid lots of flicker while resizing the window
Jorge Arellano Cid <jcid@dillo.org>
parents: 2004
diff changeset
704 TopGroup->box(FL_NO_BOX);
1806
6e5e5125dd97 RAW_LABEL is SHORTCUT_LABEL
corvid <corvid@lavabit.com>
parents: 1795
diff changeset
705 clear_flag(SHORTCUT_LABEL);
930
b277eed3119c whitespace cleanup: 's/ +$//g'
Jorge Arellano Cid <jcid@dillo.org>
parents: 907
diff changeset
706
72
fbda2a94d998 - Made "New browser window" inherit the panel style of its parent.
jcid
parents: 61
diff changeset
707 if (cur_ui) {
fbda2a94d998 - Made "New browser window" inherit the panel style of its parent.
jcid
parents: 61
diff changeset
708 PanelSize = cur_ui->PanelSize;
fbda2a94d998 - Made "New browser window" inherit the panel style of its parent.
jcid
parents: 61
diff changeset
709 CuteColor = cur_ui->CuteColor;
fbda2a94d998 - Made "New browser window" inherit the panel style of its parent.
jcid
parents: 61
diff changeset
710 Small_Icons = cur_ui->Small_Icons;
1584
5d2db34381f9 don't inherit UI_TEMPORARILY_SHOW_PANELS, use UI_HIDDEN instead
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1579
diff changeset
711 if (cur_ui->Panelmode == UI_HIDDEN ||
5d2db34381f9 don't inherit UI_TEMPORARILY_SHOW_PANELS, use UI_HIDDEN instead
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1579
diff changeset
712 cur_ui->Panelmode == UI_TEMPORARILY_SHOW_PANELS)
5d2db34381f9 don't inherit UI_TEMPORARILY_SHOW_PANELS, use UI_HIDDEN instead
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1579
diff changeset
713 Panelmode = UI_HIDDEN;
5d2db34381f9 don't inherit UI_TEMPORARILY_SHOW_PANELS, use UI_HIDDEN instead
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1579
diff changeset
714 else
5d2db34381f9 don't inherit UI_TEMPORARILY_SHOW_PANELS, use UI_HIDDEN instead
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 1579
diff changeset
715 Panelmode = UI_NORMAL;
72
fbda2a94d998 - Made "New browser window" inherit the panel style of its parent.
jcid
parents: 61
diff changeset
716 } else {
fbda2a94d998 - Made "New browser window" inherit the panel style of its parent.
jcid
parents: 61
diff changeset
717 // Set some default values
fbda2a94d998 - Made "New browser window" inherit the panel style of its parent.
jcid
parents: 61
diff changeset
718 //PanelSize = P_tiny, CuteColor = 26, Small_Icons = 0;
82
ac9dd0d4c7b0 - Enabled panel_size in preferences.
jcid
parents: 75
diff changeset
719 PanelSize = prefs.panel_size;
ac9dd0d4c7b0 - Enabled panel_size in preferences.
jcid
parents: 75
diff changeset
720 Small_Icons = prefs.small_icons;
ac9dd0d4c7b0 - Enabled panel_size in preferences.
jcid
parents: 75
diff changeset
721 CuteColor = 206;
217
a27eafd634d1 - Made CTRL-l focus the location bar instead of popping up a dialog.
jcid
parents: 213
diff changeset
722 Panelmode = (UIPanelmode) prefs.fullwindow_start;
72
fbda2a94d998 - Made "New browser window" inherit the panel style of its parent.
jcid
parents: 61
diff changeset
723 }
fbda2a94d998 - Made "New browser window" inherit the panel style of its parent.
jcid
parents: 61
diff changeset
724
86
c6cecbed4727 - Made TopGroup a PackedGroup, simplifying UI code and removing workarounds.
jcid
parents: 82
diff changeset
725 // Control panel
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
726 TopGroup->begin();
1928
261762bef174 Part of the UI wasn't visible. This minor changes fix it.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1927
diff changeset
727 make_panel(ui_w);
2024
f542084fa707 rm spaces
corvid <corvid@lavabit.com>
parents: 2012
diff changeset
728
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
729 // Render area
2052
89af8495455f remove use of Fl_Pack to avoid resizing issues
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 2042
diff changeset
730 Main = new Fl_Group(0,0,0,0,"Welcome..."); // size is set by rearrange()
1928
261762bef174 Part of the UI wasn't visible. This minor changes fix it.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1927
diff changeset
731 Main->align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
732 Main->box(FL_FLAT_BOX);
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
733 Main->color(FL_GRAY_RAMP + 3);
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
734 Main->labelfont(FL_HELVETICA_BOLD_ITALIC);
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
735 Main->labelsize(36);
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
736 Main->labeltype(FL_SHADOW_LABEL);
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
737 Main->labelcolor(FL_WHITE);
1975
06bbf0f0df1c Switched make_panel() to use insert() instead of begin()/end() pairs
Jorge Arellano Cid <jcid@dillo.org>
parents: 1972
diff changeset
738 TopGroup->add(Main);
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
739 TopGroup->resizable(Main);
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
740 MainIdx = TopGroup->find(Main);
2024
f542084fa707 rm spaces
corvid <corvid@lavabit.com>
parents: 2012
diff changeset
741
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
742 // Find text bar
1948
caf71cd30ec8 Made the findbar operative again (it has tricks and workarounds)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1947
diff changeset
743 FindBarSpace = 1;
caf71cd30ec8 Made the findbar operative again (it has tricks and workarounds)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1947
diff changeset
744 FindBar = new Findbar(ui_w, fh);
caf71cd30ec8 Made the findbar operative again (it has tricks and workarounds)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1947
diff changeset
745 TopGroup->add(FindBar);
1947
821e6262ead9 Keybindings and some variable name normalizations
Jorge Arellano Cid <jcid@dillo.org>
parents: 1945
diff changeset
746
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
747 // Status Panel
1947
821e6262ead9 Keybindings and some variable name normalizations
Jorge Arellano Cid <jcid@dillo.org>
parents: 1945
diff changeset
748 make_status_bar(ui_w, ui_h);
1948
caf71cd30ec8 Made the findbar operative again (it has tricks and workarounds)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1947
diff changeset
749 TopGroup->add(StatusBar);
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
750 TopGroup->end();
2052
89af8495455f remove use of Fl_Pack to avoid resizing issues
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 2042
diff changeset
751 TopGroup->rearrange();
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
752
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
753 // Make the full screen button (to be attached to the viewport later)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
754 // TODO: attach to the viewport
1813
6a203275d317 a bit of src/ui
corvid <corvid@lavabit.com>
parents: 1806
diff changeset
755 //FullScreen = new Fl_Button(0,0,15,15);
337
47c57c73dd2c - minor mem leak fix.
jcid
parents: 333
diff changeset
756 //FullScreen->image(ImgFullScreenOn);
47c57c73dd2c - minor mem leak fix.
jcid
parents: 333
diff changeset
757 //FullScreen->tooltip("Hide Controls");
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 337
diff changeset
758 //FullScreen->callback(fullscreen_cb, this);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
759
32
90c545de7201 - Enabled hiding widgets of the control panel from dillorc2.
jcid
parents: 30
diff changeset
760 customize(0);
90c545de7201 - Enabled hiding widgets of the control panel from dillorc2.
jcid
parents: 30
diff changeset
761
217
a27eafd634d1 - Made CTRL-l focus the location bar instead of popping up a dialog.
jcid
parents: 213
diff changeset
762 if (Panelmode) {
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
763 //Panel->hide();
1947
821e6262ead9 Keybindings and some variable name normalizations
Jorge Arellano Cid <jcid@dillo.org>
parents: 1945
diff changeset
764 //StatusBar->hide();
72
fbda2a94d998 - Made "New browser window" inherit the panel style of its parent.
jcid
parents: 61
diff changeset
765 }
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
766 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
767
301
da2c1fb876c8 - implemented UI's destructor (i.e. UI::~UI())
jcid
parents: 224
diff changeset
768 /*
da2c1fb876c8 - implemented UI's destructor (i.e. UI::~UI())
jcid
parents: 224
diff changeset
769 * UI destructor
da2c1fb876c8 - implemented UI's destructor (i.e. UI::~UI())
jcid
parents: 224
diff changeset
770 */
da2c1fb876c8 - implemented UI's destructor (i.e. UI::~UI())
jcid
parents: 224
diff changeset
771 UI::~UI()
da2c1fb876c8 - implemented UI's destructor (i.e. UI::~UI())
jcid
parents: 224
diff changeset
772 {
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 337
diff changeset
773 _MSG("UI::~UI()\n");
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 337
diff changeset
774 dFree(TabTooltip);
2003
fd842ba40164 FindBar leak
corvid <corvid@lavabit.com>
parents: 1997
diff changeset
775
fd842ba40164 FindBar leak
corvid <corvid@lavabit.com>
parents: 1997
diff changeset
776 if (!FindBarSpace)
fd842ba40164 FindBar leak
corvid <corvid@lavabit.com>
parents: 1997
diff changeset
777 delete FindBar;
301
da2c1fb876c8 - implemented UI's destructor (i.e. UI::~UI())
jcid
parents: 224
diff changeset
778 }
220
2b5b315bcf24 - Set key bindings to its modifiers when alone only.
jcid
parents: 217
diff changeset
779
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
780 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
781 * FLTK event handler for this window.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
782 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
783 int UI::handle(int event)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
784 {
1791
corvid <corvid@lavabit.com>
parents: 1790
diff changeset
785 _MSG("UI::handle event=%d (%d,%d)\n", event, Fl::event_x(), Fl::event_y());
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 337
diff changeset
786
1064
485acc9e60e2 Added configurable keybindings! (in ~/.dillo/keysrc) # part1
Jorge Arellano Cid <jcid@dillo.org>
parents: 946
diff changeset
787 int ret = 0;
1791
corvid <corvid@lavabit.com>
parents: 1790
diff changeset
788 if (event == FL_KEYBOARD) {
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 337
diff changeset
789 return 0; // Receive as shortcut
1791
corvid <corvid@lavabit.com>
parents: 1790
diff changeset
790 } else if (event == FL_SHORTCUT) {
1158
752b1f8da34f KeysCommand_t
corvid <corvid@lavabit.com>
parents: 1122
diff changeset
791 KeysCommand_t cmd = Keys::getKeyCmd();
1064
485acc9e60e2 Added configurable keybindings! (in ~/.dillo/keysrc) # part1
Jorge Arellano Cid <jcid@dillo.org>
parents: 946
diff changeset
792 if (cmd == KEYS_NOP) {
485acc9e60e2 Added configurable keybindings! (in ~/.dillo/keysrc) # part1
Jorge Arellano Cid <jcid@dillo.org>
parents: 946
diff changeset
793 // Do nothing
1209
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1195
diff changeset
794 } else if (cmd == KEYS_SCREEN_UP || cmd == KEYS_SCREEN_DOWN ||
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1195
diff changeset
795 cmd == KEYS_LINE_UP || cmd == KEYS_LINE_DOWN ||
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1195
diff changeset
796 cmd == KEYS_LEFT || cmd == KEYS_RIGHT ||
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1195
diff changeset
797 cmd == KEYS_TOP || cmd == KEYS_BOTTOM) {
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1195
diff changeset
798 a_UIcmd_scroll(a_UIcmd_get_bw_by_widget(this), cmd);
6b35322fb5f2 keybindings for scrolling
corvid <corvid@lavabit.com>
parents: 1195
diff changeset
799 ret = 1;
1064
485acc9e60e2 Added configurable keybindings! (in ~/.dillo/keysrc) # part1
Jorge Arellano Cid <jcid@dillo.org>
parents: 946
diff changeset
800 } else if (cmd == KEYS_BACK) {
485acc9e60e2 Added configurable keybindings! (in ~/.dillo/keysrc) # part1
Jorge Arellano Cid <jcid@dillo.org>
parents: 946
diff changeset
801 a_UIcmd_back(a_UIcmd_get_bw_by_widget(this));
485acc9e60e2 Added configurable keybindings! (in ~/.dillo/keysrc) # part1
Jorge Arellano Cid <jcid@dillo.org>
parents: 946
diff changeset
802 ret = 1;
485acc9e60e2 Added configurable keybindings! (in ~/.dillo/keysrc) # part1
Jorge Arellano Cid <jcid@dillo.org>
parents: 946
diff changeset
803 } else if (cmd == KEYS_FORWARD) {
485acc9e60e2 Added configurable keybindings! (in ~/.dillo/keysrc) # part1
Jorge Arellano Cid <jcid@dillo.org>
parents: 946
diff changeset
804 a_UIcmd_forw(a_UIcmd_get_bw_by_widget(this));
485acc9e60e2 Added configurable keybindings! (in ~/.dillo/keysrc) # part1
Jorge Arellano Cid <jcid@dillo.org>
parents: 946
diff changeset
805 ret = 1;
485acc9e60e2 Added configurable keybindings! (in ~/.dillo/keysrc) # part1
Jorge Arellano Cid <jcid@dillo.org>
parents: 946
diff changeset
806 } else if (cmd == KEYS_BOOKMARKS) {
485acc9e60e2 Added configurable keybindings! (in ~/.dillo/keysrc) # part1
Jorge Arellano Cid <jcid@dillo.org>
parents: 946
diff changeset
807 a_UIcmd_book(a_UIcmd_get_bw_by_widget(this));
485acc9e60e2 Added configurable keybindings! (in ~/.dillo/keysrc) # part1
Jorge Arellano Cid <jcid@dillo.org>
parents: 946
diff changeset
808 ret = 1;
485acc9e60e2 Added configurable keybindings! (in ~/.dillo/keysrc) # part1
Jorge Arellano Cid <jcid@dillo.org>
parents: 946
diff changeset
809 } else if (cmd == KEYS_FIND) {
1995
5c3180af5df3 Re-enabled "Find text" to select text when already shown
Jorge Arellano Cid <jcid@dillo.org>
parents: 1988
diff changeset
810 findbar_toggle(1);
1064
485acc9e60e2 Added configurable keybindings! (in ~/.dillo/keysrc) # part1
Jorge Arellano Cid <jcid@dillo.org>
parents: 946
diff changeset
811 ret = 1;
485acc9e60e2 Added configurable keybindings! (in ~/.dillo/keysrc) # part1
Jorge Arellano Cid <jcid@dillo.org>
parents: 946
diff changeset
812 } else if (cmd == KEYS_WEBSEARCH) {
485acc9e60e2 Added configurable keybindings! (in ~/.dillo/keysrc) # part1
Jorge Arellano Cid <jcid@dillo.org>
parents: 946
diff changeset
813 a_UIcmd_search_dialog(a_UIcmd_get_bw_by_widget(this));
485acc9e60e2 Added configurable keybindings! (in ~/.dillo/keysrc) # part1
Jorge Arellano Cid <jcid@dillo.org>
parents: 946
diff changeset
814 ret = 1;
485acc9e60e2 Added configurable keybindings! (in ~/.dillo/keysrc) # part1
Jorge Arellano Cid <jcid@dillo.org>
parents: 946
diff changeset
815 } else if (cmd == KEYS_GOTO) {
485acc9e60e2 Added configurable keybindings! (in ~/.dillo/keysrc) # part1
Jorge Arellano Cid <jcid@dillo.org>
parents: 946
diff changeset
816 focus_location();
485acc9e60e2 Added configurable keybindings! (in ~/.dillo/keysrc) # part1
Jorge Arellano Cid <jcid@dillo.org>
parents: 946
diff changeset
817 ret = 1;
1954
b0fd6feb8c51 Bound KEYS_HIDE_PANELS key to hide panels (escape)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1953
diff changeset
818 } else if (cmd == KEYS_HIDE_PANELS) {
b0fd6feb8c51 Bound KEYS_HIDE_PANELS key to hide panels (escape)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1953
diff changeset
819 fullscreen_toggle();
1064
485acc9e60e2 Added configurable keybindings! (in ~/.dillo/keysrc) # part1
Jorge Arellano Cid <jcid@dillo.org>
parents: 946
diff changeset
820 ret = 1;
1954
b0fd6feb8c51 Bound KEYS_HIDE_PANELS key to hide panels (escape)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1953
diff changeset
821 //if (get_panelmode() == UI_TEMPORARILY_SHOW_PANELS)
b0fd6feb8c51 Bound KEYS_HIDE_PANELS key to hide panels (escape)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1953
diff changeset
822 // set_panelmode(UI_HIDDEN);
1064
485acc9e60e2 Added configurable keybindings! (in ~/.dillo/keysrc) # part1
Jorge Arellano Cid <jcid@dillo.org>
parents: 946
diff changeset
823 } else if (cmd == KEYS_OPEN) {
485acc9e60e2 Added configurable keybindings! (in ~/.dillo/keysrc) # part1
Jorge Arellano Cid <jcid@dillo.org>
parents: 946
diff changeset
824 a_UIcmd_open_file(a_UIcmd_get_bw_by_widget(this));
485acc9e60e2 Added configurable keybindings! (in ~/.dillo/keysrc) # part1
Jorge Arellano Cid <jcid@dillo.org>
parents: 946
diff changeset
825 ret = 1;
485acc9e60e2 Added configurable keybindings! (in ~/.dillo/keysrc) # part1
Jorge Arellano Cid <jcid@dillo.org>
parents: 946
diff changeset
826 } else if (cmd == KEYS_HOME) {
485acc9e60e2 Added configurable keybindings! (in ~/.dillo/keysrc) # part1
Jorge Arellano Cid <jcid@dillo.org>
parents: 946
diff changeset
827 a_UIcmd_home(a_UIcmd_get_bw_by_widget(this));
485acc9e60e2 Added configurable keybindings! (in ~/.dillo/keysrc) # part1
Jorge Arellano Cid <jcid@dillo.org>
parents: 946
diff changeset
828 ret = 1;
485acc9e60e2 Added configurable keybindings! (in ~/.dillo/keysrc) # part1
Jorge Arellano Cid <jcid@dillo.org>
parents: 946
diff changeset
829 } else if (cmd == KEYS_RELOAD) {
485acc9e60e2 Added configurable keybindings! (in ~/.dillo/keysrc) # part1
Jorge Arellano Cid <jcid@dillo.org>
parents: 946
diff changeset
830 a_UIcmd_reload(a_UIcmd_get_bw_by_widget(this));
485acc9e60e2 Added configurable keybindings! (in ~/.dillo/keysrc) # part1
Jorge Arellano Cid <jcid@dillo.org>
parents: 946
diff changeset
831 ret = 1;
1195
3d823ef2f6e3 Added the "stop" keybinding (not bound!)
corvid <corvid@lavabit.com>
parents: 1186
diff changeset
832 } else if (cmd == KEYS_STOP) {
3d823ef2f6e3 Added the "stop" keybinding (not bound!)
corvid <corvid@lavabit.com>
parents: 1186
diff changeset
833 a_UIcmd_stop(a_UIcmd_get_bw_by_widget(this));
3d823ef2f6e3 Added the "stop" keybinding (not bound!)
corvid <corvid@lavabit.com>
parents: 1186
diff changeset
834 ret = 1;
1308
23900c1bdf8d 'save' key action
corvid <corvid@lavabit.com>
parents: 1222
diff changeset
835 } else if (cmd == KEYS_SAVE) {
23900c1bdf8d 'save' key action
corvid <corvid@lavabit.com>
parents: 1222
diff changeset
836 a_UIcmd_save(a_UIcmd_get_bw_by_widget(this));
23900c1bdf8d 'save' key action
corvid <corvid@lavabit.com>
parents: 1222
diff changeset
837 ret = 1;
1064
485acc9e60e2 Added configurable keybindings! (in ~/.dillo/keysrc) # part1
Jorge Arellano Cid <jcid@dillo.org>
parents: 946
diff changeset
838 } else if (cmd == KEYS_FULLSCREEN) {
1953
808ca0de6d8f Made fullscreen work again (Ctrl+Space)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1952
diff changeset
839 fullscreen_toggle();
1064
485acc9e60e2 Added configurable keybindings! (in ~/.dillo/keysrc) # part1
Jorge Arellano Cid <jcid@dillo.org>
parents: 946
diff changeset
840 ret = 1;
485acc9e60e2 Added configurable keybindings! (in ~/.dillo/keysrc) # part1
Jorge Arellano Cid <jcid@dillo.org>
parents: 946
diff changeset
841 } else if (cmd == KEYS_FILE_MENU) {
485acc9e60e2 Added configurable keybindings! (in ~/.dillo/keysrc) # part1
Jorge Arellano Cid <jcid@dillo.org>
parents: 946
diff changeset
842 a_UIcmd_file_popup(a_UIcmd_get_bw_by_widget(this), FileButton);
485acc9e60e2 Added configurable keybindings! (in ~/.dillo/keysrc) # part1
Jorge Arellano Cid <jcid@dillo.org>
parents: 946
diff changeset
843 ret = 1;
333
9b507e8840a2 - Reverted an accidental testing code commit.
jcid
parents: 332
diff changeset
844 }
1947
821e6262ead9 Keybindings and some variable name normalizations
Jorge Arellano Cid <jcid@dillo.org>
parents: 1945
diff changeset
845 }
821e6262ead9 Keybindings and some variable name normalizations
Jorge Arellano Cid <jcid@dillo.org>
parents: 1945
diff changeset
846 #if 0
1791
corvid <corvid@lavabit.com>
parents: 1790
diff changeset
847 } else if (event == FL_PUSH) {
438
29c514f5ce00 - Added the "middle_click_drags_page" dillorc option.
jcid
parents: 408
diff changeset
848 if (prefs.middle_click_drags_page == 0 &&
1791
corvid <corvid@lavabit.com>
parents: 1790
diff changeset
849 Fl::event_button() == FL_MIDDLE_MOUSE &&
438
29c514f5ce00 - Added the "middle_click_drags_page" dillorc option.
jcid
parents: 408
diff changeset
850 !a_UIcmd_pointer_on_link(a_UIcmd_get_bw_by_widget(this))) {
1823
ca17943888ad more src/ui
corvid <corvid@lavabit.com>
parents: 1822
diff changeset
851 if (Main->contains(Fl::belowmouse())) {
1559
3bafb7d27d78 allow pasting into form widgets when middle_click_drags_page=NO
corvid <corvid@lavabit.com>
parents: 1525
diff changeset
852 /* Offer the event to Main's children (form widgets) */
1823
ca17943888ad more src/ui
corvid <corvid@lavabit.com>
parents: 1822
diff changeset
853 /* TODO: Try just offering it to Fl::belowmouse() */
1813
6a203275d317 a bit of src/ui
corvid <corvid@lavabit.com>
parents: 1806
diff changeset
854 ret = ((Fl_Group *)Main)->Fl_Group::handle(event);
1559
3bafb7d27d78 allow pasting into form widgets when middle_click_drags_page=NO
corvid <corvid@lavabit.com>
parents: 1525
diff changeset
855 }
3bafb7d27d78 allow pasting into form widgets when middle_click_drags_page=NO
corvid <corvid@lavabit.com>
parents: 1525
diff changeset
856 if (!ret) {
3bafb7d27d78 allow pasting into form widgets when middle_click_drags_page=NO
corvid <corvid@lavabit.com>
parents: 1525
diff changeset
857 /* middle click was not on a link or a form widget */
3bafb7d27d78 allow pasting into form widgets when middle_click_drags_page=NO
corvid <corvid@lavabit.com>
parents: 1525
diff changeset
858 paste_url();
3bafb7d27d78 allow pasting into form widgets when middle_click_drags_page=NO
corvid <corvid@lavabit.com>
parents: 1525
diff changeset
859 ret = 1;
3bafb7d27d78 allow pasting into form widgets when middle_click_drags_page=NO
corvid <corvid@lavabit.com>
parents: 1525
diff changeset
860 }
438
29c514f5ce00 - Added the "middle_click_drags_page" dillorc option.
jcid
parents: 408
diff changeset
861 }
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
862 }
1929
5ce120292c22 Added code and made the necesary bindings so tabs start to be functional
Jorge Arellano Cid <jcid@dillo.org>
parents: 1928
diff changeset
863 #endif
1064
485acc9e60e2 Added configurable keybindings! (in ~/.dillo/keysrc) # part1
Jorge Arellano Cid <jcid@dillo.org>
parents: 946
diff changeset
864 if (!ret) {
1813
6a203275d317 a bit of src/ui
corvid <corvid@lavabit.com>
parents: 1806
diff changeset
865 ret = Fl_Group::handle(event);
1064
485acc9e60e2 Added configurable keybindings! (in ~/.dillo/keysrc) # part1
Jorge Arellano Cid <jcid@dillo.org>
parents: 946
diff changeset
866 }
485acc9e60e2 Added configurable keybindings! (in ~/.dillo/keysrc) # part1
Jorge Arellano Cid <jcid@dillo.org>
parents: 946
diff changeset
867
52
1c6b55026e84 Switched UI shortcuts from a global event handler to UI::handle.
jcid
parents: 51
diff changeset
868 return ret;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
869 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
870
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
871
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
872 //----------------------------
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
873 // API for the User Interface
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
874 //----------------------------
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
875
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
876 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
877 * Get the text from the location input-box.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
878 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
879 const char *UI::get_location()
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
880 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
881 return Location->value();
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
882 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
883
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
884 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
885 * Set a new URL in the location input-box.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
886 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
887 void UI::set_location(const char *str)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
888 {
381
a6e2a67f8393 - Avoid a valgrind detexcted illegal memory access.
jcid
parents: 378
diff changeset
889 if (!str) str = "";
1822
a0ed332132e1 some more src/ui
corvid <corvid@lavabit.com>
parents: 1813
diff changeset
890 Location->value(str);
381
a6e2a67f8393 - Avoid a valgrind detexcted illegal memory access.
jcid
parents: 378
diff changeset
891 Location->position(strlen(str));
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
892 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
893
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
894 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
895 * Focus location entry.
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 337
diff changeset
896 * If it's not visible, show it until the callback is done.
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
897 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
898 void UI::focus_location()
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
899 {
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 337
diff changeset
900 if (get_panelmode() == UI_HIDDEN) {
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 337
diff changeset
901 set_panelmode(UI_TEMPORARILY_SHOW_PANELS);
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 337
diff changeset
902 }
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
903 Location->take_focus();
314
cf1216d236d4 - Reimplemented the menubar in a more ortodox way.
jcid
parents: 311
diff changeset
904 // Make text selected when already focused.
cf1216d236d4 - Reimplemented the menubar in a more ortodox way.
jcid
parents: 311
diff changeset
905 Location->position(Location->size(), 0);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
906 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
907
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
908 /*
341
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 337
diff changeset
909 * Focus Main area.
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 337
diff changeset
910 */
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 337
diff changeset
911 void UI::focus_main()
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 337
diff changeset
912 {
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 337
diff changeset
913 Main->take_focus();
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 337
diff changeset
914 }
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 337
diff changeset
915
215da0caf90b - Implemented tabbed browsing.
jcid
parents: 337
diff changeset
916 /*
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
917 * Set a new message in the status bar.
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
918 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
919 void UI::set_status(const char *str)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
920 {
1822
a0ed332132e1 some more src/ui
corvid <corvid@lavabit.com>
parents: 1813
diff changeset
921 StatusOutput->value(str);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
922 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
923
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
924 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
925 * Set the page progress text
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
926 * cmd: 0 Deactivate, 1 Update, 2 Clear
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
927 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
928 void UI::set_page_prog(size_t nbytes, int cmd)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
929 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
930 char str[32];
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
931
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
932 if (cmd == 0) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
933 PProg->deactivate();
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
934 } else {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
935 PProg->activate();
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
936 if (cmd == 1) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
937 snprintf(str, 32, "%s%.1f KB",
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
938 (PanelSize == 0) ? "" : "Page\n", nbytes/1024.0);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
939 } else if (cmd == 2) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
940 str[0] = '\0';
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
941 }
75
4dfc78307039 Made progress bars resize automatically.
jcid
parents: 72
diff changeset
942 PProg->update_label(str);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
943 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
944 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
945
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
946 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
947 * Set the image progress text
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
948 * cmd: 0 Deactivate, 1 Update, 2 Clear
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
949 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
950 void UI::set_img_prog(int n_img, int t_img, int cmd)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
951 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
952 char str[32];
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
953
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
954 if (cmd == 0) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
955 IProg->deactivate();
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
956 } else {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
957 IProg->activate();
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
958 if (cmd == 1) {
930
b277eed3119c whitespace cleanup: 's/ +$//g'
Jorge Arellano Cid <jcid@dillo.org>
parents: 907
diff changeset
959 snprintf(str, 32, "%s%d of %d",
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
960 (PanelSize == 0) ? "" : "Images\n", n_img, t_img);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
961 } else if (cmd == 2) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
962 str[0] = '\0';
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
963 }
75
4dfc78307039 Made progress bars resize automatically.
jcid
parents: 72
diff changeset
964 IProg->update_label(str);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
965 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
966 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
967
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
968 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
969 * Set the bug meter progress text
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
970 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
971 void UI::set_bug_prog(int n_bug)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
972 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
973 char str[32];
1950
cd551611000a Made the bug meter number&icon display correctly
Jorge Arellano Cid <jcid@dillo.org>
parents: 1948
diff changeset
974 int new_w = 20;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
975
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
976 if (n_bug == 0) {
374
fb3a62d1aab2 - Set UI's to share icons.
jcid
parents: 372
diff changeset
977 BugMeter->image(icons->ImgMeterOK);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
978 BugMeter->label("");
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
979 } else if (n_bug >= 1) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
980 if (n_bug == 1)
374
fb3a62d1aab2 - Set UI's to share icons.
jcid
parents: 372
diff changeset
981 BugMeter->image(icons->ImgMeterBug);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
982 snprintf(str, 32, "%d", n_bug);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
983 BugMeter->copy_label(str);
1950
cd551611000a Made the bug meter number&icon display correctly
Jorge Arellano Cid <jcid@dillo.org>
parents: 1948
diff changeset
984 new_w = strlen(str)*9 + 20;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
985 }
1950
cd551611000a Made the bug meter number&icon display correctly
Jorge Arellano Cid <jcid@dillo.org>
parents: 1948
diff changeset
986 BugMeter->size(new_w, BugMeter->h());
cd551611000a Made the bug meter number&icon display correctly
Jorge Arellano Cid <jcid@dillo.org>
parents: 1948
diff changeset
987 StatusBar->rearrange();
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
988 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
989
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
990 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
991 * Customize the UI's panel (show/hide buttons)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
992 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
993 void UI::customize(int flags)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
994 {
32
90c545de7201 - Enabled hiding widgets of the control panel from dillorc2.
jcid
parents: 30
diff changeset
995 // flags argument not currently used
90c545de7201 - Enabled hiding widgets of the control panel from dillorc2.
jcid
parents: 30
diff changeset
996
90c545de7201 - Enabled hiding widgets of the control panel from dillorc2.
jcid
parents: 30
diff changeset
997 if ( !prefs.show_back )
90c545de7201 - Enabled hiding widgets of the control panel from dillorc2.
jcid
parents: 30
diff changeset
998 Back->hide();
90c545de7201 - Enabled hiding widgets of the control panel from dillorc2.
jcid
parents: 30
diff changeset
999 if ( !prefs.show_forw )
90c545de7201 - Enabled hiding widgets of the control panel from dillorc2.
jcid
parents: 30
diff changeset
1000 Forw->hide();
90c545de7201 - Enabled hiding widgets of the control panel from dillorc2.
jcid
parents: 30
diff changeset
1001 if ( !prefs.show_home )
90c545de7201 - Enabled hiding widgets of the control panel from dillorc2.
jcid
parents: 30
diff changeset
1002 Home->hide();
90c545de7201 - Enabled hiding widgets of the control panel from dillorc2.
jcid
parents: 30
diff changeset
1003 if ( !prefs.show_reload )
90c545de7201 - Enabled hiding widgets of the control panel from dillorc2.
jcid
parents: 30
diff changeset
1004 Reload->hide();
90c545de7201 - Enabled hiding widgets of the control panel from dillorc2.
jcid
parents: 30
diff changeset
1005 if ( !prefs.show_save )
90c545de7201 - Enabled hiding widgets of the control panel from dillorc2.
jcid
parents: 30
diff changeset
1006 Save->hide();
90c545de7201 - Enabled hiding widgets of the control panel from dillorc2.
jcid
parents: 30
diff changeset
1007 if ( !prefs.show_stop )
90c545de7201 - Enabled hiding widgets of the control panel from dillorc2.
jcid
parents: 30
diff changeset
1008 Stop->hide();
90c545de7201 - Enabled hiding widgets of the control panel from dillorc2.
jcid
parents: 30
diff changeset
1009 if ( !prefs.show_bookmarks )
90c545de7201 - Enabled hiding widgets of the control panel from dillorc2.
jcid
parents: 30
diff changeset
1010 Bookmarks->hide();
834
9a0725437bf1 Added the show_tools dillorc option
corvid <corvid@lavabit.com>
parents: 827
diff changeset
1011 if ( !prefs.show_tools )
9a0725437bf1 Added the show_tools dillorc option
corvid <corvid@lavabit.com>
parents: 827
diff changeset
1012 Tools->hide();
32
90c545de7201 - Enabled hiding widgets of the control panel from dillorc2.
jcid
parents: 30
diff changeset
1013 if ( !prefs.show_clear_url )
90c545de7201 - Enabled hiding widgets of the control panel from dillorc2.
jcid
parents: 30
diff changeset
1014 Clear->hide();
90c545de7201 - Enabled hiding widgets of the control panel from dillorc2.
jcid
parents: 30
diff changeset
1015 if ( !prefs.show_url )
90c545de7201 - Enabled hiding widgets of the control panel from dillorc2.
jcid
parents: 30
diff changeset
1016 Location->hide();
90c545de7201 - Enabled hiding widgets of the control panel from dillorc2.
jcid
parents: 30
diff changeset
1017 if ( !prefs.show_search )
90c545de7201 - Enabled hiding widgets of the control panel from dillorc2.
jcid
parents: 30
diff changeset
1018 Search->hide();
1525
3c683905dbe3 Added a help button. It tries a local help file then dillo.org's one.
corvid, jcid
parents: 1343
diff changeset
1019 if ( !prefs.show_help )
3c683905dbe3 Added a help button. It tries a local help file then dillo.org's one.
corvid, jcid
parents: 1343
diff changeset
1020 Help->hide();
1997
6debdc67273e Re-enabled "show_progress_box" dillorc preference
Jorge Arellano Cid <jcid@dillo.org>
parents: 1995
diff changeset
1021 if ( !prefs.show_progress_box ) {
6debdc67273e Re-enabled "show_progress_box" dillorc preference
Jorge Arellano Cid <jcid@dillo.org>
parents: 1995
diff changeset
1022 IProg->hide();
6debdc67273e Re-enabled "show_progress_box" dillorc preference
Jorge Arellano Cid <jcid@dillo.org>
parents: 1995
diff changeset
1023 PProg->hide();
6debdc67273e Re-enabled "show_progress_box" dillorc preference
Jorge Arellano Cid <jcid@dillo.org>
parents: 1995
diff changeset
1024 }
1927
e7abafb75d0e Made Dillo code follow my fltk1.3 UI prototype
Jorge Arellano Cid <jcid@dillo.org>
parents: 1925
diff changeset
1025
1980
95f3007dbbfc Made button visibility prefs work again for: search, help and file menu
Jorge Arellano Cid <jcid@dillo.org>
parents: 1978
diff changeset
1026 if (NavBar)
95f3007dbbfc Made button visibility prefs work again for: search, help and file menu
Jorge Arellano Cid <jcid@dillo.org>
parents: 1978
diff changeset
1027 NavBar->rearrange();
95f3007dbbfc Made button visibility prefs work again for: search, help and file menu
Jorge Arellano Cid <jcid@dillo.org>
parents: 1978
diff changeset
1028 if (LocBar)
95f3007dbbfc Made button visibility prefs work again for: search, help and file menu
Jorge Arellano Cid <jcid@dillo.org>
parents: 1978
diff changeset
1029 LocBar->rearrange();
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1030 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1031
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1032 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1033 * On-the-fly panel style change
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1034 */
1977
e816e06ee901 Added a submenu to control the panel size (Tools)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1976
diff changeset
1035 void UI::change_panel(int new_size, int small_icons)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1036 {
1976
041d4979092f Made on-the-fly control panel work again
Jorge Arellano Cid <jcid@dillo.org>
parents: 1975
diff changeset
1037 // Remove current panel's bars
041d4979092f Made on-the-fly control panel work again
Jorge Arellano Cid <jcid@dillo.org>
parents: 1975
diff changeset
1038 init_sizes();
041d4979092f Made on-the-fly control panel work again
Jorge Arellano Cid <jcid@dillo.org>
parents: 1975
diff changeset
1039 TopGroup->remove(MenuBar);
041d4979092f Made on-the-fly control panel work again
Jorge Arellano Cid <jcid@dillo.org>
parents: 1975
diff changeset
1040 Fl::delete_widget(MenuBar);
041d4979092f Made on-the-fly control panel work again
Jorge Arellano Cid <jcid@dillo.org>
parents: 1975
diff changeset
1041 TopGroup->remove(LocBar);
041d4979092f Made on-the-fly control panel work again
Jorge Arellano Cid <jcid@dillo.org>
parents: 1975
diff changeset
1042 Fl::delete_widget(LocBar);
041d4979092f Made on-the-fly control panel work again
Jorge Arellano Cid <jcid@dillo.org>
parents: 1975
diff changeset
1043 TopGroup->remove(NavBar);
041d4979092f Made on-the-fly control panel work again
Jorge Arellano Cid <jcid@dillo.org>
parents: 1975
diff changeset
1044 Fl::delete_widget(NavBar);
041d4979092f Made on-the-fly control panel work again
Jorge Arellano Cid <jcid@dillo.org>
parents: 1975
diff changeset
1045 MenuBar = LocBar = NavBar = NULL;
1927
e7abafb75d0e Made Dillo code follow my fltk1.3 UI prototype
Jorge Arellano Cid <jcid@dillo.org>
parents: 1925
diff changeset
1046
1978
3172b6199fd1 Disabled the right-click-over-search-button hook that changed panel size
Jorge Arellano Cid <jcid@dillo.org>
parents: 1977
diff changeset
1047 // Set internal vars for panel size
3172b6199fd1 Disabled the right-click-over-search-button hook that changed panel size
Jorge Arellano Cid <jcid@dillo.org>
parents: 1977
diff changeset
1048 PanelSize = new_size;
3172b6199fd1 Disabled the right-click-over-search-button hook that changed panel size
Jorge Arellano Cid <jcid@dillo.org>
parents: 1977
diff changeset
1049 Small_Icons = small_icons;
1977
e816e06ee901 Added a submenu to control the panel size (Tools)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1976
diff changeset
1050
1976
041d4979092f Made on-the-fly control panel work again
Jorge Arellano Cid <jcid@dillo.org>
parents: 1975
diff changeset
1051 // make a new panel
041d4979092f Made on-the-fly control panel work again
Jorge Arellano Cid <jcid@dillo.org>
parents: 1975
diff changeset
1052 make_panel(TopGroup->w());
32
90c545de7201 - Enabled hiding widgets of the control panel from dillorc2.
jcid
parents: 30
diff changeset
1053 customize(0);
1977
e816e06ee901 Added a submenu to control the panel size (Tools)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1976
diff changeset
1054 a_UIcmd_set_buttons_sens(a_UIcmd_get_bw_by_widget(this));
1976
041d4979092f Made on-the-fly control panel work again
Jorge Arellano Cid <jcid@dillo.org>
parents: 1975
diff changeset
1055
2052
89af8495455f remove use of Fl_Pack to avoid resizing issues
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 2042
diff changeset
1056 TopGroup->rearrange();
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1057 Location->take_focus();
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1058 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1059
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1060 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1061 * On-the-fly color style change
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1062 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1063 void UI::color_change_cb_i()
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1064 {
479
cd066a3f0405 Added some const quialifiers.
corvid <corvid@lavabit.com>
parents: 451
diff changeset
1065 const int cols[] = {7,17,26,51,140,156,205,206,215,-1};
cd066a3f0405 Added some const quialifiers.
corvid <corvid@lavabit.com>
parents: 451
diff changeset
1066 static int ncolor = 0;
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1067
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1068 ncolor = (cols[ncolor+1] < 0) ? 0 : ncolor + 1;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1069 CuteColor = cols[ncolor];
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1070 MSG("Location color %d\n", CuteColor);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1071 Location->color(CuteColor);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1072 Location->redraw();
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1073 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1074
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1075 /*
217
a27eafd634d1 - Made CTRL-l focus the location bar instead of popping up a dialog.
jcid
parents: 213
diff changeset
1076 * Set or remove the Panelmode flag and update the UI accordingly
a27eafd634d1 - Made CTRL-l focus the location bar instead of popping up a dialog.
jcid
parents: 213
diff changeset
1077 */
a27eafd634d1 - Made CTRL-l focus the location bar instead of popping up a dialog.
jcid
parents: 213
diff changeset
1078 void UI::set_panelmode(UIPanelmode mode)
a27eafd634d1 - Made CTRL-l focus the location bar instead of popping up a dialog.
jcid
parents: 213
diff changeset
1079 {
a27eafd634d1 - Made CTRL-l focus the location bar instead of popping up a dialog.
jcid
parents: 213
diff changeset
1080 if (mode == UI_HIDDEN) {
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
1081 //Panel->hide();
1947
821e6262ead9 Keybindings and some variable name normalizations
Jorge Arellano Cid <jcid@dillo.org>
parents: 1945
diff changeset
1082 StatusBar->hide();
217
a27eafd634d1 - Made CTRL-l focus the location bar instead of popping up a dialog.
jcid
parents: 213
diff changeset
1083 } else {
a27eafd634d1 - Made CTRL-l focus the location bar instead of popping up a dialog.
jcid
parents: 213
diff changeset
1084 /* UI_NORMAL or UI_TEMPORARILY_SHOW_PANELS */
1924
998acefd6a51 Initial changes to make the tiny panel mode work
Jorge Arellano Cid <jcid@dillo.org>
parents: 1843
diff changeset
1085 //Panel->show();
1947
821e6262ead9 Keybindings and some variable name normalizations
Jorge Arellano Cid <jcid@dillo.org>
parents: 1945
diff changeset
1086 StatusBar->show();
217
a27eafd634d1 - Made CTRL-l focus the location bar instead of popping up a dialog.
jcid
parents: 213
diff changeset
1087 }
a27eafd634d1 - Made CTRL-l focus the location bar instead of popping up a dialog.
jcid
parents: 213
diff changeset
1088 Panelmode = mode;
2052
89af8495455f remove use of Fl_Pack to avoid resizing issues
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 2042
diff changeset
1089 TopGroup->rearrange();
217
a27eafd634d1 - Made CTRL-l focus the location bar instead of popping up a dialog.
jcid
parents: 213
diff changeset
1090 }
a27eafd634d1 - Made CTRL-l focus the location bar instead of popping up a dialog.
jcid
parents: 213
diff changeset
1091
a27eafd634d1 - Made CTRL-l focus the location bar instead of popping up a dialog.
jcid
parents: 213
diff changeset
1092 /*
a27eafd634d1 - Made CTRL-l focus the location bar instead of popping up a dialog.
jcid
parents: 213
diff changeset
1093 * Get the value of the panelmode flag
a27eafd634d1 - Made CTRL-l focus the location bar instead of popping up a dialog.
jcid
parents: 213
diff changeset
1094 */
a27eafd634d1 - Made CTRL-l focus the location bar instead of popping up a dialog.
jcid
parents: 213
diff changeset
1095 UIPanelmode UI::get_panelmode()
a27eafd634d1 - Made CTRL-l focus the location bar instead of popping up a dialog.
jcid
parents: 213
diff changeset
1096 {
a27eafd634d1 - Made CTRL-l focus the location bar instead of popping up a dialog.
jcid
parents: 213
diff changeset
1097 return Panelmode;
a27eafd634d1 - Made CTRL-l focus the location bar instead of popping up a dialog.
jcid
parents: 213
diff changeset
1098 }
a27eafd634d1 - Made CTRL-l focus the location bar instead of popping up a dialog.
jcid
parents: 213
diff changeset
1099
a27eafd634d1 - Made CTRL-l focus the location bar instead of popping up a dialog.
jcid
parents: 213
diff changeset
1100 /*
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1101 * Toggle the Control Panel out of the way
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1102 */
217
a27eafd634d1 - Made CTRL-l focus the location bar instead of popping up a dialog.
jcid
parents: 213
diff changeset
1103 void UI::panelmode_cb_i()
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1104 {
217
a27eafd634d1 - Made CTRL-l focus the location bar instead of popping up a dialog.
jcid
parents: 213
diff changeset
1105 set_panelmode((UIPanelmode) !Panelmode);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1106 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1107
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1108 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1109 * Set 'nw' as the main render area widget
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1110 */
1945
b24a5b73ff10 Made the status bar visible and operative.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1944
diff changeset
1111 void UI::set_render_layout(Fl_Group *nw)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1112 {
1945
b24a5b73ff10 Made the status bar visible and operative.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1944
diff changeset
1113 // Resize layout widget to current height
2052
89af8495455f remove use of Fl_Pack to avoid resizing issues
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 2042
diff changeset
1114 nw->resize(0,Main->y(),Main->w(),Main->h());
1945
b24a5b73ff10 Made the status bar visible and operative.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1944
diff changeset
1115
b24a5b73ff10 Made the status bar visible and operative.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1944
diff changeset
1116 TopGroup->insert(*nw, Main);
b24a5b73ff10 Made the status bar visible and operative.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1944
diff changeset
1117 remove(Main);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1118 delete(Main);
1945
b24a5b73ff10 Made the status bar visible and operative.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1944
diff changeset
1119 Main = nw;
1928
261762bef174 Part of the UI wasn't visible. This minor changes fix it.
Jorge Arellano Cid <jcid@dillo.org>
parents: 1927
diff changeset
1120 TopGroup->resizable(Main);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1121 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1122
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1123 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1124 * Set button sensitivity (Back/Forw/Stop)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1125 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1126 void UI::button_set_sens(UIButton btn, int sens)
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1127 {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1128 switch (btn) {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1129 case UI_BACK:
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1130 (sens) ? Back->activate() : Back->deactivate();
1823
ca17943888ad more src/ui
corvid <corvid@lavabit.com>
parents: 1822
diff changeset
1131 // Back->redraw(DAMAGE_HIGHLIGHT);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1132 break;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1133 case UI_FORW:
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1134 (sens) ? Forw->activate() : Forw->deactivate();
1823
ca17943888ad more src/ui
corvid <corvid@lavabit.com>
parents: 1822
diff changeset
1135 // Forw->redraw(DAMAGE_HIGHLIGHT);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1136 break;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1137 case UI_STOP:
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1138 (sens) ? Stop->activate() : Stop->deactivate();
1823
ca17943888ad more src/ui
corvid <corvid@lavabit.com>
parents: 1822
diff changeset
1139 // Stop->redraw(DAMAGE_HIGHLIGHT);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1140 break;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1141 default:
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1142 break;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1143 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1144 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1145
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1146 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1147 * Paste a middle-click-selection into "Clear" button as URL
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1148 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1149 void UI::paste_url()
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1150 {
1822
a0ed332132e1 some more src/ui
corvid <corvid@lavabit.com>
parents: 1813
diff changeset
1151 Fl::paste(*Clear, false);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1152 }
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
1153
224
07d1e0d8463c - Replaced the findtext dialog with an in-window widget!
jcid
parents: 221
diff changeset
1154 /*
1954
b0fd6feb8c51 Bound KEYS_HIDE_PANELS key to hide panels (escape)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1953
diff changeset
1155 * Adjust space for the findbar (if necessary) and show or remove it
224
07d1e0d8463c - Replaced the findtext dialog with an in-window widget!
jcid
parents: 221
diff changeset
1156 */
1948
caf71cd30ec8 Made the findbar operative again (it has tricks and workarounds)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1947
diff changeset
1157 void UI::findbar_toggle(bool add)
224
07d1e0d8463c - Replaced the findtext dialog with an in-window widget!
jcid
parents: 221
diff changeset
1158 {
1948
caf71cd30ec8 Made the findbar operative again (it has tricks and workarounds)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1947
diff changeset
1159 /* WORKAROUND:
caf71cd30ec8 Made the findbar operative again (it has tricks and workarounds)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1947
diff changeset
1160 * This is tricky: As fltk-1.3 resizes hidden widgets (which it
caf71cd30ec8 Made the findbar operative again (it has tricks and workarounds)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1947
diff changeset
1161 * doesn't resize when visible!). We need to go through hoops to
caf71cd30ec8 Made the findbar operative again (it has tricks and workarounds)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1947
diff changeset
1162 * get the desired behaviour.
caf71cd30ec8 Made the findbar operative again (it has tricks and workarounds)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1947
diff changeset
1163 * Most probably this is a bug in FLTK and we have to report it.
caf71cd30ec8 Made the findbar operative again (it has tricks and workarounds)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1947
diff changeset
1164 */
caf71cd30ec8 Made the findbar operative again (it has tricks and workarounds)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1947
diff changeset
1165
1995
5c3180af5df3 Re-enabled "Find text" to select text when already shown
Jorge Arellano Cid <jcid@dillo.org>
parents: 1988
diff changeset
1166 if (add) {
5c3180af5df3 Re-enabled "Find text" to select text when already shown
Jorge Arellano Cid <jcid@dillo.org>
parents: 1988
diff changeset
1167 if (!FindBarSpace) {
5c3180af5df3 Re-enabled "Find text" to select text when already shown
Jorge Arellano Cid <jcid@dillo.org>
parents: 1988
diff changeset
1168 // show
5c3180af5df3 Re-enabled "Find text" to select text when already shown
Jorge Arellano Cid <jcid@dillo.org>
parents: 1988
diff changeset
1169 Main->size(Main->w(), Main->h()-FindBar->h());
5c3180af5df3 Re-enabled "Find text" to select text when already shown
Jorge Arellano Cid <jcid@dillo.org>
parents: 1988
diff changeset
1170 insert(*FindBar, StatusBar);
5c3180af5df3 Re-enabled "Find text" to select text when already shown
Jorge Arellano Cid <jcid@dillo.org>
parents: 1988
diff changeset
1171 FindBar->show();
5c3180af5df3 Re-enabled "Find text" to select text when already shown
Jorge Arellano Cid <jcid@dillo.org>
parents: 1988
diff changeset
1172 FindBarSpace = 1;
5c3180af5df3 Re-enabled "Find text" to select text when already shown
Jorge Arellano Cid <jcid@dillo.org>
parents: 1988
diff changeset
1173 } else {
5c3180af5df3 Re-enabled "Find text" to select text when already shown
Jorge Arellano Cid <jcid@dillo.org>
parents: 1988
diff changeset
1174 // select text
5c3180af5df3 Re-enabled "Find text" to select text when already shown
Jorge Arellano Cid <jcid@dillo.org>
parents: 1988
diff changeset
1175 FindBar->show();
5c3180af5df3 Re-enabled "Find text" to select text when already shown
Jorge Arellano Cid <jcid@dillo.org>
parents: 1988
diff changeset
1176 }
1948
caf71cd30ec8 Made the findbar operative again (it has tricks and workarounds)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1947
diff changeset
1177 } else if (!add && FindBarSpace) {
caf71cd30ec8 Made the findbar operative again (it has tricks and workarounds)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1947
diff changeset
1178 // hide
caf71cd30ec8 Made the findbar operative again (it has tricks and workarounds)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1947
diff changeset
1179 Main->size(Main->w(), Main->h()+FindBar->h());
caf71cd30ec8 Made the findbar operative again (it has tricks and workarounds)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1947
diff changeset
1180 remove(FindBar);
caf71cd30ec8 Made the findbar operative again (it has tricks and workarounds)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1947
diff changeset
1181 FindBarSpace = 0;
224
07d1e0d8463c - Replaced the findtext dialog with an in-window widget!
jcid
parents: 221
diff changeset
1182 }
2052
89af8495455f remove use of Fl_Pack to avoid resizing issues
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 2042
diff changeset
1183 TopGroup->rearrange();
1953
808ca0de6d8f Made fullscreen work again (Ctrl+Space)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1952
diff changeset
1184 }
1948
caf71cd30ec8 Made the findbar operative again (it has tricks and workarounds)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1947
diff changeset
1185
1953
808ca0de6d8f Made fullscreen work again (Ctrl+Space)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1952
diff changeset
1186 /*
808ca0de6d8f Made fullscreen work again (Ctrl+Space)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1952
diff changeset
1187 * Make panels disappear growing the render area.
808ca0de6d8f Made fullscreen work again (Ctrl+Space)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1952
diff changeset
1188 * WORKAROUND: here we avoid hidden widgets resize by setting their
808ca0de6d8f Made fullscreen work again (Ctrl+Space)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1952
diff changeset
1189 * size to (0,0) while hidden.
808ca0de6d8f Made fullscreen work again (Ctrl+Space)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1952
diff changeset
1190 * (Already reported to FLTK team)
808ca0de6d8f Made fullscreen work again (Ctrl+Space)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1952
diff changeset
1191 */
808ca0de6d8f Made fullscreen work again (Ctrl+Space)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1952
diff changeset
1192 void UI::fullscreen_toggle()
808ca0de6d8f Made fullscreen work again (Ctrl+Space)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1952
diff changeset
1193 {
808ca0de6d8f Made fullscreen work again (Ctrl+Space)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1952
diff changeset
1194 int dh = 0;
808ca0de6d8f Made fullscreen work again (Ctrl+Space)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1952
diff changeset
1195 int hide = StatusBar->visible();
808ca0de6d8f Made fullscreen work again (Ctrl+Space)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1952
diff changeset
1196
808ca0de6d8f Made fullscreen work again (Ctrl+Space)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1952
diff changeset
1197 // hide/show panels
808ca0de6d8f Made fullscreen work again (Ctrl+Space)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1952
diff changeset
1198 init_sizes();
1967
fa525b466aef Fixed offset bugs with panel tiny and large (also fullscreen mode for large)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1959
diff changeset
1199 if (MenuBar) {
fa525b466aef Fixed offset bugs with panel tiny and large (also fullscreen mode for large)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1959
diff changeset
1200 dh += mh;
fa525b466aef Fixed offset bugs with panel tiny and large (also fullscreen mode for large)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1959
diff changeset
1201 hide ? MenuBar->size(0,0) : MenuBar->size(w(),mh);
fa525b466aef Fixed offset bugs with panel tiny and large (also fullscreen mode for large)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1959
diff changeset
1202 hide ? MenuBar->hide() : MenuBar->show();
fa525b466aef Fixed offset bugs with panel tiny and large (also fullscreen mode for large)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1959
diff changeset
1203 }
1953
808ca0de6d8f Made fullscreen work again (Ctrl+Space)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1952
diff changeset
1204 if (LocBar) {
808ca0de6d8f Made fullscreen work again (Ctrl+Space)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1952
diff changeset
1205 dh += lh;
808ca0de6d8f Made fullscreen work again (Ctrl+Space)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1952
diff changeset
1206 hide ? LocBar->size(0,0) : LocBar->size(w(),lh);
808ca0de6d8f Made fullscreen work again (Ctrl+Space)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1952
diff changeset
1207 hide ? LocBar->hide() : LocBar->show();
808ca0de6d8f Made fullscreen work again (Ctrl+Space)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1952
diff changeset
1208 }
808ca0de6d8f Made fullscreen work again (Ctrl+Space)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1952
diff changeset
1209 if (NavBar) {
808ca0de6d8f Made fullscreen work again (Ctrl+Space)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1952
diff changeset
1210 dh += nh;
808ca0de6d8f Made fullscreen work again (Ctrl+Space)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1952
diff changeset
1211 hide ? NavBar->size(0,0) : NavBar->size(w(),nh);
808ca0de6d8f Made fullscreen work again (Ctrl+Space)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1952
diff changeset
1212 hide ? NavBar->hide() : NavBar->show();
808ca0de6d8f Made fullscreen work again (Ctrl+Space)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1952
diff changeset
1213 }
808ca0de6d8f Made fullscreen work again (Ctrl+Space)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1952
diff changeset
1214 if (StatusBar) {
808ca0de6d8f Made fullscreen work again (Ctrl+Space)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1952
diff changeset
1215 dh += sh;
808ca0de6d8f Made fullscreen work again (Ctrl+Space)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1952
diff changeset
1216 hide ? StatusBar->size(0,0) : StatusBar->size(w(),sh);;
808ca0de6d8f Made fullscreen work again (Ctrl+Space)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1952
diff changeset
1217 hide ? StatusBar->hide() : StatusBar->show();;
808ca0de6d8f Made fullscreen work again (Ctrl+Space)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1952
diff changeset
1218 }
808ca0de6d8f Made fullscreen work again (Ctrl+Space)
Jorge Arellano Cid <jcid@dillo.org>
parents: 1952
diff changeset
1219
2052
89af8495455f remove use of Fl_Pack to avoid resizing issues
Johannes Hofmann <Johannes.Hofmann@gmx.de>
parents: 2042
diff changeset
1220 TopGroup->rearrange();
224
07d1e0d8463c - Replaced the findtext dialog with an in-window widget!
jcid
parents: 221
diff changeset
1221 }