From 64d3ecbb49ca39a39fda0fe77732cb09a43a401c Mon Sep 17 00:00:00 2001 From: corvid Date: Thu, 6 Jan 2011 02:15:06 +0000 Subject: keys and mouse buttons --- src/findbar.cc | 22 ++++----- src/keys.cc | 140 ++++++++++++++++++++++++++++----------------------------- src/menu.cc | 4 +- src/ui.cc | 22 ++++----- src/uicmd.cc | 12 ++--- 5 files changed, 100 insertions(+), 100 deletions(-) (limited to 'src') diff --git a/src/findbar.cc b/src/findbar.cc index 8cca52ba..915d355a 100644 --- a/src/findbar.cc +++ b/src/findbar.cc @@ -35,15 +35,15 @@ int MyInput::handle(int e) { _MSG("findbar MyInput::handle()\n"); int ret = 1, k = event_key(); - unsigned modifier = event_state() & (SHIFT | CTRL | ALT | META); + unsigned modifier = event_state() & (FL_SHIFT | FL_CTRL | FL_ALT | FL_META); if (e == KEY) { - if (k == LeftKey || k == RightKey) { - if (modifier == SHIFT) { + if (k == FL_Left || k == FL_Right) { + if (modifier == FL_SHIFT) { a_UIcmd_send_event_to_tabs_by_wid(e, this); return 1; } - } 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; } @@ -92,7 +92,7 @@ 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) + if (event_key() == FL_Enter) search_cb(widget, vfb); } @@ -139,13 +139,13 @@ Findbar::Findbar(int width, int height) : next_btn = new HighlightButton(x, border, button_width, height, "Next"); x += button_width + gap; - next_btn->add_shortcut(ReturnKey); - next_btn->add_shortcut(KeypadEnter); + next_btn->add_shortcut(FL_Enter); + next_btn->add_shortcut(FL_KP_Enter); next_btn->callback(search_cb, this); next_btn->clear_tab_to_focus(); prev_btn= new HighlightButton(x, border, button_width, height, "Previous"); - prev_btn->add_shortcut(SHIFT+ReturnKey); + prev_btn->add_shortcut(FL_SHIFT+FL_Enter); prev_btn->callback(searchBackwards_cb, this); prev_btn->clear_tab_to_focus(); x += button_width + gap; @@ -172,15 +172,15 @@ 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); + unsigned modifier = event_state() & (FL_SHIFT | FL_CTRL | FL_ALT | FL_META); - if (event == KEY && modifier == 0 && k == EscapeKey) { + if (event == KEY && modifier == 0 && k == FL_Escape) { hide(); ret = 1; } diff --git a/src/keys.cc b/src/keys.cc index 1a39f4c8..a3430c72 100644 --- a/src/keys.cc +++ b/src/keys.cc @@ -38,80 +38,80 @@ 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_F1 }, + { "F2", FL_F2 }, + { "F3", FL_F3 }, + { "F4", FL_F4 }, + { "F5", FL_F5 }, + { "F6", FL_F6 }, + { "F7", FL_F7 }, + { "F8", FL_F8 }, + { "F9", FL_F9 }, + { "F10", FL_F10 }, + { "F11", FL_F11 }, + { "F12", FL_F12 }, + { "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 } }; 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 , 'q' }, + { "find" , KEYS_FIND , FL_CTRL , 'f' }, + { "websearch" , KEYS_WEBSEARCH , FL_CTRL , 's' }, + { "bookmarks" , KEYS_BOOKMARKS , FL_CTRL , 'b' }, + { "fullscreen" , KEYS_FULLSCREEN , FL_CTRL , ' ' }, + { "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_ALT , '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; @@ -174,9 +174,9 @@ KeysCommand_t Keys::getKeyCmd() KeyBinding_t keyNode; // We're only interested in some flags keyNode.modifier = fltk::event_state() & - (fltk::SHIFT | fltk::CTRL | fltk::ALT | fltk::META); + (FL_SHIFT | FL_CTRL | FL_ALT | FL_META); - if (keyNode.modifier == fltk::SHIFT && + if (keyNode.modifier == FL_SHIFT && ispunct(fltk::event_text()[0])) { // Get key code for a shifted character keyNode.key = fltk::event_text()[0]; diff --git a/src/menu.cc b/src/menu.cc index d802bddb..e032c189 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -139,7 +139,7 @@ static void Menu_open_url_nw_cb(Widget* ) static void Menu_open_url_nt_cb(Widget* ) { int focus = prefs.focus_new_tab ? 1 : 0; - if (event_state(SHIFT)) focus = !focus; + if (event_state(FL_SHIFT)) focus = !focus; a_UIcmd_open_url_nt(popup_bw, popup_url, focus); } @@ -293,7 +293,7 @@ static void Menu_history_cb(Widget *wid, void *data) // 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 (event_state(FL_SHIFT)) focus = !focus; a_UIcmd_open_url_nt(popup_bw, url, focus); } else { a_UIcmd_open_url_nw(popup_bw, url); diff --git a/src/ui.cc b/src/ui.cc index fac78604..c6ee971d 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -103,8 +103,8 @@ public: }; /* - * Disable: UpKey, DownKey, PageUpKey, PageDownKey and - * CTRL+{o,r,HomeKey,EndKey} + * Disable keys: Up, Down, Page_Up, Page_Down and + * CTRL+{o,r,Home,End} */ int CustInput::handle(int e) { @@ -113,23 +113,23 @@ int CustInput::handle(int e) _MSG("CustInput::handle event=%d\n", e); // We're only interested in some flags - unsigned modifier = event_state() & (SHIFT | CTRL | ALT); + unsigned modifier = 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)) { + (k == FL_Up || k == FL_Down || k == FL_Left || k == FL_Right)) { return 0; } else if (e == KEY) { - if (modifier == CTRL) { + if (modifier == FL_CTRL) { 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 == 'o' || k == 'r' || k == FL_Home || k == FL_End) return 0; - } else if (modifier == SHIFT) { - if (k == LeftKey || k == RightKey) { - _MSG(" CustInput::handle > SHIFT+RightKey\n"); + } else if (modifier == FL_SHIFT) { + if (k == FL_Left || k == FL_Right) { + _MSG(" CustInput::handle > FL_SHIFT+FL_Right\n"); a_UIcmd_send_event_to_tabs_by_wid(e, this); return 1; } @@ -288,7 +288,7 @@ static void location_cb(Widget *wid, void *data) * 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) { + if (event_key() == FL_Enter) { a_UIcmd_open_urlstr(a_UIcmd_get_bw_by_widget(i), i->value()); } if (ui->get_panelmode() == UI_TEMPORARILY_SHOW_PANELS) { @@ -853,7 +853,7 @@ int UI::handle(int event) } } else if (event == PUSH) { if (prefs.middle_click_drags_page == 0 && - event_button() == MiddleButton && + event_button() == FL_MIDDLE_MOUSE && !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) */ diff --git a/src/uicmd.cc b/src/uicmd.cc index 001165d6..6b3287a6 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -249,13 +249,13 @@ public: 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) { + unsigned modifier = event_state() & (FL_SHIFT | FL_CTRL | FL_ALT); + if (k == FL_Up || k == FL_Down || k == FL_Tab) { return 0; - } else if (k == LeftKey || k == RightKey) { - if (modifier == SHIFT) { + } else if (k == FL_Left || k == FL_Right) { + if (modifier == FL_SHIFT) { int i = value(); - if (k == LeftKey) {i = i ? i-1 : children()-1;} + if (k == FL_Left) {i = i ? i-1 : children()-1;} else {i++; if (i >= children()) i = 0;} selected_child(child(i)); return 1; @@ -383,7 +383,7 @@ BrowserWindow *a_UIcmd_get_bw_by_widget(void *v_wid) } /* - * FLTK regards SHIFT + {LeftKey, Right} as navigation keys. + * FLTK regards SHIFT + {Left, 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. -- cgit v1.2.3 From 728c7f38c7c45dc5e0b45526d62ba2caf44e4e73 Mon Sep 17 00:00:00 2001 From: corvid Date: Thu, 6 Jan 2011 02:51:08 +0000 Subject: events --- dw/fltkpreview.cc | 8 ++++---- dw/fltkviewbase.cc | 14 +++++++------- dw/fltkviewport.cc | 52 ++++++++++++++++++++++++++-------------------------- src/findbar.cc | 10 +++++----- src/keys.cc | 8 ++++---- src/menu.cc | 6 +++--- src/ui.cc | 36 ++++++++++++++++++------------------ src/uicmd.cc | 22 +++++++++++----------- src/xembed.cc | 2 +- 9 files changed, 79 insertions(+), 79 deletions(-) (limited to 'src') diff --git a/dw/fltkpreview.cc b/dw/fltkpreview.cc index 7096420f..b169ff6b 100644 --- a/dw/fltkpreview.cc +++ b/dw/fltkpreview.cc @@ -278,18 +278,18 @@ int FltkPreviewButton::handle (int event) /** \bug Some parts are missing. */ switch (event) { - case PUSH: + case FL_PUSH: window->showWindow (); return Button::handle (event); - case DRAG: + case FL_DRAG: if (window->visible ()) { - window->scrollTo (event_x_root (), event_y_root ()); + window->scrollTo (Fl::event_x_root (), Fl::event_y_root ()); return 1; } return Button::handle (event); - case RELEASE: + case FL_RELEASE: window->hideWindow (); return Button::handle (event); diff --git a/dw/fltkviewbase.cc b/dw/fltkviewbase.cc index cab22cf4..dcc9ed08 100644 --- a/dw/fltkviewbase.cc +++ b/dw/fltkviewbase.cc @@ -184,7 +184,7 @@ void FltkViewBase::drawChildWidgets () { core::ButtonState getDwButtonState () { - int s1 = event_state (); + int s1 = Fl::event_state (); int s2 = (core::ButtonState)0; if (s1 & SHIFT) s2 |= core::SHIFT_MASK; @@ -207,7 +207,7 @@ int FltkViewBase::handle (int event) * when passed a fltk::PUSH event. " */ switch(event) { - case PUSH: + case FL_PUSH: processed = theLayout->buttonPress (this, event_clicks () + 1, translateViewXToCanvasX (event_x ()), @@ -220,7 +220,7 @@ int FltkViewBase::handle (int event) } return processed ? true : Group::handle (event); - case RELEASE: + case FL_RELEASE: processed = theLayout->buttonRelease (this, event_clicks () + 1, translateViewXToCanvasX (event_x ()), @@ -229,7 +229,7 @@ int FltkViewBase::handle (int event) _MSG("RELEASE => %s\n", processed ? "true" : "false"); return processed ? true : Group::handle (event); - case MOVE: + case FL_MOVE: mouse_x = event_x(); mouse_y = event_y(); processed = @@ -240,7 +240,7 @@ int FltkViewBase::handle (int event) _MSG("MOVE => %s\n", processed ? "true" : "false"); return processed ? true : Group::handle (event); - case DRAG: + case FL_DRAG: processed = theLayout->motionNotify (this, translateViewXToCanvasX (event_x ()), @@ -249,13 +249,13 @@ int FltkViewBase::handle (int event) _MSG("DRAG => %s\n", processed ? "true" : "false"); return processed ? true : Group::handle (event); - case ENTER: + case FL_ENTER: theLayout->enterNotify (this, translateViewXToCanvasX (event_x ()), translateViewYToCanvasY (event_y ()), getDwButtonState ()); return Group::handle (event); - case LEAVE: + case FL_LEAVE: theLayout->leaveNotify (this, getDwButtonState ()); return Group::handle (event); diff --git a/dw/fltkviewport.cc b/dw/fltkviewport.cc index 0d6c1b46..1be6f0c0 100644 --- a/dw/fltkviewport.cc +++ b/dw/fltkviewport.cc @@ -214,87 +214,87 @@ int FltkViewport::handle (int event) { _MSG("FltkViewport::handle %d\n", event); - if (hscrollbar->Rectangle::contains (event_x (), event_y ()) && - !(event_state() & (SHIFT | CTRL | ALT)) && + if (hscrollbar->Rectangle::contains (Fl::event_x (), Fl::event_y ()) && + !(Fl::event_state() & (SHIFT | CTRL | ALT)) && hscrollbar->send (event)) { return 1; } - if (vscrollbar->Rectangle::contains (event_x (), event_y ()) && + if (vscrollbar->Rectangle::contains (Fl::event_x (), Fl::event_y ()) && vscrollbar->send (event)) { return 1; } switch(event) { - case ::fltk::KEY: - /* Tell fltk we want to receive KEY events as SHORTCUT. + case FL_KEYBOARD: + /* Tell fltk we want to receive KEYBOARD events as SHORTCUT. * As we don't know the exact keybindings set by the user, we ask * for all of them (except Tab to keep form navigation). */ - if (::fltk::event_key() != FL_Tab) + if (Fl::event_key() != FL_Tab) return 0; break; - case ::fltk::FOCUS: + case FL_FOCUS: /** \bug Draw focus box. */ /* If the user clicks with the left button we take focus * and thereby unfocus any form widgets. * Otherwise we let fltk do the focus handling. */ - if (::fltk::event_button() == FL_LEFT_MOUSE || focus_index() < 0) { + if (Fl::event_button() == FL_LEFT_MOUSE || focus_index() < 0) { focus_index(-1); return 1; } break; - case ::fltk::UNFOCUS: + case FL_UNFOCUS: /** \bug Undraw focus box. */ break; - case ::fltk::PUSH: + case FL_PUSH: take_focus(); - if (::fltk::event_button() == FL_MIDDLE_MOUSE) { + if (Fl::event_button() == FL_MIDDLE_MOUSE) { /* pass event so that middle click can open link in new window */ if (FltkWidgetView::handle (event) == 0) { dragScrolling = 1; - dragX = ::fltk::event_x(); - dragY = ::fltk::event_y(); + dragX = Fl::event_x(); + dragY = Fl::event_y(); setCursor (core::style::CURSOR_MOVE); } return 1; } break; - case ::fltk::DRAG: - if (::fltk::event_button() == FL_MIDDLE_MOUSE) { + case FL_DRAG: + if (Fl::event_button() == FL_MIDDLE_MOUSE) { if (dragScrolling) { - scroll(dragX - ::fltk::event_x(), dragY - ::fltk::event_y()); - dragX = ::fltk::event_x(); - dragY = ::fltk::event_y(); + scroll(dragX - Fl::event_x(), dragY - Fl::event_y()); + dragX = Fl::event_x(); + dragY = Fl::event_y(); return 1; } } break; - case ::fltk:: MOUSEWHEEL: - return (event_dx() ? hscrollbar : vscrollbar)->handle(event); + case FL_MOUSEWHEEL: + return (Fl::event_dx() ? hscrollbar : vscrollbar)->handle(event); break; - case ::fltk::RELEASE: - if (::fltk::event_button() == FL_MIDDLE_MOUSE) { + case FL_RELEASE: + if (Fl::event_button() == FL_MIDDLE_MOUSE) { dragScrolling = 0; setCursor (core::style::CURSOR_DEFAULT); } break; - case ::fltk::ENTER: + case FL_ENTER: /* could be the result of, e.g., closing another window. */ - mouse_x = ::fltk::event_x(); - mouse_y = ::fltk::event_y(); + mouse_x = Fl::event_x(); + mouse_y = Fl::event_y(); positionChanged(); break; - case ::fltk::LEAVE: + case FL_LEAVE: mouse_x = mouse_y = -1; break; } diff --git a/src/findbar.cc b/src/findbar.cc index 915d355a..49cffcd6 100644 --- a/src/findbar.cc +++ b/src/findbar.cc @@ -34,8 +34,8 @@ public: int MyInput::handle(int e) { _MSG("findbar MyInput::handle()\n"); - int ret = 1, k = event_key(); - unsigned modifier = event_state() & (FL_SHIFT | FL_CTRL | FL_ALT | FL_META); + int ret = 1, k = Fl::event_key(); + unsigned modifier = Fl::event_state() & (FL_SHIFT| FL_CTRL| FL_ALT|FL_META); if (e == KEY) { if (k == FL_Left || k == FL_Right) { @@ -92,7 +92,7 @@ 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() == FL_Enter) + if (Fl::event_key() == FL_Enter) search_cb(widget, vfb); } @@ -177,8 +177,8 @@ Findbar::~Findbar() int Findbar::handle(int event) { int ret = 0; - int k = event_key(); - unsigned modifier = event_state() & (FL_SHIFT | FL_CTRL | FL_ALT | FL_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 == FL_Escape) { hide(); diff --git a/src/keys.cc b/src/keys.cc index a3430c72..2343ccbb 100644 --- a/src/keys.cc +++ b/src/keys.cc @@ -173,16 +173,16 @@ KeysCommand_t Keys::getKeyCmd() KeysCommand_t ret = KEYS_NOP; KeyBinding_t keyNode; // We're only interested in some flags - keyNode.modifier = fltk::event_state() & + keyNode.modifier = Fl::event_state() & (FL_SHIFT | FL_CTRL | FL_ALT | FL_META); if (keyNode.modifier == FL_SHIFT && - ispunct(fltk::event_text()[0])) { + ispunct(Fl::event_text()[0])) { // Get key code for a shifted character - keyNode.key = fltk::event_text()[0]; + keyNode.key = Fl::event_text()[0]; keyNode.modifier = 0; } else { - keyNode.key = fltk::event_key(); + keyNode.key = Fl::event_key(); } _MSG("getKeyCmd: key=%d, mod=%d\n", keyNode.key, keyNode.modifier); diff --git a/src/menu.cc b/src/menu.cc index e032c189..37d78938 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -57,7 +57,7 @@ public: int button () { return EventButton; }; void draw(); int handle(int e) { - EventButton = event_button(); + EventButton = Fl::event_button(); return Item::handle(e); } }; @@ -139,7 +139,7 @@ static void Menu_open_url_nw_cb(Widget* ) static void Menu_open_url_nt_cb(Widget* ) { int focus = prefs.focus_new_tab ? 1 : 0; - if (event_state(FL_SHIFT)) focus = !focus; + if (Fl::event_state(FL_SHIFT)) focus = !focus; a_UIcmd_open_url_nt(popup_bw, popup_url, focus); } @@ -293,7 +293,7 @@ static void Menu_history_cb(Widget *wid, void *data) // 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(FL_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); diff --git a/src/ui.cc b/src/ui.cc index c6ee971d..7e0d19a7 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -108,18 +108,18 @@ public: */ 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() & (FL_SHIFT | FL_CTRL | FL_ALT); + unsigned modifier = Fl::event_state() & (FL_SHIFT | FL_CTRL | FL_ALT); // Don't focus with arrow keys - if (e == FOCUS && + if (e == FL_FOCUS && (k == FL_Up || k == FL_Down || k == FL_Left || k == FL_Right)) { return 0; - } else if (e == KEY) { + } else if (e == FL_KEYBOARD) { if (modifier == FL_CTRL) { if (k == 'l') { // Make text selected when already focused. @@ -154,8 +154,8 @@ public: int CustHighlightButton::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); @@ -207,7 +207,7 @@ public: */ static void search_cb(Widget *wid, void *data) { - int k = event_key(); + int k = Fl::event_key(); if (k == 1) { a_UIcmd_search_dialog(a_UIcmd_get_bw_by_widget(wid)); @@ -243,7 +243,7 @@ static void help_cb(Widget *w, void *) */ static void filemenu_cb(Widget *wid, void *) { - int k = event_key(); + int k = Fl::event_key(); if (k == 1 || k == 3) { a_UIcmd_file_popup(a_UIcmd_get_bw_by_widget(wid), wid); } @@ -256,7 +256,7 @@ static void clear_cb(Widget *w, void *data) { UI *ui = (UI*)data; - int k = event_key(); + int k = Fl::event_key(); if (k == 1) { ui->set_location(""); ui->focus_location(); @@ -288,7 +288,7 @@ static void location_cb(Widget *wid, void *data) * 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() == FL_Enter) { + if (Fl::event_key() == FL_Enter) { a_UIcmd_open_urlstr(a_UIcmd_get_bw_by_widget(i), i->value()); } if (ui->get_panelmode() == UI_TEMPORARILY_SHOW_PANELS) { @@ -303,7 +303,7 @@ static void location_cb(Widget *wid, void *data) static void b1_cb(Widget *wid, void *cb_data) { int bn = VOIDP2INT(cb_data); - int k = event_key(); + int k = Fl::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); @@ -373,7 +373,7 @@ static void b1_cb(Widget *wid, void *cb_data) */ static void bugmeter_cb(Widget *wid, void *data) { - int k = event_key(); + int k = Fl::event_key(); if (k == 1) { a_UIcmd_view_page_bugs(a_UIcmd_get_bw_by_widget(wid)); } else if (k == 3) { @@ -778,14 +778,14 @@ UI::~UI() */ int UI::handle(int event) { - _MSG("UI::handle event=%d (%d,%d)\n", event, event_x(), event_y()); + _MSG("UI::handle event=%d (%d,%d)\n", event, Fl::event_x(), Fl::event_y()); _MSG("Panel->h()=%d Main->h()=%d\n", Panel->h() , Main->h()); int ret = 0; - if (event == KEY) { + if (event == FL_KEYBOARD) { 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 @@ -851,11 +851,11 @@ int UI::handle(int event) a_Timeout_add(0.0, a_UIcmd_close_all_bw, NULL); ret = 1; } - } else if (event == PUSH) { + } else if (event == FL_PUSH) { if (prefs.middle_click_drags_page == 0 && - event_button() == FL_MIDDLE_MOUSE && + Fl::event_button() == FL_MIDDLE_MOUSE && !a_UIcmd_pointer_on_link(a_UIcmd_get_bw_by_widget(this))) { - if (Main->Rectangle::contains (event_x (), event_y ())) { + if (Main->Rectangle::contains (Fl::event_x (), Fl::event_y ())) { /* Offer the event to Main's children (form widgets) */ int save_x = e_x, save_y = e_y; diff --git a/src/uicmd.cc b/src/uicmd.cc index 6b3287a6..21b069cf 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -246,10 +246,10 @@ public: // 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(); + if (e == FL_KEYBOARD) { + int k = Fl::event_key(); // We're only interested in some flags - unsigned modifier = event_state() & (FL_SHIFT | FL_CTRL | FL_ALT); + unsigned modifier = Fl::event_state() & (FL_SHIFT | FL_CTRL | FL_ALT); if (k == FL_Up || k == FL_Down || k == FL_Tab) { return 0; } else if (k == FL_Left || k == FL_Right) { @@ -268,9 +268,9 @@ public: 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) { + } else if (e == FL_MOVE) { CustShrinkTabPager *cstp = (CustShrinkTabPager *) pager(); - if (event_inside(r) && children() > 1) { + if (Fl::event_inside(r) && children() > 1) { /* We're inside the button area */ cstp->btn_highlight(true); if (prefs.show_tooltip) { @@ -295,12 +295,12 @@ public: } } } - } else if (e == PUSH && event_inside(r) && - event_button() == 1 && children() > 1) { + } else if (e == FL_PUSH && Fl::event_inside(r) && + Fl::event_button() == 1 && children() > 1) { buttonPushed = true; return 1; /* non-zero */ - } else if (e == RELEASE) { - if (event_inside(r) && event_button() == 1 && + } else if (e == FL_RELEASE) { + if (Fl::event_inside(r) && Fl::event_button() == 1 && children() > 1 && buttonPushed) { a_UIcmd_close_bw(a_UIcmd_get_bw_by_widget(selected_child())); } else { @@ -308,13 +308,13 @@ public: cstp->btn_highlight(false); } buttonPushed = false; - } else if (e == DRAG) { + } else if (e == FL_DRAG) { /* Ignore this event */ return 1; } int ret = TabGroup::handle(e); - if (e == PUSH) { + if (e == FL_PUSH) { /* WORKAROUND: FLTK raises the window on unhandled clicks, * which we do not want. */ diff --git a/src/xembed.cc b/src/xembed.cc index 04a4362a..49828ffe 100644 --- a/src/xembed.cc +++ b/src/xembed.cc @@ -71,7 +71,7 @@ Xembed::sendXembedEvent(uint32_t message) { int Xembed::handle(int e) { - if (e == fltk::PUSH) + if (e == FL_PUSH) sendXembedEvent(XEMBED_REQUEST_FOCUS); return Window::handle(e); -- cgit v1.2.3 From 1aa8c2e16f5fea7763db6415f0684f51d01f4de3 Mon Sep 17 00:00:00 2001 From: corvid Date: Thu, 6 Jan 2011 03:09:45 +0000 Subject: when --- dw/fltkui.cc | 18 +++++++++--------- src/findbar.cc | 2 +- src/ui.cc | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/dw/fltkui.cc b/dw/fltkui.cc index ff8c7539..abf82993 100644 --- a/dw/fltkui.cc +++ b/dw/fltkui.cc @@ -262,7 +262,7 @@ FltkLabelButtonResource::~FltkLabelButtonResource () label); button->set_flag (::fltk::RAW_LABEL); button->callback (widgetCallback, this); - button->when (::fltk::WHEN_RELEASE); + button->when (FL_WHEN_RELEASE); return button; } @@ -315,7 +315,7 @@ static void setButtonEvent(dw::core::EventButton *event) void FltkLabelButtonResource::widgetCallback (::fltk::Widget *widget, void *data) { - if ((widget->when () & ::fltk::WHEN_RELEASE) && + if ((widget->when () & FL_WHEN_RELEASE) && ((Fl::event_key() == FL_Enter) || (Fl::event_button() == FL_LEFT_MOUSE || Fl::event_button() == FL_MIDDLE_MOUSE))) { @@ -363,7 +363,7 @@ void FltkComplexButtonResource::widgetCallback (::fltk::Widget *widget, { FltkComplexButtonResource *res = (FltkComplexButtonResource*)data; - if (widget->when() == ::fltk::WHEN_RELEASE && + if (widget->when() == FL_WHEN_RELEASE && ((Fl::event_key() == FL_Enter) || (Fl::event_button() == FL_LEFT_MOUSE || Fl::event_button() == FL_MIDDLE_MOUSE))) { @@ -430,7 +430,7 @@ int FltkComplexButtonResource::reliefYThickness () new ComplexButton (allocation->x, allocation->y, allocation->width, allocation->ascent + allocation->descent); button->callback (widgetCallback, this); - button->when (::fltk::WHEN_RELEASE); + button->when (FL_WHEN_RELEASE); if (!relief) button->box(::fltk::FLAT_BOX); @@ -479,7 +479,7 @@ FltkEntryResource::~FltkEntryResource () if (password) input->type(::fltk::Input::SECRET); input->callback (widgetCallback, this); - input->when (::fltk::WHEN_ENTER_KEY_ALWAYS); + input->when (FL_WHEN_ENTER_KEY_ALWAYS); if (label) { input->label(label); @@ -525,7 +525,7 @@ void FltkEntryResource::widgetCallback (::fltk::Widget *widget, * page. BUG: this must be investigated and reported to FLTK2 team */ _MSG("when = %d\n", widget->when ()); - if ((widget->when () & ::fltk::WHEN_ENTER_KEY_ALWAYS) && + if ((widget->when () & FL_WHEN_ENTER_KEY_ALWAYS) && (Fl::event_key() == FL_Enter)) ((FltkEntryResource*)data)->emitActivate (); } @@ -801,7 +801,7 @@ dw::core::ui::RadioButtonResource::GroupIterator void FltkRadioButtonResource::widgetCallback (::fltk::Widget *widget, void *data) { - if (widget->when () & ::fltk::WHEN_CHANGED) + if (widget->when () & FL_WHEN_CHANGED) ((FltkRadioButtonResource*)data)->buttonClicked (); } @@ -834,7 +834,7 @@ void FltkRadioButtonResource::buttonClicked () allocation->width, allocation->ascent + allocation->descent); button->set_flag (::fltk::RAW_LABEL); - button->when (::fltk::WHEN_CHANGED); + button->when (FL_WHEN_CHANGED); button->callback (widgetCallback, this); button->type (::fltk::Button::TOGGLE); @@ -1149,7 +1149,7 @@ FltkListResource::~FltkListResource () menu->type(::fltk::Browser::MULTI); menu->set_flag (::fltk::RAW_LABEL); menu->callback(widgetCallback,this); - menu->when(::fltk::WHEN_CHANGED); + menu->when(FL_WHEN_CHANGED); return menu; } diff --git a/src/findbar.cc b/src/findbar.cc index 49cffcd6..713b13ac 100644 --- a/src/findbar.cc +++ b/src/findbar.cc @@ -132,7 +132,7 @@ Findbar::Findbar(int width, int height) : x += input_width + gap; resizable(i); i->color(206); - i->when(WHEN_ENTER_KEY_ALWAYS); + i->when(FL_WHEN_ENTER_KEY_ALWAYS); i->callback(search_cb2, this); i->clear_tab_to_focus(); i->set_click_to_focus(); diff --git a/src/ui.cc b/src/ui.cc index 7e0d19a7..a7d2f756 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -469,7 +469,7 @@ PackedGroup *UI::make_location() Input *i = Location = new CustInput(0,0,0,0,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(); -- cgit v1.2.3 From 91a6eef96200b8449e72030c766c514b1a07785c Mon Sep 17 00:00:00 2001 From: corvid Date: Thu, 6 Jan 2011 03:38:57 +0000 Subject: some UI constants --- dw/fltkpreview.cc | 2 +- dw/fltkui.cc | 4 ++-- src/dialog.cc | 12 ++++++------ src/findbar.cc | 2 +- src/ui.cc | 32 ++++++++++++++++---------------- src/uicmd.cc | 2 +- 6 files changed, 27 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/dw/fltkpreview.cc b/dw/fltkpreview.cc index b169ff6b..0de11404 100644 --- a/dw/fltkpreview.cc +++ b/dw/fltkpreview.cc @@ -169,7 +169,7 @@ void FltkPreview::drawFltkWidget (::fltk::Widget *widget, FltkPreviewWindow::FltkPreviewWindow (dw::core::Layout *layout): MenuWindow (1, 1) { - box (EMBOSSED_BOX); + box (FL_EMBOSSED_BOX); begin (); preview = new FltkPreview (BORDER_WIDTH, BORDER_WIDTH, 1, 1, layout); diff --git a/dw/fltkui.cc b/dw/fltkui.cc index abf82993..ccccc711 100644 --- a/dw/fltkui.cc +++ b/dw/fltkui.cc @@ -432,7 +432,7 @@ int FltkComplexButtonResource::reliefYThickness () button->callback (widgetCallback, this); button->when (FL_WHEN_RELEASE); if (!relief) - button->box(::fltk::FLAT_BOX); + button->box(FL_FLAT_BOX); flatView = new FltkFlatView (allocation->x + reliefXThickness (), allocation->y + reliefYThickness (), @@ -483,7 +483,7 @@ FltkEntryResource::~FltkEntryResource () if (label) { input->label(label); - input->set_flag(::fltk::ALIGN_INSIDE_LEFT); + input->set_flag(FL_ALIGN_INSIDE); } if (initText) input->value (initText); diff --git a/src/dialog.cc b/src/dialog.cc index 47af9921..82dd1e45 100644 --- a/src/dialog.cc +++ b/src/dialog.cc @@ -197,8 +197,8 @@ int a_Dialog_choice5(const char *QuestionTxt, window->resizable(ib); Widget *box = new Widget(0,0,ww,wh-bh, QuestionTxt); - box->box(DOWN_BOX); - box->labelfont(HELVETICA_BOLD_ITALIC); + box->box(FL_DOWN_BOX); + box->labelfont(FL_HELVETICA_BOLD_ITALIC); box->labelsize(14); HighlightButton *b; @@ -207,8 +207,8 @@ int a_Dialog_choice5(const char *QuestionTxt, 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->align(FL_ALIGN_WRAP|FL_ALIGN_CLIP); + b->box(FL_UP_BOX); b->callback(choice5_cb, INT2VOIDP(i)); xpos += bw + gap; } @@ -253,9 +253,9 @@ int a_Dialog_user_password(const char *message, UserPasswordCB cb, void *vp) /* message */ WordwrapOutput *message_output = new WordwrapOutput(20,20,window_w-40,100); - message_output->box(DOWN_BOX); + message_output->box(FL_DOWN_BOX); message_output->text(message); - message_output->textfont(HELVETICA_BOLD_ITALIC); + message_output->textfont(FL_HELVETICA_BOLD_ITALIC); message_output->textsize(14); /* inputs */ diff --git a/src/findbar.cc b/src/findbar.cc index 713b13ac..84396954 100644 --- a/src/findbar.cc +++ b/src/findbar.cc @@ -117,7 +117,7 @@ Findbar::Findbar(int width, int height) : int x = border; height -= 2 * border; - box(PLASTIC_UP_BOX); + box(FL_PLASTIC_UP_BOX); Group::hide(); begin(); diff --git a/src/ui.cc b/src/ui.cc index a7d2f756..a17b2376 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -505,12 +505,12 @@ PackedGroup *UI::make_progress_bars(int wide, int thin_up) ProgBox->begin(); // Images IProg = new CustProgressBox(0,0,0,0); - IProg->box(thin_up ? THIN_UP_BOX : EMBOSSED_BOX); + IProg->box(thin_up ? FL_THIN_UP_BOX : FL_EMBOSSED_BOX); IProg->labelcolor(GRAY10); IProg->update_label(wide ? "Images\n0 of 0" : "0 of 0"); // Page PProg = new CustProgressBox(0,0,0,0); - PProg->box(thin_up ? THIN_UP_BOX : EMBOSSED_BOX); + PProg->box(thin_up ? FL_THIN_UP_BOX : FL_EMBOSSED_BOX); PProg->labelcolor(GRAY10); PProg->update_label(wide ? "Page\n0.0KB" : "0.0KB"); ProgBox->type(PackedGroup::ALL_CHILDREN_VERTICAL); @@ -537,7 +537,7 @@ Widget *UI::make_filemenu_button() h = fh; btn->resize(w+padding,h); _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_FLAT_BOX : FL_THIN_UP_BOX); btn->callback(filemenu_cb, this); if (prefs.show_tooltip) btn->tooltip("File menu"); @@ -593,7 +593,7 @@ Group *UI::make_panel(int ww) g1 = new Group(0,0,ww,bh); // Toolbar pg = make_toolbar(ww,bh); - pg->box(EMBOSSED_BOX); + pg->box(FL_EMBOSSED_BOX); g1->add(pg); w = make_filemenu_button(); pg->add(w); @@ -611,7 +611,7 @@ Group *UI::make_panel(int ww) // File menu if (PanelSize == P_large) { g3 = new Group(0,0,ww,lh); - g3->box(FLAT_BOX); + g3->box(FL_FLAT_BOX); Widget *bn = make_filemenu_button(); g3->add(bn); g3->add_resizable(*new InvisibleBox(bn->w(),0,ww - bn->w(),lh)); @@ -648,8 +648,8 @@ Group *UI::make_panel(int ww) pg->add(w); g3->resizable(pg); // Better than 'w3' and it also works - pg->box(BORDER_FRAME); - //g3->box(EMBOSSED_BOX); + pg->box(FL_BORDER_FRAME); + //g3->box(FL_EMBOSSED_BOX); g3->end(); g1->resizable(g3); @@ -670,7 +670,7 @@ Group *UI::make_status_panel(int ww) // Status box Status = new Output(0, 0, ww-bm_w, s_h, 0); Status->value(""); - Status->box(THIN_DOWN_BOX); + Status->box(FL_THIN_DOWN_BOX); Status->clear_click_to_focus(); Status->clear_tab_to_focus(); Status->color(GRAY80); @@ -680,8 +680,8 @@ Group *UI::make_status_panel(int ww) // 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); + BugMeter->box(FL_THIN_DOWN_BOX); + BugMeter->align(FL_ALIGN_INSIDE|FL_ALIGN_CLIP|FL_ALIGN_LEFT); if (prefs.show_tooltip) BugMeter->tooltip("Show HTML bugs\n(right-click for menu)"); BugMeter->callback(bugmeter_cb, this); @@ -731,12 +731,12 @@ UI::UI(int x, int y, int ww, int wh, const char* label, const UI *cur_ui) : // Render area Main = new Widget(0,0,1,1,"Welcome..."); - Main->box(FLAT_BOX); + Main->box(FL_FLAT_BOX); Main->color(GRAY15); - Main->labelfont(HELVETICA_BOLD_ITALIC); + Main->labelfont(FL_HELVETICA_BOLD_ITALIC); Main->labelsize(36); - Main->labeltype(SHADOW_LABEL); - Main->labelcolor(WHITE); + Main->labeltype(FL_SHADOW_LABEL); + Main->labelcolor(FL_WHITE); TopGroup->add(Main); TopGroup->resizable(Main); MainIdx = TopGroup->find(Main); @@ -1117,8 +1117,8 @@ void UI::set_render_layout(Widget &nw) TopGroup->replace(MainIdx, nw); delete(Main); Main = &nw; - //TopGroup->box(DOWN_BOX); - //TopGroup->box(BORDER_FRAME); + //TopGroup->box(FL_DOWN_BOX); + //TopGroup->box(FL_BORDER_FRAME); TopGroup->resizable(TopGroup->child(MainIdx)); } diff --git a/src/uicmd.cc b/src/uicmd.cc index 21b069cf..bfc35ed9 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -89,7 +89,7 @@ public: setcolor(btn_hl ? 206 : GRAY75); fillrect(r); if (btn_hl) { - setcolor(WHITE); + setcolor(FL_WHITE); strokerect(r); } setcolor(GRAY10); -- cgit v1.2.3 From 097cdeb3184d97c5caead5a59a8a73bc597e82e0 Mon Sep 17 00:00:00 2001 From: corvid Date: Thu, 6 Jan 2011 04:01:40 +0000 Subject: some dialog.cc changes --- src/dialog.cc | 89 ++++++++++++++++++++++++++++------------------------------- 1 file changed, 42 insertions(+), 47 deletions(-) (limited to 'src') diff --git a/src/dialog.cc b/src/dialog.cc index 82dd1e45..6715f690 100644 --- a/src/dialog.cc +++ b/src/dialog.cc @@ -13,30 +13,27 @@ #include // for rint() -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include "msg.h" #include "dialog.hh" #include "misc.h" #include "prefs.h" -using namespace fltk; - /* * Close dialog window. */ -static void window_close_cb(Widget *, void *vwin) +static void window_close_cb(Fl_Widget *, void *vwin) { - delete (Window*)vwin; + delete (Fl_Window*)vwin; } /* @@ -44,7 +41,7 @@ static void window_close_cb(Widget *, void *vwin) */ void a_Dialog_msg(const char *msg) { - message("%s", msg); + fl_message("%s", msg); } /* @@ -56,7 +53,7 @@ void a_Dialog_msg(const char *msg) int a_Dialog_choice3(const char *msg, const char *b0, const char *b1, const char *b2) { - return choice(msg, b0, b1, b2); + return fl_choice(msg, b0, b1, b2); } /* @@ -64,7 +61,7 @@ int a_Dialog_choice3(const char *msg, */ const char *a_Dialog_input(const char *msg) { - return input("%s", "", msg); + return fl_input("%s", "", msg); } /* @@ -72,7 +69,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 +80,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); } /* @@ -111,12 +108,8 @@ 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; } @@ -130,11 +123,11 @@ void a_Dialog_text_window(const char *txt, const char *title) int lines, line_num_width; Font *textfont = font(prefs.font_monospace, 0); - Window *window = new Window(ww, wh, title ? title : "Untitled"); + Fl_Window *window = new Fl_Window(ww, wh, title ? title : "Untitled"); window->callback(window_close_cb, window); window->begin(); - TextDisplay *td = new TextDisplay(0,0,ww, wh-bh); + Fl_Text_Display *td = new Fl_Text_Display(0,0,ww, wh-bh); td->buffer()->text(txt); if (textfont) @@ -154,7 +147,7 @@ void a_Dialog_text_window(const char *txt, const char *title) /* WORKAROUND: FLTK may not display all the lines without this */ td->resize(ww+1,wh-bh); - ReturnButton *b = new ReturnButton (0, wh-bh, ww, bh, "Close"); + Fl_Return_Button *b = new Fl_Return_Button (0, wh-bh, ww, bh, "Close"); b->callback(window_close_cb, window); window->resizable(td); @@ -165,7 +158,7 @@ void a_Dialog_text_window(const char *txt, const char *title) /*--------------------------------------------------------------------------*/ 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); @@ -190,23 +183,23 @@ int a_Dialog_choice5(const char *QuestionTxt, txt[4] = alt4; txt[5] = alt5; for (int i=1; txt[i]; ++i, ++nb) ; - Window *window = new Window(ww,wh,"Choice5"); + Fl_Window *window = new Fl_Window(ww,wh,"Choice5"); 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); + Fl_Box *box = new Fl_Box(0,0,ww,wh-bh, QuestionTxt); box->box(FL_DOWN_BOX); box->labelfont(FL_HELVETICA_BOLD_ITALIC); box->labelsize(14); - 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 = 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)); @@ -227,7 +220,7 @@ int a_Dialog_choice5(const char *QuestionTxt, /* * 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 *vIntPtr) { int ret = VOIDP2INT(vIntPtr); _MSG("Dialog_user_password_cb: %d\n", ret); @@ -246,38 +239,40 @@ int a_Dialog_user_password(const char *message, UserPasswordCB cb, void *vp) input_x = 80, input_w = 200, input_h = 30, button_y = 230, button_h = 30; - Window *window = - new Window(window_w,window_h,"User/Password"); + Fl_Window *window = + new Fl_Window(window_w,window_h,"User/Password"); window->begin(); /* message */ - WordwrapOutput *message_output = - new WordwrapOutput(20,20,window_w-40,100); + Fl_Output *message_output = + new Fl_Output(20,20,window_w-40,100); + /* BUG type() not tested */ + message_output->type(FL_NORMAL_OUTPUT | FL_INPUT_WRAP); message_output->box(FL_DOWN_BOX); message_output->text(message); message_output->textfont(FL_HELVETICA_BOLD_ITALIC); message_output->textsize(14); /* inputs */ - Input *user_input = - new Input(input_x,140,input_w,input_h,"User"); + Fl_Input *user_input = + new Fl_Input(input_x,140,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"); + Fl_Secret_Input *password_input = + new Fl_Secret_Input(input_x,180,input_w,input_h,"Password"); password_input->labelsize(14); password_input->textsize(14); /* "OK" button */ - Button *ok_button = - new Button(200,button_y,50,button_h,"OK"); + Fl_Button *ok_button = + new Fl_Button(200,button_y,50,button_h,"OK"); ok_button->labelsize(14); ok_button->callback(Dialog_user_password_cb); ok_button->user_data(INT2VOIDP(1)); /* "Cancel" button */ - Button *cancel_button = - new Button(50,button_y,100,button_h,"Cancel"); + Fl_Button *cancel_button = + new Fl_Button(50,button_y,100,button_h,"Cancel"); cancel_button->labelsize(14); cancel_button->callback(Dialog_user_password_cb); cancel_button->user_data(INT2VOIDP(0)); -- cgit v1.2.3 From 96225ec746f55d8d67d92a885115a69aeabeaac7 Mon Sep 17 00:00:00 2001 From: corvid Date: Thu, 6 Jan 2011 04:49:54 +0000 Subject: findbar --- src/findbar.cc | 64 +++++++++++++++++++++++++++------------------------------- src/findbar.hh | 33 +++++++++++++++--------------- 2 files changed, 46 insertions(+), 51 deletions(-) (limited to 'src') diff --git a/src/findbar.cc b/src/findbar.cc index 84396954..d02bc5d4 100644 --- a/src/findbar.cc +++ b/src/findbar.cc @@ -9,8 +9,8 @@ * (at your option) any later version. */ -#include -#include +#include +#include #include "findbar.hh" #include "msg.h" @@ -18,16 +18,14 @@ #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); }; @@ -37,7 +35,7 @@ int MyInput::handle(int e) int ret = 1, k = Fl::event_key(); unsigned modifier = Fl::event_state() & (FL_SHIFT| FL_CTRL| FL_ALT|FL_META); - if (e == KEY) { + if (e == FL_KEYBOARD) { if (k == FL_Left || k == FL_Right) { if (modifier == FL_SHIFT) { a_UIcmd_send_event_to_tabs_by_wid(e, this); @@ -50,17 +48,17 @@ int MyInput::handle(int e) } 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') { @@ -86,7 +84,7 @@ void Findbar::searchBackwards_cb(Widget *, void *vfb) /* * Find next occurrence of input key */ -void Findbar::search_cb2(Widget *widget, void *vfb) +void Findbar::search_cb2(Fl_Widget *widget, void *vfb) { /* * Somehow fltk even regards the first loss of focus for the @@ -99,7 +97,7 @@ void Findbar::search_cb2(Widget *widget, void *vfb) /* * Hide the search bar */ -void Findbar::hide_cb(Widget *, void *vfb) +void Findbar::hide_cb(Fl_Widget *, void *vfb) { ((Findbar *)vfb)->hide(); } @@ -108,7 +106,7 @@ 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; @@ -118,15 +116,15 @@ Findbar::Findbar(int width, int height) : height -= 2 * border; box(FL_PLASTIC_UP_BOX); - Group::hide(); + Fl_Group::hide(); 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(); i = new MyInput(x, border, input_width, height); x += input_width + gap; @@ -134,25 +132,23 @@ Findbar::Findbar(int width, int height) : i->color(206); i->when(FL_WHEN_ENTER_KEY_ALWAYS); i->callback(search_cb2, this); - i->clear_tab_to_focus(); - i->set_click_to_focus(); + i->clear_visible_focus(); - 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(FL_Enter); - next_btn->add_shortcut(FL_KP_Enter); + next_btn->shortcut(FL_Enter); next_btn->callback(search_cb, this); - next_btn->clear_tab_to_focus(); + next_btn->clear_visible_focus(); - prev_btn= new HighlightButton(x, border, button_width, height, "Previous"); - prev_btn->add_shortcut(FL_SHIFT+FL_Enter); + prev_btn= new Fl_Button(x, border, button_width, height, "Previous"); + prev_btn->shortcut(FL_SHIFT+FL_Enter); prev_btn->callback(searchBackwards_cb, this); - prev_btn->clear_tab_to_focus(); + prev_btn->clear_visible_focus(); x += button_width + gap; - 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(); + check_btn->clear_visible_focus(); x += 2 * button_width + gap; end(); @@ -180,13 +176,13 @@ int Findbar::handle(int event) int k = Fl::event_key(); unsigned modifier = Fl::event_state() & (FL_SHIFT| FL_CTRL| FL_ALT|FL_META); - if (event == KEY && modifier == 0 && k == FL_Escape) { + 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 +192,7 @@ int Findbar::handle(int event) */ void Findbar::show() { - Group::show(); + Fl_Group::show(); /* select text even if already focused */ i->take_focus(); i->position(i->size(), 0); @@ -209,7 +205,7 @@ void Findbar::hide() { BrowserWindow *bw; - Group::hide(); + Fl_Group::hide(); if ((bw = a_UIcmd_get_bw_by_widget(this))) a_UIcmd_findtext_reset(bw); a_UIcmd_focus_main_area(bw); diff --git a/src/findbar.hh b/src/findbar.hh index ba7ed8ed..77d4a685 100644 --- a/src/findbar.hh +++ b/src/findbar.hh @@ -1,28 +1,27 @@ #ifndef __FINDBAR_HH__ #define __FINDBAR_HH__ -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include /* * 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 search_cb2 (Fl_Widget *, void *); + static void hide_cb (Fl_Widget *, void *); public: Findbar(int width, int height); -- cgit v1.2.3 From 14291040084927ff783a115df31895192cac4e65 Mon Sep 17 00:00:00 2001 From: corvid Date: Thu, 6 Jan 2011 06:03:25 +0000 Subject: some dillo.cc --- src/dillo.cc | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/dillo.cc b/src/dillo.cc index 3159674e..caf15248 100644 --- a/src/dillo.cc +++ b/src/dillo.cc @@ -24,10 +24,8 @@ #include #include -#include -#include -#include -#include +#include +#include #include "msg.h" #include "paths.hh" @@ -318,10 +316,7 @@ int main(int argc, char **argv) } // Sets WM_CLASS hint on X11 - fltk::Window::xclass("dillo"); - - // WORKAROUND: sometimes the default pager triggers redraw storms - fltk::TabGroup::default_pager(fltk::PAGER_SHRINK); + Fl_Window::default_xclass("dillo"); checkPreferredFonts(); /* use preferred font for UI */ @@ -369,7 +364,7 @@ int main(int argc, char **argv) } } - fltk::run(); + Fl::run(); /* * Memory deallocating routines -- cgit v1.2.3 From d5fc09282877f18ebccde82048f165840b8fa6c1 Mon Sep 17 00:00:00 2001 From: corvid Date: Thu, 6 Jan 2011 06:12:23 +0000 Subject: keys --- src/keys.cc | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/keys.cc b/src/keys.cc index 2343ccbb..d71c74bf 100644 --- a/src/keys.cc +++ b/src/keys.cc @@ -9,7 +9,7 @@ * (at your option) any later version. */ -#include +#include #include #include /* strtol */ #include @@ -43,18 +43,18 @@ static const Mapping_t keyNames[] = { { "Down", FL_Down }, { "End", FL_End }, { "Esc", FL_Escape }, - { "F1", FL_F1 }, - { "F2", FL_F2 }, - { "F3", FL_F3 }, - { "F4", FL_F4 }, - { "F5", FL_F5 }, - { "F6", FL_F6 }, - { "F7", FL_F7 }, - { "F8", FL_F8 }, - { "F9", FL_F9 }, - { "F10", FL_F10 }, - { "F11", FL_F11 }, - { "F12", FL_F12 }, + { "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 }, -- cgit v1.2.3 From 56a52362e9b10d271c75d9cbd4833a791752b554 Mon Sep 17 00:00:00 2001 From: corvid Date: Thu, 6 Jan 2011 06:19:52 +0000 Subject: timeout --- src/timeout.cc | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src') 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 +#include #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); } /* -- cgit v1.2.3 From 9464c3387e5aae945a52dd62646e4def0e0fd9a9 Mon Sep 17 00:00:00 2001 From: corvid Date: Thu, 6 Jan 2011 06:36:39 +0000 Subject: utf8 --- src/utf8.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/utf8.cc b/src/utf8.cc index 0138c616..a4a8504b 100644 --- a/src/utf8.cc +++ b/src/utf8.cc @@ -9,7 +9,7 @@ * (at your option) any later version. */ -#include +#include #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); } /* -- cgit v1.2.3 From dfc472816706b5e6a3e2c42f7c83503d01aaeb87 Mon Sep 17 00:00:00 2001 From: corvid Date: Thu, 6 Jan 2011 06:48:31 +0000 Subject: iowatch --- src/IO/iowatch.cc | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src') 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 +#include #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); } -- cgit v1.2.3 From a3777e2c753de7b7587384f14a5b3846bbc9e50a Mon Sep 17 00:00:00 2001 From: corvid Date: Thu, 6 Jan 2011 18:36:36 +0000 Subject: RAW_LABEL is SHORTCUT_LABEL --- dw/fltkui.cc | 14 +++++++------- src/menu.cc | 2 +- src/ui.cc | 2 +- src/uicmd.cc | 1 - 4 files changed, 9 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/dw/fltkui.cc b/dw/fltkui.cc index ccccc711..8c8f5aad 100644 --- a/dw/fltkui.cc +++ b/dw/fltkui.cc @@ -260,7 +260,7 @@ FltkLabelButtonResource::~FltkLabelButtonResource () new ::fltk::Button (allocation->x, allocation->y, allocation->width, allocation->ascent + allocation->descent, label); - button->set_flag (::fltk::RAW_LABEL); + button->clear_flag (SHORTCUT_LABEL); button->callback (widgetCallback, this); button->when (FL_WHEN_RELEASE); return button; @@ -720,7 +720,7 @@ FltkCheckButtonResource::~FltkCheckButtonResource () ::fltk::CheckButton *cb = new ::fltk::CheckButton (allocation->x, allocation->y, allocation->width, allocation->ascent + allocation->descent); - cb->set_flag (::fltk::RAW_LABEL); + cb->clear_flag (SHORTCUT_LABEL); return cb; } @@ -833,7 +833,7 @@ void FltkRadioButtonResource::buttonClicked () new ::fltk::RadioButton (allocation->x, allocation->y, allocation->width, allocation->ascent + allocation->descent); - button->set_flag (::fltk::RAW_LABEL); + button->clear_flag (SHORTCUT_LABEL); button->when (FL_WHEN_CHANGED); button->callback (widgetCallback, this); button->type (::fltk::Button::TOGGLE); @@ -864,7 +864,7 @@ template ::fltk::Item *FltkSelectionResource::Item::createNewWidget (int index) { ::fltk::Item *item = new ::fltk::Item (name); - item->set_flag (::fltk::RAW_LABEL); + item->clear_flag (SHORTCUT_LABEL); item->user_data ((void *) index); return item; } @@ -874,7 +874,7 @@ template FltkSelectionResource::Item::createNewGroupWidget () { ::fltk::ItemGroup *itemGroup = new ::fltk::ItemGroup (name); - itemGroup->set_flag (::fltk::RAW_LABEL); + itemGroup->clear_flag (SHORTCUT_LABEL); itemGroup->user_data ((void *) -1L); return itemGroup; } @@ -1076,7 +1076,7 @@ FltkOptionMenuResource::~FltkOptionMenuResource () new ::fltk::Choice (allocation->x, allocation->y, allocation->width, allocation->ascent + allocation->descent); - menu->set_flag (::fltk::RAW_LABEL); + menu->clear_flag (SHORTCUT_LABEL); menu->callback(widgetCallback,this); return menu; } @@ -1147,7 +1147,7 @@ FltkListResource::~FltkListResource () allocation->ascent + allocation->descent); if (mode == SELECTION_MULTIPLE) menu->type(::fltk::Browser::MULTI); - menu->set_flag (::fltk::RAW_LABEL); + menu->clear_flag (SHORTCUT_LABEL); menu->callback(widgetCallback,this); menu->when(FL_WHEN_CHANGED); return menu; diff --git a/src/menu.cc b/src/menu.cc index 37d78938..37ddd3f1 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -412,7 +412,7 @@ void a_Menu_page_popup(BrowserWindow *bw, const DilloUrl *url, } i = new Item(label); - i->set_flag(RAW_LABEL); + i->clear_flag(SHORTCUT_LABEL); i->user_data(a_Url_dup(url)); i->callback(Menu_stylesheet_cb); stylesheets->add(i); diff --git a/src/ui.cc b/src/ui.cc index a17b2376..c46021ea 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -705,7 +705,7 @@ UI::UI(int x, int y, int ww, int wh, const char* label, const UI *cur_ui) : TopGroup = new PackedGroup(0, 0, ww, wh); add(TopGroup); resizable(TopGroup); - set_flag(RAW_LABEL); + clear_flag(SHORTCUT_LABEL); if (cur_ui) { PanelSize = cur_ui->PanelSize; diff --git a/src/uicmd.cc b/src/uicmd.cc index bfc35ed9..c0f18487 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -421,7 +421,6 @@ BrowserWindow *a_UIcmd_browser_window_new(int ww, int 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); -- cgit v1.2.3 From 835160c63ccad20bc37cb5b01d63f0bdb0d9e16e Mon Sep 17 00:00:00 2001 From: corvid Date: Fri, 7 Jan 2011 05:50:50 +0000 Subject: trivial bits of menu --- src/menu.cc | 62 +++++++++++++++++++++++++++++-------------------------------- 1 file changed, 29 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/menu.cc b/src/menu.cc index 37ddd3f1..4090e1ae 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -11,11 +11,7 @@ // Functions/Methods for menus -#include -#include -#include -#include -#include +#include #include "lout/misc.hh" /* SimpleVector */ #include "msg.h" @@ -81,7 +77,7 @@ void CustItem::draw() { /* * Static function for File menu callbacks. */ -static void filemenu_cb(Widget *wid, void *data) +static void filemenu_cb(Fl_Widget *wid, void *data) { if (strcmp((char*)data, "nw") == 0) { UI *ui = (UI*)popup_bw->ui; @@ -100,13 +96,13 @@ static void filemenu_cb(Widget *wid, void *data) } -static void Menu_copy_urlstr_cb(Widget *) +static void Menu_copy_urlstr_cb(Fl_Widget *) { 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 +114,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* ) { _MSG("Open URL cb: click! :-)\n"); a_UIcmd_open_url(popup_bw, popup_url); @@ -127,7 +123,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* ) { _MSG("Open URL in new window cb: click! :-)\n"); a_UIcmd_open_url_nw(popup_bw, popup_url); @@ -136,7 +132,7 @@ 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* ) { int focus = prefs.focus_new_tab ? 1 : 0; if (Fl::event_state(FL_SHIFT)) focus = !focus; @@ -146,7 +142,7 @@ static void Menu_open_url_nt_cb(Widget* ) /* * Add bookmark */ -static void Menu_add_bookmark_cb(Widget* ) +static void Menu_add_bookmark_cb(Fl_Widget* ) { a_UIcmd_add_bookmark(popup_bw, popup_url); } @@ -154,7 +150,7 @@ static void Menu_add_bookmark_cb(Widget* ) /* * Find text */ -static void Menu_find_text_cb(Widget* ) +static void Menu_find_text_cb(Fl_Widget* ) { ((UI *)popup_bw->ui)->set_findbar_visibility(1); } @@ -162,7 +158,7 @@ static void Menu_find_text_cb(Widget* ) /* * Save link */ -static void Menu_save_link_cb(Widget* ) +static void Menu_save_link_cb(Fl_Widget* ) { a_UIcmd_save_link(popup_bw, popup_url); } @@ -170,7 +166,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* ) { a_UIcmd_save(popup_bw); } @@ -178,7 +174,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* ) { a_UIcmd_view_page_source(popup_bw, popup_url); } @@ -186,7 +182,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* ) { a_UIcmd_view_page_bugs(popup_bw); } @@ -194,7 +190,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,7 +202,7 @@ 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 *v_form) { void *doc = a_Bw_get_url_doc(popup_bw, popup_url); @@ -217,7 +213,7 @@ static void Menu_form_submit_cb(Widget*, void *v_form) /* * Reset form */ -static void Menu_form_reset_cb(Widget*, void *v_form) +static void Menu_form_reset_cb(Fl_Widget*, void *v_form) { void *doc = a_Bw_get_url_doc(popup_bw, popup_url); @@ -228,7 +224,7 @@ static void Menu_form_reset_cb(Widget*, void *v_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 *w, void *user_data) { void *v_form = w->parent()->user_data(); bool visible = *((bool *) user_data); @@ -238,7 +234,7 @@ static void Menu_form_hiddens_cb(Widget *w, void *user_data) a_Html_form_display_hiddens(doc, v_form, !visible); } -static void Menu_stylesheet_cb(Widget *w, void *vUrl) +static void Menu_stylesheet_cb(Fl_Widget *w, void *vUrl) { const DilloUrl *url = (const DilloUrl *) vUrl; a_UIcmd_open_url(popup_bw, url); @@ -247,7 +243,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* ) { Dstr *dstr = dStr_sized_new(128); @@ -260,7 +256,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* ) { Dstr *dstr = dStr_sized_new(128); @@ -274,7 +270,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* ) { a_UIcmd_open_urlstr(popup_bw, "http://www.dillo.org/help/bug_meter.html"); } @@ -283,7 +279,7 @@ 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 *wid, void *data) { int mb = ((CustItem*)wid)->button(); int offset = history_direction * VOIDP2INT(data); @@ -384,7 +380,7 @@ void a_Menu_page_popup(BrowserWindow *bw, const DilloUrl *url, int n = stylesheets->children(); for (j = 0; j < n; j++) { /* get rid of the old ones */ - Widget *child = stylesheets->child(0); + Fl_Widget *child = stylesheets->child(0); dFree((char *)child->label()); a_Url_free((DilloUrl *)child->user_data()); delete child; @@ -567,7 +563,7 @@ 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; + Fl_Widget *wid = (Fl_Widget*)v_wid; // One menu for every browser window static PopupMenu *pm = 0; @@ -575,7 +571,7 @@ void a_Menu_file_popup(BrowserWindow *bw, void *v_wid) popup_x = wid->x(); popup_y = wid->y() + wid->h() + // WORKAROUND: ?? wid->y() doesn't count tabs ?? - (((Group*)ui->tabs())->children() > 1 ? 20 : 0); + (((Fl_Group*)ui->tabs())->children() > 1 ? 20 : 0); a_Url_free(popup_url); popup_url = NULL; @@ -679,7 +675,7 @@ void a_Menu_history_popup(BrowserWindow *bw, int direction) /* * Toggle use of remote stylesheets */ -static void Menu_remote_css_cb(Widget *wid) +static void Menu_remote_css_cb(Fl_Widget *wid) { _MSG("Menu_remote_css_cb\n"); prefs.load_stylesheets = wid->state() ? 1 : 0; @@ -689,7 +685,7 @@ static void Menu_remote_css_cb(Widget *wid) /* * Toggle use of embedded CSS style */ -static void Menu_embedded_css_cb(Widget *wid) +static void Menu_embedded_css_cb(Fl_Widget *wid) { prefs.parse_embedded_css = wid->state() ? 1 : 0; a_UIcmd_repush(popup_bw); @@ -698,7 +694,7 @@ static void Menu_embedded_css_cb(Widget *wid) /* * 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) { if ((prefs.load_images = wid->state() ? 1 : 0)) { void *doc = a_Bw_get_current_doc(popup_bw); @@ -717,7 +713,7 @@ 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; + Fl_Widget *wid = (Fl_Widget*)v_wid; Item *it; popup_bw = bw; -- cgit v1.2.3 From 3ee62eff466beae0648a03fd18f991b9c7160462 Mon Sep 17 00:00:00 2001 From: corvid Date: Fri, 7 Jan 2011 12:32:16 +0000 Subject: a bit of src/ui --- src/ui.cc | 176 ++++++++++++++++++++++++++++---------------------------------- src/ui.hh | 50 +++++++++--------- 2 files changed, 103 insertions(+), 123 deletions(-) (limited to 'src') diff --git a/src/ui.cc b/src/ui.cc index c46021ea..482ad0f7 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -14,34 +14,20 @@ #include #include -#include -#include -#include -#include -#include // for mouse buttons and keys -#include // UI label font for tabs -#include -#include -#include -#include - #include "keys.hh" #include "ui.hh" #include "msg.h" #include "timeout.hh" #include "utf8.hh" -using namespace fltk; - - // Include image data #include "pixmaps.h" #include "uicmd.hh" struct iconset { - Image *ImgMeterOK, *ImgMeterBug, - *ImgHome, *ImgReload, *ImgSave, *ImgBook, *ImgTools, - *ImgClear,*ImgSearch, *ImgHelp; + Fl_Image *ImgMeterOK, *ImgMeterBug, + *ImgHome, *ImgReload, *ImgSave, *ImgBook, *ImgTools, + *ImgClear,*ImgSearch, *ImgHelp; MultiImage *ImgLeftMulti, *ImgRightMulti, *ImgStopMulti; }; @@ -95,10 +81,10 @@ 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); }; @@ -137,7 +123,7 @@ int CustInput::handle(int e) } _MSG("\n"); - return Input::handle(e); + return Fl_Input::handle(e); } //---------------------------------------------------------------------------- @@ -145,14 +131,14 @@ int CustInput::handle(int e) /* * Used to handle "paste" within the toolbar's Clear button. */ -class CustHighlightButton : public HighlightButton { +class CustButton : public Fl_Button { public: - CustHighlightButton(int x, int y, int w, int h, const char *l=0) : - HighlightButton(x,y,w,h,l) {}; + CustButton(int x, int y, int w, int h, const char *l=0) : + Fl_Button(x,y,w,h,l) {}; int handle(int e); }; -int CustHighlightButton::handle(int e) +int CustButton::handle(int e) { if (e == FL_PASTE) { const char* t = Fl::event_text(); @@ -162,7 +148,7 @@ int CustHighlightButton::handle(int e) return 1; } } - return HighlightButton::handle(e); + return Fl_Button::handle(e); } //---------------------------------------------------------------------------- @@ -170,11 +156,11 @@ 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; if (!padding) { @@ -205,7 +191,7 @@ 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 = Fl::event_key(); @@ -221,7 +207,7 @@ static void search_cb(Widget *wid, void *data) /* * 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); @@ -241,7 +227,7 @@ 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 = Fl::event_key(); if (k == 1 || k == 3) { @@ -252,7 +238,7 @@ 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; @@ -268,7 +254,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,7 +264,7 @@ 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; UI *ui = (UI*)data; @@ -300,7 +286,7 @@ 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 = Fl::event_key(); @@ -361,7 +347,7 @@ static void b1_cb(Widget *wid, void *cb_data) /* * Callback handler for fullscreen button press */ -//static void fullscreen_cb(Widget *wid, void *data) +//static void fullscreen_cb(Fl_Widget *wid, void *data) //{ // /* TODO: do we want to toggle fullscreen or panelmode? // maybe we need to add another button?*/ @@ -371,7 +357,7 @@ static void b1_cb(Widget *wid, void *cb_data) /* * 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 = Fl::event_key(); if (k == 1) { @@ -392,53 +378,52 @@ static void bugmeter_cb(Widget *wid, void *data) /* * Create the archetipic browser buttons */ -PackedGroup *UI::make_toolbar(int tw, int th) +Fl_Pack *UI::make_toolbar(int tw, int th) { - HighlightButton *b; - PackedGroup *p1=new PackedGroup(0,0,tw,th); + Fl_Button *b; + Fl_Pack *p1=new Fl_Pack(0,0,tw,th); p1->begin(); - Back = b = new HighlightButton(xpos, 0, bw, bh, (lbl) ? "Back" : 0); + Back = b = new Fl_Button(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); + b->clear_visible_focus(); - Forw = b = new HighlightButton(xpos, 0, bw, bh, (lbl) ? "Forw" : 0); + Forw = b = new Fl_Button(xpos, 0, bw, bh, (lbl) ? "Forw" : 0); b->image(icons->ImgRightMulti); b->callback(b1_cb, (void *)UI_FORW); - b->clear_tab_to_focus(); + b->clear_visible_focus(); - Home = b = new HighlightButton(xpos, 0, bw, bh, (lbl) ? "Home" : 0); + Home = b = new Fl_Button(xpos, 0, bw, bh, (lbl) ? "Home" : 0); b->image(icons->ImgHome); b->callback(b1_cb, (void *)UI_HOME); - b->clear_tab_to_focus(); + b->clear_visible_focus(); - Reload = b = new HighlightButton(xpos, 0, bw, bh, (lbl) ? "Reload" : 0); + Reload = b = new Fl_Button(xpos, 0, bw, bh, (lbl) ? "Reload" : 0); b->image(icons->ImgReload); b->callback(b1_cb, (void *)UI_RELOAD); - b->clear_tab_to_focus(); + b->clear_visible_focus(); - Save = b = new HighlightButton(xpos, 0, bw, bh, (lbl) ? "Save" : 0); + Save = b = new Fl_Button(xpos, 0, bw, bh, (lbl) ? "Save" : 0); b->image(icons->ImgSave); b->callback(b1_cb, (void *)UI_SAVE); - b->clear_tab_to_focus(); + b->clear_visible_focus(); - Stop = b = new HighlightButton(xpos, 0, bw, bh, (lbl) ? "Stop" : 0); + Stop = b = new Fl_Button(xpos, 0, bw, bh, (lbl) ? "Stop" : 0); b->image(icons->ImgStopMulti); b->callback(b1_cb, (void *)UI_STOP); - b->clear_tab_to_focus(); + b->clear_visible_focus(); - Bookmarks = b = new HighlightButton(xpos, 0, bw, bh, (lbl) ? "Book" : 0); + Bookmarks = b = new Fl_Button(xpos, 0, bw, bh, (lbl) ? "Book" : 0); b->image(icons->ImgBook); b->callback(b1_cb, (void *)UI_BOOK); - b->clear_tab_to_focus(); + b->clear_visible_focus(); - Tools = b = new HighlightButton(xpos, 0, bw, bh, (lbl) ? "Tools" : 0); + Tools = b = new Fl_Button(xpos, 0, bw, bh, (lbl) ? "Tools" : 0); b->image(icons->ImgTools); b->callback(b1_cb, (void *)UI_TOOLS); - b->clear_tab_to_focus(); + b->clear_visible_focus(); - p1->type(PackedGroup::ALL_CHILDREN_VERTICAL); + p1->type(Fl_Pack::HORIZONTAL); p1->end(); if (prefs.show_tooltip) { @@ -457,33 +442,32 @@ PackedGroup *UI::make_toolbar(int tw, int th) /* * Create the location box (Clear/Input/Search) */ -PackedGroup *UI::make_location() +Fl_Pack *UI::make_location() { - Button *b; - PackedGroup *pg = new PackedGroup(0,0,0,0); + Fl_Button *b; + Fl_Pack *pg = new Fl_Pack(0,0,0,0); pg->begin(); Clear = b = new CustHighlightButton(2,2,16,22,0); b->image(icons->ImgClear); b->callback(clear_cb, this); - b->clear_tab_to_focus(); + b->clear_visible_focus(); Input *i = Location = new CustInput(0,0,0,0,0); i->color(CuteColor); i->when(FL_WHEN_ENTER_KEY); i->callback(location_cb, this); - i->set_click_to_focus(); Search = b = new HighlightButton(0,0,16,22,0); b->image(icons->ImgSearch); b->callback(search_cb, this); - b->clear_tab_to_focus(); + b->clear_visible_focus(); Help = b = new HighlightButton(0,0,16,22,0); b->image(icons->ImgHelp); b->callback(help_cb, this); - b->clear_tab_to_focus(); + b->clear_visible_focus(); - pg->type(PackedGroup::ALL_CHILDREN_VERTICAL); + pg->type(Fl_Pack::HORIZONTAL); pg->resizable(i); pg->end(); @@ -499,9 +483,9 @@ PackedGroup *UI::make_location() /* * Create the progress bars */ -PackedGroup *UI::make_progress_bars(int wide, int thin_up) +Fl_Pack *UI::make_progress_bars(int wide, int thin_up) { - ProgBox = new PackedGroup(0,0,0,0); + ProgBox = new Fl_Pack(0,0,0,0); ProgBox->begin(); // Images IProg = new CustProgressBox(0,0,0,0); @@ -513,7 +497,7 @@ PackedGroup *UI::make_progress_bars(int wide, int thin_up) PProg->box(thin_up ? FL_THIN_UP_BOX : FL_EMBOSSED_BOX); PProg->labelcolor(GRAY10); PProg->update_label(wide ? "Page\n0.0KB" : "0.0KB"); - ProgBox->type(PackedGroup::ALL_CHILDREN_VERTICAL); + ProgBox->type(FL_Pack::HORIZONTAL); ProgBox->end(); return ProgBox; @@ -523,12 +507,12 @@ PackedGroup *UI::make_progress_bars(int wide, int thin_up) * Create the "File" menu * Static function for File menu callbacks. */ -Widget *UI::make_filemenu_button() +Fl_Widget *UI::make_filemenu_button() { - HighlightButton *btn; + Fl_Button *btn; int w,h, padding; - FileButton = btn = new HighlightButton(0,0,0,0,"W"); + FileButton = btn = new Fl_Button(0,0,0,0,"W"); btn->measure_label(w, h); padding = w; btn->copy_label(PanelSize == P_tiny ? "&F" : "&File"); @@ -551,11 +535,11 @@ Widget *UI::make_filemenu_button() /* * Create the control panel */ -Group *UI::make_panel(int ww) +Fl_Group *UI::make_panel(int ww) { - Widget *w; - Group *g1, *g2, *g3; - PackedGroup *pg; + Fl_Widget *w; + Fl_Group *g1, *g2, *g3; + Fl_Pack *pg; if (PanelSize > P_large) { PanelSize = P_tiny; @@ -606,23 +590,23 @@ Group *UI::make_panel(int ww) g1->resizable(pg); } else { - g1 = new Group(0,0,ww,fh+lh+bh); + g1 = new Fl_Group(0,0,ww,fh+lh+bh); g1->begin(); // File menu if (PanelSize == P_large) { - g3 = new Group(0,0,ww,lh); + g3 = new Fl_Group(0,0,ww,lh); g3->box(FL_FLAT_BOX); - Widget *bn = make_filemenu_button(); + Fl_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 = new Fl_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 = new Fl_Pack(0,fh,ww,lh); + g2->type(Fl_Pack::HORIZONTAL); g2->begin(); make_filemenu_button(); pg = make_location(); @@ -632,11 +616,11 @@ Group *UI::make_panel(int ww) g2->end(); // Toolbar - g3 = new Group(0,fh+lh,ww,bh); + g3 = new Fl_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); + //w = new Box(0,0,0,0,"i n v i s i b l e"); + w = new Box(0,0,0,0,0); pg->add(w); pg->resizable(w); @@ -662,23 +646,22 @@ Group *UI::make_panel(int ww) /* * Create the status panel */ -Group *UI::make_status_panel(int ww) +Fl_Group *UI::make_status_panel(int ww) { const int s_h = 20, bm_w = 16; - Group *g = new Group(0, 0, ww, s_h, 0); + Fl_Group *g = new Fl_Group(0, 0, ww, s_h, 0); // Status box - Status = new Output(0, 0, ww-bm_w, s_h, 0); + Status = new Fl_Output(0, 0, ww-bm_w, s_h, 0); Status->value(""); Status->box(FL_THIN_DOWN_BOX); - Status->clear_click_to_focus(); - Status->clear_tab_to_focus(); + Status->clear_visible_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 = new Fl_Button(ww-bm_w,0,bm_w,s_h,0); BugMeter->image(icons->ImgMeterOK); BugMeter->box(FL_THIN_DOWN_BOX); BugMeter->align(FL_ALIGN_INSIDE|FL_ALIGN_CLIP|FL_ALIGN_LEFT); @@ -696,13 +679,13 @@ Group *UI::make_status_panel(int ww) * 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) + Fl_Group(x, y, ww, wh, label) { PointerOnLink = FALSE; Tabs = NULL; TabTooltip = NULL; - TopGroup = new PackedGroup(0, 0, ww, wh); + TopGroup = new Fl_Pack(0, 0, ww, wh); add(TopGroup); resizable(TopGroup); clear_flag(SHORTCUT_LABEL); @@ -730,7 +713,7 @@ UI::UI(int x, int y, int ww, int wh, const char* label, const UI *cur_ui) : TopGroup->add(Panel); // Render area - Main = new Widget(0,0,1,1,"Welcome..."); + Main = new Fl_Widget(0,0,1,1,"Welcome..."); Main->box(FL_FLAT_BOX); Main->color(GRAY15); Main->labelfont(FL_HELVETICA_BOLD_ITALIC); @@ -751,7 +734,7 @@ UI::UI(int x, int y, int ww, int wh, const char* label, const UI *cur_ui) : // 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); @@ -861,7 +844,7 @@ int UI::handle(int event) e_x -= Main->x(); e_y -= Main->y(); - ret = ((Group *)Main)->Group::handle(event); + ret = ((Fl_Group *)Main)->Fl_Group::handle(event); e_x = save_x; e_y = save_y; } @@ -874,7 +857,7 @@ int UI::handle(int event) } if (!ret) { - ret = Group::handle(event); + ret = Fl_Group::handle(event); } return ret; @@ -1069,7 +1052,6 @@ void UI::color_change_cb_i() MSG("Location color %d\n", CuteColor); Location->color(CuteColor); Location->redraw(); - HighlightButton::default_style->highlight_color(CuteColor); } /* diff --git a/src/ui.hh b/src/ui.hh index 9e1b6d4f..a4b0bd7b 100644 --- a/src/ui.hh +++ b/src/ui.hh @@ -3,16 +3,14 @@ // UI for dillo -------------------------------------------------------------- -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include "findbar.hh" @@ -42,19 +40,19 @@ class CustTabGroup; // // UI class definition ------------------------------------------------------- // -class UI : public fltk::Group { +class UI : public Fl_Group { CustTabGroup *Tabs; char *TabTooltip; - fltk::Group *TopGroup; - fltk::Button *Back, *Forw, *Home, *Reload, *Save, *Stop, *Bookmarks, *Tools, + Fl_Group *TopGroup; + Fl_Button *Back, *Forw, *Home, *Reload, *Save, *Stop, *Bookmarks, *Tools, *Clear, *Search, *Help, *FullScreen, *BugMeter, *FileButton; - fltk::Input *Location; - fltk::PackedGroup *ProgBox; + Fl_Input *Location; + Fl_Pack *ProgBox; CustProgressBox *PProg, *IProg; - fltk::Group *Panel, *StatusPanel; - fltk::Widget *Main; - fltk::Output *Status; + Fl_Group *Panel, *StatusPanel; + Fl_Widget *Main; + Fl_Output *Status; int MainIdx; // Panel customization variables @@ -65,13 +63,13 @@ class UI : public fltk::Group { 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_Pack *make_toolbar(int tw, int th); + Fl_Pack *make_location(); + Fl_Pack *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(); + Fl_Group *make_panel(int ww); + Fl_Group *make_status_panel(int ww); public: @@ -89,7 +87,7 @@ 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_render_layout(Fl_Widget &nw); void set_tab_title(const char *label); void customize(int flags); void button_set_sens(UIButton btn, int sens); @@ -97,7 +95,7 @@ public: void set_panelmode(UIPanelmode mode); UIPanelmode get_panelmode(); void set_findbar_visibility(bool visible); - Widget *fullscreen_button() { return FullScreen; } + Fl_Widget *fullscreen_button() { return FullScreen; } void fullscreen_toggle() { FullScreen->do_callback(); } CustTabGroup *tabs() { return Tabs; } -- cgit v1.2.3 From 96f93a6aad702dfe4e1989d1e57841e2b5296d21 Mon Sep 17 00:00:00 2001 From: corvid Date: Fri, 7 Jan 2011 13:19:23 +0000 Subject: some uicmd --- src/uicmd.cc | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/uicmd.cc b/src/uicmd.cc index c0f18487..24c0b413 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -16,11 +16,8 @@ #include #include /* for rint */ -#include -#include -#include -#include -#include +#include +#include #include "paths.hh" #include "keys.hh" @@ -226,18 +223,18 @@ TabGroupPager* CustShrinkTabPager::clone() const { /* * For custom handling of keyboard */ -class CustTabGroup : public fltk::TabGroup { - Tooltip *toolTip; +class CustTabGroup : public Fl_Tabs { + Fl_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) { + Fl_Tabs(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; + toolTip = new Fl_Tooltip; tooltipEnabled = false; buttonPushed = false; }; @@ -312,7 +309,7 @@ public: /* Ignore this event */ return 1; } - int ret = TabGroup::handle(e); + int ret = Fl_Tabs::handle(e); if (e == FL_PUSH) { /* WORKAROUND: FLTK raises the window on unhandled clicks, @@ -323,8 +320,8 @@ public: return ret; } - void remove (Widget *w) { - TabGroup::remove (w); + void remove (Fl_Widget *w) { + Fl_Tabs::remove (w); /* fixup resizable in case we just removed it */ if (resizable () == w) { if (children () > 0) @@ -337,8 +334,8 @@ public: hideLabels (); } - void add (Widget *w) { - TabGroup::add (w); + void add (Fl_Widget *w) { + Fl_Tabs::add (w); if (children () > 1) showLabels (); } @@ -356,7 +353,7 @@ public: //---------------------------------------------------------------------------- -static void win_cb (fltk::Widget *w, void *cb_data) { +static void win_cb (Fl_Widget *w, void *cb_data) { int choice = 0; CustTabGroup *tabs = (CustTabGroup*) cb_data; @@ -376,7 +373,7 @@ 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 (((Fl_Widget*)bw->ui)->contains((Fl_Widget*)v_wid)) return bw; } return NULL; @@ -405,7 +402,7 @@ BrowserWindow *a_UIcmd_browser_window_new(int ww, int wh, { BrowserWindow *old_bw = (BrowserWindow*)vbw; BrowserWindow *new_bw = NULL; - Window *win; + Fl_Window *win; if (ww <= 0 || wh <= 0) { // Set default geometry from dillorc. @@ -416,7 +413,7 @@ BrowserWindow *a_UIcmd_browser_window_new(int ww, int wh, if (xid) win = new Xembed(xid, ww, wh); else - win = new Window(ww, wh); + win = new Fl_Window(ww, wh); win->shortcut(0); // Ignore Escape if (prefs.buffered_drawing != 2) -- cgit v1.2.3 From b7b692902b798b81a2fd488f11406047be2c721a Mon Sep 17 00:00:00 2001 From: corvid Date: Sat, 8 Jan 2011 03:56:36 +0000 Subject: a bit of dialog --- src/dialog.cc | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/dialog.cc b/src/dialog.cc index 6715f690..c0082d90 100644 --- a/src/dialog.cc +++ b/src/dialog.cc @@ -120,7 +120,6 @@ 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); Fl_Window *window = new Fl_Window(ww, wh, title ? title : "Untitled"); @@ -135,17 +134,10 @@ void a_Dialog_text_window(const char *txt, const char *title) 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); - /* 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); + td->size(ww+1,wh-bh); Fl_Return_Button *b = new Fl_Return_Button (0, wh-bh, ww, bh, "Close"); b->callback(window_close_cb, window); @@ -249,7 +241,7 @@ int a_Dialog_user_password(const char *message, UserPasswordCB cb, void *vp) /* BUG type() not tested */ message_output->type(FL_NORMAL_OUTPUT | FL_INPUT_WRAP); message_output->box(FL_DOWN_BOX); - message_output->text(message); + message_output->value(message); message_output->textfont(FL_HELVETICA_BOLD_ITALIC); message_output->textsize(14); -- cgit v1.2.3 From 8f25f501b9bd60cbb0efecf7a2297cb828c0dba7 Mon Sep 17 00:00:00 2001 From: corvid Date: Sat, 8 Jan 2011 04:23:26 +0000 Subject: some xembed --- src/xembed.cc | 17 ++++++++--------- src/xembed.hh | 6 +++--- 2 files changed, 11 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/xembed.cc b/src/xembed.cc index 49828ffe..45507e64 100644 --- a/src/xembed.cc +++ b/src/xembed.cc @@ -12,10 +12,9 @@ #include #include -#include -#include -#include -#include +#include +#include +#include #include "xembed.hh" @@ -74,10 +73,10 @@ Xembed::handle(int e) { 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) { +static int event_handler(int e, Fl_Window *w) { Atom xembed_atom = XInternAtom (fltk::xdisplay, "_XEMBED", false); if (fltk::xevent.type == ClientMessage) { @@ -110,7 +109,7 @@ void Xembed::create() { } void Xembed::createInternal(uint32_t parent) { - fltk::Window *window = this; + Fl_Window *window = this; Colormap colormap = fltk::xcolormap; XSetWindowAttributes attr; @@ -154,12 +153,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(); + Fl_Window::create(); } #endif diff --git a/src/xembed.hh b/src/xembed.hh index 70d79c5f..fe40014d 100644 --- a/src/xembed.hh +++ b/src/xembed.hh @@ -1,11 +1,11 @@ #ifndef __XEMBED_HH__ #define __XEMBED_HH__ -#include +#include #include "d_size.h" -class Xembed : public fltk::Window { +class Xembed : public Fl_Window { private: uint32_t xid; void createInternal(uint32_t parent); @@ -13,7 +13,7 @@ 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(); -- cgit v1.2.3 From 5bb91804ea4617f5da1689db3752e1a25ffc2dfa Mon Sep 17 00:00:00 2001 From: corvid Date: Sun, 9 Jan 2011 04:20:12 +0000 Subject: fair amount of menu --- src/menu.cc | 431 ++++++++++++++++++++++++------------------------------------ 1 file changed, 173 insertions(+), 258 deletions(-) (limited to 'src') diff --git a/src/menu.cc b/src/menu.cc index 4090e1ae..da72a99a 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -11,6 +11,7 @@ // Functions/Methods for menus +#include #include #include "lout/misc.hh" /* SimpleVector */ @@ -23,8 +24,6 @@ #include "keys.hh" #include "timeout.hh" -using namespace fltk; - /* * Local data */ @@ -34,6 +33,7 @@ using namespace fltk; static DilloUrl *popup_url = NULL; // Weak reference to the popup's bw static BrowserWindow *popup_bw = NULL; +static void *popup_form = NULL; // Where to place the filemenu popup static int popup_x, popup_y; // History popup direction (-1 = back, 1 = forward). @@ -46,7 +46,7 @@ static int *history_list = NULL; * Used to add the hint for history popup menus, and to remember * the mouse button pressed over a menu item. */ -class CustItem : public Item { +class CustItem : public Fl_Menu_Item { int EventButton; public: CustItem (const char* label) : Item(label) { EventButton = 0; }; @@ -96,7 +96,7 @@ static void filemenu_cb(Fl_Widget *wid, void *data) } -static void Menu_copy_urlstr_cb(Fl_Widget *) +static void Menu_copy_urlstr_cb(Fl_Widget*, void*) { if (popup_url) a_UIcmd_copy_urlstr(popup_bw, URL_STR(popup_url)); @@ -114,7 +114,7 @@ static void Menu_link_cb(Fl_Widget*, void *user_data) /* * Open URL */ -static void Menu_open_url_cb(Fl_Widget* ) +static void Menu_open_url_cb(Fl_Widget*, void* ) { _MSG("Open URL cb: click! :-)\n"); a_UIcmd_open_url(popup_bw, popup_url); @@ -123,7 +123,7 @@ static void Menu_open_url_cb(Fl_Widget* ) /* * Open URL in new window */ -static void Menu_open_url_nw_cb(Fl_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); @@ -132,7 +132,7 @@ static void Menu_open_url_nw_cb(Fl_Widget* ) /* * Open URL in new Tab */ -static void Menu_open_url_nt_cb(Fl_Widget* ) +static void Menu_open_url_nt_cb(Fl_Widget*, void* ) { int focus = prefs.focus_new_tab ? 1 : 0; if (Fl::event_state(FL_SHIFT)) focus = !focus; @@ -142,7 +142,7 @@ static void Menu_open_url_nt_cb(Fl_Widget* ) /* * Add bookmark */ -static void Menu_add_bookmark_cb(Fl_Widget* ) +static void Menu_add_bookmark_cb(Fl_Widget*, void* ) { a_UIcmd_add_bookmark(popup_bw, popup_url); } @@ -150,7 +150,7 @@ static void Menu_add_bookmark_cb(Fl_Widget* ) /* * Find text */ -static void Menu_find_text_cb(Fl_Widget* ) +static void Menu_find_text_cb(Fl_Widget*, void* ) { ((UI *)popup_bw->ui)->set_findbar_visibility(1); } @@ -158,7 +158,7 @@ static void Menu_find_text_cb(Fl_Widget* ) /* * Save link */ -static void Menu_save_link_cb(Fl_Widget* ) +static void Menu_save_link_cb(Fl_Widget*, void* ) { a_UIcmd_save_link(popup_bw, popup_url); } @@ -166,7 +166,7 @@ static void Menu_save_link_cb(Fl_Widget* ) /* * Save current page */ -static void Menu_save_page_cb(Fl_Widget* ) +static void Menu_save_page_cb(Fl_Widget*, void* ) { a_UIcmd_save(popup_bw); } @@ -174,7 +174,7 @@ static void Menu_save_page_cb(Fl_Widget* ) /* * View current page source */ -static void Menu_view_page_source_cb(Fl_Widget* ) +static void Menu_view_page_source_cb(Fl_Widget*, void* ) { a_UIcmd_view_page_source(popup_bw, popup_url); } @@ -182,7 +182,7 @@ static void Menu_view_page_source_cb(Fl_Widget* ) /* * View current page's bugs */ -static void Menu_view_page_bugs_cb(Fl_Widget* ) +static void Menu_view_page_bugs_cb(Fl_Widget*, void* ) { a_UIcmd_view_page_bugs(popup_bw); } @@ -202,23 +202,23 @@ static void Menu_load_images_cb(Fl_Widget*, void *user_data) /* * Submit form */ -static void Menu_form_submit_cb(Fl_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(Fl_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); } /* @@ -226,12 +226,11 @@ static void Menu_form_reset_cb(Fl_Widget*, void *v_form) */ static void Menu_form_hiddens_cb(Fl_Widget *w, 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(Fl_Widget *w, void *vUrl) @@ -243,7 +242,7 @@ static void Menu_stylesheet_cb(Fl_Widget *w, void *vUrl) /* * Validate URL with the W3C */ -static void Menu_bugmeter_validate_w3c_cb(Fl_Widget* ) +static void Menu_bugmeter_validate_w3c_cb(Fl_Widget*, void* ) { Dstr *dstr = dStr_sized_new(128); @@ -256,7 +255,7 @@ static void Menu_bugmeter_validate_w3c_cb(Fl_Widget* ) /* * Validate URL with the WDG */ -static void Menu_bugmeter_validate_wdg_cb(Fl_Widget* ) +static void Menu_bugmeter_validate_wdg_cb(Fl_Widget*, void* ) { Dstr *dstr = dStr_sized_new(128); @@ -270,7 +269,7 @@ static void Menu_bugmeter_validate_wdg_cb(Fl_Widget* ) /* * Show info page for the bug meter */ -static void Menu_bugmeter_about_cb(Fl_Widget* ) +static void Menu_bugmeter_about_cb(Fl_Widget*, void* ) { a_UIcmd_open_urlstr(popup_bw, "http://www.dillo.org/help/bug_meter.html"); } @@ -307,18 +306,10 @@ static void Menu_history_cb(Fl_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) + ((Fl_Widget *)m)->do_callback(); a_Timeout_remove(); } @@ -330,65 +321,48 @@ void a_Menu_page_popup(BrowserWindow *bw, const DilloUrl *url, { lout::misc::SimpleVector *cssUrls = (lout::misc::SimpleVector *) 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, 0, 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 */ - Fl_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); @@ -407,14 +381,14 @@ void a_Menu_page_popup(BrowserWindow *bw, const DilloUrl *url, label = dStrconcat(action, url_str, NULL); } - i = new Item(label); - i->clear_flag(SHORTCUT_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); @@ -425,33 +399,20 @@ 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 window", 0, Menu_open_url_nw_cb,0,0,0,0,0,0}, + {"Open link in new tab",0,Menu_open_url_nt_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); } @@ -463,14 +424,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 window", 0, Menu_open_url_nw_cb,0,0,0,0,0,0}, + {"Open image in new tab", 0, Menu_open_url_nt_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); @@ -479,46 +449,19 @@ 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); @@ -530,29 +473,23 @@ 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); } @@ -564,8 +501,22 @@ void a_Menu_file_popup(BrowserWindow *bw, void *v_wid) { UI *ui = (UI *)bw->ui; Fl_Widget *wid = (Fl_Widget*)v_wid; - // One menu for every browser window - static PopupMenu *pm = 0; + + static Fl_Menu_Item pm[] = { + {"New window", Keys::getShortcut(KEYS_NEW_WINDOW), filemenu_cb, + (void*)"nw",0,0,0,0,0}, + {"New tab", Keys::getShortcut(KEYS_NEW_TAB), filemenu_cb, + (void*)"nt", 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(); @@ -575,31 +526,8 @@ void a_Menu_file_popup(BrowserWindow *bw, void *v_wid) a_Url_free(popup_url); popup_url = NULL; - if (!pm) { - int shortcut; - Item *i; - pm = new PopupMenu(0,0,0,0,"File"); - pm->begin(); - shortcut = Keys::getShortcut(KEYS_NEW_WINDOW); - i = new Item("New Window", shortcut, filemenu_cb, (void*)"nw"); - shortcut = Keys::getShortcut(KEYS_NEW_TAB); - i = new Item("New Tab", shortcut, filemenu_cb, (void*)"nt"); - new Divider(); - shortcut = Keys::getShortcut(KEYS_OPEN); - i = new Item("Open File...", shortcut, filemenu_cb, (void*)"of"); - shortcut = Keys::getShortcut(KEYS_GOTO); - i = new Item("Open URL...", shortcut, filemenu_cb, (void*)"ou"); - shortcut = Keys::getShortcut(KEYS_CLOSE_TAB); - i = new Item("Close", shortcut, filemenu_cb, (void*)"cw"); - new Divider(); - shortcut = Keys::getShortcut(KEYS_CLOSE_ALL); - i = 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); } /* @@ -607,28 +535,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); } /* @@ -638,65 +559,65 @@ 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; 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->popup(); + pm = new Fl_Menu_Item[n + 1]; + memset(pm, '\0', sizeof(Fl_Menu_Item[n + 1])); + + 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(Fl_Widget *wid) +static void Menu_remote_css_cb(Fl_Widget *wid, void*) { + Fl_Menu_Item *item = (Fl_Menu_Item*) wid; + _MSG("Menu_remote_css_cb\n"); - prefs.load_stylesheets = wid->state() ? 1 : 0; + prefs.load_stylesheets = item->value() ? 1 : 0; a_UIcmd_repush(popup_bw); } /* * Toggle use of embedded CSS style */ -static void Menu_embedded_css_cb(Fl_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; + + prefs.parse_embedded_css = item->value() ? 1 : 0; a_UIcmd_repush(popup_bw); } /* * Toggle loading of images -- and load them if enabling. */ -static void Menu_imgload_toggle_cb(Fl_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; + + if ((prefs.load_images = item->value() ? 1 : 0)) { void *doc = a_Bw_get_current_doc(popup_bw); if (doc) { @@ -711,31 +632,25 @@ static void Menu_imgload_toggle_cb(Fl_Widget *wid) */ void a_Menu_tools_popup(BrowserWindow *bw, void *v_wid) { - // One menu shared by every browser window - static PopupMenu *pm = NULL; Fl_Widget *wid = (Fl_Widget*)v_wid; - Item *it; + + 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,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(); - } - //pm->popup(); - pm->value(-1); - ((Menu*)pm)->popup(Rectangle(0,wid->h(),pm->w(),pm->h())); + if (prefs.load_stylesheets) + pm[0].set(); + if (prefs.parse_embedded_css) + pm[1].set(); + if (prefs.load_images) + pm[2].set(); + + pm->popup(wid->x(), wid->y()); } -- cgit v1.2.3 From 885f3bc2c339ef009853da785f6b06ffab7e0622 Mon Sep 17 00:00:00 2001 From: corvid Date: Sun, 9 Jan 2011 21:14:51 +0000 Subject: some more src/ui --- src/ui.cc | 123 ++++++++++++++++++++++++++++++-------------------------------- src/ui.hh | 2 +- 2 files changed, 61 insertions(+), 64 deletions(-) (limited to 'src') diff --git a/src/ui.cc b/src/ui.cc index 482ad0f7..dab4e75a 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -20,6 +20,10 @@ #include "timeout.hh" #include "utf8.hh" +#include +#include +#include + // Include image data #include "pixmaps.h" #include "uicmd.hh" @@ -27,46 +31,39 @@ struct iconset { Fl_Image *ImgMeterOK, *ImgMeterBug, *ImgHome, *ImgReload, *ImgSave, *ImgBook, *ImgTools, - *ImgClear,*ImgSearch, *ImgHelp; - MultiImage *ImgLeftMulti, *ImgRightMulti, *ImgStopMulti; + *ImgClear,*ImgSearch, *ImgHelp, *ImgLeft, *ImgRight, *ImgStop; }; 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(right_xpm), + new Fl_Pixmap(stop_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(right_s_xpm), + new Fl_Pixmap(stop_s_xpm), }; @@ -170,7 +167,7 @@ public: } copy_label(lbl); measure_label(w,h); - resize(w+padding,h); + size(w+padding,h); redraw_label(); } }; @@ -266,7 +263,7 @@ static void color_change_cb(Fl_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"); @@ -384,12 +381,12 @@ Fl_Pack *UI::make_toolbar(int tw, int th) Fl_Pack *p1=new Fl_Pack(0,0,tw,th); p1->begin(); Back = b = new Fl_Button(xpos, 0, bw, bh, (lbl) ? "Back" : 0); - b->image(icons->ImgLeftMulti); + b->image(icons->ImgLeft); b->callback(b1_cb, (void *)UI_BACK); b->clear_visible_focus(); Forw = b = new Fl_Button(xpos, 0, bw, bh, (lbl) ? "Forw" : 0); - b->image(icons->ImgRightMulti); + b->image(icons->ImgRight); b->callback(b1_cb, (void *)UI_FORW); b->clear_visible_focus(); @@ -409,7 +406,7 @@ Fl_Pack *UI::make_toolbar(int tw, int th) b->clear_visible_focus(); Stop = b = new Fl_Button(xpos, 0, bw, bh, (lbl) ? "Stop" : 0); - b->image(icons->ImgStopMulti); + b->image(icons->ImgStop); b->callback(b1_cb, (void *)UI_STOP); b->clear_visible_focus(); @@ -447,22 +444,22 @@ Fl_Pack *UI::make_location() Fl_Button *b; Fl_Pack *pg = new Fl_Pack(0,0,0,0); pg->begin(); - Clear = b = new CustHighlightButton(2,2,16,22,0); + Clear = b = new CustButton(2,2,16,22,0); b->image(icons->ImgClear); b->callback(clear_cb, this); b->clear_visible_focus(); - Input *i = Location = new CustInput(0,0,0,0,0); + Fl_Input *i = Location = new CustInput(0,0,0,0,0); i->color(CuteColor); i->when(FL_WHEN_ENTER_KEY); i->callback(location_cb, this); - Search = b = new HighlightButton(0,0,16,22,0); + Search = b = new Fl_Button(0,0,16,22,0); b->image(icons->ImgSearch); b->callback(search_cb, this); b->clear_visible_focus(); - Help = b = new HighlightButton(0,0,16,22,0); + Help = b = new Fl_Button(0,0,16,22,0); b->image(icons->ImgHelp); b->callback(help_cb, this); b->clear_visible_focus(); @@ -497,7 +494,7 @@ Fl_Pack *UI::make_progress_bars(int wide, int thin_up) PProg->box(thin_up ? FL_THIN_UP_BOX : FL_EMBOSSED_BOX); PProg->labelcolor(GRAY10); PProg->update_label(wide ? "Page\n0.0KB" : "0.0KB"); - ProgBox->type(FL_Pack::HORIZONTAL); + ProgBox->type(Fl_Pack::HORIZONTAL); ProgBox->end(); return ProgBox; @@ -519,13 +516,13 @@ Fl_Widget *UI::make_filemenu_button() btn->measure_label(w,h); if (PanelSize == P_large) h = fh; - btn->resize(w+padding,h); + btn->size(w+padding,h); _MSG("UI::make_filemenu_button w=%d h=%d padding=%d\n", w, h, padding); btn->box(PanelSize == P_large ? FL_FLAT_BOX : FL_THIN_UP_BOX); btn->callback(filemenu_cb, this); if (prefs.show_tooltip) btn->tooltip("File menu"); - btn->clear_tab_to_focus(); + btn->clear_visible_focus(); if (!prefs.show_filemenu && PanelSize != P_large) btn->hide(); return btn; @@ -574,7 +571,7 @@ Fl_Group *UI::make_panel(int ww) } if (PanelSize == P_tiny) { - g1 = new Group(0,0,ww,bh); + g1 = new Fl_Group(0,0,ww,bh); // Toolbar pg = make_toolbar(ww,bh); pg->box(FL_EMBOSSED_BOX); @@ -598,12 +595,12 @@ Fl_Group *UI::make_panel(int ww) g3->box(FL_FLAT_BOX); Fl_Widget *bn = make_filemenu_button(); g3->add(bn); - g3->add_resizable(*new InvisibleBox(bn->w(),0,ww - bn->w(),lh)); + g3->add_resizable(*new Fl_Box(bn->w(),0,ww - bn->w(),lh)); g2 = new Fl_Group(0,fh,ww,lh); g2->begin(); pg = make_location(); - pg->resize(ww,lh); + pg->size(ww,lh); } else { g2 = new Fl_Pack(0,fh,ww,lh); g2->type(Fl_Pack::HORIZONTAL); @@ -619,8 +616,8 @@ Fl_Group *UI::make_panel(int ww) g3 = new Fl_Group(0,fh+lh,ww,bh); g3->begin(); pg = make_toolbar(ww,bh); - //w = new Box(0,0,0,0,"i n v i s i b l e"); - w = new Box(0,0,0,0,0); + //w = new Fl_Box(0,0,0,0,"i n v i s i b l e"); + w = new Fl_Box(0,0,0,0,0); pg->add(w); pg->resizable(w); @@ -652,13 +649,13 @@ Fl_Group *UI::make_status_panel(int ww) Fl_Group *g = new Fl_Group(0, 0, ww, s_h, 0); // Status box - Status = new Fl_Output(0, 0, ww-bm_w, s_h, 0); - Status->value(""); - Status->box(FL_THIN_DOWN_BOX); - Status->clear_visible_focus(); - Status->color(GRAY80); - g->add(Status); - //Status->throw_focus(); + StatusOutput = new Fl_Output(0, 0, ww-bm_w, s_h, 0); + StatusOutput->value(""); + StatusOutput->box(FL_THIN_DOWN_BOX); + StatusOutput->clear_visible_focus(); + StatusOutput->color(GRAY80); + g->add(StatusOutput); + //StatusOutput->throw_focus(); // Bug Meter BugMeter = new Fl_Button(ww-bm_w,0,bm_w,s_h,0); @@ -668,10 +665,10 @@ Fl_Group *UI::make_status_panel(int ww) if (prefs.show_tooltip) BugMeter->tooltip("Show HTML bugs\n(right-click for menu)"); BugMeter->callback(bugmeter_cb, this); - BugMeter->clear_tab_to_focus(); + BugMeter->clear_visible_focus(); g->add(BugMeter); - g->resizable(Status); + g->resizable(StatusOutput); return g; } @@ -713,7 +710,7 @@ UI::UI(int x, int y, int ww, int wh, const char* label, const UI *cur_ui) : TopGroup->add(Panel); // Render area - Main = new Fl_Widget(0,0,1,1,"Welcome..."); + Main = new Fl_Box(0,0,1,1,"Welcome..."); Main->box(FL_FLAT_BOX); Main->color(GRAY15); Main->labelfont(FL_HELVETICA_BOLD_ITALIC); @@ -884,7 +881,7 @@ 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)); } @@ -915,7 +912,7 @@ void UI::focus_main() */ void UI::set_status(const char *str) { - Status->value(str); + StatusOutput->value(str); } /* @@ -981,7 +978,7 @@ void UI::set_bug_prog(int n_bug) BugMeter->redraw_label(); new_w = strlen(str)*8 + 20; } - Status->resize(0,0,StatusPanel->w()-new_w,Status->h()); + StatusOutput->resize(0,0,StatusPanel->w()-new_w,StatusOutput->h()); BugMeter->resize(StatusPanel->w()-new_w, 0, new_w, BugMeter->h()); StatusPanel->init_sizes(); } @@ -1026,7 +1023,7 @@ void UI::customize(int flags) */ void UI::panel_cb_i() { - Group *NewPanel; + Fl_Group *NewPanel; // Create a new Panel ++PanelSize; @@ -1089,7 +1086,7 @@ 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_Widget &nw) { // BUG: replace() is not working as it should. // In our case, replacing the rendering area leaves the vertical @@ -1163,7 +1160,7 @@ void UI::button_set_sens(UIButton btn, int sens) */ void UI::paste_url() { - paste(*Clear, false); + Fl::paste(*Clear, false); } /* diff --git a/src/ui.hh b/src/ui.hh index a4b0bd7b..79f71b35 100644 --- a/src/ui.hh +++ b/src/ui.hh @@ -52,7 +52,7 @@ class UI : public Fl_Group { CustProgressBox *PProg, *IProg; Fl_Group *Panel, *StatusPanel; Fl_Widget *Main; - Fl_Output *Status; + Fl_Output *StatusOutput; int MainIdx; // Panel customization variables -- cgit v1.2.3 From 4188bbb05f20d264987053edbd1d4a250884c7b8 Mon Sep 17 00:00:00 2001 From: corvid Date: Tue, 11 Jan 2011 02:15:10 +0000 Subject: more src/ui --- src/ui.cc | 33 +++++++++++++++------------------ src/ui.hh | 5 ++--- 2 files changed, 17 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/ui.cc b/src/ui.cc index dab4e75a..aef1302b 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -487,12 +487,12 @@ Fl_Pack *UI::make_progress_bars(int wide, int thin_up) // Images IProg = new CustProgressBox(0,0,0,0); IProg->box(thin_up ? FL_THIN_UP_BOX : FL_EMBOSSED_BOX); - IProg->labelcolor(GRAY10); + IProg->labelcolor(FL_GRAY_RAMP + 2); IProg->update_label(wide ? "Images\n0 of 0" : "0 of 0"); // Page PProg = new CustProgressBox(0,0,0,0); PProg->box(thin_up ? FL_THIN_UP_BOX : FL_EMBOSSED_BOX); - PProg->labelcolor(GRAY10); + PProg->labelcolor(FL_GRAY_RAMP + 2); PProg->update_label(wide ? "Page\n0.0KB" : "0.0KB"); ProgBox->type(Fl_Pack::HORIZONTAL); ProgBox->end(); @@ -653,7 +653,7 @@ Fl_Group *UI::make_status_panel(int ww) StatusOutput->value(""); StatusOutput->box(FL_THIN_DOWN_BOX); StatusOutput->clear_visible_focus(); - StatusOutput->color(GRAY80); + StatusOutput->color(FL_GRAY_RAMP + 18); g->add(StatusOutput); //StatusOutput->throw_focus(); @@ -710,9 +710,9 @@ UI::UI(int x, int y, int ww, int wh, const char* label, const UI *cur_ui) : TopGroup->add(Panel); // Render area - Main = new Fl_Box(0,0,1,1,"Welcome..."); + Main = new Fl_Group(0,0,1,1,"Welcome..."); Main->box(FL_FLAT_BOX); - Main->color(GRAY15); + Main->color(FL_GRAY_RAMP + 3); Main->labelfont(FL_HELVETICA_BOLD_ITALIC); Main->labelsize(36); Main->labeltype(FL_SHADOW_LABEL); @@ -835,15 +835,10 @@ int UI::handle(int event) if (prefs.middle_click_drags_page == 0 && Fl::event_button() == FL_MIDDLE_MOUSE && !a_UIcmd_pointer_on_link(a_UIcmd_get_bw_by_widget(this))) { - if (Main->Rectangle::contains (Fl::event_x (), Fl::event_y ())) { + if (Main->contains(Fl::belowmouse())) { /* 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(); + /* TODO: Try just offering it to Fl::belowmouse() */ ret = ((Fl_Group *)Main)->Fl_Group::handle(event); - e_x = save_x; - e_y = save_y; } if (!ret) { /* middle click was not on a link or a form widget */ @@ -1028,8 +1023,9 @@ void UI::panel_cb_i() // Create a new Panel ++PanelSize; NewPanel = make_panel(TopGroup->w()); - TopGroup->replace(*Panel, *NewPanel); + TopGroup->remove(Panel); delete(Panel); + TopGroup->add(NewPanel); Panel = NewPanel; customize(0); @@ -1086,15 +1082,16 @@ void UI::panelmode_cb_i() /* * Set 'nw' as the main render area widget */ -void UI::set_render_layout(Fl_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); + TopGroup->remove(MainIdx); delete(Main); + TopGroup->add(nw); Main = &nw; //TopGroup->box(FL_DOWN_BOX); //TopGroup->box(FL_BORDER_FRAME); @@ -1140,15 +1137,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; diff --git a/src/ui.hh b/src/ui.hh index 79f71b35..600badc6 100644 --- a/src/ui.hh +++ b/src/ui.hh @@ -50,8 +50,7 @@ class UI : public Fl_Group { Fl_Input *Location; Fl_Pack *ProgBox; CustProgressBox *PProg, *IProg; - Fl_Group *Panel, *StatusPanel; - Fl_Widget *Main; + Fl_Group *Panel, *Main, *StatusPanel; Fl_Output *StatusOutput; int MainIdx; @@ -87,7 +86,7 @@ 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(Fl_Widget &nw); + void set_render_layout(Fl_Group &nw); void set_tab_title(const char *label); void customize(int flags); void button_set_sens(UIButton btn, int sens); -- cgit v1.2.3 From b77e43108fc62c1d0358f4ab6f627a8fa81c4245 Mon Sep 17 00:00:00 2001 From: corvid Date: Tue, 11 Jan 2011 21:06:25 +0000 Subject: more uicmd --- src/uicmd.cc | 65 +++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 36 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/uicmd.cc b/src/uicmd.cc index 24c0b413..9122a105 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -17,7 +17,9 @@ #include /* for rint */ #include +#include #include +#include #include "paths.hh" #include "keys.hh" @@ -53,10 +55,10 @@ using namespace dw::fltk; */ static char *save_dir = NULL; -using namespace fltk; - //---------------------------------------------------------------------------- +#if 0 + #define BTN_W 25 #define BTN_H 20 @@ -217,7 +219,7 @@ int CustShrinkTabPager::update_positions( TabGroupPager* CustShrinkTabPager::clone() const { return new CustShrinkTabPager(*this); } - +#endif /* custom pager */ //---------------------------------------------------------------------------- /* @@ -231,9 +233,9 @@ public: CustTabGroup (int x, int y, int ww, int wh, const char *lbl=0) : Fl_Tabs(x,y,ww,wh,lbl) { // The parameter pager is cloned, so free it. - CustShrinkTabPager *cp = new CustShrinkTabPager(); - this->pager(cp); - delete cp; +// CustShrinkTabPager *cp = new CustShrinkTabPager(); +// this->pager(cp); +// delete cp; toolTip = new Fl_Tooltip; tooltipEnabled = false; buttonPushed = false; @@ -242,7 +244,7 @@ public: 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); +// fltk::Rectangle r(btn_x,0,BTN_W,BTN_H); if (e == FL_KEYBOARD) { int k = Fl::event_key(); // We're only interested in some flags @@ -251,20 +253,27 @@ public: return 0; } else if (k == FL_Left || k == FL_Right) { if (modifier == FL_SHIFT) { - int i = value(); + int i = find(value()); if (k == FL_Left) {i = i ? i-1 : children()-1;} else {i++; if (i >= children()) i = 0;} - selected_child(child(i)); + value(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 == FL_RELEASE) { + Fl_Widget *new_focus = which(Fl::event_x(), Fl::event_y()); + + if (new_focus && new_focus != value()) { + // Update the window title + BrowserWindow *bw = a_UIcmd_get_bw_by_widget(new_focus); + const char *title = a_History_get_title(NAV_TOP_UIDX(bw), 1); + + a_UIcmd_set_page_title(bw, title ? title : ""); + } +// custom pager +#if 0 } else if (e == FL_MOVE) { CustShrinkTabPager *cstp = (CustShrinkTabPager *) pager(); if (Fl::event_inside(r) && children() > 1) { @@ -299,12 +308,13 @@ public: } else if (e == FL_RELEASE) { if (Fl::event_inside(r) && Fl::event_button() == 1 && children() > 1 && buttonPushed) { - a_UIcmd_close_bw(a_UIcmd_get_bw_by_widget(selected_child())); + a_UIcmd_close_bw(a_UIcmd_get_bw_by_widget(value())); } else { CustShrinkTabPager *cstp = (CustShrinkTabPager *) pager(); cstp->btn_highlight(false); } buttonPushed = false; +#endif } else if (e == FL_DRAG) { /* Ignore this event */ return 1; @@ -412,14 +422,15 @@ BrowserWindow *a_UIcmd_browser_window_new(int ww, int wh, if (xid) win = new Xembed(xid, ww, wh); - else + else if (prefs.buffered_drawing != 2) win = new Fl_Window(ww, wh); + else + win = new Fl_Double_Window(ww, wh); - win->shortcut(0); // Ignore Escape - if (prefs.buffered_drawing != 2) - win->clear_double_buffer(); +//may need a handler for this +// win->shortcut(0); // Ignore Escape CustTabGroup *DilloTabs = new CustTabGroup(0, 0, ww, wh); - DilloTabs->clear_tab_to_focus(); + DilloTabs->clear_visible_focus(); DilloTabs->selection_color(156); win->add(DilloTabs); @@ -436,10 +447,7 @@ BrowserWindow *a_UIcmd_browser_window_new(int ww, int wh, 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()); + new_ui->window()->position(prefs.xpos, prefs.ypos); } // Now create the Dw render layout and viewport @@ -540,9 +548,8 @@ void a_UIcmd_close_bw(void *vbw) 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(); + if (ui->tabs()->value()) + ui->tabs()->value()->take_focus(); else ui->tabs()->window()->hide(); } @@ -653,7 +660,7 @@ 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)); + BW2UI(new_bw)->tabs()->value(BW2UI(new_bw)); UIcmd_open_url_nbw(new_bw, url); } @@ -1221,7 +1228,7 @@ 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()->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)); -- cgit v1.2.3 From c3fdae648e12378d8a0b5191253e43a6630b7741 Mon Sep 17 00:00:00 2001 From: corvid Date: Wed, 12 Jan 2011 03:26:52 +0000 Subject: comment out history menu button handling --- src/menu.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/menu.cc b/src/menu.cc index da72a99a..aaf6756c 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -41,6 +41,10 @@ static int history_direction = -1; // History popup, list of URL-indexes. static int *history_list = NULL; +#if 0 +My guess is that a modified copy of Fl_Menu_ that handles something similar +to Fl_Menu_Item may be necessary. I sure hope not, though. + /* * Local sub class. * Used to add the hint for history popup menus, and to remember @@ -71,7 +75,7 @@ void CustItem::draw() { } Item::draw(); } - +#endif //-------------------------------------------------------------------------- /* @@ -280,8 +284,11 @@ static void Menu_bugmeter_about_cb(Fl_Widget*, void* ) */ static void Menu_history_cb(Fl_Widget *wid, void *data) { +#if 0 int mb = ((CustItem*)wid)->button(); +#endif int offset = history_direction * VOIDP2INT(data); +#if 0 const DilloUrl *url = a_History_get_url(history_list[VOIDP2INT(data)-1]); if (mb == 2) { @@ -294,8 +301,11 @@ static void Menu_history_cb(Fl_Widget *wid, void *data) a_UIcmd_open_url_nw(popup_bw, url); } } else { +#endif a_UIcmd_nav_jump(popup_bw, offset, 0); +#if 0 } +#endif } /* -- cgit v1.2.3 From 2d3fc936c29d039b644d6b4fa879fa584fdb7d96 Mon Sep 17 00:00:00 2001 From: corvid Date: Sun, 16 Jan 2011 00:17:55 +0000 Subject: some general commenting-out for src/ I also get a conflict with Status in dns.h. (Also seen in ui.cc, which I changed like a week ago.) Seemingly defined in X somewhere already. I remember the same thing happening on my port experiment a couple of years, so...I'll just change it. --- src/dialog.cc | 19 +++++++++++++++++-- src/dillo.cc | 10 ++++++---- src/dns.h | 2 +- src/xembed.cc | 3 +++ 4 files changed, 27 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/dialog.cc b/src/dialog.cc index c0082d90..5db21583 100644 --- a/src/dialog.cc +++ b/src/dialog.cc @@ -118,6 +118,8 @@ char *a_Dialog_open_file(const char *msg, */ void a_Dialog_text_window(const char *txt, const char *title) { +#if 0 +PORT1.3 //int wh = 600, ww = 650, bh = 30; int wh = prefs.height, ww = prefs.width, bh = 30; Font *textfont = font(prefs.font_monospace, 0); @@ -145,17 +147,21 @@ void a_Dialog_text_window(const char *txt, const char *title) window->resizable(td); window->end(); window->show(); +#endif } /*--------------------------------------------------------------------------*/ static int choice5_answer; +#if 0 +PORT1.3 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); } +#endif /* * Make a question-dialog with a question and some alternatives. @@ -165,6 +171,8 @@ int a_Dialog_choice5(const char *QuestionTxt, const char *alt1, const char *alt2, const char *alt3, const char *alt4, const char *alt5) { +#if 0 +PORT1.3 choice5_answer = 0; int ww = 440, wh = 150, bw = 50, bh = 45, nb = 0; @@ -205,6 +213,9 @@ int a_Dialog_choice5(const char *QuestionTxt, _MSG("Choice5 answer = %d\n", choice5_answer); return choice5_answer; +#else +return fl_choice(QuestionTxt, alt1, alt2, alt3); +#endif } @@ -214,9 +225,12 @@ int a_Dialog_choice5(const char *QuestionTxt, */ static void Dialog_user_password_cb(Fl_Widget *button, void *vIntPtr) { +#if 0 +PORT1.3 int ret = VOIDP2INT(vIntPtr); _MSG("Dialog_user_password_cb: %d\n", ret); button->window()->make_exec_return(ret); +#endif } /* @@ -272,7 +286,8 @@ int a_Dialog_user_password(const char *message, UserPasswordCB cb, void *vp) window->end(); window->size_range(window_w,window_h,window_w,window_h); window->resizable(window); - +#if 0 +PORT1.3 if ((ok = window->exec())) { /* call the callback */ const char *user, *password; @@ -281,7 +296,7 @@ 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); } - +#endif delete window; return ok; diff --git a/src/dillo.cc b/src/dillo.cc index caf15248..440457a6 100644 --- a/src/dillo.cc +++ b/src/dillo.cc @@ -167,7 +167,8 @@ static OptID getCmdOption(const CLI_options *options, int argc, char **argv, } return opt_id; } - +#if 0 +PORT1.3 /* * Tell the user if default/pref fonts can't be found. */ @@ -185,7 +186,7 @@ static void checkPreferredFonts() checkFont(prefs.font_cursive, "cursive"); checkFont(prefs.font_fantasy, "fantasy"); } - +#endif /* * Given a command line argument, build a DilloUrl for it. */ @@ -317,7 +318,8 @@ int main(int argc, char **argv) // Sets WM_CLASS hint on X11 Fl_Window::default_xclass("dillo"); - +#if 0 +PORT1.3 checkPreferredFonts(); /* use preferred font for UI */ fltk::Font *dfont = fltk::font(prefs.font_sans_serif, 0); @@ -325,7 +327,7 @@ int main(int argc, char **argv) fltk::Widget::default_style->textfont(dfont); fltk::Widget::default_style->labelfont(dfont); } - +#endif // Create a new UI/bw pair BrowserWindow *bw = a_UIcmd_browser_window_new(0, 0, xid, NULL); 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/xembed.cc b/src/xembed.cc index 45507e64..dda135d0 100644 --- a/src/xembed.cc +++ b/src/xembed.cc @@ -158,7 +158,10 @@ Xembed::handle(int e) { void Xembed::create() { +#if 0 +PORT1.3 Fl_Window::create(); +#endif } #endif -- cgit v1.2.3 From 9e34ba448c0ca6924ebab59a6a9ffd998f7e40f5 Mon Sep 17 00:00:00 2001 From: corvid Date: Mon, 17 Jan 2011 05:31:24 +0000 Subject: toolbar button cb --- src/ui.cc | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/ui.cc b/src/ui.cc index aef1302b..ac2082d5 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -286,53 +286,53 @@ static void location_cb(Fl_Widget *wid, void *data) static void b1_cb(Fl_Widget *wid, void *cb_data) { int bn = VOIDP2INT(cb_data); - int k = Fl::event_key(); - if (k && k <= 7) { + int k = Fl::event_button(); + if (k >= FL_LEFT_MOUSE && k <= FL_RIGHT_MOUSE) { _MSG("[%s], mouse button %d was pressed\n", button_names[bn], k); _MSG("mouse button %d was pressed\n", k); } switch (bn) { case UI_BACK: - if (k == 1) { + if (k == FL_LEFT_MOUSE) { a_UIcmd_back(a_UIcmd_get_bw_by_widget(wid)); - } else if (k == 3) { + } else if (k == FL_RIGHT_MOUSE) { a_UIcmd_back_popup(a_UIcmd_get_bw_by_widget(wid)); } break; case UI_FORW: - if (k == 1) { + if (k == FL_LEFT_MOUSE) { a_UIcmd_forw(a_UIcmd_get_bw_by_widget(wid)); - } else if (k == 3) { + } else if (k == FL_RIGHT_MOUSE) { a_UIcmd_forw_popup(a_UIcmd_get_bw_by_widget(wid)); } break; case UI_HOME: - if (k == 1) { + if (k == FL_LEFT_MOUSE) { a_UIcmd_home(a_UIcmd_get_bw_by_widget(wid)); } break; case UI_RELOAD: - if (k == 1) { + if (k == FL_LEFT_MOUSE) { a_UIcmd_reload(a_UIcmd_get_bw_by_widget(wid)); } break; case UI_SAVE: - if (k == 1) { + if (k == FL_LEFT_MOUSE) { a_UIcmd_save(a_UIcmd_get_bw_by_widget(wid)); } break; case UI_STOP: - if (k == 1) { + if (k == FL_LEFT_MOUSE) { a_UIcmd_stop(a_UIcmd_get_bw_by_widget(wid)); } break; case UI_BOOK: - if (k == 1) { + if (k == FL_LEFT_MOUSE) { a_UIcmd_book(a_UIcmd_get_bw_by_widget(wid)); } break; case UI_TOOLS: - if (k == 1 || k == 3) { + if (k == FL_LEFT_MOUSE || k == FL_RIGHT_MOUSE) { a_UIcmd_tools(a_UIcmd_get_bw_by_widget(wid), wid); } break; -- cgit v1.2.3 From ea91dbdec1b06589c64c19101a916bab3176c02a Mon Sep 17 00:00:00 2001 From: corvid Date: Mon, 17 Jan 2011 13:54:50 +0000 Subject: fix findbar input focusing The documentation for clear_visible_focus all talks about the keyboard, but but Fl::focus must think that the mouse is an honorary part of the keyboard. Not that tab-to-focus is any horrible behavior for findbar's input anyway. --- src/findbar.cc | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/findbar.cc b/src/findbar.cc index d02bc5d4..dd792833 100644 --- a/src/findbar.cc +++ b/src/findbar.cc @@ -132,7 +132,6 @@ Findbar::Findbar(int width, int height) : i->color(206); i->when(FL_WHEN_ENTER_KEY_ALWAYS); i->callback(search_cb2, this); - i->clear_visible_focus(); next_btn = new Fl_Button(x, border, button_width, height, "Next"); x += button_width + gap; -- cgit v1.2.3 From fd5ecc0d41cefb6ee2e12cf16924490a5804c7e7 Mon Sep 17 00:00:00 2001 From: corvid Date: Mon, 17 Jan 2011 14:24:08 +0000 Subject: deactivated toolbar buttons --- src/ui.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ui.cc b/src/ui.cc index ac2082d5..0ef03adf 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -31,7 +31,8 @@ struct iconset { Fl_Image *ImgMeterOK, *ImgMeterBug, *ImgHome, *ImgReload, *ImgSave, *ImgBook, *ImgTools, - *ImgClear,*ImgSearch, *ImgHelp, *ImgLeft, *ImgRight, *ImgStop; + *ImgClear,*ImgSearch, *ImgHelp, *ImgLeft, *ImgLeftIn, + *ImgRight, *ImgRightIn, *ImgStop, *ImgStopIn; }; static struct iconset standard_icons = { @@ -46,8 +47,11 @@ static struct iconset standard_icons = { 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 = { @@ -62,8 +66,11 @@ static struct iconset small_icons = { standard_icons.ImgSearch, standard_icons.ImgHelp, new Fl_Pixmap(left_s_xpm), - new Fl_Pixmap(right_s_xpm), + new Fl_Pixmap(left_si_xpm), + new Fl_Pixmap(right_i_xpm), + new Fl_Pixmap(right_si_xpm), new Fl_Pixmap(stop_s_xpm), + new Fl_Pixmap(stop_si_xpm), }; @@ -382,11 +389,13 @@ Fl_Pack *UI::make_toolbar(int tw, int th) p1->begin(); Back = b = new Fl_Button(xpos, 0, bw, bh, (lbl) ? "Back" : 0); b->image(icons->ImgLeft); + b->deimage(icons->ImgLeftIn); b->callback(b1_cb, (void *)UI_BACK); b->clear_visible_focus(); Forw = b = new Fl_Button(xpos, 0, bw, bh, (lbl) ? "Forw" : 0); b->image(icons->ImgRight); + b->deimage(icons->ImgRightIn); b->callback(b1_cb, (void *)UI_FORW); b->clear_visible_focus(); @@ -407,6 +416,7 @@ Fl_Pack *UI::make_toolbar(int tw, int th) Stop = b = new Fl_Button(xpos, 0, bw, bh, (lbl) ? "Stop" : 0); b->image(icons->ImgStop); + b->deimage(icons->ImgStopIn); b->callback(b1_cb, (void *)UI_STOP); b->clear_visible_focus(); -- cgit v1.2.3 From 6629806e5680aa844248eca4e0b85c3472b2ae62 Mon Sep 17 00:00:00 2001 From: corvid Date: Mon, 17 Jan 2011 14:44:39 +0000 Subject: more UI button event handling --- src/ui.cc | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/ui.cc b/src/ui.cc index 0ef03adf..e107036b 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -197,13 +197,13 @@ public: */ static void search_cb(Fl_Widget *wid, void *data) { - int k = Fl::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) { + } else if (b == FL_RIGHT_MOUSE) { ((UI*)data)->panel_cb_i(); } } @@ -233,8 +233,8 @@ static void help_cb(Fl_Widget *w, void *) */ static void filemenu_cb(Fl_Widget *wid, void *) { - int k = Fl::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); } } @@ -246,11 +246,11 @@ static void clear_cb(Fl_Widget *w, void *data) { UI *ui = (UI*)data; - int k = Fl::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(); } } @@ -293,53 +293,53 @@ static void location_cb(Fl_Widget *wid, void *data) static void b1_cb(Fl_Widget *wid, void *cb_data) { int bn = VOIDP2INT(cb_data); - int k = Fl::event_button(); - if (k >= FL_LEFT_MOUSE && k <= FL_RIGHT_MOUSE) { - _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 == FL_LEFT_MOUSE) { + if (b == FL_LEFT_MOUSE) { a_UIcmd_back(a_UIcmd_get_bw_by_widget(wid)); - } else if (k == FL_RIGHT_MOUSE) { + } else if (b == FL_RIGHT_MOUSE) { a_UIcmd_back_popup(a_UIcmd_get_bw_by_widget(wid)); } break; case UI_FORW: - if (k == FL_LEFT_MOUSE) { + if (b == FL_LEFT_MOUSE) { a_UIcmd_forw(a_UIcmd_get_bw_by_widget(wid)); - } else if (k == FL_RIGHT_MOUSE) { + } else if (b == FL_RIGHT_MOUSE) { a_UIcmd_forw_popup(a_UIcmd_get_bw_by_widget(wid)); } break; case UI_HOME: - if (k == FL_LEFT_MOUSE) { + if (b == FL_LEFT_MOUSE) { a_UIcmd_home(a_UIcmd_get_bw_by_widget(wid)); } break; case UI_RELOAD: - if (k == FL_LEFT_MOUSE) { + if (b == FL_LEFT_MOUSE) { a_UIcmd_reload(a_UIcmd_get_bw_by_widget(wid)); } break; case UI_SAVE: - if (k == FL_LEFT_MOUSE) { + if (b == FL_LEFT_MOUSE) { a_UIcmd_save(a_UIcmd_get_bw_by_widget(wid)); } break; case UI_STOP: - if (k == FL_LEFT_MOUSE) { + if (b == FL_LEFT_MOUSE) { a_UIcmd_stop(a_UIcmd_get_bw_by_widget(wid)); } break; case UI_BOOK: - if (k == FL_LEFT_MOUSE) { + if (b == FL_LEFT_MOUSE) { a_UIcmd_book(a_UIcmd_get_bw_by_widget(wid)); } break; case UI_TOOLS: - if (k == FL_LEFT_MOUSE || k == FL_RIGHT_MOUSE) { + if (b == FL_LEFT_MOUSE || b == FL_RIGHT_MOUSE) { a_UIcmd_tools(a_UIcmd_get_bw_by_widget(wid), wid); } break; @@ -363,10 +363,10 @@ static void b1_cb(Fl_Widget *wid, void *cb_data) */ static void bugmeter_cb(Fl_Widget *wid, void *data) { - int k = Fl::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)); } } -- cgit v1.2.3 From 5f545e6d355ace8fc21210520c37e2f2a84b56fb Mon Sep 17 00:00:00 2001 From: corvid Date: Sat, 22 Jan 2011 01:04:33 +0000 Subject: tools popup menu --- src/menu.cc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/menu.cc b/src/menu.cc index aaf6756c..036484ac 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -604,8 +604,8 @@ static void Menu_remote_css_cb(Fl_Widget *wid, void*) { Fl_Menu_Item *item = (Fl_Menu_Item*) wid; - _MSG("Menu_remote_css_cb\n"); - prefs.load_stylesheets = item->value() ? 1 : 0; + item->flags ^= FL_MENU_VALUE; + prefs.load_stylesheets = item->flags & FL_MENU_VALUE ? 1 : 0; a_UIcmd_repush(popup_bw); } @@ -616,7 +616,8 @@ static void Menu_embedded_css_cb(Fl_Widget *wid, void*) { Fl_Menu_Item *item = (Fl_Menu_Item*) wid; - prefs.parse_embedded_css = item->value() ? 1 : 0; + item->flags ^= FL_MENU_VALUE; + prefs.parse_embedded_css = item->flags & FL_MENU_VALUE ? 1 : 0; a_UIcmd_repush(popup_bw); } @@ -627,7 +628,9 @@ static void Menu_imgload_toggle_cb(Fl_Widget *wid, void*) { Fl_Menu_Item *item = (Fl_Menu_Item*) wid; - if ((prefs.load_images = item->value() ? 1 : 0)) { + 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) { @@ -642,6 +645,7 @@ static void Menu_imgload_toggle_cb(Fl_Widget *wid, void*) */ void a_Menu_tools_popup(BrowserWindow *bw, void *v_wid) { + const Fl_Menu_Item *item; Fl_Widget *wid = (Fl_Widget*)v_wid; static Fl_Menu_Item pm[] = { @@ -661,6 +665,8 @@ void a_Menu_tools_popup(BrowserWindow *bw, void *v_wid) if (prefs.load_images) pm[2].set(); - pm->popup(wid->x(), wid->y()); + item = pm->popup(wid->x(), wid->y()); + if (item) + ((Fl_Widget *)item)->do_callback(); } -- cgit v1.2.3 From 8db75fab08c074838b303d5009d127020a8605c1 Mon Sep 17 00:00:00 2001 From: corvid Date: Sat, 22 Jan 2011 07:22:24 +0000 Subject: better menu positioning --- src/menu.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/menu.cc b/src/menu.cc index 036484ac..f63e04b8 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -573,6 +573,8 @@ void a_Menu_history_popup(BrowserWindow *bw, int direction) 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. @@ -665,7 +667,7 @@ void a_Menu_tools_popup(BrowserWindow *bw, void *v_wid) if (prefs.load_images) pm[2].set(); - item = pm->popup(wid->x(), wid->y()); + item = pm->popup(wid->x(), wid->y() + wid->h()); if (item) ((Fl_Widget *)item)->do_callback(); } -- cgit v1.2.3 From e5ca46df6de7044051ab73419ee75f8e167917af Mon Sep 17 00:00:00 2001 From: corvid Date: Sun, 23 Jan 2011 16:58:23 +0000 Subject: xembed --- src/xembed.cc | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/xembed.cc b/src/xembed.cc index dda135d0..2039d8c9 100644 --- a/src/xembed.cc +++ b/src/xembed.cc @@ -12,13 +12,14 @@ #include #include +#define FL_INTERNALS #include #include #include #include "xembed.hh" -#if USE_X11 +#ifdef X_PROTOCOL typedef enum { XEMBED_EMBEDDED_NOTIFY = 0, @@ -40,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, @@ -59,13 +60,13 @@ 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 @@ -76,18 +77,21 @@ Xembed::handle(int e) { return Fl_Window::handle(e); } -static int event_handler(int e, Fl_Window *w) { - Atom xembed_atom = XInternAtom (fltk::xdisplay, "_XEMBED", false); +static int event_handler(int e) { + 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. +#if 0 +PORT1.3 w->resize(0, 0, w->w(), w->h()); +#endif break; case XEMBED_WINDOW_DEACTIVATE: break; @@ -105,12 +109,12 @@ static int event_handler(int e, Fl_Window *w) { void Xembed::create() { createInternal(xid); setXembedInfo(1); - fltk::add_event_handler(event_handler); + Fl::add_handler(event_handler); } void Xembed::createInternal(uint32_t parent) { Fl_Window *window = this; - Colormap colormap = fltk::xcolormap; + Colormap colormap = fl_colormap; XSetWindowAttributes attr; attr.border_pixel = 0; @@ -132,18 +136,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) {}; -- cgit v1.2.3 From 0996de0d697c3b5baface97f05b18353f7f30d64 Mon Sep 17 00:00:00 2001 From: corvid Date: Sun, 23 Jan 2011 23:28:22 +0000 Subject: prevent new Fl_Widgets from automatically being added to a Fl_Group --- dw/fltkcomplexbutton.cc | 1 + dw/fltkviewbase.cc | 1 + src/findbar.cc | 15 ++++++++++----- src/uicmd.cc | 2 ++ 4 files changed, 14 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/dw/fltkcomplexbutton.cc b/dw/fltkcomplexbutton.cc index 6efe0181..3ef50238 100644 --- a/dw/fltkcomplexbutton.cc +++ b/dw/fltkcomplexbutton.cc @@ -168,6 +168,7 @@ int ComplexButton::handle(int event) { */ ComplexButton::ComplexButton(int X, int Y, int W, int H, const char *L) : Fl_Group(X,Y,W,H,L) { + Fl_Group::current(0); box(FL_UP_BOX); down_box(FL_NO_BOX); value_ = oldval = 0; diff --git a/dw/fltkviewbase.cc b/dw/fltkviewbase.cc index f29c9a12..5c2a3639 100644 --- a/dw/fltkviewbase.cc +++ b/dw/fltkviewbase.cc @@ -41,6 +41,7 @@ bool FltkViewBase::backBufferInUse; FltkViewBase::FltkViewBase (int x, int y, int w, int h, const char *label): Fl_Group (x, y, w, h, label) { + Fl_Group::current(0); canvasWidth = 1; canvasHeight = 1; bgColor = FL_WHITE; diff --git a/src/findbar.cc b/src/findbar.cc index dd792833..5dd45bd6 100644 --- a/src/findbar.cc +++ b/src/findbar.cc @@ -113,18 +113,21 @@ Findbar::Findbar(int width, int height) : int border = 2; int input_width = width - (2 * border + 4 * (button_width + gap)); int x = border; + + Fl_Group::current(0); + height -= 2 * border; box(FL_PLASTIC_UP_BOX); Fl_Group::hide(); - begin(); 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_visible_focus(); + add(hide_btn); i = new MyInput(x, border, input_width, height); x += input_width + gap; @@ -132,25 +135,27 @@ Findbar::Findbar(int width, int height) : i->color(206); i->when(FL_WHEN_ENTER_KEY_ALWAYS); i->callback(search_cb2, this); + add(i); next_btn = new Fl_Button(x, border, button_width, height, "Next"); x += button_width + gap; next_btn->shortcut(FL_Enter); next_btn->callback(search_cb, this); next_btn->clear_visible_focus(); + add(next_btn); 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(); - x += button_width + gap; + add(prev_btn); check_btn = new Fl_Check_Button(x, border, 2*button_width, height, "Case-sensitive"); - check_btn->clear_visible_focus(); x += 2 * button_width + gap; - - end(); + check_btn->clear_visible_focus(); + add(check_btn); if (prefs.show_tooltip) { hide_btn->tooltip("Hide"); diff --git a/src/uicmd.cc b/src/uicmd.cc index 9122a105..04d1f0f6 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -232,6 +232,7 @@ class CustTabGroup : public Fl_Tabs { public: CustTabGroup (int x, int y, int ww, int wh, const char *lbl=0) : Fl_Tabs(x,y,ww,wh,lbl) { + Fl_Group::current(0); // The parameter pager is cloned, so free it. // CustShrinkTabPager *cp = new CustShrinkTabPager(); // this->pager(cp); @@ -427,6 +428,7 @@ BrowserWindow *a_UIcmd_browser_window_new(int ww, int wh, else win = new Fl_Double_Window(ww, wh); + Fl_Group::current(0); //may need a handler for this // win->shortcut(0); // Ignore Escape CustTabGroup *DilloTabs = new CustTabGroup(0, 0, ww, wh); -- cgit v1.2.3 From 077343565fc72d251b2ef044c82d179b2443d930 Mon Sep 17 00:00:00 2001 From: corvid Date: Mon, 24 Jan 2011 16:34:06 +0000 Subject: remove a FLTK2 workaround --- src/menu.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src') diff --git a/src/menu.cc b/src/menu.cc index f63e04b8..6c5835f8 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -509,7 +509,6 @@ 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; Fl_Widget *wid = (Fl_Widget*)v_wid; static Fl_Menu_Item pm[] = { @@ -530,9 +529,7 @@ void a_Menu_file_popup(BrowserWindow *bw, void *v_wid) popup_bw = bw; popup_x = wid->x(); - popup_y = wid->y() + wid->h() + - // WORKAROUND: ?? wid->y() doesn't count tabs ?? - (((Fl_Group*)ui->tabs())->children() > 1 ? 20 : 0); + popup_y = wid->y() + wid->h(); a_Url_free(popup_url); popup_url = NULL; -- cgit v1.2.3 From 274f556b3b4b787be97390d4c951101c7e2ae97c Mon Sep 17 00:00:00 2001 From: corvid Date: Tue, 25 Jan 2011 04:34:28 +0000 Subject: dialog text window --- src/dialog.cc | 50 +++++++++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/dialog.cc b/src/dialog.cc index 5db21583..509614d9 100644 --- a/src/dialog.cc +++ b/src/dialog.cc @@ -28,14 +28,6 @@ #include "misc.h" #include "prefs.h" -/* - * Close dialog window. - */ -static void window_close_cb(Fl_Widget *, void *vwin) -{ - delete (Fl_Window*)vwin; -} - /* * Display a message in a popup window. */ @@ -113,41 +105,57 @@ char *a_Dialog_open_file(const char *msg, 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) { -#if 0 -PORT1.3 - //int wh = 600, ww = 650, bh = 30; int wh = prefs.height, ww = prefs.width, bh = 30; - Font *textfont = font(prefs.font_monospace, 0); +// Font *textfont = font(prefs.font_monospace, 0); - Fl_Window *window = new Fl_Window(ww, wh, title ? title : "Untitled"); - window->callback(window_close_cb, window); - window->begin(); + Fl_Window *window = new Fl_Window(ww, wh, title ? title : "Dillo text"); + Fl_Group::current(0); + + 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()->text(txt); + td->buffer(buf); +#if 0 +PORT1.3 if (textfont) td->textfont(textfont); td->textsize((int) rint(13.0 * prefs.font_factor)); fltk::setfont(td->textfont(), td->textsize()); +#else + td->textfont(FL_COURIER); + td->textsize((int) rint(13.0 * prefs.font_factor)); +#endif /* 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->size(ww+1,wh-bh); + window->add(td); Fl_Return_Button *b = new Fl_Return_Button (0, wh-bh, ww, bh, "Close"); - b->callback(window_close_cb, window); + b->callback(text_window_close_cb, td); + window->add(b); + window->callback(text_window_close_cb, td); window->resizable(td); - window->end(); window->show(); -#endif } /*--------------------------------------------------------------------------*/ -- cgit v1.2.3 From 1031b6670a99d91c3d0d9d71c3c9b259f7f04894 Mon Sep 17 00:00:00 2001 From: corvid Date: Tue, 25 Jan 2011 05:07:53 +0000 Subject: let caller know user/pass dialog isn't working yet --- src/dialog.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/dialog.cc b/src/dialog.cc index 509614d9..c4d3f0dc 100644 --- a/src/dialog.cc +++ b/src/dialog.cc @@ -248,7 +248,7 @@ PORT1.3 */ int a_Dialog_user_password(const char *message, UserPasswordCB cb, void *vp) { - int ok, + int ok = 0, window_w = 300, window_h = 280, input_x = 80, input_w = 200, input_h = 30, button_y = 230, button_h = 30; -- cgit v1.2.3 From 2a51e4ae8a467b83ba98818cf52cf5e0b9270877 Mon Sep 17 00:00:00 2001 From: corvid Date: Tue, 25 Jan 2011 21:13:56 +0000 Subject: FL_NO_BOX for tabs when labels not shown --- src/uicmd.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/uicmd.cc b/src/uicmd.cc index 04d1f0f6..d22c8e32 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -233,6 +233,7 @@ public: CustTabGroup (int x, int y, int ww, int wh, const char *lbl=0) : Fl_Tabs(x,y,ww,wh,lbl) { Fl_Group::current(0); + box(FL_NO_BOX); // The parameter pager is cloned, so free it. // CustShrinkTabPager *cp = new CustShrinkTabPager(); // this->pager(cp); @@ -341,14 +342,18 @@ public: resizable (NULL); } - if (children () < 2) + if (children () < 2) { + box(FL_NO_BOX); hideLabels (); + } } void add (Fl_Widget *w) { Fl_Tabs::add (w); - if (children () > 1) + if (children () > 1) { + box(FL_THIN_UP_BOX); showLabels (); + } } void hideLabels() { -- cgit v1.2.3 From 0ba2621dba5a58a84dee5944cd89acd5541b67a0 Mon Sep 17 00:00:00 2001 From: corvid Date: Wed, 26 Jan 2011 02:00:50 +0000 Subject: fix the temporary choice5 code --- src/dialog.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/dialog.cc b/src/dialog.cc index c4d3f0dc..5db6b54f 100644 --- a/src/dialog.cc +++ b/src/dialog.cc @@ -222,7 +222,7 @@ PORT1.3 return choice5_answer; #else -return fl_choice(QuestionTxt, alt1, alt2, alt3); +return 1 + fl_choice(QuestionTxt, alt1, alt2, alt3); #endif } -- cgit v1.2.3 From 39174335692871d5375bc3d4581b661d4f2d7e67 Mon Sep 17 00:00:00 2001 From: corvid Date: Thu, 3 Feb 2011 08:16:56 +0000 Subject: rm clear_visible_focus() on tabs --- src/uicmd.cc | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/uicmd.cc b/src/uicmd.cc index d22c8e32..885d704e 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -437,7 +437,6 @@ BrowserWindow *a_UIcmd_browser_window_new(int ww, int wh, //may need a handler for this // win->shortcut(0); // Ignore Escape CustTabGroup *DilloTabs = new CustTabGroup(0, 0, ww, wh); - DilloTabs->clear_visible_focus(); DilloTabs->selection_color(156); win->add(DilloTabs); -- cgit v1.2.3 From 1b3d3f9ef09191c3086592f9273ccffa683fa516 Mon Sep 17 00:00:00 2001 From: corvid Date: Fri, 4 Feb 2011 17:08:37 +0000 Subject: use our own pthread flags in src/Makefile --- src/Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') 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 \ -- cgit v1.2.3 From fc99fd7a3497252746618a0d6f94b823aed1ff12 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Sun, 6 Feb 2011 14:40:09 -0300 Subject: imported patch choice5 --- src/dialog.cc | 56 +++++++++++++++++++++++++------------------------------- src/dialog.hh | 2 -- src/nav.c | 6 +++--- src/uicmd.cc | 12 ++++++------ 4 files changed, 34 insertions(+), 42 deletions(-) (limited to 'src') diff --git a/src/dialog.cc b/src/dialog.cc index 5db6b54f..c932118e 100644 --- a/src/dialog.cc +++ b/src/dialog.cc @@ -36,18 +36,6 @@ void a_Dialog_msg(const char *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) - */ -int a_Dialog_choice3(const char *msg, - const char *b0, const char *b1, const char *b2) -{ - return fl_choice(msg, b0, b1, b2); -} - /* * Dialog for one line of Input with a message. */ @@ -161,35 +149,33 @@ PORT1.3 /*--------------------------------------------------------------------------*/ static int choice5_answer; -#if 0 -PORT1.3 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(); } -#endif /* - * 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, const char *alt1, const char *alt2, const char *alt3, const char *alt4, const char *alt5) { -#if 0 -PORT1.3 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); + ww = 140 + nb*(bw+10); Fl_Window *window = new Fl_Window(ww,wh,"Choice5"); window->begin(); @@ -197,10 +183,20 @@ PORT1.3 ib->begin(); window->resizable(ib); - Fl_Box *box = new Fl_Box(0,0,ww,wh-bh, QuestionTxt); - box->box(FL_DOWN_BOX); - box->labelfont(FL_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); Fl_Button *b; int xpos = 0, gap = 8; @@ -212,18 +208,16 @@ PORT1.3 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(); - delete window; - _MSG("Choice5 answer = %d\n", choice5_answer); + window->show(); + while (window->shown()) + Fl::wait(); + _MSG("a_Dialog_choice5 answer = %d\n", choice5_answer); return choice5_answer; -#else -return 1 + fl_choice(QuestionTxt, alt1, alt2, alt3); -#endif } 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/nav.c b/src/nav.c index c5311cfb..7f9d03db 100644 --- a/src/nav.c +++ b/src/nav.c @@ -488,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/uicmd.cc b/src/uicmd.cc index 885d704e..e005aaf6 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -374,9 +374,9 @@ static void win_cb (Fl_Widget *w, void *cb_data) { CustTabGroup *tabs = (CustTabGroup*) cb_data; if (tabs->children () > 1) - choice = a_Dialog_choice3 ("Window contains more than one tab.", - "Close all tabs", "Cancel", NULL); - if (choice == 0) + choice = a_Dialog_choice5("Window contains more than one tab.", + "Close all tabs", "Cancel", NULL, NULL, NULL); + if (choice == 1) while (tabs->children()) a_UIcmd_close_bw(a_UIcmd_get_bw_by_widget(tabs->child(0))); } @@ -573,9 +573,9 @@ void a_UIcmd_close_all_bw(void *) int choice = 0; 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.", + "Close all tabs and windows", "Cancel", NULL, NULL, NULL); + if (choice == 1) while ((bw = a_Bw_get(0))) a_UIcmd_close_bw((void*)bw); } -- cgit v1.2.3 From f359543fa273a205b0111e824d34fca839cd3b45 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Sun, 6 Feb 2011 22:13:53 -0300 Subject: choice5 part2 (minor fix) --- src/uicmd.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/uicmd.cc b/src/uicmd.cc index e005aaf6..0c25a4f4 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -370,7 +370,7 @@ public: //---------------------------------------------------------------------------- static void win_cb (Fl_Widget *w, void *cb_data) { - int choice = 0; + int choice = 1; CustTabGroup *tabs = (CustTabGroup*) cb_data; if (tabs->children () > 1) @@ -570,7 +570,7 @@ 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_choice5("More than one open tab or Window.", -- cgit v1.2.3 From a11a2e0366866db9409760d312eda22a5bf0a690 Mon Sep 17 00:00:00 2001 From: corvid Date: Wed, 9 Feb 2011 01:31:14 +0000 Subject: disable symbol-interpretation in labels There was some discussion of how to do this last month in fltk-dev http://fltk.org/newsgroups.php?s10630+gfltk.development+v10640+T0 --- dw/fltkcomplexbutton.cc | 1 - dw/fltkplatform.cc | 24 +----------------------- dw/fltkplatform.hh | 1 - dw/fltkui.cc | 4 ---- src/dillo.cc | 26 +++++++++++++++++++++++++- 5 files changed, 26 insertions(+), 30 deletions(-) (limited to 'src') diff --git a/dw/fltkcomplexbutton.cc b/dw/fltkcomplexbutton.cc index e1427a9e..435ccb03 100644 --- a/dw/fltkcomplexbutton.cc +++ b/dw/fltkcomplexbutton.cc @@ -173,7 +173,6 @@ ComplexButton::ComplexButton(int X, int Y, int W, int H, const char *L) down_box(FL_NO_BOX); value_ = oldval = 0; shortcut_ = 0; - set_flag(SHORTCUT_LABEL); } ComplexButton::~ComplexButton() { diff --git a/dw/fltkplatform.cc b/dw/fltkplatform.cc index b3e33bce..dba4ab3f 100644 --- a/dw/fltkplatform.cc +++ b/dw/fltkplatform.cc @@ -191,26 +191,6 @@ FltkColor * FltkColor::create (int col) FltkTooltip::FltkTooltip (const char *text) : Tooltip(text) { shown = false; - - if (!text || !strpbrk(text, "&@")) { - escaped_str = NULL; - } else { - /* - * WORKAROUND: ::fltk::Tooltip::tooltip_timeout() makes instance_ - * if necessary, and immediately uses it. This means that we can't - * get our hands on it to set RAW_LABEL until after it has been shown - * once. So let's escape the special characters ourselves. - */ - const char *src = text; - char *dest = escaped_str = (char *) malloc(strlen(text) * 2 + 1); - - while (*src) { - if (*src == '&' || *src == '@') - *dest++ = *src; - *dest++ = *src++; - } - *dest = '\0'; - } } FltkTooltip::~FltkTooltip () @@ -221,8 +201,6 @@ probably can remember the one from onEnter if (shown) Fl_Tooltip::exit(); #endif - if (escaped_str) - free(escaped_str); } FltkTooltip *FltkTooltip::create (const char *text) @@ -235,7 +213,7 @@ void FltkTooltip::onEnter() Fl_Widget *widget = Fl::belowmouse(); Fl_Tooltip::enter_area(widget, widget->x(), widget->y(), widget->w(), - widget->h(), escaped_str ? escaped_str : str); + widget->h(), str); shown = true; } diff --git a/dw/fltkplatform.hh b/dw/fltkplatform.hh index 791dcc82..6a81da4d 100644 --- a/dw/fltkplatform.hh +++ b/dw/fltkplatform.hh @@ -60,7 +60,6 @@ private: FltkTooltip (const char *text); ~FltkTooltip (); bool shown; - char *escaped_str; /* fltk WORKAROUND */ public: static FltkTooltip *create(const char *text); void onEnter(); diff --git a/dw/fltkui.cc b/dw/fltkui.cc index 0ffafe35..9ce5a816 100644 --- a/dw/fltkui.cc +++ b/dw/fltkui.cc @@ -244,7 +244,6 @@ Fl_Widget *FltkLabelButtonResource::createNewWidget (core::Allocation Fl_Button *button = new Fl_Button (allocation->x, allocation->y, allocation->width, allocation->ascent + allocation->descent, label); -// button->clear_flag (SHORTCUT_LABEL); button->callback (widgetCallback, this); button->when (FL_WHEN_RELEASE); return button; @@ -736,7 +735,6 @@ Fl_Button *FltkCheckButtonResource::createNewButton (core::Allocation Fl_Check_Button *cb = new Fl_Check_Button (allocation->x, allocation->y, allocation->width, allocation->ascent + allocation->descent); -// cb->clear_flag (SHORTCUT_LABEL); return cb; } @@ -848,7 +846,6 @@ Fl_Button *FltkRadioButtonResource::createNewButton (core::Allocation Fl_Button *button = new Fl_Round_Button (allocation->x, allocation->y, allocation->width, allocation->ascent + allocation->descent); -// button->clear_flag (SHORTCUT_LABEL); button->when (FL_WHEN_CHANGED); button->callback (widgetCallback, this); button->type (FL_TOGGLE_BUTTON); @@ -1061,7 +1058,6 @@ Fl_Widget *FltkListResource::createNewWidget (core::Allocation *allocation) tree->showroot(0); tree->connectorstyle(FL_TREE_CONNECTOR_NONE); tree->marginleft(-14); -// tree->clear_flag (SHORTCUT_LABEL); tree->callback(widgetCallback,this); tree->when(FL_WHEN_CHANGED); diff --git a/src/dillo.cc b/src/dillo.cc index 440457a6..86f0a57b 100644 --- a/src/dillo.cc +++ b/src/dillo.cc @@ -24,8 +24,9 @@ #include #include -#include #include +#include +#include #include "msg.h" #include "paths.hh" @@ -167,6 +168,25 @@ static OptID getCmdOption(const CLI_options *options, int argc, char **argv, } return opt_id; } + +static void custLabelDraw(const Fl_Label* o, int X, int Y, int W, int H, + Fl_Align align) +{ + const int interpret_symbols = 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_font(o->font, o->size); + fl_measure(o->value, W, H, interpret_symbols); +} + #if 0 PORT1.3 /* @@ -318,6 +338,10 @@ int main(int argc, char **argv) // Sets WM_CLASS hint on X11 Fl_Window::default_xclass("dillo"); + + // Disable '@' interpretation in labels + Fl::set_labeltype(FL_NORMAL_LABEL, custLabelDraw, custLabelMeasure); + #if 0 PORT1.3 checkPreferredFonts(); -- cgit v1.2.3 From fd4669bd343070fa3ecebb5c0bc6a2f965a68346 Mon Sep 17 00:00:00 2001 From: corvid Date: Tue, 15 Feb 2011 19:02:54 +0000 Subject: make_current() Here are the gory fl_text_extents()-related details: http://www.fltk.org/str.php?L2550 --- src/dillo.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/dillo.cc b/src/dillo.cc index 86f0a57b..3811d1d2 100644 --- a/src/dillo.cc +++ b/src/dillo.cc @@ -355,6 +355,12 @@ PORT1.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); -- cgit v1.2.3 From 151ad1018b0c1481474617ca96d393d95dd8a07e Mon Sep 17 00:00:00 2001 From: corvid Date: Fri, 18 Feb 2011 02:06:35 +0000 Subject: findbar activation the Fl_Input would eat the shift-enter keypress, meaning that the Previous button never got its shortcut. --- src/findbar.cc | 16 +--------------- src/findbar.hh | 1 - 2 files changed, 1 insertion(+), 16 deletions(-) (limited to 'src') diff --git a/src/findbar.cc b/src/findbar.cc index 5dd45bd6..2bda5452 100644 --- a/src/findbar.cc +++ b/src/findbar.cc @@ -81,19 +81,6 @@ void Findbar::searchBackwards_cb(Fl_Widget *, void *vfb) } } -/* - * Find next occurrence of input key - */ -void Findbar::search_cb2(Fl_Widget *widget, void *vfb) -{ - /* - * Somehow fltk even regards the first loss of focus for the - * window as a WHEN_ENTER_KEY_ALWAYS event. - */ - if (Fl::event_key() == FL_Enter) - search_cb(widget, vfb); -} - /* * Hide the search bar */ @@ -133,8 +120,7 @@ Findbar::Findbar(int width, int height) : x += input_width + gap; resizable(i); i->color(206); - i->when(FL_WHEN_ENTER_KEY_ALWAYS); - i->callback(search_cb2, this); + i->when(FL_WHEN_NEVER); add(i); next_btn = new Fl_Button(x, border, button_width, height, "Next"); diff --git a/src/findbar.hh b/src/findbar.hh index 77d4a685..11986407 100644 --- a/src/findbar.hh +++ b/src/findbar.hh @@ -20,7 +20,6 @@ class Findbar : public Fl_Group { static void search_cb (Fl_Widget *, void *); static void searchBackwards_cb (Fl_Widget *, void *); - static void search_cb2 (Fl_Widget *, void *); static void hide_cb (Fl_Widget *, void *); public: -- cgit v1.2.3 From e90273b90ea846855dfeb5fd675104d26114701e Mon Sep 17 00:00:00 2001 From: corvid Date: Thu, 24 Feb 2011 04:56:13 +0000 Subject: add some band-aids again for now for this whole events-during-deletion problem Conceptually, what feels like it 'should' happen when the form widgets are deleted and MOVEs and LEAVEs and whatnot are flying around is for the viewport not to do anything with events. But it would want to accept FOCUS, and no doubt there are other cases to make it not so simple. --- dw/layout.cc | 3 +++ src/uicmd.cc | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/dw/layout.cc b/dw/layout.cc index 3680e0c8..d1fecf48 100644 --- a/dw/layout.cc +++ b/dw/layout.cc @@ -852,6 +852,9 @@ void Layout::moveToWidget (Widget *newWidgetAtPoint, ButtonState state) int trackLen, i; EventCrossing crossingEvent; + if (!topLevel) + return; + if (newWidgetAtPoint != widgetAtPoint) { // The mouse pointer has been moved into another widget. if (newWidgetAtPoint && widgetAtPoint) diff --git a/src/uicmd.cc b/src/uicmd.cc index 885d704e..268321d6 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -551,7 +551,6 @@ void a_UIcmd_close_bw(void *vbw) MSG("a_UIcmd_close_bw\n"); a_Bw_stop_clients(bw, BW_Root + BW_Img + BW_Force); - delete(layout); if (ui->tabs()) { ui->tabs()->remove(ui); if (ui->tabs()->value()) @@ -559,6 +558,7 @@ void a_UIcmd_close_bw(void *vbw) else ui->tabs()->window()->hide(); } + delete(layout); delete(ui); a_Bw_free(bw); -- cgit v1.2.3 From 2ec3aadaaa3e850c7ed1019c053d8672c0b0b363 Mon Sep 17 00:00:00 2001 From: corvid Date: Fri, 25 Feb 2011 07:00:11 +0000 Subject: page title a_UIcmd_set_page_title() requires the selected child to have been changed already. --- src/uicmd.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/uicmd.cc b/src/uicmd.cc index 268321d6..b921734f 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -272,6 +272,7 @@ public: BrowserWindow *bw = a_UIcmd_get_bw_by_widget(new_focus); const char *title = a_History_get_title(NAV_TOP_UIDX(bw), 1); + value(new_focus); a_UIcmd_set_page_title(bw, title ? title : ""); } // custom pager -- cgit v1.2.3 From f0f13935151ad61c4f31c5cf4047053f175f2575 Mon Sep 17 00:00:00 2001 From: corvid Date: Fri, 25 Feb 2011 07:22:30 +0000 Subject: fl_choice does not behave like fltk::choice did --- src/dialog.cc | 3 +-- src/nav.c | 4 ++-- src/uicmd.cc | 10 +++++----- 3 files changed, 8 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/dialog.cc b/src/dialog.cc index 5db6b54f..a2b34fa9 100644 --- a/src/dialog.cc +++ b/src/dialog.cc @@ -38,9 +38,8 @@ void a_Dialog_msg(const char *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) + * Return: 0, 1 or 2 (esc = 0, window close = 0, enter = 1) */ int a_Dialog_choice3(const char *msg, const char *b0, const char *b1, const char *b2) diff --git a/src/nav.c b/src/nav.c index c5311cfb..253a7708 100644 --- a/src/nav.c +++ b/src/nav.c @@ -489,8 +489,8 @@ static void Nav_reload_callback(void *data) } 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" */ + "No", "Yes", "Cancel"); + confirmed = (choice == 1); /* "Yes" */ } if (confirmed) { diff --git a/src/uicmd.cc b/src/uicmd.cc index b921734f..ab053dfb 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -376,8 +376,8 @@ static void win_cb (Fl_Widget *w, void *cb_data) { if (tabs->children () > 1) choice = a_Dialog_choice3 ("Window contains more than one tab.", - "Close all tabs", "Cancel", NULL); - if (choice == 0) + "Cancel", "Close all tabs", NULL); + if (choice == 1) while (tabs->children()) a_UIcmd_close_bw(a_UIcmd_get_bw_by_widget(tabs->child(0))); } @@ -574,9 +574,9 @@ void a_UIcmd_close_all_bw(void *) int choice = 0; 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_choice3 ("More than one open tab or window.", + "Cancel", "Close all tabs and windows", NULL); + if (choice == 1) while ((bw = a_Bw_get(0))) a_UIcmd_close_bw((void*)bw); } -- cgit v1.2.3 From 97580cb82d95b69d42df91c332767cf14bdb13cc Mon Sep 17 00:00:00 2001 From: corvid Date: Sat, 26 Feb 2011 19:07:08 +0000 Subject: remove tab limit workaround from fltk2 Skimming through Fl_Tabs.cxx, I didn't see any obvious limits. More importantly, I held down ^T for a full minute, used the browser briefly, and then held down ^Q for a full minute. No problems seen. --- src/uicmd.cc | 5 ----- 1 file changed, 5 deletions(-) (limited to 'src') diff --git a/src/uicmd.cc b/src/uicmd.cc index ab053dfb..90c8f33c 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -503,11 +503,6 @@ static BrowserWindow *UIcmd_tab_new(const void *vbw) 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); - // 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()); -- cgit v1.2.3 From 2423ac309789f13e104fc629c5a60c3c4947dfc4 Mon Sep 17 00:00:00 2001 From: corvid Date: Wed, 2 Mar 2011 04:49:18 +0000 Subject: disable shortcut drawing in labels --- src/dillo.cc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/dillo.cc b/src/dillo.cc index 3811d1d2..c7a0cbc3 100644 --- a/src/dillo.cc +++ b/src/dillo.cc @@ -174,6 +174,8 @@ static void custLabelDraw(const Fl_Label* o, int X, int Y, int W, int H, { 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); @@ -183,6 +185,8 @@ 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); } -- cgit v1.2.3 From 8edebf4f7e3775f3242ac257741c3fc1510f2d79 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Wed, 9 Mar 2011 14:17:01 -0300 Subject: Initial changes to make the tiny panel mode work --- src/ui.cc | 368 +++++++++++++++++++++++++++++++------------------------------- src/ui.hh | 17 +-- 2 files changed, 191 insertions(+), 194 deletions(-) (limited to 'src') diff --git a/src/ui.cc b/src/ui.cc index e107036b..25f1fb01 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -80,6 +80,43 @@ static struct iconset *icons = &standard_icons; * Local sub classes */ +//---------------------------------------------------------------------------- +/* + * Used to reposition group's widgets when some of them are hidden + */ +class Fl_CustGroup : public Fl_Group { +public: + Fl_CustGroup(int x,int y,int w ,int h,const char *l = 0) : + Fl_Group(x,y,w,h,l) { }; + void rearrange(void) { + int n = children(), xpos = 0, r_x1, r_i = -1, i; + + init_sizes(); + for (i = 0; i < n; ++i) { + if (child(i) == resizable()) { + r_i = i; + r_x1 = xpos; + break; + } + if (child(i)->visible()) { + child(i)->position(xpos, child(i)->y()); + xpos += child(i)->w(); + } + } + if (r_i < 0) + return; + xpos = w(); + for (i = n - 1; i > r_i; --i) { + if (child(i)->visible()) { + xpos -= child(i)->w(); + child(i)->position(xpos, child(i)->y()); + } + } + child(r_i)->resize(r_x1, child(r_i)->y(), xpos-r_x1, child(r_i)->h()); + redraw(); + } +}; + //---------------------------------------------------------------------------- /* @@ -173,8 +210,8 @@ public: padding = w > 2 ? w/2 : 1; } copy_label(lbl); - measure_label(w,h); - size(w+padding,h); + //measure_label(w,h); + //size(w+padding,this->h()); redraw_label(); } }; @@ -380,58 +417,41 @@ static void bugmeter_cb(Fl_Widget *wid, void *data) //---------------------------- /* - * Create the archetipic browser buttons + * Make a generic navigation button */ -Fl_Pack *UI::make_toolbar(int tw, int th) +Fl_Button *UI::make_button(const char *label, + Fl_Image *img, Fl_Image *deimg, + int b_n, int start) { - Fl_Button *b; - Fl_Pack *p1=new Fl_Pack(0,0,tw,th); - p1->begin(); - Back = b = new Fl_Button(xpos, 0, bw, bh, (lbl) ? "Back" : 0); - b->image(icons->ImgLeft); - b->deimage(icons->ImgLeftIn); - b->callback(b1_cb, (void *)UI_BACK); - b->clear_visible_focus(); - - Forw = b = new Fl_Button(xpos, 0, bw, bh, (lbl) ? "Forw" : 0); - b->image(icons->ImgRight); - b->deimage(icons->ImgRightIn); - b->callback(b1_cb, (void *)UI_FORW); - b->clear_visible_focus(); - - Home = b = new Fl_Button(xpos, 0, bw, bh, (lbl) ? "Home" : 0); - b->image(icons->ImgHome); - b->callback(b1_cb, (void *)UI_HOME); - b->clear_visible_focus(); - - Reload = b = new Fl_Button(xpos, 0, bw, bh, (lbl) ? "Reload" : 0); - b->image(icons->ImgReload); - b->callback(b1_cb, (void *)UI_RELOAD); - b->clear_visible_focus(); - - Save = b = new Fl_Button(xpos, 0, bw, bh, (lbl) ? "Save" : 0); - b->image(icons->ImgSave); - b->callback(b1_cb, (void *)UI_SAVE); - b->clear_visible_focus(); - - Stop = b = new Fl_Button(xpos, 0, bw, bh, (lbl) ? "Stop" : 0); - b->image(icons->ImgStop); - b->deimage(icons->ImgStopIn); - b->callback(b1_cb, (void *)UI_STOP); - b->clear_visible_focus(); - - Bookmarks = b = new Fl_Button(xpos, 0, bw, bh, (lbl) ? "Book" : 0); - b->image(icons->ImgBook); - b->callback(b1_cb, (void *)UI_BOOK); - b->clear_visible_focus(); - - Tools = b = new Fl_Button(xpos, 0, bw, bh, (lbl) ? "Tools" : 0); - b->image(icons->ImgTools); - b->callback(b1_cb, (void *)UI_TOOLS); - b->clear_visible_focus(); + if (start) + p_xpos = 0; + + Fl_Button *b = new Fl_Button(p_xpos, p_ypos, bw, bh, (lbl) ? label : NULL); + if (img) + b->image(img); + if (deimg) + b->deimage(deimg); + b->callback(b1_cb, (void *)b_n); + b->clear_visible_focus(); + b->labelsize(12); + b->box(FL_NO_BOX); + p_xpos += bw; + return b; +} - p1->type(Fl_Pack::HORIZONTAL); - p1->end(); +/* + * Create the archetipic browser buttons + */ +void UI::make_toolbar(int tw, int th) +{ + 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"); @@ -443,40 +463,41 @@ Fl_Pack *UI::make_toolbar(int tw, int th) Bookmarks->tooltip("View bookmarks"); Tools->tooltip("Settings"); } - return p1; } /* * Create the location box (Clear/Input/Search) */ -Fl_Pack *UI::make_location() +void UI::make_location(int ww) { Fl_Button *b; - Fl_Pack *pg = new Fl_Pack(0,0,0,0); - pg->begin(); - Clear = b = new CustButton(2,2,16,22,0); + + Clear = b = new CustButton(p_xpos,0,16,lh,0); b->image(icons->ImgClear); b->callback(clear_cb, this); b->clear_visible_focus(); + b->box(FL_THIN_UP_BOX); + p_xpos += b->w(); - Fl_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(FL_WHEN_ENTER_KEY); i->callback(location_cb, this); + p_xpos += i->w(); - Search = b = new Fl_Button(0,0,16,22,0); + Search = b = new Fl_Button(p_xpos,0,16,lh,0); b->image(icons->ImgSearch); b->callback(search_cb, this); b->clear_visible_focus(); + b->box(FL_THIN_UP_BOX); + p_xpos += b->w(); - Help = b = new Fl_Button(0,0,16,22,0); + Help = b = new Fl_Button(p_xpos,0,16,lh,0); b->image(icons->ImgHelp); b->callback(help_cb, this); b->clear_visible_focus(); - - pg->type(Fl_Pack::HORIZONTAL); - pg->resizable(i); - pg->end(); + 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."); @@ -484,30 +505,26 @@ Fl_Pack *UI::make_location() Search->tooltip("Search the Web"); Help->tooltip("Help"); } - return pg; } /* * Create the progress bars */ -Fl_Pack *UI::make_progress_bars(int wide, int thin_up) +void UI::make_progress_bars(int wide, int thin_up) { - ProgBox = new Fl_Pack(0,0,0,0); - ProgBox->begin(); // Images - IProg = new CustProgressBox(0,0,0,0); + 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 = 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(Fl_Pack::HORIZONTAL); - ProgBox->end(); - - return ProgBox; } /* @@ -519,14 +536,15 @@ Fl_Widget *UI::make_filemenu_button() Fl_Button *btn; int w,h, padding; - FileButton = btn = new Fl_Button(0,0,0,0,"W"); + FileButton = btn = new Fl_Button(p_xpos,0,0,0,"W"); 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->size(w+padding,h); + btn->size(w+padding,PanelSize == P_tiny ? bh : lh); + p_xpos += btn->w(); _MSG("UI::make_filemenu_button w=%d h=%d padding=%d\n", w, h, padding); btn->box(PanelSize == P_large ? FL_FLAT_BOX : FL_THIN_UP_BOX); btn->callback(filemenu_cb, this); @@ -542,10 +560,11 @@ Fl_Widget *UI::make_filemenu_button() /* * Create the control panel */ -Fl_Group *UI::make_panel(int ww) +void UI::make_panel(int ww) { Fl_Widget *w; - Fl_Group *g1, *g2, *g3; + Fl_CustGroup *g1; + Fl_Group *g2, *g3; Fl_Pack *pg; if (PanelSize > P_large) { @@ -558,105 +577,90 @@ Fl_Group *UI::make_panel(int ww) 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, fh = 0, lh = 22, lbl = 0; else - xpos = 0, bw = 28, bh = 28, fh = 0, lh = 28, lbl = 0; + bw = 28, bh = 28, fh = 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, fh = 0, lh = 20, lbl = 0; else - xpos = 0, bw = 28, bh = 28, fh = 0, lh = 28, lbl = 0; + bw = 28, bh = 28, fh = 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, fh = 0, lh = 22, lbl = 1; else - xpos = 0, bw = 45, bh = 45, fh = 0, lh = 28, lbl = 1; + bw = 45, bh = 45, fh = 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, fh = 22, lh = 22, lbl = 1; else - xpos = 0, bw = 45, bh = 45, fh = 24, lh = 28, lbl = 1; + bw = 45, bh = 45, fh = 24, lh = 28, lbl = 1; } if (PanelSize == P_tiny) { - g1 = new Fl_Group(0,0,ww,bh); + g1 = new Fl_CustGroup(0,0,ww,bh); // Toolbar - pg = make_toolbar(ww,bh); - pg->box(FL_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); - + make_toolbar(ww,bh); + make_filemenu_button(); + make_location(ww); + g1->resizable(Location); + make_progress_bars(0,1); + g1->box(FL_THIN_UP_FRAME); + g1->end(); } else { - g1 = new Fl_Group(0,0,ww,fh+lh+bh); - g1->begin(); - // File menu - if (PanelSize == P_large) { - g3 = new Fl_Group(0,0,ww,lh); - g3->box(FL_FLAT_BOX); - Fl_Widget *bn = make_filemenu_button(); - g3->add(bn); - g3->add_resizable(*new Fl_Box(bn->w(),0,ww - bn->w(),lh)); - - g2 = new Fl_Group(0,fh,ww,lh); - g2->begin(); - pg = make_location(); - pg->size(ww,lh); - } else { - g2 = new Fl_Pack(0,fh,ww,lh); - g2->type(Fl_Pack::HORIZONTAL); - g2->begin(); + // File menu + if (PanelSize == P_large) { + g3 = new Fl_Group(0,0,ww,lh); + g3->box(FL_FLAT_BOX); + Fl_Widget *bn = make_filemenu_button(); + g3->add(bn); + g3->add_resizable(*new Fl_Box(bn->w(),0,ww - bn->w(),lh)); + + g2 = new Fl_Group(0,fh,ww,lh); + g2->begin(); + //pg = make_location(); + pg->size(ww,lh); + } else { + g2 = new Fl_CustGroup(0,0,ww,lh); make_filemenu_button(); - pg = make_location(); - } - - g2->resizable(pg); - g2->end(); + make_location(ww); + g2->resizable(Location); + g2->end(); + } // Toolbar - g3 = new Fl_Group(0,fh+lh,ww,bh); + //p_ypos += g2->y(); + p_ypos = 0; + //g3 = new Fl_Group(0,fh+lh,ww,bh); + g3 = new Fl_Group(0,p_ypos,ww,bh); g3->begin(); - pg = make_toolbar(ww,bh); - //w = new Fl_Box(0,0,0,0,"i n v i s i b l e"); - w = new Fl_Box(0,0,0,0,0); - pg->add(w); - pg->resizable(w); - + make_toolbar(ww,bh); + w = new Fl_Box(p_xpos,p_ypos,ww-p_xpos-2*pw,bh,"i n v i s i b l e"); + w->box(FL_THIN_UP_BOX); + g3->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(FL_BORDER_FRAME); - //g3->box(FL_EMBOSSED_BOX); g3->end(); - - g1->resizable(g3); - g1->end(); } - - return g1; } /* * Create the status panel */ -Fl_Group *UI::make_status_panel(int ww) +void UI::make_status_panel(int ww) { const int s_h = 20, bm_w = 16; - Fl_Group *g = new Fl_Group(0, 0, ww, s_h, 0); + // HACK: we need a defined StatusOutput + StatusPanel = new Fl_Group(0, 400, 1, 1, 0); + StatusPanel->end(); // Status box StatusOutput = new Fl_Output(0, 0, ww-bm_w, s_h, 0); @@ -664,7 +668,6 @@ Fl_Group *UI::make_status_panel(int ww) StatusOutput->box(FL_THIN_DOWN_BOX); StatusOutput->clear_visible_focus(); StatusOutput->color(FL_GRAY_RAMP + 18); - g->add(StatusOutput); //StatusOutput->throw_focus(); // Bug Meter @@ -676,25 +679,21 @@ Fl_Group *UI::make_status_panel(int ww) BugMeter->tooltip("Show HTML bugs\n(right-click for menu)"); BugMeter->callback(bugmeter_cb, this); BugMeter->clear_visible_focus(); - g->add(BugMeter); - - g->resizable(StatusOutput); - return g; } /* * User Interface constructor */ UI::UI(int x, int y, int ww, int wh, const char* label, const UI *cur_ui) : - Fl_Group(x, y, ww, wh, label) + Fl_Pack(x, y, ww, wh, label) { PointerOnLink = FALSE; Tabs = NULL; TabTooltip = NULL; - TopGroup = new Fl_Pack(0, 0, ww, wh); - add(TopGroup); - resizable(TopGroup); + TopGroup = this; + TopGroup->type(VERTICAL); + //resizable(TopGroup); clear_flag(SHORTCUT_LABEL); if (cur_ui) { @@ -716,28 +715,29 @@ UI::UI(int x, int y, int ww, int wh, const char* label, const UI *cur_ui) : } // Control panel - Panel = make_panel(ww); - TopGroup->add(Panel); - - // Render area - Main = new Fl_Group(0,0,1,1,"Welcome..."); - 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 - findbar = new Findbar(ww, 28); - TopGroup->add(findbar); - - // Status Panel - StatusPanel = make_status_panel(ww); - TopGroup->add(StatusPanel); + TopGroup->begin(); + make_panel(ww); + + // Render area + Main = new Fl_Group(0,50,ww,wh-70,"Welcome..."); + 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->resizable(Main); + MainIdx = TopGroup->find(Main); + + // Find text bar + findbar = new Findbar(ww, 28); + //TopGroup->add(findbar); + + // Status Panel + make_status_panel(ww); + //TopGroup->add(StatusPanel); + + TopGroup->end(); // Make the full screen button (to be attached to the viewport later) // TODO: attach to the viewport @@ -749,7 +749,7 @@ UI::UI(int x, int y, int ww, int wh, const char* label, const UI *cur_ui) : customize(0); if (Panelmode) { - Panel->hide(); + //Panel->hide(); StatusPanel->hide(); } } @@ -1019,8 +1019,8 @@ 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 ) +// ProgBox->hide(); } /* @@ -1029,7 +1029,7 @@ void UI::customize(int flags) void UI::panel_cb_i() { Fl_Group *NewPanel; - +#if 0 // Create a new Panel ++PanelSize; NewPanel = make_panel(TopGroup->w()); @@ -1038,7 +1038,7 @@ void UI::panel_cb_i() TopGroup->add(NewPanel); Panel = NewPanel; customize(0); - +#endif Location->take_focus(); } @@ -1063,11 +1063,11 @@ void UI::color_change_cb_i() void UI::set_panelmode(UIPanelmode mode) { if (mode == UI_HIDDEN) { - Panel->hide(); + //Panel->hide(); StatusPanel->hide(); } else { /* UI_NORMAL or UI_TEMPORARILY_SHOW_PANELS */ - Panel->show(); + //Panel->show(); StatusPanel->show(); } Panelmode = mode; @@ -1094,14 +1094,10 @@ void UI::panelmode_cb_i() */ 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->remove(MainIdx); delete(Main); - TopGroup->add(nw); + TopGroup->insert(nw, MainIdx); Main = &nw; //TopGroup->box(FL_DOWN_BOX); //TopGroup->box(FL_BORDER_FRAME); diff --git a/src/ui.hh b/src/ui.hh index 600badc6..64251e6a 100644 --- a/src/ui.hh +++ b/src/ui.hh @@ -40,7 +40,7 @@ class CustTabGroup; // // UI class definition ------------------------------------------------------- // -class UI : public Fl_Group { +class UI : public Fl_Pack { CustTabGroup *Tabs; char *TabTooltip; @@ -56,19 +56,20 @@ class UI : public Fl_Group { int MainIdx; // Panel customization variables int PanelSize, CuteColor, Small_Icons; - int xpos, bw, bh, fh, lh, lbl; + int p_xpos, p_ypos, bw, bh, fh, lh, pw, lbl; UIPanelmode Panelmode; Findbar *findbar; int PointerOnLink; - - Fl_Pack *make_toolbar(int tw, int th); - Fl_Pack *make_location(); - Fl_Pack *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); Fl_Widget *make_filemenu_button(); - Fl_Group *make_panel(int ww); - Fl_Group *make_status_panel(int ww); + void make_panel(int ww); + void make_status_panel(int ww); public: -- cgit v1.2.3 From f8ec6ac86bcc3b9edda3b5edc30d436c3dae839a Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Wed, 9 Mar 2011 14:18:58 -0300 Subject: Added CustGroup class (it repositions child widgets when others are hidden) --- src/ui.cc | 59 +++++++++---------------------------------------- src/ui.hh | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 86 insertions(+), 49 deletions(-) (limited to 'src') diff --git a/src/ui.cc b/src/ui.cc index 25f1fb01..bee1d937 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -80,43 +80,6 @@ static struct iconset *icons = &standard_icons; * Local sub classes */ -//---------------------------------------------------------------------------- -/* - * Used to reposition group's widgets when some of them are hidden - */ -class Fl_CustGroup : public Fl_Group { -public: - Fl_CustGroup(int x,int y,int w ,int h,const char *l = 0) : - Fl_Group(x,y,w,h,l) { }; - void rearrange(void) { - int n = children(), xpos = 0, r_x1, r_i = -1, i; - - init_sizes(); - for (i = 0; i < n; ++i) { - if (child(i) == resizable()) { - r_i = i; - r_x1 = xpos; - break; - } - if (child(i)->visible()) { - child(i)->position(xpos, child(i)->y()); - xpos += child(i)->w(); - } - } - if (r_i < 0) - return; - xpos = w(); - for (i = n - 1; i > r_i; --i) { - if (child(i)->visible()) { - xpos -= child(i)->w(); - child(i)->position(xpos, child(i)->y()); - } - } - child(r_i)->resize(r_x1, child(r_i)->y(), xpos-r_x1, child(r_i)->h()); - redraw(); - } -}; - //---------------------------------------------------------------------------- /* @@ -419,14 +382,13 @@ static void bugmeter_cb(Fl_Widget *wid, void *data) /* * Make a generic navigation button */ -Fl_Button *UI::make_button(const char *label, - Fl_Image *img, Fl_Image *deimg, +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 Fl_Button(p_xpos, p_ypos, bw, bh, (lbl) ? label : NULL); + Fl_Button *b = new Fl_Button(p_xpos, 0, bw, bh, (lbl) ? label : NULL); if (img) b->image(img); if (deimg) @@ -563,7 +525,7 @@ Fl_Widget *UI::make_filemenu_button() void UI::make_panel(int ww) { Fl_Widget *w; - Fl_CustGroup *g1; + CustGroup *g1; Fl_Group *g2, *g3; Fl_Pack *pg; @@ -600,9 +562,10 @@ void UI::make_panel(int ww) else bw = 45, bh = 45, fh = 24, lh = 28, lbl = 1; } + nh = bh, sh = 24; if (PanelSize == P_tiny) { - g1 = new Fl_CustGroup(0,0,ww,bh); + g1 = new CustGroup(0,0,ww,bh); // Toolbar make_toolbar(ww,bh); make_filemenu_button(); @@ -625,7 +588,8 @@ void UI::make_panel(int ww) //pg = make_location(); pg->size(ww,lh); } else { - g2 = new Fl_CustGroup(0,0,ww,lh); + g2 = new CustGroup(0,0,ww,lh); + p_xpos = 0; make_filemenu_button(); make_location(ww); g2->resizable(Location); @@ -633,13 +597,11 @@ void UI::make_panel(int ww) } // Toolbar - //p_ypos += g2->y(); p_ypos = 0; - //g3 = new Fl_Group(0,fh+lh,ww,bh); - g3 = new Fl_Group(0,p_ypos,ww,bh); + g3 = new CustGroup(0,0,ww,bh); g3->begin(); make_toolbar(ww,bh); - w = new Fl_Box(p_xpos,p_ypos,ww-p_xpos-2*pw,bh,"i n v i s i b l e"); + w = new Fl_Box(p_xpos,0,ww-p_xpos-2*pw,bh,"i n v i s i b l e"); w->box(FL_THIN_UP_BOX); g3->resizable(w); p_xpos = ww - 2*pw; @@ -719,7 +681,8 @@ UI::UI(int x, int y, int ww, int wh, const char* label, const UI *cur_ui) : make_panel(ww); // Render area - Main = new Fl_Group(0,50,ww,wh-70,"Welcome..."); + int mh = wh - (lh+bh+sh); + Main = new Fl_Group(0,0,0,mh,"Welcome..."); Main->box(FL_FLAT_BOX); Main->color(FL_GRAY_RAMP + 3); Main->labelfont(FL_HELVETICA_BOLD_ITALIC); diff --git a/src/ui.hh b/src/ui.hh index 64251e6a..b2c69f8e 100644 --- a/src/ui.hh +++ b/src/ui.hh @@ -37,6 +37,80 @@ typedef enum { class CustProgressBox; class CustTabGroup; + +// Class definition ---------------------------------------------------------- +/* + * Used to reposition group's widgets when some of them are hidden + */ +class CustGroup : public Fl_Group { +public: + CustGroup(int x,int y,int w ,int h,const char *l = 0) : + Fl_Group(x,y,w,h,l) { }; + void rearrange(void) { + int n = children(), xpos = 0, r_x1, r_i = -1, i; + + init_sizes(); + for (i = 0; i < n; ++i) { + if (child(i) == resizable()) { + r_i = i; + r_x1 = xpos; + break; + } + if (child(i)->visible()) { + child(i)->position(xpos, child(i)->y()); + xpos += child(i)->w(); + } + } + if (r_i < 0) + return; + xpos = w(); + for (i = n - 1; i > r_i; --i) { + if (child(i)->visible()) { + xpos -= child(i)->w(); + child(i)->position(xpos, child(i)->y()); + } + } + child(r_i)->resize(r_x1, child(r_i)->y(), xpos-r_x1, child(r_i)->h()); + redraw(); + } + void rearrange_y(void) { + int n = children(), pos = 0, r_pos, r_i = -1, i; + + printf("children = %d\n", n); + init_sizes(); + for (i = 0; i < n; ++i) { + if (child(i) == resizable()) { + r_i = i; + r_pos = pos; + break; + } + if (child(i)->visible()) { + printf("child[%d] x=%d y=%d w=%d h=%d\n", + i, child(i)->x(), pos, child(i)->w(), child(i)->h()); + child(i)->position(child(i)->x(), pos); + pos += child(i)->h(); + } + } + if (r_i < 0) + return; + pos = h(); + for (i = n - 1; i > r_i; --i) { + if (child(i)->visible()) { + pos -= child(i)->h(); + printf("child[%d] x=%d y=%d w=%d h=%d\n", + i, child(i)->x(), pos, child(i)->w(), child(i)->h()); + child(i)->position(child(i)->x(), pos); + } + } + child(r_i)->resize(child(r_i)->x(), r_pos, child(r_i)->w(), pos-r_pos); + printf("resizable child[%d] x=%d y=%d w=%d h=%d\n", + r_i, child(r_i)->x(), r_pos, child(r_i)->w(), child(r_i)->h()); + child(r_i)->hide(); + redraw(); + } +}; + + // // UI class definition ------------------------------------------------------- // @@ -56,7 +130,7 @@ class UI : public Fl_Pack { int MainIdx; // Panel customization variables int PanelSize, CuteColor, Small_Icons; - int p_xpos, p_ypos, bw, bh, fh, lh, pw, lbl; + int p_xpos, p_ypos, bw, bh, fh, lh, nh, sh, pw, lbl; UIPanelmode Panelmode; Findbar *findbar; -- cgit v1.2.3 From 91775fc630020de9f8505fa731272763167cb08e Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Wed, 9 Mar 2011 14:20:19 -0300 Subject: Made a brand new CustTabs class (to allow fine control of tabs). --- src/ui.hh | 8 +- src/uicmd.cc | 472 ++++++++++++++++++++--------------------------------------- 2 files changed, 165 insertions(+), 315 deletions(-) (limited to 'src') diff --git a/src/ui.hh b/src/ui.hh index b2c69f8e..053e85d9 100644 --- a/src/ui.hh +++ b/src/ui.hh @@ -35,7 +35,7 @@ typedef enum { // Private classes class CustProgressBox; -class CustTabGroup; +class CustTabs; // Class definition ---------------------------------------------------------- @@ -115,7 +115,7 @@ public: // UI class definition ------------------------------------------------------- // class UI : public Fl_Pack { - CustTabGroup *Tabs; + CustTabs *Tabs; char *TabTooltip; Fl_Group *TopGroup; @@ -172,8 +172,8 @@ public: Fl_Widget *fullscreen_button() { return FullScreen; } void fullscreen_toggle() { FullScreen->do_callback(); } - CustTabGroup *tabs() { return Tabs; } - void tabs(CustTabGroup *tabs) { Tabs = tabs; } + CustTabs *tabs() { return Tabs; } + void tabs(CustTabs *tabs) { Tabs = tabs; } int pointerOnLink() { return PointerOnLink; } void pointerOnLink(int flag) { PointerOnLink = flag; } diff --git a/src/uicmd.cc b/src/uicmd.cc index 0c25a4f4..74cfbb7b 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -16,10 +16,11 @@ #include #include /* for rint */ +#include #include #include -#include -#include +#include +#include #include "paths.hh" #include "keys.hh" @@ -57,321 +58,193 @@ static char *save_dir = NULL; //---------------------------------------------------------------------------- -#if 0 - -#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(FL_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 CustGroup { + int tab_w, tab_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) : + CustGroup(0,0,ww,th,lbl) { + tab_w = 80, tab_h = th, tab_n = 0, curtab_idx = -1; + tabcolor_active = FL_DARK_CYAN; tabcolor_inactive = 206; + //Fl_Box *w = new Fl_Box(tab_w,0,ww-tab_w,tab_h,"i n v i s i b l e"); + Fl_Box *w = new Fl_Box(0,0,0,0,"i n v i s i b l e"); + w->box(FL_NO_BOX); + resizable(0); + end(); + + Wizard = new Fl_Wizard(0,tab_h,ww,wh-tab_h); + Wizard->end(); + add_new_tab(1); }; - bool btn_highlight() { return btn_hl; }; - - CustShrinkTabPager() : TabGroupPager() { - noclip(true); - btn_hl = false; - tg = NULL; - } + int handle(int e); + UI *add_new_tab(int focus); + void remove_tab(); + Fl_Wizard *wizard(void) { return Wizard; } + int get_btn_idx(UI *ui); + void switch_tab(CustTabButton *cbtn); + void prev_tab(void); + void next_tab(void); }; -int CustShrinkTabPager::available_width(TabGroup *g) const -{ - _MSG("CustShrinkTabPager::available_width\n"); - int w = MAX (g->w() - this->slope()-1 - BTN_W, 0); - btn_x = w + 6; - return w; -} - -int CustShrinkTabPager::which(TabGroup* g, int event_x,int event_y) -{ - 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; ichildren(); i++) { - if (event_x < p[i+1]+(ivalue()); + ret = 1; + } else if (k == 't') { + add_new_tab(1); + } else if (k == 'q') { + remove_tab(); + } + } } - return -1; + + return (ret) ? ret : CustGroup::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(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; + current(0); + UI *new_ui = new UI(0,tab_h,Wizard->w(),Wizard->h()); + new_ui->tabs(this); + Wizard->add(new_ui); - 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; - } + int ntabs = children(); + snprintf(tab_label, 64,"ctab%d", ++tab_n); + CustTabButton *btn = new CustTabButton((ntabs-1)*tab_w,0,tab_w,tab_h); + btn->copy_label(tab_label); + btn->clear_visible_focus(); + btn->box(FL_PLASTIC_ROUND_UP_BOX); + btn->color(tabcolor_active); + btn->ui(new_ui); + add(btn); + btn->redraw(); + //btn->callback(tab_btn_cb, this); - int w2[128]; + if (focus) + switch_tab(btn); + rearrange(); - for (i = 0; i < numchildren; i++) - w2[i] = tab_width[i]; - i = numchildren - 1; - int j = 0; + return new_ui; +} - int minsize = 5; +void CustTabs::remove_tab() +{ + CustTabButton *btn; + UI *ui = (UI*)Wizard->value(); - bool right = true; + // the invisible box is also a child + if (children() == 2) + exit(0); - while (cumulated_width > available_width) { - int n; // which one to shrink + // remove label button + int idx = get_btn_idx(ui); + btn = (CustTabButton*)child(idx); + idx > 1 ? prev_tab() : next_tab(); + remove(idx); + delete btn; + rearrange(); + redraw(); - 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; - } - } - // 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; + Wizard->remove(ui); + delete(ui); } -TabGroupPager* CustShrinkTabPager::clone() const { - return new CustShrinkTabPager(*this); +int CustTabs::get_btn_idx(UI *ui) +{ + for (int i = children()-1; i; --i) { + CustTabButton *btn = (CustTabButton*)child(i); + if (btn->ui() == ui) + return i; + } + return -1; } -#endif /* custom pager */ -//---------------------------------------------------------------------------- -/* - * For custom handling of keyboard - */ -class CustTabGroup : public Fl_Tabs { - Fl_Tooltip *toolTip; - bool tooltipEnabled; - bool buttonPushed; -public: - CustTabGroup (int x, int y, int ww, int wh, const char *lbl=0) : - Fl_Tabs(x,y,ww,wh,lbl) { - Fl_Group::current(0); - box(FL_NO_BOX); - // The parameter pager is cloned, so free it. -// CustShrinkTabPager *cp = new CustShrinkTabPager(); -// this->pager(cp); -// delete cp; - toolTip = new Fl_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 == FL_KEYBOARD) { - int k = Fl::event_key(); - // We're only interested in some flags - unsigned modifier = Fl::event_state() & (FL_SHIFT | FL_CTRL | FL_ALT); - if (k == FL_Up || k == FL_Down || k == FL_Tab) { - return 0; - } else if (k == FL_Left || k == FL_Right) { - if (modifier == FL_SHIFT) { - int i = find(value()); - if (k == FL_Left) {i = i ? i-1 : children()-1;} - else {i++; if (i >= children()) i = 0;} - value(child(i)); - return 1; - } - // Avoid focus change. - return 0; - } - } else if (e == FL_RELEASE) { - Fl_Widget *new_focus = which(Fl::event_x(), Fl::event_y()); - - if (new_focus && new_focus != value()) { - // Update the window title - BrowserWindow *bw = a_UIcmd_get_bw_by_widget(new_focus); - const char *title = a_History_get_title(NAV_TOP_UIDX(bw), 1); - - a_UIcmd_set_page_title(bw, title ? title : ""); - } -// custom pager -#if 0 - } else if (e == FL_MOVE) { - CustShrinkTabPager *cstp = (CustShrinkTabPager *) pager(); - if (Fl::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 == FL_PUSH && Fl::event_inside(r) && - Fl::event_button() == 1 && children() > 1) { - buttonPushed = true; - return 1; /* non-zero */ - } else if (e == FL_RELEASE) { - if (Fl::event_inside(r) && Fl::event_button() == 1 && - children() > 1 && buttonPushed) { - a_UIcmd_close_bw(a_UIcmd_get_bw_by_widget(value())); - } else { - CustShrinkTabPager *cstp = (CustShrinkTabPager *) pager(); - cstp->btn_highlight(false); - } - buttonPushed = false; -#endif - } else if (e == FL_DRAG) { - /* Ignore this event */ - return 1; - } - int ret = Fl_Tabs::handle(e); +void CustTabs::switch_tab(CustTabButton *cbtn) +{ + int idx; + CustTabButton *btn; + UI *old_ui = (UI*)Wizard->value(); - if (e == FL_PUSH) { - /* WORKAROUND: FLTK raises the window on unhandled clicks, - * which we do not want. - */ - ret = 1; + if (cbtn->ui() != old_ui) { + // Set old tab label to normal color + if ((idx = get_btn_idx(old_ui)) > 0) { + btn = (CustTabButton*)child(idx); + btn->color(tabcolor_inactive); + btn->redraw(); } - return ret; + Wizard->value(cbtn->ui()); + cbtn->color(tabcolor_active); + cbtn->redraw(); } +} - void remove (Fl_Widget *w) { - Fl_Tabs::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) { - box(FL_NO_BOX); - hideLabels (); - } - } + if ((idx = get_btn_idx((UI*)Wizard->value())) > 1) + switch_tab( (CustTabButton*)child(idx-1) ); +} + +void CustTabs::next_tab() +{ + int idx; + + if ((idx = get_btn_idx((UI*)Wizard->value())) > 0 && idx+1 < children()) + switch_tab( (CustTabButton*)child(idx+1) ); +} - void add (Fl_Widget *w) { - Fl_Tabs::add (w); - if (children () > 1) { - box(FL_THIN_UP_BOX); - showLabels (); - } - } - void hideLabels() { - for (int i = children () - 1; i >= 0; i--) - child(i)->resize(x(), y(), w(), h()); - } - void showLabels() { - for (int i = children () - 1; i >= 0; i--) - child(i)->resize(x(), y() + 20, w(), h() - 20); - } -}; //---------------------------------------------------------------------------- static void win_cb (Fl_Widget *w, void *cb_data) { int choice = 1; - CustTabGroup *tabs = (CustTabGroup*) cb_data; + CustTabs *tabs = (CustTabs*) cb_data; if (tabs->children () > 1) choice = a_Dialog_choice5("Window contains more than one tab.", @@ -434,26 +307,19 @@ BrowserWindow *a_UIcmd_browser_window_new(int ww, int wh, win = new Fl_Double_Window(ww, wh); Fl_Group::current(0); -//may need a handler for this -// win->shortcut(0); // Ignore Escape - CustTabGroup *DilloTabs = new CustTabGroup(0, 0, ww, wh); + CustTabs *DilloTabs = new CustTabs(ww, wh, 16); DilloTabs->selection_color(156); win->add(DilloTabs); // 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); - - DilloTabs->add(new_ui); - DilloTabs->resizable(new_ui); - DilloTabs->window()->resizable(new_ui); - DilloTabs->window()->show(); + UI *new_ui = DilloTabs->add_new_tab(1); + win->resizable(new_ui); + win->show(); + //DilloTabs->window()->show(); if (old_bw == NULL && prefs.xpos >= 0 && prefs.ypos >= 0) { // position the first window according to preferences - new_ui->window()->position(prefs.xpos, prefs.ypos); + DilloTabs->window()->position(prefs.xpos, prefs.ypos); } // Now create the Dw render layout and viewport @@ -492,7 +358,7 @@ BrowserWindow *a_UIcmd_browser_window_new(int ww, int wh, * Create a new Tab. * i.e the new UI and its associated BrowserWindow data structure. */ -static BrowserWindow *UIcmd_tab_new(const void *vbw) +static BrowserWindow *UIcmd_tab_new(const void *vbw, int focus) { _MSG(" UIcmd_tab_new vbw=%p\n", vbw); @@ -508,13 +374,7 @@ static BrowserWindow *UIcmd_tab_new(const void *vbw) 0, vbw); // 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 = ui->tabs()->add_new_tab(focus); // Now create the Dw render layout and viewport FltkPlatform *platform = new FltkPlatform (); @@ -553,14 +413,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); - if (ui->tabs()->value()) - ui->tabs()->value()->take_focus(); - else - ui->tabs()->window()->hide(); + ui->tabs()->remove_tab(); } - delete(ui); - a_Bw_free(bw); } @@ -663,11 +517,7 @@ 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()->value(BW2UI(new_bw)); - + BrowserWindow *new_bw = UIcmd_tab_new(vbw, focus); UIcmd_open_url_nbw(new_bw, url); } @@ -1234,7 +1084,7 @@ 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()->value()) == 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)); -- cgit v1.2.3 From d19fdb04e7c6cf270e4637e8b82261c8a4f81f42 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Wed, 9 Mar 2011 14:21:25 -0300 Subject: Made Dillo code follow my fltk1.3 UI prototype --- src/ui.cc | 53 +++++++++++++++++++++++++++-------------------------- src/ui.hh | 1 + 2 files changed, 28 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/ui.cc b/src/ui.cc index bee1d937..72b9b42e 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -525,9 +525,6 @@ Fl_Widget *UI::make_filemenu_button() void UI::make_panel(int ww) { Fl_Widget *w; - CustGroup *g1; - Fl_Group *g2, *g3; - Fl_Pack *pg; if (PanelSize > P_large) { PanelSize = P_tiny; @@ -565,52 +562,53 @@ void UI::make_panel(int ww) nh = bh, sh = 24; if (PanelSize == P_tiny) { - g1 = new CustGroup(0,0,ww,bh); - // Toolbar + NavBar = new CustGroup(0,0,ww,bh); + NavBar->begin(); make_toolbar(ww,bh); make_filemenu_button(); make_location(ww); - g1->resizable(Location); + NavBar->resizable(Location); make_progress_bars(0,1); - g1->box(FL_THIN_UP_FRAME); - g1->end(); + NavBar->box(FL_THIN_UP_FRAME); + NavBar->end(); } else { // File menu if (PanelSize == P_large) { - g3 = new Fl_Group(0,0,ww,lh); - g3->box(FL_FLAT_BOX); - Fl_Widget *bn = make_filemenu_button(); - g3->add(bn); - g3->add_resizable(*new Fl_Box(bn->w(),0,ww - bn->w(),lh)); - - g2 = new Fl_Group(0,fh,ww,lh); - g2->begin(); - //pg = make_location(); - pg->size(ww,lh); + Fl_Group *g3 = new Fl_Group(0,0,ww,lh); + g3->begin(); + g3->box(FL_FLAT_BOX); + Fl_Widget *bn = make_filemenu_button(); + g3->add_resizable(*new Fl_Box(bn->w(),0,ww - bn->w(),lh)); + g3->end(); + + LocBar = new CustGroup(0,0,ww,lh); + LocBar->begin(); + make_location(ww); + LocBar->end(); } else { - g2 = new CustGroup(0,0,ww,lh); + LocBar = new CustGroup(0,0,ww,lh); p_xpos = 0; make_filemenu_button(); make_location(ww); - g2->resizable(Location); - g2->end(); + LocBar->resizable(Location); + LocBar->end(); } // Toolbar p_ypos = 0; - g3 = new CustGroup(0,0,ww,bh); - g3->begin(); + NavBar = new CustGroup(0,0,ww,bh); + NavBar->begin(); make_toolbar(ww,bh); w = new Fl_Box(p_xpos,0,ww-p_xpos-2*pw,bh,"i n v i s i b l e"); w->box(FL_THIN_UP_BOX); - g3->resizable(w); + NavBar->resizable(w); p_xpos = ww - 2*pw; if (PanelSize == P_small) { make_progress_bars(0,0); } else { make_progress_bars(1,0); } - g3->end(); + NavBar->end(); } } @@ -984,6 +982,8 @@ void UI::customize(int flags) Help->hide(); // if ( !prefs.show_progress_box ) // ProgBox->hide(); + + NavBar->rearrange(); } /* @@ -991,8 +991,9 @@ void UI::customize(int flags) */ void UI::panel_cb_i() { - Fl_Group *NewPanel; #if 0 + Fl_Group *NewPanel; + // Create a new Panel ++PanelSize; NewPanel = make_panel(TopGroup->w()); diff --git a/src/ui.hh b/src/ui.hh index 053e85d9..9c50b653 100644 --- a/src/ui.hh +++ b/src/ui.hh @@ -121,6 +121,7 @@ class UI : public Fl_Pack { Fl_Group *TopGroup; Fl_Button *Back, *Forw, *Home, *Reload, *Save, *Stop, *Bookmarks, *Tools, *Clear, *Search, *Help, *FullScreen, *BugMeter, *FileButton; + CustGroup *LocBar, *NavBar, *StBar; Fl_Input *Location; Fl_Pack *ProgBox; CustProgressBox *PProg, *IProg; -- cgit v1.2.3 From a472472ab9d6e5bead93f6adc754a33ef4c3ccb7 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Wed, 9 Mar 2011 14:22:32 -0300 Subject: Part of the UI wasn't visible. This minor changes fix it. --- src/ui.cc | 16 ++++++++-------- src/uicmd.cc | 25 ++++++++++++++++++++----- 2 files changed, 28 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/ui.cc b/src/ui.cc index 72b9b42e..2de27fc9 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -644,8 +644,8 @@ void UI::make_status_panel(int ww) /* * User Interface constructor */ -UI::UI(int x, int y, int ww, int wh, const char* label, const UI *cur_ui) : - Fl_Pack(x, y, ww, wh, label) +UI::UI(int x, int y, int ui_w, int ui_h, const char* label, const UI *cur_ui) : + Fl_Pack(x, y, ui_w, ui_h, label) { PointerOnLink = FALSE; @@ -676,11 +676,12 @@ UI::UI(int x, int y, int ww, int wh, const char* label, const UI *cur_ui) : // Control panel TopGroup->begin(); - make_panel(ww); + make_panel(ui_w); // Render area - int mh = wh - (lh+bh+sh); + int mh = ui_h - (lh+bh+sh); Main = new Fl_Group(0,0,0,mh,"Welcome..."); + 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); @@ -691,11 +692,11 @@ UI::UI(int x, int y, int ww, int wh, const char* label, const UI *cur_ui) : MainIdx = TopGroup->find(Main); // Find text bar - findbar = new Findbar(ww, 28); + findbar = new Findbar(ui_w, 28); //TopGroup->add(findbar); // Status Panel - make_status_panel(ww); + make_status_panel(ui_w); //TopGroup->add(StatusPanel); TopGroup->end(); @@ -1058,14 +1059,13 @@ void UI::panelmode_cb_i() */ void UI::set_render_layout(Fl_Group &nw) { - // We'll use a workaround in a_UIcmd_browser_window_new() instead. TopGroup->remove(MainIdx); delete(Main); TopGroup->insert(nw, MainIdx); Main = &nw; + TopGroup->resizable(Main); //TopGroup->box(FL_DOWN_BOX); //TopGroup->box(FL_BORDER_FRAME); - TopGroup->resizable(TopGroup->child(MainIdx)); } /* diff --git a/src/uicmd.cc b/src/uicmd.cc index 74cfbb7b..7635e306 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -21,6 +21,7 @@ #include #include #include +#include #include "paths.hh" #include "keys.hh" @@ -55,6 +56,7 @@ using namespace dw::fltk; * Local data */ static char *save_dir = NULL; +static UI *Gui; //---------------------------------------------------------------------------- @@ -95,7 +97,10 @@ public: Wizard = new Fl_Wizard(0,tab_h,ww,wh-tab_h); Wizard->end(); - add_new_tab(1); + Gui = add_new_tab(1); + printf("Wizard window: %p\n", Wizard->window()); + //printf("Gui visible: %d\n", Gui->visible()); + //printf("Gui visible_r: %d\n", Gui->visible_r()); }; int handle(int e); UI *add_new_tab(int focus); @@ -150,6 +155,7 @@ UI *CustTabs::add_new_tab(int focus) UI *new_ui = new UI(0,tab_h,Wizard->w(),Wizard->h()); new_ui->tabs(this); Wizard->add(new_ui); + new_ui->show(); int ntabs = children(); snprintf(tab_label, 64,"ctab%d", ++tab_n); @@ -306,16 +312,21 @@ BrowserWindow *a_UIcmd_browser_window_new(int ww, int wh, else win = new Fl_Double_Window(ww, wh); - Fl_Group::current(0); + //Fl_Group::current(0); CustTabs *DilloTabs = new CustTabs(ww, wh, 16); DilloTabs->selection_color(156); - win->add(DilloTabs); + //win->add(DilloTabs); +#if 0 // Create and set the UI UI *new_ui = DilloTabs->add_new_tab(1); + //DilloTabs->window()->show(); +#else + UI *new_ui = Gui; + //win->resizable(new_ui); win->resizable(new_ui); win->show(); - //DilloTabs->window()->show(); +#endif if (old_bw == NULL && prefs.xpos >= 0 && prefs.ypos >= 0) { // position the first window according to preferences @@ -349,7 +360,7 @@ BrowserWindow *a_UIcmd_browser_window_new(int ww, int wh, win->callback(win_cb, DilloTabs); - new_ui->focus_location(); + //new_ui->focus_location(); return new_bw; } @@ -479,10 +490,12 @@ void a_UIcmd_open_urlstr(void *vbw, const char *urlstr) */ void a_UIcmd_open_url(BrowserWindow *bw, const DilloUrl *url) { +#if 0 a_Nav_push(bw, url, NULL); 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) @@ -1117,6 +1130,7 @@ void a_UIcmd_set_msg(BrowserWindow *bw, const char *format, ...) */ void a_UIcmd_set_buttons_sens(BrowserWindow *bw) { +#if 0 int sens; // Stop @@ -1129,6 +1143,7 @@ void a_UIcmd_set_buttons_sens(BrowserWindow *bw) sens = (a_Nav_stack_ptr(bw) < a_Nav_stack_size(bw) - 1 && !bw->nav_expecting); BW2UI(bw)->button_set_sens(UI_FORW, sens); +#endif } /* -- cgit v1.2.3 From 33658b04af7478669b23c07ac699693e30c83df8 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Wed, 9 Mar 2011 14:24:10 -0300 Subject: Added code and made the necesary bindings so tabs start to be functional --- src/ui.cc | 42 +++-------------- src/ui.hh | 1 - src/uicmd.cc | 150 +++++++++++++++++++++++++++++------------------------------ 3 files changed, 81 insertions(+), 112 deletions(-) (limited to 'src') diff --git a/src/ui.cc b/src/ui.cc index 2de27fc9..b28c95cd 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -98,6 +98,7 @@ public: */ int CustInput::handle(int e) { +#if 0 int k = Fl::event_key(); _MSG("CustInput::handle event=%d\n", e); @@ -126,7 +127,7 @@ int CustInput::handle(int e) } } _MSG("\n"); - +#endif return Fl_Input::handle(e); } @@ -599,8 +600,8 @@ void UI::make_panel(int ww) NavBar = new CustGroup(0,0,ww,bh); NavBar->begin(); make_toolbar(ww,bh); - w = new Fl_Box(p_xpos,0,ww-p_xpos-2*pw,bh,"i n v i s i b l e"); - w->box(FL_THIN_UP_BOX); + w = new Fl_Box(p_xpos,0,ww-p_xpos-2*pw,bh); + w->box(FL_NO_BOX); NavBar->resizable(w); p_xpos = ww - 2*pw; if (PanelSize == P_small) { @@ -734,7 +735,7 @@ int UI::handle(int event) _MSG("Panel->h()=%d Main->h()=%d\n", Panel->h() , Main->h()); int ret = 0; - +#if 0 if (event == FL_KEYBOARD) { return 0; // Receive as shortcut } else if (event == FL_SHORTCUT) { @@ -819,7 +820,7 @@ int UI::handle(int event) } } } - +#endif if (!ret) { ret = Fl_Group::handle(event); } @@ -1068,37 +1069,6 @@ void UI::set_render_layout(Fl_Group &nw) //TopGroup->box(FL_BORDER_FRAME); } -/* - * 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); - } -} - /* * Set button sensitivity (Back/Forw/Stop) */ diff --git a/src/ui.hh b/src/ui.hh index 9c50b653..363ff9a6 100644 --- a/src/ui.hh +++ b/src/ui.hh @@ -163,7 +163,6 @@ public: void set_img_prog(int n_img, int t_img, int cmd); void set_bug_prog(int n_bug); void set_render_layout(Fl_Group &nw); - void set_tab_title(const char *label); void customize(int flags); void button_set_sens(UIButton btn, int sens); void paste_url(); diff --git a/src/uicmd.cc b/src/uicmd.cc index 7635e306..3f6e1966 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -58,6 +58,10 @@ using namespace dw::fltk; static char *save_dir = NULL; static UI *Gui; +/* + * Forward declarations + */ +static BrowserWindow *UIcmd_tab_new(CustTabs *tabs, int focus); //---------------------------------------------------------------------------- @@ -97,7 +101,6 @@ public: Wizard = new Fl_Wizard(0,tab_h,ww,wh-tab_h); Wizard->end(); - Gui = add_new_tab(1); printf("Wizard window: %p\n", Wizard->window()); //printf("Gui visible: %d\n", Gui->visible()); //printf("Gui visible_r: %d\n", Gui->visible_r()); @@ -107,11 +110,27 @@ public: void remove_tab(); Fl_Wizard *wizard(void) { return Wizard; } int get_btn_idx(UI *ui); + int num_tabs() { return (children() - 1); } // substract invisible box void switch_tab(CustTabButton *cbtn); void prev_tab(void); void next_tab(void); + + void set_tab_label(UI *ui, const char *title); }; +/* + * Callback for mouse click + */ +static void tab_btn_cb (Fl_Widget *w, void *cb_data) +{ + CustTabButton *btn = (CustTabButton*) w; + CustTabs *tabs = (CustTabs*) cb_data; + int b = Fl::event_button(); + + if (b == FL_LEFT_MOUSE) + tabs->switch_tab(btn); +} + int CustTabs::handle(int e) { int ret = 0; @@ -134,7 +153,7 @@ int CustTabs::handle(int e) //toggle_cb(NULL, Wizard->value()); ret = 1; } else if (k == 't') { - add_new_tab(1); + UIcmd_tab_new(this, 1); } else if (k == 'q') { remove_tab(); } @@ -157,9 +176,9 @@ UI *CustTabs::add_new_tab(int focus) Wizard->add(new_ui); new_ui->show(); - int ntabs = children(); snprintf(tab_label, 64,"ctab%d", ++tab_n); - CustTabButton *btn = new CustTabButton((ntabs-1)*tab_w,0,tab_w,tab_h); + CustTabButton *btn = new CustTabButton(num_tabs()*tab_w,0,tab_w,tab_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); @@ -167,7 +186,7 @@ UI *CustTabs::add_new_tab(int focus) btn->ui(new_ui); add(btn); btn->redraw(); - //btn->callback(tab_btn_cb, this); + btn->callback(tab_btn_cb, this); if (focus) switch_tab(btn); @@ -181,10 +200,6 @@ void CustTabs::remove_tab() CustTabButton *btn; UI *ui = (UI*)Wizard->value(); - // the invisible box is also a child - if (children() == 2) - exit(0); - // remove label button int idx = get_btn_idx(ui); btn = (CustTabButton*)child(idx); @@ -196,11 +211,17 @@ void CustTabs::remove_tab() Wizard->remove(ui); delete(ui); + + if (num_tabs() == 0) { + window()->hide(); + // TODO: free memory + //delete window(); + } } int CustTabs::get_btn_idx(UI *ui) { - for (int i = children()-1; i; --i) { + for (int i = 1; i <= num_tabs(); ++i) { CustTabButton *btn = (CustTabButton*)child(i); if (btn->ui() == ui) return i; @@ -239,11 +260,35 @@ void CustTabs::next_tab() { int idx; - if ((idx = get_btn_idx((UI*)Wizard->value())) > 0 && idx+1 < children()) + if ((idx = get_btn_idx((UI*)Wizard->value())) > 0 && idx < num_tabs()) switch_tab( (CustTabButton*)child(idx+1) ); } - +/* + * 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 > 0) { + // 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); + child(idx)->redraw_label(); + } + } +} //---------------------------------------------------------------------------- @@ -252,12 +297,12 @@ static void win_cb (Fl_Widget *w, void *cb_data) { int choice = 1; CustTabs *tabs = (CustTabs*) cb_data; - if (tabs->children () > 1) + if (tabs->num_tabs() > 1) choice = a_Dialog_choice5("Window contains more than one tab.", "Close all tabs", "Cancel", NULL, NULL, NULL); if (choice == 1) - while (tabs->children()) - a_UIcmd_close_bw(a_UIcmd_get_bw_by_widget(tabs->child(0))); + while (tabs->num_tabs()) + a_UIcmd_close_bw(a_UIcmd_get_bw_by_widget(tabs->wizard()->value())); } /* @@ -314,50 +359,17 @@ BrowserWindow *a_UIcmd_browser_window_new(int ww, int wh, //Fl_Group::current(0); CustTabs *DilloTabs = new CustTabs(ww, wh, 16); - DilloTabs->selection_color(156); - //win->add(DilloTabs); + win->end(); -#if 0 - // Create and set the UI - UI *new_ui = DilloTabs->add_new_tab(1); - //DilloTabs->window()->show(); -#else - UI *new_ui = Gui; - //win->resizable(new_ui); - win->resizable(new_ui); + new_bw = UIcmd_tab_new(DilloTabs, 1); + win->resizable(Gui); win->show(); -#endif if (old_bw == NULL && prefs.xpos >= 0 && prefs.ypos >= 0) { // position the first window according to preferences 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(); @@ -366,26 +378,16 @@ BrowserWindow *a_UIcmd_browser_window_new(int ww, int wh, } /* - * 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, int focus) +static BrowserWindow *UIcmd_tab_new(CustTabs *tabs, 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 = ui->tabs()->add_new_tab(focus); + UI *new_ui = tabs->add_new_tab(1); + Gui = new_ui; // Now create the Dw render layout and viewport FltkPlatform *platform = new FltkPlatform (); @@ -394,14 +396,13 @@ static BrowserWindow *UIcmd_tab_new(const void *vbw, int focus) layout->setBgColor (bgColor); FltkViewport *viewport = new FltkViewport (0, 0, 1, 1); - + viewport->setBufferedDrawing (prefs.buffered_drawing ? true : 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(); + BrowserWindow *new_bw = a_Bw_new(); // Reference the UI from the bw new_bw->ui = (void *)new_ui; @@ -490,8 +491,8 @@ void a_UIcmd_open_urlstr(void *vbw, const char *urlstr) */ void a_UIcmd_open_url(BrowserWindow *bw, const DilloUrl *url) { -#if 0 a_Nav_push(bw, url, NULL); +#if 0 if (BW2UI(bw)->get_panelmode() == UI_TEMPORARILY_SHOW_PANELS) BW2UI(bw)->set_panelmode(UI_HIDDEN); a_UIcmd_focus_main_area(bw); @@ -530,7 +531,8 @@ 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, focus); + BrowserWindow *bw = (BrowserWindow *)vbw; + BrowserWindow *new_bw = UIcmd_tab_new(BW2UI(bw)->tabs(), focus); UIcmd_open_url_nbw(new_bw, url); } @@ -1106,7 +1108,7 @@ void a_UIcmd_set_page_title(BrowserWindow *bw, const char *label) 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); } /* @@ -1130,7 +1132,6 @@ void a_UIcmd_set_msg(BrowserWindow *bw, const char *format, ...) */ void a_UIcmd_set_buttons_sens(BrowserWindow *bw) { -#if 0 int sens; // Stop @@ -1143,7 +1144,6 @@ void a_UIcmd_set_buttons_sens(BrowserWindow *bw) sens = (a_Nav_stack_ptr(bw) < a_Nav_stack_size(bw) - 1 && !bw->nav_expecting); BW2UI(bw)->button_set_sens(UI_FORW, sens); -#endif } /* -- cgit v1.2.3 From 2dec0150336e6b9cc19e0230697fe952115d6ef3 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Wed, 9 Mar 2011 14:25:32 -0300 Subject: Moved some keyboard events from class UI to class CustTabs (where they belong) --- src/ui.cc | 5 +++-- src/uicmd.cc | 44 +++++++++++++++++++++++++++++++++----------- 2 files changed, 36 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/ui.cc b/src/ui.cc index b28c95cd..2dc16ead 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -98,18 +98,19 @@ public: */ int CustInput::handle(int e) { -#if 0 int k = Fl::event_key(); _MSG("CustInput::handle event=%d\n", e); // We're only interested in some flags - unsigned modifier = Fl::event_state() & (FL_SHIFT | FL_CTRL | FL_ALT); + //unsigned modifier = Fl::event_state() & (FL_SHIFT | FL_CTRL | FL_ALT); // Don't focus with arrow keys if (e == FL_FOCUS && (k == FL_Up || k == FL_Down || k == FL_Left || k == FL_Right)) { return 0; + } +#if 0 } else if (e == FL_KEYBOARD) { if (modifier == FL_CTRL) { if (k == 'l') { diff --git a/src/uicmd.cc b/src/uicmd.cc index 3f6e1966..d7e7723d 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -136,7 +136,38 @@ int CustTabs::handle(int e) int ret = 0; //printf("CustTabs::handle e=%s\n", fl_eventnames[e]); - if (e == FL_KEYUP) { + 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 (cmd == KEYS_NOP) { + // Do nothing + } 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) { + printf("CustTabs::handle KEYS_LEFT_TAB\n"); + ret = 1; + } else if (cmd == KEYS_RIGHT_TAB) { + printf("CustTabs::handle KEYS_RIGHT_TAB\n"); + ret = 1; + } else if (cmd == KEYS_NEW_WINDOW) { + a_UIcmd_browser_window_new(ui->w(),ui->h()+this->h(),0,bw); + ret = 1; + } else if (cmd == KEYS_FULLSCREEN) { + printf("CustTabs::handle KEYS_FULLSCREEN\n"); + ret = 1; + } else if (cmd == KEYS_CLOSE_ALL) { + a_Timeout_add(0.0, a_UIcmd_close_all_bw, NULL); + ret = 1; + } + + } else if (e == FL_KEYUP) { int k = Fl::event_key(); // We're only interested in some flags unsigned modifier = Fl::event_state() & (FL_SHIFT | FL_CTRL | FL_ALT); @@ -147,16 +178,6 @@ int CustTabs::handle(int e) (k == FL_Left) ? prev_tab() : next_tab(); ret = 1; } - } else if (modifier == FL_CTRL) { - if (k == ' ') { - //printf("CustTabs::handle FL_CTRL + Space\n"); - //toggle_cb(NULL, Wizard->value()); - ret = 1; - } else if (k == 't') { - UIcmd_tab_new(this, 1); - } else if (k == 'q') { - remove_tab(); - } } } @@ -423,6 +444,7 @@ void a_UIcmd_close_bw(void *vbw) MSG("a_UIcmd_close_bw\n"); a_Bw_stop_clients(bw, BW_Root + BW_Img + BW_Force); + //TODO: sometimes this call segfaults upon exit delete(layout); if (ui->tabs()) { ui->tabs()->remove_tab(); -- cgit v1.2.3 From b540f44f385ea69ed0b6467ec84ae08d260d233f Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Wed, 9 Mar 2011 14:26:19 -0300 Subject: Made remove_tab() work for non-focused tabs --- src/uicmd.cc | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/uicmd.cc b/src/uicmd.cc index d7e7723d..7a8c3ccd 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -93,7 +93,6 @@ public: CustGroup(0,0,ww,th,lbl) { tab_w = 80, tab_h = th, tab_n = 0, curtab_idx = -1; tabcolor_active = FL_DARK_CYAN; tabcolor_inactive = 206; - //Fl_Box *w = new Fl_Box(tab_w,0,ww-tab_w,tab_h,"i n v i s i b l e"); Fl_Box *w = new Fl_Box(0,0,0,0,"i n v i s i b l e"); w->box(FL_NO_BOX); resizable(0); @@ -101,13 +100,10 @@ public: Wizard = new Fl_Wizard(0,tab_h,ww,wh-tab_h); Wizard->end(); - printf("Wizard window: %p\n", Wizard->window()); - //printf("Gui visible: %d\n", Gui->visible()); - //printf("Gui visible_r: %d\n", Gui->visible_r()); }; int handle(int e); UI *add_new_tab(int focus); - void remove_tab(); + void remove_tab(UI *ui); Fl_Wizard *wizard(void) { return Wizard; } int get_btn_idx(UI *ui); int num_tabs() { return (children() - 1); } // substract invisible box @@ -127,15 +123,19 @@ static void tab_btn_cb (Fl_Widget *w, void *cb_data) CustTabs *tabs = (CustTabs*) cb_data; int b = Fl::event_button(); - if (b == FL_LEFT_MOUSE) + if (b == FL_LEFT_MOUSE) { tabs->switch_tab(btn); + } else if (b == FL_RIGHT_MOUSE) { + // TODO: just an example, not necessarily final + a_UIcmd_close_bw(a_UIcmd_get_bw_by_widget(btn->ui())); + } } int CustTabs::handle(int e) { int ret = 0; - //printf("CustTabs::handle e=%s\n", fl_eventnames[e]); + _MSG("CustTabs::handle e=%s\n", fl_eventnames[e]); if (e == FL_KEYBOARD) { return 0; // Receive as shortcut } else if (e == FL_SHORTCUT) { @@ -151,16 +151,16 @@ int CustTabs::handle(int e) a_UIcmd_close_bw(bw); ret = 1; } else if (cmd == KEYS_LEFT_TAB) { - printf("CustTabs::handle KEYS_LEFT_TAB\n"); + MSG("CustTabs::handle KEYS_LEFT_TAB\n"); ret = 1; } else if (cmd == KEYS_RIGHT_TAB) { - printf("CustTabs::handle KEYS_RIGHT_TAB\n"); + MSG("CustTabs::handle KEYS_RIGHT_TAB\n"); ret = 1; } else if (cmd == KEYS_NEW_WINDOW) { a_UIcmd_browser_window_new(ui->w(),ui->h()+this->h(),0,bw); ret = 1; } else if (cmd == KEYS_FULLSCREEN) { - printf("CustTabs::handle KEYS_FULLSCREEN\n"); + MSG("CustTabs::handle KEYS_FULLSCREEN\n"); ret = 1; } else if (cmd == KEYS_CLOSE_ALL) { a_Timeout_add(0.0, a_UIcmd_close_all_bw, NULL); @@ -216,10 +216,12 @@ UI *CustTabs::add_new_tab(int focus) return new_ui; } -void CustTabs::remove_tab() +/* + * Remove tab by UI + */ +void CustTabs::remove_tab(UI *ui) { CustTabButton *btn; - UI *ui = (UI*)Wizard->value(); // remove label button int idx = get_btn_idx(ui); @@ -228,6 +230,7 @@ void CustTabs::remove_tab() remove(idx); delete btn; rearrange(); + //TODO: redraw doesn't work sometimes redraw(); Wizard->remove(ui); @@ -334,8 +337,9 @@ 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 (((Fl_Widget*)bw->ui)->contains((Fl_Widget*)v_wid)) + if (((UI*)bw->ui)->contains((Fl_Widget*)v_wid)) { return bw; + } } return NULL; } @@ -447,7 +451,7 @@ void a_UIcmd_close_bw(void *vbw) //TODO: sometimes this call segfaults upon exit delete(layout); if (ui->tabs()) { - ui->tabs()->remove_tab(); + ui->tabs()->remove_tab(ui); } a_Bw_free(bw); } -- cgit v1.2.3 From 2148ba7e5bb175eee37eef3de469356524dade51 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Thu, 10 Mar 2011 13:41:12 -0300 Subject: Minor fixes for panel_size=large --- src/ui.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ui.cc b/src/ui.cc index 2dc16ead..09eb0787 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -510,7 +510,7 @@ Fl_Widget *UI::make_filemenu_button() btn->size(w+padding,PanelSize == P_tiny ? bh : lh); p_xpos += btn->w(); _MSG("UI::make_filemenu_button w=%d h=%d padding=%d\n", w, h, padding); - btn->box(PanelSize == P_large ? FL_FLAT_BOX : FL_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"); @@ -578,11 +578,12 @@ void UI::make_panel(int ww) if (PanelSize == P_large) { Fl_Group *g3 = new Fl_Group(0,0,ww,lh); g3->begin(); - g3->box(FL_FLAT_BOX); + g3->box(FL_THIN_UP_BOX); Fl_Widget *bn = make_filemenu_button(); g3->add_resizable(*new Fl_Box(bn->w(),0,ww - bn->w(),lh)); g3->end(); + p_xpos = 0; LocBar = new CustGroup(0,0,ww,lh); LocBar->begin(); make_location(ww); -- cgit v1.2.3 From 1c24e3a90ca78e0f797b4c974153d97443756063 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Sun, 13 Mar 2011 09:50:30 -0400 Subject: Made the status bar visible and operative. The Bug Meter needs some work due to differences with FLTK2 --- dw/fltkviewport.cc | 3 ++- src/ui.cc | 76 ++++++++++++++++++++++++++++-------------------------- src/ui.hh | 4 +-- src/uicmd.cc | 5 ++-- 4 files changed, 47 insertions(+), 41 deletions(-) (limited to 'src') diff --git a/dw/fltkviewport.cc b/dw/fltkviewport.cc index d0080a05..ee919b29 100644 --- a/dw/fltkviewport.cc +++ b/dw/fltkviewport.cc @@ -180,7 +180,8 @@ void FltkViewport::draw () if (d & FL_DAMAGE_SCROLL) { clear_damage (FL_DAMAGE_SCROLL); - fl_scroll(x(), y(), w () - hdiff, h () - vdiff, -scrollDX, -scrollDY, draw_area, this); + fl_scroll(x(), y(), w() - hdiff, h() - vdiff, + -scrollDX, -scrollDY, draw_area, this); clear_damage (d & ~FL_DAMAGE_SCROLL); } diff --git a/src/ui.cc b/src/ui.cc index 09eb0787..f13ca982 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -561,7 +561,7 @@ void UI::make_panel(int ww) else bw = 45, bh = 45, fh = 24, lh = 28, lbl = 1; } - nh = bh, sh = 24; + nh = bh, sh = 20; if (PanelSize == P_tiny) { NavBar = new CustGroup(0,0,ww,bh); @@ -618,30 +618,33 @@ void UI::make_panel(int ww) /* * Create the status panel */ -void UI::make_status_panel(int ww) +void UI::make_status_panel(int ww, int wh) { - const int s_h = 20, bm_w = 16; - // HACK: we need a defined StatusOutput - StatusPanel = new Fl_Group(0, 400, 1, 1, 0); - StatusPanel->end(); + const int bm_w = 20; + StatusPanel = new CustGroup(0, wh-sh, ww, sh); + + // Status box + StatusOutput = new Fl_Output(0, wh-sh, ww-bm_w, sh); + StatusOutput->value("hola!"); + StatusOutput->labelsize(8); + StatusOutput->box(FL_THIN_DOWN_BOX); + StatusOutput->clear_visible_focus(); + StatusOutput->color(FL_GRAY_RAMP + 18); + //StatusOutput->throw_focus(); + + // Bug Meter + // TODO: fltk1.3 places label on top or bottom (no left right) + BugMeter = new Fl_Button(ww-bm_w,wh-sh,bm_w,sh); + BugMeter->image(icons->ImgMeterOK); + BugMeter->box(FL_THIN_UP_BOX); + BugMeter->align(FL_ALIGN_INSIDE|FL_ALIGN_LEFT); + if (prefs.show_tooltip) + BugMeter->tooltip("Show HTML bugs\n(right-click for menu)"); + BugMeter->callback(bugmeter_cb, this); + BugMeter->clear_visible_focus(); - // Status box - StatusOutput = new Fl_Output(0, 0, ww-bm_w, s_h, 0); - StatusOutput->value(""); - StatusOutput->box(FL_THIN_DOWN_BOX); - StatusOutput->clear_visible_focus(); - StatusOutput->color(FL_GRAY_RAMP + 18); - //StatusOutput->throw_focus(); - - // Bug Meter - BugMeter = new Fl_Button(ww-bm_w,0,bm_w,s_h,0); - BugMeter->image(icons->ImgMeterOK); - BugMeter->box(FL_THIN_DOWN_BOX); - BugMeter->align(FL_ALIGN_INSIDE|FL_ALIGN_CLIP|FL_ALIGN_LEFT); - if (prefs.show_tooltip) - BugMeter->tooltip("Show HTML bugs\n(right-click for menu)"); - BugMeter->callback(bugmeter_cb, this); - BugMeter->clear_visible_focus(); + StatusPanel->end(); + StatusPanel->resizable(StatusOutput); } /* @@ -684,6 +687,7 @@ UI::UI(int x, int y, int ui_w, int ui_h, const char* label, const UI *cur_ui) : // Render area int mh = ui_h - (lh+bh+sh); Main = new Fl_Group(0,0,0,mh,"Welcome..."); + Main->end(); Main->align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE); Main->box(FL_FLAT_BOX); Main->color(FL_GRAY_RAMP + 3); @@ -695,12 +699,11 @@ UI::UI(int x, int y, int ui_w, int ui_h, const char* label, const UI *cur_ui) : MainIdx = TopGroup->find(Main); // Find text bar - findbar = new Findbar(ui_w, 28); + //findbar = new Findbar(ui_w, 28); //TopGroup->add(findbar); // Status Panel - make_status_panel(ui_w); - //TopGroup->add(StatusPanel); + make_status_panel(ui_w, ui_h); TopGroup->end(); @@ -715,7 +718,7 @@ UI::UI(int x, int y, int ui_w, int ui_h, const char* label, const UI *cur_ui) : if (Panelmode) { //Panel->hide(); - StatusPanel->hide(); + //StatusPanel->hide(); } } @@ -948,9 +951,9 @@ void UI::set_bug_prog(int n_bug) BugMeter->redraw_label(); new_w = strlen(str)*8 + 20; } - StatusOutput->resize(0,0,StatusPanel->w()-new_w,StatusOutput->h()); - BugMeter->resize(StatusPanel->w()-new_w, 0, new_w, BugMeter->h()); - StatusPanel->init_sizes(); +// StatusOutput->resize(0,0,StatusPanel->w()-new_w,StatusOutput->h()); +// BugMeter->resize(StatusPanel->w()-new_w, 0, new_w, BugMeter->h()); +// StatusPanel->init_sizes(); } /* @@ -1060,15 +1063,16 @@ void UI::panelmode_cb_i() /* * Set 'nw' as the main render area widget */ -void UI::set_render_layout(Fl_Group &nw) +void UI::set_render_layout(Fl_Group *nw) { - TopGroup->remove(MainIdx); + // Resize layout widget to current height + nw->resize(0,0,0,Main->h()); + + TopGroup->insert(*nw, Main); + remove(Main); delete(Main); - TopGroup->insert(nw, MainIdx); - Main = &nw; + Main = nw; TopGroup->resizable(Main); - //TopGroup->box(FL_DOWN_BOX); - //TopGroup->box(FL_BORDER_FRAME); } /* diff --git a/src/ui.hh b/src/ui.hh index 363ff9a6..74f62d75 100644 --- a/src/ui.hh +++ b/src/ui.hh @@ -144,7 +144,7 @@ class UI : public Fl_Pack { void make_menubar(int x, int y, int w, int h); Fl_Widget *make_filemenu_button(); void make_panel(int ww); - void make_status_panel(int ww); + void make_status_panel(int ww, int wh); public: @@ -162,7 +162,7 @@ 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(Fl_Group &nw); + void set_render_layout(Fl_Group *nw); void customize(int flags); void button_set_sens(UIButton btn, int sens); void paste_url(); diff --git a/src/uicmd.cc b/src/uicmd.cc index 7a8c3ccd..08f9f70b 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -420,10 +420,11 @@ static BrowserWindow *UIcmd_tab_new(CustTabs *tabs, int focus) 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->setBufferedDrawing (prefs.buffered_drawing ? true : false); layout->attachView (viewport); - new_ui->set_render_layout(*viewport); + new_ui->set_render_layout(viewport); viewport->setScrollStep((int) rint(14.0 * prefs.font_factor)); // Now, create a new browser window structure -- cgit v1.2.3 From b224c3e30c01837307922cd2402ef3e83896abc9 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Tue, 15 Mar 2011 09:26:49 -0300 Subject: Keybindings and some variable name normalizations --- src/ui.cc | 91 +++++++++++++++++++++++++++------------------------------------ src/ui.hh | 8 +++--- 2 files changed, 43 insertions(+), 56 deletions(-) (limited to 'src') diff --git a/src/ui.cc b/src/ui.cc index f13ca982..e2de1a40 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -103,32 +103,26 @@ int CustInput::handle(int e) _MSG("CustInput::handle event=%d\n", e); // We're only interested in some flags - //unsigned modifier = Fl::event_state() & (FL_SHIFT | FL_CTRL | FL_ALT); + unsigned modifier = Fl::event_state() & (FL_SHIFT | FL_CTRL | FL_ALT); // Don't focus with arrow keys if (e == FL_FOCUS && (k == FL_Up || k == FL_Down || k == FL_Left || k == FL_Right)) { return 0; - } -#if 0 } else if (e == FL_KEYBOARD) { if (modifier == FL_CTRL) { if (k == 'l') { // Make text selected when already focused. position(size(), 0); return 1; - } else if (k == 'o' || k == 'r' || k == FL_Home || k == FL_End) + } 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 == FL_SHIFT) { - if (k == FL_Left || k == FL_Right) { - _MSG(" CustInput::handle > FL_SHIFT+FL_Right\n"); - a_UIcmd_send_event_to_tabs_by_wid(e, this); - return 1; } } } - _MSG("\n"); -#endif + return Fl_Input::handle(e); } @@ -506,7 +500,7 @@ Fl_Widget *UI::make_filemenu_button() btn->copy_label(PanelSize == P_tiny ? "&F" : "&File"); btn->measure_label(w,h); if (PanelSize == P_large) - h = fh; + h = mh; btn->size(w+padding,PanelSize == P_tiny ? bh : lh); p_xpos += btn->w(); _MSG("UI::make_filemenu_button w=%d h=%d padding=%d\n", w, h, padding); @@ -542,26 +536,26 @@ void UI::make_panel(int ww) p_xpos = p_ypos = 0; if (PanelSize == P_tiny) { if (Small_Icons) - bw = 22, bh = 22, fh = 0, lh = 22, lbl = 0; + bw = 22, bh = 22, mh = 0, lh = 22, lbl = 0; else - 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) - bw = 20, bh = 20, fh = 0, lh = 20, lbl = 0; + bw = 20, bh = 20, mh = 0, lh = 20, lbl = 0; else - 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) - bw = 42, bh = 36, fh = 0, lh = 22, lbl = 1; + bw = 42, bh = 36, mh = 0, lh = 22, lbl = 1; else - 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) - bw = 42, bh = 36, fh = 22, lh = 22, lbl = 1; + bw = 42, bh = 36, mh = 22, lh = 22, lbl = 1; else - bw = 45, bh = 45, fh = 24, lh = 28, lbl = 1; + bw = 45, bh = 45, mh = 24, lh = 28, lbl = 1; } - nh = bh, sh = 20; + nh = bh, fh = 28; sh = 20; if (PanelSize == P_tiny) { NavBar = new CustGroup(0,0,ww,bh); @@ -618,10 +612,10 @@ void UI::make_panel(int ww) /* * Create the status panel */ -void UI::make_status_panel(int ww, int wh) +void UI::make_status_bar(int ww, int wh) { const int bm_w = 20; - StatusPanel = new CustGroup(0, wh-sh, ww, sh); + StatusBar = new CustGroup(0, wh-sh, ww, sh); // Status box StatusOutput = new Fl_Output(0, wh-sh, ww-bm_w, sh); @@ -630,7 +624,6 @@ void UI::make_status_panel(int ww, int wh) StatusOutput->box(FL_THIN_DOWN_BOX); StatusOutput->clear_visible_focus(); StatusOutput->color(FL_GRAY_RAMP + 18); - //StatusOutput->throw_focus(); // Bug Meter // TODO: fltk1.3 places label on top or bottom (no left right) @@ -643,8 +636,8 @@ void UI::make_status_panel(int ww, int wh) BugMeter->callback(bugmeter_cb, this); BugMeter->clear_visible_focus(); - StatusPanel->end(); - StatusPanel->resizable(StatusOutput); + StatusBar->end(); + StatusBar->resizable(StatusOutput); } /* @@ -685,7 +678,7 @@ UI::UI(int x, int y, int ui_w, int ui_h, const char* label, const UI *cur_ui) : make_panel(ui_w); // Render area - int mh = ui_h - (lh+bh+sh); + int mh = ui_h - (lh+bh+fh+sh); Main = new Fl_Group(0,0,0,mh,"Welcome..."); Main->end(); Main->align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE); @@ -701,9 +694,10 @@ UI::UI(int x, int y, int ui_w, int ui_h, const char* label, const UI *cur_ui) : // Find text bar //findbar = new Findbar(ui_w, 28); //TopGroup->add(findbar); - + Fl_Box *fb = new Fl_Box(0,0,0,fh, "F I N D B A R"); + // Status Panel - make_status_panel(ui_w, ui_h); + make_status_bar(ui_w, ui_h); TopGroup->end(); @@ -716,9 +710,13 @@ UI::UI(int x, int y, int ui_w, int ui_h, const char* label, const UI *cur_ui) : customize(0); + // Hide findbar + fb->hide(); + Main->size(Main->w(), Main->h()+fb->h()); + if (Panelmode) { //Panel->hide(); - //StatusPanel->hide(); + //StatusBar->hide(); } } @@ -737,10 +735,8 @@ UI::~UI() int UI::handle(int event) { _MSG("UI::handle event=%d (%d,%d)\n", event, Fl::event_x(), Fl::event_y()); - _MSG("Panel->h()=%d Main->h()=%d\n", Panel->h() , Main->h()); int ret = 0; -#if 0 if (event == FL_KEYBOARD) { return 0; // Receive as shortcut } else if (event == FL_SHORTCUT) { @@ -763,7 +759,8 @@ 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); + MSG("UI::handle ->KEYS_FIND\n"); + //set_findbar_visibility(1); ret = 1; } else if (cmd == KEYS_WEBSEARCH) { a_UIcmd_search_dialog(a_UIcmd_get_bw_by_widget(this)); @@ -771,18 +768,9 @@ 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)); + //set_panelmode(UI_HIDDEN); ret = 1; } else if (cmd == KEYS_OPEN) { a_UIcmd_open_file(a_UIcmd_get_bw_by_widget(this)); @@ -800,15 +788,14 @@ int UI::handle(int event) a_UIcmd_save(a_UIcmd_get_bw_by_widget(this)); ret = 1; } else if (cmd == KEYS_FULLSCREEN) { - panelmode_cb_i(); + //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; } + } +#if 0 } else if (event == FL_PUSH) { if (prefs.middle_click_drags_page == 0 && Fl::event_button() == FL_MIDDLE_MOUSE && @@ -951,9 +938,9 @@ void UI::set_bug_prog(int n_bug) BugMeter->redraw_label(); new_w = strlen(str)*8 + 20; } -// StatusOutput->resize(0,0,StatusPanel->w()-new_w,StatusOutput->h()); -// BugMeter->resize(StatusPanel->w()-new_w, 0, new_w, BugMeter->h()); -// StatusPanel->init_sizes(); +// StatusOutput->resize(0,0,StatusBar->w()-new_w,StatusOutput->h()); +// BugMeter->resize(StatusBar->w()-new_w, 0, new_w, BugMeter->h()); +// StatusBar->init_sizes(); } /* @@ -1035,11 +1022,11 @@ void UI::set_panelmode(UIPanelmode mode) { if (mode == UI_HIDDEN) { //Panel->hide(); - StatusPanel->hide(); + StatusBar->hide(); } else { /* UI_NORMAL or UI_TEMPORARILY_SHOW_PANELS */ //Panel->show(); - StatusPanel->show(); + StatusBar->show(); } Panelmode = mode; } diff --git a/src/ui.hh b/src/ui.hh index 74f62d75..f5225357 100644 --- a/src/ui.hh +++ b/src/ui.hh @@ -121,17 +121,17 @@ class UI : public Fl_Pack { Fl_Group *TopGroup; Fl_Button *Back, *Forw, *Home, *Reload, *Save, *Stop, *Bookmarks, *Tools, *Clear, *Search, *Help, *FullScreen, *BugMeter, *FileButton; - CustGroup *LocBar, *NavBar, *StBar; + CustGroup *LocBar, *NavBar, *StatusBar; Fl_Input *Location; Fl_Pack *ProgBox; CustProgressBox *PProg, *IProg; - Fl_Group *Panel, *Main, *StatusPanel; + Fl_Group *Panel, *Main; Fl_Output *StatusOutput; int MainIdx; // Panel customization variables int PanelSize, CuteColor, Small_Icons; - int p_xpos, p_ypos, bw, bh, fh, lh, nh, sh, pw, lbl; + int p_xpos, p_ypos, bw, bh, mh, lh, nh, fh, sh, pw, lbl; UIPanelmode Panelmode; Findbar *findbar; @@ -144,7 +144,7 @@ class UI : public Fl_Pack { void make_menubar(int x, int y, int w, int h); Fl_Widget *make_filemenu_button(); void make_panel(int ww); - void make_status_panel(int ww, int wh); + void make_status_bar(int ww, int wh); public: -- cgit v1.2.3 From a39c454217025d86a3ee9ae42895adbe6bf249be Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Tue, 15 Mar 2011 09:28:45 -0300 Subject: Made the findbar operative again (it has tricks and workarounds) --- src/findbar.cc | 23 +++++++++++++++++------ src/menu.cc | 2 +- src/ui.cc | 52 ++++++++++++++++++++++++++++++++++++---------------- src/ui.hh | 6 +++--- src/uicmd.cc | 17 ++++++++++++++++- src/uicmd.hh | 1 + 6 files changed, 74 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/findbar.cc b/src/findbar.cc index 2bda5452..cb0b345b 100644 --- a/src/findbar.cc +++ b/src/findbar.cc @@ -99,14 +99,13 @@ Findbar::Findbar(int width, int height) : 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(FL_PLASTIC_UP_BOX); - Fl_Group::hide(); + box(FL_THIN_UP_BOX); hide_btn = new Fl_Button(x, border, 16, height, 0); hideImg = new Fl_Pixmap(new_s_xpm); @@ -114,6 +113,7 @@ Findbar::Findbar(int width, int height) : x += 16 + gap; hide_btn->callback(hide_cb, this); hide_btn->clear_visible_focus(); + hide_btn->box(FL_THIN_UP_BOX); add(hide_btn); i = new MyInput(x, border, input_width, height); @@ -128,6 +128,7 @@ Findbar::Findbar(int width, int height) : next_btn->shortcut(FL_Enter); next_btn->callback(search_cb, this); next_btn->clear_visible_focus(); + next_btn->box(FL_THIN_UP_BOX); add(next_btn); prev_btn= new Fl_Button(x, border, button_width, height, "Previous"); @@ -135,6 +136,7 @@ Findbar::Findbar(int width, int height) : 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 Fl_Check_Button(x, border, 2*button_width, height, @@ -182,7 +184,13 @@ int Findbar::handle(int event) */ void Findbar::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); @@ -193,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(); - if ((bw = a_UIcmd_get_bw_by_widget(this))) - a_UIcmd_findtext_reset(bw); + a_UIcmd_findbar_toggle(bw, 0); + + a_UIcmd_findtext_reset(bw); a_UIcmd_focus_main_area(bw); } diff --git a/src/menu.cc b/src/menu.cc index 6c5835f8..0918ba51 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -156,7 +156,7 @@ static void Menu_add_bookmark_cb(Fl_Widget*, void* ) */ static void Menu_find_text_cb(Fl_Widget*, void* ) { - ((UI *)popup_bw->ui)->set_findbar_visibility(1); + ((UI *)popup_bw->ui)->findbar_toggle(1); } /* diff --git a/src/ui.cc b/src/ui.cc index e2de1a40..9026b822 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -110,7 +110,11 @@ int CustInput::handle(int e) (k == FL_Up || k == FL_Down || k == FL_Left || k == FL_Right)) { return 0; } else if (e == FL_KEYBOARD) { - if (modifier == FL_CTRL) { + if (k == FL_Escape && modifier == 0) { + // Let the parent group handle this Esc key + return 0; + + } else if (modifier == FL_CTRL) { if (k == 'l') { // Make text selected when already focused. position(size(), 0); @@ -692,12 +696,13 @@ UI::UI(int x, int y, int ui_w, int ui_h, const char* label, const UI *cur_ui) : MainIdx = TopGroup->find(Main); // Find text bar - //findbar = new Findbar(ui_w, 28); - //TopGroup->add(findbar); - Fl_Box *fb = new Fl_Box(0,0,0,fh, "F I N D B A R"); + 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(); @@ -710,10 +715,6 @@ UI::UI(int x, int y, int ui_w, int ui_h, const char* label, const UI *cur_ui) : customize(0); - // Hide findbar - fb->hide(); - Main->size(Main->w(), Main->h()+fb->h()); - if (Panelmode) { //Panel->hide(); //StatusBar->hide(); @@ -759,8 +760,10 @@ int UI::handle(int event) a_UIcmd_book(a_UIcmd_get_bw_by_widget(this)); ret = 1; } else if (cmd == KEYS_FIND) { - MSG("UI::handle ->KEYS_FIND\n"); - //set_findbar_visibility(1); + if (!FindBarSpace) { + findbar_toggle(1); + } else + FindBar->hide(); ret = 1; } else if (cmd == KEYS_WEBSEARCH) { a_UIcmd_search_dialog(a_UIcmd_get_bw_by_widget(this)); @@ -1094,13 +1097,30 @@ void UI::paste_url() } /* - * Shows or hides the findbar of this window + * Ajust 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. + * Most probably this is a bug in FLTK and we have to report it. + */ + + if (add && !FindBarSpace) { + // show + Main->size(Main->w(), Main->h()-FindBar->h()); + insert(*FindBar, StatusBar); + FindBar->show(); + FindBarSpace = 1; + } else if (!add && FindBarSpace) { + // hide + Main->size(Main->w(), Main->h()+FindBar->h()); + remove(FindBar); + FindBarSpace = 0; } + + // Main->redraw(); is not enough + redraw(); } diff --git a/src/ui.hh b/src/ui.hh index f5225357..c74b2056 100644 --- a/src/ui.hh +++ b/src/ui.hh @@ -127,14 +127,14 @@ class UI : public Fl_Pack { CustProgressBox *PProg, *IProg; Fl_Group *Panel, *Main; Fl_Output *StatusOutput; + Findbar *FindBar; - int MainIdx; + int FindBarSpace, MainIdx; // Panel customization variables int PanelSize, CuteColor, Small_Icons; int p_xpos, p_ypos, bw, bh, mh, lh, nh, fh, sh, pw, lbl; UIPanelmode Panelmode; - Findbar *findbar; int PointerOnLink; Fl_Button *make_button(const char *label, Fl_Image *img, Fl_Image*deimg, int b_n, int start = 0); @@ -168,7 +168,7 @@ public: void paste_url(); void set_panelmode(UIPanelmode mode); UIPanelmode get_panelmode(); - void set_findbar_visibility(bool visible); + void findbar_toggle(bool add); Fl_Widget *fullscreen_button() { return FullScreen; } void fullscreen_toggle() { FullScreen->do_callback(); } diff --git a/src/uicmd.cc b/src/uicmd.cc index 08f9f70b..190b9e7e 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -142,7 +142,11 @@ int CustTabs::handle(int e) UI *ui = (UI*)wizard()->value(); BrowserWindow *bw = a_UIcmd_get_bw_by_widget(ui); KeysCommand_t cmd = Keys::getKeyCmd(); - if (cmd == KEYS_NOP) { + if (Fl::event_key() == FL_Escape) { + // Hide findbar if present + ui->findbar_toggle(0); + ret = 1; + } else if (cmd == KEYS_NOP) { // Do nothing } else if (cmd == KEYS_NEW_TAB) { a_UIcmd_open_url_nt(bw, NULL, 1); @@ -435,6 +439,9 @@ static BrowserWindow *UIcmd_tab_new(CustTabs *tabs, int focus) // 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; } @@ -1230,6 +1237,14 @@ void a_UIcmd_findtext_reset(BrowserWindow *bw) a_UIcmd_set_msg(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. */ diff --git a/src/uicmd.hh b/src/uicmd.hh index c8fea9e7..65394ff2 100644 --- a/src/uicmd.hh +++ b/src/uicmd.hh @@ -39,6 +39,7 @@ 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); -- cgit v1.2.3 From dfce5ad6bc52369ebabcb508305dbffdaefd4553 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Tue, 15 Mar 2011 13:01:14 -0300 Subject: Made the bug meter number&icon display correctly --- src/ui.cc | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/ui.cc b/src/ui.cc index 9026b822..1bd6217c 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -630,11 +630,10 @@ void UI::make_status_bar(int ww, int wh) StatusOutput->color(FL_GRAY_RAMP + 18); // Bug Meter - // TODO: fltk1.3 places label on top or bottom (no left right) BugMeter = new Fl_Button(ww-bm_w,wh-sh,bm_w,sh); BugMeter->image(icons->ImgMeterOK); - BugMeter->box(FL_THIN_UP_BOX); - BugMeter->align(FL_ALIGN_INSIDE|FL_ALIGN_LEFT); + BugMeter->box(FL_THIN_DOWN_BOX); + BugMeter->align(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); @@ -928,7 +927,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); @@ -939,11 +938,10 @@ void UI::set_bug_prog(int n_bug) 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; } -// StatusOutput->resize(0,0,StatusBar->w()-new_w,StatusOutput->h()); -// BugMeter->resize(StatusBar->w()-new_w, 0, new_w, BugMeter->h()); -// StatusBar->init_sizes(); + BugMeter->size(new_w, BugMeter->h()); + StatusBar->rearrange(); } /* -- cgit v1.2.3 From 9f7e29fb7765c0d3ae9b375e95585f047acc6140 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Thu, 17 Mar 2011 17:26:18 -0300 Subject: Assorted minor changes (see verbose log) * Changed version to 3.0-pre * Made PgUp/PgDn Up/Dn keys shift focus from location to main area * Set http://dillo.org as the status bar first message (was "hola!). * Doubled the mousewheel scrollstep --- configure.in | 2 +- src/ui.cc | 13 ++++++++++--- src/uicmd.cc | 2 +- 3 files changed, 12 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/configure.in b/configure.in index e5d0786a..bf419619 100644 --- a/configure.in +++ b/configure.in @@ -1,6 +1,6 @@ dnl Process this file with aclocal, autoconf and automake. -AC_INIT([dillo], [2.2]) +AC_INIT([dillo], [3.0-pre]) dnl Detect the canonical target build environment AC_CANONICAL_TARGET diff --git a/src/ui.cc b/src/ui.cc index 1bd6217c..e4d6fd46 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -124,6 +124,13 @@ int CustInput::handle(int e) // 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) { + // Give up focus and honor the key + a_UIcmd_focus_main_area(a_UIcmd_get_bw_by_widget(this)); + return 0; + } } } @@ -623,7 +630,7 @@ void UI::make_status_bar(int ww, int wh) // Status box StatusOutput = new Fl_Output(0, wh-sh, ww-bm_w, sh); - StatusOutput->value("hola!"); + StatusOutput->value("http://dillo.org"); StatusOutput->labelsize(8); StatusOutput->box(FL_THIN_DOWN_BOX); StatusOutput->clear_visible_focus(); @@ -1112,13 +1119,13 @@ void UI::findbar_toggle(bool add) insert(*FindBar, StatusBar); FindBar->show(); FindBarSpace = 1; + redraw(); } else if (!add && FindBarSpace) { // hide Main->size(Main->w(), Main->h()+FindBar->h()); remove(FindBar); FindBarSpace = 0; + redraw(); /* Main->redraw(); is not enough */ } - // Main->redraw(); is not enough - redraw(); } diff --git a/src/uicmd.cc b/src/uicmd.cc index 190b9e7e..7a01d069 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -429,7 +429,7 @@ static BrowserWindow *UIcmd_tab_new(CustTabs *tabs, int focus) viewport->setBufferedDrawing (prefs.buffered_drawing ? true : false); layout->attachView (viewport); new_ui->set_render_layout(viewport); - viewport->setScrollStep((int) rint(14.0 * prefs.font_factor)); + viewport->setScrollStep((int) rint(28.0 * prefs.font_factor)); // Now, create a new browser window structure BrowserWindow *new_bw = a_Bw_new(); -- cgit v1.2.3 From 7960052b9b50e81705794ebf7e29289d60740df2 Mon Sep 17 00:00:00 2001 From: corvid Date: Fri, 18 Mar 2011 16:25:58 +0000 Subject: www.dillo.org status value --- src/ui.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui.cc b/src/ui.cc index e4d6fd46..b1e8972d 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -630,7 +630,7 @@ void UI::make_status_bar(int ww, int wh) // Status box StatusOutput = new Fl_Output(0, wh-sh, ww-bm_w, sh); - StatusOutput->value("http://dillo.org"); + StatusOutput->value("http://www.dillo.org"); StatusOutput->labelsize(8); StatusOutput->box(FL_THIN_DOWN_BOX); StatusOutput->clear_visible_focus(); -- cgit v1.2.3 From a8401c80019e376bc25db73b01d352bc764d294d Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Wed, 23 Mar 2011 11:42:35 -0300 Subject: Made fullscreen work again (Ctrl+Space) --- src/ui.cc | 46 +++++++++++++++++++++++++++++++++++----------- src/ui.hh | 3 +-- 2 files changed, 36 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/ui.cc b/src/ui.cc index b1e8972d..2eb4f52c 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -355,16 +355,6 @@ static void b1_cb(Fl_Widget *wid, void *cb_data) } } -/* - * Callback handler for fullscreen button press - */ -//static void fullscreen_cb(Fl_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. */ @@ -658,6 +648,8 @@ UI::UI(int x, int y, int ui_w, int ui_h, const char* label, const UI *cur_ui) : { PointerOnLink = FALSE; + LocBar = NavBar = StatusBar = NULL; + Tabs = NULL; TabTooltip = NULL; TopGroup = this; @@ -797,7 +789,7 @@ int UI::handle(int event) a_UIcmd_save(a_UIcmd_get_bw_by_widget(this)); ret = 1; } else if (cmd == KEYS_FULLSCREEN) { - //panelmode_cb_i(); + fullscreen_toggle(); ret = 1; } else if (cmd == KEYS_FILE_MENU) { a_UIcmd_file_popup(a_UIcmd_get_bw_by_widget(this), FileButton); @@ -1127,5 +1119,37 @@ void UI::findbar_toggle(bool add) FindBarSpace = 0; redraw(); /* Main->redraw(); is not enough */ } +} + +/* + * 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::fullscreen_toggle() +{ + int dh = 0; + int hide = StatusBar->visible(); + + // hide/show panels + init_sizes(); + if (LocBar) { + dh += lh; + hide ? LocBar->size(0,0) : LocBar->size(w(),lh); + hide ? LocBar->hide() : LocBar->show(); + } + if (NavBar) { + dh += nh; + hide ? NavBar->size(0,0) : NavBar->size(w(),nh); + hide ? NavBar->hide() : NavBar->show(); + } + if (StatusBar) { + dh += sh; + hide ? StatusBar->size(0,0) : StatusBar->size(w(),sh);; + hide ? StatusBar->hide() : StatusBar->show();; + } + Main->size(Main->w(), Main->h() + (hide ? dh : -dh)); + redraw(); } diff --git a/src/ui.hh b/src/ui.hh index c74b2056..9308cdd0 100644 --- a/src/ui.hh +++ b/src/ui.hh @@ -169,8 +169,7 @@ public: void set_panelmode(UIPanelmode mode); UIPanelmode get_panelmode(); void findbar_toggle(bool add); - Fl_Widget *fullscreen_button() { return FullScreen; } - void fullscreen_toggle() { FullScreen->do_callback(); } + void fullscreen_toggle(); CustTabs *tabs() { return Tabs; } void tabs(CustTabs *tabs) { Tabs = tabs; } -- cgit v1.2.3 From 1270e496491cc1df952e970f58ebdde0d4fb6ca7 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Thu, 24 Mar 2011 18:23:15 -0300 Subject: Bound KEYS_HIDE_PANELS key to hide panels (escape) --- src/ui.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/ui.cc b/src/ui.cc index 2eb4f52c..1d9e9bfd 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -769,10 +769,11 @@ int UI::handle(int event) } else if (cmd == KEYS_GOTO) { focus_location(); ret = 1; - } else if (cmd == KEYS_HIDE_PANELS && - get_panelmode() == UI_TEMPORARILY_SHOW_PANELS) { - //set_panelmode(UI_HIDDEN); + } else if (cmd == KEYS_HIDE_PANELS) { + fullscreen_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; @@ -1094,7 +1095,7 @@ void UI::paste_url() } /* - * Ajust space for the findbar (if necessary) and show or remove it + * Adjust space for the findbar (if necessary) and show or remove it */ void UI::findbar_toggle(bool add) { -- cgit v1.2.3 From 8cd5c228b38e9a66665262379ee12cd66ae477fd Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Wed, 30 Mar 2011 16:03:40 -0300 Subject: Fix for redraw problem when closing a non-focused tab (with tabs=2) --- src/uicmd.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/uicmd.cc b/src/uicmd.cc index 7a01d069..80099b9b 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -231,10 +231,14 @@ void CustTabs::remove_tab(UI *ui) int idx = get_btn_idx(ui); btn = (CustTabButton*)child(idx); idx > 1 ? prev_tab() : next_tab(); + + // WORKAROUND: with two tabs, closing the non-focused one, doesn't + // delete it from screen. This hide() call makes it work. --Jcid + btn->hide(); + remove(idx); delete btn; rearrange(); - //TODO: redraw doesn't work sometimes redraw(); Wizard->remove(ui); @@ -456,7 +460,6 @@ void a_UIcmd_close_bw(void *vbw) MSG("a_UIcmd_close_bw\n"); a_Bw_stop_clients(bw, BW_Root + BW_Img + BW_Force); - //TODO: sometimes this call segfaults upon exit delete(layout); if (ui->tabs()) { ui->tabs()->remove_tab(ui); -- cgit v1.2.3 From b835e19fabe790739f34093c4bc47ef6582a1a90 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Fri, 1 Apr 2011 14:59:23 -0300 Subject: Fixed button sensitivity when starting with an empty page --- src/dillo.cc | 5 ++++- src/menu.cc | 3 +-- src/uicmd.cc | 13 +++++++++---- 3 files changed, 14 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/dillo.cc b/src/dillo.cc index c7a0cbc3..a45ecdd1 100644 --- a/src/dillo.cc +++ b/src/dillo.cc @@ -380,7 +380,10 @@ PORT1.3 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); diff --git a/src/menu.cc b/src/menu.cc index 0918ba51..e44d3672 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -84,8 +84,7 @@ void CustItem::draw() { static void filemenu_cb(Fl_Widget *wid, 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) { diff --git a/src/uicmd.cc b/src/uicmd.cc index 80099b9b..e4b034fe 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -161,7 +161,7 @@ int CustTabs::handle(int e) MSG("CustTabs::handle KEYS_RIGHT_TAB\n"); ret = 1; } else if (cmd == KEYS_NEW_WINDOW) { - a_UIcmd_browser_window_new(ui->w(),ui->h()+this->h(),0,bw); + a_UIcmd_open_url_nw(bw, NULL); ret = 1; } else if (cmd == KEYS_FULLSCREEN) { MSG("CustTabs::handle KEYS_FULLSCREEN\n"); @@ -405,8 +405,6 @@ BrowserWindow *a_UIcmd_browser_window_new(int ww, int wh, win->callback(win_cb, DilloTabs); - //new_ui->focus_location(); - return new_bw; } @@ -528,7 +526,13 @@ 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); @@ -546,6 +550,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); } } -- cgit v1.2.3 From 6e30f0b366c5fb4404cae4a38a7418515f0a2af4 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Fri, 15 Apr 2011 14:08:53 -0300 Subject: Fix for endless loop with META refresh and same URL or no URL at all --- src/html.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/html.cc b/src/html.cc index 3e44e26e..2ba4329a 100644 --- a/src/html.cc +++ b/src/html.cc @@ -2845,6 +2845,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 */ @@ -2875,14 +2876,17 @@ static void Html_tag_open_meta(DilloHtml *html, const char *tag, int tagsize) } else { mr_url = dStrdup(content); } + new_url = a_Url_new(mr_url, URL_STR(html->base_url)); - if (delay == 0) { + 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; - 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, @@ -2900,6 +2904,7 @@ static void Html_tag_open_meta(DilloHtml *html, const char *tag, int tagsize) } dStr_free(ds_msg, 1); } + a_Url_free(new_url); dFree(mr_url); } else if (!dStrcasecmp(equiv, "content-type") && -- cgit v1.2.3 From 03fcca9bbb9641821e3f4d071dcf1105777182ba Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Fri, 15 Apr 2011 18:16:05 -0300 Subject: Introduced class CustLightButton for visual feedback on panel buttons --- src/ui.cc | 50 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/ui.cc b/src/ui.cc index 1d9e9bfd..fda82271 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -139,17 +139,44 @@ int CustInput::handle(int 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); +} + +//---------------------------------------------------------------------------- + /* * Used to handle "paste" within the toolbar's Clear button. */ -class CustButton : public Fl_Button { +class CustPasteButton : public CustLightButton { public: - CustButton(int x, int y, int w, int h, const char *l=0) : - Fl_Button(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 CustButton::handle(int e) +int CustPasteButton::handle(int e) { if (e == FL_PASTE) { const char* t = Fl::event_text(); @@ -159,7 +186,7 @@ int CustButton::handle(int e) return 1; } } - return Fl_Button::handle(e); + return CustLightButton::handle(e); } //---------------------------------------------------------------------------- @@ -385,7 +412,7 @@ Fl_Button *UI::make_button(const char *label, Fl_Image *img, Fl_Image *deimg, if (start) p_xpos = 0; - Fl_Button *b = new Fl_Button(p_xpos, 0, bw, bh, (lbl) ? label : NULL); + Fl_Button *b = new CustLightButton(p_xpos, 0, bw, bh, (lbl) ? label : NULL); if (img) b->image(img); if (deimg) @@ -393,7 +420,8 @@ Fl_Button *UI::make_button(const char *label, Fl_Image *img, Fl_Image *deimg, b->callback(b1_cb, (void *)b_n); b->clear_visible_focus(); b->labelsize(12); - b->box(FL_NO_BOX); + b->box(FL_FLAT_BOX); + b->down_box(FL_THIN_DOWN_FRAME); p_xpos += bw; return b; } @@ -431,7 +459,7 @@ void UI::make_location(int ww) { Fl_Button *b; - Clear = b = new CustButton(p_xpos,0,16,lh,0); + Clear = b = new CustPasteButton(p_xpos,0,16,lh,0); b->image(icons->ImgClear); b->callback(clear_cb, this); b->clear_visible_focus(); @@ -444,14 +472,14 @@ void UI::make_location(int ww) i->callback(location_cb, this); p_xpos += i->w(); - Search = b = new Fl_Button(p_xpos,0,16,lh,0); + Search = b = new CustLightButton(p_xpos,0,16,lh,0); b->image(icons->ImgSearch); b->callback(search_cb, this); b->clear_visible_focus(); b->box(FL_THIN_UP_BOX); p_xpos += b->w(); - Help = b = new Fl_Button(p_xpos,0,16,lh,0); + Help = b = new CustLightButton(p_xpos,0,16,lh,0); b->image(icons->ImgHelp); b->callback(help_cb, this); b->clear_visible_focus(); @@ -627,7 +655,7 @@ void UI::make_status_bar(int ww, int wh) StatusOutput->color(FL_GRAY_RAMP + 18); // Bug Meter - BugMeter = new Fl_Button(ww-bm_w,wh-sh,bm_w,sh); + 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_TEXT_NEXT_TO_IMAGE); -- cgit v1.2.3 From f5a66adda52c917dec3d159ad698baad030912f0 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Sat, 16 Apr 2011 16:43:27 -0300 Subject: Fixed offset bugs with panel tiny and large (also fullscreen mode for large) --- src/ui.cc | 28 ++++++++++++++++------------ src/ui.hh | 2 +- 2 files changed, 17 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/ui.cc b/src/ui.cc index fda82271..008c32cc 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -528,9 +528,8 @@ Fl_Widget *UI::make_filemenu_button() padding = w; btn->copy_label(PanelSize == P_tiny ? "&F" : "&File"); btn->measure_label(w,h); - if (PanelSize == P_large) - h = mh; - btn->size(w+padding,PanelSize == P_tiny ? bh : lh); + 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 ? FL_THIN_UP_BOX : FL_THIN_UP_BOX); @@ -587,7 +586,7 @@ void UI::make_panel(int ww) nh = bh, fh = 28; sh = 20; if (PanelSize == P_tiny) { - NavBar = new CustGroup(0,0,ww,bh); + NavBar = new CustGroup(0,0,ww,nh); NavBar->begin(); make_toolbar(ww,bh); make_filemenu_button(); @@ -599,12 +598,12 @@ void UI::make_panel(int ww) } else { // File menu if (PanelSize == P_large) { - Fl_Group *g3 = new Fl_Group(0,0,ww,lh); - g3->begin(); - g3->box(FL_THIN_UP_BOX); + MenuBar = new CustGroup(0,0,ww,mh); + MenuBar->begin(); + MenuBar->box(FL_THIN_UP_BOX); Fl_Widget *bn = make_filemenu_button(); - g3->add_resizable(*new Fl_Box(bn->w(),0,ww - bn->w(),lh)); - g3->end(); + MenuBar->add_resizable(*new Fl_Box(bn->w(),0,ww - bn->w(),mh)); + MenuBar->end(); p_xpos = 0; LocBar = new CustGroup(0,0,ww,lh); @@ -676,7 +675,7 @@ UI::UI(int x, int y, int ui_w, int ui_h, const char* label, const UI *cur_ui) : { PointerOnLink = FALSE; - LocBar = NavBar = StatusBar = NULL; + MenuBar = LocBar = NavBar = StatusBar = NULL; Tabs = NULL; TabTooltip = NULL; @@ -708,8 +707,8 @@ UI::UI(int x, int y, int ui_w, int ui_h, const char* label, const UI *cur_ui) : make_panel(ui_w); // Render area - int mh = ui_h - (lh+bh+fh+sh); - Main = new Fl_Group(0,0,0,mh,"Welcome..."); + int main_h = ui_h - (mh+(LocBar?lh:0)+nh+fh+sh); + Main = new Fl_Group(0,0,0,main_h,"Welcome..."); Main->end(); Main->align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE); Main->box(FL_FLAT_BOX); @@ -1163,6 +1162,11 @@ void UI::fullscreen_toggle() // hide/show panels init_sizes(); + if (MenuBar) { + dh += mh; + hide ? MenuBar->size(0,0) : MenuBar->size(w(),mh); + hide ? MenuBar->hide() : MenuBar->show(); + } if (LocBar) { dh += lh; hide ? LocBar->size(0,0) : LocBar->size(w(),lh); diff --git a/src/ui.hh b/src/ui.hh index 9308cdd0..ebe6b9f3 100644 --- a/src/ui.hh +++ b/src/ui.hh @@ -121,7 +121,7 @@ class UI : public Fl_Pack { Fl_Group *TopGroup; Fl_Button *Back, *Forw, *Home, *Reload, *Save, *Stop, *Bookmarks, *Tools, *Clear, *Search, *Help, *FullScreen, *BugMeter, *FileButton; - CustGroup *LocBar, *NavBar, *StatusBar; + CustGroup *MenuBar, *LocBar, *NavBar, *StatusBar; Fl_Input *Location; Fl_Pack *ProgBox; CustProgressBox *PProg, *IProg; -- cgit v1.2.3 From b949237e024ec19cfddda9003d5905c60e8599c8 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Tue, 19 Apr 2011 13:48:16 -0300 Subject: Set FL_FREE_LABELTYPE to interpret symbols and draw shortcut (for "File" menu) --- src/dillo.cc | 27 +++++++++++++++++++++++++-- src/ui.cc | 1 + 2 files changed, 26 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/dillo.cc b/src/dillo.cc index a45ecdd1..0e76411b 100644 --- a/src/dillo.cc +++ b/src/dillo.cc @@ -169,13 +169,16 @@ static OptID getCmdOption(const CLI_options *options, int argc, char **argv, return opt_id; } +/* + * We'll set FL_NORMAL_LABEL to not interpret special symbols, + * and FL_FREE_LABELTYPE to interpret them. + */ 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); @@ -186,7 +189,26 @@ 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 = 1; + fl_draw_shortcut = 1; fl_font(o->font, o->size); fl_measure(o->value, W, H, interpret_symbols); } @@ -343,8 +365,9 @@ int main(int argc, char **argv) // Sets WM_CLASS hint on X11 Fl_Window::default_xclass("dillo"); - // Disable '@' interpretation in labels + // Disable '@' interpretation in normal labels Fl::set_labeltype(FL_NORMAL_LABEL, custLabelDraw, custLabelMeasure); + Fl::set_labeltype(FL_FREE_LABELTYPE,custMenuLabelDraw,custMenuLabelMeasure); #if 0 PORT1.3 diff --git a/src/ui.cc b/src/ui.cc index 008c32cc..804bc8c2 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -524,6 +524,7 @@ Fl_Widget *UI::make_filemenu_button() int w,h, padding; FileButton = btn = new Fl_Button(p_xpos,0,0,0,"W"); + btn->labeltype(FL_FREE_LABELTYPE); btn->measure_label(w, h); padding = w; btn->copy_label(PanelSize == P_tiny ? "&F" : "&File"); -- cgit v1.2.3 From 7a526530784731fd19f2ec313cb0c82beed944dd Mon Sep 17 00:00:00 2001 From: corvid Date: Wed, 20 Apr 2011 01:55:59 +0000 Subject: rm obsolete comment --- src/ui.cc | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/ui.cc b/src/ui.cc index 804bc8c2..4880cdff 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -869,8 +869,6 @@ 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->value(str); Location->position(strlen(str)); } -- cgit v1.2.3 From d85682a6441876ae1a39b8d8abe1ec7bef39cc6d Mon Sep 17 00:00:00 2001 From: corvid Date: Wed, 20 Apr 2011 13:48:57 +0000 Subject: symbol/shortcut interpretation, comments --- src/dillo.cc | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/dillo.cc b/src/dillo.cc index 0e76411b..937385cb 100644 --- a/src/dillo.cc +++ b/src/dillo.cc @@ -170,8 +170,8 @@ static OptID getCmdOption(const CLI_options *options, int argc, char **argv, } /* - * We'll set FL_NORMAL_LABEL to not interpret special symbols, - * and FL_FREE_LABELTYPE to interpret them. + * 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) @@ -206,7 +206,7 @@ static void custMenuLabelDraw(const Fl_Label* o, int X, int Y, int W, int H, static void custMenuLabelMeasure(const Fl_Label* o, int& W, int& H) { - const int interpret_symbols = 1; + const int interpret_symbols = 0; fl_draw_shortcut = 1; fl_font(o->font, o->size); @@ -365,8 +365,10 @@ int main(int argc, char **argv) // Sets WM_CLASS hint on X11 Fl_Window::default_xclass("dillo"); - // Disable '@' interpretation in normal labels + // Disable '@' and '&' interpretation in normal labels. Fl::set_labeltype(FL_NORMAL_LABEL, custLabelDraw, custLabelMeasure); + + // Use to permit '&' interpretation. Fl::set_labeltype(FL_FREE_LABELTYPE,custMenuLabelDraw,custMenuLabelMeasure); #if 0 -- cgit v1.2.3 From 3af2baa213aeb6eadac056a7a4e71da5174a2806 Mon Sep 17 00:00:00 2001 From: corvid Date: Wed, 20 Apr 2011 13:54:55 +0000 Subject: comment --- src/menu.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/menu.cc b/src/menu.cc index e44d3672..94ab7e37 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -34,7 +34,7 @@ static DilloUrl *popup_url = NULL; // Weak reference to the popup's bw static BrowserWindow *popup_bw = NULL; static void *popup_form = NULL; -// Where to place the filemenu popup +// Where to place the popup static int popup_x, popup_y; // History popup direction (-1 = back, 1 = forward). static int history_direction = -1; -- cgit v1.2.3 From f65cb8b1c2ec26474f2629de4c2b31de1993ffe8 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Thu, 21 Apr 2011 13:12:51 -0300 Subject: Switched make_panel() to use insert() instead of begin()/end() pairs --- src/ui.cc | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/ui.cc b/src/ui.cc index 4880cdff..db56ea60 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -586,6 +586,7 @@ void UI::make_panel(int ww) } nh = bh, fh = 28; sh = 20; + current(0); if (PanelSize == P_tiny) { NavBar = new CustGroup(0,0,ww,nh); NavBar->begin(); @@ -596,8 +597,8 @@ void UI::make_panel(int ww) make_progress_bars(0,1); NavBar->box(FL_THIN_UP_FRAME); NavBar->end(); + TopGroup->insert(*NavBar,0); } else { - // File menu if (PanelSize == P_large) { MenuBar = new CustGroup(0,0,ww,mh); MenuBar->begin(); @@ -605,19 +606,23 @@ void UI::make_panel(int ww) Fl_Widget *bn = make_filemenu_button(); MenuBar->add_resizable(*new Fl_Box(bn->w(),0,ww - bn->w(),mh)); MenuBar->end(); + TopGroup->insert(*MenuBar,0); p_xpos = 0; LocBar = new CustGroup(0,0,ww,lh); LocBar->begin(); make_location(ww); LocBar->end(); + TopGroup->insert(*LocBar,1); } else { LocBar = new CustGroup(0,0,ww,lh); + LocBar->begin(); p_xpos = 0; make_filemenu_button(); make_location(ww); LocBar->resizable(Location); LocBar->end(); + TopGroup->insert(*LocBar,0); } // Toolbar @@ -635,6 +640,7 @@ void UI::make_panel(int ww) make_progress_bars(1,0); } NavBar->end(); + TopGroup->insert(*NavBar,(MenuBar ? 2 : 1)); } } @@ -682,7 +688,6 @@ UI::UI(int x, int y, int ui_w, int ui_h, const char* label, const UI *cur_ui) : TabTooltip = NULL; TopGroup = this; TopGroup->type(VERTICAL); - //resizable(TopGroup); clear_flag(SHORTCUT_LABEL); if (cur_ui) { @@ -710,7 +715,6 @@ UI::UI(int x, int y, int ui_w, int ui_h, const char* label, const UI *cur_ui) : // Render area int main_h = ui_h - (mh+(LocBar?lh:0)+nh+fh+sh); Main = new Fl_Group(0,0,0,main_h,"Welcome..."); - Main->end(); Main->align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE); Main->box(FL_FLAT_BOX); Main->color(FL_GRAY_RAMP + 3); @@ -718,6 +722,7 @@ UI::UI(int x, int y, int ui_w, int ui_h, const char* label, const UI *cur_ui) : Main->labelsize(36); Main->labeltype(FL_SHADOW_LABEL); Main->labelcolor(FL_WHITE); + TopGroup->add(Main); TopGroup->resizable(Main); MainIdx = TopGroup->find(Main); -- cgit v1.2.3 From 5567884e9d110921ec880bfb886acdb3ab7e2a65 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Thu, 21 Apr 2011 13:14:44 -0300 Subject: Made on-the-fly control panel work again --- src/ui.cc | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/ui.cc b/src/ui.cc index db56ea60..f6ad84cd 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -1017,18 +1017,26 @@ void UI::customize(int flags) */ void UI::panel_cb_i() { -#if 0 - Fl_Group *NewPanel; - - // Create a new Panel + // 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; + + // make a new panel ++PanelSize; - NewPanel = make_panel(TopGroup->w()); - TopGroup->remove(Panel); - delete(Panel); - TopGroup->add(NewPanel); - Panel = NewPanel; + make_panel(TopGroup->w()); customize(0); -#endif + + // adjust Main's height + int main_h = h() - (mh+(LocBar?lh:0)+nh+(FindBarSpace?fh:0)+sh); + Main->size(Main->w(), main_h); + redraw(); + Location->take_focus(); } -- cgit v1.2.3 From feb717facdc7fadf6b629d4bb9a34bfa87eba623 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Thu, 21 Apr 2011 13:15:51 -0300 Subject: Added a submenu to control the panel size (Tools) --- src/menu.cc | 22 +++++++++++++++++++--- src/ui.cc | 22 ++++++++++++++-------- src/ui.hh | 4 +++- 3 files changed, 36 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/menu.cc b/src/menu.cc index 94ab7e37..43fc27ab 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -645,16 +645,26 @@ void a_Menu_tools_popup(BrowserWindow *bw, void *v_wid) { 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,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, 0, (void*)"Submenu1", FL_SUBMENU,0,0,0,0}, + {"tiny", 0,0,(void*)P_tiny,FL_MENU_RADIO,0,0,0,0}, + {"small", 0,0,(void*)P_small,FL_MENU_RADIO,0,0,0,0}, + {"medium",0,0,(void*)P_medium,FL_MENU_RADIO,0,0,0,0}, + {"large", 0,0,(void*)P_large,FL_MENU_RADIO|FL_MENU_DIVIDER,0,0,0,0}, + {"small icons", 0,0,(void*)10,FL_MENU_TOGGLE,0,0,0,0}, {0,0,0,0,0,0,0,0,0} }; popup_bw = bw; + int cur_panelsize = ui->get_panelsize(); + int cur_smallicons = ui->get_smallicons(); if (prefs.load_stylesheets) pm[0].set(); @@ -662,9 +672,15 @@ void a_Menu_tools_popup(BrowserWindow *bw, void *v_wid) 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(); + if (item) { + if (VOIDP2INT(item->user_data_) == 10) + ui->change_panel(cur_panelsize, !cur_smallicons); + else + ui->change_panel(VOIDP2INT(item->user_data_), cur_smallicons); + } } diff --git a/src/ui.cc b/src/ui.cc index f6ad84cd..3defba8a 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -238,7 +238,7 @@ static void search_cb(Fl_Widget *wid, void *data) } else if (b == FL_MIDDLE_MOUSE) { ((UI*)data)->color_change_cb_i(); } else if (b == FL_RIGHT_MOUSE) { - ((UI*)data)->panel_cb_i(); + ((UI*)data)->change_panel(-1,-1); } } @@ -551,11 +551,6 @@ void UI::make_panel(int ww) { Fl_Widget *w; - if (PanelSize > P_large) { - PanelSize = P_tiny; - Small_Icons = !Small_Icons; - } - if (Small_Icons) icons = &small_icons; else @@ -1015,7 +1010,7 @@ void UI::customize(int flags) /* * On-the-fly panel style change */ -void UI::panel_cb_i() +void UI::change_panel(int new_size, int small_icons) { // Remove current panel's bars init_sizes(); @@ -1027,10 +1022,21 @@ void UI::panel_cb_i() Fl::delete_widget(NavBar); MenuBar = LocBar = NavBar = NULL; + // Set panel and icons size + if (new_size < 0 || small_icons < 0) { + if (++PanelSize > P_large) { + PanelSize = P_tiny; + Small_Icons = !Small_Icons; + } + } else { + PanelSize = new_size; + Small_Icons = small_icons; + } + // make a new panel - ++PanelSize; make_panel(TopGroup->w()); customize(0); + a_UIcmd_set_buttons_sens(a_UIcmd_get_bw_by_widget(this)); // adjust Main's height int main_h = h() - (mh+(LocBar?lh:0)+nh+(FindBarSpace?fh:0)+sh); diff --git a/src/ui.hh b/src/ui.hh index ebe6b9f3..b42b2ab6 100644 --- a/src/ui.hh +++ b/src/ui.hh @@ -168,6 +168,9 @@ public: void paste_url(); void set_panelmode(UIPanelmode mode); UIPanelmode get_panelmode(); + 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 fullscreen_toggle(); @@ -177,7 +180,6 @@ public: 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(); -- cgit v1.2.3 From 0e49a66a2f5a5ed84285c39f6eed40fc1b911c1e Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Thu, 21 Apr 2011 13:22:00 -0300 Subject: Disabled the right-click-over-search-button hook that changed panel size --- src/ui.cc | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/ui.cc b/src/ui.cc index 3defba8a..24ea3039 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -238,7 +238,7 @@ static void search_cb(Fl_Widget *wid, void *data) } else if (b == FL_MIDDLE_MOUSE) { ((UI*)data)->color_change_cb_i(); } else if (b == FL_RIGHT_MOUSE) { - ((UI*)data)->change_panel(-1,-1); + // nothing ATM } } @@ -1022,16 +1022,9 @@ void UI::change_panel(int new_size, int small_icons) Fl::delete_widget(NavBar); MenuBar = LocBar = NavBar = NULL; - // Set panel and icons size - if (new_size < 0 || small_icons < 0) { - if (++PanelSize > P_large) { - PanelSize = P_tiny; - Small_Icons = !Small_Icons; - } - } else { - PanelSize = new_size; - Small_Icons = small_icons; - } + // Set internal vars for panel size + PanelSize = new_size; + Small_Icons = small_icons; // make a new panel make_panel(TopGroup->w()); -- cgit v1.2.3 From 12a3282acf655441d094e15fb817cb99f0be9426 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Thu, 21 Apr 2011 14:02:08 -0300 Subject: Reenabled "focus_new_tab" dillorc pref (also SHIFT-middleclick to revert) --- src/uicmd.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/uicmd.cc b/src/uicmd.cc index e4b034fe..5f36b785 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -207,7 +207,7 @@ UI *CustTabs::add_new_tab(int focus) btn->copy_label(tab_label); btn->clear_visible_focus(); btn->box(FL_PLASTIC_ROUND_UP_BOX); - btn->color(tabcolor_active); + btn->color(focus ? tabcolor_active : tabcolor_inactive); btn->ui(new_ui); add(btn); btn->redraw(); @@ -394,7 +394,8 @@ BrowserWindow *a_UIcmd_browser_window_new(int ww, int wh, CustTabs *DilloTabs = new CustTabs(ww, wh, 16); win->end(); - new_bw = UIcmd_tab_new(DilloTabs, 1); + int focus = 1; + new_bw = UIcmd_tab_new(DilloTabs, focus); win->resizable(Gui); win->show(); @@ -417,7 +418,7 @@ static BrowserWindow *UIcmd_tab_new(CustTabs *tabs, int focus) MSG(" UIcmd_tab_new\n"); // Create and set the UI - UI *new_ui = tabs->add_new_tab(1); + UI *new_ui = tabs->add_new_tab(focus); Gui = new_ui; // Now create the Dw render layout and viewport -- cgit v1.2.3 From 85ced28dc8f9c8732012559a54e1b75a3ab47522 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Thu, 21 Apr 2011 17:46:42 -0300 Subject: Made button visibility prefs work again for: search, help and file menu --- src/ui.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ui.cc b/src/ui.cc index 24ea3039..cb4b4fdc 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -538,7 +538,7 @@ Fl_Widget *UI::make_filemenu_button() if (prefs.show_tooltip) btn->tooltip("File menu"); btn->clear_visible_focus(); - if (!prefs.show_filemenu && PanelSize != P_large) + if (!prefs.show_filemenu) btn->hide(); return btn; } @@ -607,6 +607,7 @@ void UI::make_panel(int ww) LocBar = new CustGroup(0,0,ww,lh); LocBar->begin(); make_location(ww); + LocBar->resizable(Location); LocBar->end(); TopGroup->insert(*LocBar,1); } else { @@ -1004,7 +1005,10 @@ void UI::customize(int flags) // if ( !prefs.show_progress_box ) // ProgBox->hide(); - NavBar->rearrange(); + if (NavBar) + NavBar->rearrange(); + if (LocBar) + LocBar->rearrange(); } /* -- cgit v1.2.3 From 8cb0ecb4528da4f988ce4ccd13bfaddb4e968aa3 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Thu, 21 Apr 2011 19:06:09 -0300 Subject: Fixed a glitch with panel size change and redraw --- src/ui.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui.cc b/src/ui.cc index cb4b4fdc..c66bdb66 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -627,7 +627,7 @@ void UI::make_panel(int ww) NavBar->begin(); make_toolbar(ww,bh); w = new Fl_Box(p_xpos,0,ww-p_xpos-2*pw,bh); - w->box(FL_NO_BOX); + w->box(FL_FLAT_BOX); NavBar->resizable(w); p_xpos = ww - 2*pw; if (PanelSize == P_small) { -- cgit v1.2.3 From 15788cf72d831d266f33576fab9fa1c4aea98421 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Fri, 22 Apr 2011 13:23:09 -0300 Subject: Made "new tab" and "new window" follow the style of the requesting UI --- src/uicmd.cc | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/uicmd.cc b/src/uicmd.cc index 5f36b785..223817a2 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -61,7 +61,7 @@ static UI *Gui; /* * Forward declarations */ -static BrowserWindow *UIcmd_tab_new(CustTabs *tabs, int focus); +static BrowserWindow *UIcmd_tab_new(CustTabs *tabs, UI *old_ui, int focus); //---------------------------------------------------------------------------- @@ -102,7 +102,7 @@ public: Wizard->end(); }; int handle(int e); - UI *add_new_tab(int focus); + 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); @@ -191,12 +191,12 @@ int CustTabs::handle(int e) /* * Create a new tab with its own UI */ -UI *CustTabs::add_new_tab(int focus) +UI *CustTabs::add_new_tab(UI *old_ui, int focus) { char tab_label[64]; current(0); - UI *new_ui = new UI(0,tab_h,Wizard->w(),Wizard->h()); + UI *new_ui = new UI(0,tab_h,Wizard->w(),Wizard->h(),0,old_ui); new_ui->tabs(this); Wizard->add(new_ui); new_ui->show(); @@ -375,6 +375,7 @@ BrowserWindow *a_UIcmd_browser_window_new(int ww, int wh, { BrowserWindow *old_bw = (BrowserWindow*)vbw; BrowserWindow *new_bw = NULL; + UI *old_ui = old_bw ? BW2UI(old_bw) : NULL; Fl_Window *win; if (ww <= 0 || wh <= 0) { @@ -395,7 +396,7 @@ BrowserWindow *a_UIcmd_browser_window_new(int ww, int wh, win->end(); int focus = 1; - new_bw = UIcmd_tab_new(DilloTabs, focus); + new_bw = UIcmd_tab_new(DilloTabs, old_ui, focus); win->resizable(Gui); win->show(); @@ -413,12 +414,12 @@ BrowserWindow *a_UIcmd_browser_window_new(int ww, int wh, * Create a new Tab button, UI and its associated BrowserWindow data * structure. */ -static BrowserWindow *UIcmd_tab_new(CustTabs *tabs, int focus) +static BrowserWindow *UIcmd_tab_new(CustTabs *tabs, UI *old_ui, int focus) { - MSG(" UIcmd_tab_new\n"); + _MSG(" UIcmd_tab_new\n"); // Create and set the UI - UI *new_ui = tabs->add_new_tab(focus); + UI *new_ui = tabs->add_new_tab(old_ui, focus); Gui = new_ui; // Now create the Dw render layout and viewport @@ -575,7 +576,8 @@ 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 *bw = (BrowserWindow *)vbw; - BrowserWindow *new_bw = UIcmd_tab_new(BW2UI(bw)->tabs(), focus); + BrowserWindow *new_bw = UIcmd_tab_new(BW2UI(bw)->tabs(), + bw ? BW2UI(bw) : NULL, focus); UIcmd_open_url_nbw(new_bw, url); } -- cgit v1.2.3 From 6f6e1d22aaf13430072c816fa5fefcb24c210e80 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Fri, 22 Apr 2011 16:12:20 -0300 Subject: Fix for e816e06ee901: it disabled the preceeding menuitems --- src/menu.cc | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/menu.cc b/src/menu.cc index 43fc27ab..f6fc9d4e 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -619,6 +619,16 @@ static void Menu_embedded_css_cb(Fl_Widget *wid, void*) 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. */ @@ -654,10 +664,11 @@ void a_Menu_tools_popup(BrowserWindow *bw, void *v_wid) {"Load images", 0, Menu_imgload_toggle_cb, 0, FL_MENU_TOGGLE|FL_MENU_DIVIDER,0,0,0,0}, {"Panel size", 0, 0, (void*)"Submenu1", FL_SUBMENU,0,0,0,0}, - {"tiny", 0,0,(void*)P_tiny,FL_MENU_RADIO,0,0,0,0}, - {"small", 0,0,(void*)P_small,FL_MENU_RADIO,0,0,0,0}, - {"medium",0,0,(void*)P_medium,FL_MENU_RADIO,0,0,0,0}, - {"large", 0,0,(void*)P_large,FL_MENU_RADIO|FL_MENU_DIVIDER,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,0,(void*)10,FL_MENU_TOGGLE,0,0,0,0}, {0,0,0,0,0,0,0,0,0} }; @@ -677,10 +688,7 @@ void a_Menu_tools_popup(BrowserWindow *bw, void *v_wid) item = pm->popup(wid->x(), wid->y() + wid->h()); if (item) { - if (VOIDP2INT(item->user_data_) == 10) - ui->change_panel(cur_panelsize, !cur_smallicons); - else - ui->change_panel(VOIDP2INT(item->user_data_), cur_smallicons); + ((Fl_Widget *)item)->do_callback(); } } -- cgit v1.2.3 From 5eecefedf0f6df8a18def517229f9cc1a291f096 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Fri, 22 Apr 2011 18:32:01 -0300 Subject: Fix for e816e06ee901: part 2 (missing callback) --- src/menu.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/menu.cc b/src/menu.cc index f6fc9d4e..71cc1957 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -669,7 +669,8 @@ void a_Menu_tools_popup(BrowserWindow *bw, void *v_wid) {"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,0,(void*)10,FL_MENU_TOGGLE,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} }; -- cgit v1.2.3 From d8bfa3d7f887a9b48f69bae66f1e7430cbaf3e5f Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Wed, 27 Apr 2011 15:59:47 -0300 Subject: Set Ctrl-w as default for close tab/window (it was Ctrl-q) --- doc/user_help.html | 8 ++++---- src/keys.cc | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/doc/user_help.html b/doc/user_help.html index 0ef12d4c..48eaeb14 100644 --- a/doc/user_help.html +++ b/doc/user_help.html @@ -37,7 +37,7 @@
  • Some of the functions in Dillo are handled by independent processes. For instance, downloads come through wget. If Dillo exits, the download can continue (more details - below). + below). @@ -69,7 +69,7 @@
  • Dialogs can be closed with the ESC key.
  • If you want to try a different control panel, right-click over the search button until you find one that suits your needs, then make - it the default in your dillorc file. + it the default in your dillorc file.
  • The whole window area can be used to display the page. Just hit Ctrl-Space! @@ -232,7 +232,7 @@
  • If you don't have root access, install dpid and the dpis inside your ~/.dillo/ directory as explained - in the README file. + in the README file. @@ -273,7 +273,7 @@ Ctrl-R Reload reload current page Ctrl-N New New browser window Ctrl-T Tab New tab -Ctrl-Q Quit quit tab/window +Ctrl-W Window quit tab/window Ctrl-O Open Open file Ctrl-B Bookmarks view bookmarks Ctrl-Space "more space!" Hide/show controls diff --git a/src/keys.cc b/src/keys.cc index d71c74bf..c009fdfa 100644 --- a/src/keys.cc +++ b/src/keys.cc @@ -85,7 +85,7 @@ static const KeyBinding_t default_keys[] = { { "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 , 'q' }, + { "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' }, -- cgit v1.2.3 From cba85f1371ff700dcdc2060b3dfe617a83669f8b Mon Sep 17 00:00:00 2001 From: corvid Date: Wed, 27 Apr 2011 19:56:21 +0000 Subject: change keysrc as well --- src/keysrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/keysrc b/src/keysrc index 3f53674f..f7bebb66 100644 --- a/src/keysrc +++ b/src/keysrc @@ -27,7 +27,7 @@ # "close-tab" closes the current tab. # Note that this closes the browser window if there is only one tab. -#q = close-tab +#w = close-tab # "close-all" closes all tabs/windows and exits. #q = close-all -- cgit v1.2.3 From 8fa4c9664385632ae706c3a34e896940e8ba10f0 Mon Sep 17 00:00:00 2001 From: corvid Date: Thu, 28 Apr 2011 16:09:30 +0000 Subject: fix panel size menu --- src/menu.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/menu.cc b/src/menu.cc index 71cc1957..ef3236f2 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -671,6 +671,7 @@ void a_Menu_tools_popup(BrowserWindow *bw, void *v_wid) 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} }; -- cgit v1.2.3 From e608f83c2911039b724d72eec75c69ed190482f5 Mon Sep 17 00:00:00 2001 From: corvid Date: Thu, 28 Apr 2011 19:31:47 +0000 Subject: fltk1's copy_label() calls redraw_label() --- src/ui.cc | 2 -- src/uicmd.cc | 2 -- 2 files changed, 4 deletions(-) (limited to 'src') diff --git a/src/ui.cc b/src/ui.cc index c66bdb66..966e2ec6 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -209,7 +209,6 @@ public: copy_label(lbl); //measure_label(w,h); //size(w+padding,this->h()); - redraw_label(); } }; @@ -964,7 +963,6 @@ 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)*9 + 20; } BugMeter->size(new_w, BugMeter->h()); diff --git a/src/uicmd.cc b/src/uicmd.cc index 223817a2..8e73a1e9 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -317,7 +317,6 @@ void CustTabs::set_tab_label(UI *ui, const char *label) // Avoid unnecessary redraws if (strcmp(child(idx)->label(), title)) { child(idx)->copy_label(title); - child(idx)->redraw_label(); } } } @@ -1151,7 +1150,6 @@ void a_UIcmd_set_page_title(BrowserWindow *bw, const char *label) snprintf(title + i, 4, "..."); } BW2UI(bw)->window()->copy_label(title); - BW2UI(bw)->window()->redraw_label(); } BW2UI(bw)->tabs()->set_tab_label(BW2UI(bw), label); } -- cgit v1.2.3 From bf26a108295b7c2d281118c4e7258d868a5deb34 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Thu, 28 Apr 2011 19:38:26 -0300 Subject: Made Ctrl-q the default for close-all (it was Alt-q) --- doc/user_help.html | 4 ++-- src/keys.cc | 2 +- src/keysrc | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/doc/user_help.html b/doc/user_help.html index 48eaeb14..b6219f71 100644 --- a/doc/user_help.html +++ b/doc/user_help.html @@ -276,12 +276,12 @@ Ctrl-W Window quit tab/window Ctrl-O Open Open file Ctrl-B Bookmarks view bookmarks -Ctrl-Space "more space!" Hide/show controls +Ctrl-Space or Esc "more space!" Hide/show controls +Ctrl-Q Quit exit Dillo Back or "," < previous page Shift-Back or "." > next page Esc escape close dialog Alt-F File file menu -Alt-X eXit exit Dillo Shift-Right Right Next tab Shift-Left Left Previous tab Ctrl-TabKey TabKey Next tab diff --git a/src/keys.cc b/src/keys.cc index c009fdfa..b00df190 100644 --- a/src/keys.cc +++ b/src/keys.cc @@ -95,7 +95,7 @@ static const KeyBinding_t default_keys[] = { { "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_ALT , 'q' }, + { "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 }, diff --git a/src/keysrc b/src/keysrc index f7bebb66..086367c9 100644 --- a/src/keysrc +++ b/src/keysrc @@ -30,7 +30,7 @@ #w = close-tab # "close-all" closes all tabs/windows and exits. -#q = close-all +#q = close-all # "left-tab" and "right-tab" switch to the left/right of the current tab. # *** NOT HOOKED UP YET *** -- cgit v1.2.3 From 1e61bf1c83d638941739be2c786af63851bc4338 Mon Sep 17 00:00:00 2001 From: corvid Date: Fri, 29 Apr 2011 04:11:46 +0000 Subject: less wordy close dialog buttons --- src/uicmd.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/uicmd.cc b/src/uicmd.cc index 8e73a1e9..c12b7e9d 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -330,7 +330,7 @@ static void win_cb (Fl_Widget *w, void *cb_data) { if (tabs->num_tabs() > 1) choice = a_Dialog_choice5("Window contains more than one tab.", - "Close all tabs", "Cancel", NULL, NULL, NULL); + "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())); @@ -475,8 +475,8 @@ void a_UIcmd_close_all_bw(void *) int choice = 1; if (a_Bw_num() > 1) - choice = a_Dialog_choice5("More than one open tab or Window.", - "Close all tabs and windows", "Cancel", NULL, NULL, NULL); + 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); -- cgit v1.2.3 From 9193ddeffbe3ede83193f302cba21b86e6b6c94b Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Fri, 29 Apr 2011 12:30:39 -0300 Subject: Set middle click as default for close tab (+ right_click_closes_tab in dillorc) --- dillorc | 4 ++++ src/prefs.c | 1 + src/prefs.h | 1 + src/prefsparser.cc | 1 + src/uicmd.cc | 3 ++- 5 files changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/dillorc b/dillorc index fccb7932..56dc9ec5 100644 --- a/dillorc +++ b/dillorc @@ -228,6 +228,10 @@ # If you prefer to open a new Window instead, set it to NO. #middle_click_opens_new_tab=YES +# A mouse's middle click over a tab closes the Tab. +# With mousewheel mouses, right click feels way better (set to YES). +#right_click_closes_tab=NO + # Mouse middle click by default drives drag-scrolling. # To paste an URL into the window instead of scrolling, set it to NO. # Note: You could always paste the URL onto the URL box clear button. diff --git a/src/prefs.c b/src/prefs.c index f968710a..be0882bd 100644 --- a/src/prefs.c +++ b/src/prefs.c @@ -70,6 +70,7 @@ 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; diff --git a/src/prefs.h b/src/prefs.h index 4009925c..4debee89 100644 --- a/src/prefs.h +++ b/src/prefs.h @@ -84,6 +84,7 @@ struct _DilloPrefs { char *font_monospace; bool_t enterpress_forces_submit; bool_t middle_click_opens_new_tab; + bool_t right_click_closes_tab; char *search_url; char *save_dir; bool_t show_msg; diff --git a/src/prefsparser.cc b/src/prefsparser.cc index 95f98c16..7d0582cd 100644 --- a/src/prefsparser.cc +++ b/src/prefsparser.cc @@ -81,6 +81,7 @@ 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 }, diff --git a/src/uicmd.cc b/src/uicmd.cc index c12b7e9d..fd6067e6 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -125,7 +125,8 @@ static void tab_btn_cb (Fl_Widget *w, void *cb_data) if (b == FL_LEFT_MOUSE) { tabs->switch_tab(btn); - } else if (b == FL_RIGHT_MOUSE) { + } 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())); } -- cgit v1.2.3 From b88762c5bcd8924ef3ba44f1eacc8eb4c2270944 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Sat, 30 Apr 2011 17:10:21 -0300 Subject: Re-enabled middle click on history popups (Back and Forward buttons) --- src/menu.cc | 49 ++++--------------------------------------------- 1 file changed, 4 insertions(+), 45 deletions(-) (limited to 'src') diff --git a/src/menu.cc b/src/menu.cc index ef3236f2..fa725931 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -41,41 +41,6 @@ static int history_direction = -1; // History popup, list of URL-indexes. static int *history_list = NULL; -#if 0 -My guess is that a modified copy of Fl_Menu_ that handles something similar -to Fl_Menu_Item may be necessary. I sure hope not, though. - -/* - * 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 Fl_Menu_Item { - int EventButton; -public: - CustItem (const char* label) : Item(label) { EventButton = 0; }; - int button () { return EventButton; }; - void draw(); - int handle(int e) { - EventButton = Fl::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(); -} -#endif //-------------------------------------------------------------------------- /* @@ -283,14 +248,13 @@ static void Menu_bugmeter_about_cb(Fl_Widget*, void* ) */ static void Menu_history_cb(Fl_Widget *wid, void *data) { -#if 0 - int mb = ((CustItem*)wid)->button(); -#endif + int mb = Fl::event_button(); int offset = history_direction * VOIDP2INT(data); -#if 0 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; @@ -299,12 +263,7 @@ static void Menu_history_cb(Fl_Widget *wid, void *data) } else { a_UIcmd_open_url_nw(popup_bw, url); } - } else { -#endif - a_UIcmd_nav_jump(popup_bw, offset, 0); -#if 0 } -#endif } /* -- cgit v1.2.3 From fc691dfd5cfa43d35d47e3db0675cc76279ff94b Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Sat, 30 Apr 2011 22:18:45 -0300 Subject: Re-enabled "Find text" to select text when already shown --- src/ui.cc | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/ui.cc b/src/ui.cc index 966e2ec6..1fd7f6b7 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -786,10 +786,7 @@ int UI::handle(int event) a_UIcmd_book(a_UIcmd_get_bw_by_widget(this)); ret = 1; } else if (cmd == KEYS_FIND) { - if (!FindBarSpace) { - findbar_toggle(1); - } else - FindBar->hide(); + findbar_toggle(1); ret = 1; } else if (cmd == KEYS_WEBSEARCH) { a_UIcmd_search_dialog(a_UIcmd_get_bw_by_widget(this)); @@ -1146,13 +1143,18 @@ void UI::findbar_toggle(bool add) * Most probably this is a bug in FLTK and we have to report it. */ - if (add && !FindBarSpace) { - // show - Main->size(Main->w(), Main->h()-FindBar->h()); - insert(*FindBar, StatusBar); - FindBar->show(); - FindBarSpace = 1; - redraw(); + if (add) { + if (!FindBarSpace) { + // show + Main->size(Main->w(), Main->h()-FindBar->h()); + insert(*FindBar, StatusBar); + FindBar->show(); + FindBarSpace = 1; + redraw(); + } else { + // select text + FindBar->show(); + } } else if (!add && FindBarSpace) { // hide Main->size(Main->w(), Main->h()+FindBar->h()); -- cgit v1.2.3 From b0a08db34316bdc37dd6e8fc8c8cd9920463913d Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Sun, 1 May 2011 22:41:12 -0300 Subject: Re-enabled "show_progress_box" dillorc preference --- src/ui.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ui.cc b/src/ui.cc index 1fd7f6b7..cd9147a9 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -997,8 +997,10 @@ 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(); -- cgit v1.2.3 From 761e47f55d9caffcdc1381293f6b26356601b5ed Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Mon, 2 May 2011 21:39:52 +0200 Subject: initial take on Xembed port to fltk-1.3 --- src/xembed.cc | 9 +++------ src/xembed.hh | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/xembed.cc b/src/xembed.cc index 2039d8c9..f5b3ae51 100644 --- a/src/xembed.cc +++ b/src/xembed.cc @@ -106,7 +106,7 @@ PORT1.3 // TODO: Implement more XEMBED support; -void Xembed::create() { +void Xembed::show() { createInternal(xid); setXembedInfo(1); Fl::add_handler(event_handler); @@ -161,11 +161,8 @@ Xembed::handle(int e) { } void -Xembed::create() { -#if 0 -PORT1.3 - Fl_Window::create(); -#endif +Xembed::show() { + Fl_Window::show(); } #endif diff --git a/src/xembed.hh b/src/xembed.hh index fe40014d..d7663c8e 100644 --- a/src/xembed.hh +++ b/src/xembed.hh @@ -16,7 +16,7 @@ class Xembed : public Fl_Window { Xembed(uint32_t xid, int _w, int _h) : Fl_Window(_w, _h) { this->xid = xid; }; - void create(); + void show(); int handle(int event); }; -- cgit v1.2.3 From 3e14c7b0392808eba16343eee6ce9278c8facd11 Mon Sep 17 00:00:00 2001 From: corvid Date: Sun, 8 May 2011 22:50:51 +0000 Subject: FindBar leak --- src/ui.cc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/ui.cc b/src/ui.cc index cd9147a9..0270b38b 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -754,6 +754,9 @@ UI::~UI() { _MSG("UI::~UI()\n"); dFree(TabTooltip); + + if (!FindBarSpace) + delete FindBar; } /* -- cgit v1.2.3 From 6f807dd550576b3f6622658d6c6c55e5b0a59bc7 Mon Sep 17 00:00:00 2001 From: corvid Date: Sun, 8 May 2011 22:58:39 +0000 Subject: fl_measure expects w to be set --- src/ui.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/ui.cc b/src/ui.cc index 0270b38b..27303115 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -200,7 +200,7 @@ public: CustProgressBox(int x, int y, int w, int h, const char *l=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); @@ -520,7 +520,7 @@ void UI::make_progress_bars(int wide, int thin_up) Fl_Widget *UI::make_filemenu_button() { Fl_Button *btn; - int w,h, padding; + int w = 0, h = 0, padding; FileButton = btn = new Fl_Button(p_xpos,0,0,0,"W"); btn->labeltype(FL_FREE_LABELTYPE); -- cgit v1.2.3 From 0b50246dca460726123406508b59a01a308856ac Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Fri, 13 May 2011 14:14:43 -0400 Subject: Avoid lots of flicker while resizing the window (when "buffered_drawing" is set to 0 or 1) --- dw/fltkviewbase.cc | 1 + src/ui.cc | 1 + src/uicmd.cc | 3 ++- test/dw_anchors_test.cc | 1 + test/dw_border_test.cc | 1 + test/dw_example.cc | 1 + test/dw_find_test.cc | 2 ++ test/dw_images_scaled.cc | 1 + test/dw_images_scaled2.cc | 1 + test/dw_images_simple.cc | 1 + test/dw_links.cc | 1 + test/dw_links2.cc | 3 +++ test/dw_lists.cc | 1 + test/dw_resource_test.cc | 1 + test/dw_table.cc | 1 + test/dw_table_aligned.cc | 1 + test/dw_ui_test.cc | 1 + test/fltk_browser.cc | 1 + 18 files changed, 22 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/dw/fltkviewbase.cc b/dw/fltkviewbase.cc index 10c3fa65..9c17eabb 100644 --- a/dw/fltkviewbase.cc +++ b/dw/fltkviewbase.cc @@ -78,6 +78,7 @@ FltkViewBase::FltkViewBase (int x, int y, int w, int h, const char *label): if (backBuffer == NULL) { backBuffer = new BackBuffer (); } + box(FL_NO_BOX); } FltkViewBase::~FltkViewBase () diff --git a/src/ui.cc b/src/ui.cc index 27303115..5ca58e8e 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -683,6 +683,7 @@ UI::UI(int x, int y, int ui_w, int ui_h, const char* label, const UI *cur_ui) : TabTooltip = NULL; TopGroup = this; TopGroup->type(VERTICAL); + TopGroup->box(FL_NO_BOX); clear_flag(SHORTCUT_LABEL); if (cur_ui) { diff --git a/src/uicmd.cc b/src/uicmd.cc index fd6067e6..02747e48 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -96,6 +96,7 @@ public: Fl_Box *w = new Fl_Box(0,0,0,0,"i n v i s i b l e"); w->box(FL_NO_BOX); resizable(0); + box(FL_FLAT_BOX); end(); Wizard = new Fl_Wizard(0,tab_h,ww,wh-tab_h); @@ -391,7 +392,7 @@ BrowserWindow *a_UIcmd_browser_window_new(int ww, int wh, else win = new Fl_Double_Window(ww, wh); - //Fl_Group::current(0); + win->box(FL_NO_BOX); CustTabs *DilloTabs = new CustTabs(ww, wh, 16); win->end(); diff --git a/test/dw_anchors_test.cc b/test/dw_anchors_test.cc index be5bed7a..17a0d699 100644 --- a/test/dw_anchors_test.cc +++ b/test/dw_anchors_test.cc @@ -99,6 +99,7 @@ int main(int argc, char **argv) layout = new Layout (platform); window = new Fl_Window(250, 200, "Dw Anchors Test"); + window->box(FL_NO_BOX); window->begin(); viewport = new FltkViewport (50, 0, 200, 200); diff --git a/test/dw_border_test.cc b/test/dw_border_test.cc index 5f7b8bb5..453d5a3f 100644 --- a/test/dw_border_test.cc +++ b/test/dw_border_test.cc @@ -39,6 +39,7 @@ int main(int argc, char **argv) Layout *layout = new Layout (platform); Fl_Window *window = new Fl_Window(200, 300, "Dw Border Test"); + window->box(FL_NO_BOX); window->begin(); FltkViewport *viewport = new FltkViewport (0, 0, 200, 300); diff --git a/test/dw_example.cc b/test/dw_example.cc index 674252fe..c83878de 100644 --- a/test/dw_example.cc +++ b/test/dw_example.cc @@ -34,6 +34,7 @@ int main(int argc, char **argv) dw::core::Layout *layout = new dw::core::Layout (platform); Fl_Window *window = new Fl_Window(200, 300, "Dw Example"); + window->box(FL_NO_BOX); window->begin(); dw::fltk::FltkViewport *viewport = diff --git a/test/dw_find_test.cc b/test/dw_find_test.cc index d007301a..01032285 100644 --- a/test/dw_find_test.cc +++ b/test/dw_find_test.cc @@ -73,6 +73,7 @@ int main(int argc, char **argv) layout = new Layout (platform); window = new Fl_Window(200, 300, "Dw Find Test"); + window->box(FL_NO_BOX); window->begin(); viewport = new FltkViewport (0, 0, 200, 280); @@ -90,6 +91,7 @@ int main(int argc, char **argv) resetButton->clear_visible_focus (); resultLabel = new Fl_Box(100, 280, 100, 20, "---"); + resultLabel->box(FL_FLAT_BOX); FontAttrs fontAttrs; fontAttrs.name = "Bitstream Charter"; diff --git a/test/dw_images_scaled.cc b/test/dw_images_scaled.cc index a6b3d390..171930cb 100644 --- a/test/dw_images_scaled.cc +++ b/test/dw_images_scaled.cc @@ -96,6 +96,7 @@ int main(int argc, char **argv) layout = new Layout (platform); Fl_Window *window = new Fl_Window(410, 210, "Dw Scaled Image"); + window->box(FL_NO_BOX); window->begin(); FltkViewport *viewport = new FltkViewport (0, 0, 410, 210); diff --git a/test/dw_images_scaled2.cc b/test/dw_images_scaled2.cc index 5a8e0f57..0e897188 100644 --- a/test/dw_images_scaled2.cc +++ b/test/dw_images_scaled2.cc @@ -73,6 +73,7 @@ int main(int argc, char **argv) layout = new Layout (platform); Fl_Window *window = new Fl_Window(410, 210, "Dw Scaled Image 2"); + window->box(FL_NO_BOX); window->begin(); FltkViewport *viewport = new FltkViewport (0, 0, 410, 210); diff --git a/test/dw_images_simple.cc b/test/dw_images_simple.cc index d2554929..ec6f6008 100644 --- a/test/dw_images_simple.cc +++ b/test/dw_images_simple.cc @@ -97,6 +97,7 @@ int main(int argc, char **argv) layout = new Layout (platform); Fl_Window *window = new Fl_Window(410, 210, "Dw Simple Image"); + window->box(FL_NO_BOX); window->begin(); FltkViewport *viewport = new FltkViewport (0, 0, 410, 210); diff --git a/test/dw_links.cc b/test/dw_links.cc index 5160462b..a73e6c46 100644 --- a/test/dw_links.cc +++ b/test/dw_links.cc @@ -77,6 +77,7 @@ int main(int argc, char **argv) Layout *layout = new Layout (platform); Fl_Window *window = new Fl_Window(200, 300, "Dw Links"); + window->box(FL_NO_BOX); window->begin(); FltkViewport *viewport = new FltkViewport (0, 0, 200, 300); diff --git a/test/dw_links2.cc b/test/dw_links2.cc index a4a6bbab..bca9a8ac 100644 --- a/test/dw_links2.cc +++ b/test/dw_links2.cc @@ -80,11 +80,13 @@ int main(int argc, char **argv) Layout *layout = new Layout (platform); Fl_Window *window = new Fl_Window(200, 300, "Dw Links2"); + window->box(FL_NO_BOX); window->begin(); Fl_Widget *Panel = new Fl_Box(0, 0, ww, lh, "CONTROL PANEL"); Panel->color(FL_GRAY_RAMP + 3); Panel->labelcolor(FL_WHITE); + Panel->box(FL_FLAT_BOX); Fl_Widget *Main = new Fl_Box(0, lh, ww, wh - 2*lh, "MAIN RENDERING AREA"); Main->color(FL_GRAY_RAMP + 4); Main->labelcolor(FL_WHITE); @@ -93,6 +95,7 @@ int main(int argc, char **argv) Fl_Widget *Bar = new Fl_Box(0, wh - lh, 200, lh, "STATUS BAR..."); Bar->color(FL_GRAY_RAMP + 3); Bar->labelcolor(FL_WHITE); + Bar->box(FL_FLAT_BOX); window->resizable(Main); window->end(); diff --git a/test/dw_lists.cc b/test/dw_lists.cc index 9d0298ca..9862f09c 100644 --- a/test/dw_lists.cc +++ b/test/dw_lists.cc @@ -39,6 +39,7 @@ int main(int argc, char **argv) Layout *layout = new Layout (platform); Fl_Window *window = new Fl_Window(200, 300, "Dw Lists"); + window->box(FL_NO_BOX); window->begin(); FltkViewport *viewport = new FltkViewport (0, 0, 200, 300); diff --git a/test/dw_resource_test.cc b/test/dw_resource_test.cc index 7b550594..671d0d10 100644 --- a/test/dw_resource_test.cc +++ b/test/dw_resource_test.cc @@ -40,6 +40,7 @@ int main(int argc, char **argv) Layout *layout = new Layout (platform); Fl_Window *window = new Fl_Window(410, 210, "Dw Resource test"); + window->box(FL_NO_BOX); window->begin(); FltkViewport *viewport = new FltkViewport (0, 0, 410, 210); diff --git a/test/dw_table.cc b/test/dw_table.cc index 1d4ae368..21a381f7 100644 --- a/test/dw_table.cc +++ b/test/dw_table.cc @@ -39,6 +39,7 @@ int main(int argc, char **argv) Layout *layout = new Layout (platform); Fl_Window *window = new Fl_Window(300, 300, "Dw Table"); + window->box(FL_NO_BOX); window->begin(); FltkViewport *viewport = new FltkViewport (0, 0, 300, 300); diff --git a/test/dw_table_aligned.cc b/test/dw_table_aligned.cc index e6043f3c..0f4441a9 100644 --- a/test/dw_table_aligned.cc +++ b/test/dw_table_aligned.cc @@ -39,6 +39,7 @@ int main(int argc, char **argv) Layout *layout = new Layout (platform); Fl_Window *window = new Fl_Window(200, 300, "Dw Table Aligned"); + window->box(FL_NO_BOX); window->begin(); FltkViewport *viewport = new FltkViewport (0, 0, 200, 300); diff --git a/test/dw_ui_test.cc b/test/dw_ui_test.cc index 57368fab..dee2809d 100644 --- a/test/dw_ui_test.cc +++ b/test/dw_ui_test.cc @@ -44,6 +44,7 @@ int main(int argc, char **argv) Layout *layout = new Layout (platform); Fl_Window *window = new Fl_Window(400, 400, "Dw UI Test"); + window->box(FL_NO_BOX); window->begin(); FltkViewport *viewport = new FltkViewport (0, 0, 400, 400); diff --git a/test/fltk_browser.cc b/test/fltk_browser.cc index d5d5ef32..9afda33a 100644 --- a/test/fltk_browser.cc +++ b/test/fltk_browser.cc @@ -26,6 +26,7 @@ int main (int argc, char *argv[]) { Fl_Window *window = new Fl_Window (300, 300, "FLTK Browser"); + window->box(FL_NO_BOX); window->begin (); Fl_Browser *browser = new Fl_Browser (0, 0, 300, 300); browser->begin (); -- cgit v1.2.3 From 0f8cb48af3903c6a355c5404f5b5d01942eabd2b Mon Sep 17 00:00:00 2001 From: corvid Date: Mon, 16 May 2011 18:57:34 +0000 Subject: only disable the inputs outside of forms if stylesheets are pending http://lists.auriga.wearlab.de/pipermail/dillo-dev/2010-March/007408.html http://lists.auriga.wearlab.de/pipermail/dillo-dev/2011-May/008319.html --- src/form.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/form.cc b/src/form.cc index 18441fb8..bf1f8e33 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); + } } } -- cgit v1.2.3 From 399b0fa3b970ec1ff6969902639d5058c3e732a9 Mon Sep 17 00:00:00 2001 From: corvid Date: Mon, 16 May 2011 19:13:04 +0000 Subject: rm spaces --- dw/fltkcomplexbutton.cc | 2 +- dw/fltkcomplexbutton.hh | 4 ++-- dw/fltkui.cc | 2 +- dw/fltkviewbase.cc | 4 ++-- dw/fltkviewbase.hh | 2 +- dw/fltkviewport.cc | 2 +- src/cssparser.cc | 2 +- src/html.cc | 2 +- src/menu.cc | 6 +++--- src/ui.cc | 4 ++-- src/uicmd.cc | 2 +- 11 files changed, 16 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/dw/fltkcomplexbutton.cc b/dw/fltkcomplexbutton.cc index 211a37e8..39257bde 100644 --- a/dw/fltkcomplexbutton.cc +++ b/dw/fltkcomplexbutton.cc @@ -126,7 +126,7 @@ int ComplexButton::handle(int event) { return 1; case FL_SHORTCUT: if (!(shortcut() ? - Fl::test_shortcut(shortcut()) : test_shortcut())) return 0; + Fl::test_shortcut(shortcut()) : test_shortcut())) return 0; if (Fl::visible_focus() && handle(FL_FOCUS)) Fl::focus(this); goto triggered_by_keyboard; case FL_FOCUS : /* FALLTHROUGH */ diff --git a/dw/fltkcomplexbutton.hh b/dw/fltkcomplexbutton.hh index 6266694a..e4ca2e2b 100644 --- a/dw/fltkcomplexbutton.hh +++ b/dw/fltkcomplexbutton.hh @@ -23,7 +23,7 @@ #include // values for type() -#define FL_NORMAL_BUTTON 0 /**< value() will be set to 1 during the press of the button and +#define FL_NORMAL_BUTTON 0 /**< value() will be set to 1 during the press of the button and reverts back to 0 when the button is released */ #define FL_TOGGLE_BUTTON 1 ///< value() toggles between 0 and 1 at every click of the button #define FL_RADIO_BUTTON (FL_RESERVED_TYPE+2) /**< is set to 1 at button press, and all other @@ -49,7 +49,7 @@ protected: static Fl_Widget_Tracker *key_release_tracker; static void key_release_timeout(void*); void simulate_key_action(); - + virtual void draw(); public: diff --git a/dw/fltkui.cc b/dw/fltkui.cc index f79dea80..c29a32ec 100644 --- a/dw/fltkui.cc +++ b/dw/fltkui.cc @@ -980,7 +980,7 @@ Fl_Menu_Item *FltkOptionMenuResource::newItem() return item; } - + void FltkOptionMenuResource::addItem (const char *str, bool enabled, bool selected) { diff --git a/dw/fltkviewbase.cc b/dw/fltkviewbase.cc index de974578..eaaae1c4 100644 --- a/dw/fltkviewbase.cc +++ b/dw/fltkviewbase.cc @@ -143,7 +143,7 @@ void FltkViewBase::draw (const core::Rectangle *rect, // fl_clip_box() can't handle values greater than SHRT_MAX! if (X > x () + w () || Y > y () + h ()) return; - + W = X + rect->width > x () + w () ? x () + w () - X : rect->width; H = Y + rect->height > y () + h () ? y () + h () - Y : rect->height; @@ -288,7 +288,7 @@ int FltkViewBase::handle (int event) case FL_UNFOCUS: focused_child = fl_oldfocus; return 0; - + default: return Fl_Group::handle (event); } diff --git a/dw/fltkviewbase.hh b/dw/fltkviewbase.hh index 4fb7df9d..b1b6c4ab 100644 --- a/dw/fltkviewbase.hh +++ b/dw/fltkviewbase.hh @@ -23,7 +23,7 @@ private: public: Fl_Offscreen offscreen; - + BackBuffer (); ~BackBuffer (); void setSize(int w, int h); diff --git a/dw/fltkviewport.cc b/dw/fltkviewport.cc index 135550e8..9e75932f 100644 --- a/dw/fltkviewport.cc +++ b/dw/fltkviewport.cc @@ -147,7 +147,7 @@ void FltkViewport::hscrollbarCallback (Fl_Widget *hscrollbar,void *viewportPtr) // ---------------------------------------------------------------------- -void FltkViewport::resize(int X, int Y, int W, int H) +void FltkViewport::resize(int X, int Y, int W, int H) { bool dimension_changed = W != w() || H != h(); diff --git a/src/cssparser.cc b/src/cssparser.cc index aa4cea56..1075ef63 100644 --- a/src/cssparser.cc +++ b/src/cssparser.cc @@ -1522,7 +1522,7 @@ const char * CssParser::propertyNameString(CssPropertyName name) { return Css_property_info[name].symbol; } - + void CssParser::ignoreBlock() { int depth = 0; diff --git a/src/html.cc b/src/html.cc index ede391a3..c3235209 100644 --- a/src/html.cc +++ b/src/html.cc @@ -2880,7 +2880,7 @@ static void Html_tag_open_meta(DilloHtml *html, const char *tag, int tagsize) if (a_Url_cmp(html->base_url, new_url) == 0) { /* redirection loop, or empty url string: ignore */ - BUG_MSG("META refresh: %s\n", + BUG_MSG("META refresh: %s\n", *mr_url ? "redirection loop" : "no target URL"); } else if (delay == 0) { /* zero-delay redirection */ diff --git a/src/menu.cc b/src/menu.cc index fa725931..d054a917 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -505,8 +505,8 @@ void a_Menu_bugmeter_popup(BrowserWindow *bw, const DilloUrl *url) {"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} - }; + {0,0,0,0,0,0,0,0,0} + }; popup_x = Fl::event_x(); popup_y = Fl::event_y(); @@ -620,7 +620,7 @@ void a_Menu_tools_popup(BrowserWindow *bw, void *v_wid) {"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, + {"Load images", 0, Menu_imgload_toggle_cb, 0, FL_MENU_TOGGLE|FL_MENU_DIVIDER,0,0,0,0}, {"Panel size", 0, 0, (void*)"Submenu1", FL_SUBMENU,0,0,0,0}, {"tiny", 0,Menu_panel_change_cb,(void*)0,FL_MENU_RADIO,0,0,0,0}, diff --git a/src/ui.cc b/src/ui.cc index 5ca58e8e..a8a802fb 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -707,7 +707,7 @@ UI::UI(int x, int y, int ui_w, int ui_h, const char* label, const UI *cur_ui) : // Control panel TopGroup->begin(); make_panel(ui_w); - + // Render area int main_h = ui_h - (mh+(LocBar?lh:0)+nh+fh+sh); Main = new Fl_Group(0,0,0,main_h,"Welcome..."); @@ -721,7 +721,7 @@ UI::UI(int x, int y, int ui_w, int ui_h, const char* label, const UI *cur_ui) : TopGroup->add(Main); TopGroup->resizable(Main); MainIdx = TopGroup->find(Main); - + // Find text bar FindBarSpace = 1; FindBar = new Findbar(ui_w, fh); diff --git a/src/uicmd.cc b/src/uicmd.cc index 02747e48..415f0d3b 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -305,7 +305,7 @@ void CustTabs::set_tab_label(UI *ui, const char *label) { char title[128]; int idx = get_btn_idx(ui); - + if (idx > 0) { // Make a label for this tab size_t tab_chars = 7, label_len = strlen(label); -- cgit v1.2.3 From 43bc67a98263ec6c4a561c3c14dc688b7ee59fca Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Tue, 17 May 2011 13:58:58 -0400 Subject: uicmd.cc: remove an unnecessary static variable --- src/uicmd.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src') diff --git a/src/uicmd.cc b/src/uicmd.cc index 415f0d3b..09c33ce8 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -56,7 +56,6 @@ using namespace dw::fltk; * Local data */ static char *save_dir = NULL; -static UI *Gui; /* * Forward declarations @@ -398,7 +397,7 @@ BrowserWindow *a_UIcmd_browser_window_new(int ww, int wh, int focus = 1; new_bw = UIcmd_tab_new(DilloTabs, old_ui, focus); - win->resizable(Gui); + win->resizable(BW2UI(new_bw)); win->show(); if (old_bw == NULL && prefs.xpos >= 0 && prefs.ypos >= 0) { @@ -421,7 +420,6 @@ static BrowserWindow *UIcmd_tab_new(CustTabs *tabs, UI *old_ui, int focus) // Create and set the UI UI *new_ui = tabs->add_new_tab(old_ui, focus); - Gui = new_ui; // Now create the Dw render layout and viewport FltkPlatform *platform = new FltkPlatform (); -- cgit v1.2.3 From 5bffa87a1d72795ae5c6a7a4778bf6f7323bb953 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Tue, 17 May 2011 18:57:29 -0400 Subject: Made KEYS_LEFT_TAB and KEYS_RIGHT_TAB no longer handled as a special case * Made TAB-key focus the main area from location input. * Made KEYS_LEFT_TAB and KEYS_RIGHT_TAB cycle.. --- src/ui.cc | 12 ++++++++---- src/uicmd.cc | 26 +++++++------------------- 2 files changed, 15 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/ui.cc b/src/ui.cc index a8a802fb..9be4d60b 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -93,8 +93,8 @@ public: }; /* - * Disable keys: Up, Down, Page_Up, Page_Down and - * CTRL+{o,r,Home,End} + * Disable keys: Up, Down, Page_Up, Page_Down, Tab and + * CTRL+{o,r,Home,End} SHIFT+{Left,Right}. */ int CustInput::handle(int e) { @@ -113,7 +113,11 @@ int CustInput::handle(int e) 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 == 'l') { // Make text selected when already focused. @@ -126,7 +130,7 @@ int CustInput::handle(int e) } } else if (modifier == 0) { if (k == FL_Down || k == FL_Up || - k == FL_Page_Down || k == FL_Page_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; diff --git a/src/uicmd.cc b/src/uicmd.cc index 09c33ce8..b403d827 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -149,6 +149,7 @@ int CustTabs::handle(int e) 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; @@ -156,10 +157,10 @@ int CustTabs::handle(int e) a_UIcmd_close_bw(bw); ret = 1; } else if (cmd == KEYS_LEFT_TAB) { - MSG("CustTabs::handle KEYS_LEFT_TAB\n"); + prev_tab(); ret = 1; } else if (cmd == KEYS_RIGHT_TAB) { - MSG("CustTabs::handle KEYS_RIGHT_TAB\n"); + next_tab(); ret = 1; } else if (cmd == KEYS_NEW_WINDOW) { a_UIcmd_open_url_nw(bw, NULL); @@ -171,19 +172,6 @@ int CustTabs::handle(int e) a_Timeout_add(0.0, a_UIcmd_close_all_bw, NULL); ret = 1; } - - } else if (e == FL_KEYUP) { - int k = Fl::event_key(); - // We're only interested in some flags - unsigned modifier = Fl::event_state() & (FL_SHIFT | FL_CTRL | FL_ALT); - if (k == FL_Up || k == FL_Down || k == FL_Tab) { - ; - } else if (k == FL_Left || k == FL_Right) { - if (modifier == FL_SHIFT) { - (k == FL_Left) ? prev_tab() : next_tab(); - ret = 1; - } - } } return (ret) ? ret : CustGroup::handle(e); @@ -285,16 +273,16 @@ void CustTabs::prev_tab() { int idx; - if ((idx = get_btn_idx((UI*)Wizard->value())) > 1) - switch_tab( (CustTabButton*)child(idx-1) ); + if ((idx = get_btn_idx((UI*)Wizard->value())) != -1) + switch_tab( (CustTabButton*)child(idx > 1 ? idx-1 : num_tabs()) ); } void CustTabs::next_tab() { int idx; - if ((idx = get_btn_idx((UI*)Wizard->value())) > 0 && idx < num_tabs()) - switch_tab( (CustTabButton*)child(idx+1) ); + if ((idx = get_btn_idx((UI*)Wizard->value())) != -1) + switch_tab( (CustTabButton*)child(idx < num_tabs() ? idx+1 : 1) ); } /* -- cgit v1.2.3 From 6f569cdca6e2da6bbfb09152cd3006e22b8d2356 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Wed, 18 May 2011 14:05:55 -0400 Subject: Made SHIFT+{Left,Right} keyboard events work from the findbar --- src/findbar.cc | 8 ++++---- src/uicmd.cc | 14 -------------- 2 files changed, 4 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/findbar.cc b/src/findbar.cc index cb0b345b..02f9545b 100644 --- a/src/findbar.cc +++ b/src/findbar.cc @@ -36,10 +36,10 @@ int MyInput::handle(int e) unsigned modifier = Fl::event_state() & (FL_SHIFT| FL_CTRL| FL_ALT|FL_META); if (e == FL_KEYBOARD) { - if (k == FL_Left || k == FL_Right) { - if (modifier == FL_SHIFT) { - a_UIcmd_send_event_to_tabs_by_wid(e, this); - return 1; + if (modifier == FL_SHIFT) { + if (k == FL_Left || k == FL_Right) { + // Let these keys get to the UI + return 0; } } else if (k == FL_Escape && modifier == 0) { // Avoid clearing the text with Esc, just hide the findbar. diff --git a/src/uicmd.cc b/src/uicmd.cc index b403d827..1e58df51 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -340,20 +340,6 @@ BrowserWindow *a_UIcmd_get_bw_by_widget(void *v_wid) return NULL; } -/* - * FLTK regards SHIFT + {Left, 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*. -- cgit v1.2.3 From f4703fee483f6d65736e880e5a0963d9ff598b4d Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Wed, 18 May 2011 14:22:14 -0400 Subject: Bound CTRL+{a,e,d,k} in the location bar (for start,end,del,cut) --- src/ui.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui.cc b/src/ui.cc index 9be4d60b..fa5588da 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -119,7 +119,16 @@ int CustInput::handle(int e) return 0; } } else if (modifier == FL_CTRL) { - if (k == 'l') { + 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; -- cgit v1.2.3 From 6183351c57d1da1d4867e775bce036718f7cd0e1 Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Sat, 21 May 2011 00:02:26 +0200 Subject: fix excessive redraws on pages with bugs --- src/ui.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ui.cc b/src/ui.cc index fa5588da..5762f15d 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -672,7 +672,7 @@ void UI::make_status_bar(int ww, int wh) 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_TEXT_NEXT_TO_IMAGE); + 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); -- cgit v1.2.3 From 00df6fa92c4ca418822f13ceca30fdd2574b3ffb Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Sun, 22 May 2011 10:16:01 -0400 Subject: sync window title with current tab --- src/uicmd.cc | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/uicmd.cc b/src/uicmd.cc index 1e58df51..c95054c6 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -254,6 +254,7 @@ void CustTabs::switch_tab(CustTabButton *cbtn) { int idx; CustTabButton *btn; + BrowserWindow *bw; UI *old_ui = (UI*)Wizard->value(); if (cbtn->ui() != old_ui) { @@ -266,6 +267,12 @@ void CustTabs::switch_tab(CustTabButton *cbtn) 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 = a_History_get_title(NAV_TOP_UIDX(bw), 1); + a_UIcmd_set_page_title(bw, title ? title : ""); + } } } -- cgit v1.2.3 From 82c9bfdf3ca12c1b6619f9ac6a90380811b66a09 Mon Sep 17 00:00:00 2001 From: corvid Date: Wed, 25 May 2011 22:09:26 +0000 Subject: user/password dialog --- src/dialog.cc | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/dialog.cc b/src/dialog.cc index c932118e..35505561 100644 --- a/src/dialog.cc +++ b/src/dialog.cc @@ -222,17 +222,10 @@ int a_Dialog_choice5(const char *QuestionTxt, /*--------------------------------------------------------------------------*/ -/* - * ret: 0 = Cancel, 1 = OK - */ -static void Dialog_user_password_cb(Fl_Widget *button, void *vIntPtr) +static void Dialog_user_password_cb(Fl_Widget *button, void *) { -#if 0 -PORT1.3 - int ret = VOIDP2INT(vIntPtr); - _MSG("Dialog_user_password_cb: %d\n", ret); - button->window()->make_exec_return(ret); -#endif + button->window()->user_data(button); + button->window()->hide(); } /* @@ -249,6 +242,7 @@ int a_Dialog_user_password(const char *message, UserPasswordCB cb, void *vp) Fl_Window *window = new Fl_Window(window_w,window_h,"User/Password"); + window->user_data(NULL); window->begin(); /* message */ @@ -276,21 +270,24 @@ int a_Dialog_user_password(const char *message, UserPasswordCB cb, void *vp) new Fl_Button(200,button_y,50,button_h,"OK"); ok_button->labelsize(14); ok_button->callback(Dialog_user_password_cb); - ok_button->user_data(INT2VOIDP(1)); /* "Cancel" button */ Fl_Button *cancel_button = new Fl_Button(50,button_y,100,button_h,"Cancel"); cancel_button->labelsize(14); cancel_button->callback(Dialog_user_password_cb); - cancel_button->user_data(INT2VOIDP(0)); window->end(); window->size_range(window_w,window_h,window_w,window_h); window->resizable(window); -#if 0 -PORT1.3 - 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(); @@ -298,7 +295,6 @@ PORT1.3 _MSG("a_Dialog_user_passwd: ok = %d\n", ok); (*cb)(user, password, vp); } -#endif delete window; return ok; -- cgit v1.2.3 From 10703178fadb93dc4a30b7c646e00299202ce67b Mon Sep 17 00:00:00 2001 From: corvid Date: Wed, 25 May 2011 22:46:10 +0000 Subject: delete choice5 window --- src/dialog.cc | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/dialog.cc b/src/dialog.cc index 35505561..4368720c 100644 --- a/src/dialog.cc +++ b/src/dialog.cc @@ -216,6 +216,7 @@ int a_Dialog_choice5(const char *QuestionTxt, while (window->shown()) Fl::wait(); _MSG("a_Dialog_choice5 answer = %d\n", choice5_answer); + delete window; return choice5_answer; } -- cgit v1.2.3 From 1538e8a0c25b95c8e9e345cb6ba75dcd66157558 Mon Sep 17 00:00:00 2001 From: corvid Date: Wed, 25 May 2011 23:37:57 +0000 Subject: rm comment --- src/dialog.cc | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/dialog.cc b/src/dialog.cc index 4368720c..a2139106 100644 --- a/src/dialog.cc +++ b/src/dialog.cc @@ -249,7 +249,6 @@ int a_Dialog_user_password(const char *message, UserPasswordCB cb, void *vp) /* message */ Fl_Output *message_output = new Fl_Output(20,20,window_w-40,100); - /* BUG type() not tested */ message_output->type(FL_NORMAL_OUTPUT | FL_INPUT_WRAP); message_output->box(FL_DOWN_BOX); message_output->value(message); -- cgit v1.2.3 From 706a33d7ab12cd2b24f8f8101aaac43bf20f55fb Mon Sep 17 00:00:00 2001 From: corvid Date: Thu, 26 May 2011 02:51:18 +0000 Subject: clickable menu items (even those introducing submenus) MUST have callbacks I clicked on the "Panel size" item itself instead of any of the options in its submenu, and: Segfault! --- src/menu.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/menu.cc b/src/menu.cc index d054a917..3850a423 100644 --- a/src/menu.cc +++ b/src/menu.cc @@ -43,6 +43,10 @@ static int *history_list = NULL; //-------------------------------------------------------------------------- +static void Menu_nop_cb(Fl_Widget *, void *) +{ +} + /* * Static function for File menu callbacks. */ @@ -295,7 +299,8 @@ void a_Menu_page_popup(BrowserWindow *bw, const DilloUrl *url, 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, 0, 0,FL_SUBMENU_POINTER|FL_MENU_DIVIDER,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}, @@ -622,7 +627,7 @@ void a_Menu_tools_popup(BrowserWindow *bw, void *v_wid) 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, 0, (void*)"Submenu1", FL_SUBMENU,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}, -- cgit v1.2.3 From fe3616d054d7a1efc771a57890d9464c16607ce2 Mon Sep 17 00:00:00 2001 From: corvid Date: Thu, 26 May 2011 14:21:52 +0000 Subject: fix compilation warnings reported in http://lists.auriga.wearlab.de/pipermail/dillo-dev/2011-May/008348.html --- src/IO/http.c | 2 +- src/dialog.cc | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/IO/http.c b/src/IO/http.c index 77a1be43..137ff957 100644 --- a/src/IO/http.c +++ b/src/IO/http.c @@ -174,7 +174,7 @@ static void Http_connect_queued_sockets(HostConnection_t *hc) MSG_BW(sd->web, 1, "ERROR: %s", dStrerror(sd->Err)); a_Chain_bfcb(OpAbort, sd->Info, NULL, "Both"); dFree(sd->Info); - Http_socket_free((int) sd->Info->LocalKey); + Http_socket_free(VOIDP2INT(sd->Info->LocalKey)); } else { sd->connected_to = hc->host; hc->active_connections++; diff --git a/src/dialog.cc b/src/dialog.cc index a2139106..0775a1b9 100644 --- a/src/dialog.cc +++ b/src/dialog.cc @@ -174,7 +174,8 @@ int a_Dialog_choice5(const char *QuestionTxt, 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) + ; ww = 140 + nb*(bw+10); Fl_Window *window = new Fl_Window(ww,wh,"Choice5"); -- cgit v1.2.3 From a1fc98c9e52a545f01df80d6844cc4e60217d333 Mon Sep 17 00:00:00 2001 From: corvid Date: Thu, 26 May 2011 15:29:22 +0000 Subject: user/pass dialog appearance --- src/auth.c | 4 ++-- src/dialog.cc | 56 ++++++++++++++++++++++++++++++++++---------------------- 2 files changed, 36 insertions(+), 24 deletions(-) (limited to 'src') 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/dialog.cc b/src/dialog.cc index 0775a1b9..7f2b31c0 100644 --- a/src/dialog.cc +++ b/src/dialog.cc @@ -237,49 +237,61 @@ static void Dialog_user_password_cb(Fl_Widget *button, void *) */ int a_Dialog_user_password(const char *message, UserPasswordCB cb, void *vp) { - int ok = 0, - 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; - Fl_Window *window = - new Fl_Window(window_w,window_h,"User/Password"); + /* 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); - window->begin(); /* message */ - Fl_Output *message_output = - new Fl_Output(20,20,window_w-40,100); - message_output->type(FL_NORMAL_OUTPUT | FL_INPUT_WRAP); - message_output->box(FL_DOWN_BOX); - message_output->value(message); - message_output->textfont(FL_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()); + fl_measure(msg->label(), msg_w, msg_h, 0); /* fl_measure wraps at msg_w */ + msg_w = MIN(msg_w, msg->w()); + msg->size(msg_w, msg_h); + window->add(msg); /* inputs */ - Fl_Input *user_input = - new Fl_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); + window->add(user_input); + y += input_h + 10; Fl_Secret_Input *password_input = - new Fl_Secret_Input(input_x,180,input_w,input_h,"Password"); + 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 */ - Fl_Button *ok_button = - new Fl_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); + window->add(ok_button); /* "Cancel" button */ Fl_Button *cancel_button = - new Fl_Button(50,button_y,100,button_h,"Cancel"); + new Fl_Button(50, y, 100, button_h, "Cancel"); cancel_button->labelsize(14); cancel_button->callback(Dialog_user_password_cb); + 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); window->show(); -- cgit v1.2.3 From f8e218199b36a728ee7523e8e6a20d088f1befbb Mon Sep 17 00:00:00 2001 From: Johannes Hofmann Date: Thu, 26 May 2011 21:12:33 +0200 Subject: remove use of Fl_Pack to avoid resizing issues CustGroup is split into CustGroupHorizontal and CustGroupVertical. CustGroupVertical is then used to replace Fl_Pack for TopGroup. --- src/ui.cc | 43 ++++++++++++------------ src/ui.hh | 108 ++++++++++++++++++++++++++--------------------------------- src/uicmd.cc | 6 ++-- 3 files changed, 72 insertions(+), 85 deletions(-) (limited to 'src') diff --git a/src/ui.cc b/src/ui.cc index 5762f15d..1004bfdc 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -535,7 +535,7 @@ Fl_Widget *UI::make_filemenu_button() Fl_Button *btn; int w = 0, h = 0, padding; - FileButton = btn = new Fl_Button(p_xpos,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; @@ -595,7 +595,7 @@ void UI::make_panel(int ww) current(0); if (PanelSize == P_tiny) { - NavBar = new CustGroup(0,0,ww,nh); + NavBar = new CustGroupHorizontal(0,0,ww,nh); NavBar->begin(); make_toolbar(ww,bh); make_filemenu_button(); @@ -604,38 +604,42 @@ void UI::make_panel(int ww) make_progress_bars(0,1); NavBar->box(FL_THIN_UP_FRAME); NavBar->end(); + NavBar->rearrange(); TopGroup->insert(*NavBar,0); } else { if (PanelSize == P_large) { - MenuBar = new CustGroup(0,0,ww,mh); + 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 CustGroup(0,0,ww,lh); + 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 CustGroup(0,0,ww,lh); + LocBar = new CustGroupHorizontal(0,0,ww,lh); LocBar->begin(); p_xpos = 0; make_filemenu_button(); make_location(ww); LocBar->resizable(Location); LocBar->end(); + LocBar->rearrange(); TopGroup->insert(*LocBar,0); } // Toolbar p_ypos = 0; - NavBar = new CustGroup(0,0,ww,bh); + NavBar = new CustGroupHorizontal(0,0,ww,bh); NavBar->begin(); make_toolbar(ww,bh); w = new Fl_Box(p_xpos,0,ww-p_xpos-2*pw,bh); @@ -648,6 +652,7 @@ void UI::make_panel(int ww) make_progress_bars(1,0); } NavBar->end(); + NavBar->rearrange(); TopGroup->insert(*NavBar,(MenuBar ? 2 : 1)); } } @@ -658,7 +663,7 @@ void UI::make_panel(int ww) void UI::make_status_bar(int ww, int wh) { const int bm_w = 20; - StatusBar = new CustGroup(0, wh-sh, ww, sh); + StatusBar = new CustGroupHorizontal(0, wh-sh, ww, sh); // Status box StatusOutput = new Fl_Output(0, wh-sh, ww-bm_w, sh); @@ -680,13 +685,14 @@ void UI::make_status_bar(int ww, int wh) StatusBar->end(); StatusBar->resizable(StatusOutput); + StatusBar->rearrange(); } /* * User Interface constructor */ UI::UI(int x, int y, int ui_w, int ui_h, const char* label, const UI *cur_ui) : - Fl_Pack(x, y, ui_w, ui_h, label) + CustGroupVertical(x, y, ui_w, ui_h, label) { PointerOnLink = FALSE; @@ -695,7 +701,6 @@ UI::UI(int x, int y, int ui_w, int ui_h, const char* label, const UI *cur_ui) : Tabs = NULL; TabTooltip = NULL; TopGroup = this; - TopGroup->type(VERTICAL); TopGroup->box(FL_NO_BOX); clear_flag(SHORTCUT_LABEL); @@ -722,8 +727,7 @@ UI::UI(int x, int y, int ui_w, int ui_h, const char* label, const UI *cur_ui) : make_panel(ui_w); // Render area - int main_h = ui_h - (mh+(LocBar?lh:0)+nh+fh+sh); - Main = new Fl_Group(0,0,0,main_h,"Welcome..."); + 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); @@ -743,8 +747,8 @@ UI::UI(int x, int y, int ui_w, int ui_h, const char* label, const UI *cur_ui) : // 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 @@ -1049,11 +1053,7 @@ void UI::change_panel(int new_size, int small_icons) customize(0); a_UIcmd_set_buttons_sens(a_UIcmd_get_bw_by_widget(this)); - // adjust Main's height - int main_h = h() - (mh+(LocBar?lh:0)+nh+(FindBarSpace?fh:0)+sh); - Main->size(Main->w(), main_h); - redraw(); - + TopGroup->rearrange(); Location->take_focus(); } @@ -1086,6 +1086,7 @@ void UI::set_panelmode(UIPanelmode mode) StatusBar->show(); } Panelmode = mode; + TopGroup->rearrange(); } /* @@ -1110,7 +1111,7 @@ void UI::panelmode_cb_i() void UI::set_render_layout(Fl_Group *nw) { // Resize layout widget to current height - nw->resize(0,0,0,Main->h()); + nw->resize(0,Main->y(),Main->w(),Main->h()); TopGroup->insert(*nw, Main); remove(Main); @@ -1169,7 +1170,6 @@ void UI::findbar_toggle(bool add) insert(*FindBar, StatusBar); FindBar->show(); FindBarSpace = 1; - redraw(); } else { // select text FindBar->show(); @@ -1179,8 +1179,8 @@ void UI::findbar_toggle(bool add) Main->size(Main->w(), Main->h()+FindBar->h()); remove(FindBar); FindBarSpace = 0; - redraw(); /* Main->redraw(); is not enough */ } + TopGroup->rearrange(); } /* @@ -1217,6 +1217,5 @@ void UI::fullscreen_toggle() hide ? StatusBar->hide() : StatusBar->show();; } - Main->size(Main->w(), Main->h() + (hide ? dh : -dh)); - redraw(); + TopGroup->rearrange(); } diff --git a/src/ui.hh b/src/ui.hh index b42b2ab6..7865d9e9 100644 --- a/src/ui.hh +++ b/src/ui.hh @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include @@ -40,72 +39,62 @@ class CustTabs; // Class definition ---------------------------------------------------------- /* - * Used to reposition group's widgets when some of them are hidden + * 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 CustGroup : public Fl_Group { +class CustGroupHorizontal : public Fl_Group { public: - CustGroup(int x,int y,int w ,int h,const char *l = 0) : + CustGroupHorizontal(int x,int y,int w ,int h,const char *l = 0) : Fl_Group(x,y,w,h,l) { }; - void rearrange(void) { - int n = children(), xpos = 0, r_x1, r_i = -1, i; - init_sizes(); - for (i = 0; i < n; ++i) { - if (child(i) == resizable()) { - r_i = i; - r_x1 = xpos; - break; - } - if (child(i)->visible()) { - child(i)->position(xpos, child(i)->y()); - xpos += child(i)->w(); - } - } - if (r_i < 0) - return; - xpos = w(); - for (i = n - 1; i > r_i; --i) { - if (child(i)->visible()) { - xpos -= child(i)->w(); - child(i)->position(xpos, child(i)->y()); + 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(); } - child(r_i)->resize(r_x1, child(r_i)->y(), xpos-r_x1, child(r_i)->h()); + init_sizes(); redraw(); } - void rearrange_y(void) { - int n = children(), pos = 0, r_pos, r_i = -1, i; +}; - printf("children = %d\n", n); - init_sizes(); - for (i = 0; i < n; ++i) { - if (child(i) == resizable()) { - r_i = i; - r_pos = pos; - break; - } - if (child(i)->visible()) { - printf("child[%d] x=%d y=%d w=%d h=%d\n", - i, child(i)->x(), pos, child(i)->w(), child(i)->h()); - child(i)->position(child(i)->x(), pos); - pos += child(i)->h(); - } - } - if (r_i < 0) - return; - pos = h(); - for (i = n - 1; i > r_i; --i) { - if (child(i)->visible()) { - pos -= child(i)->h(); - printf("child[%d] x=%d y=%d w=%d h=%d\n", - i, child(i)->x(), pos, child(i)->w(), child(i)->h()); - child(i)->position(child(i)->x(), pos); +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(); } - child(r_i)->resize(child(r_i)->x(), r_pos, child(r_i)->w(), pos-r_pos); - printf("resizable child[%d] x=%d y=%d w=%d h=%d\n", - r_i, child(r_i)->x(), r_pos, child(r_i)->w(), child(r_i)->h()); - child(r_i)->hide(); + init_sizes(); redraw(); } }; @@ -114,16 +103,15 @@ public: // // UI class definition ------------------------------------------------------- // -class UI : public Fl_Pack { +class UI : public CustGroupVertical { CustTabs *Tabs; char *TabTooltip; - Fl_Group *TopGroup; + CustGroupVertical *TopGroup; Fl_Button *Back, *Forw, *Home, *Reload, *Save, *Stop, *Bookmarks, *Tools, *Clear, *Search, *Help, *FullScreen, *BugMeter, *FileButton; - CustGroup *MenuBar, *LocBar, *NavBar, *StatusBar; + CustGroupHorizontal *MenuBar, *LocBar, *NavBar, *StatusBar; Fl_Input *Location; - Fl_Pack *ProgBox; CustProgressBox *PProg, *IProg; Fl_Group *Panel, *Main; Fl_Output *StatusOutput; diff --git a/src/uicmd.cc b/src/uicmd.cc index c95054c6..a28128c8 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -83,13 +83,13 @@ public: /* * Allows fine control of the tabbed interface */ -class CustTabs : public CustGroup { +class CustTabs : public CustGroupHorizontal { int tab_w, tab_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) : - CustGroup(0,0,ww,th,lbl) { + CustGroupHorizontal(0,0,ww,th,lbl) { tab_w = 80, tab_h = th, tab_n = 0, curtab_idx = -1; tabcolor_active = FL_DARK_CYAN; tabcolor_inactive = 206; Fl_Box *w = new Fl_Box(0,0,0,0,"i n v i s i b l e"); @@ -174,7 +174,7 @@ int CustTabs::handle(int e) } } - return (ret) ? ret : CustGroup::handle(e); + return (ret) ? ret : CustGroupHorizontal::handle(e); } /* -- cgit v1.2.3 From b0357cf1928e75b4128e6d4366897fc75449a28b Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Thu, 26 May 2011 19:21:15 -0400 Subject: Cleanups and bugfix for closing an unselected tab * Removed the invisible widget from the tabbar * Fixed closing the first tab when not selected * Removed a workaround (not necessary anymore) --- src/uicmd.cc | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/uicmd.cc b/src/uicmd.cc index a28128c8..575fa082 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -92,9 +92,7 @@ public: CustGroupHorizontal(0,0,ww,th,lbl) { tab_w = 80, tab_h = th, tab_n = 0, curtab_idx = -1; tabcolor_active = FL_DARK_CYAN; tabcolor_inactive = 206; - Fl_Box *w = new Fl_Box(0,0,0,0,"i n v i s i b l e"); - w->box(FL_NO_BOX); - resizable(0); + resizable(NULL); box(FL_FLAT_BOX); end(); @@ -106,7 +104,7 @@ public: void remove_tab(UI *ui); Fl_Wizard *wizard(void) { return Wizard; } int get_btn_idx(UI *ui); - int num_tabs() { return (children() - 1); } // substract invisible box + int num_tabs() { return children(); } void switch_tab(CustTabButton *cbtn); void prev_tab(void); void next_tab(void); @@ -199,7 +197,6 @@ UI *CustTabs::add_new_tab(UI *old_ui, int focus) btn->color(focus ? tabcolor_active : tabcolor_inactive); btn->ui(new_ui); add(btn); - btn->redraw(); btn->callback(tab_btn_cb, this); if (focus) @@ -216,19 +213,19 @@ void CustTabs::remove_tab(UI *ui) { CustTabButton *btn; - // remove label button - int idx = get_btn_idx(ui); - btn = (CustTabButton*)child(idx); - idx > 1 ? prev_tab() : next_tab(); - - // WORKAROUND: with two tabs, closing the non-focused one, doesn't - // delete it from screen. This hide() call makes it work. --Jcid - btn->hide(); + // 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); - remove(idx); + 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(); - redraw(); Wizard->remove(ui); delete(ui); @@ -242,7 +239,7 @@ void CustTabs::remove_tab(UI *ui) int CustTabs::get_btn_idx(UI *ui) { - for (int i = 1; i <= num_tabs(); ++i) { + for (int i = 0; i < num_tabs(); ++i) { CustTabButton *btn = (CustTabButton*)child(i); if (btn->ui() == ui) return i; @@ -250,6 +247,9 @@ int CustTabs::get_btn_idx(UI *ui) return -1; } +/* + * Make cbtn's tab the active one + */ void CustTabs::switch_tab(CustTabButton *cbtn) { int idx; @@ -259,7 +259,7 @@ void CustTabs::switch_tab(CustTabButton *cbtn) if (cbtn->ui() != old_ui) { // Set old tab label to normal color - if ((idx = get_btn_idx(old_ui)) > 0) { + if ((idx = get_btn_idx(old_ui)) != -1) { btn = (CustTabButton*)child(idx); btn->color(tabcolor_inactive); btn->redraw(); @@ -281,7 +281,7 @@ void CustTabs::prev_tab() int idx; if ((idx = get_btn_idx((UI*)Wizard->value())) != -1) - switch_tab( (CustTabButton*)child(idx > 1 ? idx-1 : num_tabs()) ); + switch_tab( (CustTabButton*)child(idx > 0 ? idx-1 : num_tabs()-1) ); } void CustTabs::next_tab() @@ -289,7 +289,7 @@ void CustTabs::next_tab() int idx; if ((idx = get_btn_idx((UI*)Wizard->value())) != -1) - switch_tab( (CustTabButton*)child(idx < num_tabs() ? idx+1 : 1) ); + switch_tab( (CustTabButton*)child((idx+1 < num_tabs()) ? idx+1 : 0) ); } /* @@ -300,7 +300,7 @@ void CustTabs::set_tab_label(UI *ui, const char *label) char title[128]; int idx = get_btn_idx(ui); - if (idx > 0) { + if (idx != -1) { // Make a label for this tab size_t tab_chars = 7, label_len = strlen(label); -- cgit v1.2.3 From a5e0529ddbbebe32ca3a652e53926389fbd00379 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Fri, 27 May 2011 09:47:48 -0400 Subject: Hide tabbar when (tabs == 1), show tabbar when (tabs >= 2) --- src/uicmd.cc | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/uicmd.cc b/src/uicmd.cc index 575fa082..275b059f 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -84,19 +84,20 @@ public: * Allows fine control of the tabbed interface */ class CustTabs : public CustGroupHorizontal { - int tab_w, tab_h, tab_n; + 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, tab_n = 0, curtab_idx = -1; + 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,tab_h,ww,wh-tab_h); + Wizard = new Fl_Wizard(0,ctab_h,ww,wh-ctab_h); Wizard->end(); }; int handle(int e); @@ -182,14 +183,23 @@ UI *CustTabs::add_new_tab(UI *old_ui, int focus) { char tab_label[64]; + 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(); + } + current(0); - UI *new_ui = new UI(0,tab_h,Wizard->w(),Wizard->h(),0,old_ui); + 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,tab_h); + 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(); @@ -201,6 +211,8 @@ UI *CustTabs::add_new_tab(UI *old_ui, int focus) if (focus) switch_tab(btn); + if (num_tabs() == 1) + btn->hide(); rearrange(); return new_ui; @@ -234,6 +246,15 @@ void CustTabs::remove_tab(UI *ui) 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(); } } -- cgit v1.2.3 From 57b8dfc2cce6d65927d11fbc15667b5a410fb3de Mon Sep 17 00:00:00 2001 From: corvid Date: Fri, 27 May 2011 15:20:08 +0000 Subject: rm fltk2 workaround Haven't found any need for it with 1.3. --- dw/fltkui.cc | 11 +---------- src/ui.cc | 9 ++------- 2 files changed, 3 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/dw/fltkui.cc b/dw/fltkui.cc index f3192c22..62928ed4 100644 --- a/dw/fltkui.cc +++ b/dw/fltkui.cc @@ -513,16 +513,7 @@ void FltkEntryResource::sizeRequest (core::Requisition *requisition) void FltkEntryResource::widgetCallback (Fl_Widget *widget, void *data) { - /* The (::fltk::event_key() == FL_Enter) 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 - */ - _MSG("when = %d\n", widget->when ()); - if ((widget->when () & FL_WHEN_ENTER_KEY_ALWAYS) && - (Fl::event_key() == FL_Enter)) - ((FltkEntryResource*)data)->emitActivate (); + ((FltkEntryResource*)data)->emitActivate (); } const char *FltkEntryResource::getText () diff --git a/src/ui.cc b/src/ui.cc index 1004bfdc..30106c21 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -320,13 +320,8 @@ static void location_cb(Fl_Widget *wid, void *data) 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 (Fl::event_key() == FL_Enter) { - 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); } -- cgit v1.2.3 From 9b72578eab16832c7bf70984fb528339a3994e32 Mon Sep 17 00:00:00 2001 From: Jorge Arellano Cid Date: Fri, 27 May 2011 13:26:15 -0400 Subject: Avoid unnecessary background redraws --- src/ui.cc | 4 ++++ src/uicmd.cc | 2 ++ 2 files changed, 6 insertions(+) (limited to 'src') diff --git a/src/ui.cc b/src/ui.cc index 30106c21..6fc769c8 100644 --- a/src/ui.cc +++ b/src/ui.cc @@ -591,6 +591,7 @@ void UI::make_panel(int ww) current(0); if (PanelSize == P_tiny) { NavBar = new CustGroupHorizontal(0,0,ww,nh); + NavBar->box(FL_NO_BOX); NavBar->begin(); make_toolbar(ww,bh); make_filemenu_button(); @@ -622,6 +623,7 @@ void UI::make_panel(int ww) 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(); @@ -635,6 +637,7 @@ void UI::make_panel(int ww) // Toolbar 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); @@ -659,6 +662,7 @@ void UI::make_status_bar(int ww, int wh) { 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); diff --git a/src/uicmd.cc b/src/uicmd.cc index 275b059f..68550e41 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -98,6 +98,7 @@ public: end(); Wizard = new Fl_Wizard(0,ctab_h,ww,wh-ctab_h); + Wizard->box(FL_NO_BOX); Wizard->end(); }; int handle(int e); @@ -431,6 +432,7 @@ static BrowserWindow *UIcmd_tab_new(CustTabs *tabs, UI *old_ui, int focus) // 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); layout->attachView (viewport); new_ui->set_render_layout(viewport); -- cgit v1.2.3 From a7b232cd79762bd097ac527dbd60dd51d1f56b02 Mon Sep 17 00:00:00 2001 From: corvid Date: Fri, 27 May 2011 19:50:33 +0000 Subject: move the disabling of prefs.limit_text_width --- src/prefsparser.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/prefsparser.cc b/src/prefsparser.cc index 7d0582cd..9d245706 100644 --- a/src/prefsparser.cc +++ b/src/prefsparser.cc @@ -171,13 +171,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