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))
$(eval $(call gb_UI_add_uifiles,modules/scalc,\
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 \
))
......
......@@ -32,54 +32,47 @@
// =======================================================================
ScSortKeyItem::ScSortKeyItem( Window* pParent ) :
//
aFlSort ( pParent, ScResId( FL_SORT ) ),
aLbSort ( pParent, ScResId( LB_SORT ) ),
aBtnUp ( pParent, ScResId( BTN_UP ) ),
aBtnDown ( pParent, ScResId( BTN_DOWN ) )
ScSortKeyItem::ScSortKeyItem(Window* pParent)
{
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()
{
aFlSort.Disable();
aLbSort.Disable();
aBtnUp.Disable();
aBtnDown.Disable();
m_pFrame->Disable();
}
// -----------------------------------------------------------------------
void ScSortKeyItem::EnableField()
{
aFlSort.Enable();
aLbSort.Enable();
aBtnUp.Enable();
aBtnDown.Enable();
m_pFrame->Enable();
}
// =======================================================================
ScSortKeyWindow::ScSortKeyWindow( Window* pParent, const ResId& rResId, ScSortKeyItems& rSortKeyItems ) :
Window( pParent, rResId ),
//
aFlSort ( this, ScResId( FL_SORT ) ),
aLbSort ( this, ScResId( LB_SORT ) ),
aBtnUp ( this, ScResId( BTN_UP ) ),
aBtnDown ( this, ScResId( BTN_DOWN ) ),
//
nScrollPos ( 0 ),
mrSortKeyItems( rSortKeyItems )
ScSortKeyWindow::ScSortKeyWindow(SfxTabPage* pParent, ScSortKeyItems& rSortKeyItems)
: mrSortKeyItems(rSortKeyItems)
{
aFlSort.Hide();
aLbSort.Hide();
aBtnUp.Hide();
aBtnDown.Hide();
nItemHeight = aBtnDown.GetPosPixel().Y() + aBtnDown.GetSizePixel().Height();
pParent->get(m_pBox, "SortKeyWindow");
if (!mrSortKeyItems.empty())
nItemHeight = mrSortKeyItems.front().getItemHeight();
else
{
ScSortKeyItem aTemp(m_pBox);
nItemHeight = aTemp.getItemHeight();
}
}
// -----------------------------------------------------------------------
......@@ -93,95 +86,56 @@ ScSortKeyWindow::~ScSortKeyWindow()
void ScSortKeyWindow::AddSortKey( sal_uInt16 nItemNumber )
{
ScSortKeyItem* pSortKeyItem = new ScSortKeyItem( this );
ScSortKeyItem* pSortKeyItem = new ScSortKeyItem(m_pBox);
// Set Sort key number
String aLine = pSortKeyItem->aFlSort.GetText();
String aLine = pSortKeyItem->m_pFlSort->GetText();
aLine += String::CreateFromInt32( nItemNumber );
pSortKeyItem->aFlSort.SetText( aLine );
mrSortKeyItems.push_back( pSortKeyItem );
pSortKeyItem->m_pFlSort->SetText( aLine );
Window* pWindows[] = { &aFlSort, &aLbSort, &aBtnUp, &aBtnDown, NULL };
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++;
}
mrSortKeyItems.push_back(pSortKeyItem);
}
// -----------------------------------------------------------------------
void ScSortKeyWindow::DoScroll( sal_Int32 nNewPos )
void ScSortKeyWindow::DoScroll(sal_Int32 nNewPos)
{
nScrollPos += 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++;
}
}
m_pBox->SetPosPixel(Point(0, nNewPos));
}
// =======================================================================
ScSortKeyCtrl::ScSortKeyCtrl( Window* pParent, const ScResId& rResId, ScSortKeyItems& rItems ):
Control( pParent, rResId),
//
aSortWin ( this, ResId( WIN_MANAGESORTKEY, *rResId.GetResMgr() ), rItems ),
aVertScroll ( this, ResId( SB_SORT, *rResId.GetResMgr() ) ),
nThumbPos ( 0 )
ScSortKeyCtrl::ScSortKeyCtrl(SfxTabPage* pParent, ScSortKeyItems& rItems)
: m_aSortWin(pParent, rItems)
, m_rScrolledWindow(*pParent->get<VclScrolledWindow>("SortCriteriaPage"))
, m_rVertScroll(m_rScrolledWindow.getVertScrollBar())
, nThumbPos(0)
{
aVertScroll.EnableDrag();
aVertScroll.Show();
FreeResource();
m_rVertScroll.EnableDrag();
m_rVertScroll.Show();
aVertScroll.SetRangeMin( 0 );
sal_Int32 nScrollOffset = aSortWin.GetItemHeight();
sal_Int32 nVisibleItems = aSortWin.GetSizePixel().Height() / nScrollOffset;
aVertScroll.SetRangeMax( nVisibleItems );
aVertScroll.SetPageSize( nVisibleItems - 1 );
aVertScroll.SetVisibleSize( nVisibleItems );
m_rVertScroll.SetRangeMin( 0 );
m_rVertScroll.SetVisibleSize( 0xFFFF );
Link aScrollLink = LINK( this, ScSortKeyCtrl, ScrollHdl );
aVertScroll.SetScrollHdl( aScrollLink );
m_rVertScroll.SetScrollHdl( aScrollLink );
}
// -----------------------------------------------------------------------
ScSortKeyCtrl::~ScSortKeyCtrl()
void ScSortKeyCtrl::setScrollRange()
{
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 )
{
sal_Int32 nOffset = aSortWin.GetItemHeight();
nOffset *= ( nThumbPos - pScrollBar->GetThumbPos() );
nThumbPos = pScrollBar->GetThumbPos();
aSortWin.DoScroll( nOffset );
sal_Int32 nOffset = m_aSortWin.GetItemHeight();
nOffset *= pScrollBar->GetThumbPos();
m_aSortWin.DoScroll( -nOffset );
return 0;
}
......@@ -189,9 +143,9 @@ IMPL_LINK( ScSortKeyCtrl, ScrollHdl, ScrollBar*, pScrollBar )
void ScSortKeyCtrl::AddSortKey( sal_uInt16 nItem )
{
aVertScroll.SetRangeMax( nItem );
aVertScroll.DoScroll( nItem );
aSortWin.AddSortKey( nItem );
m_rVertScroll.SetRangeMax( nItem );
m_rVertScroll.DoScroll( nItem );
m_aSortWin.AddSortKey( nItem );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This diff is collapsed.
......@@ -36,6 +36,7 @@
#include <vcl/edit.hxx>
#include <vcl/fixed.hxx>
#include <vcl/layout.hxx>
#include <vcl/lstbox.hxx>
#include <vcl/scrbar.hxx>
#include <vcl/ctrl.hxx>
......@@ -44,61 +45,61 @@
// =======================================================================
struct ScSortKeyItem
struct ScSortKeyItem : public VclBuilderContainer
{
FixedLine aFlSort;
ListBox aLbSort;
RadioButton aBtnUp;
RadioButton aBtnDown;
VclFrame* m_pFrame;
FixedText* m_pFlSort;
ListBox* m_pLbSort;
RadioButton* m_pBtnUp;
RadioButton* m_pBtnDown;
ScSortKeyItem ( Window* pParent );
ScSortKeyItem(Window* pParent);
void DisableField();
void EnableField();
long getItemHeight() const;
};
typedef boost::ptr_vector<ScSortKeyItem> ScSortKeyItems;
// =======================================================================
class ScSortKeyWindow : public Window
class ScSortKeyWindow
{
private:
FixedLine aFlSort;
ListBox aLbSort;
RadioButton aBtnUp;
RadioButton aBtnDown;
VclBox* m_pBox;
sal_Int32 nScrollPos;
sal_Int32 nItemHeight;
ScSortKeyItems& mrSortKeyItems;
public:
ScSortKeyWindow( Window* pParent, const ResId& rResId, ScSortKeyItems& mrSortKeyItems );
ScSortKeyWindow(SfxTabPage* pParent, ScSortKeyItems& mrSortKeyItems);
~ScSortKeyWindow();
void AddSortKey( sal_uInt16 nItem );
void DoScroll( sal_Int32 nNewPos );
sal_Int32 GetItemHeight() const { return nItemHeight; }
sal_Int32 GetTotalHeight() const { return m_pBox->GetSizePixel().Height(); }
};
// =======================================================================
class ScSortKeyCtrl : public Control
class ScSortKeyCtrl
{
private:
ScSortKeyWindow aSortWin;
ScrollBar aVertScroll;
ScSortKeyWindow m_aSortWin;
VclScrolledWindow& m_rScrolledWindow;
ScrollBar& m_rVertScroll;
sal_Int32 nThumbPos;
DECL_LINK( ScrollHdl, ScrollBar* );
DECL_LINK(ScrollHdl, ScrollBar*);
public:
ScSortKeyCtrl( Window* pParent, const ScResId& rResId, ScSortKeyItems& mrSortKeyItems );
~ScSortKeyCtrl();
ScSortKeyCtrl(SfxTabPage* pParent, ScSortKeyItems& mrSortKeyItems);
void setScrollRange();
void AddSortKey( sal_uInt16 nItem );
};
......
......@@ -59,6 +59,10 @@ public:
virtual sal_Bool FillItemSet ( 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:
virtual void ActivatePage ( const SfxItemSet& rSet );
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"?>
<interface>
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkBox" id="SortPage">
<object class="GtkBox" id="SortOptionsPage">
<property name="visible">True</property>
<property name="can_focus">False</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