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;
93#define DILLO_INPUTBOX (Fl_Boxtype) (FL_FREE_BOXTYPE + 1)
100 static const int margin_x = 3;
101 CustInput (
int x,
int y,
int w,
int h,
const char* l=0) :
105 Fl_Boxtype b = box();
107 Fl::box_dx(b) + margin_x,
109 Fl::box_dw(b) + margin_x,
113 virtual int handle(
int e);
120int CustInput::handle(
int e)
122 int k = Fl::event_key();
124 _MSG(
"CustInput::handle event=%d\n", e);
127 unsigned modifier = Fl::event_state() & (FL_SHIFT | FL_CTRL | FL_ALT);
131 (k == FL_Up || k == FL_Down || k == FL_Left || k == FL_Right)) {
133 }
else if (e == FL_KEYBOARD) {
134 if (k == FL_Escape && modifier == 0) {
137 }
else if (modifier == FL_SHIFT) {
138 if (k == FL_Left || k == FL_Right) {
142 }
else if (modifier == FL_CTRL) {
146 }
else if (k ==
'k') {
147 cut(position(), size());
149 }
else if (k ==
'd') {
150 cut(position(), position()+1);
152 }
else if (k ==
'a' || k ==
'l') {
156 }
else if (k ==
'h' || k ==
'o' || k ==
'r' ||
157 k == FL_Home || k == FL_End) {
161 }
else if (modifier == 0) {
162 if (k == FL_Down || k == FL_Up ||
163 k == FL_Page_Down || k == FL_Page_Up || k == FL_Tab) {
169 if (k == FL_Page_Down || k == FL_Page_Up) {
186 CustPasteButton(
int x,
int y,
int w,
int h,
const char *l=0) :
191int CustPasteButton::handle(
int e)
194 const char* t = Fl::event_text();
209class CustProgressBox :
public Fl_Box {
212 CustProgressBox(
int x,
int y,
int w,
int h,
const char *l=0) :
213 Fl_Box(x,y,w,h,l) { padding = 0; };
214 void update_label(
const char *lbl) {
219 padding = w > 2 ? w/2 : 1;
243 int b = Fl::event_button();
245 if (b == FL_LEFT_MOUSE) {
258 if (access(
path, R_OK) == 0) {
263 MSG(
"Can't read local help file at \"%s\"."
264 " Getting remote help...\n",
path);
275 int b = Fl::event_button();
276 if (b == FL_LEFT_MOUSE || b == FL_RIGHT_MOUSE) {
288 int b = Fl::event_button();
289 if (b == FL_LEFT_MOUSE) {
292 }
else if (b == FL_MIDDLE_MOUSE) {
302 Fl_Input *i = (Fl_Input*)wid;
305 _MSG(
"location_cb()\n");
316static void b1_cb(Fl_Widget *wid,
void *cb_data)
319 int b = Fl::event_button();
320 if (b >= FL_LEFT_MOUSE && b <= FL_RIGHT_MOUSE) {
321 _MSG(
"[%s], mouse button %d was pressed\n", button_names[bn], b);
322 _MSG(
"mouse button %d was pressed\n", b);
326 if (b == FL_LEFT_MOUSE) {
328 }
else if (b == FL_MIDDLE_MOUSE) {
330 }
else if (b == FL_RIGHT_MOUSE) {
332 wid->y() + wid->h());
336 if (b == FL_LEFT_MOUSE) {
338 }
else if (b == FL_MIDDLE_MOUSE) {
340 }
else if (b == FL_RIGHT_MOUSE) {
342 wid->y() + wid->h());
346 if (b == FL_LEFT_MOUSE) {
348 }
else if (b == FL_MIDDLE_MOUSE) {
353 if (b == FL_LEFT_MOUSE) {
358 if (b == FL_LEFT_MOUSE) {
363 if (b == FL_LEFT_MOUSE) {
368 if (b == FL_LEFT_MOUSE) {
370 }
else if (b == FL_MIDDLE_MOUSE) {
375 if (b == FL_LEFT_MOUSE || b == FL_RIGHT_MOUSE) {
377 wid->y() + wid->h());
390 int b = Fl::event_button();
391 if (b == FL_LEFT_MOUSE) {
393 }
else if (b == FL_RIGHT_MOUSE) {
421 b->clear_visible_focus();
424 b->down_box(FL_THIN_DOWN_FRAME);
434 if (!
icons->ImgLeftIn) {
436 icons->ImgLeftIn->desaturate();
437 icons->ImgLeftIn->color_average(FL_BACKGROUND_COLOR, .14f);
439 if (!
icons->ImgRightIn) {
441 icons->ImgRightIn->desaturate();
442 icons->ImgRightIn->color_average(FL_BACKGROUND_COLOR, .14f);
444 if (!
icons->ImgStopIn) {
446 icons->ImgStopIn->desaturate();
447 icons->ImgStopIn->color_average(FL_BACKGROUND_COLOR, .14f);
476 b->image(
icons->ImgClear);
478 b->clear_visible_focus();
479 b->box(FL_THIN_UP_BOX);
480 b->
set_tooltip(
"Clear the URL box.\nMiddle-click to paste a URL.");
487 i->when(FL_WHEN_ENTER_KEY);
489 i->set_tooltip(
"Location");
496 b->image(
icons->ImgSearch);
498 b->clear_visible_focus();
499 b->box(FL_THIN_UP_BOX);
504 b->image(
icons->ImgHelp);
506 b->clear_visible_focus();
507 b->box(FL_THIN_UP_BOX);
520 IProg->labelsize(12);
521 IProg->box(thin_up ? FL_THIN_UP_BOX : FL_EMBOSSED_BOX);
522 IProg->update_label(wide ?
"Images\n0 of 0" :
"0 of 0");
526 PProg->labelsize(12);
527 PProg->box(thin_up ? FL_THIN_UP_BOX : FL_EMBOSSED_BOX);
528 PProg->update_label(wide ?
"Page\n0.0 KB" :
"0.0 KB");
538 int w = 0, h = 0, padding;
541 btn->labeltype(FL_FREE_LABELTYPE);
542 btn->measure_label(w, h);
545 btn->measure_label(w,h);
547 btn->size(w+padding, h);
549 _MSG(
"UI::make_filemenu_button w=%d h=%d padding=%d\n", w, h, padding);
550 btn->box(FL_THIN_UP_BOX);
553 btn->clear_visible_focus();
601 NavBar->box(FL_THIN_UP_FRAME);
650 StatusOutput->value(
"https://dillo-browser.github.io/");
660 BugMeter->align(FL_ALIGN_INSIDE | FL_ALIGN_TEXT_NEXT_TO_IMAGE);
673UI::UI(
int x,
int y,
int ui_w,
int ui_h,
const char* label,
const UI *cur_ui) :
681 clear_flag(SHORTCUT_LABEL);
700 Main =
new Fl_Group(0,0,0,0,
"Welcome...");
701 Main->align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
702 Main->box(FL_FLAT_BOX);
703 Main->labelfont(FL_HELVETICA_BOLD_ITALIC);
705 Main->labeltype(FL_SHADOW_LABEL);
740 _MSG(
"UI::handle event=%s\n", fl_eventnames[event]);
743 if (event == FL_KEYBOARD) {
745 }
else if (event == FL_SHORTCUT) {
819 }
else if (event == FL_RELEASE) {
820 if (Fl::event_button() == FL_MIDDLE_MOUSE &&
829 ret = Fl_Group::handle(event);
910 if (nbytes >= 1024 * 1024) {
912 magnitude = nbytes / (1024 * 1024.0);
915 magnitude = nbytes / 1024.0;
917 snprintf(str, 32,
"%s%.1f %cB",
918 (
PanelSize == 0) ?
"" :
"Page\n", magnitude, prefix);
919 }
else if (cmd == 2) {
922 PProg->update_label(str);
939 snprintf(str, 32,
"%s%d of %d",
940 (
PanelSize == 0) ?
"" :
"Images\n", n_img, t_img);
941 }
else if (cmd == 2) {
944 IProg->update_label(str);
959 }
else if (n_bug >= 1) {
962 snprintf(str, 32,
"%d", n_bug);
964 new_w = strlen(str)*9 + 20;
1020 Fl::delete_widget(
LocBar);
1022 Fl::delete_widget(
NavBar);
1063 (sens) ?
Back->activate() :
Back->deactivate();
1066 (sens) ?
Forw->activate() :
Forw->deactivate();
1069 (sens) ?
Stop->activate() :
Stop->deactivate();
1081 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)