[Libreoffice-commits] core.git: sc/source sc/uiconfig

Caolán McNamara caolanm at redhat.com
Fri Jun 6 05:37:10 PDT 2014


 sc/source/ui/condformat/condformatmgr.cxx |   91 ++++++++++--------------------
 sc/source/ui/inc/condformatmgr.hxx        |   16 +----
 sc/uiconfig/scalc/ui/condformatmanager.ui |   34 +++++------
 3 files changed, 55 insertions(+), 86 deletions(-)

New commits:
commit 5918209d281927b714850157b2d1415fa8765c6f
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Fri Jun 6 12:28:42 2014 +0100

    Resolves: fdo#73675 tweak conversion to use SvSimpleTable
    
    Change-Id: Ibfa5c806581c450a0b0407cb07751e06dd3a787e

diff --git a/sc/source/ui/condformat/condformatmgr.cxx b/sc/source/ui/condformat/condformatmgr.cxx
index 6a9ea44..5e0b3e8 100644
--- a/sc/source/ui/condformat/condformatmgr.cxx
+++ b/sc/source/ui/condformat/condformatmgr.cxx
@@ -18,36 +18,22 @@
 #define ITEMID_CONDITION 2
 
 
-ScCondFormatManagerWindow::ScCondFormatManagerWindow(Window* pParent, ScDocument* pDoc, ScConditionalFormatList* pFormatList):
-    SvTabListBox(pParent, WB_BORDER | WB_HSCROLL | WB_SORT | WB_CLIPCHILDREN | WB_TABSTOP),
-    maHeaderBar( pParent, WB_BUTTONSTYLE | WB_BOTTOMBORDER ),
-    mpDoc(pDoc),
-    mpFormatList(pFormatList)
+ScCondFormatManagerWindow::ScCondFormatManagerWindow(SvSimpleTableContainer& rParent,
+    ScDocument* pDoc, ScConditionalFormatList* pFormatList)
+    : SvSimpleTable(rParent, WB_HSCROLL | WB_SORT | WB_TABSTOP)
+    , mpDoc(pDoc)
+    , mpFormatList(pFormatList)
 {
-    Size aBoxSize( pParent->GetOutputSizePixel() );
-
-    maHeaderBar.SetPosSizePixel( Point(0, 0), Size( aBoxSize.Width(), 16 ) );
-
     OUString aConditionStr(ScGlobal::GetRscString(STR_HEADER_COND));
     OUString aRangeStr(ScGlobal::GetRscString(STR_HEADER_RANGE));
 
-    long nTabSize = aBoxSize.Width()/2;
-    maHeaderBar.InsertItem( ITEMID_RANGE, aRangeStr, nTabSize, HIB_LEFT| HIB_VCENTER );
-    maHeaderBar.InsertItem( ITEMID_CONDITION, aConditionStr, nTabSize, HIB_LEFT| HIB_VCENTER );
-
-    static long nTabs[] = {2, 0, nTabSize };
-    Size aHeadSize( maHeaderBar.GetSizePixel() );
-
-    //pParent->SetFocusControl( this );
-    SetPosSizePixel( Point( 0, aHeadSize.Height() ), Size( aBoxSize.Width(), aBoxSize.Height() - aHeadSize.Height() ) );
-    SetTabs( &nTabs[0], MAP_PIXEL );
-
-    maHeaderBar.SetEndDragHdl( LINK(this, ScCondFormatManagerWindow, HeaderEndDragHdl ) );
-    HeaderEndDragHdl(NULL);
+    OUStringBuffer sHeader;
+    sHeader.append(aRangeStr).append("\t").append(aConditionStr);
+    InsertHeaderEntry(sHeader.makeStringAndClear(), HEADERBAR_APPEND, HIB_LEFT | HIB_VCENTER);
+    setColSizes();
 
     Init();
     Show();
-    maHeaderBar.Show();
     SetSelectionMode(MULTIPLE_SELECTION);
 }
 
@@ -70,15 +56,18 @@ void ScCondFormatManagerWindow::Init()
         SvTreeListEntry* pEntry = InsertEntryToColumn( createEntryString(*itr), TREELIST_APPEND, 0xffff );
         maMapLBoxEntryToCondIndex.insert(std::pair<SvTreeListEntry*,sal_Int32>(pEntry,itr->GetKey()));
     }
+
     SetUpdateMode(true);
+
+    if (mpFormatList->size())
+        SelectRow(0);
 }
 
-void ScCondFormatManagerWindow::ChangeSize(Size aSize)
+void ScCondFormatManagerWindow::Resize()
 {
-    maHeaderBar.SetSizePixel( Size( aSize.Width(), 16 ) );
-    Size aHeadSize( maHeaderBar.GetSizePixel() );
-    SetSizePixel( Size( aSize.Width(), aSize.Height() - aHeadSize.Height() ) );
-    HeaderEndDragHdl(NULL);
+    SvSimpleTable::Resize();
+    if (GetParentDialog()->isCalculatingInitialLayoutSize())
+        setColSizes();
 }
 
 void ScCondFormatManagerWindow::DeleteSelection()
@@ -111,23 +100,14 @@ void ScCondFormatManagerWindow::Update()
     Init();
 }
 
-IMPL_LINK_NOARG(ScCondFormatManagerWindow, HeaderEndDragHdl)
+void ScCondFormatManagerWindow::setColSizes()
 {
-    long aTableSize = maHeaderBar.GetSizePixel().Width();
-    long aItemRangeSize = maHeaderBar.GetItemSize(ITEMID_RANGE);
-
-    //calculate column size based on user input and minimum size
-    long aItemCondSize = aTableSize - aItemRangeSize;
-
-    Size aSz;
-    aSz.Width() = aItemRangeSize;
-    SetTab( ITEMID_RANGE, PixelToLogic( aSz, MapMode(MAP_APPFONT) ).Width(), MAP_APPFONT );
-    maHeaderBar.SetItemSize(ITEMID_RANGE, aItemRangeSize);
-    aSz.Width() += aItemCondSize;
-    SetTab( ITEMID_CONDITION, PixelToLogic( aSz, MapMode(MAP_APPFONT) ).Width(), MAP_APPFONT );
-    maHeaderBar.SetItemSize(ITEMID_CONDITION, aItemCondSize);
-
-    return 0;
+    HeaderBar &rBar = GetTheHeaderBar();
+    if (rBar.GetItemCount() < 2)
+        return;
+    long aStaticTabs[]= { 2, 0, 0 };
+    aStaticTabs[2] = rBar.GetSizePixel().Width() / 2;
+    SvSimpleTable::SetTabs(aStaticTabs, MAP_PIXEL);
 }
 
 ScCondFormatManagerDlg::ScCondFormatManagerDlg(Window* pParent, ScDocument* pDoc, const ScConditionalFormatList* pFormatList, const ScAddress& rPos):
@@ -137,13 +117,14 @@ ScCondFormatManagerDlg::ScCondFormatManagerDlg(Window* pParent, ScDocument* pDoc
     maPos(rPos),
     mbModified(false)
 {
-    get(m_pGrid, "dialog-vbox1");
-    get(m_pContainer, "CONTAINER");
-    m_pContainer->SetSizePixel(Size(300, 100));
-    m_pCtrlManager = new ScCondFormatManagerWindow(m_pContainer, mpDoc, mpFormatList);
-    get(m_pBtnAdd, "ADD");
-    get(m_pBtnRemove, "REMOVE");
-    get(m_pBtnEdit, "EDIT");
+    SvSimpleTableContainer *pContainer = get<SvSimpleTableContainer>("CONTAINER");
+    Size aSize(LogicToPixel(Size(290, 220), MAP_APPFONT));
+    pContainer->set_width_request(aSize.Width());
+    pContainer->set_height_request(aSize.Height());
+    m_pCtrlManager = new ScCondFormatManagerWindow(*pContainer, mpDoc, mpFormatList);
+    get(m_pBtnAdd, "add");
+    get(m_pBtnRemove, "remove");
+    get(m_pBtnEdit, "edit");
 
     m_pBtnRemove->SetClickHdl(LINK(this, ScCondFormatManagerDlg, RemoveBtnHdl));
     m_pBtnEdit->SetClickHdl(LINK(this, ScCondFormatManagerDlg, EditBtnHdl));
@@ -151,16 +132,10 @@ ScCondFormatManagerDlg::ScCondFormatManagerDlg(Window* pParent, ScDocument* pDoc
     m_pCtrlManager->SetDoubleClickHdl(LINK(this, ScCondFormatManagerDlg, EditBtnHdl));
 }
 
-void ScCondFormatManagerDlg::Resize()
-{
-    m_pGrid->SetSizePixel(Size(GetOutputSizePixel().Width() - 12, GetOutputSizePixel().Height() - 12));
-    m_pCtrlManager->ChangeSize(Size(GetOutputSizePixel().Width() - 18, GetOutputSizePixel().Height() - 100));
-}
-
 ScCondFormatManagerDlg::~ScCondFormatManagerDlg()
 {
-    delete mpFormatList;
     delete m_pCtrlManager;
+    delete mpFormatList;
 }
 
 bool ScCondFormatManagerDlg::IsInRefMode() const
diff --git a/sc/source/ui/inc/condformatmgr.hxx b/sc/source/ui/inc/condformatmgr.hxx
index 488f6c6..381eb65 100644
--- a/sc/source/ui/inc/condformatmgr.hxx
+++ b/sc/source/ui/inc/condformatmgr.hxx
@@ -17,7 +17,7 @@
 #include <svtools/svtabbx.hxx>
 #include <vcl/button.hxx>
 #include <vcl/fixed.hxx>
-#include <svtools/headbar.hxx>
+#include <svtools/simptabl.hxx>
 
 #include "conditio.hxx"
 
@@ -25,26 +25,24 @@
 
 class ScDocument;
 
-class ScCondFormatManagerWindow : public SvTabListBox
+class ScCondFormatManagerWindow : public SvSimpleTable
 {
 private:
     void Init();
     OUString createEntryString(const ScConditionalFormat& rFormat);
+    void setColSizes();
 
-    HeaderBar maHeaderBar;
     ScDocument* mpDoc;
     ScConditionalFormatList* mpFormatList;
     std::map<SvTreeListEntry*, sal_Int32> maMapLBoxEntryToCondIndex;
 
-    DECL_LINK( HeaderEndDragHdl, void* );
-
 public:
-    ScCondFormatManagerWindow( Window* pParent, ScDocument* pDoc, ScConditionalFormatList* pFormatList);
-    void ChangeSize(Size aSize);
+    ScCondFormatManagerWindow(SvSimpleTableContainer& rParent, ScDocument* pDoc, ScConditionalFormatList* pFormatList);
 
     void DeleteSelection();
     ScConditionalFormat* GetSelection();
     void Update();
+    virtual void Resize() SAL_OVERRIDE;
 };
 
 class ScCondFormatManagerDlg : public ModalDialog
@@ -64,8 +62,6 @@ private:
     PushButton *m_pBtnRemove;
     PushButton *m_pBtnEdit;
     ScConditionalFormatList* mpFormatList;
-    Window *m_pContainer;
-    VclVBox *m_pGrid;
     ScCondFormatManagerWindow *m_pCtrlManager;
 
     ScDocument* mpDoc;
@@ -75,8 +71,6 @@ private:
     DECL_LINK(EditBtnHdl, void*);
     DECL_LINK(AddBtnHdl, void*);
 
-    virtual void Resize();
-
     bool mbModified;
 };
 
diff --git a/sc/uiconfig/scalc/ui/condformatmanager.ui b/sc/uiconfig/scalc/ui/condformatmanager.ui
index 24bf873..7a01298 100644
--- a/sc/uiconfig/scalc/ui/condformatmanager.ui
+++ b/sc/uiconfig/scalc/ui/condformatmanager.ui
@@ -1,6 +1,8 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.16.1 -->
 <interface>
-  <!-- interface-requires gtk+ 3.0 -->
+  <requires lib="gtk+" version="3.0"/>
+  <!-- interface-requires LibreOffice 1.0 -->
   <object class="GtkDialog" id="CondFormatManager">
     <property name="can_focus">False</property>
     <property name="border_width">6</property>
@@ -18,13 +20,14 @@
             <property name="can_focus">False</property>
             <property name="layout_style">end</property>
             <child>
-              <object class="GtkButton" id="OK">
+              <object class="GtkButton" id="ok">
                 <property name="label">gtk-ok</property>
                 <property name="use_action_appearance">False</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="has_default">True</property>
                 <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
                 <property name="use_stock">True</property>
               </object>
               <packing>
@@ -34,13 +37,12 @@
               </packing>
             </child>
             <child>
-              <object class="GtkButton" id="HELP">
-                <property name="label">gtk-help</property>
+              <object class="GtkButton" id="cancel">
+                <property name="label">gtk-cancel</property>
                 <property name="use_action_appearance">False</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
                 <property name="use_stock">True</property>
               </object>
               <packing>
@@ -72,13 +74,12 @@
                 <property name="spacing">6</property>
                 <property name="layout_style">start</property>
                 <child>
-                  <object class="GtkButton" id="ADD">
+                  <object class="GtkButton" id="add">
                     <property name="label" translatable="yes">Add</property>
                     <property name="use_action_appearance">False</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="receives_default">True</property>
-                    <property name="use_action_appearance">False</property>
                   </object>
                   <packing>
                     <property name="expand">False</property>
@@ -87,13 +88,12 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkButton" id="EDIT">
+                  <object class="GtkButton" id="edit">
                     <property name="label" translatable="yes">Edit...</property>
                     <property name="use_action_appearance">False</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="receives_default">True</property>
-                    <property name="use_action_appearance">False</property>
                   </object>
                   <packing>
                     <property name="expand">False</property>
@@ -102,13 +102,12 @@
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkButton" id="REMOVE">
+                  <object class="GtkButton" id="remove">
                     <property name="label" translatable="yes">Remove</property>
                     <property name="use_action_appearance">False</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
                     <property name="receives_default">True</property>
-                    <property name="use_action_appearance">False</property>
                   </object>
                   <packing>
                     <property name="expand">False</property>
@@ -125,13 +124,14 @@
               </packing>
             </child>
             <child>
-              <object class="GtkDrawingArea" id="CONTAINER">
-                <property name="width_request">300</property>
-                <property name="height_request">200</property>
+              <object class="svtlo-SvSimpleTableContainer" id="CONTAINER">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <property name="hexpand">True</property>
                 <property name="vexpand">True</property>
+                <child internal-child="selection">
+                  <object class="GtkTreeSelection" id="Simple Table Container-selection1"/>
+                </child>
               </object>
               <packing>
                 <property name="left_attach">0</property>
@@ -150,8 +150,8 @@
       </object>
     </child>
     <action-widgets>
-      <action-widget response="0">OK</action-widget>
-      <action-widget response="0">HELP</action-widget>
+      <action-widget response="0">ok</action-widget>
+      <action-widget response="0">cancel</action-widget>
     </action-widgets>
   </object>
 </interface>


More information about the Libreoffice-commits mailing list