diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-06-08 09:38:01 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-06-11 08:01:25 +0200 |
commit | c161e8a5a816f649e21105b09723f620336507ac (patch) | |
tree | 2b4f32a305861f3ac8a673c341874d0146a0aa41 /sc | |
parent | add data bar ui elements (diff) | |
download | core-c161e8a5a816f649e21105b09723f620336507ac.tar.gz core-c161e8a5a816f649e21105b09723f620336507ac.zip |
more support for data bars in new dialogs
Change-Id: I2292517a060a12c1d0dffd70558afc8a57e89754
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/condformat/colorformat.cxx | 120 | ||||
-rw-r--r-- | sc/source/ui/condformat/condformatdlg.cxx | 35 | ||||
-rw-r--r-- | sc/source/ui/inc/colorformat.hxx | 9 | ||||
-rw-r--r-- | sc/source/ui/inc/condformatdlg.hrc | 2 | ||||
-rw-r--r-- | sc/source/ui/inc/condformatdlg.hxx | 7 | ||||
-rw-r--r-- | sc/source/ui/src/condformatdlg.src | 5 |
6 files changed, 163 insertions, 15 deletions
diff --git a/sc/source/ui/condformat/colorformat.cxx b/sc/source/ui/condformat/colorformat.cxx index 745d123c915c..de45815416b1 100644 --- a/sc/source/ui/condformat/colorformat.cxx +++ b/sc/source/ui/condformat/colorformat.cxx @@ -33,6 +33,7 @@ #include <svx/xtable.hxx> #include <svx/drawitem.hxx> +#include <vcl/msgbox.hxx> ScDataBarSettingsDlg::ScDataBarSettingsDlg(Window* pWindow): ModalDialog( pWindow, ScResId( RID_SCDLG_DATABAR ) ), @@ -66,7 +67,7 @@ ScDataBarSettingsDlg::ScDataBarSettingsDlg(Window* pWindow): namespace { -void SetType(ScColorScaleEntry* pEntry, ListBox& aLstBox) +void SetType(const ScColorScaleEntry* pEntry, ListBox& aLstBox) { if(pEntry->GetMin()) aLstBox.SelectEntryPos(0); @@ -82,6 +83,37 @@ void SetType(ScColorScaleEntry* pEntry, ListBox& aLstBox) aLstBox.SelectEntryPos(4); } +void GetType(const ListBox& rLstBox, const Edit& rEd, ScColorScaleEntry* pEntry ) +{ + double nVal = 0; + switch(rLstBox.GetSelectEntryPos()) + { + case 0: + pEntry->SetMin(true); + break; + case 1: + pEntry->SetMax(true); + break; + case 2: + pEntry->SetPercentile(true); + nVal = rtl::math::stringToDouble(rEd.GetText(), '.', ','); + pEntry->SetValue(nVal); + break; + case 3: + nVal = rtl::math::stringToDouble(rEd.GetText(), '.', ','); + pEntry->SetPercent(true); + pEntry->SetValue(nVal); + break; + case 4: + //FIXME + break; + case 5: + nVal = rtl::math::stringToDouble(rEd.GetText(), '.', ','); + pEntry->SetValue(nVal); + break; + } +} + void SetValue( ScColorScaleEntry* pEntry, Edit& aEdit) { if(pEntry->HasFormula()) @@ -94,6 +126,53 @@ void SetValue( ScColorScaleEntry* pEntry, Edit& aEdit) } +ScDataBarSettingsDlg::ScDataBarSettingsDlg(Window* pWindow, const ScDataBarFormatData& rData): + ModalDialog( pWindow, ScResId( RID_SCDLG_DATABAR ) ), + maBtnOk( this, ScResId( BTN_OK ) ), + maBtnCancel( this, ScResId( BTN_CANCEL ) ), + maFlBarColors( this, ScResId( FL_BAR_COLORS ) ), + maFlAxes( this, ScResId( FL_AXIS ) ), + maFlValues( this, ScResId( FL_VALUES ) ), + maFtMin( this, ScResId( FT_MINIMUM ) ), + maFtMax( this, ScResId( FT_MAXIMUM ) ), + maFtPositive( this, ScResId( FT_POSITIVE ) ), + maFtNegative( this, ScResId( FT_NEGATIVE ) ), + maFtPosition( this, ScResId( FT_POSITION ) ), + maFtAxisColor( this, ScResId( FT_COLOR_AXIS ) ), + maLbPos( this, ScResId( LB_POS ) ), + maLbNeg( this, ScResId( LB_NEG ) ), + maLbAxisCol( this, ScResId( LB_COL_AXIS ) ), + maLbTypeMin( this, ScResId( LB_TYPE ) ), + maLbTypeMax( this, ScResId( LB_TYPE ) ), + maLbAxisPos( this, ScResId( LB_AXIS_POSITION ) ), + maEdMin( this, ScResId( ED_MIN ) ), + maEdMax( this, ScResId( ED_MAX ) ) +{ + Init(); + FreeResource(); + + maLbPos.SelectEntry( rData.maPositiveColor ); + if(rData.mpNegativeColor) + maLbNeg.SelectEntry( *rData.mpNegativeColor ); + + switch (rData.meAxisPosition) + { + case databar::NONE: + maLbAxisPos.SelectEntryPos(2); + break; + case databar::AUTOMATIC: + maLbAxisPos.SelectEntryPos(0); + break; + case databar::MIDDLE: + maLbAxisPos.SelectEntryPos(1); + break; + } + ::SetType(rData.mpLowerLimit.get(), maLbTypeMin); + ::SetType(rData.mpUpperLimit.get(), maLbTypeMax); + SetValue(rData.mpLowerLimit.get(), maEdMin); + SetValue(rData.mpUpperLimit.get(), maEdMax); +} + ScDataBarSettingsDlg::ScDataBarSettingsDlg(Window* pWindow, ScDataBarFormat* pFormat): ModalDialog( pWindow, ScResId( RID_SCDLG_DATABAR ) ), maBtnOk( this, ScResId( BTN_OK ) ), @@ -188,6 +267,43 @@ void ScDataBarSettingsDlg::Init() maLbTypeMax.SetPosPixel(aPoint); } +namespace { + +void GetAxesPosition(ScDataBarFormatData* pData, const ListBox& rLbox) +{ + switch(rLbox.GetSelectEntryPos()) + { + case 0: + pData->meAxisPosition = databar::AUTOMATIC; + break; + case 1: + pData->meAxisPosition = databar::MIDDLE; + break; + case 2: + pData->meAxisPosition = databar::NONE; + break; + } +} + + +} + +ScDataBarFormatData* ScDataBarSettingsDlg::GetData() +{ + ScDataBarFormatData* pData = new ScDataBarFormatData(); + pData->maPositiveColor = maLbPos.GetSelectEntryColor(); + pData->mpNegativeColor.reset(new Color(maLbNeg.GetSelectEntryColor())); + pData->mbGradient = true; //FIXME + pData->mpUpperLimit.reset(new ScColorScaleEntry()); + pData->mpLowerLimit.reset(new ScColorScaleEntry()); + + ::GetType(maLbTypeMin, maEdMin, pData->mpLowerLimit.get()); + ::GetType(maLbTypeMax, maEdMax, pData->mpUpperLimit.get()); + GetAxesPosition(pData, maLbAxisPos); + + return pData; +} + IMPL_LINK_NOARG( ScDataBarSettingsDlg, OkBtnHdl ) { //check that min < max @@ -216,7 +332,7 @@ IMPL_LINK_NOARG( ScDataBarSettingsDlg, OkBtnHdl ) } else { - Close(); + EndDialog(RET_OK); } return 0; } diff --git a/sc/source/ui/condformat/condformatdlg.cxx b/sc/source/ui/condformat/condformatdlg.cxx index 2f4675409058..6f13586a9944 100644 --- a/sc/source/ui/condformat/condformatdlg.cxx +++ b/sc/source/ui/condformat/condformatdlg.cxx @@ -36,6 +36,7 @@ #include <svl/intitem.hxx> #include <svx/xtable.hxx> #include <svx/drawitem.hxx> +#include <vcl/msgbox.hxx> #include "anyrefdg.hxx" #include "document.hxx" @@ -44,6 +45,7 @@ #include "tabvwsh.hxx" #include "conditio.hxx" #include "colorscale.hxx" +#include "colorformat.hxx" #include <rtl/math.hxx> @@ -164,6 +166,11 @@ ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc, const ScForm maLbColMin( this, ScResId( LB_COL) ), maLbColMiddle( this, ScResId( LB_COL) ), maLbColMax( this, ScResId( LB_COL) ), + maLbDataBarMinType( this, ScResId( LB_TYPE_COL_SCALE ) ), + maLbDataBarMaxType( this, ScResId( LB_TYPE_COL_SCALE ) ), + maEdDataBarMin( this, ScResId( ED_COL_SCALE ) ), + maEdDataBarMax( this, ScResId( ED_COL_SCALE ) ), + maBtOptions( this, ScResId( BTN_OPTIONS ) ), mpDoc(pDoc) { SetControlBackground(GetSettings().GetStyleSettings().GetDialogColor()); @@ -240,6 +247,7 @@ ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc, const ScForm else if( pFormatEntry && pFormatEntry->GetType() == condformat::DATABAR ) { const ScDataBarFormat* pEntry = static_cast<const ScDataBarFormat*>(pFormatEntry); + mpDataBarData.reset(new ScDataBarFormatData(*pEntry->GetDataBarData())); maLbType.SelectEntryPos(0); maLbColorFormat.SelectEntryPos(2); SetDataBarType(); @@ -250,6 +258,10 @@ ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc, const ScForm SetHeight(); } +ScCondFrmtEntry::~ScCondFrmtEntry() +{ +} + void ScCondFrmtEntry::Init() { maLbType.SetSelectHdl( LINK( this, ScCondFrmtEntry, TypeListHdl ) ); @@ -266,15 +278,18 @@ void ScCondFrmtEntry::Init() Point aPointEd = maEdMiddle.GetPosPixel(); Point aPointCol = maLbColMiddle.GetPosPixel(); Point aPointEdDataBar = maEdDataBarMin.GetPosPixel(); + Point aPointLbDataBar = maLbDataBarMaxType.GetPosPixel(); const long nMovePos = 150; aPointLb.X() += nMovePos; aPointEd.X() += nMovePos; aPointCol.X() += nMovePos; aPointEdDataBar.X() += 1.5*nMovePos; + aPointLbDataBar.X() += 1.5*nMovePos; maLbEntryTypeMiddle.SetPosPixel(aPointLb); maEdMiddle.SetPosPixel(aPointEd); maLbColMiddle.SetPosPixel(aPointCol); maEdDataBarMin.SetPosPixel(aPointEdDataBar); + maLbDataBarMaxType.SetPosPixel(aPointLbDataBar); aPointLb.X() += nMovePos; aPointEd.X() += nMovePos; aPointCol.X() += nMovePos; @@ -319,6 +334,14 @@ void ScCondFrmtEntry::Init() maLbColMiddle.SetUpdateMode( sal_True ); maLbColMax.SetUpdateMode( sal_True ); } + + maBtOptions.SetClickHdl( LINK( this, ScCondFrmtEntry, OptionBtnHdl ) ); + + mpDataBarData.reset(new ScDataBarFormatData()); + mpDataBarData->mpUpperLimit.reset(new ScColorScaleEntry()); + mpDataBarData->mpLowerLimit.reset(new ScColorScaleEntry()); + mpDataBarData->mpLowerLimit->SetMin(true); + mpDataBarData->mpUpperLimit->SetMax(true); } namespace { @@ -445,7 +468,7 @@ void ScCondFrmtEntry::SetHeight() aSize.Height() = 200; break; case DATABAR: - aSize.Height() = 120; + aSize.Height() = 200; break; default: break; @@ -637,7 +660,7 @@ ScFormatEntry* ScCondFrmtEntry::createColorscaleEntry() const ScFormatEntry* ScCondFrmtEntry::createDatabarEntry() const { ScDataBarFormat* pDataBar = new ScDataBarFormat(mpDoc); - pDataBar->SetDataBarData(new ScDataBarFormatData()); + pDataBar->SetDataBarData(new ScDataBarFormatData(*mpDataBarData.get())); return pDataBar; } @@ -753,8 +776,12 @@ IMPL_LINK_NOARG(ScCondFrmtEntry, StyleSelectHdl) IMPL_LINK_NOARG( ScCondFrmtEntry, OptionBtnHdl ) { - ScDataBarSettingsDlg* pDlg = new ScDataBarSettingsDlg(this); - pDlg->Execute(); + ScDataBarSettingsDlg* pDlg = new ScDataBarSettingsDlg(this, *mpDataBarData); + if( pDlg->Execute() == RET_OK) + { + std::cout << "Ok" << std::endl; + mpDataBarData.reset(pDlg->GetData()); + } return 0; } diff --git a/sc/source/ui/inc/colorformat.hxx b/sc/source/ui/inc/colorformat.hxx index e89c3ed9fdb6..4fe44f9ba470 100644 --- a/sc/source/ui/inc/colorformat.hxx +++ b/sc/source/ui/inc/colorformat.hxx @@ -33,11 +33,7 @@ #include "anyrefdg.hxx" class ScDataBarFormat; - -class ScColorScaleSettingsDlg : public ModalDialog -{ - -}; +struct ScDataBarFormatData; class ScDataBarSettingsDlg : public ModalDialog { @@ -72,7 +68,10 @@ private: public: ScDataBarSettingsDlg(Window* pParent); + ScDataBarSettingsDlg(Window* pParent, const ScDataBarFormatData& rData); ScDataBarSettingsDlg(Window* pParent, ScDataBarFormat* pFormat); + + ScDataBarFormatData* GetData(); }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/condformatdlg.hrc b/sc/source/ui/inc/condformatdlg.hrc index 87f8944243a0..045b21525753 100644 --- a/sc/source/ui/inc/condformatdlg.hrc +++ b/sc/source/ui/inc/condformatdlg.hrc @@ -52,6 +52,6 @@ #define ED_COL_SCALE 28 #define WD_PREVIEW 26 #define LB_COL 27 -#define BTN_OPTIONS 28 +#define BTN_OPTIONS 30 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/inc/condformatdlg.hxx b/sc/source/ui/inc/condformatdlg.hxx index f44e6c875099..d1f80a925e7c 100644 --- a/sc/source/ui/inc/condformatdlg.hxx +++ b/sc/source/ui/inc/condformatdlg.hxx @@ -44,6 +44,7 @@ class ScDocument; class ScConditionalFormat; class ScFormatEntry; class ScConditionalFormat; +struct ScDataBarFormatData; enum ScCondFormatEntryType { @@ -97,7 +98,9 @@ private: ListBox maLbDataBarMaxType; Edit maEdDataBarMin; Edit maEdDataBarMax; - Button maBtOptions; + PushButton maBtOptions; + + boost::scoped_ptr<ScDataBarFormatData> mpDataBarData; // void SwitchToType(ScCondFormatEntryType eType); @@ -121,10 +124,12 @@ private: DECL_LINK( TypeListHdl, void*); DECL_LINK( ColFormatTypeHdl, void*); DECL_LINK( StyleSelectHdl, void* ); + DECL_LINK( OptionBtnHdl, void* ); public: ScCondFrmtEntry( Window* pParent, ScDocument* pDoc ); ScCondFrmtEntry( Window* pParent, ScDocument* pDoc, const ScFormatEntry* pFormatEntry ); + virtual ~ScCondFrmtEntry(); virtual long Notify( NotifyEvent& rNEvt ); diff --git a/sc/source/ui/src/condformatdlg.src b/sc/source/ui/src/condformatdlg.src index ecac52bf2694..48aa50c4a85b 100644 --- a/sc/source/ui/src/condformatdlg.src +++ b/sc/source/ui/src/condformatdlg.src @@ -215,10 +215,11 @@ Control RID_COND_ENTRY DropDown = TRUE; DDExtraWidth = TRUE; }; - Button BTN_OPTIONS + PushButton BTN_OPTIONS { - Pos = MAP_APPFONT( 120 , 62 ); + Pos = MAP_APPFONT( 120, 62 ); Size = MAP_APPFONT( 60, 14 ); + Text [ en-US ] = "More options ..."; }; }; |