summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/IO/about.c2
-rw-r--r--src/IO/iowatch.cc12
-rw-r--r--src/IO/iowatch.hh2
-rw-r--r--src/Makefile.am3
-rw-r--r--src/auth.c4
-rw-r--r--src/capi.c1
-rw-r--r--src/chain.c5
-rw-r--r--src/cssparser.cc2
-rw-r--r--src/dialog.cc382
-rw-r--r--src/dialog.hh2
-rw-r--r--src/dillo.cc87
-rw-r--r--src/dns.h2
-rw-r--r--src/findbar.cc133
-rw-r--r--src/findbar.hh32
-rw-r--r--src/form.cc5
-rw-r--r--src/html.cc88
-rw-r--r--src/keys.cc189
-rw-r--r--src/keys.hh1
-rw-r--r--src/keysrc15
-rw-r--r--src/menu.cc553
-rw-r--r--src/misc.c32
-rw-r--r--src/misc.h1
-rw-r--r--src/nav.c7
-rw-r--r--src/prefs.c12
-rw-r--r--src/prefs.h4
-rw-r--r--src/prefsparser.cc31
-rw-r--r--src/timeout.cc9
-rw-r--r--src/ui.cc978
-rw-r--r--src/ui.hh139
-rw-r--r--src/uicmd.cc713
-rw-r--r--src/uicmd.hh4
-rw-r--r--src/utf8.cc13
-rw-r--r--src/utf8.hh1
-rw-r--r--src/web.cc7
-rw-r--r--src/xembed.cc65
-rw-r--r--src/xembed.hh8
36 files changed, 1898 insertions, 1646 deletions
diff --git a/src/IO/about.c b/src/IO/about.c
index 2e5c4485..132db8a1 100644
--- a/src/IO/about.c
+++ b/src/IO/about.c
@@ -75,7 +75,7 @@ const char *const AboutSplash=
" <tr>\n"
" <td>&nbsp;&nbsp;\n"
" <td>\n"
-" <a href='http://dillo.org/dillo-2.x/ChangeLog'>\n"
+" <a href='http://hg.dillo.org/dillo/file/tip/ChangeLog'>\n"
" ChangeLog</a>\n"
" <tr>\n"
" <td>&nbsp;&nbsp;\n"
diff --git a/src/IO/iowatch.cc b/src/IO/iowatch.cc
index f67b711f..f5243934 100644
--- a/src/IO/iowatch.cc
+++ b/src/IO/iowatch.cc
@@ -11,19 +11,17 @@
// Simple ADT for watching file descriptor activity
-#include <fltk/run.h>
+#include <FL/Fl.H>
#include "iowatch.hh"
-using namespace fltk;
-
-
//
// Hook a Callback for a certain activities in a FD
//
-void a_IOwatch_add_fd(int fd, int when, FileHandler Callback, void *usr_data=0)
+void a_IOwatch_add_fd(int fd, int when, Fl_FD_Handler Callback,
+ void *usr_data = 0)
{
if (fd >= 0)
- add_fd(fd, when, Callback, usr_data);
+ Fl::add_fd(fd, when, Callback, usr_data);
}
//
@@ -32,6 +30,6 @@ void a_IOwatch_add_fd(int fd, int when, FileHandler Callback, void *usr_data=0)
void a_IOwatch_remove_fd(int fd, int when)
{
if (fd >= 0)
- remove_fd(fd, when);
+ Fl::remove_fd(fd, when);
}
diff --git a/src/IO/iowatch.hh b/src/IO/iowatch.hh
index 681d0080..e2d497f1 100644
--- a/src/IO/iowatch.hh
+++ b/src/IO/iowatch.hh
@@ -2,7 +2,7 @@
#define __IO_WATCH_H__
/*
- * BUG: enum {READ = 1, WRITE = 4, EXCEPT = 8} borrowed from fltk/run.h
+ * BUG: enum {READ = 1, WRITE = 4, EXCEPT = 8} borrowed from FL/Enumerations.H
*/
#define DIO_READ 1
#define DIO_WRITE 4
diff --git a/src/Makefile.am b/src/Makefile.am
index 0f09b716..9de7eed5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -18,7 +18,8 @@ dillo_LDADD = \
$(top_builddir)/dw/libDw-fltk.a \
$(top_builddir)/dw/libDw-core.a \
$(top_builddir)/lout/liblout.a \
- @LIBJPEG_LIBS@ @LIBPNG_LIBS@ @LIBFLTK_LIBS@ @LIBZ_LIBS@ @LIBICONV_LIBS@
+ @LIBJPEG_LIBS@ @LIBPNG_LIBS@ @LIBFLTK_LIBS@ @LIBZ_LIBS@ \
+ @LIBICONV_LIBS@ @LIBPTHREAD_LIBS@
dillo_SOURCES = \
dillo.cc \
diff --git a/src/auth.c b/src/auth.c
index 91baca30..8943c3fd 100644
--- a/src/auth.c
+++ b/src/auth.c
@@ -486,8 +486,8 @@ static int Auth_do_auth_dialog(const char *realm, const DilloUrl *url)
AuthDialogData_t *data;
_MSG("auth.c: Auth_do_auth_dialog: realm = '%s'\n", realm);
- message = dStrconcat("Enter a user and password for \"",
- realm, "\".", NULL);
+ message = dStrconcat("The server at ", URL_HOST(url), " requires a username"
+ " and password for \"", realm, "\".", NULL);
data = dNew(AuthDialogData_t, 1);
data->realm_name = dStrdup(realm);
data->url = a_Url_dup(url);
diff --git a/src/capi.c b/src/capi.c
index 5e2928e3..867083b5 100644
--- a/src/capi.c
+++ b/src/capi.c
@@ -758,6 +758,7 @@ void a_Capi_ccc(int Op, int Branch, int Dir, ChainLink *Info,
a_Chain_bcb(OpAbort, Info, NULL, NULL);
/* remove the cache entry for this URL */
a_Cache_entry_remove_by_url(conn->url);
+ a_Nav_cancel_expect_if_eq(conn->bw, conn->url);
Capi_conn_unref(conn);
dFree(Info);
break;
diff --git a/src/chain.c b/src/chain.c
index d4098a2d..a13b3120 100644
--- a/src/chain.c
+++ b/src/chain.c
@@ -22,7 +22,7 @@
*/
#if VERBOSE
static void Chain_debug_msg(char *FuncStr, int Op, int Branch, int Dir,
- ChainLink *Info)
+ ChainLink *Info)
{
const char *StrOps[] = {"", "OpStart", "OpSend",
"OpStop", "OpEnd", "OpAbort"};
@@ -31,7 +31,8 @@ static void Chain_debug_msg(char *FuncStr, int Op, int Branch, int Dir,
Info, Info ? Info->Flags : -1);
}
#else
-static void Chain_debug_msg() { }
+static void Chain_debug_msg(char *FuncStr, int Op, int Branch, int Dir,
+ ChainLink *Info) { }
#endif
/*
* Create and initialize a new chain-link
diff --git a/src/cssparser.cc b/src/cssparser.cc
index 6bd8ba14..3d62b31d 100644
--- a/src/cssparser.cc
+++ b/src/cssparser.cc
@@ -1521,7 +1521,7 @@ const char * CssParser::propertyNameString(CssPropertyName name)
{
return Css_property_info[name].symbol;
}
-
+
void CssParser::ignoreBlock()
{
int depth = 0;
diff --git a/src/dialog.cc b/src/dialog.cc
index 47af9921..85121c63 100644
--- a/src/dialog.cc
+++ b/src/dialog.cc
@@ -13,58 +13,195 @@
#include <math.h> // for rint()
-#include <fltk/Window.h>
-#include <fltk/ask.h>
-#include <fltk/file_chooser.h>
-#include <fltk/TextBuffer.h>
-#include <fltk/ReturnButton.h>
-#include <fltk/TextDisplay.h>
-#include <fltk/HighlightButton.h>
-#include <fltk/WordwrapOutput.h>
-#include <fltk/Input.h>
-#include <fltk/SecretInput.h>
+#include <FL/Fl_Window.H>
+#include <FL/Fl_File_Chooser.H>
+#include <FL/Fl_Return_Button.H>
+#include <FL/Fl_Text_Display.H>
+#include <FL/Fl_Button.H>
+#include <FL/Fl_Return_Button.H>
+#include <FL/Fl_Output.H>
+#include <FL/Fl_Input.H>
+#include <FL/Fl_Secret_Input.H>
+#include <FL/Fl_Choice.H>
+#include <FL/Fl_Menu_Item.H>
#include "msg.h"
#include "dialog.hh"
#include "misc.h"
#include "prefs.h"
-using namespace fltk;
+/*
+ * Local Data
+ */
+static int input_answer;
+static char *input_str = NULL;
+static int choice5_answer;
+
+
+/*
+ * Local sub classes
+ */
+//----------------------------------------------------------------------------
/*
- * Close dialog window.
+ * Used to enable CTRL+{a,e,d,k} in search dialog (for start,end,del,cut)
+ * TODO: bind down arrow to a search engine selection list.
*/
-static void window_close_cb(Widget *, void *vwin)
+class CustInput3 : public Fl_Input {
+public:
+ CustInput3 (int x, int y, int w, int h, const char* l=0) :
+ Fl_Input(x,y,w,h,l) {};
+ int handle(int e);
+};
+
+int CustInput3::handle(int e)
{
- delete (Window*)vwin;
+ int k = Fl::event_key();
+
+ _MSG("CustInput3::handle event=%d\n", e);
+
+ // We're only interested in some flags
+ unsigned modifier = Fl::event_state() & (FL_SHIFT | FL_CTRL | FL_ALT);
+
+ if (e == FL_KEYBOARD && modifier == FL_CTRL) {
+ if (k == 'a' || k == 'e') {
+ position(k == 'a' ? 0 : size());
+ return 1;
+ } else if (k == 'k') {
+ cut(position(), size());
+ return 1;
+ } else if (k == 'd') {
+ cut(position(), position()+1);
+ return 1;
+ }
+ }
+ return Fl_Input::handle(e);
}
/*
+ * Used to make the ENTER key activate the CustChoice
+ */
+class CustChoice : public Fl_Choice {
+public:
+ CustChoice (int x, int y, int w, int h, const char* l=0) :
+ Fl_Choice(x,y,w,h,l) {};
+ int handle(int e) {
+ if (e == FL_KEYBOARD &&
+ (Fl::event_key() == FL_Enter || Fl::event_key() == FL_Down) &&
+ (Fl::event_state() & (FL_SHIFT|FL_CTRL|FL_ALT|FL_META)) == 0) {
+ MSG("CustChoice: ENTER\n");
+ return Fl_Choice::handle(FL_PUSH);
+ }
+ return Fl_Choice::handle(e);
+ };
+};
+
+//----------------------------------------------------------------------------
+
+
+/*
* Display a message in a popup window.
*/
void a_Dialog_msg(const char *msg)
{
- message("%s", msg);
+ fl_message("%s", msg);
}
+
/*
- * Offer a three choice dialog.
- * The option string that begins with "*" is the default.
- *
- * Return: 0, 1 or 2 (esc = 2, window close = 2)
+ * Callback for a_Dialog_input()
*/
-int a_Dialog_choice3(const char *msg,
- const char *b0, const char *b1, const char *b2)
+static void input_cb(Fl_Widget *button, void *number)
{
- return choice(msg, b0, b1, b2);
+ input_answer = VOIDP2INT(number);
+ button->window()->hide();
}
/*
* Dialog for one line of Input with a message.
+ * avoids the sound bell in fl_input(), and allows customization
+ *
+ * Return value: string on success, NULL upon Cancel or Close window
*/
const char *a_Dialog_input(const char *msg)
{
- return input("%s", "", msg);
+ static Fl_Menu_Item *pm = 0;
+ int ww = 450, wh = 130, gap = 10, ih = 60, bw = 80, bh = 30;
+
+ input_answer = 0;
+
+ Fl_Window *window = new Fl_Window(ww,wh,"Ask");
+ window->set_modal();
+ window->begin();
+ Fl_Group* ib = new Fl_Group(0,0,window->w(),window->h());
+ ib->begin();
+ window->resizable(ib);
+
+ /* '?' Icon */
+ Fl_Box* o = new Fl_Box(gap, gap, ih, ih);
+ o->box(FL_THIN_UP_BOX);
+ o->labelfont(FL_TIMES_BOLD);
+ o->labelsize(34);
+ o->color(FL_WHITE);
+ o->labelcolor(FL_BLUE);
+ o->label("?");
+ o->show();
+
+ Fl_Box *box = new Fl_Box(ih+2*gap,gap,ww-(ih+3*gap),ih/2, msg);
+ box->labelfont(FL_HELVETICA);
+ box->labelsize(14);
+ box->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE|FL_ALIGN_CLIP|FL_ALIGN_WRAP);
+
+ CustInput3 *c_inp = new CustInput3(ih+2*gap,gap+ih/2+gap,ww-(ih+3*gap),24);
+ c_inp->labelsize(14);
+ c_inp->textsize(14);
+
+ CustChoice *ch = new CustChoice(1*gap,ih+3*gap,180,24);
+ if (!pm) {
+ int n_it = dList_length(prefs.search_urls);
+ pm = new Fl_Menu_Item[n_it+1];
+ memset(pm, '\0', sizeof(Fl_Menu_Item[n_it+1]));
+ for (int i = 0, j = 0; i < n_it; i++) {
+ char *label, *url, *source;
+ source = (char *)dList_nth_data(prefs.search_urls, i);
+ if (a_Misc_parse_search_url(source, &label, &url) < 0)
+ continue;
+ pm[j++].label(FL_NORMAL_LABEL, strdup(label));
+ }
+ }
+ ch->tooltip("Select search engine");
+ ch->menu(pm);
+ ch->value(prefs.search_url_idx);
+ ch->textcolor(FL_DARK_BLUE);
+
+ int xpos = ww-2*(gap+bw), ypos = ih+3*gap;
+ Fl_Return_Button *rb = new Fl_Return_Button(xpos, ypos, bw, bh, "OK");
+ rb->align(FL_ALIGN_INSIDE|FL_ALIGN_CLIP);
+ rb->box(FL_UP_BOX);
+ rb->callback(input_cb, INT2VOIDP(1));
+
+ xpos = ww-(gap+bw);
+ Fl_Button *b = new Fl_Button(xpos, ypos, bw, bh, "Cancel");
+ b->align(FL_ALIGN_INSIDE|FL_ALIGN_CLIP);
+ b->box(FL_UP_BOX);
+ b->callback(input_cb, INT2VOIDP(2));
+
+ window->end();
+
+ window->show();
+ while (window->shown())
+ Fl::wait();
+ _MSG("a_Dialog_input answer = %d\n", input_answer);
+ if (input_answer == 1) {
+ /* we have a string, save it */
+ dFree(input_str);
+ input_str = dStrdup(c_inp->value());
+ MSG("a_Dialog_input value() = %d\n", ch->value());
+ prefs.search_url_idx = ch->value();
+ }
+ delete window;
+
+ return (input_answer == 1) ? input_str : NULL;
}
/*
@@ -72,7 +209,7 @@ const char *a_Dialog_input(const char *msg)
*/
const char *a_Dialog_passwd(const char *msg)
{
- return password("%s", "", msg);
+ return fl_password("%s", "", msg);
}
/*
@@ -83,7 +220,7 @@ const char *a_Dialog_passwd(const char *msg)
const char *a_Dialog_save_file(const char *msg,
const char *pattern, const char *fname)
{
- return file_chooser(msg, pattern, fname);
+ return fl_file_chooser(msg, pattern, fname);
}
/*
@@ -101,7 +238,6 @@ const char *a_Dialog_select_file(const char *msg,
return a_Dialog_save_file(msg, pattern, fname);
}
-//#include <fltk/FileIcon.h>
/*
* Show the open file dialog.
*
@@ -111,69 +247,66 @@ char *a_Dialog_open_file(const char *msg,
const char *pattern, const char *fname)
{
const char *fc_name;
-/*
- static int icons_loaded = 0;
- if (!icons_loaded)
- FileIcon::load_system_icons();
-*/
- fc_name = file_chooser(msg, pattern, fname);
+
+ fc_name = fl_file_chooser(msg, pattern, fname);
return (fc_name) ? a_Misc_escape_chars(fc_name, "% ") : NULL;
}
/*
+ * Close text window.
+ */
+static void text_window_close_cb(Fl_Widget *, void *vtd)
+{
+ Fl_Text_Display *td = (Fl_Text_Display *)vtd;
+ Fl_Text_Buffer *buf = td->buffer();
+
+ delete (Fl_Window*)td->window();
+ delete buf;
+}
+
+/*
* Show a new window with the provided text
*/
void a_Dialog_text_window(const char *txt, const char *title)
{
- //int wh = 600, ww = 650, bh = 30;
int wh = prefs.height, ww = prefs.width, bh = 30;
- int lines, line_num_width;
- Font *textfont = font(prefs.font_monospace, 0);
- Window *window = new Window(ww, wh, title ? title : "Untitled");
- window->callback(window_close_cb, window);
- window->begin();
-
- TextDisplay *td = new TextDisplay(0,0,ww, wh-bh);
- td->buffer()->text(txt);
+ Fl_Window *window = new Fl_Window(ww, wh, title ? title : "Dillo text");
+ Fl_Group::current(0);
- if (textfont)
- td->textfont(textfont);
- td->textsize((int) rint(13.0 * prefs.font_factor));
- fltk::setfont(td->textfont(), td->textsize());
- lines = td->total_lines();
- line_num_width = 2;
- while (lines /= 10)
- ++line_num_width;
- line_num_width = (int)(line_num_width * fltk::getwidth("0"));
- td->linenumber_width(line_num_width);
+ Fl_Text_Buffer *buf = new Fl_Text_Buffer();
+ buf->text(txt);
+ Fl_Text_Display *td = new Fl_Text_Display(0,0,ww, wh-bh);
+ td->buffer(buf);
+ td->textsize((int) rint(14.0 * prefs.font_factor));
/* enable wrapping lines; text uses entire width of window */
td->wrap_mode(true, false);
- /* WORKAROUND: FLTK may not display all the lines without this */
- td->resize(ww+1,wh-bh);
+ window->add(td);
- ReturnButton *b = new ReturnButton (0, wh-bh, ww, bh, "Close");
- b->callback(window_close_cb, window);
+ Fl_Return_Button *b = new Fl_Return_Button (0, wh-bh, ww, bh, "Close");
+ b->callback(text_window_close_cb, td);
+ window->add(b);
+ window->callback(text_window_close_cb, td);
window->resizable(td);
- window->end();
window->show();
}
/*--------------------------------------------------------------------------*/
-static int choice5_answer;
-static void choice5_cb(Widget *button, void *number)
+static void choice5_cb(Fl_Widget *button, void *number)
{
choice5_answer = VOIDP2INT(number);
_MSG("choice5_cb: %d\n", choice5_answer);
- button->window()->make_exec_return(true);
+ button->window()->hide();
}
/*
- * Make a question-dialog with a question and some alternatives.
+ * Make a question-dialog with a question and up to five alternatives.
+ * (if less alternatives, non used parameters must be NULL).
+ *
* Return value: 0 = dialog was cancelled, 1-5 = selected alternative.
*/
int a_Dialog_choice5(const char *QuestionTxt,
@@ -182,56 +315,72 @@ int a_Dialog_choice5(const char *QuestionTxt,
{
choice5_answer = 0;
- int ww = 440, wh = 150, bw = 50, bh = 45, nb = 0;
+ int ww = 440, wh = 120, bw = 50, bh = 45, ih = 50, nb = 0;
const char *txt[7];
txt[0] = txt[6] = NULL;
txt[1] = alt1; txt[2] = alt2; txt[3] = alt3;
txt[4] = alt4; txt[5] = alt5;
- for (int i=1; txt[i]; ++i, ++nb) ;
+ for (int i=1; txt[i]; ++i, ++nb)
+ ;
+
+ if (!nb) {
+ MSG_ERR("a_Dialog_choice5: No choices.\n");
+ return choice5_answer;
+ }
+ ww = 140 + nb*(bw+10);
- Window *window = new Window(ww,wh,"Choice5");
+ Fl_Window *window = new Fl_Window(ww,wh,"Choice5");
+ window->set_modal();
window->begin();
- Group* ib = new Group(0,0,window->w(),window->h());
+ Fl_Group* ib = new Fl_Group(0,0,window->w(),window->h());
ib->begin();
window->resizable(ib);
- Widget *box = new Widget(0,0,ww,wh-bh, QuestionTxt);
- box->box(DOWN_BOX);
- box->labelfont(HELVETICA_BOLD_ITALIC);
+ /* '?' Icon */
+ Fl_Box* o = new Fl_Box(10, (wh-bh-ih)/2, ih, ih);
+ o->box(FL_THIN_UP_BOX);
+ o->labelfont(FL_TIMES_BOLD);
+ o->labelsize(34);
+ o->color(FL_WHITE);
+ o->labelcolor(FL_BLUE);
+ o->label("?");
+ o->show();
+
+ Fl_Box *box = new Fl_Box(60,0,ww-60,wh-bh, QuestionTxt);
+ box->labelfont(FL_HELVETICA);
box->labelsize(14);
+ box->align(FL_ALIGN_WRAP);
- HighlightButton *b;
+ Fl_Button *b;
int xpos = 0, gap = 8;
bw = (ww - gap)/nb - gap;
xpos += gap;
for (int i=1; i <= nb; ++i) {
- b = new HighlightButton(xpos, wh-bh, bw, bh, txt[i]);
- b->align(ALIGN_WRAP|ALIGN_CLIP);
- b->box(UP_BOX);
+ b = new Fl_Button(xpos, wh-bh, bw, bh, txt[i]);
+ b->align(FL_ALIGN_WRAP|FL_ALIGN_CLIP);
+ b->box(FL_UP_BOX);
b->callback(choice5_cb, INT2VOIDP(i));
xpos += bw + gap;
+ /* TODO: set focus to the *-prefixed alternative */
}
window->end();
- //window->hotspot(box);
- window->exec();
+ window->show();
+ while (window->shown())
+ Fl::wait();
+ _MSG("a_Dialog_choice5 answer = %d\n", choice5_answer);
delete window;
- _MSG("Choice5 answer = %d\n", choice5_answer);
return choice5_answer;
}
/*--------------------------------------------------------------------------*/
-/*
- * ret: 0 = Cancel, 1 = OK
- */
-static void Dialog_user_password_cb(Widget *button, void *vIntPtr)
+static void Dialog_user_password_cb(Fl_Widget *button, void *)
{
- int ret = VOIDP2INT(vIntPtr);
- _MSG("Dialog_user_password_cb: %d\n", ret);
- button->window()->make_exec_return(ret);
+ button->window()->user_data(button);
+ button->window()->hide();
}
/*
@@ -241,52 +390,70 @@ static void Dialog_user_password_cb(Widget *button, void *vIntPtr)
*/
int a_Dialog_user_password(const char *message, UserPasswordCB cb, void *vp)
{
- int ok,
- window_w = 300, window_h = 280,
- input_x = 80, input_w = 200, input_h = 30,
- button_y = 230, button_h = 30;
+ int ok = 0, window_h = 280, y, msg_w, msg_h;
+ const int window_w = 300, input_x = 80, input_w = 200, input_h = 30,
+ button_h = 30;
- Window *window =
- new Window(window_w,window_h,"User/Password");
- window->begin();
+ /* window is resized below */
+ Fl_Window *window = new Fl_Window(window_w,window_h,"Dillo User/Password");
+ Fl_Group::current(0);
+ window->user_data(NULL);
/* message */
- WordwrapOutput *message_output =
- new WordwrapOutput(20,20,window_w-40,100);
- message_output->box(DOWN_BOX);
- message_output->text(message);
- message_output->textfont(HELVETICA_BOLD_ITALIC);
- message_output->textsize(14);
+ y = 20;
+ msg_w = window_w - 40;
+ Fl_Box *msg = new Fl_Box(20, y, msg_w, 100); /* resized below */
+ msg->label(message);
+ msg->labelfont(FL_HELVETICA);
+ msg->labelsize(14);
+ msg->align(FL_ALIGN_INSIDE | FL_ALIGN_TOP_LEFT | FL_ALIGN_WRAP);
+
+ fl_font(msg->labelfont(), msg->labelsize());
+ msg_w -= 6; /* The label doesn't fill the entire box. */
+ fl_measure(msg->label(), msg_w, msg_h, 0); /* fl_measure wraps at msg_w */
+ msg->size(msg->w(), msg_h);
+ window->add(msg);
/* inputs */
- Input *user_input =
- new Input(input_x,140,input_w,input_h,"User");
+ y += msg_h + 20;
+ Fl_Input *user_input = new Fl_Input(input_x, y, input_w, input_h, "User");
user_input->labelsize(14);
user_input->textsize(14);
- SecretInput *password_input =
- new SecretInput(input_x,180,input_w,input_h,"Password");
+ window->add(user_input);
+ y += input_h + 10;
+ Fl_Secret_Input *password_input =
+ new Fl_Secret_Input(input_x, y, input_w, input_h, "Password");
password_input->labelsize(14);
password_input->textsize(14);
+ window->add(password_input);
/* "OK" button */
- Button *ok_button =
- new Button(200,button_y,50,button_h,"OK");
+ y += input_h + 20;
+ Fl_Button *ok_button = new Fl_Button(200, y, 50, button_h, "OK");
ok_button->labelsize(14);
ok_button->callback(Dialog_user_password_cb);
- ok_button->user_data(INT2VOIDP(1));
+ window->add(ok_button);
/* "Cancel" button */
- Button *cancel_button =
- new Button(50,button_y,100,button_h,"Cancel");
+ Fl_Button *cancel_button =
+ new Fl_Button(50, y, 100, button_h, "Cancel");
cancel_button->labelsize(14);
cancel_button->callback(Dialog_user_password_cb);
- cancel_button->user_data(INT2VOIDP(0));
+ window->add(cancel_button);
- window->end();
- window->size_range(window_w,window_h,window_w,window_h);
+ y += button_h + 20;
+ window_h = y;
+ window->size(window_w, window_h);
+ window->size_range(window_w, window_h, window_w, window_h);
window->resizable(window);
- if ((ok = window->exec())) {
+ window->show();
+ while (window->shown())
+ Fl::wait();
+
+ ok = ((Fl_Widget *)window->user_data()) == ok_button ? 1 : 0;
+
+ if (ok) {
/* call the callback */
const char *user, *password;
user = user_input->value();
@@ -294,7 +461,6 @@ int a_Dialog_user_password(const char *message, UserPasswordCB cb, void *vp)
_MSG("a_Dialog_user_passwd: ok = %d\n", ok);
(*cb)(user, password, vp);
}
-
delete window;
return ok;
diff --git a/src/dialog.hh b/src/dialog.hh
index 440e9bba..57b21849 100644
--- a/src/dialog.hh
+++ b/src/dialog.hh
@@ -9,8 +9,6 @@ typedef void (*UserPasswordCB)(const char *user, const char *password,
void *vp);
void a_Dialog_msg(const char *msg);
-int a_Dialog_choice3(const char *msg,
- const char *b0, const char *b1, const char *b2);
int a_Dialog_choice5(const char *QuestionTxt,
const char *alt1, const char *alt2, const char *alt3,
const char *alt4, const char *alt5);
diff --git a/src/dillo.cc b/src/dillo.cc
index 3159674e..e5fca5c5 100644
--- a/src/dillo.cc
+++ b/src/dillo.cc
@@ -24,10 +24,9 @@
#include <signal.h>
#include <locale.h>
-#include <fltk/Window.h>
-#include <fltk/TabGroup.h>
-#include <fltk/Font.h>
-#include <fltk/run.h>
+#include <FL/Fl.H>
+#include <FL/Fl_Window.H>
+#include <FL/fl_draw.H>
#include "msg.h"
#include "paths.hh"
@@ -49,6 +48,8 @@
#include "cookies.h"
#include "auth.h"
+#include "dw/fltkcore.hh"
+
/*
* Command line options structure
*/
@@ -171,11 +172,55 @@ static OptID getCmdOption(const CLI_options *options, int argc, char **argv,
}
/*
+ * Set FL_NORMAL_LABEL to interpret neither symbols (@) nor shortcuts (&),
+ * and FL_FREE_LABELTYPE to interpret shortcuts.
+ */
+static void custLabelDraw(const Fl_Label* o, int X, int Y, int W, int H,
+ Fl_Align align)
+{
+ const int interpret_symbols = 0;
+
+ fl_draw_shortcut = 0;
+ fl_font(o->font, o->size);
+ fl_color((Fl_Color)o->color);
+ fl_draw(o->value, X, Y, W, H, align, o->image, interpret_symbols);
+}
+
+static void custLabelMeasure(const Fl_Label* o, int& W, int& H)
+{
+ const int interpret_symbols = 0;
+
+ fl_draw_shortcut = 0;
+ fl_font(o->font, o->size);
+ fl_measure(o->value, W, H, interpret_symbols);
+}
+
+static void custMenuLabelDraw(const Fl_Label* o, int X, int Y, int W, int H,
+ Fl_Align align)
+{
+ const int interpret_symbols = 0;
+
+ fl_draw_shortcut = 1;
+ fl_font(o->font, o->size);
+ fl_color((Fl_Color)o->color);
+ fl_draw(o->value, X, Y, W, H, align, o->image, interpret_symbols);
+}
+
+static void custMenuLabelMeasure(const Fl_Label* o, int& W, int& H)
+{
+ const int interpret_symbols = 0;
+
+ fl_draw_shortcut = 1;
+ fl_font(o->font, o->size);
+ fl_measure(o->value, W, H, interpret_symbols);
+}
+
+/*
* Tell the user if default/pref fonts can't be found.
*/
static void checkFont(const char *name, const char *type)
{
- if (::fltk::font(name) == NULL)
+ if (! dw::fltk::FltkFont::fontExists(name))
MSG_WARN("preferred %s font \"%s\" not found.\n", type, name);
}
@@ -318,22 +363,31 @@ int main(int argc, char **argv)
}
// Sets WM_CLASS hint on X11
- fltk::Window::xclass("dillo");
+ Fl_Window::default_xclass("dillo");
+
+ // Disable '@' and '&' interpretation in normal labels.
+ Fl::set_labeltype(FL_NORMAL_LABEL, custLabelDraw, custLabelMeasure);
- // WORKAROUND: sometimes the default pager triggers redraw storms
- fltk::TabGroup::default_pager(fltk::PAGER_SHRINK);
+ // Use to permit '&' interpretation.
+ Fl::set_labeltype(FL_FREE_LABELTYPE,custMenuLabelDraw,custMenuLabelMeasure);
checkPreferredFonts();
+
/* use preferred font for UI */
- fltk::Font *dfont = fltk::font(prefs.font_sans_serif, 0);
- if (dfont) {
- fltk::Widget::default_style->textfont(dfont);
- fltk::Widget::default_style->labelfont(dfont);
- }
+ Fl_Font defaultFont = dw::fltk::FltkFont::get (prefs.font_sans_serif, 0);
+ Fl::set_font(FL_HELVETICA, defaultFont); // this seems to be the
+ // only way to set the
+ // default font in fltk1.3
// Create a new UI/bw pair
BrowserWindow *bw = a_UIcmd_browser_window_new(0, 0, xid, NULL);
+ /* We need this so that fl_text_extents() in dw/fltkplatform.cc can
+ * work when FLTK is configured without XFT and Dillo is opening
+ * immediately-available URLs from the cmdline (e.g. about:splash).
+ */
+ ((Fl_Widget *)bw->ui)->window()->make_current();
+
/* Proxy authentication */
if (prefs.http_proxyuser && !a_Http_proxy_auth()) {
const char *passwd = a_UIcmd_get_passwd(prefs.http_proxyuser);
@@ -349,7 +403,10 @@ int main(int argc, char **argv)
if (idx == argc) {
/* No URLs/files on cmdline. Send startup screen */
- a_UIcmd_open_url(bw, prefs.start_page);
+ if (strcmp(URL_STR(prefs.start_page), "about:blank") == 0)
+ a_UIcmd_open_url(bw, NULL);
+ else
+ a_UIcmd_open_url(bw, prefs.start_page);
} else {
for (int i = idx; i < argc; i++) {
DilloUrl *start_url = makeStartUrl(argv[i], local);
@@ -369,7 +426,7 @@ int main(int argc, char **argv)
}
}
- fltk::run();
+ Fl::run();
/*
* Memory deallocating routines
diff --git a/src/dns.h b/src/dns.h
index 78f8cf18..70c0b8dc 100644
--- a/src/dns.h
+++ b/src/dns.h
@@ -8,7 +8,7 @@ extern "C" {
#endif /* __cplusplus */
-typedef void (*DnsCallback_t)(int Status, Dlist *addr_list, void *data);
+typedef void (*DnsCallback_t)(int status, Dlist *addr_list, void *data);
void a_Dns_init (void);
void a_Dns_freeall(void);
diff --git a/src/findbar.cc b/src/findbar.cc
index 8cca52ba..02f9545b 100644
--- a/src/findbar.cc
+++ b/src/findbar.cc
@@ -9,8 +9,8 @@
* (at your option) any later version.
*/
-#include <fltk/events.h>
-#include <fltk/Window.h>
+#include <FL/Fl.H>
+#include <FL/Fl_Window.H>
#include "findbar.hh"
#include "msg.h"
@@ -18,49 +18,47 @@
#include "uicmd.hh"
#include "bw.h"
-using namespace fltk;
-
/*
* Local sub class
* (Used to handle escape in the findbar, may also avoid some shortcuts).
*/
-class MyInput : public Input {
+class MyInput : public Fl_Input {
public:
MyInput (int x, int y, int w, int h, const char* l=0) :
- Input(x,y,w,h,l) {};
+ Fl_Input(x,y,w,h,l) {};
int handle(int e);
};
int MyInput::handle(int e)
{
_MSG("findbar MyInput::handle()\n");
- int ret = 1, k = event_key();
- unsigned modifier = event_state() & (SHIFT | CTRL | ALT | META);
-
- if (e == KEY) {
- if (k == LeftKey || k == RightKey) {
- if (modifier == SHIFT) {
- a_UIcmd_send_event_to_tabs_by_wid(e, this);
- return 1;
+ int ret = 1, k = Fl::event_key();
+ unsigned modifier = Fl::event_state() & (FL_SHIFT| FL_CTRL| FL_ALT|FL_META);
+
+ if (e == FL_KEYBOARD) {
+ if (modifier == FL_SHIFT) {
+ if (k == FL_Left || k == FL_Right) {
+ // Let these keys get to the UI
+ return 0;
}
- } else if (k == EscapeKey && modifier == 0) {
+ } else if (k == FL_Escape && modifier == 0) {
// Avoid clearing the text with Esc, just hide the findbar.
return 0;
}
}
if (ret)
- ret = Input::handle(e);
+ ret = Fl_Input::handle(e);
return ret;
};
/*
* Find next occurrence of input key
*/
-void Findbar::search_cb(Widget *, void *vfb)
+void Findbar::search_cb(Fl_Widget *, void *vfb)
{
Findbar *fb = (Findbar *)vfb;
- const char *key = fb->i->text();
+ const char *key = fb->i->value();
bool case_sens = fb->check_btn->value();
if (key[0] != '\0')
@@ -71,10 +69,10 @@ void Findbar::search_cb(Widget *, void *vfb)
/*
* Find previous occurrence of input key
*/
-void Findbar::searchBackwards_cb(Widget *, void *vfb)
+void Findbar::searchBackwards_cb(Fl_Widget *, void *vfb)
{
Findbar *fb = (Findbar *)vfb;
- const char *key = fb->i->text();
+ const char *key = fb->i->value();
bool case_sens = fb->check_btn->value();
if (key[0] != '\0') {
@@ -84,22 +82,9 @@ void Findbar::searchBackwards_cb(Widget *, void *vfb)
}
/*
- * Find next occurrence of input key
- */
-void Findbar::search_cb2(Widget *widget, void *vfb)
-{
- /*
- * Somehow fltk even regards the first loss of focus for the
- * window as a WHEN_ENTER_KEY_ALWAYS event.
- */
- if (event_key() == ReturnKey)
- search_cb(widget, vfb);
-}
-
-/*
* Hide the search bar
*/
-void Findbar::hide_cb(Widget *, void *vfb)
+void Findbar::hide_cb(Fl_Widget *, void *vfb)
{
((Findbar *)vfb)->hide();
}
@@ -108,54 +93,57 @@ void Findbar::hide_cb(Widget *, void *vfb)
* Construct text search bar
*/
Findbar::Findbar(int width, int height) :
- Group(0, 0, width, height)
+ Fl_Group(0, 0, width, height)
{
int button_width = 70;
int gap = 2;
int border = 2;
int input_width = width - (2 * border + 4 * (button_width + gap));
- int x = border;
+ int x = 0;
+
+ Fl_Group::current(0);
+
height -= 2 * border;
- box(PLASTIC_UP_BOX);
- Group::hide();
+ box(FL_THIN_UP_BOX);
- begin();
- hide_btn = new HighlightButton(x, border, 16, height, 0);
- hideImg = new xpmImage(new_s_xpm);
+ hide_btn = new Fl_Button(x, border, 16, height, 0);
+ hideImg = new Fl_Pixmap(new_s_xpm);
hide_btn->image(hideImg);
x += 16 + gap;
hide_btn->callback(hide_cb, this);
- hide_btn->clear_tab_to_focus();
+ hide_btn->clear_visible_focus();
+ hide_btn->box(FL_THIN_UP_BOX);
+ add(hide_btn);
i = new MyInput(x, border, input_width, height);
x += input_width + gap;
resizable(i);
i->color(206);
- i->when(WHEN_ENTER_KEY_ALWAYS);
- i->callback(search_cb2, this);
- i->clear_tab_to_focus();
- i->set_click_to_focus();
+ i->when(FL_WHEN_NEVER);
+ add(i);
- next_btn = new HighlightButton(x, border, button_width, height, "Next");
+ next_btn = new Fl_Button(x, border, button_width, height, "Next");
x += button_width + gap;
- next_btn->add_shortcut(ReturnKey);
- next_btn->add_shortcut(KeypadEnter);
+ next_btn->shortcut(FL_Enter);
next_btn->callback(search_cb, this);
- next_btn->clear_tab_to_focus();
+ next_btn->clear_visible_focus();
+ next_btn->box(FL_THIN_UP_BOX);
+ add(next_btn);
- prev_btn= new HighlightButton(x, border, button_width, height, "Previous");
- prev_btn->add_shortcut(SHIFT+ReturnKey);
- prev_btn->callback(searchBackwards_cb, this);
- prev_btn->clear_tab_to_focus();
+ prev_btn= new Fl_Button(x, border, button_width, height, "Previous");
x += button_width + gap;
+ prev_btn->shortcut(FL_SHIFT+FL_Enter);
+ prev_btn->callback(searchBackwards_cb, this);
+ prev_btn->clear_visible_focus();
+ prev_btn->box(FL_THIN_UP_BOX);
+ add(prev_btn);
- check_btn = new CheckButton(x, border, 2*button_width, height,
+ check_btn = new Fl_Check_Button(x, border, 2*button_width, height,
"Case-sensitive");
- check_btn->clear_tab_to_focus();
x += 2 * button_width + gap;
-
- end();
+ check_btn->clear_visible_focus();
+ add(check_btn);
if (prefs.show_tooltip) {
hide_btn->tooltip("Hide");
@@ -172,21 +160,21 @@ Findbar::~Findbar()
}
/*
- * Handle events. Used to catch EscapeKey events.
+ * Handle events. Used to catch FL_Escape events.
*/
int Findbar::handle(int event)
{
int ret = 0;
- int k = event_key();
- unsigned modifier = event_state() & (SHIFT | CTRL | ALT | META);
+ int k = Fl::event_key();
+ unsigned modifier = Fl::event_state() & (FL_SHIFT| FL_CTRL| FL_ALT|FL_META);
- if (event == KEY && modifier == 0 && k == EscapeKey) {
+ if (event == FL_KEYBOARD && modifier == 0 && k == FL_Escape) {
hide();
ret = 1;
}
if (ret == 0)
- ret = Group::handle(event);
+ ret = Fl_Group::handle(event);
return ret;
}
@@ -196,7 +184,13 @@ int Findbar::handle(int event)
*/
void Findbar::show()
{
- Group::show();
+ BrowserWindow *bw = a_UIcmd_get_bw_by_widget(this);
+ dReturn_if (bw == NULL);
+
+ // It takes more than just calling show() to do the trick
+ //a_UIcmd_findbar_toggle(bw, 1);
+ Fl_Group::show();
+
/* select text even if already focused */
i->take_focus();
i->position(i->size(), 0);
@@ -207,10 +201,13 @@ void Findbar::show()
*/
void Findbar::hide()
{
- BrowserWindow *bw;
+ BrowserWindow *bw = a_UIcmd_get_bw_by_widget(this);
+ dReturn_if (bw == NULL);
+
+ // It takes more than just calling hide() to do the trick
+ Fl_Group::hide();
+ a_UIcmd_findbar_toggle(bw, 0);
- Group::hide();
- if ((bw = a_UIcmd_get_bw_by_widget(this)))
- a_UIcmd_findtext_reset(bw);
+ a_UIcmd_findtext_reset(bw);
a_UIcmd_focus_main_area(bw);
}
diff --git a/src/findbar.hh b/src/findbar.hh
index ba7ed8ed..11986407 100644
--- a/src/findbar.hh
+++ b/src/findbar.hh
@@ -1,28 +1,26 @@
#ifndef __FINDBAR_HH__
#define __FINDBAR_HH__
-#include <fltk/xpmImage.h>
-#include <fltk/Widget.h>
-#include <fltk/HighlightButton.h>
-#include <fltk/Button.h>
-#include <fltk/Input.h>
-#include <fltk/Group.h>
-#include <fltk/CheckButton.h>
+#include <FL/Fl_Pixmap.H>
+#include <FL/Fl_Widget.H>
+#include <FL/Fl_Button.H>
+#include <FL/Fl_Input.H>
+#include <FL/Fl_Group.H>
+#include <FL/Fl_Check_Button.H>
/*
* Searchbar to find text in page.
*/
-class Findbar : public fltk::Group {
- fltk::Button *clrb;
- fltk::HighlightButton *hide_btn, *next_btn, *prev_btn;
- fltk::CheckButton *check_btn;
- fltk::xpmImage *hideImg;
- fltk::Input *i;
+class Findbar : public Fl_Group {
+ Fl_Button *clrb;
+ Fl_Button *hide_btn, *next_btn, *prev_btn;
+ Fl_Check_Button *check_btn;
+ Fl_Pixmap *hideImg;
+ Fl_Input *i;
- static void search_cb (fltk::Widget *, void *);
- static void searchBackwards_cb (fltk::Widget *, void *);
- static void search_cb2 (fltk::Widget *, void *);
- static void hide_cb (fltk::Widget *, void *);
+ static void search_cb (Fl_Widget *, void *);
+ static void searchBackwards_cb (Fl_Widget *, void *);
+ static void hide_cb (Fl_Widget *, void *);
public:
Findbar(int width, int height);
diff --git a/src/form.cc b/src/form.cc
index 18441fb8..9b86fcb7 100644
--- a/src/form.cc
+++ b/src/form.cc
@@ -249,7 +249,9 @@ static void Html_add_input(DilloHtml *html, DilloHtmlInputType type,
html->inputs_outside_form->increase();
html->inputs_outside_form->set(ni, input);
- input->setEnabled(false);
+ if (html->bw->NumPendingStyleSheets > 0) {
+ input->setEnabled(false);
+ }
}
}
@@ -609,7 +611,6 @@ void Html_tag_open_isindex(DilloHtml *html, const char *tag, int tagsize)
/*
* The textarea tag
- * (TODO: It doesn't support wrapping).
*/
void Html_tag_open_textarea(DilloHtml *html, const char *tag, int tagsize)
{
diff --git a/src/html.cc b/src/html.cc
index 45e3d64a..1bdbd8fb 100644
--- a/src/html.cc
+++ b/src/html.cc
@@ -2449,12 +2449,14 @@ static void Html_tag_open_a(DilloHtml *html, const char *tag, int tagsize)
html->InVisitedLink = true;
html->styleEngine->setPseudoVisited ();
if (html->non_css_visited_color != -1)
- html->styleEngine->setNonCssHint(CSS_PROPERTY_COLOR, CSS_TYPE_COLOR,
+ html->styleEngine->setNonCssHint(CSS_PROPERTY_COLOR,
+ CSS_TYPE_COLOR,
html->non_css_visited_color);
} else {
html->styleEngine->setPseudoLink ();
if (html->non_css_link_color != -1)
- html->styleEngine->setNonCssHint(CSS_PROPERTY_COLOR, CSS_TYPE_COLOR,
+ html->styleEngine->setNonCssHint(CSS_PROPERTY_COLOR,
+ CSS_TYPE_COLOR,
html->non_css_link_color);
}
@@ -2732,9 +2734,11 @@ static void Html_tag_open_hr(DilloHtml *html, const char *tag, int tagsize)
html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_LEFT_WIDTH,
CSS_TYPE_LENGTH_PERCENTAGE, size_top);
html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_BOTTOM_WIDTH,
- CSS_TYPE_LENGTH_PERCENTAGE, size_bottom);
+ CSS_TYPE_LENGTH_PERCENTAGE,
+ size_bottom);
html->styleEngine->setNonCssHint (CSS_PROPERTY_BORDER_RIGHT_WIDTH,
- CSS_TYPE_LENGTH_PERCENTAGE, size_bottom);
+ CSS_TYPE_LENGTH_PERCENTAGE,
+ size_bottom);
}
HT2TB(html)->addParbreak (5, html->styleEngine->wordStyle ());
@@ -2838,6 +2842,7 @@ static void Html_tag_open_meta(DilloHtml *html, const char *tag, int tagsize)
const char *p, *equiv, *content, *new_content;
char delay_str[64], *mr_url;
+ DilloUrl *new_url;
int delay;
/* only valid inside HEAD */
@@ -2859,44 +2864,45 @@ static void Html_tag_open_meta(DilloHtml *html, const char *tag, int tagsize)
}
/* Skip to anything after "URL=" */
while (*content && *(content++) != '=') ;
- if (*content) {
-
- /* Handle the case of a quoted URL */
- if (*content == '"' || *content == '\'') {
- if ((p = strchr(content + 1, *content)))
- mr_url = dStrndup(content + 1, p - content - 1);
- else
- mr_url = dStrdup(content + 1);
- } else {
- mr_url = dStrdup(content);
- }
-
- if (delay == 0) {
- /* zero-delay redirection */
- html->stop_parser = true;
- DilloUrl *new_url = a_Url_new(mr_url, URL_STR(html->base_url));
- if (a_Capi_dpi_verify_request(html->bw, new_url))
- a_UIcmd_redirection0((void*)html->bw, new_url);
- a_Url_free(new_url);
- } else {
- /* Send a custom HTML message.
- * TODO: This is a hairy hack,
- * It'd be much better to build a widget. */
- Dstr *ds_msg = dStr_sized_new(256);
- dStr_sprintf(ds_msg, meta_template, mr_url, delay_str);
- {
- int o_InFlags = html->InFlags;
- int o_TagSoup = html->TagSoup;
- html->InFlags = IN_BODY;
- html->TagSoup = false;
- Html_write_raw(html, ds_msg->str, ds_msg->len, 0);
- html->TagSoup = o_TagSoup;
- html->InFlags = o_InFlags;
- }
- dStr_free(ds_msg, 1);
+ /* Handle the case of a quoted URL */
+ if (*content == '"' || *content == '\'') {
+ if ((p = strchr(content + 1, *content)))
+ mr_url = dStrndup(content + 1, p - content - 1);
+ else
+ mr_url = dStrdup(content + 1);
+ } else {
+ mr_url = dStrdup(content);
+ }
+ new_url = a_Url_new(mr_url, URL_STR(html->base_url));
+
+ if (a_Url_cmp(html->base_url, new_url) == 0) {
+ /* redirection loop, or empty url string: ignore */
+ BUG_MSG("META refresh: %s\n",
+ *mr_url ? "redirection loop" : "no target URL");
+ } else if (delay == 0) {
+ /* zero-delay redirection */
+ html->stop_parser = true;
+ if (a_Capi_dpi_verify_request(html->bw, new_url))
+ a_UIcmd_redirection0((void*)html->bw, new_url);
+ } else {
+ /* Send a custom HTML message.
+ * TODO: This is a hairy hack,
+ * It'd be much better to build a widget. */
+ Dstr *ds_msg = dStr_sized_new(256);
+ dStr_sprintf(ds_msg, meta_template, mr_url, delay_str);
+ {
+ int o_InFlags = html->InFlags;
+ int o_TagSoup = html->TagSoup;
+ html->InFlags = IN_BODY;
+ html->TagSoup = false;
+ Html_write_raw(html, ds_msg->str, ds_msg->len, 0);
+ html->TagSoup = o_TagSoup;
+ html->InFlags = o_InFlags;
}
- dFree(mr_url);
+ dStr_free(ds_msg, 1);
}
+ a_Url_free(new_url);
+ dFree(mr_url);
} else if (!dStrcasecmp(equiv, "content-type") &&
(content = a_Html_get_attr(html, tag, tagsize, "content"))) {
@@ -3018,7 +3024,7 @@ static void Html_tag_open_link(DilloHtml *html, const char *tag, int tagsize)
!(url = a_Html_url_new(html, attrbuf, NULL, 0)))
return;
- MSG(" Html_tag_open_link(): addCssUrl %s\n", URL_STR(url));
+ _MSG(" Html_tag_open_link(): addCssUrl %s\n", URL_STR(url));
html->addCssUrl(url);
a_Url_free(url);
diff --git a/src/keys.cc b/src/keys.cc
index 1a39f4c8..e5510ef0 100644
--- a/src/keys.cc
+++ b/src/keys.cc
@@ -9,7 +9,7 @@
* (at your option) any later version.
*/
-#include <fltk/events.h>
+#include <FL/Fl.H>
#include <stdio.h>
#include <stdlib.h> /* strtol */
#include <string.h>
@@ -17,6 +17,7 @@
#include "dlib/dlib.h"
#include "keys.hh"
+#include "utf8.hh"
#include "msg.h"
/*
@@ -38,80 +39,96 @@ typedef struct {
* Local data
*/
static const Mapping_t keyNames[] = {
- { "Backspace", fltk::BackSpaceKey },
- { "Delete", fltk::DeleteKey },
- { "Down", fltk::DownKey },
- { "End", fltk::EndKey },
- { "Esc", fltk::EscapeKey },
- { "F1", fltk::F1Key },
- { "F2", fltk::F2Key },
- { "F3", fltk::F3Key },
- { "F4", fltk::F4Key },
- { "F5", fltk::F5Key },
- { "F6", fltk::F6Key },
- { "F7", fltk::F7Key },
- { "F8", fltk::F8Key },
- { "F9", fltk::F9Key },
- { "F10", fltk::F10Key },
- { "F11", fltk::F11Key },
- { "F12", fltk::F12Key },
- { "Home", fltk::HomeKey },
- { "Insert", fltk::InsertKey },
- { "Left", fltk::LeftKey },
- { "PageDown", fltk::PageDownKey },
- { "PageUp", fltk::PageUpKey },
- { "Print", fltk::PrintKey },
- { "Return", fltk::ReturnKey },
- { "Right", fltk::RightKey },
- { "Space", fltk::SpaceKey },
- { "Tab", fltk::TabKey },
- { "Up", fltk::UpKey }
+ { "Backspace", FL_BackSpace },
+ { "Delete", FL_Delete },
+ { "Down", FL_Down },
+ { "End", FL_End },
+ { "Esc", FL_Escape },
+ { "F1", FL_F + 1 },
+ { "F2", FL_F + 2 },
+ { "F3", FL_F + 3 },
+ { "F4", FL_F + 4 },
+ { "F5", FL_F + 5 },
+ { "F6", FL_F + 6 },
+ { "F7", FL_F + 7 },
+ { "F8", FL_F + 8 },
+ { "F9", FL_F + 9 },
+ { "F10", FL_F + 10 },
+ { "F11", FL_F + 11 },
+ { "F12", FL_F + 12 },
+ { "Home", FL_Home },
+ { "Insert", FL_Insert },
+ { "Left", FL_Left },
+ { "PageDown", FL_Page_Down },
+ { "PageUp", FL_Page_Up },
+ { "Print", FL_Print },
+ { "Return", FL_Enter },
+ { "Right", FL_Right },
+ { "Space", ' ' },
+ { "Tab", FL_Tab },
+ { "Up", FL_Up },
+ /* multimedia keys */
+ { "Back", FL_Back },
+ { "Favorites", FL_Favorites },
+ { "Forward", FL_Forward },
+ { "HomePage", FL_Home_Page },
+ { "Mail", FL_Mail },
+ { "MediaNext", FL_Media_Next },
+ { "MediaPlay", FL_Media_Play },
+ { "MediaPrev", FL_Media_Prev },
+ { "MediaStop", FL_Media_Stop },
+ { "Refresh", FL_Refresh },
+ { "Search", FL_Search },
+ { "Sleep", FL_Sleep },
+ { "Stop", FL_Stop },
+ { "VolumeDown", FL_Volume_Down },
+ { "VolumeMute", FL_Volume_Mute },
+ { "VolumeUp", FL_Volume_Up },
};
static const Mapping_t modifierNames[] = {
- { "Shift", fltk::SHIFT },
- { "Ctrl", fltk::CTRL },
- { "Alt", fltk::ALT },
- { "Meta", fltk::META },
- { "Button1", fltk::BUTTON1 },
- { "Button2", fltk::BUTTON2 },
- { "Button3", fltk::BUTTON3 }
+ { "Shift", FL_SHIFT },
+ { "Ctrl", FL_CTRL },
+ { "Alt", FL_ALT },
+ { "Meta", FL_META },
+ { "Button1", FL_BUTTON1 },
+ { "Button2", FL_BUTTON2 },
+ { "Button3", FL_BUTTON3 }
};
static const KeyBinding_t default_keys[] = {
- { "nop" , KEYS_NOP , 0 , 0 },
- { "open" , KEYS_OPEN , fltk::CTRL , 'o' },
- { "new-window" , KEYS_NEW_WINDOW , fltk::CTRL , 'n' },
- { "new-tab" , KEYS_NEW_TAB , fltk::CTRL , 't' },
- { "left-tab" , KEYS_LEFT_TAB , fltk::SHIFT , fltk::TabKey },
- { "right-tab" , KEYS_RIGHT_TAB , fltk::CTRL , fltk::TabKey },
- { "close-tab" , KEYS_CLOSE_TAB , fltk::CTRL , 'q' },
- { "find" , KEYS_FIND , fltk::CTRL , 'f' },
- { "websearch" , KEYS_WEBSEARCH , fltk::CTRL , 's' },
- { "bookmarks" , KEYS_BOOKMARKS , fltk::CTRL , 'b' },
- { "fullscreen" , KEYS_FULLSCREEN , fltk::CTRL , fltk::SpaceKey },
- { "reload" , KEYS_RELOAD , fltk::CTRL , 'r' },
- { "stop" , KEYS_STOP , 0 , 0 },
- { "save" , KEYS_SAVE , 0 , 0 },
- { "hide-panels" , KEYS_HIDE_PANELS , 0 , fltk::EscapeKey },
- { "file-menu" , KEYS_FILE_MENU , fltk::ALT , 'f' },
- { "close-all" , KEYS_CLOSE_ALL , fltk::ALT , 'q' },
- { "back" , KEYS_BACK , 0 , fltk::BackSpaceKey },
- { "back" , KEYS_BACK , 0 , ',' },
- { "forward" , KEYS_FORWARD , fltk::SHIFT , fltk::BackSpaceKey },
- { "forward" , KEYS_FORWARD , 0 , '.' },
- { "goto" , KEYS_GOTO , fltk::CTRL , 'l' },
- { "home" , KEYS_HOME , fltk::CTRL , 'h' },
- { "screen-up" , KEYS_SCREEN_UP , 0 , fltk::PageUpKey },
- { "screen-up" , KEYS_SCREEN_UP , 0 , 'b' },
- { "screen-down" , KEYS_SCREEN_DOWN , 0 , fltk::PageDownKey },
- { "screen-down" , KEYS_SCREEN_DOWN , 0 , fltk::SpaceKey },
- { "line-up" , KEYS_LINE_UP , 0 , fltk::UpKey },
- { "line-down" , KEYS_LINE_DOWN , 0 , fltk::DownKey },
- { "left" , KEYS_LEFT , 0 , fltk::LeftKey },
- { "right" , KEYS_RIGHT , 0 , fltk::RightKey },
- { "top" , KEYS_TOP , 0 , fltk::HomeKey },
- { "bottom" , KEYS_BOTTOM , 0 , fltk::EndKey },
+ { "nop" , KEYS_NOP , 0 , 0 },
+ { "open" , KEYS_OPEN , FL_CTRL , 'o' },
+ { "new-window" , KEYS_NEW_WINDOW , FL_CTRL , 'n' },
+ { "new-tab" , KEYS_NEW_TAB , FL_CTRL , 't' },
+ { "left-tab" , KEYS_LEFT_TAB , FL_SHIFT , FL_Tab },
+ { "right-tab" , KEYS_RIGHT_TAB , FL_CTRL , FL_Tab },
+ { "close-tab" , KEYS_CLOSE_TAB , FL_CTRL , 'w' },
+ { "find" , KEYS_FIND , FL_CTRL , 'f' },
+ { "websearch" , KEYS_WEBSEARCH , FL_CTRL , 's' },
+ { "bookmarks" , KEYS_BOOKMARKS , FL_CTRL , 'b' },
+ { "reload" , KEYS_RELOAD , FL_CTRL , 'r' },
+ { "stop" , KEYS_STOP , 0 , 0 },
+ { "save" , KEYS_SAVE , 0 , 0 },
+ { "hide-panels" , KEYS_HIDE_PANELS , 0 , FL_Escape },
+ { "file-menu" , KEYS_FILE_MENU , FL_ALT , 'f' },
+ { "close-all" , KEYS_CLOSE_ALL , FL_CTRL , 'q' },
+ { "back" , KEYS_BACK , 0 , FL_BackSpace },
+ { "back" , KEYS_BACK , 0 , ',' },
+ { "forward" , KEYS_FORWARD , FL_SHIFT , FL_BackSpace },
+ { "forward" , KEYS_FORWARD , 0 , '.' },
+ { "goto" , KEYS_GOTO , FL_CTRL , 'l' },
+ { "home" , KEYS_HOME , FL_CTRL , 'h' },
+ { "screen-up" , KEYS_SCREEN_UP , 0 , FL_Page_Up },
+ { "screen-up" , KEYS_SCREEN_UP , 0 , 'b' },
+ { "screen-down" , KEYS_SCREEN_DOWN , 0 , FL_Page_Down },
+ { "screen-down" , KEYS_SCREEN_DOWN , 0 , ' ' },
+ { "line-up" , KEYS_LINE_UP , 0 , FL_Up },
+ { "line-down" , KEYS_LINE_DOWN , 0 , FL_Down },
+ { "left" , KEYS_LEFT , 0 , FL_Left },
+ { "right" , KEYS_RIGHT , 0 , FL_Right },
+ { "top" , KEYS_TOP , 0 , FL_Home },
+ { "bottom" , KEYS_BOTTOM , 0 , FL_End },
};
static Dlist *bindings;
@@ -172,20 +189,25 @@ KeysCommand_t Keys::getKeyCmd()
{
KeysCommand_t ret = KEYS_NOP;
KeyBinding_t keyNode;
- // We're only interested in some flags
- keyNode.modifier = fltk::event_state() &
- (fltk::SHIFT | fltk::CTRL | fltk::ALT | fltk::META);
-
- if (keyNode.modifier == fltk::SHIFT &&
- ispunct(fltk::event_text()[0])) {
- // Get key code for a shifted character
- keyNode.key = fltk::event_text()[0];
- keyNode.modifier = 0;
+
+ keyNode.modifier = Fl::event_state() & (FL_SHIFT | FL_CTRL |FL_ALT|FL_META);
+ if (iscntrl(Fl::event_text()[0])) {
+ keyNode.key = Fl::event_key();
} else {
- keyNode.key = fltk::event_key();
+ const char *beyond = Fl::event_text() + Fl::event_length();
+ keyNode.key = a_Utf8_decode(Fl::event_text(), beyond, NULL);
+
+ /* BUG: The idea is to drop the modifiers if their use results in a
+ * different character (e.g., if shift-8 gives '*', drop the shift,
+ * but if ctrl-6 gives '6', keep the ctrl), but we have to compare a
+ * keysym with a Unicode codepoint, which only works for characters
+ * below U+0100 (those known to latin-1).
+ */
+ if (keyNode.key != Fl::event_key())
+ keyNode.modifier = 0;
}
-
- _MSG("getKeyCmd: key=%d, mod=%d\n", keyNode.key, keyNode.modifier);
+ _MSG("getKeyCmd: evkey=0x%x evtext=\'%s\' key=0x%x, mod=0x%x\n",
+ Fl::event_key(), Fl::event_text(), keyNode.key, keyNode.modifier);
void *data = dList_find_sorted(bindings, &keyNode, nodeByKeyCmp);
if (data)
ret = ((KeyBinding_t*)data)->cmd;
@@ -311,8 +333,11 @@ void Keys::parseKey(char *key, char *commandName)
// Get key code
if (!key[1]) {
keycode = *key;
+ } else if (a_Utf8_char_count(keystr, strlen(keystr)) == 1) {
+ const char *beyond = keystr + strlen(keystr);
+ keycode = a_Utf8_decode(keystr, beyond, NULL);
} else if (key[0] == '0' && key[1] == 'x') {
- /* keysym. For details on values reported, see fltk's fltk/events.h */
+ /* keysym */
keycode = strtol(key, NULL, 0x10);
} else if ((st = getKeyCode(keystr)) == -1) {
MSG("Keys::parseKey unknown keyname: %s\n", keystr);
diff --git a/src/keys.hh b/src/keys.hh
index d234838c..893cf17b 100644
--- a/src/keys.hh
+++ b/src/keys.hh
@@ -27,7 +27,6 @@ typedef enum {
KEYS_FIND,
KEYS_WEBSEARCH,
KEYS_BOOKMARKS,
- KEYS_FULLSCREEN,
KEYS_RELOAD,
KEYS_STOP,
KEYS_SAVE,
diff --git a/src/keysrc b/src/keysrc
index 3f53674f..df658be4 100644
--- a/src/keysrc
+++ b/src/keysrc
@@ -6,10 +6,15 @@
# The commented-out bindings below show the defaults built into Dillo.
#
# Modifiers recognized: "Shift", "Ctrl", "Alt", "Meta".
+#
# Key names recognized: "Backspace", "Delete", "Down", "End", "Esc",
# "F1" through "F12", "Home", "Insert", "Left", "PageDown", "PageUp",
# "Print", "Return", "Right", "Space", "Tab", "Up".
#
+# Multimedia keys: "Back", "Favorites", "Forward", "HomePage", "Mail",
+# "MediaNext", "MediaPlay", "MediaPrev", "MediaStop", "Refresh", "Search",
+# "Sleep", "Stop", "VolumeDown", "VolumeMute", VolumeUp".
+#
# If Dillo is running under X11, keys whose names are not recognized can
# be specified using their keysym value in hexadecimal. Use xev to get
# the keysym. Example rule: "0x1008ff27 = forward".
@@ -27,13 +32,12 @@
# "close-tab" closes the current tab.
# Note that this closes the browser window if there is only one tab.
-#<ctrl>q = close-tab
+#<ctrl>w = close-tab
# "close-all" closes all tabs/windows and exits.
-#<alt>q = close-all
+#<ctrl>q = close-all
# "left-tab" and "right-tab" switch to the left/right of the current tab.
-# *** NOT HOOKED UP YET ***
# <shift>tab = left-tab
# <ctrl>tab = right-tab
@@ -52,7 +56,7 @@
# "find" lets you search for a text string on the current page.
#<ctrl>f = find
-# "hide-panels" hides the findbar.
+# "hide-panels" hides the findbar if present, control panels if not.
#esc = hide-panels
# "websearch" lets you send a text string to the search engine that you
@@ -62,9 +66,6 @@
# go to your "bookmarks".
#<ctrl>b = bookmarks
-# "fullscreen" hides/shows the panels at the top and bottom of a dillo window.
-#<ctrl>space = fullscreen
-
# "file-menu" pops up the file menu.
#<alt>f = file-menu
diff --git a/src/menu.cc b/src/menu.cc
index 23c33b4a..090e2b56 100644
--- a/src/menu.cc
+++ b/src/menu.cc
@@ -11,11 +11,8 @@
// Functions/Methods for menus
-#include <fltk/events.h>
-#include <fltk/PopupMenu.h>
-#include <fltk/Item.h>
-#include <fltk/ToggleItem.h>
-#include <fltk/Divider.h>
+#include <FL/Fl.H>
+#include <FL/Fl_Menu_Item.H>
#include "lout/misc.hh" /* SimpleVector */
#include "msg.h"
@@ -27,8 +24,6 @@
#include "keys.hh"
#include "timeout.hh"
-using namespace fltk;
-
/*
* Local data
*/
@@ -38,54 +33,27 @@ using namespace fltk;
static DilloUrl *popup_url = NULL;
// Weak reference to the popup's bw
static BrowserWindow *popup_bw = NULL;
-// Where to place the filemenu popup
+static void *popup_form = NULL;
+// Where to place the popup
static int popup_x, popup_y;
// History popup direction (-1 = back, 1 = forward).
static int history_direction = -1;
// History popup, list of URL-indexes.
static int *history_list = NULL;
-/*
- * Local sub class.
- * Used to add the hint for history popup menus, and to remember
- * the mouse button pressed over a menu item.
- */
-class CustItem : public Item {
- int EventButton;
-public:
- CustItem (const char* label) : Item(label) { EventButton = 0; };
- int button () { return EventButton; };
- void draw();
- int handle(int e) {
- EventButton = event_button();
- return Item::handle(e);
- }
-};
-
-/*
- * This adds a call to a_UIcmd_set_msg() to show the URL in the status bar
- * TODO: erase the URL on popup close.
- */
-void CustItem::draw() {
- const DilloUrl *url;
- if (flags() & SELECTED) {
- url = a_History_get_url(history_list[(VOIDP2INT(user_data()))-1]);
- a_UIcmd_set_msg(popup_bw, "%s", URL_STR(url));
- }
- Item::draw();
+//--------------------------------------------------------------------------
+static void Menu_nop_cb(Fl_Widget*, void*)
+{
}
-
-//--------------------------------------------------------------------------
/*
* Static function for File menu callbacks.
*/
-static void filemenu_cb(Widget *wid, void *data)
+static void filemenu_cb(Fl_Widget*, void *data)
{
if (strcmp((char*)data, "nw") == 0) {
- UI *ui = (UI*)popup_bw->ui;
- a_UIcmd_browser_window_new(ui->w(), ui->h(), 0, popup_bw);
+ a_UIcmd_open_url_nw(popup_bw, NULL);
} else if (strcmp((char*)data, "nt") == 0) {
a_UIcmd_open_url_nt(popup_bw, NULL, 1);
} else if (strcmp((char*)data, "of") == 0) {
@@ -100,13 +68,13 @@ static void filemenu_cb(Widget *wid, void *data)
}
-static void Menu_copy_urlstr_cb(Widget *)
+static void Menu_copy_urlstr_cb(Fl_Widget*, void*)
{
if (popup_url)
a_UIcmd_copy_urlstr(popup_bw, URL_STR(popup_url));
}
-static void Menu_link_cb(Widget*, void *user_data)
+static void Menu_link_cb(Fl_Widget*, void *user_data)
{
DilloUrl *url = (DilloUrl *) user_data ;
_MSG("Menu_link_cb: click! :-)\n");
@@ -118,7 +86,7 @@ static void Menu_link_cb(Widget*, void *user_data)
/*
* Open URL
*/
-static void Menu_open_url_cb(Widget* )
+static void Menu_open_url_cb(Fl_Widget*, void*)
{
_MSG("Open URL cb: click! :-)\n");
a_UIcmd_open_url(popup_bw, popup_url);
@@ -127,7 +95,7 @@ static void Menu_open_url_cb(Widget* )
/*
* Open URL in new window
*/
-static void Menu_open_url_nw_cb(Widget* )
+static void Menu_open_url_nw_cb(Fl_Widget*, void*)
{
_MSG("Open URL in new window cb: click! :-)\n");
a_UIcmd_open_url_nw(popup_bw, popup_url);
@@ -136,17 +104,17 @@ static void Menu_open_url_nw_cb(Widget* )
/*
* Open URL in new Tab
*/
-static void Menu_open_url_nt_cb(Widget* )
+static void Menu_open_url_nt_cb(Fl_Widget*, void*)
{
int focus = prefs.focus_new_tab ? 1 : 0;
- if (event_state(SHIFT)) focus = !focus;
+ if (Fl::event_state(FL_SHIFT)) focus = !focus;
a_UIcmd_open_url_nt(popup_bw, popup_url, focus);
}
/*
* Add bookmark
*/
-static void Menu_add_bookmark_cb(Widget* )
+static void Menu_add_bookmark_cb(Fl_Widget*, void*)
{
a_UIcmd_add_bookmark(popup_bw, popup_url);
}
@@ -154,15 +122,15 @@ static void Menu_add_bookmark_cb(Widget* )
/*
* Find text
*/
-static void Menu_find_text_cb(Widget* )
+static void Menu_find_text_cb(Fl_Widget*, void*)
{
- ((UI *)popup_bw->ui)->set_findbar_visibility(1);
+ ((UI *)popup_bw->ui)->findbar_toggle(1);
}
/*
* Save link
*/
-static void Menu_save_link_cb(Widget* )
+static void Menu_save_link_cb(Fl_Widget*, void*)
{
a_UIcmd_save_link(popup_bw, popup_url);
}
@@ -170,7 +138,7 @@ static void Menu_save_link_cb(Widget* )
/*
* Save current page
*/
-static void Menu_save_page_cb(Widget* )
+static void Menu_save_page_cb(Fl_Widget*, void*)
{
a_UIcmd_save(popup_bw);
}
@@ -178,7 +146,7 @@ static void Menu_save_page_cb(Widget* )
/*
* View current page source
*/
-static void Menu_view_page_source_cb(Widget* )
+static void Menu_view_page_source_cb(Fl_Widget*, void*)
{
a_UIcmd_view_page_source(popup_bw, popup_url);
}
@@ -186,7 +154,7 @@ static void Menu_view_page_source_cb(Widget* )
/*
* View current page's bugs
*/
-static void Menu_view_page_bugs_cb(Widget* )
+static void Menu_view_page_bugs_cb(Fl_Widget*, void*)
{
a_UIcmd_view_page_bugs(popup_bw);
}
@@ -194,7 +162,7 @@ static void Menu_view_page_bugs_cb(Widget* )
/*
* Load images on current page that match URL pattern
*/
-static void Menu_load_images_cb(Widget*, void *user_data)
+static void Menu_load_images_cb(Fl_Widget*, void *user_data)
{
DilloUrl *page_url = (DilloUrl *) user_data;
void *doc = a_Bw_get_url_doc(popup_bw, page_url);
@@ -206,39 +174,38 @@ static void Menu_load_images_cb(Widget*, void *user_data)
/*
* Submit form
*/
-static void Menu_form_submit_cb(Widget*, void *v_form)
+static void Menu_form_submit_cb(Fl_Widget*, void*)
{
void *doc = a_Bw_get_url_doc(popup_bw, popup_url);
if (doc)
- a_Html_form_submit(doc, v_form);
+ a_Html_form_submit(doc, popup_form);
}
/*
* Reset form
*/
-static void Menu_form_reset_cb(Widget*, void *v_form)
+static void Menu_form_reset_cb(Fl_Widget*, void*)
{
void *doc = a_Bw_get_url_doc(popup_bw, popup_url);
if (doc)
- a_Html_form_reset(doc, v_form);
+ a_Html_form_reset(doc, popup_form);
}
/*
* Toggle display of 'hidden' form controls.
*/
-static void Menu_form_hiddens_cb(Widget *w, void *user_data)
+static void Menu_form_hiddens_cb(Fl_Widget*, void *user_data)
{
- void *v_form = w->parent()->user_data();
bool visible = *((bool *) user_data);
void *doc = a_Bw_get_url_doc(popup_bw, popup_url);
if (doc)
- a_Html_form_display_hiddens(doc, v_form, !visible);
+ a_Html_form_display_hiddens(doc, popup_form, !visible);
}
-static void Menu_stylesheet_cb(Widget *w, void *vUrl)
+static void Menu_stylesheet_cb(Fl_Widget*, void *vUrl)
{
const DilloUrl *url = (const DilloUrl *) vUrl;
a_UIcmd_open_url(popup_bw, url);
@@ -247,7 +214,7 @@ static void Menu_stylesheet_cb(Widget *w, void *vUrl)
/*
* Validate URL with the W3C
*/
-static void Menu_bugmeter_validate_w3c_cb(Widget* )
+static void Menu_bugmeter_validate_w3c_cb(Fl_Widget*, void*)
{
Dstr *dstr = dStr_sized_new(128);
@@ -260,7 +227,7 @@ static void Menu_bugmeter_validate_w3c_cb(Widget* )
/*
* Validate URL with the WDG
*/
-static void Menu_bugmeter_validate_wdg_cb(Widget* )
+static void Menu_bugmeter_validate_wdg_cb(Fl_Widget*, void*)
{
Dstr *dstr = dStr_sized_new(128);
@@ -274,7 +241,7 @@ static void Menu_bugmeter_validate_wdg_cb(Widget* )
/*
* Show info page for the bug meter
*/
-static void Menu_bugmeter_about_cb(Widget* )
+static void Menu_bugmeter_about_cb(Fl_Widget*, void*)
{
a_UIcmd_open_urlstr(popup_bw, "http://www.dillo.org/help/bug_meter.html");
}
@@ -283,23 +250,23 @@ static void Menu_bugmeter_about_cb(Widget* )
* Navigation History callback.
* Go to selected URL.
*/
-static void Menu_history_cb(Widget *wid, void *data)
+static void Menu_history_cb(Fl_Widget*, void *data)
{
- int mb = ((CustItem*)wid)->button();
+ int mb = Fl::event_button();
int offset = history_direction * VOIDP2INT(data);
const DilloUrl *url = a_History_get_url(history_list[VOIDP2INT(data)-1]);
- if (mb == 2) {
+ if (mb == 1) {
+ a_UIcmd_nav_jump(popup_bw, offset, 0);
+ } else if (mb == 2) {
// Middle button, open in a new window/tab
if (prefs.middle_click_opens_new_tab) {
int focus = prefs.focus_new_tab ? 1 : 0;
- if (event_state(SHIFT)) focus = !focus;
+ if (Fl::event_state(FL_SHIFT)) focus = !focus;
a_UIcmd_open_url_nt(popup_bw, url, focus);
} else {
a_UIcmd_open_url_nw(popup_bw, url);
}
- } else {
- a_UIcmd_nav_jump(popup_bw, offset, 0);
}
}
@@ -311,18 +278,10 @@ static void Menu_history_cb(Widget *wid, void *data)
*/
static void Menu_popup_cb(void *data)
{
- ((PopupMenu *)data)->popup();
- a_Timeout_remove();
-}
+ const Fl_Menu_Item *m = ((Fl_Menu_Item *)data)->popup(popup_x, popup_y);
-/*
- * Same as above but with coordinates.
- */
-static void Menu_popup_cb2(void *data)
-{
- Menu *m = (Menu *)data;
- m->value(-1);
- m->popup(Rectangle(popup_x,popup_y,m->w(),m->h()), m->label());
+ if (m && m->callback())
+ m->do_callback((Fl_Widget *)data);
a_Timeout_remove();
}
@@ -334,65 +293,49 @@ void a_Menu_page_popup(BrowserWindow *bw, const DilloUrl *url,
{
lout::misc::SimpleVector <DilloUrl*> *cssUrls =
(lout::misc::SimpleVector <DilloUrl*> *) v_cssUrls;
- Item *i;
- int j;
- // One menu for every browser window
- static PopupMenu *pm = 0;
- // Active/inactive control.
- static Item *view_page_bugs_item = 0, *view_source_item = 0;
- static ItemGroup *stylesheets = 0;
-
+ int j = 0;
+
+ static Fl_Menu_Item *stylesheets = NULL;
+ static Fl_Menu_Item pm[] = {
+ {"View page source", 0, Menu_view_page_source_cb,0,0,0,0,0,0},
+ {"View page bugs", 0, Menu_view_page_bugs_cb,0,0,0,0,0,0},
+ {"View stylesheets", 0, Menu_nop_cb,0,FL_SUBMENU_POINTER|FL_MENU_DIVIDER,
+ 0,0,0,0},
+ {"Bookmark this page", 0,Menu_add_bookmark_cb,0,FL_MENU_DIVIDER,0,0,0,0},
+ {"Find text", 0, Menu_find_text_cb,0,0,0,0,0,0},
+ {"Save page as...", 0, Menu_save_page_cb,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0}
+ };
+
+ popup_x = Fl::event_x();
+ popup_y = Fl::event_y();
popup_bw = bw;
a_Url_free(popup_url);
popup_url = a_Url_dup(url);
- if (!pm) {
- pm = new PopupMenu(0,0,0,0,"&PAGE OPTIONS");
- pm->begin();
- i = view_source_item = new Item("View page Source");
- i->callback(Menu_view_page_source_cb);
- i = view_page_bugs_item = new Item("View page Bugs");
- i->callback(Menu_view_page_bugs_cb);
- stylesheets = new ItemGroup("View Stylesheets");
- new Divider();
- i = new Item("Bookmark this page");
- i->callback(Menu_add_bookmark_cb);
- new Divider();
- i = new Item("Find Text");
- i->callback(Menu_find_text_cb);
- //i->shortcut(CTRL+'f');
- i = new Item("Jump to...");
- i->deactivate();
- new Divider();
- i = new Item("Save page As...");
- i->callback(Menu_save_page_cb);
-
- pm->type(PopupMenu::POPUP123);
- pm->end();
- }
-
- if (has_bugs == TRUE)
- view_page_bugs_item->activate();
- else
- view_page_bugs_item->deactivate();
+ has_bugs == TRUE ? pm[1].activate() : pm[1].deactivate();
if (strncmp(URL_STR(url), "dpi:/vsource/", 13) == 0)
- view_source_item->deactivate();
+ pm[0].deactivate();
else
- view_source_item->activate();
-
- int n = stylesheets->children();
- for (j = 0; j < n; j++) {
- /* get rid of the old ones */
- Widget *child = stylesheets->child(0);
- dFree((char *)child->label());
- a_Url_free((DilloUrl *)child->user_data());
- delete child;
+ pm[0].activate();
+
+ if (stylesheets) {
+ while (stylesheets[j].text) {
+ dFree((char *) stylesheets[j].label());
+ a_Url_free((DilloUrl *) stylesheets[j].user_data());
+ j++;
+ }
+ delete [] stylesheets;
+ stylesheets = NULL;
}
if (cssUrls && cssUrls->size () > 0) {
- stylesheets->activate();
+ stylesheets = new Fl_Menu_Item[cssUrls->size() + 1];
+ memset(stylesheets, '\0', sizeof(Fl_Menu_Item[cssUrls->size() + 1]));
+
for (j = 0; j < cssUrls->size(); j++) {
+
/* may want ability to Load individual unloaded stylesheets as well */
const char *action = "View ";
DilloUrl *url = cssUrls->get(j);
@@ -411,17 +354,17 @@ void a_Menu_page_popup(BrowserWindow *bw, const DilloUrl *url,
label = dStrconcat(action, url_str, NULL);
}
- i = new Item(label);
- i->set_flag(RAW_LABEL);
- i->user_data(a_Url_dup(url));
- i->callback(Menu_stylesheet_cb);
- stylesheets->add(i);
+ stylesheets[j].label(FL_NORMAL_LABEL, label);
+ stylesheets[j].callback(Menu_stylesheet_cb, a_Url_dup(url));
}
+
+ pm[2].user_data(stylesheets);
+ pm[2].activate();
} else {
- stylesheets->deactivate();
+ pm[2].deactivate();
}
- a_Timeout_add(0.0, Menu_popup_cb, (void *)pm);
+ a_Timeout_add(0.0, Menu_popup_cb, (void*)pm);
}
/*
@@ -429,35 +372,23 @@ void a_Menu_page_popup(BrowserWindow *bw, const DilloUrl *url,
*/
void a_Menu_link_popup(BrowserWindow *bw, const DilloUrl *url)
{
- // One menu for every browser window
- static PopupMenu *pm = 0;
-
+ static Fl_Menu_Item pm[] = {
+ {"Open link in new tab", 0, Menu_open_url_nt_cb,0,0,0,0,0,0},
+ {"Open link in new window", 0, Menu_open_url_nw_cb,0,FL_MENU_DIVIDER,0,0,
+ 0,0},
+ {"Bookmark this link", 0, Menu_add_bookmark_cb,0,0,0,0,0,0},
+ {"Copy link location", 0, Menu_copy_urlstr_cb,0,FL_MENU_DIVIDER,0,0,0,0},
+ {"Save link as...", 0, Menu_save_link_cb,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0}
+ };
+
+ popup_x = Fl::event_x();
+ popup_y = Fl::event_y();
popup_bw = bw;
a_Url_free(popup_url);
popup_url = a_Url_dup(url);
- if (!pm) {
- Item *i;
- pm = new PopupMenu(0,0,0,0,"&LINK OPTIONS");
- //pm->callback(Menu_link_cb, url);
- pm->begin();
- i = new Item("Open Link in New Window");
- i->callback(Menu_open_url_nw_cb);
- i = new Item("Open Link in New Tab");
- i->callback(Menu_open_url_nt_cb);
- new Divider();
- i = new Item("Bookmark this Link");
- i->callback(Menu_add_bookmark_cb);
- i = new Item("Copy Link location");
- i->callback(Menu_copy_urlstr_cb);
- new Divider();
- i = new Item("Save Link As...");
- i->callback(Menu_save_link_cb);
-
- pm->type(PopupMenu::POPUP123);
- pm->end();
- }
- a_Timeout_add(0.0, Menu_popup_cb, (void *)pm);
+ a_Timeout_add(0.0, Menu_popup_cb, (void*)pm);
}
/*
@@ -467,14 +398,23 @@ void a_Menu_image_popup(BrowserWindow *bw, const DilloUrl *url,
bool_t loaded_img, DilloUrl *page_url,
DilloUrl *link_url)
{
- // One menu for every browser window
- static PopupMenu *pm = 0;
- // Active/inactive control.
- static Item *link_menuitem = 0;
- static Item *load_img_menuitem = 0;
static DilloUrl *popup_page_url = NULL;
static DilloUrl *popup_link_url = NULL;
-
+ static Fl_Menu_Item pm[] = {
+ {"Isolate image", 0, Menu_open_url_cb,0,0,0,0,0,0},
+ {"Open image in new tab", 0, Menu_open_url_nt_cb,0,0,0,0,0,0},
+ {"Open image in new window", 0, Menu_open_url_nw_cb, 0, FL_MENU_DIVIDER,
+ 0,0,0,0},
+ {"Load image", 0, Menu_load_images_cb,0,0,0,0,0,0},
+ {"Bookmark this image", 0, Menu_add_bookmark_cb,0,0,0,0,0,0},
+ {"Copy image location", 0,Menu_copy_urlstr_cb,0,FL_MENU_DIVIDER,0,0,0,0},
+ {"Save image as...", 0, Menu_save_link_cb, 0, FL_MENU_DIVIDER,0,0,0,0},
+ {"Link menu", 0, Menu_link_cb,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0}
+ };
+
+ popup_x = Fl::event_x();
+ popup_y = Fl::event_y();
popup_bw = bw;
a_Url_free(popup_url);
popup_url = a_Url_dup(url);
@@ -483,49 +423,22 @@ void a_Menu_image_popup(BrowserWindow *bw, const DilloUrl *url,
a_Url_free(popup_link_url);
popup_link_url = a_Url_dup(link_url);
- if (!pm) {
- Item *i;
- pm = new PopupMenu(0,0,0,0,"&IMAGE OPTIONS");
- pm->begin();
- i = new Item("Isolate Image");
- i->callback(Menu_open_url_cb);
- i = new Item("Open Image in New Window");
- i->callback(Menu_open_url_nw_cb);
- i = new Item("Open Image in New Tab");
- i->callback(Menu_open_url_nt_cb);
- new Divider();
- i = load_img_menuitem = new Item("Load image");
- i->callback(Menu_load_images_cb);
- i = new Item("Bookmark this Image");
- i->callback(Menu_add_bookmark_cb);
- i = new Item("Copy Image location");
- i->callback(Menu_copy_urlstr_cb);
- new Divider();
- i = new Item("Save Image As...");
- i->callback(Menu_save_link_cb);
- new Divider();
- i = link_menuitem = new Item("Link menu");
- i->callback(Menu_link_cb);
-
- pm->type(PopupMenu::POPUP123);
- pm->end();
- }
if (loaded_img) {
- load_img_menuitem->deactivate();
+ pm[3].deactivate();
} else {
- load_img_menuitem->activate();
- load_img_menuitem->user_data(popup_page_url);
+ pm[3].activate();
+ pm[3].user_data(popup_page_url);
}
if (link_url) {
- link_menuitem->user_data(popup_link_url);
- link_menuitem->activate();
+ pm[7].activate();
+ pm[7].user_data(popup_link_url);
} else {
- link_menuitem->deactivate();
+ pm[7].deactivate();
}
- a_Timeout_add(0.0, Menu_popup_cb, (void *)pm);
+ a_Timeout_add(0.0, Menu_popup_cb, (void*)pm);
}
/*
@@ -534,31 +447,25 @@ void a_Menu_image_popup(BrowserWindow *bw, const DilloUrl *url,
void a_Menu_form_popup(BrowserWindow *bw, const DilloUrl *page_url,
void *formptr, bool_t hidvis)
{
- static PopupMenu *pm = 0;
- static Item *hiddens_item = 0;
static bool hiddens_visible;
-
+ static Fl_Menu_Item pm[] = {
+ {"Submit form", 0, Menu_form_submit_cb,0,0,0,0,0,0},
+ {"Reset form", 0, Menu_form_reset_cb,0,0,0,0,0,0},
+ {0, 0, Menu_form_hiddens_cb, &hiddens_visible, 0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0}
+ };
+
+ popup_x = Fl::event_x();
+ popup_y = Fl::event_y();
popup_bw = bw;
a_Url_free(popup_url);
popup_url = a_Url_dup(page_url);
- if (!pm) {
- Item *i;
- pm = new PopupMenu(0,0,0,0,"FORM OPTIONS");
- pm->add(i = new Item("Submit form"));
- i->callback(Menu_form_submit_cb);
- pm->add(i = new Item("Reset form"));
- i->callback(Menu_form_reset_cb);
- pm->add(hiddens_item = new Item(""));
- hiddens_item->callback(Menu_form_hiddens_cb);
- hiddens_item->user_data(&hiddens_visible);
- pm->type(PopupMenu::POPUP123);
- }
- pm->user_data(formptr);
+ popup_form = formptr;
hiddens_visible = hidvis;
- hiddens_item->label(hiddens_visible ? "Hide hiddens": "Show hiddens");
+ pm[2].label(hiddens_visible ? "Hide hiddens": "Show hiddens");
- a_Timeout_add(0.0, Menu_popup_cb, (void *)pm);
+ a_Timeout_add(0.0, Menu_popup_cb, (void*)pm);
}
/*
@@ -566,43 +473,32 @@ void a_Menu_form_popup(BrowserWindow *bw, const DilloUrl *page_url,
*/
void a_Menu_file_popup(BrowserWindow *bw, void *v_wid)
{
- UI *ui = (UI *)bw->ui;
- Widget *wid = (Widget*)v_wid;
- // One menu for every browser window
- static PopupMenu *pm = 0;
+ Fl_Widget *wid = (Fl_Widget*)v_wid;
+
+ static Fl_Menu_Item pm[] = {
+ {"New tab", Keys::getShortcut(KEYS_NEW_TAB), filemenu_cb,
+ (void*)"nt",0,0,0,0,0},
+ {"New window", Keys::getShortcut(KEYS_NEW_WINDOW), filemenu_cb,
+ (void*)"nw", FL_MENU_DIVIDER,0,0,0,0},
+ {"Open file...", Keys::getShortcut(KEYS_OPEN), filemenu_cb,
+ (void*)"of",0,0,0,0,0},
+ {"Open URL...", Keys::getShortcut(KEYS_GOTO), filemenu_cb,
+ (void*)"ou",0,0,0,0,0},
+ {"Close", Keys::getShortcut(KEYS_CLOSE_TAB), filemenu_cb,
+ (void*)"cw", FL_MENU_DIVIDER,0,0,0,0},
+ {"Exit Dillo", Keys::getShortcut(KEYS_CLOSE_ALL), filemenu_cb,
+ (void*)"ed",0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0}
+ };
popup_bw = bw;
popup_x = wid->x();
- popup_y = wid->y() + wid->h() +
- // WORKAROUND: ?? wid->y() doesn't count tabs ??
- (((Group*)ui->tabs())->children() > 1 ? 20 : 0);
+ popup_y = wid->y() + wid->h();
a_Url_free(popup_url);
popup_url = NULL;
- if (!pm) {
- int shortcut;
- pm = new PopupMenu(0,0,0,0,"File");
- pm->begin();
- shortcut = Keys::getShortcut(KEYS_NEW_WINDOW);
- new Item("New Window", shortcut, filemenu_cb, (void*)"nw");
- shortcut = Keys::getShortcut(KEYS_NEW_TAB);
- new Item("New Tab", shortcut, filemenu_cb, (void*)"nt");
- new Divider();
- shortcut = Keys::getShortcut(KEYS_OPEN);
- new Item("Open File...", shortcut, filemenu_cb, (void*)"of");
- shortcut = Keys::getShortcut(KEYS_GOTO);
- new Item("Open URL...", shortcut, filemenu_cb, (void*)"ou");
- shortcut = Keys::getShortcut(KEYS_CLOSE_TAB);
- new Item("Close", shortcut, filemenu_cb, (void*)"cw");
- new Divider();
- shortcut = Keys::getShortcut(KEYS_CLOSE_ALL);
- new Item("Exit Dillo", shortcut, filemenu_cb, (void*)"ed");
- pm->type(PopupMenu::POPUP123);
- pm->end();
- }
-
- pm->label(wid->visible() ? NULL : "File");
- a_Timeout_add(0.0, Menu_popup_cb2, (void *)pm);
+ //pm->label(wid->visible() ? NULL : "File");
+ a_Timeout_add(0.0, Menu_popup_cb, (void*)pm);
}
/*
@@ -610,28 +506,21 @@ void a_Menu_file_popup(BrowserWindow *bw, void *v_wid)
*/
void a_Menu_bugmeter_popup(BrowserWindow *bw, const DilloUrl *url)
{
- // One menu for every browser window
- static PopupMenu *pm = 0;
+ static Fl_Menu_Item pm[] = {
+ {"Validate URL with W3C", 0, Menu_bugmeter_validate_w3c_cb,0,0,0,0,0,0},
+ {"Validate URL with WDG", 0, Menu_bugmeter_validate_wdg_cb, 0,
+ FL_MENU_DIVIDER,0,0,0,0},
+ {"About bug meter", 0, Menu_bugmeter_about_cb,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0}
+ };
+ popup_x = Fl::event_x();
+ popup_y = Fl::event_y();
popup_bw = bw;
a_Url_free(popup_url);
popup_url = a_Url_dup(url);
- if (!pm) {
- Item *i;
- pm = new PopupMenu(0,0,0,0,"&BUG METER OPTIONS");
- pm->begin();
- i = new Item("Validate URL with W3C");
- i->callback(Menu_bugmeter_validate_w3c_cb);
- i = new Item("Validate URL with WDG");
- i->callback(Menu_bugmeter_validate_wdg_cb);
- new Divider();
- i = new Item("About Bug Meter...");
- i->callback(Menu_bugmeter_about_cb);
- pm->type(PopupMenu::POPUP123);
- pm->end();
- }
- pm->popup();
+ a_Timeout_add(0.0, Menu_popup_cb, (void*)pm);
}
/*
@@ -641,65 +530,80 @@ void a_Menu_bugmeter_popup(BrowserWindow *bw, const DilloUrl *url)
*/
void a_Menu_history_popup(BrowserWindow *bw, int direction)
{
- static PopupMenu *pm = 0;
- Item *it;
- int i;
+ static Fl_Menu_Item *pm = 0;
+ int i, n;
popup_bw = bw;
+ popup_x = Fl::event_x();
+ popup_y = Fl::event_y();
history_direction = direction;
// TODO: hook popdown event with delete or similar.
if (pm)
- delete(pm);
+ delete [] pm;
if (history_list)
dFree(history_list);
- if (direction == -1) {
- pm = new PopupMenu(0,0,0,0, "&PREVIOUS PAGES");
- } else {
- pm = new PopupMenu(0,0,0,0, "&FOLLOWING PAGES");
- }
-
// Get a list of URLs for this popup
history_list = a_UIcmd_get_history(bw, direction);
- pm->begin();
- for (i = 0; history_list[i] != -1; i += 1) {
- // TODO: restrict title size
- it = new CustItem(a_History_get_title(history_list[i], 1));
- it->callback(Menu_history_cb, INT2VOIDP(i+1));
- }
- pm->type(PopupMenu::POPUP123);
- pm->end();
+ for (n = 0; history_list[n] != -1; n++)
+ ;
+
+ pm = new Fl_Menu_Item[n + 1];
+ memset(pm, '\0', sizeof(Fl_Menu_Item[n + 1]));
- pm->popup();
+ for (i = 0; i < n; i++) {
+ pm[i].label(FL_NORMAL_LABEL, a_History_get_title(history_list[i], 1));
+ pm[i].callback(Menu_history_cb, INT2VOIDP(i+1));
+ }
+ a_Timeout_add(0.0, Menu_popup_cb, (void*)pm);
}
/*
* Toggle use of remote stylesheets
*/
-static void Menu_remote_css_cb(Widget *wid)
+static void Menu_remote_css_cb(Fl_Widget *wid, void*)
{
- _MSG("Menu_remote_css_cb\n");
- prefs.load_stylesheets = wid->state() ? 1 : 0;
+ Fl_Menu_Item *item = (Fl_Menu_Item*) wid;
+
+ item->flags ^= FL_MENU_VALUE;
+ prefs.load_stylesheets = item->flags & FL_MENU_VALUE ? 1 : 0;
a_UIcmd_repush(popup_bw);
}
/*
* Toggle use of embedded CSS style
*/
-static void Menu_embedded_css_cb(Widget *wid)
+static void Menu_embedded_css_cb(Fl_Widget *wid, void*)
{
- prefs.parse_embedded_css = wid->state() ? 1 : 0;
+ Fl_Menu_Item *item = (Fl_Menu_Item*) wid;
+
+ item->flags ^= FL_MENU_VALUE;
+ prefs.parse_embedded_css = item->flags & FL_MENU_VALUE ? 1 : 0;
a_UIcmd_repush(popup_bw);
}
+static void Menu_panel_change_cb(Fl_Widget*, void *user_data)
+{
+ UI *ui = (UI*)popup_bw->ui;
+
+ if (VOIDP2INT(user_data) == 10) /* small icons */
+ ui->change_panel(ui->get_panelsize(), !ui->get_smallicons());
+ else
+ ui->change_panel(VOIDP2INT(user_data), ui->get_smallicons());
+}
+
/*
* Toggle loading of images -- and load them if enabling.
*/
-static void Menu_imgload_toggle_cb(Widget *wid)
+static void Menu_imgload_toggle_cb(Fl_Widget *wid, void*)
{
- if ((prefs.load_images = wid->state() ? 1 : 0)) {
+ Fl_Menu_Item *item = (Fl_Menu_Item*) wid;
+
+ item->flags ^= FL_MENU_VALUE;
+
+ if ((prefs.load_images = item->flags & FL_MENU_VALUE ? 1 : 0)) {
void *doc = a_Bw_get_current_doc(popup_bw);
if (doc) {
@@ -714,31 +618,44 @@ static void Menu_imgload_toggle_cb(Widget *wid)
*/
void a_Menu_tools_popup(BrowserWindow *bw, void *v_wid)
{
- // One menu shared by every browser window
- static PopupMenu *pm = NULL;
- Widget *wid = (Widget*)v_wid;
- Item *it;
+ const Fl_Menu_Item *item;
+ Fl_Widget *wid = (Fl_Widget*)v_wid;
+ UI *ui = (UI*)bw->ui;
+
+ static Fl_Menu_Item pm[] = {
+ {"Use remote CSS", 0, Menu_remote_css_cb, 0, FL_MENU_TOGGLE,0,0,0,0},
+ {"Use embedded CSS", 0, Menu_embedded_css_cb, 0,
+ FL_MENU_TOGGLE|FL_MENU_DIVIDER,0,0,0,0},
+ {"Load images", 0, Menu_imgload_toggle_cb, 0,
+ FL_MENU_TOGGLE|FL_MENU_DIVIDER,0,0,0,0},
+ {"Panel size", 0, Menu_nop_cb, (void*)"Submenu1", FL_SUBMENU,0,0,0,0},
+ {"tiny", 0,Menu_panel_change_cb,(void*)0,FL_MENU_RADIO,0,0,0,0},
+ {"small", 0,Menu_panel_change_cb,(void*)1,FL_MENU_RADIO,0,0,0,0},
+ {"medium",0,Menu_panel_change_cb,(void*)2,FL_MENU_RADIO,0,0,0,0},
+ {"large", 0,Menu_panel_change_cb,(void*)3,
+ FL_MENU_RADIO|FL_MENU_DIVIDER,0,0,0,0},
+ {"small icons", 0,Menu_panel_change_cb,(void*)10,
+ FL_MENU_TOGGLE,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0},
+ {0,0,0,0,0,0,0,0,0}
+ };
popup_bw = bw;
-
- if (!pm) {
- pm = new PopupMenu(0,0,0,0, "TOOLS");
- pm->begin();
- it = new ToggleItem("Use remote CSS");
- it->callback(Menu_remote_css_cb);
- it->state(prefs.load_stylesheets);
- it = new ToggleItem("Use embedded CSS");
- it->callback(Menu_embedded_css_cb);
- it->state(prefs.parse_embedded_css);
- new Divider();
- it = new ToggleItem("Load images");
- it->callback(Menu_imgload_toggle_cb);
- it->state(prefs.load_images);
- pm->type(PopupMenu::POPUP13);
- pm->end();
+ int cur_panelsize = ui->get_panelsize();
+ int cur_smallicons = ui->get_smallicons();
+
+ if (prefs.load_stylesheets)
+ pm[0].set();
+ if (prefs.parse_embedded_css)
+ pm[1].set();
+ if (prefs.load_images)
+ pm[2].set();
+ pm[4+cur_panelsize].setonly();
+ cur_smallicons ? pm[8].set() : pm[8].clear();
+
+ item = pm->popup(wid->x(), wid->y() + wid->h());
+ if (item) {
+ ((Fl_Widget *)item)->do_callback();
}
- //pm->popup();
- pm->value(-1);
- ((Menu*)pm)->popup(Rectangle(0,wid->h(),pm->w(),pm->h()));
}
diff --git a/src/misc.c b/src/misc.c
index 213b0ada..ef64e875 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -383,6 +383,38 @@ int a_Misc_parse_geometry(char *str, int *x, int *y, int *w, int *h)
}
/*
+ * Parse dillorc's search_url string ("[<label> ]<url>")
+ * Return value: -1 on error, 0 on success (and label and urlstr pointers)
+ */
+int a_Misc_parse_search_url(char *source, char **label, char **urlstr)
+{
+ static char buf[32];
+ char *p, *q;
+ int ret = -1;
+
+ if ((p = strrchr(source, ' '))) {
+ /* label and url pair */
+ strncpy(buf,source,MIN(p-source,31));
+ buf[MIN(p-source,31)] = 0;
+ source = p+1;
+ if ((p = strchr(source, '/')) && p[1] && (q = strchr(p+2,'/'))) {
+ *urlstr = source;
+ ret = 0;
+ }
+ } else {
+ /* url only, make a custom label */
+ if ((p = strchr(source, '/')) && p[1] && (q = strchr(p+2,'/'))) {
+ strncpy(buf,p+2,MIN(q-p-2,31));
+ buf[MIN(q-p-2,31)] = 0;
+ *urlstr = source;
+ ret = 0;
+ }
+ }
+ *label = buf;
+ return ret;
+}
+
+/*
* Encodes string using base64 encoding.
* Return value: new string or NULL if input string is empty.
*/
diff --git a/src/misc.h b/src/misc.h
index 0b4eaaa5..75f0f78a 100644
--- a/src/misc.h
+++ b/src/misc.h
@@ -17,6 +17,7 @@ void a_Misc_parse_content_type(const char *str, char **major, char **minor,
char **charset);
int a_Misc_content_type_cmp(const char* ct1, const char *ct2);
int a_Misc_parse_geometry(char *geom, int *x, int *y, int *w, int *h);
+int a_Misc_parse_search_url(char *source, char **label, char **urlstr);
char *a_Misc_encode_base64(const char *in);
Dstr *a_Misc_file2dstr(const char *filename);
diff --git a/src/nav.c b/src/nav.c
index c7c46157..31f9e92d 100644
--- a/src/nav.c
+++ b/src/nav.c
@@ -252,6 +252,7 @@ void a_Nav_cancel_expect(BrowserWindow *bw)
a_Url_free(bw->nav_expect_url);
bw->nav_expect_url = NULL;
bw->nav_expecting = FALSE;
+ a_UIcmd_set_buttons_sens(bw);
}
if (bw->meta_refresh_status > 0)
--bw->meta_refresh_status;
@@ -487,9 +488,9 @@ static void Nav_reload_callback(void *data)
confirmed = 0;
} else if (URL_FLAGS(h_url) & URL_Post) {
/* Attempt to repost data, let's confirm... */
- choice = a_Dialog_choice3("Repost form data?",
- "Yes", "*No", "Cancel");
- confirmed = (choice == 0); /* "Yes" */
+ choice = a_Dialog_choice5("Repost form data?",
+ "No", "Yes", "Cancel", NULL, NULL);
+ confirmed = (choice == 2); /* "Yes" */
}
if (confirmed) {
diff --git a/src/prefs.c b/src/prefs.c
index f968710a..cbd1f5d8 100644
--- a/src/prefs.c
+++ b/src/prefs.c
@@ -70,11 +70,15 @@ void a_Prefs_init(void)
prefs.load_stylesheets=TRUE;
prefs.middle_click_drags_page = TRUE;
prefs.middle_click_opens_new_tab = TRUE;
+ prefs.right_click_closes_tab = FALSE;
prefs.no_proxy = dStrdup(PREFS_NO_PROXY);
prefs.panel_size = P_medium;
prefs.parse_embedded_css=TRUE;
prefs.save_dir = dStrdup(PREFS_SAVE_DIR);
- prefs.search_url = dStrdup(PREFS_SEARCH_URL);
+ prefs.search_urls = dList_new(16);
+ dList_append(prefs.search_urls, dStrdup(PREFS_SEARCH_URL));
+ dList_append(prefs.search_urls, NULL); /* flags a default search URL */
+ prefs.search_url_idx = 0;
prefs.show_back = TRUE;
prefs.show_bookmarks = TRUE;
prefs.show_clear_url = TRUE;
@@ -103,6 +107,8 @@ void a_Prefs_init(void)
*/
void a_Prefs_freeall(void)
{
+ int i;
+
dFree(prefs.font_cursive);
dFree(prefs.font_fantasy);
dFree(prefs.font_monospace);
@@ -116,6 +122,8 @@ void a_Prefs_freeall(void)
dFree(prefs.http_user_agent);
dFree(prefs.no_proxy);
dFree(prefs.save_dir);
- dFree(prefs.search_url);
+ for (i = 0; i < dList_length(prefs.search_urls); ++i)
+ dFree(dList_nth_data(prefs.search_urls, i));
+ dList_free(prefs.search_urls);
a_Url_free(prefs.start_page);
}
diff --git a/src/prefs.h b/src/prefs.h
index 4009925c..19e3890a 100644
--- a/src/prefs.h
+++ b/src/prefs.h
@@ -84,7 +84,9 @@ struct _DilloPrefs {
char *font_monospace;
bool_t enterpress_forces_submit;
bool_t middle_click_opens_new_tab;
- char *search_url;
+ bool_t right_click_closes_tab;
+ bool_t search_url_idx;
+ Dlist *search_urls;
char *save_dir;
bool_t show_msg;
bool_t show_extra_warnings;
diff --git a/src/prefsparser.cc b/src/prefsparser.cc
index 95f98c16..bf973225 100644
--- a/src/prefsparser.cc
+++ b/src/prefsparser.cc
@@ -24,6 +24,7 @@ typedef enum {
PREFS_BOOL,
PREFS_COLOR,
PREFS_STRING,
+ PREFS_STRINGS,
PREFS_URL,
PREFS_INT32,
PREFS_DOUBLE,
@@ -81,11 +82,12 @@ int PrefsParser::parseOption(char *name, char *value)
PREFS_BOOL },
{ "middle_click_opens_new_tab", &prefs.middle_click_opens_new_tab,
PREFS_BOOL },
+ { "right_click_closes_tab", &prefs.right_click_closes_tab, PREFS_BOOL },
{ "no_proxy", &prefs.no_proxy, PREFS_STRING },
{ "panel_size", &prefs.panel_size, PREFS_PANEL_SIZE },
{ "parse_embedded_css", &prefs.parse_embedded_css, PREFS_BOOL },
{ "save_dir", &prefs.save_dir, PREFS_STRING },
- { "search_url", &prefs.search_url, PREFS_STRING },
+ { "search_url", &prefs.search_urls, PREFS_STRINGS },
{ "show_back", &prefs.show_back, PREFS_BOOL },
{ "show_bookmarks", &prefs.show_bookmarks, PREFS_BOOL },
{ "show_clear_url", &prefs.show_clear_url, PREFS_BOOL },
@@ -133,6 +135,19 @@ int PrefsParser::parseOption(char *name, char *value)
dFree(*(char **)node->pref);
*(char **)node->pref = dStrdup(value);
break;
+ case PREFS_STRINGS:
+ {
+ Dlist *lp = *(Dlist **)node->pref;
+ if (dList_length(lp) == 2 && !dList_nth_data(lp, 1)) {
+ /* override the default */
+ void *data = dList_nth_data(lp, 0);
+ dList_remove(lp, data);
+ dList_remove(lp, NULL);
+ dFree(data);
+ }
+ dList_append(lp, dStrdup(value));
+ break;
+ }
case PREFS_URL:
a_Url_free(*(DilloUrl **)node->pref);
*(DilloUrl **)node->pref = a_Url_new(value, NULL);
@@ -170,13 +185,6 @@ int PrefsParser::parseOption(char *name, char *value)
MSG_WARN("prefs: {%s} IS recognized but not handled!\n", name);
break; /* Not reached */
}
-
- if (prefs.limit_text_width) {
- /* BUG: causes 100% CPU usage with <button> or <input type="image"> */
- MSG_WARN("Disabling limit_text_width preference (currently broken).\n");
- prefs.limit_text_width = FALSE;
- }
-
return 0;
}
@@ -212,4 +220,11 @@ void PrefsParser::parse(FILE *fp)
// restore the old numeric locale
setlocale(LC_NUMERIC, oldLocale);
dFree(oldLocale);
+
+
+ if (prefs.limit_text_width) {
+ /* BUG: causes 100% CPU usage with <button> or <input type="image"> */
+ MSG_WARN("Disabling limit_text_width preference (currently broken).\n");
+ prefs.limit_text_width = FALSE;
+ }
}
diff --git a/src/timeout.cc b/src/timeout.cc
index 80eb6425..1ddcd5e1 100644
--- a/src/timeout.cc
+++ b/src/timeout.cc
@@ -11,12 +11,9 @@
// Simple ADT for timeout functions
-#include <fltk/run.h>
+#include <FL/Fl.H>
#include "timeout.hh"
-using namespace fltk;
-
-
// C++ functions with C linkage ----------------------------------------------
/*
@@ -25,7 +22,7 @@ using namespace fltk;
*/
void a_Timeout_add(float t, TimeoutCb_t cb, void *cbdata)
{
- add_timeout(t, cb, cbdata);
+ Fl::add_timeout(t, cb, cbdata);
}
/*
@@ -33,7 +30,7 @@ void a_Timeout_add(float t, TimeoutCb_t cb, void *cbdata)
*/
void a_Timeout_repeat(float t, TimeoutCb_t cb, void *cbdata)
{
- add_timeout(t, cb, cbdata);
+ Fl::add_timeout(t, cb, cbdata);
}
/*
diff --git a/src/ui.cc b/src/ui.cc
index fac78604..434dca16 100644
--- a/src/ui.cc
+++ b/src/ui.cc
@@ -14,73 +14,64 @@
#include <unistd.h>
#include <stdio.h>
-#include <fltk/HighlightButton.h>
-#include <fltk/run.h>
-#include <fltk/damage.h>
-#include <fltk/xpmImage.h>
-#include <fltk/events.h> // for mouse buttons and keys
-#include <fltk/Font.h> // UI label font for tabs
-#include <fltk/InvisibleBox.h>
-#include <fltk/PopupMenu.h>
-#include <fltk/Item.h>
-#include <fltk/Divider.h>
-
#include "keys.hh"
#include "ui.hh"
#include "msg.h"
#include "timeout.hh"
#include "utf8.hh"
-using namespace fltk;
-
+#include <FL/Fl.H>
+#include <FL/Fl_Pixmap.H>
+#include <FL/Fl_Box.H>
+#include <FL/names.h>
// Include image data
#include "pixmaps.h"
#include "uicmd.hh"
struct iconset {
- Image *ImgMeterOK, *ImgMeterBug,
- *ImgHome, *ImgReload, *ImgSave, *ImgBook, *ImgTools,
- *ImgClear,*ImgSearch, *ImgHelp;
- MultiImage *ImgLeftMulti, *ImgRightMulti, *ImgStopMulti;
+ Fl_Image *ImgMeterOK, *ImgMeterBug,
+ *ImgHome, *ImgReload, *ImgSave, *ImgBook, *ImgTools,
+ *ImgClear,*ImgSearch, *ImgHelp, *ImgLeft, *ImgLeftIn,
+ *ImgRight, *ImgRightIn, *ImgStop, *ImgStopIn;
};
static struct iconset standard_icons = {
- new xpmImage(mini_ok_xpm),
- new xpmImage(mini_bug_xpm),
- new xpmImage(home_xpm),
- new xpmImage(reload_xpm),
- new xpmImage(save_xpm),
- new xpmImage(bm_xpm),
- new xpmImage(tools_xpm),
- new xpmImage(new_s_xpm),
- new xpmImage(search_xpm),
- new xpmImage(help_xpm),
- new MultiImage(*new xpmImage(left_xpm), INACTIVE_R,
- *new xpmImage(left_i_xpm)),
- new MultiImage(*new xpmImage(right_xpm), INACTIVE_R,
- *new xpmImage(right_i_xpm)),
- new MultiImage(*new xpmImage(stop_xpm), INACTIVE_R,
- *new xpmImage(stop_i_xpm)),
+ new Fl_Pixmap(mini_ok_xpm),
+ new Fl_Pixmap(mini_bug_xpm),
+ new Fl_Pixmap(home_xpm),
+ new Fl_Pixmap(reload_xpm),
+ new Fl_Pixmap(save_xpm),
+ new Fl_Pixmap(bm_xpm),
+ new Fl_Pixmap(tools_xpm),
+ new Fl_Pixmap(new_s_xpm),
+ new Fl_Pixmap(search_xpm),
+ new Fl_Pixmap(help_xpm),
+ new Fl_Pixmap(left_xpm),
+ new Fl_Pixmap(left_i_xpm),
+ new Fl_Pixmap(right_xpm),
+ new Fl_Pixmap(right_i_xpm),
+ new Fl_Pixmap(stop_xpm),
+ new Fl_Pixmap(stop_i_xpm),
};
static struct iconset small_icons = {
standard_icons.ImgMeterOK,
standard_icons.ImgMeterBug,
- new xpmImage(home_s_xpm),
- new xpmImage(reload_s_xpm),
- new xpmImage(save_s_xpm),
- new xpmImage(bm_s_xpm),
- new xpmImage(tools_s_xpm),
- new xpmImage(new_s_xpm),
+ new Fl_Pixmap(home_s_xpm),
+ new Fl_Pixmap(reload_s_xpm),
+ new Fl_Pixmap(save_s_xpm),
+ new Fl_Pixmap(bm_s_xpm),
+ new Fl_Pixmap(tools_s_xpm),
+ new Fl_Pixmap(new_s_xpm),
standard_icons.ImgSearch,
standard_icons.ImgHelp,
- new MultiImage(*new xpmImage(left_s_xpm), INACTIVE_R,
- *new xpmImage(left_si_xpm)),
- new MultiImage(*new xpmImage(right_s_xpm), INACTIVE_R,
- *new xpmImage(right_si_xpm)),
- new MultiImage(*new xpmImage(stop_s_xpm), INACTIVE_R,
- *new xpmImage(stop_si_xpm)),
+ new Fl_Pixmap(left_s_xpm),
+ new Fl_Pixmap(left_si_xpm),
+ new Fl_Pixmap(right_s_xpm),
+ new Fl_Pixmap(right_si_xpm),
+ new Fl_Pixmap(stop_s_xpm),
+ new Fl_Pixmap(stop_si_xpm),
};
@@ -95,49 +86,96 @@ static struct iconset *icons = &standard_icons;
/*
* (Used to avoid certain shortcuts in the location bar)
*/
-class CustInput : public Input {
+class CustInput : public Fl_Input {
public:
CustInput (int x, int y, int w, int h, const char* l=0) :
- Input(x,y,w,h,l) {};
+ Fl_Input(x,y,w,h,l) {};
int handle(int e);
};
/*
- * Disable: UpKey, DownKey, PageUpKey, PageDownKey and
- * CTRL+{o,r,HomeKey,EndKey}
+ * Disable keys: Up, Down, Page_Up, Page_Down, Tab and
+ * CTRL+{o,r,Home,End} SHIFT+{Left,Right}.
*/
int CustInput::handle(int e)
{
- int k = event_key();
+ int k = Fl::event_key();
_MSG("CustInput::handle event=%d\n", e);
// We're only interested in some flags
- unsigned modifier = event_state() & (SHIFT | CTRL | ALT);
+ unsigned modifier = Fl::event_state() & (FL_SHIFT | FL_CTRL | FL_ALT);
// Don't focus with arrow keys
- if (e == FOCUS &&
- (k == UpKey || k == DownKey || k == LeftKey || k == RightKey)) {
+ if (e == FL_FOCUS &&
+ (k == FL_Up || k == FL_Down || k == FL_Left || k == FL_Right)) {
return 0;
- } else if (e == KEY) {
- if (modifier == CTRL) {
- if (k == 'l') {
+ } else if (e == FL_KEYBOARD) {
+ if (k == FL_Escape && modifier == 0) {
+ // Let the parent group handle this Esc key
+ return 0;
+ } else if (modifier == FL_SHIFT) {
+ if (k == FL_Left || k == FL_Right) {
+ // Let these keys get to the UI
+ return 0;
+ }
+ } else if (modifier == FL_CTRL) {
+ if (k == 'a' || k == 'e') {
+ position(k == 'a' ? 0 : size());
+ return 1;
+ } else if (k == 'k') {
+ cut(position(), size());
+ return 1;
+ } else if (k == 'd') {
+ cut(position(), position()+1);
+ return 1;
+ } else if (k == 'l') {
// Make text selected when already focused.
position(size(), 0);
return 1;
- } else if (k == 'o' || k == 'r' || k == HomeKey || k == EndKey)
+ } else if (k == 'h' || k == 'o' || k == 'r' ||
+ k == FL_Home || k == FL_End) {
+ // Let these keys get to the UI
+ return 0;
+ }
+ } else if (modifier == 0) {
+ if (k == FL_Down || k == FL_Up ||
+ k == FL_Page_Down || k == FL_Page_Up || k == FL_Tab) {
+ // Give up focus and honor the key
+ a_UIcmd_focus_main_area(a_UIcmd_get_bw_by_widget(this));
return 0;
- } else if (modifier == SHIFT) {
- if (k == LeftKey || k == RightKey) {
- _MSG(" CustInput::handle > SHIFT+RightKey\n");
- a_UIcmd_send_event_to_tabs_by_wid(e, this);
- return 1;
}
}
}
- _MSG("\n");
- return Input::handle(e);
+ return Fl_Input::handle(e);
+}
+
+//----------------------------------------------------------------------------
+
+/*
+ * A button that highlights on mouse over
+ */
+class CustLightButton : public Fl_Button {
+ Fl_Color norm_color;
+public:
+ CustLightButton(int x, int y, int w, int h, const char *l=0) :
+ Fl_Button(x,y,w,h,l) { norm_color = color(); };
+ virtual int handle(int e);
+};
+
+int CustLightButton::handle(int e)
+{
+ if (active()) {
+ if (e == FL_ENTER) {
+ color(51); // {17,26,51}
+ redraw();
+ } else if (e == FL_LEAVE || e == FL_RELEASE) {
+ color(norm_color);
+ redraw();
+ }
+ }
+ return Fl_Button::handle(e);
}
//----------------------------------------------------------------------------
@@ -145,24 +183,24 @@ int CustInput::handle(int e)
/*
* Used to handle "paste" within the toolbar's Clear button.
*/
-class CustHighlightButton : public HighlightButton {
+class CustPasteButton : public CustLightButton {
public:
- CustHighlightButton(int x, int y, int w, int h, const char *l=0) :
- HighlightButton(x,y,w,h,l) {};
+ CustPasteButton(int x, int y, int w, int h, const char *l=0) :
+ CustLightButton(x,y,w,h,l) {};
int handle(int e);
};
-int CustHighlightButton::handle(int e)
+int CustPasteButton::handle(int e)
{
- if (e == PASTE) {
- const char* t = event_text();
+ if (e == FL_PASTE) {
+ const char* t = Fl::event_text();
if (t && *t) {
a_UIcmd_set_location_text(a_UIcmd_get_bw_by_widget(this), t);
a_UIcmd_open_urlstr(a_UIcmd_get_bw_by_widget(this), t);
return 1;
}
}
- return HighlightButton::handle(e);
+ return CustLightButton::handle(e);
}
//----------------------------------------------------------------------------
@@ -170,22 +208,21 @@ int CustHighlightButton::handle(int e)
/*
* Used to resize the progress boxes automatically.
*/
-class CustProgressBox : public InvisibleBox {
+class CustProgressBox : public Fl_Box {
int padding;
public:
CustProgressBox(int x, int y, int w, int h, const char *l=0) :
- InvisibleBox(x,y,w,h,l) { padding = 0; };
+ Fl_Box(x,y,w,h,l) { padding = 0; };
void update_label(const char *lbl) {
- int w,h;
+ int w = 0, h = 0;
if (!padding) {
copy_label("W");
measure_label(w, h);
padding = w > 2 ? w/2 : 1;
}
copy_label(lbl);
- measure_label(w,h);
- resize(w+padding,h);
- redraw_label();
+ //measure_label(w,h);
+ //size(w+padding,this->h());
}
};
@@ -205,23 +242,23 @@ public:
/*
* Callback for the search button.
*/
-static void search_cb(Widget *wid, void *data)
+static void search_cb(Fl_Widget *wid, void *data)
{
- int k = event_key();
+ int b = Fl::event_button();
- if (k == 1) {
+ if (b == FL_LEFT_MOUSE) {
a_UIcmd_search_dialog(a_UIcmd_get_bw_by_widget(wid));
- } else if (k == 2) {
+ } else if (b == FL_MIDDLE_MOUSE) {
((UI*)data)->color_change_cb_i();
- } else if (k == 3) {
- ((UI*)data)->panel_cb_i();
+ } else if (b == FL_RIGHT_MOUSE) {
+ // nothing ATM
}
}
/*
* Callback for the help button.
*/
-static void help_cb(Widget *w, void *)
+static void help_cb(Fl_Widget *w, void *)
{
char *path = dStrconcat(DILLO_DOCDIR, "user_help.html", NULL);
BrowserWindow *bw = a_UIcmd_get_bw_by_widget(w);
@@ -233,7 +270,7 @@ static void help_cb(Widget *w, void *)
} else {
MSG("Can't read local help file at \"%s\"."
" Getting remote help...\n", path);
- a_UIcmd_open_urlstr(bw, "http://www.dillo.org/dillo2-help.html");
+ a_UIcmd_open_urlstr(bw, "http://www.dillo.org/dillo3-help.html");
}
dFree(path);
}
@@ -241,10 +278,10 @@ static void help_cb(Widget *w, void *)
/*
* Callback for the File menu button.
*/
-static void filemenu_cb(Widget *wid, void *)
+static void filemenu_cb(Fl_Widget *wid, void *)
{
- int k = event_key();
- if (k == 1 || k == 3) {
+ int b = Fl::event_button();
+ if (b == FL_LEFT_MOUSE || b == FL_RIGHT_MOUSE) {
a_UIcmd_file_popup(a_UIcmd_get_bw_by_widget(wid), wid);
}
}
@@ -252,15 +289,15 @@ static void filemenu_cb(Widget *wid, void *)
/*
* Callback for the location's clear-button.
*/
-static void clear_cb(Widget *w, void *data)
+static void clear_cb(Fl_Widget *w, void *data)
{
UI *ui = (UI*)data;
- int k = event_key();
- if (k == 1) {
+ int b = Fl::event_button();
+ if (b == FL_LEFT_MOUSE) {
ui->set_location("");
ui->focus_location();
- } if (k == 2) {
+ } if (b == FL_MIDDLE_MOUSE) {
ui->paste_url();
}
}
@@ -268,7 +305,7 @@ static void clear_cb(Widget *w, void *data)
/*
* Change the color of the location bar.
*
-static void color_change_cb(Widget *wid, void *data)
+static void color_change_cb(Fl_Widget *wid, void *data)
{
((UI*)data)->color_change_cb_i();
}
@@ -278,19 +315,14 @@ static void color_change_cb(Widget *wid, void *data)
/*
* Send the browser to the new URL in the location.
*/
-static void location_cb(Widget *wid, void *data)
+static void location_cb(Fl_Widget *wid, void *data)
{
- Input *i = (Input*)wid;
+ Fl_Input *i = (Fl_Input*)wid;
UI *ui = (UI*)data;
_MSG("location_cb()\n");
- /* This test is necessary because WHEN_ENTER_KEY also includes
- * other events we're not interested in. For instance pressing
- * The Back or Forward, buttons, or the first click on a rendered
- * page. BUG: this must be investigated and reported to FLTK2 team */
- if (event_key() == ReturnKey) {
- a_UIcmd_open_urlstr(a_UIcmd_get_bw_by_widget(i), i->value());
- }
+ a_UIcmd_open_urlstr(a_UIcmd_get_bw_by_widget(i), i->value());
+
if (ui->get_panelmode() == UI_TEMPORARILY_SHOW_PANELS) {
ui->set_panelmode(UI_HIDDEN);
}
@@ -300,56 +332,56 @@ static void location_cb(Widget *wid, void *data)
/*
* Callback handler for button press on the panel
*/
-static void b1_cb(Widget *wid, void *cb_data)
+static void b1_cb(Fl_Widget *wid, void *cb_data)
{
int bn = VOIDP2INT(cb_data);
- int k = event_key();
- if (k && k <= 7) {
- _MSG("[%s], mouse button %d was pressed\n", button_names[bn], k);
- _MSG("mouse button %d was pressed\n", k);
+ int b = Fl::event_button();
+ if (b >= FL_LEFT_MOUSE && b <= FL_RIGHT_MOUSE) {
+ _MSG("[%s], mouse button %d was pressed\n", button_names[bn], b);
+ _MSG("mouse button %d was pressed\n", b);
}
switch (bn) {
case UI_BACK:
- if (k == 1) {
+ if (b == FL_LEFT_MOUSE) {
a_UIcmd_back(a_UIcmd_get_bw_by_widget(wid));
- } else if (k == 3) {
+ } else if (b == FL_RIGHT_MOUSE) {
a_UIcmd_back_popup(a_UIcmd_get_bw_by_widget(wid));
}
break;
case UI_FORW:
- if (k == 1) {
+ if (b == FL_LEFT_MOUSE) {
a_UIcmd_forw(a_UIcmd_get_bw_by_widget(wid));
- } else if (k == 3) {
+ } else if (b == FL_RIGHT_MOUSE) {
a_UIcmd_forw_popup(a_UIcmd_get_bw_by_widget(wid));
}
break;
case UI_HOME:
- if (k == 1) {
+ if (b == FL_LEFT_MOUSE) {
a_UIcmd_home(a_UIcmd_get_bw_by_widget(wid));
}
break;
case UI_RELOAD:
- if (k == 1) {
+ if (b == FL_LEFT_MOUSE) {
a_UIcmd_reload(a_UIcmd_get_bw_by_widget(wid));
}
break;
case UI_SAVE:
- if (k == 1) {
+ if (b == FL_LEFT_MOUSE) {
a_UIcmd_save(a_UIcmd_get_bw_by_widget(wid));
}
break;
case UI_STOP:
- if (k == 1) {
+ if (b == FL_LEFT_MOUSE) {
a_UIcmd_stop(a_UIcmd_get_bw_by_widget(wid));
}
break;
case UI_BOOK:
- if (k == 1) {
+ if (b == FL_LEFT_MOUSE) {
a_UIcmd_book(a_UIcmd_get_bw_by_widget(wid));
}
break;
case UI_TOOLS:
- if (k == 1 || k == 3) {
+ if (b == FL_LEFT_MOUSE || b == FL_RIGHT_MOUSE) {
a_UIcmd_tools(a_UIcmd_get_bw_by_widget(wid), wid);
}
break;
@@ -359,24 +391,14 @@ static void b1_cb(Widget *wid, void *cb_data)
}
/*
- * Callback handler for fullscreen button press
- */
-//static void fullscreen_cb(Widget *wid, void *data)
-//{
-// /* TODO: do we want to toggle fullscreen or panelmode?
-// maybe we need to add another button?*/
-// ((UI*)data)->panelmode_cb_i();
-//}
-
-/*
* Callback for the bug meter button.
*/
-static void bugmeter_cb(Widget *wid, void *data)
+static void bugmeter_cb(Fl_Widget *wid, void *data)
{
- int k = event_key();
- if (k == 1) {
+ int b = Fl::event_button();
+ if (b == FL_LEFT_MOUSE) {
a_UIcmd_view_page_bugs(a_UIcmd_get_bw_by_widget(wid));
- } else if (k == 3) {
+ } else if (b == FL_RIGHT_MOUSE) {
a_UIcmd_bugmeter_popup(a_UIcmd_get_bw_by_widget(wid));
}
}
@@ -390,56 +412,41 @@ static void bugmeter_cb(Widget *wid, void *data)
//----------------------------
/*
+ * Make a generic navigation button
+ */
+Fl_Button *UI::make_button(const char *label, Fl_Image *img, Fl_Image *deimg,
+ int b_n, int start)
+{
+ if (start)
+ p_xpos = 0;
+
+ Fl_Button *b = new CustLightButton(p_xpos, 0, bw, bh, (lbl) ? label : NULL);
+ if (img)
+ b->image(img);
+ if (deimg)
+ b->deimage(deimg);
+ b->callback(b1_cb, INT2VOIDP(b_n));
+ b->clear_visible_focus();
+ b->labelsize(12);
+ b->box(FL_FLAT_BOX);
+ b->down_box(FL_THIN_DOWN_FRAME);
+ p_xpos += bw;
+ return b;
+}
+
+/*
* Create the archetipic browser buttons
*/
-PackedGroup *UI::make_toolbar(int tw, int th)
+void UI::make_toolbar(int tw, int th)
{
- HighlightButton *b;
- PackedGroup *p1=new PackedGroup(0,0,tw,th);
- p1->begin();
- Back = b = new HighlightButton(xpos, 0, bw, bh, (lbl) ? "Back" : 0);
- b->image(icons->ImgLeftMulti);
- b->callback(b1_cb, (void *)UI_BACK);
- b->clear_tab_to_focus();
- HighlightButton::default_style->highlight_color(CuteColor);
-
- Forw = b = new HighlightButton(xpos, 0, bw, bh, (lbl) ? "Forw" : 0);
- b->image(icons->ImgRightMulti);
- b->callback(b1_cb, (void *)UI_FORW);
- b->clear_tab_to_focus();
-
- Home = b = new HighlightButton(xpos, 0, bw, bh, (lbl) ? "Home" : 0);
- b->image(icons->ImgHome);
- b->callback(b1_cb, (void *)UI_HOME);
- b->clear_tab_to_focus();
-
- Reload = b = new HighlightButton(xpos, 0, bw, bh, (lbl) ? "Reload" : 0);
- b->image(icons->ImgReload);
- b->callback(b1_cb, (void *)UI_RELOAD);
- b->clear_tab_to_focus();
-
- Save = b = new HighlightButton(xpos, 0, bw, bh, (lbl) ? "Save" : 0);
- b->image(icons->ImgSave);
- b->callback(b1_cb, (void *)UI_SAVE);
- b->clear_tab_to_focus();
-
- Stop = b = new HighlightButton(xpos, 0, bw, bh, (lbl) ? "Stop" : 0);
- b->image(icons->ImgStopMulti);
- b->callback(b1_cb, (void *)UI_STOP);
- b->clear_tab_to_focus();
-
- Bookmarks = b = new HighlightButton(xpos, 0, bw, bh, (lbl) ? "Book" : 0);
- b->image(icons->ImgBook);
- b->callback(b1_cb, (void *)UI_BOOK);
- b->clear_tab_to_focus();
-
- Tools = b = new HighlightButton(xpos, 0, bw, bh, (lbl) ? "Tools" : 0);
- b->image(icons->ImgTools);
- b->callback(b1_cb, (void *)UI_TOOLS);
- b->clear_tab_to_focus();
-
- p1->type(PackedGroup::ALL_CHILDREN_VERTICAL);
- p1->end();
+ Back = make_button("Back", icons->ImgLeft, icons->ImgLeftIn, UI_BACK, 1);
+ Forw = make_button("Forw", icons->ImgRight, icons->ImgRightIn, UI_FORW);
+ Home = make_button("Home", icons->ImgHome, NULL, UI_HOME);
+ Reload = make_button("Reload", icons->ImgReload, NULL, UI_RELOAD);
+ Save = make_button("Save", icons->ImgSave, NULL, UI_SAVE);
+ Stop = make_button("Stop", icons->ImgStop, icons->ImgStopIn, UI_STOP);
+ Bookmarks = make_button("Book", icons->ImgBook, NULL, UI_BOOK);
+ Tools = make_button("Tools", icons->ImgTools, NULL, UI_TOOLS);
if (prefs.show_tooltip) {
Back->tooltip("Previous page");
@@ -451,41 +458,41 @@ PackedGroup *UI::make_toolbar(int tw, int th)
Bookmarks->tooltip("View bookmarks");
Tools->tooltip("Settings");
}
- return p1;
}
/*
* Create the location box (Clear/Input/Search)
*/
-PackedGroup *UI::make_location()
+void UI::make_location(int ww)
{
- Button *b;
- PackedGroup *pg = new PackedGroup(0,0,0,0);
- pg->begin();
- Clear = b = new CustHighlightButton(2,2,16,22,0);
+ Fl_Button *b;
+
+ Clear = b = new CustPasteButton(p_xpos,0,16,lh,0);
b->image(icons->ImgClear);
b->callback(clear_cb, this);
- b->clear_tab_to_focus();
+ b->clear_visible_focus();
+ b->box(FL_THIN_UP_BOX);
+ p_xpos += b->w();
- Input *i = Location = new CustInput(0,0,0,0,0);
+ Fl_Input *i = Location = new CustInput(p_xpos,0,ww-p_xpos-32,lh,0);
i->color(CuteColor);
- i->when(WHEN_ENTER_KEY);
+ i->when(FL_WHEN_ENTER_KEY);
i->callback(location_cb, this);
- i->set_click_to_focus();
+ p_xpos += i->w();
- Search = b = new HighlightButton(0,0,16,22,0);
+ Search = b = new CustLightButton(p_xpos,0,16,lh,0);
b->image(icons->ImgSearch);
b->callback(search_cb, this);
- b->clear_tab_to_focus();
+ b->clear_visible_focus();
+ b->box(FL_THIN_UP_BOX);
+ p_xpos += b->w();
- Help = b = new HighlightButton(0,0,16,22,0);
+ Help = b = new CustLightButton(p_xpos,0,16,lh,0);
b->image(icons->ImgHelp);
b->callback(help_cb, this);
- b->clear_tab_to_focus();
-
- pg->type(PackedGroup::ALL_CHILDREN_VERTICAL);
- pg->resizable(i);
- pg->end();
+ b->clear_visible_focus();
+ b->box(FL_THIN_UP_BOX);
+ p_xpos += b->w();
if (prefs.show_tooltip) {
Clear->tooltip("Clear the URL box.\nMiddle-click to paste a URL.");
@@ -493,56 +500,53 @@ PackedGroup *UI::make_location()
Search->tooltip("Search the Web");
Help->tooltip("Help");
}
- return pg;
}
/*
* Create the progress bars
*/
-PackedGroup *UI::make_progress_bars(int wide, int thin_up)
+void UI::make_progress_bars(int wide, int thin_up)
{
- ProgBox = new PackedGroup(0,0,0,0);
- ProgBox->begin();
// Images
- IProg = new CustProgressBox(0,0,0,0);
- IProg->box(thin_up ? THIN_UP_BOX : EMBOSSED_BOX);
- IProg->labelcolor(GRAY10);
+ IProg = new CustProgressBox(p_xpos,p_ypos,pw,bh);
+ IProg->labelsize(12);
+ IProg->box(thin_up ? FL_THIN_UP_BOX : FL_EMBOSSED_BOX);
+ IProg->labelcolor(FL_GRAY_RAMP + 2);
IProg->update_label(wide ? "Images\n0 of 0" : "0 of 0");
+ p_xpos += pw;
// Page
- PProg = new CustProgressBox(0,0,0,0);
- PProg->box(thin_up ? THIN_UP_BOX : EMBOSSED_BOX);
- PProg->labelcolor(GRAY10);
+ PProg = new CustProgressBox(p_xpos,p_ypos,pw,bh);
+ PProg->labelsize(12);
+ PProg->box(thin_up ? FL_THIN_UP_BOX : FL_EMBOSSED_BOX);
+ PProg->labelcolor(FL_GRAY_RAMP + 2);
PProg->update_label(wide ? "Page\n0.0KB" : "0.0KB");
- ProgBox->type(PackedGroup::ALL_CHILDREN_VERTICAL);
- ProgBox->end();
-
- return ProgBox;
}
/*
* Create the "File" menu
* Static function for File menu callbacks.
*/
-Widget *UI::make_filemenu_button()
+Fl_Widget *UI::make_filemenu_button()
{
- HighlightButton *btn;
- int w,h, padding;
+ Fl_Button *btn;
+ int w = 0, h = 0, padding;
- FileButton = btn = new HighlightButton(0,0,0,0,"W");
+ FileButton = btn = new Fl_Button(p_xpos,0,bw,bh,"W");
+ btn->labeltype(FL_FREE_LABELTYPE);
btn->measure_label(w, h);
padding = w;
btn->copy_label(PanelSize == P_tiny ? "&F" : "&File");
btn->measure_label(w,h);
- if (PanelSize == P_large)
- h = fh;
- btn->resize(w+padding,h);
+ h = (PanelSize == P_large) ? mh : (PanelSize == P_tiny) ? bh : lh;
+ btn->size(w+padding, h);
+ p_xpos += btn->w();
_MSG("UI::make_filemenu_button w=%d h=%d padding=%d\n", w, h, padding);
- btn->box(PanelSize == P_large ? FLAT_BOX : THIN_UP_BOX);
+ btn->box(PanelSize == P_large ? FL_THIN_UP_BOX : FL_THIN_UP_BOX);
btn->callback(filemenu_cb, this);
if (prefs.show_tooltip)
btn->tooltip("File menu");
- btn->clear_tab_to_focus();
- if (!prefs.show_filemenu && PanelSize != P_large)
+ btn->clear_visible_focus();
+ if (!prefs.show_filemenu)
btn->hide();
return btn;
}
@@ -551,161 +555,154 @@ Widget *UI::make_filemenu_button()
/*
* Create the control panel
*/
-Group *UI::make_panel(int ww)
+void UI::make_panel(int ww)
{
- Widget *w;
- Group *g1, *g2, *g3;
- PackedGroup *pg;
-
- if (PanelSize > P_large) {
- PanelSize = P_tiny;
- Small_Icons = !Small_Icons;
- }
+ Fl_Widget *w;
if (Small_Icons)
icons = &small_icons;
else
icons = &standard_icons;
+ pw = 70;
+ p_xpos = p_ypos = 0;
if (PanelSize == P_tiny) {
if (Small_Icons)
- xpos = 0, bw = 22, bh = 22, fh = 0, lh = 22, lbl = 0;
+ bw = 22, bh = 22, mh = 0, lh = 22, lbl = 0;
else
- xpos = 0, bw = 28, bh = 28, fh = 0, lh = 28, lbl = 0;
+ bw = 28, bh = 28, mh = 0, lh = 28, lbl = 0;
} else if (PanelSize == P_small) {
if (Small_Icons)
- xpos = 0, bw = 20, bh = 20, fh = 0, lh = 20, lbl = 0;
+ bw = 20, bh = 20, mh = 0, lh = 20, lbl = 0;
else
- xpos = 0, bw = 28, bh = 28, fh = 0, lh = 28, lbl = 0;
+ bw = 28, bh = 28, mh = 0, lh = 28, lbl = 0;
} else if (PanelSize == P_medium) {
if (Small_Icons)
- xpos = 0, bw = 42, bh = 36, fh = 0, lh = 22, lbl = 1;
+ bw = 42, bh = 36, mh = 0, lh = 22, lbl = 1;
else
- xpos = 0, bw = 45, bh = 45, fh = 0, lh = 28, lbl = 1;
+ bw = 45, bh = 45, mh = 0, lh = 28, lbl = 1;
} else { // P_large
if (Small_Icons)
- xpos = 0, bw = 42, bh = 36, fh = 22, lh = 22, lbl = 1;
+ bw = 42, bh = 36, mh = 22, lh = 22, lbl = 1;
else
- xpos = 0, bw = 45, bh = 45, fh = 24, lh = 28, lbl = 1;
+ bw = 45, bh = 45, mh = 24, lh = 28, lbl = 1;
}
+ nh = bh, fh = 28; sh = 20;
+ current(0);
if (PanelSize == P_tiny) {
- g1 = new Group(0,0,ww,bh);
- // Toolbar
- pg = make_toolbar(ww,bh);
- pg->box(EMBOSSED_BOX);
- g1->add(pg);
- w = make_filemenu_button();
- pg->add(w);
- w = make_location();
- pg->add(w);
- pg->resizable(w);
- w = make_progress_bars(0,1);
- pg->add(w);
-
- g1->resizable(pg);
-
+ NavBar = new CustGroupHorizontal(0,0,ww,nh);
+ NavBar->box(FL_NO_BOX);
+ NavBar->begin();
+ make_toolbar(ww,bh);
+ make_filemenu_button();
+ make_location(ww);
+ NavBar->resizable(Location);
+ make_progress_bars(0,1);
+ NavBar->box(FL_THIN_UP_FRAME);
+ NavBar->end();
+ NavBar->rearrange();
+ TopGroup->insert(*NavBar,0);
} else {
- g1 = new Group(0,0,ww,fh+lh+bh);
- g1->begin();
- // File menu
- if (PanelSize == P_large) {
- g3 = new Group(0,0,ww,lh);
- g3->box(FLAT_BOX);
- Widget *bn = make_filemenu_button();
- g3->add(bn);
- g3->add_resizable(*new InvisibleBox(bn->w(),0,ww - bn->w(),lh));
-
- g2 = new Group(0,fh,ww,lh);
- g2->begin();
- pg = make_location();
- pg->resize(ww,lh);
- } else {
- g2 = new PackedGroup(0,fh,ww,lh);
- g2->type(PackedGroup::ALL_CHILDREN_VERTICAL);
- g2->begin();
+ if (PanelSize == P_large) {
+ MenuBar = new CustGroupHorizontal(0,0,ww,mh);
+ MenuBar->begin();
+ MenuBar->box(FL_THIN_UP_BOX);
+ Fl_Widget *bn = make_filemenu_button();
+ MenuBar->add_resizable(*new Fl_Box(bn->w(),0,ww - bn->w(),mh));
+ MenuBar->end();
+ MenuBar->rearrange();
+ TopGroup->insert(*MenuBar,0);
+
+ p_xpos = 0;
+ LocBar = new CustGroupHorizontal(0,0,ww,lh);
+ LocBar->begin();
+ make_location(ww);
+ LocBar->resizable(Location);
+ LocBar->end();
+ LocBar->rearrange();
+ TopGroup->insert(*LocBar,1);
+ } else {
+ LocBar = new CustGroupHorizontal(0,0,ww,lh);
+ LocBar->box(FL_NO_BOX);
+ LocBar->begin();
+ p_xpos = 0;
make_filemenu_button();
- pg = make_location();
- }
-
- g2->resizable(pg);
- g2->end();
+ make_location(ww);
+ LocBar->resizable(Location);
+ LocBar->end();
+ LocBar->rearrange();
+ TopGroup->insert(*LocBar,0);
+ }
// Toolbar
- g3 = new Group(0,fh+lh,ww,bh);
- g3->begin();
- pg = make_toolbar(ww,bh);
- //w = new InvisibleBox(0,0,0,0,"i n v i s i b l e");
- w = new InvisibleBox(0,0,0,0,0);
- pg->add(w);
- pg->resizable(w);
-
+ p_ypos = 0;
+ NavBar = new CustGroupHorizontal(0,0,ww,bh);
+ NavBar->box(FL_NO_BOX);
+ NavBar->begin();
+ make_toolbar(ww,bh);
+ w = new Fl_Box(p_xpos,0,ww-p_xpos-2*pw,bh);
+ w->box(FL_FLAT_BOX);
+ NavBar->resizable(w);
+ p_xpos = ww - 2*pw;
if (PanelSize == P_small) {
- w = make_progress_bars(0,0);
+ make_progress_bars(0,0);
} else {
- w = make_progress_bars(1,0);
+ make_progress_bars(1,0);
}
- pg->add(w);
-
- g3->resizable(pg); // Better than 'w3' and it also works
- pg->box(BORDER_FRAME);
- //g3->box(EMBOSSED_BOX);
- g3->end();
-
- g1->resizable(g3);
- g1->end();
+ NavBar->end();
+ NavBar->rearrange();
+ TopGroup->insert(*NavBar,(MenuBar ? 2 : 1));
}
-
- return g1;
}
/*
* Create the status panel
*/
-Group *UI::make_status_panel(int ww)
+void UI::make_status_bar(int ww, int wh)
{
- const int s_h = 20, bm_w = 16;
- Group *g = new Group(0, 0, ww, s_h, 0);
-
- // Status box
- Status = new Output(0, 0, ww-bm_w, s_h, 0);
- Status->value("");
- Status->box(THIN_DOWN_BOX);
- Status->clear_click_to_focus();
- Status->clear_tab_to_focus();
- Status->color(GRAY80);
- g->add(Status);
- //Status->throw_focus();
-
- // Bug Meter
- BugMeter = new HighlightButton(ww-bm_w,0,bm_w,s_h,0);
- BugMeter->image(icons->ImgMeterOK);
- BugMeter->box(THIN_DOWN_BOX);
- BugMeter->align(ALIGN_INSIDE|ALIGN_CLIP|ALIGN_LEFT);
- if (prefs.show_tooltip)
- BugMeter->tooltip("Show HTML bugs\n(right-click for menu)");
- BugMeter->callback(bugmeter_cb, this);
- BugMeter->clear_tab_to_focus();
- g->add(BugMeter);
-
- g->resizable(Status);
- return g;
+ const int bm_w = 20;
+ StatusBar = new CustGroupHorizontal(0, wh-sh, ww, sh);
+ StatusBar->box(FL_NO_BOX);
+
+ // Status box
+ StatusOutput = new Fl_Output(0, wh-sh, ww-bm_w, sh);
+ StatusOutput->value("http://www.dillo.org");
+ StatusOutput->labelsize(8);
+ StatusOutput->box(FL_THIN_DOWN_BOX);
+ StatusOutput->clear_visible_focus();
+ StatusOutput->color(FL_GRAY_RAMP + 18);
+
+ // Bug Meter
+ BugMeter = new CustLightButton(ww-bm_w,wh-sh,bm_w,sh);
+ BugMeter->image(icons->ImgMeterOK);
+ BugMeter->box(FL_THIN_DOWN_BOX);
+ BugMeter->align(FL_ALIGN_INSIDE | FL_ALIGN_TEXT_NEXT_TO_IMAGE);
+ if (prefs.show_tooltip)
+ BugMeter->tooltip("Show HTML bugs\n(right-click for menu)");
+ BugMeter->callback(bugmeter_cb, this);
+ BugMeter->clear_visible_focus();
+
+ StatusBar->end();
+ StatusBar->resizable(StatusOutput);
+ StatusBar->rearrange();
}
/*
* User Interface constructor
*/
-UI::UI(int x, int y, int ww, int wh, const char* label, const UI *cur_ui) :
- Group(x, y, ww, wh, label)
+UI::UI(int x, int y, int ui_w, int ui_h, const char* label, const UI *cur_ui) :
+ CustGroupVertical(x, y, ui_w, ui_h, label)
{
PointerOnLink = FALSE;
+ MenuBar = LocBar = NavBar = StatusBar = NULL;
+
Tabs = NULL;
TabTooltip = NULL;
- TopGroup = new PackedGroup(0, 0, ww, wh);
- add(TopGroup);
- resizable(TopGroup);
- set_flag(RAW_LABEL);
+ TopGroup = this;
+ TopGroup->box(FL_NO_BOX);
+ clear_flag(SHORTCUT_LABEL);
if (cur_ui) {
PanelSize = cur_ui->PanelSize;
@@ -722,45 +719,48 @@ UI::UI(int x, int y, int ww, int wh, const char* label, const UI *cur_ui) :
PanelSize = prefs.panel_size;
Small_Icons = prefs.small_icons;
CuteColor = 206;
- Panelmode = (UIPanelmode) prefs.fullwindow_start;
+ Panelmode = (prefs.fullwindow_start) ? UI_HIDDEN : UI_NORMAL;
}
// Control panel
- Panel = make_panel(ww);
- TopGroup->add(Panel);
-
- // Render area
- Main = new Widget(0,0,1,1,"Welcome...");
- Main->box(FLAT_BOX);
- Main->color(GRAY15);
- Main->labelfont(HELVETICA_BOLD_ITALIC);
- Main->labelsize(36);
- Main->labeltype(SHADOW_LABEL);
- Main->labelcolor(WHITE);
- TopGroup->add(Main);
- TopGroup->resizable(Main);
- MainIdx = TopGroup->find(Main);
-
- // Find text bar
- findbar = new Findbar(ww, 28);
- TopGroup->add(findbar);
-
- // Status Panel
- StatusPanel = make_status_panel(ww);
- TopGroup->add(StatusPanel);
+ TopGroup->begin();
+ make_panel(ui_w);
+
+ // Render area
+ Main = new Fl_Group(0,0,0,0,"Welcome..."); // size is set by rearrange()
+ Main->align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE);
+ Main->box(FL_FLAT_BOX);
+ Main->color(FL_GRAY_RAMP + 3);
+ Main->labelfont(FL_HELVETICA_BOLD_ITALIC);
+ Main->labelsize(36);
+ Main->labeltype(FL_SHADOW_LABEL);
+ Main->labelcolor(FL_WHITE);
+ TopGroup->add(Main);
+ TopGroup->resizable(Main);
+ MainIdx = TopGroup->find(Main);
+
+ // Find text bar
+ FindBarSpace = 1;
+ FindBar = new Findbar(ui_w, fh);
+ TopGroup->add(FindBar);
+
+ // Status Panel
+ make_status_bar(ui_w, ui_h);
+ TopGroup->add(StatusBar);
+ TopGroup->end();
+ TopGroup->rearrange();
// Make the full screen button (to be attached to the viewport later)
// TODO: attach to the viewport
- //FullScreen = new HighlightButton(0,0,15,15);
+ //FullScreen = new Fl_Button(0,0,15,15);
//FullScreen->image(ImgFullScreenOn);
//FullScreen->tooltip("Hide Controls");
//FullScreen->callback(fullscreen_cb, this);
customize(0);
- if (Panelmode) {
- Panel->hide();
- StatusPanel->hide();
+ if (Panelmode == UI_HIDDEN) {
+ panels_toggle();
}
}
@@ -771,6 +771,9 @@ UI::~UI()
{
_MSG("UI::~UI()\n");
dFree(TabTooltip);
+
+ if (!FindBarSpace)
+ delete FindBar;
}
/*
@@ -778,14 +781,21 @@ UI::~UI()
*/
int UI::handle(int event)
{
- _MSG("UI::handle event=%d (%d,%d)\n", event, event_x(), event_y());
- _MSG("Panel->h()=%d Main->h()=%d\n", Panel->h() , Main->h());
+ _MSG("UI::handle event=%s\n", fl_eventnames[event]);
int ret = 0;
+ if (event == FL_KEYBOARD) {
+ /* WORKAROUND: remove the Panel's fltk-tooltip.
+ * Although the expose event is delivered, it has an offset. This
+ * extra call avoids the lingering tooltip. */
+ if (Fl::event_inside(NavBar) ||
+ (LocBar && Fl::event_inside(LocBar)) ||
+ (MenuBar && Fl::event_inside(MenuBar)) ||
+ (StatusBar && Fl::event_inside(StatusBar)))
+ window()->damage(FL_DAMAGE_EXPOSE,0,0,1,1);
- if (event == KEY) {
return 0; // Receive as shortcut
- } else if (event == SHORTCUT) {
+ } else if (event == FL_SHORTCUT) {
KeysCommand_t cmd = Keys::getKeyCmd();
if (cmd == KEYS_NOP) {
// Do nothing
@@ -805,7 +815,7 @@ int UI::handle(int event)
a_UIcmd_book(a_UIcmd_get_bw_by_widget(this));
ret = 1;
} else if (cmd == KEYS_FIND) {
- set_findbar_visibility(1);
+ findbar_toggle(1);
ret = 1;
} else if (cmd == KEYS_WEBSEARCH) {
a_UIcmd_search_dialog(a_UIcmd_get_bw_by_widget(this));
@@ -813,19 +823,12 @@ int UI::handle(int event)
} else if (cmd == KEYS_GOTO) {
focus_location();
ret = 1;
- } else if (cmd == KEYS_NEW_TAB) {
- a_UIcmd_open_url_nt(a_UIcmd_get_bw_by_widget(this), NULL, 1);
- ret = 1;
- } else if (cmd == KEYS_CLOSE_TAB) {
- a_UIcmd_close_bw(a_UIcmd_get_bw_by_widget(this));
- ret = 1;
- } else if (cmd == KEYS_HIDE_PANELS &&
- get_panelmode() == UI_TEMPORARILY_SHOW_PANELS) {
- set_panelmode(UI_HIDDEN);
- ret = 1;
- } else if (cmd == KEYS_NEW_WINDOW) {
- a_UIcmd_browser_window_new(w(),h(),0,a_UIcmd_get_bw_by_widget(this));
+ } else if (cmd == KEYS_HIDE_PANELS) {
+ /* Hide findbar if present, hide panels if not */
+ (FindBarSpace) ? findbar_toggle(0) : panels_toggle();
ret = 1;
+ //if (get_panelmode() == UI_TEMPORARILY_SHOW_PANELS)
+ // set_panelmode(UI_HIDDEN);
} else if (cmd == KEYS_OPEN) {
a_UIcmd_open_file(a_UIcmd_get_bw_by_widget(this));
ret = 1;
@@ -841,40 +844,26 @@ int UI::handle(int event)
} else if (cmd == KEYS_SAVE) {
a_UIcmd_save(a_UIcmd_get_bw_by_widget(this));
ret = 1;
- } else if (cmd == KEYS_FULLSCREEN) {
- panelmode_cb_i();
- ret = 1;
} else if (cmd == KEYS_FILE_MENU) {
a_UIcmd_file_popup(a_UIcmd_get_bw_by_widget(this), FileButton);
ret = 1;
- } else if (cmd == KEYS_CLOSE_ALL) {
- a_Timeout_add(0.0, a_UIcmd_close_all_bw, NULL);
- ret = 1;
}
- } else if (event == PUSH) {
- if (prefs.middle_click_drags_page == 0 &&
- event_button() == MiddleButton &&
- !a_UIcmd_pointer_on_link(a_UIcmd_get_bw_by_widget(this))) {
- if (Main->Rectangle::contains (event_x (), event_y ())) {
- /* Offer the event to Main's children (form widgets) */
- int save_x = e_x, save_y = e_y;
-
- e_x -= Main->x();
- e_y -= Main->y();
- ret = ((Group *)Main)->Group::handle(event);
- e_x = save_x;
- e_y = save_y;
- }
- if (!ret) {
- /* middle click was not on a link or a form widget */
- paste_url();
- ret = 1;
- }
+ } else if (event == FL_RELEASE) {
+ if (Fl::event_button() == FL_MIDDLE_MOUSE &&
+ prefs.middle_click_drags_page == 0) {
+ /* nobody claimed the event; try paste */
+ paste_url();
+ ret = 1;
}
}
if (!ret) {
- ret = Group::handle(event);
+ ret = Fl_Group::handle(event);
+ }
+ if (!ret && event == FL_PUSH && !prefs.middle_click_drags_page) {
+ /* nobody claimed FL_PUSH: ask for FL_RELEASE,
+ * which is necessary for middle-click paste URL) */
+ ret = 1;
}
return ret;
@@ -899,9 +888,7 @@ const char *UI::get_location()
void UI::set_location(const char *str)
{
if (!str) str = "";
- // This text() call clears fl_pending_callback, avoiding
- // an extra location_cb() call.
- Location->text(str);
+ Location->value(str);
Location->position(strlen(str));
}
@@ -912,7 +899,8 @@ void UI::set_location(const char *str)
void UI::focus_location()
{
if (get_panelmode() == UI_HIDDEN) {
- set_panelmode(UI_TEMPORARILY_SHOW_PANELS);
+ // Temporary panel handling is disabled now.
+ //set_panelmode(UI_TEMPORARILY_SHOW_PANELS);
}
Location->take_focus();
// Make text selected when already focused.
@@ -932,7 +920,7 @@ void UI::focus_main()
*/
void UI::set_status(const char *str)
{
- Status->value(str);
+ StatusOutput->value(str);
}
/*
@@ -985,7 +973,7 @@ void UI::set_img_prog(int n_img, int t_img, int cmd)
void UI::set_bug_prog(int n_bug)
{
char str[32];
- int new_w = 16;
+ int new_w = 20;
if (n_bug == 0) {
BugMeter->image(icons->ImgMeterOK);
@@ -995,12 +983,10 @@ void UI::set_bug_prog(int n_bug)
BugMeter->image(icons->ImgMeterBug);
snprintf(str, 32, "%d", n_bug);
BugMeter->copy_label(str);
- BugMeter->redraw_label();
- new_w = strlen(str)*8 + 20;
+ new_w = strlen(str)*9 + 20;
}
- Status->resize(0,0,StatusPanel->w()-new_w,Status->h());
- BugMeter->resize(StatusPanel->w()-new_w, 0, new_w, BugMeter->h());
- StatusPanel->init_sizes();
+ BugMeter->size(new_w, BugMeter->h());
+ StatusBar->rearrange();
}
/*
@@ -1034,25 +1020,42 @@ void UI::customize(int flags)
Search->hide();
if ( !prefs.show_help )
Help->hide();
- if ( !prefs.show_progress_box )
- ProgBox->hide();
+ if ( !prefs.show_progress_box ) {
+ IProg->hide();
+ PProg->hide();
+ }
+
+ if (NavBar)
+ NavBar->rearrange();
+ if (LocBar)
+ LocBar->rearrange();
}
/*
* On-the-fly panel style change
*/
-void UI::panel_cb_i()
+void UI::change_panel(int new_size, int small_icons)
{
- Group *NewPanel;
-
- // Create a new Panel
- ++PanelSize;
- NewPanel = make_panel(TopGroup->w());
- TopGroup->replace(*Panel, *NewPanel);
- delete(Panel);
- Panel = NewPanel;
+ // Remove current panel's bars
+ init_sizes();
+ TopGroup->remove(MenuBar);
+ Fl::delete_widget(MenuBar);
+ TopGroup->remove(LocBar);
+ Fl::delete_widget(LocBar);
+ TopGroup->remove(NavBar);
+ Fl::delete_widget(NavBar);
+ MenuBar = LocBar = NavBar = NULL;
+
+ // Set internal vars for panel size
+ PanelSize = new_size;
+ Small_Icons = small_icons;
+
+ // make a new panel
+ make_panel(TopGroup->w());
customize(0);
+ a_UIcmd_set_buttons_sens(a_UIcmd_get_bw_by_widget(this));
+ TopGroup->rearrange();
Location->take_focus();
}
@@ -1069,7 +1072,6 @@ void UI::color_change_cb_i()
MSG("Location color %d\n", CuteColor);
Location->color(CuteColor);
Location->redraw();
- HighlightButton::default_style->highlight_color(CuteColor);
}
/*
@@ -1078,14 +1080,15 @@ void UI::color_change_cb_i()
void UI::set_panelmode(UIPanelmode mode)
{
if (mode == UI_HIDDEN) {
- Panel->hide();
- StatusPanel->hide();
+ //Panel->hide();
+ StatusBar->hide();
} else {
/* UI_NORMAL or UI_TEMPORARILY_SHOW_PANELS */
- Panel->show();
- StatusPanel->show();
+ //Panel->show();
+ StatusBar->show();
}
Panelmode = mode;
+ TopGroup->rearrange();
}
/*
@@ -1107,50 +1110,16 @@ void UI::panelmode_cb_i()
/*
* Set 'nw' as the main render area widget
*/
-void UI::set_render_layout(Widget &nw)
+void UI::set_render_layout(Fl_Group *nw)
{
- // BUG: replace() is not working as it should.
- // In our case, replacing the rendering area leaves the vertical
- // scrollbar without events.
- //
- // We'll use a workaround in a_UIcmd_browser_window_new() instead.
- TopGroup->replace(MainIdx, nw);
- delete(Main);
- Main = &nw;
- //TopGroup->box(DOWN_BOX);
- //TopGroup->box(BORDER_FRAME);
- TopGroup->resizable(TopGroup->child(MainIdx));
-}
+ // Resize layout widget to current height
+ nw->resize(0,Main->y(),Main->w(),Main->h());
-/*
- * Set the tab title
- */
-void UI::set_tab_title(const char *label)
-{
- char title[128];
-
- dReturn_if_fail(label != NULL);
-
- if (*label) {
- // Make a label for this tab
- size_t tab_chars = 18, label_len = strlen(label);
-
- if (label_len > tab_chars)
- tab_chars = a_Utf8_end_of_char(label, tab_chars - 1) + 1;
- snprintf(title, tab_chars + 1, "%s", label);
- if (label_len > tab_chars)
- snprintf(title + tab_chars, 4, "...");
- // Avoid unnecessary redraws
- if (strcmp(this->label(), title)) {
- this->copy_label(title);
- this->redraw_label();
- }
-
- // Disabled because of a bug in fltk::Tabgroup
- //dFree(TabTooltip);
- //TabTooltip = dStrdup(label);
- //this->tooltip(TabTooltip);
- }
+ TopGroup->insert(*nw, Main);
+ remove(Main);
+ delete(Main);
+ Main = nw;
+ TopGroup->resizable(Main);
}
/*
@@ -1161,15 +1130,15 @@ void UI::button_set_sens(UIButton btn, int sens)
switch (btn) {
case UI_BACK:
(sens) ? Back->activate() : Back->deactivate();
- Back->redraw(DAMAGE_HIGHLIGHT);
+// Back->redraw(DAMAGE_HIGHLIGHT);
break;
case UI_FORW:
(sens) ? Forw->activate() : Forw->deactivate();
- Forw->redraw(DAMAGE_HIGHLIGHT);
+// Forw->redraw(DAMAGE_HIGHLIGHT);
break;
case UI_STOP:
(sens) ? Stop->activate() : Stop->deactivate();
- Stop->redraw(DAMAGE_HIGHLIGHT);
+// Stop->redraw(DAMAGE_HIGHLIGHT);
break;
default:
break;
@@ -1181,17 +1150,70 @@ void UI::button_set_sens(UIButton btn, int sens)
*/
void UI::paste_url()
{
- paste(*Clear, false);
+ Fl::paste(*Clear, false);
}
/*
- * Shows or hides the findbar of this window
+ * Adjust space for the findbar (if necessary) and show or remove it
*/
-void UI::set_findbar_visibility(bool visible)
+void UI::findbar_toggle(bool add)
{
- if (visible) {
- findbar->show();
- } else {
- findbar->hide();
+ /* WORKAROUND:
+ * This is tricky: As fltk-1.3 resizes hidden widgets (which it
+ * doesn't resize when visible!). We need to go through hoops to
+ * get the desired behaviour.
+ * (STR#2639 in FLTK bug tracker).
+ */
+
+ if (add) {
+ if (!FindBarSpace) {
+ // show
+ Main->size(Main->w(), Main->h()-FindBar->h());
+ insert(*FindBar, StatusBar);
+ FindBar->show();
+ FindBarSpace = 1;
+ } else {
+ // select text
+ FindBar->show();
+ }
+ } else if (!add && FindBarSpace) {
+ // hide
+ Main->size(Main->w(), Main->h()+FindBar->h());
+ remove(FindBar);
+ FindBarSpace = 0;
}
+ TopGroup->rearrange();
+}
+
+/*
+ * Make panels disappear growing the render area.
+ * WORKAROUND: here we avoid hidden widgets resize by setting their
+ * size to (0,0) while hidden.
+ * (Already reported to FLTK team)
+ */
+void UI::panels_toggle()
+{
+ int hide = StatusBar->visible();
+
+ // hide/show panels
+ init_sizes();
+ if (MenuBar) {
+ hide ? MenuBar->size(0,0) : MenuBar->size(w(),mh);
+ hide ? MenuBar->hide() : MenuBar->show();
+ }
+ if (LocBar) {
+ hide ? LocBar->size(0,0) : LocBar->size(w(),lh);
+ hide ? LocBar->hide() : LocBar->show();
+ }
+ if (NavBar) {
+ hide ? NavBar->size(0,0) : NavBar->size(w(),nh);
+ hide ? NavBar->hide() : NavBar->show();
+ }
+ if (StatusBar) {
+ hide ? StatusBar->size(0,0) : StatusBar->size(w(),sh);;
+ hide ? StatusBar->hide() : StatusBar->show();;
+ StatusBar->rearrange();
+ }
+
+ TopGroup->rearrange();
}
diff --git a/src/ui.hh b/src/ui.hh
index 9e1b6d4f..beb202a9 100644
--- a/src/ui.hh
+++ b/src/ui.hh
@@ -3,16 +3,13 @@
// UI for dillo --------------------------------------------------------------
-#include <fltk/Window.h>
-#include <fltk/Widget.h>
-#include <fltk/Button.h>
-#include <fltk/Input.h>
-#include <fltk/PackedGroup.h>
-#include <fltk/Output.h>
-#include <fltk/Image.h>
-#include <fltk/MultiImage.h>
-#include <fltk/MenuBuild.h>
-#include <fltk/TabGroup.h>
+#include <FL/Fl_Window.H>
+#include <FL/Fl_Widget.H>
+#include <FL/Fl_Button.H>
+#include <FL/Fl_Input.H>
+#include <FL/Fl_Output.H>
+#include <FL/Fl_Image.H>
+#include <FL/Fl_Tabs.H>
#include "findbar.hh"
@@ -37,41 +34,105 @@ typedef enum {
// Private classes
class CustProgressBox;
-class CustTabGroup;
+class CustTabs;
+
+
+// Class definition ----------------------------------------------------------
+/*
+ * Used to reposition group's widgets when some of them are hidden.
+ * All children get the height of the group but retain their original width.
+ * The resizable child get's the remaining space.
+ */
+class CustGroupHorizontal : public Fl_Group {
+public:
+ CustGroupHorizontal(int x,int y,int w ,int h,const char *l = 0) :
+ Fl_Group(x,y,w,h,l) { };
+
+ void rearrange() {
+ Fl_Widget*const* a = array();
+ int sum = 0, _x = x();
+ int children_ = children();
+
+ for (int i=0; i < children_; i++)
+ if (a[i] != resizable() && a[i]->visible())
+ sum += a[i]->w();
+
+ for (int i=0; i < children_; i++) {
+ if (a[i] == resizable()) {
+ a[i]->resize(_x, y(), w() - sum, h());
+ } else {
+ a[i]->resize(_x, y(), a[i]->w(), h());
+ }
+ if (a[i]->visible())
+ _x += a[i]->w();
+ }
+ init_sizes();
+ redraw();
+ }
+};
+
+class CustGroupVertical : public Fl_Group {
+public:
+ CustGroupVertical(int x,int y,int w ,int h,const char *l = 0) :
+ Fl_Group(x,y,w,h,l) { };
+
+ void rearrange() {
+ Fl_Widget*const* a = array();
+ int sum = 0, _y = y();
+ int children_ = children();
+
+ for (int i=0; i < children_; i++)
+ if (a[i] != resizable() && a[i]->visible())
+ sum += a[i]->h();
+
+ for (int i=0; i < children_; i++) {
+ if (a[i] == resizable()) {
+ a[i]->resize(x(), _y, w(), h() - sum);
+ } else {
+ a[i]->resize(x(), _y, w(), a[i]->h());
+ }
+ if (a[i]->visible())
+ _y += a[i]->h();
+ }
+ init_sizes();
+ redraw();
+ }
+};
+
//
// UI class definition -------------------------------------------------------
//
-class UI : public fltk::Group {
- CustTabGroup *Tabs;
+class UI : public CustGroupVertical {
+ CustTabs *Tabs;
char *TabTooltip;
- fltk::Group *TopGroup;
- fltk::Button *Back, *Forw, *Home, *Reload, *Save, *Stop, *Bookmarks, *Tools,
+ CustGroupVertical *TopGroup;
+ Fl_Button *Back, *Forw, *Home, *Reload, *Save, *Stop, *Bookmarks, *Tools,
*Clear, *Search, *Help, *FullScreen, *BugMeter, *FileButton;
- fltk::Input *Location;
- fltk::PackedGroup *ProgBox;
+ CustGroupHorizontal *MenuBar, *LocBar, *NavBar, *StatusBar;
+ Fl_Input *Location;
CustProgressBox *PProg, *IProg;
- fltk::Group *Panel, *StatusPanel;
- fltk::Widget *Main;
- fltk::Output *Status;
+ Fl_Group *Panel, *Main;
+ Fl_Output *StatusOutput;
+ Findbar *FindBar;
- int MainIdx;
+ int FindBarSpace, MainIdx;
// Panel customization variables
int PanelSize, CuteColor, Small_Icons;
- int xpos, bw, bh, fh, lh, lbl;
+ int p_xpos, p_ypos, bw, bh, mh, lh, nh, fh, sh, pw, lbl;
UIPanelmode Panelmode;
- Findbar *findbar;
int PointerOnLink;
-
- fltk::PackedGroup *make_toolbar(int tw, int th);
- fltk::PackedGroup *make_location();
- fltk::PackedGroup *make_progress_bars(int wide, int thin_up);
+ Fl_Button *make_button(const char *label, Fl_Image *img,
+ Fl_Image*deimg, int b_n, int start = 0);
+ void make_toolbar(int tw, int th);
+ void make_location(int ww);
+ void make_progress_bars(int wide, int thin_up);
void make_menubar(int x, int y, int w, int h);
- fltk::Widget *make_filemenu_button();
- fltk::Group *make_panel(int ww);
- fltk::Group *make_status_panel(int ww);
+ Fl_Widget *make_filemenu_button();
+ void make_panel(int ww);
+ void make_status_bar(int ww, int wh);
public:
@@ -89,24 +150,24 @@ public:
void set_page_prog(size_t nbytes, int cmd);
void set_img_prog(int n_img, int t_img, int cmd);
void set_bug_prog(int n_bug);
- void set_render_layout(Widget &nw);
- void set_tab_title(const char *label);
+ void set_render_layout(Fl_Group *nw);
void customize(int flags);
void button_set_sens(UIButton btn, int sens);
void paste_url();
void set_panelmode(UIPanelmode mode);
UIPanelmode get_panelmode();
- void set_findbar_visibility(bool visible);
- Widget *fullscreen_button() { return FullScreen; }
- void fullscreen_toggle() { FullScreen->do_callback(); }
-
- CustTabGroup *tabs() { return Tabs; }
- void tabs(CustTabGroup *tabs) { Tabs = tabs; }
+ int get_panelsize() { return PanelSize; }
+ int get_smallicons() { return Small_Icons; }
+ void change_panel(int new_size, int small_icons);
+ void findbar_toggle(bool add);
+ void panels_toggle();
+
+ CustTabs *tabs() { return Tabs; }
+ void tabs(CustTabs *tabs) { Tabs = tabs; }
int pointerOnLink() { return PointerOnLink; }
void pointerOnLink(int flag) { PointerOnLink = flag; }
// Hooks to method callbacks
- void panel_cb_i();
void color_change_cb_i();
void toggle_cb_i();
void panelmode_cb_i();
diff --git a/src/uicmd.cc b/src/uicmd.cc
index 7dc047e6..361e42b3 100644
--- a/src/uicmd.cc
+++ b/src/uicmd.cc
@@ -16,11 +16,12 @@
#include <stdarg.h>
#include <math.h> /* for rint */
-#include <fltk/draw.h>
-#include <fltk/damage.h>
-#include <fltk/Widget.h>
-#include <fltk/TabGroup.h>
-#include <fltk/Tooltip.h>
+#include <FL/Fl.H>
+#include <FL/Fl_Widget.H>
+#include <FL/Fl_Double_Window.H>
+#include <FL/Fl_Wizard.H>
+#include <FL/Fl_Box.H>
+#include <FL/names.h>
#include "paths.hh"
#include "keys.hh"
@@ -35,6 +36,7 @@
#include "history.h"
#include "msg.h"
#include "prefs.h"
+#include "misc.h"
#include "dw/fltkviewport.hh"
@@ -56,316 +58,302 @@ using namespace dw::fltk;
*/
static char *save_dir = NULL;
-using namespace fltk;
-
+/*
+ * Forward declarations
+ */
+static BrowserWindow *UIcmd_tab_new(CustTabs *tabs, UI *old_ui, int focus);
//----------------------------------------------------------------------------
-#define BTN_W 25
-#define BTN_H 20
-static int btn_x;
+/*
+ * CustTabs ---------------------------------------------------------------
+ */
/*
- * Adds a tab-close button at the rightmost part
+ * stores the respective UI pointer
*/
-class CustShrinkTabPager : public TabGroupPager {
- bool btn_hl;
- TabGroup *tg;
+class CustTabButton : public Fl_Button {
+ UI *ui_;
public:
- int update_positions(
- TabGroup *g, int numchildren, int &selected,
- int &cumulated_width, int &available_width,
- int *tab_pos, int *tab_width);
- virtual int which(TabGroup* g, int m_x,int m_y);
- virtual TabGroupPager* clone() const;
- virtual const char * mode_name() const {return "Shrink";}
- virtual int id() const {return PAGER_SHRINK;}
- virtual int available_width(TabGroup *g) const;
- virtual bool draw_tabs(TabGroup* g, int selected, int* tab_pos,
- int* tab_width) {
- if (!tg) tg = g;
- if (g->children() > 1) {
- fltk::Rectangle r(btn_x,0,BTN_W,BTN_H);
- setcolor(btn_hl ? 206 : GRAY75);
- fillrect(r);
- if (btn_hl) {
- setcolor(WHITE);
- strokerect(r);
- }
- setcolor(GRAY10);
- //fltk::setfont(fltk::getfont()->bold(), fltk::getsize());
- r.h(r.h()-2);
- drawtext("X", r, ALIGN_CENTER);
- return false;
- } else {
- // WORKAROUND: for http://fltk.org/str.php?L2062
- // By returning true we avoid a call to TabGroup::draw_tab()
- // in TabGroup::draw() in case we don't show the tabs.
- return true;
- }
- }
+ CustTabButton (int x,int y,int w,int h, const char* label = 0) :
+ Fl_Button (x,y,w,h,label) { ui_ = NULL; };
+ void ui(UI *pui) { ui_ = pui; }
+ UI *ui(void) { return ui_; }
+};
- void btn_highlight(bool flag) {
- if (btn_hl != flag) {
- btn_hl = flag;
- if (tg)
- tg->redraw(DAMAGE_VALUE);
- }
+/*
+ * Allows fine control of the tabbed interface
+ */
+class CustTabs : public CustGroupHorizontal {
+ int tab_w, tab_h, ctab_h, tab_n;
+ Fl_Wizard *Wizard;
+ int tabcolor_inactive, tabcolor_active, curtab_idx;
+public:
+ CustTabs (int ww, int wh, int th, const char *lbl=0) :
+ CustGroupHorizontal(0,0,ww,th,lbl) {
+ tab_w = 80, tab_h = th, ctab_h = 1, tab_n = 0, curtab_idx = -1;
+ tabcolor_active = FL_DARK_CYAN; tabcolor_inactive = 206;
+ resize(0,0,ww,ctab_h);
+ resizable(NULL);
+ box(FL_FLAT_BOX);
+ end();
+
+ Wizard = new Fl_Wizard(0,ctab_h,ww,wh-ctab_h);
+ Wizard->box(FL_NO_BOX);
+ Wizard->end();
};
- bool btn_highlight() { return btn_hl; };
-
- CustShrinkTabPager() : TabGroupPager() {
- noclip(true);
- btn_hl = false;
- tg = NULL;
- }
+ int handle(int e);
+ UI *add_new_tab(UI *old_ui, int focus);
+ void remove_tab(UI *ui);
+ Fl_Wizard *wizard(void) { return Wizard; }
+ int get_btn_idx(UI *ui);
+ int num_tabs() { return children(); }
+ void switch_tab(CustTabButton *cbtn);
+ void prev_tab(void);
+ void next_tab(void);
+
+ void set_tab_label(UI *ui, const char *title);
};
-int CustShrinkTabPager::available_width(TabGroup *g) const
+/*
+ * Callback for mouse click
+ */
+static void tab_btn_cb (Fl_Widget *w, void *cb_data)
{
- _MSG("CustShrinkTabPager::available_width\n");
- int w = MAX (g->w() - this->slope()-1 - BTN_W, 0);
- btn_x = w + 6;
- return w;
+ CustTabButton *btn = (CustTabButton*) w;
+ CustTabs *tabs = (CustTabs*) cb_data;
+ int b = Fl::event_button();
+
+ if (b == FL_LEFT_MOUSE) {
+ tabs->switch_tab(btn);
+ } else if ((b == FL_RIGHT_MOUSE && prefs.right_click_closes_tab) ||
+ (b == FL_MIDDLE_MOUSE && !prefs.right_click_closes_tab)) {
+ // TODO: just an example, not necessarily final
+ a_UIcmd_close_bw(a_UIcmd_get_bw_by_widget(btn->ui()));
+ }
}
-int CustShrinkTabPager::which(TabGroup* g, int event_x,int event_y)
+int CustTabs::handle(int e)
{
- int H = g->tab_height();
- if (!H) return -1;
- if (H < 0) {
- if (event_y > g->h() || event_y < g->h()+H) return -1;
- } else {
- if (event_y > H || event_y < 0) return -1;
- }
- if (event_x < 0) return -1;
- int p[128], w[128];
- int selected = g->tab_positions(p, w);
- int d = (event_y-(H>=0?0:g->h()))*slope()/H;
- for (int i=0; i<g->children(); i++) {
- if (event_x < p[i+1]+(i<selected ? slope() - d : d)) return i;
+ int ret = 0;
+
+ _MSG("CustTabs::handle e=%s\n", fl_eventnames[e]);
+ if (e == FL_KEYBOARD) {
+ return 0; // Receive as shortcut
+ } else if (e == FL_SHORTCUT) {
+ UI *ui = (UI*)wizard()->value();
+ BrowserWindow *bw = a_UIcmd_get_bw_by_widget(ui);
+ KeysCommand_t cmd = Keys::getKeyCmd();
+ if (Fl::event_key() == FL_Escape) {
+ // Hide findbar if present
+ ui->findbar_toggle(0);
+ ret = 1;
+ } else if (cmd == KEYS_NOP) {
+ // Do nothing
+ _MSG("CustTabs::handle KEYS_NOP\n");
+ } else if (cmd == KEYS_NEW_TAB) {
+ a_UIcmd_open_url_nt(bw, NULL, 1);
+ ret = 1;
+ } else if (cmd == KEYS_CLOSE_TAB) {
+ a_UIcmd_close_bw(bw);
+ ret = 1;
+ } else if (cmd == KEYS_LEFT_TAB) {
+ prev_tab();
+ ret = 1;
+ } else if (cmd == KEYS_RIGHT_TAB) {
+ next_tab();
+ ret = 1;
+ } else if (cmd == KEYS_NEW_WINDOW) {
+ a_UIcmd_open_url_nw(bw, NULL);
+ ret = 1;
+ } else if (cmd == KEYS_CLOSE_ALL) {
+ a_Timeout_add(0.0, a_UIcmd_close_all_bw, NULL);
+ ret = 1;
+ }
}
- return -1;
+
+ return (ret) ? ret : CustGroupHorizontal::handle(e);
}
/*
- * Prevents tabs from going over the close-tab button.
- * Modified from fltk-2.0.x-r6525.
+ * Create a new tab with its own UI
*/
-int CustShrinkTabPager::update_positions(
- TabGroup *g, int numchildren, int &selected,
- int &cumulated_width, int &available_width,
- int *tab_pos, int *tab_width)
+UI *CustTabs::add_new_tab(UI *old_ui, int focus)
{
- available_width-=BTN_W;
+ char tab_label[64];
- // uh oh, they are too big, we must move them:
- // special case when the selected tab itself is too big, make it fill
- // cumulated_width:
- int i;
+ if (num_tabs() == 1) {
+ // Show tabbar
+ ctab_h = tab_h;
+ Wizard->resize(0,ctab_h,Wizard->w(),window()->h()-ctab_h);
+ resize(0,0,window()->w(),ctab_h); // tabbar
+ child(0)->show(); // first tab button
+ window()->init_sizes();
+ }
- if (tab_width[selected] >= available_width) {
- tab_width[selected] = available_width;
- for (i = 0; i <= selected; i++)
- tab_pos[i] = 0;
- for (i = selected + 1; i <= numchildren; i++)
- tab_pos[i] = available_width;
- return selected;
+ current(0);
+ UI *new_ui = new UI(0,ctab_h,Wizard->w(),Wizard->h(),0,old_ui);
+ new_ui->tabs(this);
+ Wizard->add(new_ui);
+ new_ui->show();
+
+ snprintf(tab_label, 64,"ctab%d", ++tab_n);
+ CustTabButton *btn = new CustTabButton(num_tabs()*tab_w,0,tab_w,ctab_h);
+ btn->align(FL_ALIGN_INSIDE|FL_ALIGN_CLIP);
+ btn->copy_label(tab_label);
+ btn->clear_visible_focus();
+ btn->box(FL_PLASTIC_ROUND_UP_BOX);
+ btn->color(focus ? tabcolor_active : tabcolor_inactive);
+ btn->ui(new_ui);
+ add(btn);
+ btn->callback(tab_btn_cb, this);
+
+ if (focus) {
+ switch_tab(btn);
+ } else if (num_tabs() == 2) {
+ // no focus and tabbar added: redraw current page
+ Wizard->redraw();
}
+ if (num_tabs() == 1)
+ btn->hide();
+ rearrange();
- int w2[128];
+ return new_ui;
+}
- for (i = 0; i < numchildren; i++)
- w2[i] = tab_width[i];
- i = numchildren - 1;
- int j = 0;
+/*
+ * Remove tab by UI
+ */
+void CustTabs::remove_tab(UI *ui)
+{
+ CustTabButton *btn;
- int minsize = 5;
+ // get active tab idx
+ int act_idx = get_btn_idx((UI*)Wizard->value());
+ // get to-be-removed tab idx
+ int rm_idx = get_btn_idx(ui);
+ btn = (CustTabButton*)child(rm_idx);
- bool right = true;
+ if (act_idx == rm_idx) {
+ // Active tab is being closed, switch to another one
+ rm_idx > 0 ? prev_tab() : next_tab();
+ }
+ remove(rm_idx);
+ delete btn;
+ rearrange();
- while (cumulated_width > available_width) {
- int n; // which one to shrink
+ Wizard->remove(ui);
+ delete(ui);
- if (j < selected && (!right || i <= selected)) { // shrink a left one
- n = j++;
- right = true;
- } else if (i > selected) { // shrink a right one
- n = i--;
- right = false;
- } else { // no more space, start making them zero
- minsize = 0;
- i = numchildren - 1;
- j = 0;
- right = true;
- continue;
- }
- cumulated_width -= w2[n] - minsize;
- w2[n] = minsize;
- if (cumulated_width < available_width) {
- w2[n] = available_width - cumulated_width + minsize;
- cumulated_width = available_width;
- break;
- }
+ if (num_tabs() == 0) {
+ window()->hide();
+ // TODO: free memory
+ //delete window();
+
+ } else if (num_tabs() == 1) {
+ // hide tabbar
+ ctab_h = 1;
+ child(0)->hide(); // first tab button
+ resize(0,0,window()->w(),ctab_h); // tabbar
+ Wizard->resize(0,ctab_h,Wizard->w(),window()->h()-ctab_h);
+ window()->init_sizes();
+ window()->redraw();
}
- // re-sum the positions:
- cumulated_width = 0;
- for (i = 0; i < numchildren; i++) {
- cumulated_width += w2[i];
- tab_pos[i+1] = cumulated_width;
- }
- return selected;
}
-TabGroupPager* CustShrinkTabPager::clone() const {
- return new CustShrinkTabPager(*this);
+int CustTabs::get_btn_idx(UI *ui)
+{
+ for (int i = 0; i < num_tabs(); ++i) {
+ CustTabButton *btn = (CustTabButton*)child(i);
+ if (btn->ui() == ui)
+ return i;
+ }
+ return -1;
}
-//----------------------------------------------------------------------------
-
/*
- * For custom handling of keyboard
+ * Make cbtn's tab the active one
*/
-class CustTabGroup : public fltk::TabGroup {
- Tooltip *toolTip;
- bool tooltipEnabled;
- bool buttonPushed;
-public:
- CustTabGroup (int x, int y, int ww, int wh, const char *lbl=0) :
- TabGroup(x,y,ww,wh,lbl) {
- // The parameter pager is cloned, so free it.
- CustShrinkTabPager *cp = new CustShrinkTabPager();
- this->pager(cp);
- delete cp;
- toolTip = new Tooltip;
- tooltipEnabled = false;
- buttonPushed = false;
- };
- ~CustTabGroup() { delete toolTip; }
- int handle(int e) {
- // Don't focus with arrow keys
- _MSG("CustTabGroup::handle %d\n", e);
- fltk::Rectangle r(btn_x,0,BTN_W,BTN_H);
- if (e == KEY) {
- int k = event_key();
- // We're only interested in some flags
- unsigned modifier = event_state() & (SHIFT | CTRL | ALT);
- if (k == UpKey || k == DownKey || k == TabKey) {
- return 0;
- } else if (k == LeftKey || k == RightKey) {
- if (modifier == SHIFT) {
- int i = value();
- if (k == LeftKey) {i = i ? i-1 : children()-1;}
- else {i++; if (i >= children()) i = 0;}
- selected_child(child(i));
- return 1;
- }
- // Avoid focus change.
- return 0;
- }
- } else if (e == FOCUS_CHANGE) {
- // Update the window title
- BrowserWindow *bw = a_UIcmd_get_bw_by_widget(selected_child());
- const char *title = a_History_get_title(NAV_TOP_UIDX(bw), 1);
- a_UIcmd_set_page_title(bw, title ? title : "");
- } else if (e == MOVE) {
- CustShrinkTabPager *cstp = (CustShrinkTabPager *) pager();
- if (event_inside(r) && children() > 1) {
- /* We're inside the button area */
- cstp->btn_highlight(true);
- if (prefs.show_tooltip) {
- /* Prepare the tooltip for pop-up */
- tooltipEnabled = true;
- /* We use parent() if available because we are returning 0.
- * Returning without having TabGroup processing makes the
- * popup event never reach 'this', but it reaches parent() */
- toolTip->enter(parent() ?parent():this, r, "Close current Tab");
- }
- return 0; // Change focus
- } else {
- cstp->btn_highlight(false);
-
- if (prefs.show_tooltip) {
- /* Hide the tooltip or enable it again.*/
- if (tooltipEnabled) {
- tooltipEnabled = false;
- toolTip->exit();
- } else {
- toolTip->enable();
- }
- }
- }
- } else if (e == PUSH && event_inside(r) &&
- event_button() == 1 && children() > 1) {
- buttonPushed = true;
- return 1; /* non-zero */
- } else if (e == RELEASE) {
- if (event_inside(r) && event_button() == 1 &&
- children() > 1 && buttonPushed) {
- a_UIcmd_close_bw(a_UIcmd_get_bw_by_widget(selected_child()));
- } else {
- CustShrinkTabPager *cstp = (CustShrinkTabPager *) pager();
- cstp->btn_highlight(false);
- }
- buttonPushed = false;
- } else if (e == DRAG) {
- /* Ignore this event */
- return 1;
+void CustTabs::switch_tab(CustTabButton *cbtn)
+{
+ int idx;
+ CustTabButton *btn;
+ BrowserWindow *bw;
+ UI *old_ui = (UI*)Wizard->value();
+
+ if (cbtn->ui() != old_ui) {
+ // Set old tab label to normal color
+ if ((idx = get_btn_idx(old_ui)) != -1) {
+ btn = (CustTabButton*)child(idx);
+ btn->color(tabcolor_inactive);
+ btn->redraw();
}
- int ret = TabGroup::handle(e);
-
- if (e == PUSH) {
- /* WORKAROUND: FLTK raises the window on unhandled clicks,
- * which we do not want.
- */
- ret = 1;
+ Wizard->value(cbtn->ui());
+ cbtn->color(tabcolor_active);
+ cbtn->redraw();
+
+ // Update window title
+ if ((bw = a_UIcmd_get_bw_by_widget(cbtn->ui()))) {
+ const char *title = (cbtn->ui())->label();
+ cbtn->window()->copy_label(title ? title : "");
}
- return ret;
}
+}
- void remove (Widget *w) {
- TabGroup::remove (w);
- /* fixup resizable in case we just removed it */
- if (resizable () == w) {
- if (children () > 0)
- resizable (child (children () - 1));
- else
- resizable (NULL);
- }
+void CustTabs::prev_tab()
+{
+ int idx;
- if (children () < 2)
- hideLabels ();
- }
+ if ((idx = get_btn_idx((UI*)Wizard->value())) != -1)
+ switch_tab( (CustTabButton*)child(idx > 0 ? idx-1 : num_tabs()-1) );
+}
- void add (Widget *w) {
- TabGroup::add (w);
- if (children () > 1)
- showLabels ();
- }
+void CustTabs::next_tab()
+{
+ int idx;
- void hideLabels() {
- for (int i = children () - 1; i >= 0; i--)
- child(i)->resize(x(), y(), w(), h());
- }
+ if ((idx = get_btn_idx((UI*)Wizard->value())) != -1)
+ switch_tab( (CustTabButton*)child((idx+1 < num_tabs()) ? idx+1 : 0) );
+}
- void showLabels() {
- for (int i = children () - 1; i >= 0; i--)
- child(i)->resize(x(), y() + 20, w(), h() - 20);
+/*
+ * Set this UI's tab button label
+ */
+void CustTabs::set_tab_label(UI *ui, const char *label)
+{
+ char title[128];
+ int idx = get_btn_idx(ui);
+
+ if (idx != -1) {
+ // Make a label for this tab
+ size_t tab_chars = 7, label_len = strlen(label);
+
+ if (label_len > tab_chars)
+ tab_chars = a_Utf8_end_of_char(label, tab_chars - 1) + 1;
+ snprintf(title, tab_chars + 1, "%s", label);
+ if (label_len > tab_chars)
+ snprintf(title + tab_chars, 4, "...");
+
+ // Avoid unnecessary redraws
+ if (strcmp(child(idx)->label(), title)) {
+ child(idx)->copy_label(title);
+ }
}
-};
+}
+
//----------------------------------------------------------------------------
-static void win_cb (fltk::Widget *w, void *cb_data) {
- int choice = 0;
- CustTabGroup *tabs = (CustTabGroup*) cb_data;
+static void win_cb (Fl_Widget *w, void *cb_data) {
+ int choice = 1;
+ CustTabs *tabs = (CustTabs*) cb_data;
- if (tabs->children () > 1)
- choice = a_Dialog_choice3 ("Window contains more than one tab.",
- "Close all tabs", "Cancel", NULL);
- if (choice == 0)
- while (tabs->children())
- a_UIcmd_close_bw(a_UIcmd_get_bw_by_widget(tabs->child(0)));
+ if (tabs->num_tabs() > 1)
+ choice = a_Dialog_choice5("Window contains more than one tab.",
+ "Close", "Cancel", NULL, NULL, NULL);
+ if (choice == 1)
+ while (tabs->num_tabs())
+ a_UIcmd_close_bw(a_UIcmd_get_bw_by_widget(tabs->wizard()->value()));
}
/*
@@ -376,27 +364,14 @@ BrowserWindow *a_UIcmd_get_bw_by_widget(void *v_wid)
BrowserWindow *bw;
for (int i = 0; i < a_Bw_num(); ++i) {
bw = a_Bw_get(i);
- if (((fltk::Widget*)bw->ui)->contains((fltk::Widget*)v_wid))
+ if (((UI*)bw->ui)->contains((Fl_Widget*)v_wid)) {
return bw;
+ }
}
return NULL;
}
/*
- * FLTK regards SHIFT + {LeftKey, Right} as navigation keys.
- * Special handling is required to override it. Here we route
- * these events directly to the recipient.
- * TODO: focus is not remembered correctly.
- */
-void a_UIcmd_send_event_to_tabs_by_wid(int e, void *v_wid)
-{
- BrowserWindow *bw = a_UIcmd_get_bw_by_widget(v_wid);
- UI *ui = (UI*)bw->ui;
- if (ui->tabs())
- ui->tabs()->handle(e);
-}
-
-/*
* Create a new UI and its associated BrowserWindow data structure.
* Use style from v_ui. If non-NULL it must be of type UI*.
*/
@@ -405,7 +380,8 @@ BrowserWindow *a_UIcmd_browser_window_new(int ww, int wh,
{
BrowserWindow *old_bw = (BrowserWindow*)vbw;
BrowserWindow *new_bw = NULL;
- Window *win;
+ UI *old_ui = old_bw ? BW2UI(old_bw) : NULL;
+ Fl_Window *win;
if (ww <= 0 || wh <= 0) {
// Set default geometry from dillorc.
@@ -415,96 +391,40 @@ BrowserWindow *a_UIcmd_browser_window_new(int ww, int wh,
if (xid)
win = new Xembed(xid, ww, wh);
+ else if (prefs.buffered_drawing != 2)
+ win = new Fl_Window(ww, wh);
else
- win = new Window(ww, wh);
-
- win->shortcut(0); // Ignore Escape
- if (prefs.buffered_drawing != 2)
- win->clear_double_buffer();
- win->set_flag(RAW_LABEL);
- CustTabGroup *DilloTabs = new CustTabGroup(0, 0, ww, wh);
- DilloTabs->clear_tab_to_focus();
- DilloTabs->selection_color(156);
- win->add(DilloTabs);
+ win = new Fl_Double_Window(ww, wh);
- // Create and set the UI
- UI *new_ui = new UI(0, 0, ww, wh, DEFAULT_TAB_LABEL,
- old_bw ? BW2UI(old_bw) : NULL);
- new_ui->set_status("http://www.dillo.org/");
- new_ui->tabs(DilloTabs);
+ win->box(FL_NO_BOX);
+ CustTabs *DilloTabs = new CustTabs(ww, wh, 16);
+ win->end();
- DilloTabs->add(new_ui);
- DilloTabs->resizable(new_ui);
- DilloTabs->window()->resizable(new_ui);
- DilloTabs->window()->show();
+ int focus = 1;
+ new_bw = UIcmd_tab_new(DilloTabs, old_ui, focus);
+ win->resizable(BW2UI(new_bw));
+ win->show();
if (old_bw == NULL && prefs.xpos >= 0 && prefs.ypos >= 0) {
// position the first window according to preferences
- fltk::Rectangle r;
- new_ui->window()->borders(&r);
- // borders() gives x and y border sizes as negative values
- new_ui->window()->position(prefs.xpos - r.x(), prefs.ypos - r.y());
+ DilloTabs->window()->position(prefs.xpos, prefs.ypos);
}
- // Now create the Dw render layout and viewport
- FltkPlatform *platform = new FltkPlatform ();
- Layout *layout = new Layout (platform);
- style::Color *bgColor = style::Color::create (layout, prefs.bg_color);
- layout->setBgColor (bgColor);
-
- FltkViewport *viewport = new FltkViewport (0, 0, 1, 1);
- if (prefs.buffered_drawing == 1)
- viewport->setBufferedDrawing (true);
- else
- viewport->setBufferedDrawing (false);
-
- layout->attachView (viewport);
- new_ui->set_render_layout(*viewport);
-
- viewport->setScrollStep((int) rint(14.0 * prefs.font_factor));
-
- // Now, create a new browser window structure
- new_bw = a_Bw_new();
-
- // Reference the UI from the bw
- new_bw->ui = (void *)new_ui;
- // Copy the layout pointer into the bw data
- new_bw->render_layout = (void*)layout;
-
win->callback(win_cb, DilloTabs);
- new_ui->focus_location();
-
return new_bw;
}
/*
- * Create a new Tab.
- * i.e the new UI and its associated BrowserWindow data structure.
+ * Create a new Tab button, UI and its associated BrowserWindow data
+ * structure.
*/
-static BrowserWindow *UIcmd_tab_new(const void *vbw)
+static BrowserWindow *UIcmd_tab_new(CustTabs *tabs, UI *old_ui, int focus)
{
- _MSG(" UIcmd_tab_new vbw=%p\n", vbw);
-
- dReturn_val_if_fail (vbw != NULL, NULL);
-
- BrowserWindow *new_bw = NULL;
- BrowserWindow *old_bw = (BrowserWindow*)vbw;
- UI *ui = BW2UI(old_bw);
-
- // WORKAROUND: limit the number of tabs because of a fltk bug
- if (ui->tabs()->children() >= 127)
- return a_UIcmd_browser_window_new(ui->window()->w(), ui->window()->h(),
- 0, vbw);
+ _MSG(" UIcmd_tab_new\n");
// Create and set the UI
- UI *new_ui = new UI(0, 0, ui->w(), ui->h(), DEFAULT_TAB_LABEL, ui);
- new_ui->tabs(ui->tabs());
-
- new_ui->tabs()->add(new_ui);
- new_ui->tabs()->resizable(new_ui);
- new_ui->tabs()->window()->resizable(new_ui);
- new_ui->tabs()->window()->show();
+ UI *new_ui = tabs->add_new_tab(old_ui, focus);
// Now create the Dw render layout and viewport
FltkPlatform *platform = new FltkPlatform ();
@@ -512,21 +432,26 @@ static BrowserWindow *UIcmd_tab_new(const void *vbw)
style::Color *bgColor = style::Color::create (layout, prefs.bg_color);
layout->setBgColor (bgColor);
- FltkViewport *viewport = new FltkViewport (0, 0, 1, 1);
-
+ // set_render_layout() sets the proper viewport size
+ FltkViewport *viewport = new FltkViewport (0, 0, 0, 1);
+ viewport->box(FL_NO_BOX);
+ viewport->setBufferedDrawing (prefs.buffered_drawing ? true : false);
+ viewport->setDragScroll (prefs.middle_click_drags_page ? true : false);
layout->attachView (viewport);
- new_ui->set_render_layout(*viewport);
-
- viewport->setScrollStep((int) rint(14.0 * prefs.font_factor));
+ new_ui->set_render_layout(viewport);
+ viewport->setScrollStep((int) rint(28.0 * prefs.font_factor));
// Now, create a new browser window structure
- new_bw = a_Bw_new();
+ BrowserWindow *new_bw = a_Bw_new();
// Reference the UI from the bw
new_bw->ui = (void *)new_ui;
// Copy the layout pointer into the bw data
new_bw->render_layout = (void*)layout;
+ // WORKAROUND: see findbar_toggle()
+ new_ui->findbar_toggle(0);
+
return new_bw;
}
@@ -543,15 +468,8 @@ void a_UIcmd_close_bw(void *vbw)
a_Bw_stop_clients(bw, BW_Root + BW_Img + BW_Force);
delete(layout);
if (ui->tabs()) {
- ui->tabs()->remove(ui);
- ui->tabs()->value(ui->tabs()->children() - 1);
- if (ui->tabs()->value() != -1)
- ui->tabs()->selected_child()->take_focus();
- else
- ui->tabs()->window()->hide();
+ ui->tabs()->remove_tab(ui);
}
- delete(ui);
-
a_Bw_free(bw);
}
@@ -561,12 +479,12 @@ void a_UIcmd_close_bw(void *vbw)
void a_UIcmd_close_all_bw(void *)
{
BrowserWindow *bw;
- int choice = 0;
+ int choice = 1;
if (a_Bw_num() > 1)
- choice = a_Dialog_choice3 ("More than one open tab or Window.",
- "Close all tabs and windows", "Cancel", NULL);
- if (choice == 0)
+ choice = a_Dialog_choice5("More than one open tab or window.",
+ "Quit", "Cancel", NULL, NULL, NULL);
+ if (choice == 1)
while ((bw = a_Bw_get(0)))
a_UIcmd_close_bw((void*)bw);
}
@@ -616,10 +534,18 @@ void a_UIcmd_open_urlstr(void *vbw, const char *urlstr)
*/
void a_UIcmd_open_url(BrowserWindow *bw, const DilloUrl *url)
{
- a_Nav_push(bw, url, NULL);
+ if (url) {
+ a_Nav_push(bw, url, NULL);
+ } else {
+ // Used to start a bw with a blank screen
+ BW2UI(bw)->focus_location();
+ a_UIcmd_set_buttons_sens(bw);
+ }
+#if 0
if (BW2UI(bw)->get_panelmode() == UI_TEMPORARILY_SHOW_PANELS)
BW2UI(bw)->set_panelmode(UI_HIDDEN);
a_UIcmd_focus_main_area(bw);
+#endif
}
static void UIcmd_open_url_nbw(BrowserWindow *new_bw, const DilloUrl *url)
@@ -632,6 +558,7 @@ static void UIcmd_open_url_nbw(BrowserWindow *new_bw, const DilloUrl *url)
BW2UI(new_bw)->focus_main();
} else {
BW2UI(new_bw)->focus_location();
+ a_UIcmd_set_buttons_sens(new_bw);
}
}
@@ -654,11 +581,9 @@ void a_UIcmd_open_url_nw(BrowserWindow *bw, const DilloUrl *url)
*/
void a_UIcmd_open_url_nt(void *vbw, const DilloUrl *url, int focus)
{
- BrowserWindow *new_bw = UIcmd_tab_new(vbw);
-
- if (focus)
- BW2UI(new_bw)->tabs()->selected_child(BW2UI(new_bw));
-
+ BrowserWindow *bw = (BrowserWindow *)vbw;
+ BrowserWindow *new_bw = UIcmd_tab_new(BW2UI(bw)->tabs(),
+ bw ? BW2UI(bw) : NULL, focus);
UIcmd_open_url_nbw(new_bw, url);
}
@@ -850,16 +775,20 @@ void a_UIcmd_open_file(void *vbw)
/*
* Returns a newly allocated string holding a search url generated from
- * a string of keywords (separarated by blanks) and prefs.search_url.
+ * a string of keywords (separated by blanks) and the current search_url.
* The search string is urlencoded.
*/
static char *UIcmd_make_search_str(const char *str)
{
- char *keys = a_Url_encode_hex_str(str), *c = prefs.search_url;
+ char *search_url, *l, *u, *c;
+ char *keys = a_Url_encode_hex_str(str),
+ *src = (char*)dList_nth_data(prefs.search_urls, prefs.search_url_idx);
Dstr *ds = dStr_sized_new(128);
- char *search_url;
- for (; *c; c++) {
+ /* parse search_url into label and url */
+ a_Misc_parse_search_url(src, &l, &u);
+
+ for (c = u; *c; c++) {
if (*c == '%')
switch(*++c) {
case 's':
@@ -1030,7 +959,7 @@ void a_UIcmd_view_page_source(BrowserWindow *bw, const DilloUrl *url)
}
/*
- * Show a text window with the URL's source
+ * Show the browser window's HTML errors in a text window
*/
void a_UIcmd_view_page_bugs(void *vbw)
{
@@ -1225,16 +1154,16 @@ void a_UIcmd_set_page_title(BrowserWindow *bw, const char *label)
const int size = 128;
char title[size];
- if (a_UIcmd_get_bw_by_widget(BW2UI(bw)->tabs()->selected_child()) == bw) {
+ if (a_UIcmd_get_bw_by_widget(BW2UI(bw)->tabs()->wizard()->value()) == bw) {
// This is the focused bw, set window title
if (snprintf(title, size, "Dillo: %s", label) >= size) {
uint_t i = MIN(size - 4, 1 + a_Utf8_end_of_char(title, size - 8));
snprintf(title + i, 4, "...");
}
+ BW2UI(bw)->copy_label(title);
BW2UI(bw)->window()->copy_label(title);
- BW2UI(bw)->window()->redraw_label();
}
- BW2UI(bw)->set_tab_title(label);
+ BW2UI(bw)->tabs()->set_tab_label(BW2UI(bw), label);
}
/*
@@ -1289,11 +1218,11 @@ int a_UIcmd_pointer_on_link(BrowserWindow *bw)
}
/*
- * Toggle control panel (aka. fullscreen)
+ * Toggle control panel
*/
-void a_UIcmd_fullscreen_toggle(BrowserWindow *bw)
+void a_UIcmd_panels_toggle(BrowserWindow *bw)
{
- BW2UI(bw)->fullscreen_toggle();
+ BW2UI(bw)->panels_toggle();
}
/*
@@ -1330,6 +1259,14 @@ void a_UIcmd_findtext_reset(BrowserWindow *bw)
}
/*
+ * Tell the UI to hide/show the findbar
+ */
+void a_UIcmd_findbar_toggle(BrowserWindow *bw, int on)
+{
+ BW2UI(bw)->findbar_toggle(on);
+}
+
+/*
* Focus the rendered area.
*/
void a_UIcmd_focus_main_area(BrowserWindow *bw)
diff --git a/src/uicmd.hh b/src/uicmd.hh
index c8fea9e7..dc7294a1 100644
--- a/src/uicmd.hh
+++ b/src/uicmd.hh
@@ -34,11 +34,12 @@ void a_UIcmd_search_dialog(void *vbw);
const char *a_UIcmd_get_passwd(const char *user);
void a_UIcmd_book(void *vbw);
void a_UIcmd_add_bookmark(BrowserWindow *bw, const DilloUrl *url);
-void a_UIcmd_fullscreen_toggle(BrowserWindow *bw);
+void a_UIcmd_panels_toggle(BrowserWindow *bw);
void a_UIcmd_findtext_dialog(BrowserWindow *bw);
void a_UIcmd_findtext_search(BrowserWindow *bw,const char *key,int case_sens,
int backwards);
void a_UIcmd_findtext_reset(BrowserWindow *bw);
+void a_UIcmd_findbar_toggle(BrowserWindow *bw, int on);
void a_UIcmd_focus_main_area(BrowserWindow *bw);
void a_UIcmd_focus_location(void *vbw);
void a_UIcmd_page_popup(void *vbw, bool_t has_bugs, void *v_cssUrls);
@@ -77,7 +78,6 @@ void a_UIcmd_set_bug_prog(BrowserWindow *bw, int n_bug);
void a_UIcmd_set_page_title(BrowserWindow *bw, const char *label);
void a_UIcmd_set_msg(BrowserWindow *bw, const char *format, ...);
void a_UIcmd_set_buttons_sens(BrowserWindow *bw);
-void a_UIcmd_fullscreen_toggle(BrowserWindow *bw);
void a_UIcmd_set_pointer_on_link(BrowserWindow *bw, int flag);
int a_UIcmd_pointer_on_link(BrowserWindow *bw);
diff --git a/src/utf8.cc b/src/utf8.cc
index 0138c616..3d25f4f5 100644
--- a/src/utf8.cc
+++ b/src/utf8.cc
@@ -9,7 +9,7 @@
* (at your option) any later version.
*/
-#include <fltk/utf.h>
+#include <FL/fl_utf8.h>
#include "../dlib/dlib.h" /* TRUE/FALSE */
#include "utf8.hh"
@@ -45,7 +45,7 @@ uint_t a_Utf8_end_of_char(const char *str, uint_t i)
*/
uint_t a_Utf8_decode(const char* str, const char* end, int* len)
{
- return utf8decode(str, end, len);
+ return fl_utf8decode(str, end, len);
}
/*
@@ -53,7 +53,7 @@ uint_t a_Utf8_decode(const char* str, const char* end, int* len)
*/
int a_Utf8_encode(unsigned int ucs, char *buf)
{
- return utf8encode(ucs, buf);
+ return fl_utf8encode(ucs, buf);
}
/*
@@ -63,7 +63,7 @@ int a_Utf8_encode(unsigned int ucs, char *buf)
*/
int a_Utf8_test(const char* src, unsigned int srclen)
{
- return utf8test(src, srclen);
+ return fl_utf8test(src, srclen);
}
/*
@@ -100,3 +100,8 @@ bool_t a_Utf8_combining_char(int unicode)
(unicode >= 0x20d0 && unicode <= 0x20ff) ||
(unicode >= 0xfe20 && unicode <= 0xfe2f));
}
+
+int a_Utf8_char_count(const char *str, int len)
+{
+ return fl_utf_nb_char((const uchar_t*)str, len);
+}
diff --git a/src/utf8.hh b/src/utf8.hh
index 4ded50b8..ce575118 100644
--- a/src/utf8.hh
+++ b/src/utf8.hh
@@ -24,6 +24,7 @@ int a_Utf8_encode(unsigned int ucs, char *buf);
int a_Utf8_test(const char* src, unsigned int srclen);
bool_t a_Utf8_ideographic(const char *s, const char *end, int *len);
bool_t a_Utf8_combining_char(int unicode);
+int a_Utf8_char_count(const char *str, int len);
#ifdef __cplusplus
}
diff --git a/src/web.cc b/src/web.cc
index 83700845..9daccdec 100644
--- a/src/web.cc
+++ b/src/web.cc
@@ -78,8 +78,11 @@ int a_Web_dispatch_by_type (const char *Type, DilloWeb *Web,
/* This method frees the old dw if any */
layout->setWidget(dw);
- /* Clear the title bar for pages without a <TITLE> tag */
- a_UIcmd_set_page_title(Web->bw, "");
+ /* Set the page title with the bare filename (e.g. for images),
+ * HTML pages with a <TITLE> tag will overwrite it later */
+ const char *p = strrchr(URL_STR(Web->url), '/');
+ a_UIcmd_set_page_title(Web->bw, p ? p+1 : "");
+
a_UIcmd_set_location_text(Web->bw, URL_STR(Web->url));
/* Reset both progress bars */
a_UIcmd_set_page_prog(Web->bw, 0, 2);
diff --git a/src/xembed.cc b/src/xembed.cc
index 04a4362a..f180d81d 100644
--- a/src/xembed.cc
+++ b/src/xembed.cc
@@ -12,14 +12,14 @@
#include <string.h>
#include <ctype.h>
-#include <fltk/Window.h>
-#include <fltk/run.h>
-#include <fltk/events.h>
-#include <fltk/x.h>
+#define FL_INTERNALS
+#include <FL/Fl_Window.H>
+#include <FL/Fl.H>
+#include <FL/x.H>
#include "xembed.hh"
-#if USE_X11
+#ifdef X_PROTOCOL
typedef enum {
XEMBED_EMBEDDED_NOTIFY = 0,
@@ -41,12 +41,12 @@ Xembed::setXembedInfo(unsigned long flags)
{
unsigned long buffer[2];
- Atom xembed_info_atom = XInternAtom (fltk::xdisplay, "_XEMBED_INFO", false);
+ Atom xembed_info_atom = XInternAtom (fl_display, "_XEMBED_INFO", false);
buffer[0] = 1;
buffer[1] = flags;
- XChangeProperty (fltk::xdisplay,
+ XChangeProperty (fl_display,
xid,
xembed_info_atom, xembed_info_atom, 32,
PropModeReplace,
@@ -60,35 +60,36 @@ Xembed::sendXembedEvent(uint32_t message) {
memset (&xclient, 0, sizeof (xclient));
xclient.window = xid;
xclient.type = ClientMessage;
- xclient.message_type = XInternAtom (fltk::xdisplay, "_XEMBED", false);
+ xclient.message_type = XInternAtom (fl_display, "_XEMBED", false);
xclient.format = 32;
- xclient.data.l[0] = fltk::event_time;
+ xclient.data.l[0] = fl_event_time;
xclient.data.l[1] = message;
- XSendEvent(fltk::xdisplay, xid, False, NoEventMask, (XEvent *)&xclient);
- XSync(fltk::xdisplay, False);
+ XSendEvent(fl_display, xid, False, NoEventMask, (XEvent *)&xclient);
+ XSync(fl_display, False);
}
int
Xembed::handle(int e) {
- if (e == fltk::PUSH)
+ if (e == FL_PUSH)
sendXembedEvent(XEMBED_REQUEST_FOCUS);
- return Window::handle(e);
+ return Fl_Window::handle(e);
}
-static int event_handler(int e, fltk::Window *w) {
- Atom xembed_atom = XInternAtom (fltk::xdisplay, "_XEMBED", false);
+static int event_handler(int e, Fl_Window *w) {
+ Atom xembed_atom = XInternAtom (fl_display, "_XEMBED", false);
- if (fltk::xevent.type == ClientMessage) {
- if (fltk::xevent.xclient.message_type == xembed_atom) {
- long message = fltk::xevent.xclient.data.l[1];
+ if (fl_xevent->type == ClientMessage) {
+ if (fl_xevent->xclient.message_type == xembed_atom) {
+ long message = fl_xevent->xclient.data.l[1];
switch (message) {
case XEMBED_WINDOW_ACTIVATE:
// Force a ConfigureNotify message so fltk can get the new
// coordinates after a move of the embedder window.
- w->resize(0, 0, w->w(), w->h());
+ if (w)
+ w->resize(0,0, w->w(), w->h());
break;
case XEMBED_WINDOW_DEACTIVATE:
break;
@@ -98,20 +99,20 @@ static int event_handler(int e, fltk::Window *w) {
}
}
- return 0;
+ return Fl::handle_(e, w);
}
// TODO: Implement more XEMBED support;
-void Xembed::create() {
+void Xembed::show() {
createInternal(xid);
setXembedInfo(1);
- fltk::add_event_handler(event_handler);
+ Fl::event_dispatch(event_handler);
}
void Xembed::createInternal(uint32_t parent) {
- fltk::Window *window = this;
- Colormap colormap = fltk::xcolormap;
+ Fl_Window *window = this;
+ Colormap colormap = fl_colormap;
XSetWindowAttributes attr;
attr.border_pixel = 0;
@@ -133,18 +134,18 @@ void Xembed::createInternal(uint32_t parent) {
| EnterWindowMask | LeaveWindowMask
| PointerMotionMask;
- fltk::CreatedWindow::set_xid(window,
- XCreateWindow(fltk::xdisplay,
+ Fl_X::set_xid(window,
+ XCreateWindow(fl_display,
parent,
X, Y, W, H,
0, // borderwidth
- fltk::xvisual->depth,
+ fl_visual->depth,
InputOutput,
- fltk::xvisual->visual,
+ fl_visual->visual,
mask, &attr));
}
-#else // USE_X11
+#else // X_PROTOCOL
void
Xembed::setXembedInfo(unsigned long flags) {};
@@ -154,12 +155,12 @@ Xembed::sendXembedEvent(uint32_t message) {};
int
Xembed::handle(int e) {
- return Window::handle(e);
+ return Fl_Window::handle(e);
}
void
-Xembed::create() {
- Window::create();
+Xembed::show() {
+ Fl_Window::show();
}
#endif
diff --git a/src/xembed.hh b/src/xembed.hh
index 70d79c5f..d7663c8e 100644
--- a/src/xembed.hh
+++ b/src/xembed.hh
@@ -1,11 +1,11 @@
#ifndef __XEMBED_HH__
#define __XEMBED_HH__
-#include <fltk/Window.h>
+#include <FL/Fl_Window.H>
#include "d_size.h"
-class Xembed : public fltk::Window {
+class Xembed : public Fl_Window {
private:
uint32_t xid;
void createInternal(uint32_t parent);
@@ -13,10 +13,10 @@ class Xembed : public fltk::Window {
void sendXembedEvent(uint32_t message);
public:
- Xembed(uint32_t xid, int _w, int _h) : fltk::Window(_w, _h) {
+ Xembed(uint32_t xid, int _w, int _h) : Fl_Window(_w, _h) {
this->xid = xid;
};
- void create();
+ void show();
int handle(int event);
};