Kaydet (Commit) c161e8a5 authored tarafından Markus Mohrhard's avatar Markus Mohrhard

more support for data bars in new dialogs

Change-Id: I2292517a060a12c1d0dffd70558afc8a57e89754
üst 3d193574
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <svx/xtable.hxx> #include <svx/xtable.hxx>
#include <svx/drawitem.hxx> #include <svx/drawitem.hxx>
#include <vcl/msgbox.hxx>
ScDataBarSettingsDlg::ScDataBarSettingsDlg(Window* pWindow): ScDataBarSettingsDlg::ScDataBarSettingsDlg(Window* pWindow):
ModalDialog( pWindow, ScResId( RID_SCDLG_DATABAR ) ), ModalDialog( pWindow, ScResId( RID_SCDLG_DATABAR ) ),
...@@ -66,7 +67,7 @@ ScDataBarSettingsDlg::ScDataBarSettingsDlg(Window* pWindow): ...@@ -66,7 +67,7 @@ ScDataBarSettingsDlg::ScDataBarSettingsDlg(Window* pWindow):
namespace { namespace {
void SetType(ScColorScaleEntry* pEntry, ListBox& aLstBox) void SetType(const ScColorScaleEntry* pEntry, ListBox& aLstBox)
{ {
if(pEntry->GetMin()) if(pEntry->GetMin())
aLstBox.SelectEntryPos(0); aLstBox.SelectEntryPos(0);
...@@ -82,6 +83,37 @@ void SetType(ScColorScaleEntry* pEntry, ListBox& aLstBox) ...@@ -82,6 +83,37 @@ void SetType(ScColorScaleEntry* pEntry, ListBox& aLstBox)
aLstBox.SelectEntryPos(4); 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) void SetValue( ScColorScaleEntry* pEntry, Edit& aEdit)
{ {
if(pEntry->HasFormula()) if(pEntry->HasFormula())
...@@ -94,6 +126,53 @@ void SetValue( ScColorScaleEntry* pEntry, Edit& aEdit) ...@@ -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): ScDataBarSettingsDlg::ScDataBarSettingsDlg(Window* pWindow, ScDataBarFormat* pFormat):
ModalDialog( pWindow, ScResId( RID_SCDLG_DATABAR ) ), ModalDialog( pWindow, ScResId( RID_SCDLG_DATABAR ) ),
maBtnOk( this, ScResId( BTN_OK ) ), maBtnOk( this, ScResId( BTN_OK ) ),
...@@ -188,6 +267,43 @@ void ScDataBarSettingsDlg::Init() ...@@ -188,6 +267,43 @@ void ScDataBarSettingsDlg::Init()
maLbTypeMax.SetPosPixel(aPoint); 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 ) IMPL_LINK_NOARG( ScDataBarSettingsDlg, OkBtnHdl )
{ {
//check that min < max //check that min < max
...@@ -216,7 +332,7 @@ IMPL_LINK_NOARG( ScDataBarSettingsDlg, OkBtnHdl ) ...@@ -216,7 +332,7 @@ IMPL_LINK_NOARG( ScDataBarSettingsDlg, OkBtnHdl )
} }
else else
{ {
Close(); EndDialog(RET_OK);
} }
return 0; return 0;
} }
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <svl/intitem.hxx> #include <svl/intitem.hxx>
#include <svx/xtable.hxx> #include <svx/xtable.hxx>
#include <svx/drawitem.hxx> #include <svx/drawitem.hxx>
#include <vcl/msgbox.hxx>
#include "anyrefdg.hxx" #include "anyrefdg.hxx"
#include "document.hxx" #include "document.hxx"
...@@ -44,6 +45,7 @@ ...@@ -44,6 +45,7 @@
#include "tabvwsh.hxx" #include "tabvwsh.hxx"
#include "conditio.hxx" #include "conditio.hxx"
#include "colorscale.hxx" #include "colorscale.hxx"
#include "colorformat.hxx"
#include <rtl/math.hxx> #include <rtl/math.hxx>
...@@ -164,6 +166,11 @@ ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc, const ScForm ...@@ -164,6 +166,11 @@ ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc, const ScForm
maLbColMin( this, ScResId( LB_COL) ), maLbColMin( this, ScResId( LB_COL) ),
maLbColMiddle( this, ScResId( LB_COL) ), maLbColMiddle( this, ScResId( LB_COL) ),
maLbColMax( 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) mpDoc(pDoc)
{ {
SetControlBackground(GetSettings().GetStyleSettings().GetDialogColor()); SetControlBackground(GetSettings().GetStyleSettings().GetDialogColor());
...@@ -240,6 +247,7 @@ ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc, const ScForm ...@@ -240,6 +247,7 @@ ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc, const ScForm
else if( pFormatEntry && pFormatEntry->GetType() == condformat::DATABAR ) else if( pFormatEntry && pFormatEntry->GetType() == condformat::DATABAR )
{ {
const ScDataBarFormat* pEntry = static_cast<const ScDataBarFormat*>(pFormatEntry); const ScDataBarFormat* pEntry = static_cast<const ScDataBarFormat*>(pFormatEntry);
mpDataBarData.reset(new ScDataBarFormatData(*pEntry->GetDataBarData()));
maLbType.SelectEntryPos(0); maLbType.SelectEntryPos(0);
maLbColorFormat.SelectEntryPos(2); maLbColorFormat.SelectEntryPos(2);
SetDataBarType(); SetDataBarType();
...@@ -250,6 +258,10 @@ ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc, const ScForm ...@@ -250,6 +258,10 @@ ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc, const ScForm
SetHeight(); SetHeight();
} }
ScCondFrmtEntry::~ScCondFrmtEntry()
{
}
void ScCondFrmtEntry::Init() void ScCondFrmtEntry::Init()
{ {
maLbType.SetSelectHdl( LINK( this, ScCondFrmtEntry, TypeListHdl ) ); maLbType.SetSelectHdl( LINK( this, ScCondFrmtEntry, TypeListHdl ) );
...@@ -266,15 +278,18 @@ void ScCondFrmtEntry::Init() ...@@ -266,15 +278,18 @@ void ScCondFrmtEntry::Init()
Point aPointEd = maEdMiddle.GetPosPixel(); Point aPointEd = maEdMiddle.GetPosPixel();
Point aPointCol = maLbColMiddle.GetPosPixel(); Point aPointCol = maLbColMiddle.GetPosPixel();
Point aPointEdDataBar = maEdDataBarMin.GetPosPixel(); Point aPointEdDataBar = maEdDataBarMin.GetPosPixel();
Point aPointLbDataBar = maLbDataBarMaxType.GetPosPixel();
const long nMovePos = 150; const long nMovePos = 150;
aPointLb.X() += nMovePos; aPointLb.X() += nMovePos;
aPointEd.X() += nMovePos; aPointEd.X() += nMovePos;
aPointCol.X() += nMovePos; aPointCol.X() += nMovePos;
aPointEdDataBar.X() += 1.5*nMovePos; aPointEdDataBar.X() += 1.5*nMovePos;
aPointLbDataBar.X() += 1.5*nMovePos;
maLbEntryTypeMiddle.SetPosPixel(aPointLb); maLbEntryTypeMiddle.SetPosPixel(aPointLb);
maEdMiddle.SetPosPixel(aPointEd); maEdMiddle.SetPosPixel(aPointEd);
maLbColMiddle.SetPosPixel(aPointCol); maLbColMiddle.SetPosPixel(aPointCol);
maEdDataBarMin.SetPosPixel(aPointEdDataBar); maEdDataBarMin.SetPosPixel(aPointEdDataBar);
maLbDataBarMaxType.SetPosPixel(aPointLbDataBar);
aPointLb.X() += nMovePos; aPointLb.X() += nMovePos;
aPointEd.X() += nMovePos; aPointEd.X() += nMovePos;
aPointCol.X() += nMovePos; aPointCol.X() += nMovePos;
...@@ -319,6 +334,14 @@ void ScCondFrmtEntry::Init() ...@@ -319,6 +334,14 @@ void ScCondFrmtEntry::Init()
maLbColMiddle.SetUpdateMode( sal_True ); maLbColMiddle.SetUpdateMode( sal_True );
maLbColMax.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 { namespace {
...@@ -445,7 +468,7 @@ void ScCondFrmtEntry::SetHeight() ...@@ -445,7 +468,7 @@ void ScCondFrmtEntry::SetHeight()
aSize.Height() = 200; aSize.Height() = 200;
break; break;
case DATABAR: case DATABAR:
aSize.Height() = 120; aSize.Height() = 200;
break; break;
default: default:
break; break;
...@@ -637,7 +660,7 @@ ScFormatEntry* ScCondFrmtEntry::createColorscaleEntry() const ...@@ -637,7 +660,7 @@ ScFormatEntry* ScCondFrmtEntry::createColorscaleEntry() const
ScFormatEntry* ScCondFrmtEntry::createDatabarEntry() const ScFormatEntry* ScCondFrmtEntry::createDatabarEntry() const
{ {
ScDataBarFormat* pDataBar = new ScDataBarFormat(mpDoc); ScDataBarFormat* pDataBar = new ScDataBarFormat(mpDoc);
pDataBar->SetDataBarData(new ScDataBarFormatData()); pDataBar->SetDataBarData(new ScDataBarFormatData(*mpDataBarData.get()));
return pDataBar; return pDataBar;
} }
...@@ -753,8 +776,12 @@ IMPL_LINK_NOARG(ScCondFrmtEntry, StyleSelectHdl) ...@@ -753,8 +776,12 @@ IMPL_LINK_NOARG(ScCondFrmtEntry, StyleSelectHdl)
IMPL_LINK_NOARG( ScCondFrmtEntry, OptionBtnHdl ) IMPL_LINK_NOARG( ScCondFrmtEntry, OptionBtnHdl )
{ {
ScDataBarSettingsDlg* pDlg = new ScDataBarSettingsDlg(this); ScDataBarSettingsDlg* pDlg = new ScDataBarSettingsDlg(this, *mpDataBarData);
pDlg->Execute(); if( pDlg->Execute() == RET_OK)
{
std::cout << "Ok" << std::endl;
mpDataBarData.reset(pDlg->GetData());
}
return 0; return 0;
} }
......
...@@ -33,11 +33,7 @@ ...@@ -33,11 +33,7 @@
#include "anyrefdg.hxx" #include "anyrefdg.hxx"
class ScDataBarFormat; class ScDataBarFormat;
struct ScDataBarFormatData;
class ScColorScaleSettingsDlg : public ModalDialog
{
};
class ScDataBarSettingsDlg : public ModalDialog class ScDataBarSettingsDlg : public ModalDialog
{ {
...@@ -72,7 +68,10 @@ private: ...@@ -72,7 +68,10 @@ private:
public: public:
ScDataBarSettingsDlg(Window* pParent); ScDataBarSettingsDlg(Window* pParent);
ScDataBarSettingsDlg(Window* pParent, const ScDataBarFormatData& rData);
ScDataBarSettingsDlg(Window* pParent, ScDataBarFormat* pFormat); ScDataBarSettingsDlg(Window* pParent, ScDataBarFormat* pFormat);
ScDataBarFormatData* GetData();
}; };
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -52,6 +52,6 @@ ...@@ -52,6 +52,6 @@
#define ED_COL_SCALE 28 #define ED_COL_SCALE 28
#define WD_PREVIEW 26 #define WD_PREVIEW 26
#define LB_COL 27 #define LB_COL 27
#define BTN_OPTIONS 28 #define BTN_OPTIONS 30
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -44,6 +44,7 @@ class ScDocument; ...@@ -44,6 +44,7 @@ class ScDocument;
class ScConditionalFormat; class ScConditionalFormat;
class ScFormatEntry; class ScFormatEntry;
class ScConditionalFormat; class ScConditionalFormat;
struct ScDataBarFormatData;
enum ScCondFormatEntryType enum ScCondFormatEntryType
{ {
...@@ -97,7 +98,9 @@ private: ...@@ -97,7 +98,9 @@ private:
ListBox maLbDataBarMaxType; ListBox maLbDataBarMaxType;
Edit maEdDataBarMin; Edit maEdDataBarMin;
Edit maEdDataBarMax; Edit maEdDataBarMax;
Button maBtOptions; PushButton maBtOptions;
boost::scoped_ptr<ScDataBarFormatData> mpDataBarData;
// //
void SwitchToType(ScCondFormatEntryType eType); void SwitchToType(ScCondFormatEntryType eType);
...@@ -121,10 +124,12 @@ private: ...@@ -121,10 +124,12 @@ private:
DECL_LINK( TypeListHdl, void*); DECL_LINK( TypeListHdl, void*);
DECL_LINK( ColFormatTypeHdl, void*); DECL_LINK( ColFormatTypeHdl, void*);
DECL_LINK( StyleSelectHdl, void* ); DECL_LINK( StyleSelectHdl, void* );
DECL_LINK( OptionBtnHdl, void* );
public: public:
ScCondFrmtEntry( Window* pParent, ScDocument* pDoc ); ScCondFrmtEntry( Window* pParent, ScDocument* pDoc );
ScCondFrmtEntry( Window* pParent, ScDocument* pDoc, const ScFormatEntry* pFormatEntry ); ScCondFrmtEntry( Window* pParent, ScDocument* pDoc, const ScFormatEntry* pFormatEntry );
virtual ~ScCondFrmtEntry();
virtual long Notify( NotifyEvent& rNEvt ); virtual long Notify( NotifyEvent& rNEvt );
......
...@@ -215,10 +215,11 @@ Control RID_COND_ENTRY ...@@ -215,10 +215,11 @@ Control RID_COND_ENTRY
DropDown = TRUE; DropDown = TRUE;
DDExtraWidth = TRUE; DDExtraWidth = TRUE;
}; };
Button BTN_OPTIONS PushButton BTN_OPTIONS
{ {
Pos = MAP_APPFONT( 120 , 62 ); Pos = MAP_APPFONT( 120, 62 );
Size = MAP_APPFONT( 60, 14 ); Size = MAP_APPFONT( 60, 14 );
Text [ en-US ] = "More options ...";
}; };
}; };
......
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