add gui elements for color scales
Change-Id: Ibab6b0755f668c56b2cb18056d28b2d662260bfd
This commit is contained in:
parent
633872e942
commit
9587d01488
4 changed files with 242 additions and 20 deletions
|
@ -30,14 +30,16 @@
|
|||
#include "condformatdlg.hrc"
|
||||
|
||||
#include <vcl/vclevent.hxx>
|
||||
#include <svl/style.hxx>
|
||||
|
||||
#include "anyrefdg.hxx"
|
||||
#include "document.hxx"
|
||||
#include "conditio.hxx"
|
||||
#include "stlpool.hxx"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent):
|
||||
ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent, ScDocument* pDoc):
|
||||
Control(pParent, ScResId( RID_COND_ENTRY ) ),
|
||||
mbActive(false),
|
||||
meType(CONDITION),
|
||||
|
@ -48,7 +50,17 @@ ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent):
|
|||
maEdVal1( this, ScResId( ED_VAL1 ) ),
|
||||
maEdVal2( this, ScResId( ED_VAL2 ) ),
|
||||
maFtStyle( this, ScResId( FT_STYLE ) ),
|
||||
maLbStyle( this, ScResId( LB_STYLE ) )
|
||||
maLbStyle( this, ScResId( LB_STYLE ) ),
|
||||
maLbColorFormat( this, ScResId( LB_COLOR_FORMAT ) ),
|
||||
maLbColScale2( this, ScResId( LB_COL_SCALE2 ) ),
|
||||
maLbColScale3( this, ScResId( LB_COL_SCALE3 ) ),
|
||||
maLbEntryTypeMin( this, ScResId( LB_TYPE_COL_SCALE ) ),
|
||||
maLbEntryTypeMiddle( this, ScResId( LB_TYPE_COL_SCALE ) ),
|
||||
maLbEntryTypeMax( this, ScResId( LB_TYPE_COL_SCALE ) ),
|
||||
maEdMin( this, ScResId( ED_COL_SCALE ) ),
|
||||
maEdMiddle( this, ScResId( ED_COL_SCALE ) ),
|
||||
maEdMax( this, ScResId( ED_COL_SCALE ) ),
|
||||
mpDoc(pDoc)
|
||||
{
|
||||
Size aSize = GetSizePixel();
|
||||
aSize.Height() = 40;
|
||||
|
@ -60,8 +72,22 @@ ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent):
|
|||
maClickHdl = LINK( pParent, ScCondFormatList, EntrySelectHdl );
|
||||
|
||||
maLbType.SelectEntryPos(1);
|
||||
maLbType.SetSelectHdl( LINK( this, ScCondFrmtEntry, TypeListHdl ) );
|
||||
maLbCondType.SelectEntryPos(0);
|
||||
maEdVal2.Hide();
|
||||
|
||||
SfxStyleSheetIterator aStyleIter( mpDoc->GetStyleSheetPool(), SFX_STYLE_FAMILY_PARA );
|
||||
for ( SfxStyleSheetBase* pStyle = aStyleIter.First(); pStyle; pStyle = aStyleIter.Next() )
|
||||
{
|
||||
rtl::OUString aName = pStyle->GetName();
|
||||
maLbStyle.InsertEntry( aName );
|
||||
}
|
||||
maLbStyle.SetSeparatorPos(0);
|
||||
maLbStyle.SelectEntryPos(1);
|
||||
|
||||
//disable entries for color formats
|
||||
maLbColorFormat.SelectEntryPos(0);
|
||||
SetCondType();
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
@ -107,10 +133,9 @@ long ScCondFrmtEntry::Notify( NotifyEvent& rNEvt )
|
|||
{
|
||||
if( rNEvt.GetType() == EVENT_MOUSEBUTTONDOWN )
|
||||
{
|
||||
std::cout << "ButtonDown " << std::endl;
|
||||
ImplCallEventListenersAndHandler( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, maClickHdl, this );
|
||||
}
|
||||
Control::Notify(rNEvt);
|
||||
return Control::Notify(rNEvt);
|
||||
}
|
||||
|
||||
void ScCondFrmtEntry::SwitchToType( ScCondFormatEntryType eType )
|
||||
|
@ -139,6 +164,67 @@ void ScCondFrmtEntry::SwitchToType( ScCondFormatEntryType eType )
|
|||
}
|
||||
}
|
||||
|
||||
void ScCondFrmtEntry::HideCondElements()
|
||||
{
|
||||
maEdVal1.Hide();
|
||||
maEdVal2.Hide();
|
||||
maLbStyle.Hide();
|
||||
maFtStyle.Hide();
|
||||
maLbCondType.Hide();
|
||||
}
|
||||
|
||||
void ScCondFrmtEntry::SetCondType()
|
||||
{
|
||||
maEdVal1.Show();
|
||||
maEdVal2.Show();
|
||||
maLbStyle.Show();
|
||||
maFtStyle.Show();
|
||||
HideColorScaleElements();
|
||||
HideDataBarElements();
|
||||
}
|
||||
|
||||
void ScCondFrmtEntry::HideColorScaleElements()
|
||||
{
|
||||
maLbColorFormat.Hide();
|
||||
maLbColScale2.Hide();
|
||||
maLbColScale3.Hide();
|
||||
maLbEntryTypeMin.Hide();
|
||||
maLbEntryTypeMiddle.Hide();
|
||||
maLbEntryTypeMax.Hide();
|
||||
maEdMin.Hide();
|
||||
maEdMiddle.Hide();
|
||||
maEdMax.Hide();
|
||||
}
|
||||
|
||||
void ScCondFrmtEntry::SetColorScaleType()
|
||||
{
|
||||
HideCondElements();
|
||||
HideDataBarElements();
|
||||
maLbColorFormat.Show();
|
||||
if(maLbColorFormat.GetSelectEntryPos() == 0)
|
||||
maLbColScale2.Show();
|
||||
else
|
||||
maLbColScale3.Show();
|
||||
maLbEntryTypeMin.Show();
|
||||
maLbEntryTypeMiddle.Show();
|
||||
maLbEntryTypeMax.Show();
|
||||
maEdMin.Show();
|
||||
maEdMiddle.Show();
|
||||
maEdMax.Show();
|
||||
}
|
||||
|
||||
void ScCondFrmtEntry::HideDataBarElements()
|
||||
{
|
||||
maLbColorFormat.Hide();
|
||||
}
|
||||
|
||||
void ScCondFrmtEntry::SetDataBarType()
|
||||
{
|
||||
HideCondElements();
|
||||
HideColorScaleElements();
|
||||
maLbColorFormat.Show();
|
||||
}
|
||||
|
||||
void ScCondFrmtEntry::Select()
|
||||
{
|
||||
Size aSize = GetSizePixel();
|
||||
|
@ -146,6 +232,7 @@ void ScCondFrmtEntry::Select()
|
|||
SetSizePixel(aSize);
|
||||
SetControlBackground(Color(COL_RED));
|
||||
SwitchToType(meType);
|
||||
mbActive = true;
|
||||
}
|
||||
|
||||
void ScCondFrmtEntry::Deselect()
|
||||
|
@ -155,19 +242,46 @@ void ScCondFrmtEntry::Deselect()
|
|||
SetSizePixel(aSize);
|
||||
SetControlBackground(GetSettings().GetStyleSettings().GetDialogColor());
|
||||
SwitchToType(COLLAPSED);
|
||||
mbActive = false;
|
||||
}
|
||||
|
||||
ScCondFormatList::ScCondFormatList(Window* pParent, const ResId& rResId):
|
||||
bool ScCondFrmtEntry::IsSelected() const
|
||||
{
|
||||
return mbActive;
|
||||
}
|
||||
|
||||
IMPL_LINK_NOARG(ScCondFrmtEntry, TypeListHdl)
|
||||
{
|
||||
sal_Int32 nPos = maLbType.GetSelectEntryPos();
|
||||
switch(nPos)
|
||||
{
|
||||
case 1:
|
||||
SetCondType();
|
||||
break;
|
||||
case 0:
|
||||
if(maLbColorFormat.GetSelectEntryPos() < 2)
|
||||
SetColorScaleType();
|
||||
else
|
||||
SetDataBarType();
|
||||
break;
|
||||
case 2:
|
||||
SetCondType();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
ScCondFormatList::ScCondFormatList(Window* pParent, const ResId& rResId, ScDocument* pDoc):
|
||||
Control(pParent, rResId),
|
||||
mbHasScrollBar(false),
|
||||
mpScrollBar(new ScrollBar(this, WB_VERT )),
|
||||
mnTopIndex(0)
|
||||
mnTopIndex(0),
|
||||
mpDoc(pDoc)
|
||||
{
|
||||
mpScrollBar->SetScrollHdl( LINK( this, ScCondFormatList, ScrollHdl ) );
|
||||
mpScrollBar->EnableDrag();
|
||||
maEntries.push_back( new ScCondFrmtEntry(this) );
|
||||
maEntries.push_back( new ScCondFrmtEntry(this) );
|
||||
maEntries.push_back( new ScCondFrmtEntry(this) );
|
||||
|
||||
RecalcAll();
|
||||
FreeResource();
|
||||
|
@ -216,13 +330,22 @@ void ScCondFormatList::RecalcAll()
|
|||
}
|
||||
}
|
||||
|
||||
void ScCondFormatList::DoScroll(long nDelta)
|
||||
{
|
||||
Point aNewPoint = mpScrollBar->GetPosPixel();
|
||||
Rectangle aRect(Point(), GetOutputSize());
|
||||
aRect.Right() -= mpScrollBar->GetSizePixel().Width();
|
||||
Scroll( 0, -nDelta, aRect );
|
||||
mpScrollBar->SetPosPixel(aNewPoint);
|
||||
}
|
||||
|
||||
ScCondFormatDlg::ScCondFormatDlg(Window* pParent, ScDocument* pDoc, ScConditionalFormat* pFormat, const ScRangeList& rRange):
|
||||
ModalDialog(pParent, ScResId( RID_SCDLG_CONDFORMAT )),
|
||||
maBtnAdd( this, ScResId( BTN_ADD ) ),
|
||||
maBtnRemove( this, ScResId( BTN_REMOVE ) ),
|
||||
maBtnOk( this, ScResId( BTN_OK ) ),
|
||||
maBtnCancel( this, ScResId( BTN_CANCEL ) ),
|
||||
maCondFormList( this, ScResId( CTRL_LIST ) ),
|
||||
maCondFormList( this, ScResId( CTRL_LIST ), pDoc ),
|
||||
mpDoc(pDoc),
|
||||
mpFormat(pFormat)
|
||||
{
|
||||
|
@ -234,11 +357,27 @@ ScCondFormatDlg::ScCondFormatDlg(Window* pParent, ScDocument* pDoc, ScConditiona
|
|||
aTitle.append(aRangeString);
|
||||
SetText(aTitle.makeStringAndClear());
|
||||
maBtnAdd.SetClickHdl( LINK( &maCondFormList, ScCondFormatList, AddBtnHdl ) );
|
||||
maBtnRemove.SetClickHdl( LINK( &maCondFormList, ScCondFormatList, RemoveBtnHdl ) );
|
||||
FreeResource();
|
||||
}
|
||||
|
||||
IMPL_LINK_NOARG( ScCondFormatList, AddBtnHdl )
|
||||
{
|
||||
maEntries.push_back( new ScCondFrmtEntry(this) );
|
||||
maEntries.push_back( new ScCondFrmtEntry(this, mpDoc) );
|
||||
RecalcAll();
|
||||
return 0;
|
||||
}
|
||||
|
||||
IMPL_LINK_NOARG( ScCondFormatList, RemoveBtnHdl )
|
||||
{
|
||||
for(EntryContainer::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr)
|
||||
{
|
||||
if(itr->IsSelected())
|
||||
{
|
||||
maEntries.erase(itr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
RecalcAll();
|
||||
return 0;
|
||||
}
|
||||
|
@ -256,7 +395,7 @@ IMPL_LINK( ScCondFormatList, EntrySelectHdl, ScCondFrmtEntry*, pEntry )
|
|||
|
||||
IMPL_LINK_NOARG( ScCondFormatList, ScrollHdl )
|
||||
{
|
||||
|
||||
DoScroll(mpScrollBar->GetDelta());
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,5 +44,11 @@
|
|||
#define ED_VAL2 19
|
||||
#define LB_STYLE 20
|
||||
#define FT_STYLE 21
|
||||
#define LB_COLOR_FORMAT 22
|
||||
|
||||
#define LB_COL_SCALE2 23
|
||||
#define LB_COL_SCALE3 24
|
||||
#define LB_TYPE_COL_SCALE 25
|
||||
#define ED_COL_SCALE 28
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
|
|
@ -68,20 +68,45 @@ private:
|
|||
Edit maEdVal2;
|
||||
FixedText maFtStyle;
|
||||
ListBox maLbStyle;
|
||||
|
||||
//color format ui elements
|
||||
ListBox maLbColorFormat;
|
||||
//color scale ui elements
|
||||
ListBox maLbColScale2;
|
||||
ListBox maLbColScale3;
|
||||
|
||||
ListBox maLbEntryTypeMin;
|
||||
ListBox maLbEntryTypeMiddle;
|
||||
ListBox maLbEntryTypeMax;
|
||||
|
||||
Edit maEdMin;
|
||||
Edit maEdMiddle;
|
||||
Edit maEdMax;
|
||||
|
||||
//data bar ui elements
|
||||
//
|
||||
//
|
||||
void SwitchToType(ScCondFormatEntryType eType);
|
||||
void SetCondType();
|
||||
void SetColorScaleType();
|
||||
void SetDataBarType();
|
||||
void HideCondElements();
|
||||
void HideColorScaleElements();
|
||||
void HideDataBarElements();
|
||||
|
||||
ScDocument* mpDoc;
|
||||
|
||||
DECL_LINK( TypeListHdl, void*);
|
||||
|
||||
public:
|
||||
ScCondFrmtEntry( Window* pParent );
|
||||
ScCondFrmtEntry( Window* pParent, ScDocument* pDoc );
|
||||
|
||||
virtual long Notify( NotifyEvent& rNEvt );
|
||||
|
||||
void Select();
|
||||
void Deselect();
|
||||
|
||||
bool IsSelected() const;
|
||||
};
|
||||
|
||||
class ScCondFormatList : public Control
|
||||
|
@ -94,11 +119,15 @@ private:
|
|||
boost::scoped_ptr<ScrollBar> mpScrollBar;
|
||||
long mnTopIndex;
|
||||
|
||||
ScDocument* mpDoc;
|
||||
|
||||
void RecalcAll();
|
||||
void DoScroll(long nDiff);
|
||||
public:
|
||||
ScCondFormatList( Window* pParent, const ResId& rResId );
|
||||
ScCondFormatList( Window* pParent, const ResId& rResId, ScDocument* pDoc );
|
||||
|
||||
DECL_LINK( AddBtnHdl, void* );
|
||||
DECL_LINK( RemoveBtnHdl, void* );
|
||||
DECL_LINK( ScrollHdl, void* );
|
||||
DECL_LINK( EntrySelectHdl, ScCondFrmtEntry* );
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ ModalDialog RID_SCDLG_CONDFORMAT
|
|||
{
|
||||
Pos = MAP_APPFONT( 5, 20 );
|
||||
Size = MAP_APPFONT( 190, 120 );
|
||||
|
||||
Border = TRUE;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -92,7 +92,7 @@ Control RID_COND_ENTRY
|
|||
ListBox LB_TYPE
|
||||
{
|
||||
Pos = MAP_APPFONT( 5, 15 );
|
||||
Size = MAP_APPFONT( 40, 14 );
|
||||
Size = MAP_APPFONT( 40, 40 );
|
||||
Border = TRUE;
|
||||
DropDown = TRUE;
|
||||
StringList [ en-US ] =
|
||||
|
@ -105,7 +105,7 @@ Control RID_COND_ENTRY
|
|||
ListBox LB_CELLIS_TYPE
|
||||
{
|
||||
Pos = MAP_APPFONT( 50, 15 );
|
||||
Size = MAP_APPFONT( 30, 14 );
|
||||
Size = MAP_APPFONT( 30, 40 );
|
||||
Border = TRUE;
|
||||
DropDown = TRUE;
|
||||
StringList [ en-US ] =
|
||||
|
@ -129,19 +129,19 @@ Control RID_COND_ENTRY
|
|||
Edit ED_VAL1
|
||||
{
|
||||
Pos = MAP_APPFONT( 90, 15 );
|
||||
Size = MAP_APPFONT( 70, 14 );
|
||||
Size = MAP_APPFONT( 70, 12 );
|
||||
Border = TRUE;
|
||||
};
|
||||
Edit ED_VAL2
|
||||
{
|
||||
Pos = MAP_APPFONT( 130, 15 );
|
||||
Size = MAP_APPFONT( 30, 14 );
|
||||
Size = MAP_APPFONT( 30, 12 );
|
||||
Border = TRUE;
|
||||
};
|
||||
ListBox LB_STYLE
|
||||
{
|
||||
Pos = MAP_APPFONT( 50, 32 );
|
||||
Size = MAP_APPFONT( 30, 14 );
|
||||
Size = MAP_APPFONT( 30, 40 );
|
||||
Border = TRUE;
|
||||
DropDown = TRUE;
|
||||
StringList [ en-US ] =
|
||||
|
@ -149,6 +149,54 @@ Control RID_COND_ENTRY
|
|||
"New Style...";
|
||||
};
|
||||
};
|
||||
ListBox LB_COLOR_FORMAT
|
||||
{
|
||||
Pos = MAP_APPFONT( 50, 15 );
|
||||
Size = MAP_APPFONT( 60, 40);
|
||||
Border = TRUE;
|
||||
DropDown = TRUE;
|
||||
StringList [ en-US ] =
|
||||
{
|
||||
"Color Scale (2 Entries)";
|
||||
"Color Scale (3 Entries)";
|
||||
"Data Bar";
|
||||
};
|
||||
};
|
||||
ListBox LB_COL_SCALE2
|
||||
{
|
||||
Pos = MAP_APPFONT( 120, 15 );
|
||||
Size = MAP_APPFONT( 60, 40 );
|
||||
Border = TRUE;
|
||||
DropDown = TRUE;
|
||||
};
|
||||
ListBox LB_COL_SCALE3
|
||||
{
|
||||
Pos = MAP_APPFONT( 120, 15 );
|
||||
Size = MAP_APPFONT( 60, 40 );
|
||||
Border = TRUE;
|
||||
DropDown = TRUE;
|
||||
};
|
||||
ListBox LB_TYPE_COL_SCALE
|
||||
{
|
||||
Pos = MAP_APPFONT( 5, 32 );
|
||||
Size = MAP_APPFONT( 40, 40 );
|
||||
Border = TRUE;
|
||||
DropDown = TRUE;
|
||||
StringList [ en-US ] =
|
||||
{
|
||||
"Min";
|
||||
"Max";
|
||||
"Percentile";
|
||||
"Value";
|
||||
"Percent";
|
||||
"Formula";
|
||||
};
|
||||
};
|
||||
Edit ED_COL_SCALE
|
||||
{
|
||||
Pos = MAP_APPFONT( 5, 50 );
|
||||
Size = MAP_APPFONT( 40, 12 );
|
||||
};
|
||||
};
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
|
Loading…
Reference in a new issue