changeset 2061:012f9f3a05f8

merge
author Johannes Hofmann <Johannes.Hofmann@gmx.de>
date Thu, 01 Jan 1970 01:05:39 +0100
parents a91ca614763a (current diff) b24e8b62bef3 (diff)
children d03d62c2ed36
files
diffstat 7 files changed, 64 insertions(+), 48 deletions(-) [+]
line wrap: on
line diff
--- a/dw/fltkplatform.cc	Thu May 26 21:20:32 2011 +0200
+++ b/dw/fltkplatform.cc	Thu Jan 01 01:05:39 1970 +0100
@@ -42,7 +42,8 @@
                                     FltkFont> (false, false);
 
 container::typed::HashTable <lout::object::ConstString,
-                             FltkFont::FontFamily> *FltkFont::systemFonts = NULL;
+                             FltkFont::FontFamily> *FltkFont::systemFonts =
+                             NULL;
 
 FltkFont::FontFamily FltkFont::standardFontFamily;
 
--- a/dw/fltkui.cc	Thu May 26 21:20:32 2011 +0200
+++ b/dw/fltkui.cc	Thu Jan 01 01:05:39 1970 +0100
@@ -513,16 +513,7 @@
 
 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 ()
--- a/dw/fltkui.hh	Thu May 26 21:20:32 2011 +0200
+++ b/dw/fltkui.hh	Thu Jan 01 01:05:39 1970 +0100
@@ -402,7 +402,8 @@
    public:
       Group (FltkRadioButtonResource *radioButtonResource);
 
-      inline lout::container::typed::Iterator <FltkRadioButtonResource> iterator ()
+      inline lout::container::typed::Iterator <FltkRadioButtonResource>
+                                              iterator ()
       {
          return list->iterator ();
       }
--- a/dw/image.cc	Thu May 26 21:20:32 2011 +0200
+++ b/dw/image.cc	Thu Jan 01 01:05:39 1970 +0100
@@ -315,8 +315,8 @@
 {
    bool ret = false;
 
-   currLink = mapList? mapList->link (mapKey, contentX(event),contentY(event)):
-              getStyle()->x_link;
+   currLink = mapList ? mapList->link(mapKey,contentX(event),contentY(event)) :
+      getStyle()->x_link;
    if (event->button == 3){
       (void)layout->emitLinkPress(this, currLink, getStyle()->x_img, -1, -1,
                                   event);
@@ -330,7 +330,7 @@
 
 bool Image::buttonReleaseImpl (core::EventButton *event)
 {
-   currLink = mapList ? mapList->link (mapKey, contentX(event),contentY(event)):
+   currLink = mapList ? mapList->link(mapKey,contentX(event),contentY(event)) :
       getStyle()->x_link;
    if (clicking) {
       int x = isMap ? contentX(event) : -1;
--- a/dw/layout.hh	Thu May 26 21:20:32 2011 +0200
+++ b/dw/layout.hh	Thu Jan 01 01:05:39 1970 +0100
@@ -152,7 +152,8 @@
    bool scrollIdleNotInterrupted;
 
    /* Anchors of the widget tree */
-   lout::container::typed::HashTable <lout::object::String, Anchor> *anchorsTable;
+   lout::container::typed::HashTable <lout::object::String, Anchor>
+                                     *anchorsTable;
 
    SelectionState selectionState;
    FindtextState findtextState;
--- a/src/ui.cc	Thu May 26 21:20:32 2011 +0200
+++ b/src/ui.cc	Thu Jan 01 01:05:39 1970 +0100
@@ -320,13 +320,8 @@
    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);
    }
@@ -596,6 +591,7 @@
    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();
@@ -627,6 +623,7 @@
           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();
@@ -640,6 +637,7 @@
        // 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);
@@ -664,6 +662,7 @@
 {
    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);
--- a/src/uicmd.cc	Thu May 26 21:20:32 2011 +0200
+++ b/src/uicmd.cc	Thu Jan 01 01:05:39 1970 +0100
@@ -84,21 +84,21 @@
  * 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;
-      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);
+      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->box(FL_NO_BOX);
       Wizard->end();
    };
    int handle(int e);
@@ -106,7 +106,7 @@
    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);
@@ -184,14 +184,23 @@
 {
    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();
@@ -199,11 +208,12 @@
    btn->color(focus ? tabcolor_active : tabcolor_inactive);
    btn->ui(new_ui);
    add(btn);
-   btn->redraw();
    btn->callback(tab_btn_cb, this);
 
    if (focus)
       switch_tab(btn);
+   if (num_tabs() == 1)
+      btn->hide();
    rearrange();
 
    return new_ui;
@@ -216,19 +226,19 @@
 {
    CustTabButton *btn;
 
-   // remove label button
-   int idx = get_btn_idx(ui);
-   btn = (CustTabButton*)child(idx);
-   idx > 1 ? prev_tab() : next_tab();
+   // 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);
 
-   // 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);
+   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);
@@ -237,12 +247,21 @@
       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();
    }
 }
 
 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 +269,9 @@
    return -1;
 }
 
+/*
+ * Make cbtn's tab the active one
+ */
 void CustTabs::switch_tab(CustTabButton *cbtn)
 {
    int idx;
@@ -259,7 +281,7 @@
 
    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 +303,7 @@
    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 +311,7 @@
    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 +322,7 @@
    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);
 
@@ -410,6 +432,7 @@
 
    // 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);