29#include <FL/Fl_Pixmap.H>
41#if (FL_MAJOR_VERSION == 1 && FL_MINOR_VERSION == 3 && FL_PATCH_VERSION < 10)
42#define FL_BACK_MOUSE 8
43#define FL_FORWARD_MOUSE 9
47 Fl_Image *ImgMeterOK, *ImgMeterBug,
48 *ImgHome, *ImgReload, *ImgSave, *ImgBook, *ImgTools,
49 *ImgClear,*ImgSearch, *ImgHelp, *ImgLeft, *ImgLeftIn,
50 *ImgRight, *ImgRightIn, *ImgStop, *ImgStopIn;
100#define DILLO_INPUTBOX (Fl_Boxtype) (FL_FREE_BOXTYPE + 1)
107 static const int margin_x = 3;
108 CustInput (
int x,
int y,
int w,
int h,
const char* l=0) :
112 Fl_Boxtype b = box();
114 Fl::box_dx(b) + margin_x,
116 Fl::box_dw(b) + margin_x,
120 virtual int handle(
int e);
122 void d_position(
int p);
123 void d_position(
int p,
int m);
128int CustInput::d_position()
130#if FL_API_VERSION < 10400
131 return CustInput::position();
133 return CustInput::insert_position();
137void CustInput::d_position(
int p)
139#if FL_API_VERSION < 10400
140 CustInput::position(p);
142 CustInput::insert_position(p);
147void CustInput::d_position(
int p,
int m)
149#if FL_API_VERSION < 10400
150 CustInput::position(p, m);
152 CustInput::insert_position(p, m);
160int CustInput::handle(
int e)
162 int k = Fl::event_key();
164 _MSG(
"CustInput::handle event=%d\n", e);
167 unsigned modifier = Fl::event_state() & (FL_SHIFT | FL_CTRL | FL_ALT);
171 (k == FL_Up || k == FL_Down || k == FL_Left || k == FL_Right)) {
173 }
else if (e == FL_KEYBOARD) {
174 if (k == FL_Escape && modifier == 0) {
177 }
else if (modifier == FL_SHIFT) {
178 if (k == FL_Left || k == FL_Right) {
182 }
else if (modifier == FL_CTRL) {
186 }
else if (k ==
'k') {
187 cut(d_position(), size());
189 }
else if (k ==
'd') {
190 cut(d_position(), d_position()+1);
192 }
else if (k ==
'a' || k ==
'l') {
194 d_position(size(), 0);
196 }
else if (k ==
'h' || k ==
'o' || k ==
'r' ||
197 k == FL_Home || k == FL_End) {
201 }
else if (modifier == 0) {
202 if (k == FL_Down || k == FL_Up ||
203 k == FL_Page_Down || k == FL_Page_Up || k == FL_Tab) {
209 if (k == FL_Page_Down || k == FL_Page_Up) {
226 CustPasteButton(
int x,
int y,
int w,
int h,
const char *l=0) :
231int CustPasteButton::handle(
int e)
234 const char* t = Fl::event_text();
249class CustProgressBox :
public Fl_Box {
252 CustProgressBox(
int x,
int y,
int w,
int h,
const char *l=0) :
253 Fl_Box(x,y,w,h,l) { padding = 0; };
254 void update_label(
const char *lbl) {
259 padding = w > 2 ? w/2 : 1;
283 int b = Fl::event_button();
285 if (b == FL_LEFT_MOUSE) {
298 if (access(
path, R_OK) == 0) {
303 MSG(
"Can't read local help file at \"%s\"."
304 " Getting remote help...\n",
path);
315 int b = Fl::event_button();
316 if (b == FL_LEFT_MOUSE || b == FL_RIGHT_MOUSE) {
328 int b = Fl::event_button();
329 if (b == FL_LEFT_MOUSE) {
332 }
else if (b == FL_MIDDLE_MOUSE) {
342 Fl_Input *i = (Fl_Input*)wid;
345 _MSG(
"location_cb()\n");
356static void b1_cb(Fl_Widget *wid,
void *cb_data)
359 int b = Fl::event_button();
360 if (b >= FL_LEFT_MOUSE && b <= FL_RIGHT_MOUSE) {
361 _MSG(
"[%s], mouse button %d was pressed\n", button_names[bn], b);
362 _MSG(
"mouse button %d was pressed\n", b);
366 if (b == FL_LEFT_MOUSE) {
368 }
else if (b == FL_MIDDLE_MOUSE) {
370 }
else if (b == FL_RIGHT_MOUSE) {
372 wid->y() + wid->h());
376 if (b == FL_LEFT_MOUSE) {
378 }
else if (b == FL_MIDDLE_MOUSE) {
380 }
else if (b == FL_RIGHT_MOUSE) {
382 wid->y() + wid->h());
386 if (b == FL_LEFT_MOUSE) {
388 }
else if (b == FL_MIDDLE_MOUSE) {
393 if (b == FL_LEFT_MOUSE) {
398 if (b == FL_LEFT_MOUSE) {
403 if (b == FL_LEFT_MOUSE) {
408 if (b == FL_LEFT_MOUSE) {
410 }
else if (b == FL_MIDDLE_MOUSE) {
415 if (b == FL_LEFT_MOUSE || b == FL_RIGHT_MOUSE) {
417 wid->y() + wid->h());
430 int b = Fl::event_button();
431 if (b == FL_LEFT_MOUSE) {
433 }
else if (b == FL_RIGHT_MOUSE) {
461 b->clear_visible_focus();
464 b->down_box(FL_THIN_DOWN_FRAME);
474 if (!
icons->ImgLeftIn) {
476 icons->ImgLeftIn->desaturate();
477 icons->ImgLeftIn->color_average(FL_BACKGROUND_COLOR, .14f);
479 if (!
icons->ImgRightIn) {
481 icons->ImgRightIn->desaturate();
482 icons->ImgRightIn->color_average(FL_BACKGROUND_COLOR, .14f);
484 if (!
icons->ImgStopIn) {
486 icons->ImgStopIn->desaturate();
487 icons->ImgStopIn->color_average(FL_BACKGROUND_COLOR, .14f);
516 b->image(
icons->ImgClear);
518 b->clear_visible_focus();
519 b->box(FL_THIN_UP_BOX);
520 b->
set_tooltip(
"Clear the URL box.\nMiddle-click to paste a URL.");
527 i->when(FL_WHEN_ENTER_KEY);
529 i->set_tooltip(
"Location");
536 b->image(
icons->ImgSearch);
538 b->clear_visible_focus();
539 b->box(FL_THIN_UP_BOX);
544 b->image(
icons->ImgHelp);
546 b->clear_visible_focus();
547 b->box(FL_THIN_UP_BOX);
560 IProg->labelsize(12);
561 IProg->box(thin_up ? FL_THIN_UP_BOX : FL_EMBOSSED_BOX);
562 IProg->update_label(wide ?
"Images\n0 of 0" :
"0 of 0");
566 PProg->labelsize(12);
567 PProg->box(thin_up ? FL_THIN_UP_BOX : FL_EMBOSSED_BOX);
568 PProg->update_label(wide ?
"Page\n0.0 KB" :
"0.0 KB");
578 int w = 0, h = 0, padding;
581 btn->labeltype(FL_FREE_LABELTYPE);
582 btn->measure_label(w, h);
585 btn->measure_label(w,h);
587 btn->size(w+padding, h);
589 _MSG(
"UI::make_filemenu_button w=%d h=%d padding=%d\n", w, h, padding);
590 btn->box(FL_THIN_UP_BOX);
593 btn->clear_visible_focus();
641 NavBar->box(FL_THIN_UP_FRAME);
700 BugMeter->align(FL_ALIGN_INSIDE | FL_ALIGN_TEXT_NEXT_TO_IMAGE);
713UI::UI(
int x,
int y,
int ui_w,
int ui_h,
const char* label,
const UI *cur_ui) :
721 clear_flag(SHORTCUT_LABEL);
740 Main =
new Fl_Group(0,0,0,0,
"Welcome...");
741 Main->align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
742 Main->box(FL_FLAT_BOX);
743 Main->labelfont(FL_HELVETICA_BOLD_ITALIC);
745 Main->labeltype(FL_SHADOW_LABEL);
780 _MSG(
"UI::handle event=%s\n", fl_eventnames[event]);
783 if (event == FL_KEYBOARD) {
785 }
else if (event == FL_SHORTCUT) {
859 }
else if (event == FL_RELEASE) {
860 if (Fl::event_button() == FL_MIDDLE_MOUSE &&
866 }
else if (event == FL_PUSH) {
868 _MSG(
"pressed button %d\n", Fl::event_button());
869 if (Fl::event_button() == FL_BACK_MOUSE) {
872 }
else if (Fl::event_button() == FL_FORWARD_MOUSE) {
879 ret = Fl_Group::handle(event);
910 ((CustInput *)
Location)->d_position((Fl::focus() ==
Location) ? strlen(str) : 0);
960 if (nbytes >= 1024 * 1024) {
962 magnitude = nbytes / (1024 * 1024.0);
965 magnitude = nbytes / 1024.0;
967 snprintf(str, 32,
"%s%.1f %cB",
968 (
PanelSize == 0) ?
"" :
"Page\n", magnitude, prefix);
969 }
else if (cmd == 2) {
972 PProg->update_label(str);
989 snprintf(str, 32,
"%s%d of %d",
990 (
PanelSize == 0) ?
"" :
"Images\n", n_img, t_img);
991 }
else if (cmd == 2) {
994 IProg->update_label(str);
1009 }
else if (n_bug >= 1) {
1012 snprintf(str, 32,
"%d", n_bug);
1014 new_w = strlen(str)*9 + 20;
1070 Fl::delete_widget(
LocBar);
1072 Fl::delete_widget(
NavBar);
1113 (sens) ?
Back->activate() :
Back->deactivate();
1116 (sens) ?
Forw->activate() :
Forw->deactivate();
1119 (sens) ?
Stop->activate() :
Stop->deactivate();
1131 Fl::paste(*
Clear,
false);
Used to reposition group's widgets when some of them are hidden.
Searchbar to find text in page.
void show()
Show the findbar and focus the input field.
static KeysCommand_t getKeyCmd(void)
Look if the just pressed key is bound to a command.
void set_img_prog(int n_img, int t_img, int cmd)
Set the image progress text.
void button_set_sens(UIButton btn, int sens)
Set button sensitivity (Back/Forw/Stop)
void customize()
Customize the UI's panel (show/hide buttons)
CustGroupHorizontal * LocBar
CustButton * make_button(const char *label, Fl_Image *img, Fl_Image *deimg, int b_n, int start=0)
Make a generic navigation button.
void findbar_toggle(bool add)
Adjust space for the findbar (if necessary) and show or remove it.
void set_render_layout(Fl_Group *nw)
Set 'nw' as the main render area widget.
void focus_main()
Focus Main area.
const char * get_location()
Get the text from the location input-box.
void make_toolbar(int tw, int th)
Create the archetipic browser buttons.
void change_panel(int new_size, int small_icons)
On-the-fly panel style change.
void focus_location()
Focus location entry.
int handle(int event)
To manage what events to catch and which to let pass.
void make_status_bar(int ww, int wh)
Create the status panel.
void make_progress_bars(int wide, int thin_up)
Create the progress bars.
CustGroupVertical * TopGroup
CustGroupHorizontal * NavBar
void make_location(int ww)
Create the location box (Clear/Input/Search)
UI(int x, int y, int w, int h, const char *label=0, const UI *cur_ui=NULL)
User Interface constructor.
void set_bug_prog(int n_bug)
Set the bug meter progress text.
CustGroupHorizontal * StatusBar
void panels_toggle()
Make panels disappear growing the render area.
void set_status(const char *str)
Set a new message in the status bar.
void paste_url()
Paste a middle-click-selection into "Clear" button as URL.
void make_panel(int ww)
Create the control panel.
void set_location(const char *str)
Set a new URL in the location input-box.
void make_filemenu_button()
Create the "File" menu.
void set_page_prog(size_t nbytes, int cmd)
Set the page progress text.
char * dStrconcat(const char *s1,...)
Concatenate a NULL-terminated list of strings.
char * dStrdup(const char *s)
const DilloUrl * a_History_get_url(int idx)
Return the DilloUrl field (by index)
static const char *const home_xpm[]
static const char *const save_xpm[]
static const char *const stop_s_xpm[]
static const char *const help_xpm[]
static const char *const left_s_xpm[]
static const char *const left_xpm[]
static const char *const new_s_xpm[]
static const char *const stop_xpm[]
static const char *const search_xpm[]
static const char *const mini_bug_xpm[]
static const char *const tools_xpm[]
static const char *const right_s_xpm[]
static const char *const save_s_xpm[]
static const char *const bm_xpm[]
static const char *const reload_s_xpm[]
static const char *const bm_s_xpm[]
static const char *const reload_xpm[]
static const char *const right_xpm[]
static const char *const home_s_xpm[]
static const char *const mini_ok_xpm[]
static const char *const tools_s_xpm[]
DilloPrefs prefs
Global Data.
static void b1_cb(Fl_Widget *wid, void *cb_data)
Callback handler for button press on the panel.
static void help_cb(Fl_Widget *w, void *)
Callback for the help button.
static struct iconset * icons
static struct iconset small_icons
static struct iconset standard_icons
static void bugmeter_cb(Fl_Widget *wid, void *data)
Callback for the bug meter button.
static void filemenu_cb(Fl_Widget *wid, void *)
Callback for the File menu button.
static void location_cb(Fl_Widget *wid, void *data)
Send the browser to the new URL in the location.
static void search_cb(Fl_Widget *wid, void *data)
Callback for the search button.
static void clear_cb(Fl_Widget *w, void *data)
Callback for the location's clear-button.
@ UI_NORMAL
make sure it's compatible with bool
Contains the specific data for a single window.
bool_t middle_click_drags_page
void a_UIcmd_tools(void *vbw, int x, int y)
void a_UIcmd_book(void *vbw, int nt)
void a_UIcmd_bugmeter_popup(void *vbw)
void a_UIcmd_forw_nt(void *vbw)
void a_UIcmd_home(void *vbw, int nt)
void a_UIcmd_open_file(void *vbw)
void a_UIcmd_zoom_reset(void *vbw)
void a_UIcmd_focus_tab(void *vbw, int index)
void a_UIcmd_zoom_in(void *vbw)
void a_UIcmd_zoom_out(void *vbw)
void a_UIcmd_focus_main_area(BrowserWindow *bw)
void a_UIcmd_reload(void *vbw)
BrowserWindow * a_UIcmd_get_bw_by_widget(void *v_wid)
void a_UIcmd_file_popup(void *vbw, void *v_wid)
void a_UIcmd_view_page_source(BrowserWindow *bw, const DilloUrl *url)
void a_UIcmd_search_dialog(void *vbw)
void a_UIcmd_view_page_bugs(void *vbw)
void a_UIcmd_open_urlstr(void *vbw, const char *urlstr)
void a_UIcmd_set_buttons_sens(BrowserWindow *bw)
void a_UIcmd_forw_popup(void *vbw, int x, int y)
void a_UIcmd_save(void *vbw)
void a_UIcmd_back(void *vbw)
void a_UIcmd_forw(void *vbw)
void a_UIcmd_copy(void *vbw)
void a_UIcmd_back_popup(void *vbw, int x, int y)
void a_UIcmd_stop(void *vbw)
void a_UIcmd_findtext_reset(BrowserWindow *bw)
void a_UIcmd_scroll(BrowserWindow *bw, int icmd)
void a_UIcmd_back_nt(void *vbw)
void a_UIcmd_set_location_text(void *vbw, const char *text)