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);
127int CustInput::handle(
int e)
129 int k = Fl::event_key();
131 _MSG(
"CustInput::handle event=%d\n", e);
134 unsigned modifier = Fl::event_state() & (FL_SHIFT | FL_CTRL | FL_ALT);
138 (k == FL_Up || k == FL_Down || k == FL_Left || k == FL_Right)) {
140 }
else if (e == FL_KEYBOARD) {
141 if (k == FL_Escape && modifier == 0) {
144 }
else if (modifier == FL_SHIFT) {
145 if (k == FL_Left || k == FL_Right) {
149 }
else if (modifier == FL_CTRL) {
153 }
else if (k ==
'k') {
154 cut(position(), size());
156 }
else if (k ==
'd') {
157 cut(position(), position()+1);
159 }
else if (k ==
'a' || k ==
'l') {
163 }
else if (k ==
'h' || k ==
'o' || k ==
'r' ||
164 k == FL_Home || k == FL_End) {
168 }
else if (modifier == 0) {
169 if (k == FL_Down || k == FL_Up ||
170 k == FL_Page_Down || k == FL_Page_Up || k == FL_Tab) {
176 if (k == FL_Page_Down || k == FL_Page_Up) {
193 CustPasteButton(
int x,
int y,
int w,
int h,
const char *l=0) :
198int CustPasteButton::handle(
int e)
201 const char* t = Fl::event_text();
216class CustProgressBox :
public Fl_Box {
219 CustProgressBox(
int x,
int y,
int w,
int h,
const char *l=0) :
220 Fl_Box(x,y,w,h,l) { padding = 0; };
221 void update_label(
const char *lbl) {
226 padding = w > 2 ? w/2 : 1;
250 int b = Fl::event_button();
252 if (b == FL_LEFT_MOUSE) {
265 if (access(
path, R_OK) == 0) {
270 MSG(
"Can't read local help file at \"%s\"."
271 " Getting remote help...\n",
path);
282 int b = Fl::event_button();
283 if (b == FL_LEFT_MOUSE || b == FL_RIGHT_MOUSE) {
295 int b = Fl::event_button();
296 if (b == FL_LEFT_MOUSE) {
299 }
else if (b == FL_MIDDLE_MOUSE) {
309 Fl_Input *i = (Fl_Input*)wid;
312 _MSG(
"location_cb()\n");
323static void b1_cb(Fl_Widget *wid,
void *cb_data)
326 int b = Fl::event_button();
327 if (b >= FL_LEFT_MOUSE && b <= FL_RIGHT_MOUSE) {
328 _MSG(
"[%s], mouse button %d was pressed\n", button_names[bn], b);
329 _MSG(
"mouse button %d was pressed\n", b);
333 if (b == FL_LEFT_MOUSE) {
335 }
else if (b == FL_MIDDLE_MOUSE) {
337 }
else if (b == FL_RIGHT_MOUSE) {
339 wid->y() + wid->h());
343 if (b == FL_LEFT_MOUSE) {
345 }
else if (b == FL_MIDDLE_MOUSE) {
347 }
else if (b == FL_RIGHT_MOUSE) {
349 wid->y() + wid->h());
353 if (b == FL_LEFT_MOUSE) {
355 }
else if (b == FL_MIDDLE_MOUSE) {
360 if (b == FL_LEFT_MOUSE) {
365 if (b == FL_LEFT_MOUSE) {
370 if (b == FL_LEFT_MOUSE) {
375 if (b == FL_LEFT_MOUSE) {
377 }
else if (b == FL_MIDDLE_MOUSE) {
382 if (b == FL_LEFT_MOUSE || b == FL_RIGHT_MOUSE) {
384 wid->y() + wid->h());
397 int b = Fl::event_button();
398 if (b == FL_LEFT_MOUSE) {
400 }
else if (b == FL_RIGHT_MOUSE) {
428 b->clear_visible_focus();
431 b->down_box(FL_THIN_DOWN_FRAME);
441 if (!
icons->ImgLeftIn) {
443 icons->ImgLeftIn->desaturate();
444 icons->ImgLeftIn->color_average(FL_BACKGROUND_COLOR, .14f);
446 if (!
icons->ImgRightIn) {
448 icons->ImgRightIn->desaturate();
449 icons->ImgRightIn->color_average(FL_BACKGROUND_COLOR, .14f);
451 if (!
icons->ImgStopIn) {
453 icons->ImgStopIn->desaturate();
454 icons->ImgStopIn->color_average(FL_BACKGROUND_COLOR, .14f);
483 b->image(
icons->ImgClear);
485 b->clear_visible_focus();
486 b->box(FL_THIN_UP_BOX);
487 b->
set_tooltip(
"Clear the URL box.\nMiddle-click to paste a URL.");
494 i->when(FL_WHEN_ENTER_KEY);
496 i->set_tooltip(
"Location");
503 b->image(
icons->ImgSearch);
505 b->clear_visible_focus();
506 b->box(FL_THIN_UP_BOX);
511 b->image(
icons->ImgHelp);
513 b->clear_visible_focus();
514 b->box(FL_THIN_UP_BOX);
527 IProg->labelsize(12);
528 IProg->box(thin_up ? FL_THIN_UP_BOX : FL_EMBOSSED_BOX);
529 IProg->update_label(wide ?
"Images\n0 of 0" :
"0 of 0");
533 PProg->labelsize(12);
534 PProg->box(thin_up ? FL_THIN_UP_BOX : FL_EMBOSSED_BOX);
535 PProg->update_label(wide ?
"Page\n0.0 KB" :
"0.0 KB");
545 int w = 0, h = 0, padding;
548 btn->labeltype(FL_FREE_LABELTYPE);
549 btn->measure_label(w, h);
552 btn->measure_label(w,h);
554 btn->size(w+padding, h);
556 _MSG(
"UI::make_filemenu_button w=%d h=%d padding=%d\n", w, h, padding);
557 btn->box(FL_THIN_UP_BOX);
560 btn->clear_visible_focus();
608 NavBar->box(FL_THIN_UP_FRAME);
657 StatusOutput->value(
"https://dillo-browser.github.io/");
667 BugMeter->align(FL_ALIGN_INSIDE | FL_ALIGN_TEXT_NEXT_TO_IMAGE);
680UI::UI(
int x,
int y,
int ui_w,
int ui_h,
const char* label,
const UI *cur_ui) :
688 clear_flag(SHORTCUT_LABEL);
707 Main =
new Fl_Group(0,0,0,0,
"Welcome...");
708 Main->align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
709 Main->box(FL_FLAT_BOX);
710 Main->labelfont(FL_HELVETICA_BOLD_ITALIC);
712 Main->labeltype(FL_SHADOW_LABEL);
747 _MSG(
"UI::handle event=%s\n", fl_eventnames[event]);
750 if (event == FL_KEYBOARD) {
752 }
else if (event == FL_SHORTCUT) {
826 }
else if (event == FL_RELEASE) {
827 if (Fl::event_button() == FL_MIDDLE_MOUSE &&
833 }
else if (event == FL_PUSH) {
835 _MSG(
"pressed button %d\n", Fl::event_button());
836 if (Fl::event_button() == FL_BACK_MOUSE) {
839 }
else if (Fl::event_button() == FL_FORWARD_MOUSE) {
846 ret = Fl_Group::handle(event);
927 if (nbytes >= 1024 * 1024) {
929 magnitude = nbytes / (1024 * 1024.0);
932 magnitude = nbytes / 1024.0;
934 snprintf(str, 32,
"%s%.1f %cB",
935 (
PanelSize == 0) ?
"" :
"Page\n", magnitude, prefix);
936 }
else if (cmd == 2) {
939 PProg->update_label(str);
956 snprintf(str, 32,
"%s%d of %d",
957 (
PanelSize == 0) ?
"" :
"Images\n", n_img, t_img);
958 }
else if (cmd == 2) {
961 IProg->update_label(str);
976 }
else if (n_bug >= 1) {
979 snprintf(str, 32,
"%d", n_bug);
981 new_w = strlen(str)*9 + 20;
1037 Fl::delete_widget(
LocBar);
1039 Fl::delete_widget(
NavBar);
1080 (sens) ?
Back->activate() :
Back->deactivate();
1083 (sens) ?
Forw->activate() :
Forw->deactivate();
1086 (sens) ?
Stop->activate() :
Stop->deactivate();
1098 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)