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) {
133 }
else if (k ==
'k') {
134 cut(position(), size());
136 }
else if (k ==
'd') {
137 cut(position(), position()+1);
139 }
else if (k ==
'a' || 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_MIDDLE_MOUSE) {
317 }
else if (b == FL_RIGHT_MOUSE) {
319 wid->y() + wid->h());
323 if (b == FL_LEFT_MOUSE) {
325 }
else if (b == FL_MIDDLE_MOUSE) {
327 }
else if (b == FL_RIGHT_MOUSE) {
329 wid->y() + wid->h());
333 if (b == FL_LEFT_MOUSE) {
335 }
else if (b == FL_MIDDLE_MOUSE) {
340 if (b == FL_LEFT_MOUSE) {
345 if (b == FL_LEFT_MOUSE) {
350 if (b == FL_LEFT_MOUSE) {
355 if (b == FL_LEFT_MOUSE) {
357 }
else if (b == FL_MIDDLE_MOUSE) {
362 if (b == FL_LEFT_MOUSE || b == FL_RIGHT_MOUSE) {
364 wid->y() + wid->h());
377 int b = Fl::event_button();
378 if (b == FL_LEFT_MOUSE) {
380 }
else if (b == FL_RIGHT_MOUSE) {
408 b->clear_visible_focus();
411 b->down_box(FL_THIN_DOWN_FRAME);
421 if (!
icons->ImgLeftIn) {
423 icons->ImgLeftIn->desaturate();
424 icons->ImgLeftIn->color_average(FL_BACKGROUND_COLOR, .14f);
426 if (!
icons->ImgRightIn) {
428 icons->ImgRightIn->desaturate();
429 icons->ImgRightIn->color_average(FL_BACKGROUND_COLOR, .14f);
431 if (!
icons->ImgStopIn) {
433 icons->ImgStopIn->desaturate();
434 icons->ImgStopIn->color_average(FL_BACKGROUND_COLOR, .14f);
463 b->image(
icons->ImgClear);
465 b->clear_visible_focus();
466 b->box(FL_THIN_UP_BOX);
467 b->
set_tooltip(
"Clear the URL box.\nMiddle-click to paste a URL.");
474 i->when(FL_WHEN_ENTER_KEY);
476 i->set_tooltip(
"Location");
483 b->image(
icons->ImgSearch);
485 b->clear_visible_focus();
486 b->box(FL_THIN_UP_BOX);
491 b->image(
icons->ImgHelp);
493 b->clear_visible_focus();
494 b->box(FL_THIN_UP_BOX);
507 IProg->labelsize(12);
508 IProg->box(thin_up ? FL_THIN_UP_BOX : FL_EMBOSSED_BOX);
509 IProg->update_label(wide ?
"Images\n0 of 0" :
"0 of 0");
513 PProg->labelsize(12);
514 PProg->box(thin_up ? FL_THIN_UP_BOX : FL_EMBOSSED_BOX);
515 PProg->update_label(wide ?
"Page\n0.0 KB" :
"0.0 KB");
525 int w = 0, h = 0, padding;
528 btn->labeltype(FL_FREE_LABELTYPE);
529 btn->measure_label(w, h);
532 btn->measure_label(w,h);
534 btn->size(w+padding, h);
536 _MSG(
"UI::make_filemenu_button w=%d h=%d padding=%d\n", w, h, padding);
537 btn->box(FL_THIN_UP_BOX);
540 btn->clear_visible_focus();
588 NavBar->box(FL_THIN_UP_FRAME);
637 StatusOutput->value(
"https://dillo-browser.github.io/");
647 BugMeter->align(FL_ALIGN_INSIDE | FL_ALIGN_TEXT_NEXT_TO_IMAGE);
660UI::UI(
int x,
int y,
int ui_w,
int ui_h,
const char* label,
const UI *cur_ui) :
668 clear_flag(SHORTCUT_LABEL);
687 Main =
new Fl_Group(0,0,0,0,
"Welcome...");
688 Main->align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
689 Main->box(FL_FLAT_BOX);
690 Main->labelfont(FL_HELVETICA_BOLD_ITALIC);
692 Main->labeltype(FL_SHADOW_LABEL);
727 _MSG(
"UI::handle event=%s\n", fl_eventnames[event]);
730 if (event == FL_KEYBOARD) {
732 }
else if (event == FL_SHORTCUT) {
806 }
else if (event == FL_RELEASE) {
807 if (Fl::event_button() == FL_MIDDLE_MOUSE &&
816 ret = Fl_Group::handle(event);
897 if (nbytes >= 1024 * 1024) {
899 magnitude = nbytes / (1024 * 1024.0);
902 magnitude = nbytes / 1024.0;
904 snprintf(str, 32,
"%s%.1f %cB",
905 (
PanelSize == 0) ?
"" :
"Page\n", magnitude, prefix);
906 }
else if (cmd == 2) {
909 PProg->update_label(str);
926 snprintf(str, 32,
"%s%d of %d",
927 (
PanelSize == 0) ?
"" :
"Images\n", n_img, t_img);
928 }
else if (cmd == 2) {
931 IProg->update_label(str);
946 }
else if (n_bug >= 1) {
949 snprintf(str, 32,
"%d", n_bug);
951 new_w = strlen(str)*9 + 20;
1007 Fl::delete_widget(
LocBar);
1009 Fl::delete_widget(
NavBar);
1050 (sens) ?
Back->activate() :
Back->deactivate();
1053 (sens) ?
Forw->activate() :
Forw->deactivate();
1056 (sens) ?
Stop->activate() :
Stop->deactivate();
1068 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)