29#include <FL/Fl_Pixmap.H>
40 Fl_Image *ImgMeterOK, *ImgMeterBug,
41 *ImgHome, *ImgReload, *ImgSave, *ImgBook, *ImgTools,
42 *ImgClear,*ImgSearch, *ImgHelp, *ImgLeft, *ImgLeftIn,
43 *ImgRight, *ImgRightIn, *ImgStop, *ImgStopIn;
98 CustInput (
int x,
int y,
int w,
int h,
const char* l=0) :
100 virtual int handle(
int e);
107int CustInput::handle(
int e)
109 int k = Fl::event_key();
111 _MSG(
"CustInput::handle event=%d\n", e);
114 unsigned modifier = Fl::event_state() & (FL_SHIFT | FL_CTRL | FL_ALT);
118 (k == FL_Up || k == FL_Down || k == FL_Left || k == FL_Right)) {
120 }
else if (e == FL_KEYBOARD) {
121 if (k == FL_Escape && modifier == 0) {
124 }
else if (modifier == FL_SHIFT) {
125 if (k == FL_Left || k == FL_Right) {
129 }
else if (modifier == FL_CTRL) {
130 if (k ==
'a' || k ==
'e') {
131 position(k ==
'a' ? 0 : size());
133 }
else if (k ==
'k') {
134 cut(position(), size());
136 }
else if (k ==
'd') {
137 cut(position(), position()+1);
139 }
else if (k ==
'l') {
143 }
else if (k ==
'h' || k ==
'o' || k ==
'r' ||
144 k == FL_Home || k == FL_End) {
148 }
else if (modifier == 0) {
149 if (k == FL_Down || k == FL_Up ||
150 k == FL_Page_Down || k == FL_Page_Up || k == FL_Tab) {
156 if (k == FL_Page_Down || k == FL_Page_Up) {
173 CustPasteButton(
int x,
int y,
int w,
int h,
const char *l=0) :
178int CustPasteButton::handle(
int e)
181 const char* t = Fl::event_text();
196class CustProgressBox :
public Fl_Box {
199 CustProgressBox(
int x,
int y,
int w,
int h,
const char *l=0) :
200 Fl_Box(x,y,w,h,l) { padding = 0; };
201 void update_label(
const char *lbl) {
206 padding = w > 2 ? w/2 : 1;
230 int b = Fl::event_button();
232 if (b == FL_LEFT_MOUSE) {
245 if (access(
path, R_OK) == 0) {
250 MSG(
"Can't read local help file at \"%s\"."
251 " Getting remote help...\n",
path);
262 int b = Fl::event_button();
263 if (b == FL_LEFT_MOUSE || b == FL_RIGHT_MOUSE) {
275 int b = Fl::event_button();
276 if (b == FL_LEFT_MOUSE) {
279 }
else if (b == FL_MIDDLE_MOUSE) {
289 Fl_Input *i = (Fl_Input*)wid;
292 _MSG(
"location_cb()\n");
303static void b1_cb(Fl_Widget *wid,
void *cb_data)
306 int b = Fl::event_button();
307 if (b >= FL_LEFT_MOUSE && b <= FL_RIGHT_MOUSE) {
308 _MSG(
"[%s], mouse button %d was pressed\n", button_names[bn], b);
309 _MSG(
"mouse button %d was pressed\n", b);
313 if (b == FL_LEFT_MOUSE) {
315 }
else if (b == FL_RIGHT_MOUSE) {
317 wid->y() + wid->h());
321 if (b == FL_LEFT_MOUSE) {
323 }
else if (b == FL_RIGHT_MOUSE) {
325 wid->y() + wid->h());
329 if (b == FL_LEFT_MOUSE) {
334 if (b == FL_LEFT_MOUSE) {
339 if (b == FL_LEFT_MOUSE) {
344 if (b == FL_LEFT_MOUSE) {
349 if (b == FL_LEFT_MOUSE) {
354 if (b == FL_LEFT_MOUSE || b == FL_RIGHT_MOUSE) {
356 wid->y() + wid->h());
369 int b = Fl::event_button();
370 if (b == FL_LEFT_MOUSE) {
372 }
else if (b == FL_RIGHT_MOUSE) {
400 b->clear_visible_focus();
403 b->down_box(FL_THIN_DOWN_FRAME);
413 if (!
icons->ImgLeftIn) {
415 icons->ImgLeftIn->desaturate();
416 icons->ImgLeftIn->color_average(FL_BACKGROUND_COLOR, .14f);
418 if (!
icons->ImgRightIn) {
420 icons->ImgRightIn->desaturate();
421 icons->ImgRightIn->color_average(FL_BACKGROUND_COLOR, .14f);
423 if (!
icons->ImgStopIn) {
425 icons->ImgStopIn->desaturate();
426 icons->ImgStopIn->color_average(FL_BACKGROUND_COLOR, .14f);
455 b->image(
icons->ImgClear);
457 b->clear_visible_focus();
458 b->box(FL_THIN_UP_BOX);
459 b->
set_tooltip(
"Clear the URL box.\nMiddle-click to paste a URL.");
466 i->when(FL_WHEN_ENTER_KEY);
468 i->set_tooltip(
"Location");
475 b->image(
icons->ImgSearch);
477 b->clear_visible_focus();
478 b->box(FL_THIN_UP_BOX);
483 b->image(
icons->ImgHelp);
485 b->clear_visible_focus();
486 b->box(FL_THIN_UP_BOX);
499 IProg->labelsize(12);
500 IProg->box(thin_up ? FL_THIN_UP_BOX : FL_EMBOSSED_BOX);
501 IProg->update_label(wide ?
"Images\n0 of 0" :
"0 of 0");
505 PProg->labelsize(12);
506 PProg->box(thin_up ? FL_THIN_UP_BOX : FL_EMBOSSED_BOX);
507 PProg->update_label(wide ?
"Page\n0.0 KB" :
"0.0 KB");
517 int w = 0, h = 0, padding;
520 btn->labeltype(FL_FREE_LABELTYPE);
521 btn->measure_label(w, h);
524 btn->measure_label(w,h);
526 btn->size(w+padding, h);
528 _MSG(
"UI::make_filemenu_button w=%d h=%d padding=%d\n", w, h, padding);
529 btn->box(FL_THIN_UP_BOX);
532 btn->clear_visible_focus();
580 NavBar->box(FL_THIN_UP_FRAME);
629 StatusOutput->value(
"https://dillo-browser.github.io/");
639 BugMeter->align(FL_ALIGN_INSIDE | FL_ALIGN_TEXT_NEXT_TO_IMAGE);
652UI::UI(
int x,
int y,
int ui_w,
int ui_h,
const char* label,
const UI *cur_ui) :
660 clear_flag(SHORTCUT_LABEL);
679 Main =
new Fl_Group(0,0,0,0,
"Welcome...");
680 Main->align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
681 Main->box(FL_FLAT_BOX);
682 Main->labelfont(FL_HELVETICA_BOLD_ITALIC);
684 Main->labeltype(FL_SHADOW_LABEL);
719 _MSG(
"UI::handle event=%s\n", fl_eventnames[event]);
722 if (event == FL_KEYBOARD) {
724 }
else if (event == FL_SHORTCUT) {
791 }
else if (event == FL_RELEASE) {
792 if (Fl::event_button() == FL_MIDDLE_MOUSE &&
801 ret = Fl_Group::handle(event);
882 if (nbytes >= 1024 * 1024) {
884 magnitude = nbytes / (1024 * 1024.0);
887 magnitude = nbytes / 1024.0;
889 snprintf(str, 32,
"%s%.1f %cB",
890 (
PanelSize == 0) ?
"" :
"Page\n", magnitude, prefix);
891 }
else if (cmd == 2) {
894 PProg->update_label(str);
911 snprintf(str, 32,
"%s%d of %d",
912 (
PanelSize == 0) ?
"" :
"Images\n", n_img, t_img);
913 }
else if (cmd == 2) {
916 IProg->update_label(str);
931 }
else if (n_bug >= 1) {
934 snprintf(str, 32,
"%d", n_bug);
936 new_w = strlen(str)*9 + 20;
992 Fl::delete_widget(
LocBar);
994 Fl::delete_widget(
NavBar);
1035 (sens) ?
Back->activate() :
Back->deactivate();
1038 (sens) ?
Forw->activate() :
Forw->deactivate();
1041 (sens) ?
Stop->activate() :
Stop->deactivate();
1053 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_bugmeter_popup(void *vbw)
void a_UIcmd_home(void *vbw)
void a_UIcmd_open_file(void *vbw)
void a_UIcmd_zoom_reset(void *vbw)
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_book(void *vbw)
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_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_set_location_text(void *vbw, const char *text)