summaryrefslogtreecommitdiff
path: root/sc/source/ui
diff options
context:
space:
mode:
authorKohei Yoshida <kyoshida@novell.com>2010-12-15 16:56:47 -0500
committerKohei Yoshida <kyoshida@novell.com>2010-12-15 16:56:47 -0500
commit4f8d925b70e46f106b8e1348b372a362e85c5463 (patch)
tree3a7f087b4c78727d92e47daa7e4ea924da792451 /sc/source/ui
parent9732fc537818c63c42421dcf0c1553d48ffad8b0 (diff)
Removed the old code for the data field control.
Diffstat (limited to 'sc/source/ui')
-rw-r--r--sc/source/ui/dbgui/fieldwnd.cxx358
-rw-r--r--sc/source/ui/inc/fieldwnd.hxx67
2 files changed, 0 insertions, 425 deletions
diff --git a/sc/source/ui/dbgui/fieldwnd.cxx b/sc/source/ui/dbgui/fieldwnd.cxx
index 3438cd857ce1..ef7adca49492 100644
--- a/sc/source/ui/dbgui/fieldwnd.cxx
+++ b/sc/source/ui/dbgui/fieldwnd.cxx
@@ -1228,8 +1228,6 @@ ScDPFieldType ScDPSelectFieldControl::GetFieldType() const
//=============================================================================
-#if DATA_FIELD_NEW
-
ScDPDataFieldControl::ScDPDataFieldControl(
ScDPLayoutDlg* pDialog, const ResId& rResId, FixedText* pCaption) :
ScDPHorFieldControl(pDialog, rResId, pCaption)
@@ -1258,360 +1256,4 @@ String ScDPDataFieldControl::GetDescription() const
return ScResId(STR_ACC_DATAPILOT_DATA_DESCR);
}
-#else
-
-ScDPDataFieldControl::ScDPDataFieldControl( ScDPLayoutDlg* pParent, const ResId& rResId, FixedText* pCaption ) :
- ScDPFieldControlBase(pParent, rResId, pCaption),
- maScroll(this, WB_HORZ | WB_DRAG),
- mpParent(pParent),
- mnScrollMarginHeight(0),
- mnColumnBtnCount(0),
- mnTotalBtnCount(0)
-{
- maScroll.SetLineSize(1);
- maScroll.SetVisibleSize(2);
- maScroll.SetPageSize(2);
- maScroll.SetRange(Range(0, 2));
- maScroll.DoScroll(0);
- maScroll.SetScrollHdl( LINK(this, ScDPDataFieldControl, ScrollHdl) );
- maScroll.SetEndScrollHdl( LINK(this, ScDPDataFieldControl, EndScrollHdl) );
- maScroll.Show();
-
- AppendPaintable(&maScroll);
-}
-
-ScDPDataFieldControl::~ScDPDataFieldControl()
-{
-}
-
-void ScDPDataFieldControl::CalcSize()
-{
- long nScrollSize = GetSettings().GetStyleSettings().GetScrollBarSize();
- Size aWndSize = GetSizePixel();
- mnScrollMarginHeight = nScrollSize + OUTER_MARGIN_VER;
-
- maScroll.SetSizePixel(Size(aWndSize.Width() - OUTER_MARGIN_HOR*2, nScrollSize));
- maScroll.SetPosPixel(Point(OUTER_MARGIN_HOR, aWndSize.Height() - mnScrollMarginHeight));
-
- long nH = GetFieldSize().Height() + DATA_FIELD_BTN_GAP;
- long nTotalH = aWndSize.Height() - mnScrollMarginHeight - OUTER_MARGIN_VER;
- mnColumnBtnCount = nTotalH / nH;
- mnTotalBtnCount = mnColumnBtnCount * 2;
-}
-
-bool ScDPDataFieldControl::IsValidIndex(size_t /*nIndex*/) const
-{
- // We support unlimited number of data fields. If we ever want to put a
- // cap on the number of data fields, this is the right place.
- return true;
-}
-
-Point ScDPDataFieldControl::GetFieldPosition(size_t nIndex)
-{
- Point aPos;
- Size aSize;
- GetFieldBtnPosSize(nIndex, aPos, aSize);
- return aPos;
-}
-
-bool ScDPDataFieldControl::GetFieldIndex(const Point& rPos, size_t& rnIndex)
-{
- size_t nCol, nRow;
- GetFieldBtnColRow(rPos, nCol, nRow);
- nCol += static_cast<size_t>(maScroll.GetThumbPos());
- size_t nIndex = nCol * mnColumnBtnCount;
-
- nIndex += nRow;
- size_t nFldCount = GetFieldCount();
- if (nIndex >= nFldCount)
- nIndex = nFldCount;
-
- rnIndex = nIndex;
- return true;
-}
-
-Size ScDPDataFieldControl::GetFieldSize() const
-{
- Size aWndSize = GetSizePixel();
- long nFieldObjWidth = aWndSize.Width() / 2.0 - OUTER_MARGIN_HOR - DATA_FIELD_BTN_GAP/2;
- Size aFieldSize(nFieldObjWidth, FIELD_BTN_HEIGHT);
- return aFieldSize;
-}
-
-String ScDPDataFieldControl::GetDescription() const
-{
- return ScResId(STR_ACC_DATAPILOT_DATA_DESCR);
-}
-
-ScDPFieldType ScDPDataFieldControl::GetFieldType() const
-{
- return TYPE_DATA;
-}
-
-void ScDPDataFieldControl::ScrollToEnd()
-{
- maScroll.DoScroll(maScroll.GetRangeMax());
-}
-
-void ScDPDataFieldControl::ScrollToShowSelection()
-{
- long nNewOffset = CalcOffsetToShowSelection();
- if (nNewOffset != maScroll.GetThumbPos())
- maScroll.DoScroll(nNewOffset);
-}
-
-void ScDPDataFieldControl::ResetScrollBar()
-{
- long nOldMax = maScroll.GetRangeMax();
- long nNewMax = ceil(
- static_cast<double>(GetFieldCount()) / static_cast<double>(mnColumnBtnCount));
-
- if (nOldMax != nNewMax)
- {
- maScroll.SetRangeMax(nNewMax);
- if (nNewMax < nOldMax)
- {
- // We lost a column. Scroll to the right frame.
- long nNewOffset = CalcOffsetToShowSelection();
- nNewOffset -= 2;
- if (nNewOffset < 0)
- nNewOffset = 0;
- maScroll.DoScroll(nNewOffset);
- }
- }
-}
-
-void ScDPDataFieldControl::Paint(const Rectangle& /*rRect*/)
-{
- Redraw();
-}
-
-void ScDPDataFieldControl::DataChanged( const DataChangedEvent& rDCEvt )
-{
- ScDPFieldControlBase::DataChanged(rDCEvt);
-}
-
-void ScDPDataFieldControl::MouseButtonDown(const MouseEvent& rMEvt)
-{
- if (maScroll.IsVisible())
- {
- Rectangle aRect(maScroll.GetPosPixel(), maScroll.GetSizePixel());
- if (aRect.IsInside(rMEvt.GetPosPixel()))
- {
- maScroll.MouseButtonDown(rMEvt);
- return;
- }
- }
- ScDPFieldControlBase::MouseButtonDown(rMEvt);
-}
-
-void ScDPDataFieldControl::MouseButtonUp(const MouseEvent& rMEvt)
-{
- if (maScroll.IsVisible())
- {
- Rectangle aRect(maScroll.GetPosPixel(), maScroll.GetSizePixel());
- if (aRect.IsInside(rMEvt.GetPosPixel()))
- {
- maScroll.MouseButtonUp(rMEvt);
- return;
- }
- }
- ScDPFieldControlBase::MouseButtonUp(rMEvt);
-}
-
-void ScDPDataFieldControl::MouseMove(const MouseEvent& rMEvt)
-{
- if (maScroll.IsVisible())
- {
- Rectangle aRect(maScroll.GetPosPixel(), maScroll.GetSizePixel());
- if (aRect.IsInside(rMEvt.GetPosPixel()))
- {
- maScroll.MouseMove(rMEvt);
- return;
- }
- }
- ScDPFieldControlBase::MouseMove(rMEvt);
-}
-
-bool ScDPDataFieldControl::GetFieldBtnPosSize(size_t nPos, Point& rPos, Size& rSize)
-{
- if (nPos >= mnTotalBtnCount)
- return false;
-
- Size aFieldSize = GetFieldSize();
-
- size_t nCol = nPos / mnColumnBtnCount;
- size_t nRow = nPos % mnColumnBtnCount;
-
- long nX = OUTER_MARGIN_HOR + aFieldSize.Width() * nCol;
- if (nCol > 0)
- nX += DATA_FIELD_BTN_GAP * nCol;
-
- long nY = OUTER_MARGIN_VER + aFieldSize.Height() * nRow;
- if (nRow > 0)
- nY += DATA_FIELD_BTN_GAP * nRow;
-
- rPos = Point(nX, nY);
- rSize = aFieldSize;
- return true;
-}
-
-void ScDPDataFieldControl::GetFieldBtnColRow(const Point& rPos, size_t& rCol, size_t& rRow)
-{
- Size aSize = GetSizePixel();
- long nBtnH = GetFieldSize().Height();
-
- size_t nCol = (rPos.X() <= aSize.Width()/2.0) ? 0 : 1;
- size_t nRow = 0;
-
- long nVBound = OUTER_MARGIN_VER + nBtnH + DATA_FIELD_BTN_GAP;
- while (true)
- {
- if (rPos.Y() <= nVBound)
- break;
-
- nVBound += nBtnH + DATA_FIELD_BTN_GAP;
- if (nVBound > aSize.Height())
- break;
-
- ++nRow;
- }
-
- rCol = nCol;
- rRow = nRow;
-}
-
-long ScDPDataFieldControl::CalcOffsetToShowSelection()
-{
- long nOffset = maScroll.GetThumbPos();
- size_t nSel = GetSelectedField();
- size_t nLower = nOffset*mnColumnBtnCount;
- size_t nUpper = nLower + mnColumnBtnCount * 2 - 1;
- long nNewOffset = nOffset;
- if (nSel < nLower)
- {
- // scroll to left. The selected field should be in the left column.
- nNewOffset = floor(
- static_cast<double>(nSel) / static_cast<double>(mnColumnBtnCount));
- }
- else if (nUpper < nSel)
- {
- // scroll to right. The selected field should be in the right column.
- nNewOffset = floor(
- static_cast<double>(nSel) / static_cast<double>(mnColumnBtnCount))-1;
- }
- return nNewOffset;
-}
-
-void ScDPDataFieldControl::HandleScroll()
-{
- Redraw();
-}
-
-void ScDPDataFieldControl::Redraw()
-{
- VirtualDevice aVirDev;
- // #i97623# VirtualDevice is always LTR while other windows derive direction from parent
- aVirDev.EnableRTL( IsRTLEnabled() );
- aVirDev.SetMapMode( MAP_PIXEL );
-
- Point aPos0;
- Size aWndSize = GetSizePixel();
- Font aFont = GetFont();
- aFont.SetTransparent(true);
- aVirDev.SetFont(aFont);
- aVirDev.SetOutputSizePixel(aWndSize);
-
- DrawBackground(aVirDev);
-
- long nOffset = maScroll.GetThumbPos();
- FieldNames& rFields = GetFieldNames();
- {
- FieldNames::iterator itr = rFields.begin(), itrEnd = rFields.end();
- if (nOffset)
- ::std::advance(itr, nOffset*mnColumnBtnCount);
-
- for (size_t i = 0; itr != itrEnd; ++itr, ++i)
- {
- Point aFldPt;
- Size aFldSize;
- if (!GetFieldBtnPosSize(i, aFldPt, aFldSize))
- break;
-
- size_t nField = i + nOffset*mnColumnBtnCount;
- bool bFocus = HasFocus() && (nField == GetSelectedField());
- DrawField(aVirDev, Rectangle(aFldPt, aFldSize), *itr, bFocus);
- }
- }
-
- // Create a bitmap from the virtual device, and place that bitmap onto
- // this control.
- DrawBitmap(aPos0, aVirDev.GetBitmap(aPos0, aWndSize));
-
- DrawPaintables();
- DrawInvertSelection();
- UpdateStyle();
-}
-
-size_t ScDPDataFieldControl::CalcNewFieldIndex(SCsCOL nDX, SCsROW nDY) const
-{
- size_t nField = GetSelectedField();
- if (nField < mnColumnBtnCount)
- {
- // selected button in the first column.
- if (nDX < 0)
- // in the left most column. We can't move any more to the left.
- return nField;
- if (nField == 0 && nDY < 0)
- // at the top left most position. We can't move up any more.
- return nField;
- }
-
- size_t nFldCount = GetFieldCount();
- size_t nFirstInLastCol = nFldCount / mnColumnBtnCount * mnColumnBtnCount;
- if (nFirstInLastCol <= nField)
- {
- // selected button in the last column.
- if (nDX > 0)
- // can't move to the right any more.
- return nField;
- if (nDY > 0 && nField >= nFldCount)
- // at the last position. Can't move down any more.
- return nField;
- }
-
- nDY += nDX * mnColumnBtnCount;
- nField += nDY;
-
- if (nField >= nFldCount)
- // Don't exceed the upper bound.
- nField = nFldCount - 1;
- return nField;
-}
-
-size_t ScDPDataFieldControl::GetDisplayPosition(size_t nIndex) const
-{
- long nOffset = maScroll.GetThumbPos();
- size_t nLower = mnColumnBtnCount * nOffset;
- size_t nUpper = nLower + mnColumnBtnCount*2 - 1;
- if (nLower <= nIndex && nIndex <= nUpper)
- return nIndex - nLower;
-
- return INVALID_INDEX;
-}
-
-IMPL_LINK(ScDPDataFieldControl, ScrollHdl, ScrollBar*, EMPTYARG)
-{
- HandleScroll();
- return 0;
-}
-
-IMPL_LINK(ScDPDataFieldControl, EndScrollHdl, ScrollBar*, EMPTYARG)
-{
- HandleScroll();
- return 0;
-}
-
-#endif
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/fieldwnd.hxx b/sc/source/ui/inc/fieldwnd.hxx
index f501a3246db9..22defb671cd3 100644
--- a/sc/source/ui/inc/fieldwnd.hxx
+++ b/sc/source/ui/inc/fieldwnd.hxx
@@ -347,10 +347,6 @@ public:
// ============================================================================
-#define DATA_FIELD_NEW 1
-
-#if DATA_FIELD_NEW
-
class ScDPDataFieldControl : public ScDPHorFieldControl
{
public:
@@ -362,69 +358,6 @@ public:
virtual String GetDescription() const;
};
-#else
-
-class ScDPDataFieldControl : public ScDPFieldControlBase
-{
-public:
- ScDPDataFieldControl( ScDPLayoutDlg* pParent, const ResId& rResId, FixedText* pCaption );
- virtual ~ScDPDataFieldControl();
-
- virtual void CalcSize();
- virtual bool IsValidIndex( size_t nIndex ) const;
- virtual Point GetFieldPosition( size_t nIndex );
- virtual bool GetFieldIndex(const Point& rPos, size_t& rnIndex);
- virtual Size GetFieldSize() const;
- virtual String GetDescription() const;
- virtual ScDPFieldType GetFieldType() const;
- virtual void ScrollToEnd();
- virtual void ScrollToShowSelection();
- virtual void ResetScrollBar();
-
-public:
- virtual void Paint( const Rectangle& rRect );
- virtual void DataChanged( const DataChangedEvent& rDCEvt );
- virtual void MouseButtonDown( const MouseEvent& rMEvt );
- virtual void MouseButtonUp( const MouseEvent& rMEvt );
- virtual void MouseMove( const MouseEvent& rMEvt );
-
-protected:
- virtual void Redraw();
- virtual size_t CalcNewFieldIndex( SCsCOL nDX, SCsROW nDY ) const;
- virtual size_t GetDisplayPosition(size_t nIndex) const;
-
-private:
- /**
- * Get the size and position of specified field button.
- *
- * @param nPos position index of the field button. Note that this index
- * differs from field name index in that, the top left button
- * always has an index of 0 regardless off scroll offset.
- * @param rPos
- * @param rSize
- *
- * @return false if the position index is out-of-bound, or otherwise
- * invalid.
- */
- bool GetFieldBtnPosSize(size_t nPos, Point& rPos, Size& rSize);
- void GetFieldBtnColRow(const Point& rPos, size_t& rCol, size_t& rRow);
- long CalcOffsetToShowSelection();
- void HandleScroll();
-
- DECL_LINK(ScrollHdl, ScrollBar*);
- DECL_LINK(EndScrollHdl, ScrollBar*);
-
-private:
- ScrollBar maScroll;
- ScDPLayoutDlg* mpParent;
-
- long mnScrollMarginHeight; /// bottom scroll bar margin height.
- size_t mnColumnBtnCount; /// number of buttons per single column.
- size_t mnTotalBtnCount; /// number of total visible buttons
-};
-
-#endif
-
#endif // SC_FIELDWND_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */