Kaydet (Commit) 16d7ace9 authored tarafından Caolán McNamara's avatar Caolán McNamara

rework the calc sort dialog to use .ui snippet

this should have the side-effect that the scrollbar is in the right place, and
not jammed into some odd place in the dialog

Change-Id: Ie1648568de755172b77378b19e0b59b5056c116f
üst f41a2804
...@@ -11,7 +11,9 @@ $(eval $(call gb_UI_UI,modules/scalc)) ...@@ -11,7 +11,9 @@ $(eval $(call gb_UI_UI,modules/scalc))
$(eval $(call gb_UI_add_uifiles,modules/scalc,\ $(eval $(call gb_UI_add_uifiles,modules/scalc,\
sc/uiconfig/scalc/ui/printeroptions \ sc/uiconfig/scalc/ui/printeroptions \
sc/uiconfig/scalc/ui/sortpage \ sc/uiconfig/scalc/ui/sortcriteriapage \
sc/uiconfig/scalc/ui/sortkey \
sc/uiconfig/scalc/ui/sortoptionspage \
sc/uiconfig/scalc/ui/textimportoptions \ sc/uiconfig/scalc/ui/textimportoptions \
)) ))
......
...@@ -32,54 +32,47 @@ ...@@ -32,54 +32,47 @@
// ======================================================================= // =======================================================================
ScSortKeyItem::ScSortKeyItem( Window* pParent ) : ScSortKeyItem::ScSortKeyItem(Window* pParent)
//
aFlSort ( pParent, ScResId( FL_SORT ) ),
aLbSort ( pParent, ScResId( LB_SORT ) ),
aBtnUp ( pParent, ScResId( BTN_UP ) ),
aBtnDown ( pParent, ScResId( BTN_DOWN ) )
{ {
m_pUIBuilder = new VclBuilder(pParent, getUIRootDir(), "modules/scalc/ui/sortkey.ui");
get(m_pFrame, "SortKeyFrame");
get(m_pFlSort, "sortft");
get(m_pLbSort, "sortlb");
get(m_pBtnUp, "up");
get(m_pBtnDown, "down");
} }
// ----------------------------------------------------------------------- long ScSortKeyItem::getItemHeight() const
{
return m_pFrame->get_preferred_size().Height();
}
void ScSortKeyItem::DisableField() void ScSortKeyItem::DisableField()
{ {
aFlSort.Disable(); m_pFrame->Disable();
aLbSort.Disable();
aBtnUp.Disable();
aBtnDown.Disable();
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
void ScSortKeyItem::EnableField() void ScSortKeyItem::EnableField()
{ {
aFlSort.Enable(); m_pFrame->Enable();
aLbSort.Enable();
aBtnUp.Enable();
aBtnDown.Enable();
} }
// ======================================================================= // =======================================================================
ScSortKeyWindow::ScSortKeyWindow( Window* pParent, const ResId& rResId, ScSortKeyItems& rSortKeyItems ) : ScSortKeyWindow::ScSortKeyWindow(SfxTabPage* pParent, ScSortKeyItems& rSortKeyItems)
Window( pParent, rResId ), : mrSortKeyItems(rSortKeyItems)
//
aFlSort ( this, ScResId( FL_SORT ) ),
aLbSort ( this, ScResId( LB_SORT ) ),
aBtnUp ( this, ScResId( BTN_UP ) ),
aBtnDown ( this, ScResId( BTN_DOWN ) ),
//
nScrollPos ( 0 ),
mrSortKeyItems( rSortKeyItems )
{ {
aFlSort.Hide(); pParent->get(m_pBox, "SortKeyWindow");
aLbSort.Hide(); if (!mrSortKeyItems.empty())
aBtnUp.Hide(); nItemHeight = mrSortKeyItems.front().getItemHeight();
aBtnDown.Hide(); else
{
nItemHeight = aBtnDown.GetPosPixel().Y() + aBtnDown.GetSizePixel().Height(); ScSortKeyItem aTemp(m_pBox);
nItemHeight = aTemp.getItemHeight();
}
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
...@@ -93,95 +86,56 @@ ScSortKeyWindow::~ScSortKeyWindow() ...@@ -93,95 +86,56 @@ ScSortKeyWindow::~ScSortKeyWindow()
void ScSortKeyWindow::AddSortKey( sal_uInt16 nItemNumber ) void ScSortKeyWindow::AddSortKey( sal_uInt16 nItemNumber )
{ {
ScSortKeyItem* pSortKeyItem = new ScSortKeyItem( this ); ScSortKeyItem* pSortKeyItem = new ScSortKeyItem(m_pBox);
// Set Sort key number // Set Sort key number
String aLine = pSortKeyItem->aFlSort.GetText(); String aLine = pSortKeyItem->m_pFlSort->GetText();
aLine += String::CreateFromInt32( nItemNumber ); aLine += String::CreateFromInt32( nItemNumber );
pSortKeyItem->aFlSort.SetText( aLine ); pSortKeyItem->m_pFlSort->SetText( aLine );
mrSortKeyItems.push_back( pSortKeyItem );
Window* pWindows[] = { &aFlSort, &aLbSort, &aBtnUp, &aBtnDown, NULL }; mrSortKeyItems.push_back(pSortKeyItem);
Window* pNewWindows[] = { &pSortKeyItem->aFlSort, &pSortKeyItem->aLbSort,
&pSortKeyItem->aBtnUp, &pSortKeyItem->aBtnDown, NULL };
Window** pCurrent = pWindows;
Window** pNewCurrent = pNewWindows;
while ( *pCurrent )
{
Size aSize = (*pCurrent)->GetSizePixel();
Point aPos = (*pCurrent)->GetPosPixel();
aPos.Y() += ( nItemNumber - 1 ) * GetItemHeight();
aPos.Y() += nScrollPos;
(*pNewCurrent)->SetPosSizePixel( aPos, aSize );
(*pNewCurrent)->Show();
pCurrent++;
pNewCurrent++;
}
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
void ScSortKeyWindow::DoScroll( sal_Int32 nNewPos ) void ScSortKeyWindow::DoScroll(sal_Int32 nNewPos)
{ {
nScrollPos += nNewPos; m_pBox->SetPosPixel(Point(0, nNewPos));
ScSortKeyItems::iterator pIter;
for ( pIter = mrSortKeyItems.begin(); pIter != mrSortKeyItems.end(); ++pIter )
{
Window* pNewWindows[] = { &pIter->aFlSort, &pIter->aLbSort,
&pIter->aBtnUp, &pIter->aBtnDown, NULL };
Window** pCurrent = pNewWindows;
while ( *pCurrent )
{
Point aPos = (*pCurrent)->GetPosPixel();
aPos.Y() += nNewPos;
(*pCurrent)->SetPosPixel( aPos );
pCurrent++;
}
}
} }
// ======================================================================= // =======================================================================
ScSortKeyCtrl::ScSortKeyCtrl( Window* pParent, const ScResId& rResId, ScSortKeyItems& rItems ): ScSortKeyCtrl::ScSortKeyCtrl(SfxTabPage* pParent, ScSortKeyItems& rItems)
Control( pParent, rResId), : m_aSortWin(pParent, rItems)
// , m_rScrolledWindow(*pParent->get<VclScrolledWindow>("SortCriteriaPage"))
aSortWin ( this, ResId( WIN_MANAGESORTKEY, *rResId.GetResMgr() ), rItems ), , m_rVertScroll(m_rScrolledWindow.getVertScrollBar())
aVertScroll ( this, ResId( SB_SORT, *rResId.GetResMgr() ) ), , nThumbPos(0)
nThumbPos ( 0 )
{ {
aVertScroll.EnableDrag(); m_rVertScroll.EnableDrag();
aVertScroll.Show(); m_rVertScroll.Show();
FreeResource();
aVertScroll.SetRangeMin( 0 ); m_rVertScroll.SetRangeMin( 0 );
sal_Int32 nScrollOffset = aSortWin.GetItemHeight(); m_rVertScroll.SetVisibleSize( 0xFFFF );
sal_Int32 nVisibleItems = aSortWin.GetSizePixel().Height() / nScrollOffset;
aVertScroll.SetRangeMax( nVisibleItems );
aVertScroll.SetPageSize( nVisibleItems - 1 );
aVertScroll.SetVisibleSize( nVisibleItems );
Link aScrollLink = LINK( this, ScSortKeyCtrl, ScrollHdl ); Link aScrollLink = LINK( this, ScSortKeyCtrl, ScrollHdl );
aVertScroll.SetScrollHdl( aScrollLink ); m_rVertScroll.SetScrollHdl( aScrollLink );
} }
// ----------------------------------------------------------------------- void ScSortKeyCtrl::setScrollRange()
ScSortKeyCtrl::~ScSortKeyCtrl()
{ {
sal_Int32 nScrollOffset = m_aSortWin.GetItemHeight();
sal_Int32 nVisibleItems = m_rScrolledWindow.getVisibleChildSize().Height() / nScrollOffset;
m_rVertScroll.SetPageSize( nVisibleItems - 1 );
m_rVertScroll.SetVisibleSize( nVisibleItems );
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
IMPL_LINK( ScSortKeyCtrl, ScrollHdl, ScrollBar*, pScrollBar ) IMPL_LINK( ScSortKeyCtrl, ScrollHdl, ScrollBar*, pScrollBar )
{ {
sal_Int32 nOffset = aSortWin.GetItemHeight(); sal_Int32 nOffset = m_aSortWin.GetItemHeight();
nOffset *= ( nThumbPos - pScrollBar->GetThumbPos() ); nOffset *= pScrollBar->GetThumbPos();
nThumbPos = pScrollBar->GetThumbPos(); m_aSortWin.DoScroll( -nOffset );
aSortWin.DoScroll( nOffset );
return 0; return 0;
} }
...@@ -189,9 +143,9 @@ IMPL_LINK( ScSortKeyCtrl, ScrollHdl, ScrollBar*, pScrollBar ) ...@@ -189,9 +143,9 @@ IMPL_LINK( ScSortKeyCtrl, ScrollHdl, ScrollBar*, pScrollBar )
void ScSortKeyCtrl::AddSortKey( sal_uInt16 nItem ) void ScSortKeyCtrl::AddSortKey( sal_uInt16 nItem )
{ {
aVertScroll.SetRangeMax( nItem ); m_rVertScroll.SetRangeMax( nItem );
aVertScroll.DoScroll( nItem ); m_rVertScroll.DoScroll( nItem );
aSortWin.AddSortKey( nItem ); m_aSortWin.AddSortKey( nItem );
} }
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This diff is collapsed.
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <vcl/edit.hxx> #include <vcl/edit.hxx>
#include <vcl/fixed.hxx> #include <vcl/fixed.hxx>
#include <vcl/layout.hxx>
#include <vcl/lstbox.hxx> #include <vcl/lstbox.hxx>
#include <vcl/scrbar.hxx> #include <vcl/scrbar.hxx>
#include <vcl/ctrl.hxx> #include <vcl/ctrl.hxx>
...@@ -44,61 +45,61 @@ ...@@ -44,61 +45,61 @@
// ======================================================================= // =======================================================================
struct ScSortKeyItem struct ScSortKeyItem : public VclBuilderContainer
{ {
FixedLine aFlSort; VclFrame* m_pFrame;
ListBox aLbSort; FixedText* m_pFlSort;
RadioButton aBtnUp; ListBox* m_pLbSort;
RadioButton aBtnDown; RadioButton* m_pBtnUp;
RadioButton* m_pBtnDown;
ScSortKeyItem ( Window* pParent ); ScSortKeyItem(Window* pParent);
void DisableField(); void DisableField();
void EnableField(); void EnableField();
long getItemHeight() const;
}; };
typedef boost::ptr_vector<ScSortKeyItem> ScSortKeyItems; typedef boost::ptr_vector<ScSortKeyItem> ScSortKeyItems;
// ======================================================================= // =======================================================================
class ScSortKeyWindow : public Window class ScSortKeyWindow
{ {
private: private:
FixedLine aFlSort; VclBox* m_pBox;
ListBox aLbSort;
RadioButton aBtnUp;
RadioButton aBtnDown;
sal_Int32 nScrollPos; sal_Int32 nScrollPos;
sal_Int32 nItemHeight; sal_Int32 nItemHeight;
ScSortKeyItems& mrSortKeyItems; ScSortKeyItems& mrSortKeyItems;
public: public:
ScSortKeyWindow( Window* pParent, const ResId& rResId, ScSortKeyItems& mrSortKeyItems ); ScSortKeyWindow(SfxTabPage* pParent, ScSortKeyItems& mrSortKeyItems);
~ScSortKeyWindow(); ~ScSortKeyWindow();
void AddSortKey( sal_uInt16 nItem ); void AddSortKey( sal_uInt16 nItem );
void DoScroll( sal_Int32 nNewPos ); void DoScroll( sal_Int32 nNewPos );
sal_Int32 GetItemHeight() const { return nItemHeight; } sal_Int32 GetItemHeight() const { return nItemHeight; }
sal_Int32 GetTotalHeight() const { return m_pBox->GetSizePixel().Height(); }
}; };
// ======================================================================= // =======================================================================
class ScSortKeyCtrl : public Control class ScSortKeyCtrl
{ {
private: private:
ScSortKeyWindow aSortWin; ScSortKeyWindow m_aSortWin;
ScrollBar aVertScroll; VclScrolledWindow& m_rScrolledWindow;
ScrollBar& m_rVertScroll;
sal_Int32 nThumbPos; sal_Int32 nThumbPos;
DECL_LINK( ScrollHdl, ScrollBar* ); DECL_LINK(ScrollHdl, ScrollBar*);
public: public:
ScSortKeyCtrl( Window* pParent, const ScResId& rResId, ScSortKeyItems& mrSortKeyItems ); ScSortKeyCtrl(SfxTabPage* pParent, ScSortKeyItems& mrSortKeyItems);
~ScSortKeyCtrl(); void setScrollRange();
void AddSortKey( sal_uInt16 nItem ); void AddSortKey( sal_uInt16 nItem );
}; };
......
...@@ -59,6 +59,10 @@ public: ...@@ -59,6 +59,10 @@ public:
virtual sal_Bool FillItemSet ( SfxItemSet& rArgSet ); virtual sal_Bool FillItemSet ( SfxItemSet& rArgSet );
virtual void Reset ( const SfxItemSet& rArgSet ); virtual void Reset ( const SfxItemSet& rArgSet );
virtual void SetPosSizePixel(const Point& rAllocPos, const Size& rAllocation);
virtual void SetSizePixel(const Size& rAllocation);
virtual void SetPosPixel(const Point& rAllocPos);
protected: protected:
virtual void ActivatePage ( const SfxItemSet& rSet ); virtual void ActivatePage ( const SfxItemSet& rSet );
using SfxTabPage::ActivatePage; using SfxTabPage::ActivatePage;
......
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkScrolledWindow" id="SortCriteriaPage">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="hscrollbar_policy">never</property>
<property name="vscrollbar_policy">always</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkBox" id="SortKeyWindow">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="orientation">vertical</property>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
</interface>
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<interface> <interface>
<!-- interface-requires gtk+ 3.0 --> <!-- interface-requires gtk+ 3.0 -->
<object class="GtkBox" id="SortPage"> <object class="GtkBox" id="SortOptionsPage">
<property name="visible">True</property> <property name="visible">True</property>
<property name="can_focus">False</property> <property name="can_focus">False</property>
<property name="orientation">vertical</property> <property name="orientation">vertical</property>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment