[Libreoffice-commits] .: Branch 'feature/layout' - 3 commits - sw/source

Ricardo Cruz rpmcruz at kemper.freedesktop.org
Fri Dec 17 19:24:31 PST 2010


 sw/source/ui/dialog/wordcountdialog.cxx |   95 ++++++++++++++++++++++++--------
 1 file changed, 72 insertions(+), 23 deletions(-)

New commits:
commit 9002212d5d8bc5afca1fda4119274ee76e996aa2
Author: Ricardo Cruz <rpmcruz at alunos.dcc.fc.up.pt>
Date:   Sat Dec 18 03:23:55 2010 +0000

    Implemented ButtonBox: needs to be read plataform defaults next

diff --git a/sw/source/ui/dialog/wordcountdialog.cxx b/sw/source/ui/dialog/wordcountdialog.cxx
index daacb6e..e90f6d4 100644
--- a/sw/source/ui/dialog/wordcountdialog.cxx
+++ b/sw/source/ui/dialog/wordcountdialog.cxx
@@ -86,6 +86,7 @@ SwWordCountDialog::SwWordCountDialog(Window* pParent) :
 #include <vcl/box.hxx>
 #include <vcl/table.hxx>
 #include <vcl/notebook.hxx>
+#include <vcl/buttonbox.hxx>
 
 SwWordCountDialog::SwWordCountDialog (Window* parent) :
     LDialog(parent)
@@ -119,8 +120,8 @@ SwWordCountDialog::SwWordCountDialog (Window* parent) :
     // create layout
 
     Notebook *notebook = new Notebook (this);
-    Table *table = new Table (2);
     for (int page = 0; page < 2; page++) {
+#if 1  // 0: use a Table container, 1: use Box containers
         VBox *labels_box = new VBox (false, 6);
         VBox *counts_box = new VBox (false, 6);
 
@@ -148,27 +149,77 @@ SwWordCountDialog::SwWordCountDialog (Window* parent) :
                 break;
         }
 
+        // FIXME: HBox may not be behaving correctly when expand=false for
+        // counts_box.
+        // Or it could be FixedInfo not returning a sufficient req-size. (Try
+        // using another widgets in place of one of those.)
+
         Box *cols = new HBox (false, 6);
-        // FIXME: expand should be false ...
         cols->Pack (labels_box, true, true);
         cols->Pack (counts_box, true, true);
 
         notebook->AddPage (str, cols);
+#else
+        // FIXME: Table isn't work that well:
+        // * Children that use colExpand='false' aren't being shown:
+        //   contrast the two tabs (one of them sets false one of the columns.
+        // * SetSpacing() seems to be ignored.
+        // * Table methods use (row, col) order when (row, col) is
+        //   probably more intuitive given that (row, col) refer to
+        //   (Y, X) respectively.
+        // * PackChild() use first-in first-served order, complemented with
+        //   col-span and row-span: we may want to follow gtk style here, and
+        //   instead have the user indicate (left-col, right-col, top-row,
+        //   bottom-row), which would provide some more flexible for the user
+        //   to insert a widget out of order in the Editor, or while running.
+
+        Table *table = new Table (2);
+        table->SetSpacings (6, 6);
+
+        String str;
+        switch (page) {
+            case 0:
+                str = String::CreateFromAscii ("Whole Document");
+                table->PackChild (aDocWordFT, 1, 1, false, true);
+                table->PackChild (aDocWordFI, 1, 1, false, true);
+
+                table->PackChild (aDocCharacterFT, 1, 1, false, true);
+                table->PackChild (aDocCharacterFI, 1, 1, false, true);
+
+                table->PackChild (aDocCharacterExcludingSpacesFT, 1, 1, false, true);
+                table->PackChild (aDocCharacterExcludingSpacesFI, 1, 1, false, true);
+                break;
+            case 1:
+                str = String::CreateFromAscii ("Selected Text");
+                table->PackChild (aCurrentWordFT, 1, 1, false, true);
+                table->PackChild (aCurrentWordFI, 1, 1, false, false);
+
+                table->PackChild (aCurrentCharacterFT, 1, 1, false, true);
+                table->PackChild (aCurrentCharacterFI, 1, 1, false, false);
+
+                table->PackChild (aCurrentCharacterExcludingSpacesFT, 1, 1, false, true);
+                table->PackChild (aCurrentCharacterExcludingSpacesFI, 1, 1, false, false);
+                break;
+        }
+
+        notebook->AddPage (str, table);
+#endif
     }
 
-    Box *buttons_box = new HBox (true, 6);
+    ButtonBox *bbox = new ButtonBox();
     aHelp = new HelpButton (this);
     aOK = new OKButton (this);
+    PushButton *refreshButton = new PushButton (this);
+    refreshButton->SetText (String::CreateFromAscii ("Refresh"));
 
-    buttons_box->Pack (aHelp, false, true);
-    buttons_box->Pack (aOK, false, true);
+    bbox->Pack (aHelp, HELP_BUTTON);
+    bbox->Pack (aOK, OK_BUTTON);
+    bbox->Pack (refreshButton, CUSTOM_BUTTON);
 
     Box *vbox = new VBox (false, 12);
     vbox->SetBorderWidth (6);
     vbox->Pack (notebook, notebook, true, true);
-    vbox->Pack (buttons_box, false, true);
-
-//Layout::ShowAll (buttons_box);
+    vbox->Pack (bbox, false, true);
 
     SetText (String::CreateFromAscii ("Word Count"));
     AddChild (vbox);
commit b8386df6494d076d273df14f180785aa7c48934e
Author: Ricardo Cruz <rpmcruz at alunos.dcc.fc.up.pt>
Date:   Fri Dec 17 23:55:46 2010 +0000

    Fixed Notebook

diff --git a/sw/source/ui/dialog/wordcountdialog.cxx b/sw/source/ui/dialog/wordcountdialog.cxx
index 5cceb2c..daacb6e 100644
--- a/sw/source/ui/dialog/wordcountdialog.cxx
+++ b/sw/source/ui/dialog/wordcountdialog.cxx
@@ -116,10 +116,10 @@ SwWordCountDialog::SwWordCountDialog (Window* parent) :
     aDocCharacterExcludingSpacesFT->SetText (String::CreateFromAscii ("Characters excluding spaces:"));
     aDocCharacterExcludingSpacesFI = new FixedInfo (this);
 
-#if 1
     // create layout
 
     Notebook *notebook = new Notebook (this);
+    Table *table = new Table (2);
     for (int page = 0; page < 2; page++) {
         VBox *labels_box = new VBox (false, 6);
         VBox *counts_box = new VBox (false, 6);
@@ -128,16 +128,6 @@ SwWordCountDialog::SwWordCountDialog (Window* parent) :
         switch (page) {
             case 0:
                 str = String::CreateFromAscii ("Whole Document");
-                labels_box->Pack (aCurrentWordFT, false, true);
-                labels_box->Pack (aCurrentCharacterFT, false, true);
-                labels_box->Pack (aCurrentCharacterExcludingSpacesFT, false, true);
-
-                counts_box->Pack (aCurrentWordFI, false, true);
-                counts_box->Pack (aCurrentCharacterFI, false, true);
-                counts_box->Pack (aCurrentCharacterExcludingSpacesFI, false, true);
-                break;
-            case 1:
-                str = String::CreateFromAscii ("Selected Text");
                 labels_box->Pack (aDocWordFT, false, true);
                 labels_box->Pack (aDocCharacterFT, false, true);
                 labels_box->Pack (aDocCharacterExcludingSpacesFT, false, true);
@@ -146,6 +136,16 @@ SwWordCountDialog::SwWordCountDialog (Window* parent) :
                 counts_box->Pack (aDocCharacterFI, false, true);
                 counts_box->Pack (aDocCharacterExcludingSpacesFI, false, true);
                 break;
+            case 1:
+                str = String::CreateFromAscii ("Selected Text");
+                labels_box->Pack (aCurrentWordFT, false, true);
+                labels_box->Pack (aCurrentCharacterFT, false, true);
+                labels_box->Pack (aCurrentCharacterExcludingSpacesFT, false, true);
+
+                counts_box->Pack (aCurrentWordFI, false, true);
+                counts_box->Pack (aCurrentCharacterFI, false, true);
+                counts_box->Pack (aCurrentCharacterExcludingSpacesFI, false, true);
+                break;
         }
 
         Box *cols = new HBox (false, 6);
@@ -156,29 +156,23 @@ SwWordCountDialog::SwWordCountDialog (Window* parent) :
         notebook->AddPage (str, cols);
     }
 
-    PushButton *button = new PushButton (this);
-    button->SetText (String::CreateFromAscii ("Hello !"));
-    notebook->AddPage (String::CreateFromAscii ("Test Tab"), button);
-
     Box *buttons_box = new HBox (true, 6);
     aHelp = new HelpButton (this);
     aOK = new OKButton (this);
+
     buttons_box->Pack (aHelp, false, true);
-    buttons_box->Pack (aOK, true, true);
+    buttons_box->Pack (aOK, false, true);
 
     Box *vbox = new VBox (false, 12);
     vbox->SetBorderWidth (6);
     vbox->Pack (notebook, notebook, true, true);
     vbox->Pack (buttons_box, false, true);
 
-fprintf (stderr, "wc: set title\n");
+//Layout::ShowAll (buttons_box);
+
     SetText (String::CreateFromAscii ("Word Count"));
-fprintf (stderr, "wc: add child\n");
     AddChild (vbox);
-fprintf (stderr, "wc: show all\n");
     Layout::ShowAll (this);
-fprintf (stderr, "wc: done\n");
-#endif
 
 //    FreeResource();
 }
commit 60c61256c149d6eb96037eece061c1e62893afc5
Author: Ricardo Cruz <rpmcruz at alunos.dcc.fc.up.pt>
Date:   Fri Dec 17 18:58:30 2010 +0000

    Fixed glitches/crash from the Layout introduction.

diff --git a/sw/source/ui/dialog/wordcountdialog.cxx b/sw/source/ui/dialog/wordcountdialog.cxx
index 1d022c6..5cceb2c 100644
--- a/sw/source/ui/dialog/wordcountdialog.cxx
+++ b/sw/source/ui/dialog/wordcountdialog.cxx
@@ -156,7 +156,7 @@ SwWordCountDialog::SwWordCountDialog (Window* parent) :
         notebook->AddPage (str, cols);
     }
 
-    Button *button = new Button (this);
+    PushButton *button = new PushButton (this);
     button->SetText (String::CreateFromAscii ("Hello !"));
     notebook->AddPage (String::CreateFromAscii ("Test Tab"), button);
 
@@ -171,9 +171,13 @@ SwWordCountDialog::SwWordCountDialog (Window* parent) :
     vbox->Pack (notebook, notebook, true, true);
     vbox->Pack (buttons_box, false, true);
 
-    ::Layout::ShowAll (vbox);
+fprintf (stderr, "wc: set title\n");
     SetText (String::CreateFromAscii ("Word Count"));
-//    vbox->SetPosSizePixel (0, 0, width, height, WINDOW_POSSIZE_ALL);
+fprintf (stderr, "wc: add child\n");
+    AddChild (vbox);
+fprintf (stderr, "wc: show all\n");
+    Layout::ShowAll (this);
+fprintf (stderr, "wc: done\n");
 #endif
 
 //    FreeResource();


More information about the Libreoffice-commits mailing list