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

Ricardo Cruz rpmcruz at kemper.freedesktop.org
Thu Dec 16 09:18:29 PST 2010


 sw/source/ui/dialog/wordcountdialog.cxx |  110 ++++++++++++++++++++++++++++++--
 sw/source/ui/inc/wordcountdialog.hxx    |   37 +++++-----
 2 files changed, 123 insertions(+), 24 deletions(-)

New commits:
commit 23fc1e639c77a517c21d44a8fc24d04670a0a3de
Author: Ricardo Cruz <rpmcruz at alunos.dcc.fc.up.pt>
Date:   Thu Dec 16 17:17:44 2010 +0000

    Word count dialog: use vcl layout code.

diff --git a/sw/source/ui/dialog/wordcountdialog.cxx b/sw/source/ui/dialog/wordcountdialog.cxx
index 808e169..1d022c6 100644
--- a/sw/source/ui/dialog/wordcountdialog.cxx
+++ b/sw/source/ui/dialog/wordcountdialog.cxx
@@ -39,6 +39,7 @@
 #include <layout/layout-pre.hxx>
 #include <wordcountdialog.hrc>
 
+#if 0
 #if ENABLE_LAYOUT
 #undef SW_RES
 #define SW_RES(x) #x
@@ -80,6 +81,103 @@ SwWordCountDialog::SwWordCountDialog(Window* pParent) :
 #endif /* ENABLE_LAYOUT */
     FreeResource();
 }
+#endif
+
+#include <vcl/box.hxx>
+#include <vcl/table.hxx>
+#include <vcl/notebook.hxx>
+
+SwWordCountDialog::SwWordCountDialog (Window* parent) :
+    LDialog(parent)
+{
+    // create widgets
+
+    aCurrentWordFT = new FixedText (this);
+    aCurrentWordFT->SetText (String::CreateFromAscii ("Words:"));
+    aCurrentWordFI = new FixedInfo (this);
+
+    aCurrentCharacterFT = new FixedText (this);
+    aCurrentCharacterFT->SetText (String::CreateFromAscii ("Characters:"));
+    aCurrentCharacterFI = new FixedInfo (this);
+
+    aCurrentCharacterExcludingSpacesFT = new FixedText (this);
+    aCurrentCharacterExcludingSpacesFT->SetText (String::CreateFromAscii ("Characters excluding spaces:"));
+    aCurrentCharacterExcludingSpacesFI = new FixedInfo (this);
+
+    aDocWordFT = new FixedText (this);
+    aDocWordFT->SetText (String::CreateFromAscii ("Words:"));
+    aDocWordFI = new FixedInfo (this);
+
+    aDocCharacterFT = new FixedText (this);
+    aDocCharacterFT->SetText (String::CreateFromAscii ("Characters:"));
+    aDocCharacterFI = new FixedInfo (this);
+
+    aDocCharacterExcludingSpacesFT = new FixedText (this);
+    aDocCharacterExcludingSpacesFT->SetText (String::CreateFromAscii ("Characters excluding spaces:"));
+    aDocCharacterExcludingSpacesFI = new FixedInfo (this);
+
+#if 1
+    // create layout
+
+    Notebook *notebook = new Notebook (this);
+    for (int page = 0; page < 2; page++) {
+        VBox *labels_box = new VBox (false, 6);
+        VBox *counts_box = new VBox (false, 6);
+
+        String str;
+        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);
+
+                counts_box->Pack (aDocWordFI, false, true);
+                counts_box->Pack (aDocCharacterFI, false, true);
+                counts_box->Pack (aDocCharacterExcludingSpacesFI, false, true);
+                break;
+        }
+
+        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);
+    }
+
+    Button *button = new Button (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);
+
+    Box *vbox = new VBox (false, 12);
+    vbox->SetBorderWidth (6);
+    vbox->Pack (notebook, notebook, true, true);
+    vbox->Pack (buttons_box, false, true);
+
+    ::Layout::ShowAll (vbox);
+    SetText (String::CreateFromAscii ("Word Count"));
+//    vbox->SetPosSizePixel (0, 0, width, height, WINDOW_POSSIZE_ALL);
+#endif
+
+//    FreeResource();
+}
 
 SwWordCountDialog::~SwWordCountDialog()
 {
@@ -87,12 +185,12 @@ SwWordCountDialog::~SwWordCountDialog()
 
 void  SwWordCountDialog::SetValues(const SwDocStat& rCurrent, const SwDocStat& rDoc)
 {
-    aCurrentWordFI.SetText(     String::CreateFromInt32(rCurrent.nWord ));
-    aCurrentCharacterFI.SetText(String::CreateFromInt32(rCurrent.nChar ));
-    aCurrentCharacterExcludingSpacesFI.SetText(String::CreateFromInt32(rCurrent.nCharExcludingSpaces ));
-    aDocWordFI.SetText(         String::CreateFromInt32(rDoc.nWord ));
-    aDocCharacterFI.SetText(    String::CreateFromInt32(rDoc.nChar ));
-    aDocCharacterExcludingSpacesFI.SetText(    String::CreateFromInt32(rDoc.nCharExcludingSpaces ));
+    aCurrentWordFI->SetText(     String::CreateFromInt32(rCurrent.nWord ));
+    aCurrentCharacterFI->SetText(String::CreateFromInt32(rCurrent.nChar ));
+    aCurrentCharacterExcludingSpacesFI->SetText(String::CreateFromInt32(rCurrent.nCharExcludingSpaces ));
+    aDocWordFI->SetText(         String::CreateFromInt32(rDoc.nWord ));
+    aDocCharacterFI->SetText(    String::CreateFromInt32(rDoc.nChar ));
+    aDocCharacterExcludingSpacesFI->SetText(    String::CreateFromInt32(rDoc.nCharExcludingSpaces ));
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/ui/inc/wordcountdialog.hxx b/sw/source/ui/inc/wordcountdialog.hxx
index 3d640ca..f7715b3 100644
--- a/sw/source/ui/inc/wordcountdialog.hxx
+++ b/sw/source/ui/inc/wordcountdialog.hxx
@@ -30,31 +30,32 @@
 #include <sfx2/basedlgs.hxx>
 #include <svtools/stdctrl.hxx>
 #include <vcl/button.hxx>
+#include <vcl/ldialog.hxx>
 #include <layout/layout.hxx>
 #include <layout/layout-pre.hxx>
 struct SwDocStat;
-class SwWordCountDialog : public SfxModalDialog
+class SwWordCountDialog : public LDialog
 {
-    FixedLine       aCurrentFL;
-    FixedText       aCurrentWordFT;
-    FixedInfo       aCurrentWordFI;
-    FixedText       aCurrentCharacterFT;
-    FixedInfo       aCurrentCharacterFI;
-    FixedText       aCurrentCharacterExcludingSpacesFT;
-    FixedInfo       aCurrentCharacterExcludingSpacesFI;
+    FixedLine       *aCurrentFL;
+    FixedText       *aCurrentWordFT;
+    FixedInfo       *aCurrentWordFI;
+    FixedText       *aCurrentCharacterFT;
+    FixedInfo       *aCurrentCharacterFI;
+    FixedText       *aCurrentCharacterExcludingSpacesFT;
+    FixedInfo       *aCurrentCharacterExcludingSpacesFI;
 
-    FixedLine       aDocFL;
-    FixedText       aDocWordFT;
-    FixedInfo       aDocWordFI;
-    FixedText       aDocCharacterFT;
-    FixedInfo       aDocCharacterFI;
-    FixedText       aDocCharacterExcludingSpacesFT;
-    FixedInfo       aDocCharacterExcludingSpacesFI;
+    FixedLine       *aDocFL;
+    FixedText       *aDocWordFT;
+    FixedInfo       *aDocWordFI;
+    FixedText       *aDocCharacterFT;
+    FixedInfo       *aDocCharacterFI;
+    FixedText       *aDocCharacterExcludingSpacesFT;
+    FixedInfo       *aDocCharacterExcludingSpacesFI;
 
-    FixedLine       aBottomFL;
+    FixedLine       *aBottomFL;
 
-    OKButton        aOK;
-    HelpButton      aHelp;
+    OKButton        *aOK;
+    HelpButton      *aHelp;
 
 public:    
     SwWordCountDialog(Window* pParent);


More information about the Libreoffice-commits mailing list