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

more for conditional format dialog

Change-Id: Id99be4e98ae1cd57077ac6f3758ebdb9cfc5424c
üst f76aa663
...@@ -1234,8 +1234,9 @@ ...@@ -1234,8 +1234,9 @@
#define RID_SCDLG_SORTKEY (SC_DIALOGS_START + 157) #define RID_SCDLG_SORTKEY (SC_DIALOGS_START + 157)
#define RID_SCDLG_COLORSCALE (SC_DIALOGS_START + 158) #define RID_SCDLG_COLORSCALE (SC_DIALOGS_START + 158)
#define RID_SCDLG_DATABAR (SC_DIALOGS_START + 159) #define RID_SCDLG_DATABAR (SC_DIALOGS_START + 159)
#define RID_COND_ENTRY (SC_DIALOGS_START + 160)
#define SC_DIALOGS_END (SC_DIALOGS_START + 160) #define SC_DIALOGS_END (SC_DIALOGS_START + 161)
#ifndef STD_MASKCOLOR #ifndef STD_MASKCOLOR
#define STD_MASKCOLOR Color { Red = 0xFF00; Green = 0x0000; Blue = 0xFF00; } #define STD_MASKCOLOR Color { Red = 0xFF00; Green = 0x0000; Blue = 0xFF00; }
......
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
#include "condformatdlg.hxx" #include "condformatdlg.hxx"
#include "condformatdlg.hrc" #include "condformatdlg.hrc"
#include <vcl/vclevent.hxx>
#include "anyrefdg.hxx" #include "anyrefdg.hxx"
#include "document.hxx" #include "document.hxx"
#include "conditio.hxx" #include "conditio.hxx"
...@@ -36,8 +38,9 @@ ...@@ -36,8 +38,9 @@
#include <iostream> #include <iostream>
ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent): ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent):
Control(pParent, ScResId( CTRL_ENTRY ) ), Control(pParent, ScResId( RID_COND_ENTRY ) ),
mbActive(false), mbActive(false),
meType(CONDITION),
maLbType( this, ScResId( LB_TYPE ) ), maLbType( this, ScResId( LB_TYPE ) ),
maFtCondNr( this, ScResId( FT_COND_NR ) ), maFtCondNr( this, ScResId( FT_COND_NR ) ),
maFtCondition( this, ScResId( FT_CONDITION ) ), maFtCondition( this, ScResId( FT_CONDITION ) ),
...@@ -54,19 +57,13 @@ ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent): ...@@ -54,19 +57,13 @@ ScCondFrmtEntry::ScCondFrmtEntry(Window* pParent):
SwitchToType(COLLAPSED); SwitchToType(COLLAPSED);
FreeResource(); FreeResource();
maClickHdl = LINK( pParent, ScCondFormatList, EntrySelectHdl );
maLbType.SelectEntryPos(1); maLbType.SelectEntryPos(1);
maLbCondType.SelectEntryPos(0); maLbCondType.SelectEntryPos(0);
maEdVal2.Hide(); maEdVal2.Hide();
} }
long ScCondFrmtEntry::GetHeight() const
{
if(mbActive)
return 100;
else
return 10;
}
namespace { namespace {
rtl::OUString getTextForType(ScCondFormatEntryType eType) rtl::OUString getTextForType(ScCondFormatEntryType eType)
...@@ -83,21 +80,54 @@ rtl::OUString getTextForType(ScCondFormatEntryType eType) ...@@ -83,21 +80,54 @@ rtl::OUString getTextForType(ScCondFormatEntryType eType)
break; break;
} }
return rtl::OUString("");
}
rtl::OUString getExpression(sal_Int32 nIndex)
{
switch(nIndex)
{
case 0:
return rtl::OUString("=");
case 1:
return rtl::OUString("<");
case 2:
return rtl::OUString(">");
case 5:
return rtl::OUString("!=");
default:
return rtl::OUString("not yet supported");
}
return rtl::OUString(); return rtl::OUString();
} }
} }
long ScCondFrmtEntry::Notify( NotifyEvent& rNEvt )
{
if( rNEvt.GetType() == EVENT_MOUSEBUTTONDOWN )
{
std::cout << "ButtonDown " << std::endl;
ImplCallEventListenersAndHandler( VCLEVENT_WINDOW_MOUSEBUTTONDOWN, maClickHdl, this );
}
Control::Notify(rNEvt);
}
void ScCondFrmtEntry::SwitchToType( ScCondFormatEntryType eType ) void ScCondFrmtEntry::SwitchToType( ScCondFormatEntryType eType )
{ {
switch(eType) switch(eType)
{ {
case COLLAPSED: case COLLAPSED:
maLbType.Hide(); {
maFtCondition.SetText(getTextForType(meType)); maLbType.Hide();
maFtCondition.Show(); rtl::OUStringBuffer maCondText(getTextForType(meType));
maEdVal2.Hide(); maCondText.append(rtl::OUString(" "));
maEdVal1.Hide(); maCondText.append(getExpression(maLbCondType.GetSelectEntryPos()));
maFtCondition.SetText(maCondText.makeStringAndClear());
maFtCondition.Show();
maEdVal2.Hide();
maEdVal1.Hide();
}
break; break;
default: default:
maLbType.Show(); maLbType.Show();
...@@ -111,36 +141,33 @@ void ScCondFrmtEntry::SwitchToType( ScCondFormatEntryType eType ) ...@@ -111,36 +141,33 @@ void ScCondFrmtEntry::SwitchToType( ScCondFormatEntryType eType )
void ScCondFrmtEntry::Select() void ScCondFrmtEntry::Select()
{ {
mbActive = !mbActive; Size aSize = GetSizePixel();
aSize.Height() = 130;
SetSizePixel(aSize);
SetControlBackground(Color(COL_RED));
SwitchToType(meType);
}
if(mbActive) void ScCondFrmtEntry::Deselect()
{ {
Size aSize = GetSizePixel(); Size aSize = GetSizePixel();
aSize.Height() += 120; aSize.Height() = 40;
SetSizePixel(aSize); SetSizePixel(aSize);
SetControlBackground(Color(COL_RED)); SetControlBackground(GetSettings().GetStyleSettings().GetDialogColor());
SwitchToType(meType); SwitchToType(COLLAPSED);
}
else
{
Size aSize = GetSizePixel();
aSize.Height() = 60;
SetSizePixel(aSize);
SetControlBackground(GetSettings().GetStyleSettings().GetDialogColor());
SwitchToType(COLLAPSED);
}
} }
ScCondFormatList::ScCondFormatList(Window* pParent, const ResId& rResId): ScCondFormatList::ScCondFormatList(Window* pParent, const ResId& rResId):
Control(pParent, rResId), Control(pParent, rResId),
mbHasScrollBar(false), mbHasScrollBar(false),
mpScrollBar(NULL), mpScrollBar(new ScrollBar(this, WB_VERT )),
mnTopIndex(0) mnTopIndex(0)
{ {
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) ); maEntries.push_back( new ScCondFrmtEntry(this) );
maEntries.push_back( new ScCondFrmtEntry(this) ); maEntries.push_back( new ScCondFrmtEntry(this) );
maEntries[1].Select();
RecalcAll(); RecalcAll();
FreeResource(); FreeResource();
...@@ -148,10 +175,43 @@ ScCondFormatList::ScCondFormatList(Window* pParent, const ResId& rResId): ...@@ -148,10 +175,43 @@ ScCondFormatList::ScCondFormatList(Window* pParent, const ResId& rResId):
void ScCondFormatList::RecalcAll() void ScCondFormatList::RecalcAll()
{ {
sal_Int32 nTotalHeight = 0;
for(EntryContainer::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr)
{
nTotalHeight += itr->GetSizePixel().Height();
}
Size aCtrlSize = GetOutputSize();
long nSrcBarSize = GetSettings().GetStyleSettings().GetScrollBarSize();
if(nTotalHeight > GetSizePixel().Height())
{
mbHasScrollBar = true;
mpScrollBar->SetPosSizePixel(Point(aCtrlSize.Width() -nSrcBarSize, 0),
Size(nSrcBarSize, aCtrlSize.Height()) );
std::cout << "Need ScrollBar" << std::endl;
mpScrollBar->SetRangeMax(nTotalHeight);
mpScrollBar->SetVisibleSize(aCtrlSize.Height());
mpScrollBar->Show();
}
else
{
std::cout << "Don't need ScrollBar" << std::endl;
mbHasScrollBar = false;
mpScrollBar->Hide();
}
Point aPoint(0,0); Point aPoint(0,0);
for(EntryContainer::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr) for(EntryContainer::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr)
{ {
itr->SetPosPixel(aPoint); itr->SetPosPixel(aPoint);
Size aSize = itr->GetSizePixel();
if(mbHasScrollBar)
aSize.Width() = aCtrlSize.Width() - nSrcBarSize;
else
aSize.Width() = aCtrlSize.Width();
itr->SetSizePixel(aSize);
aPoint.Y() += itr->GetSizePixel().Height(); aPoint.Y() += itr->GetSizePixel().Height();
} }
} }
...@@ -183,6 +243,22 @@ IMPL_LINK_NOARG( ScCondFormatList, AddBtnHdl ) ...@@ -183,6 +243,22 @@ IMPL_LINK_NOARG( ScCondFormatList, AddBtnHdl )
return 0; return 0;
} }
IMPL_LINK( ScCondFormatList, EntrySelectHdl, ScCondFrmtEntry*, pEntry )
{
for(EntryContainer::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr)
{
itr->Deselect();
}
pEntry->Select();
RecalcAll();
return 0;
}
IMPL_LINK_NOARG( ScCondFormatList, ScrollHdl )
{
return 0;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
#define BTN_REMOVE 11 #define BTN_REMOVE 11
#define CTRL_LIST 12 #define CTRL_LIST 12
#define CTRL_ENTRY 13
#define LB_TYPE 14 #define LB_TYPE 14
#define FT_COND_NR 15 #define FT_COND_NR 15
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include "rangelst.hxx" #include "rangelst.hxx"
#include <boost/ptr_container/ptr_vector.hpp> #include <boost/ptr_container/ptr_vector.hpp>
#include <boost/scoped_ptr.hpp>
class ScDocument; class ScDocument;
class ScConditionalFormat; class ScConditionalFormat;
...@@ -54,6 +55,8 @@ private: ...@@ -54,6 +55,8 @@ private:
bool mbActive; bool mbActive;
ScCondFormatEntryType meType; ScCondFormatEntryType meType;
Link maClickHdl;
//general ui elements //general ui elements
ListBox maLbType; ListBox maLbType;
FixedText maFtCondNr; FixedText maFtCondNr;
...@@ -75,8 +78,10 @@ private: ...@@ -75,8 +78,10 @@ private:
public: public:
ScCondFrmtEntry( Window* pParent ); ScCondFrmtEntry( Window* pParent );
long GetHeight() const; virtual long Notify( NotifyEvent& rNEvt );
void Select(); void Select();
void Deselect();
}; };
class ScCondFormatList : public Control class ScCondFormatList : public Control
...@@ -86,7 +91,7 @@ private: ...@@ -86,7 +91,7 @@ private:
EntryContainer maEntries; EntryContainer maEntries;
bool mbHasScrollBar; bool mbHasScrollBar;
ScrollBar* mpScrollBar; boost::scoped_ptr<ScrollBar> mpScrollBar;
long mnTopIndex; long mnTopIndex;
void RecalcAll(); void RecalcAll();
...@@ -94,6 +99,8 @@ public: ...@@ -94,6 +99,8 @@ public:
ScCondFormatList( Window* pParent, const ResId& rResId ); ScCondFormatList( Window* pParent, const ResId& rResId );
DECL_LINK( AddBtnHdl, void* ); DECL_LINK( AddBtnHdl, void* );
DECL_LINK( ScrollHdl, void* );
DECL_LINK( EntrySelectHdl, ScCondFrmtEntry* );
}; };
......
...@@ -67,85 +67,86 @@ ModalDialog RID_SCDLG_CONDFORMAT ...@@ -67,85 +67,86 @@ ModalDialog RID_SCDLG_CONDFORMAT
Pos = MAP_APPFONT( 5, 20 ); Pos = MAP_APPFONT( 5, 20 );
Size = MAP_APPFONT( 190, 120 ); Size = MAP_APPFONT( 190, 120 );
Control CTRL_ENTRY };
{ };
Pos = MAP_APPFONT( 0, 0 );
Size = MAP_APPFONT( 190, 40 );
Border = TRUE;
FixedText FT_COND_NR Control RID_COND_ENTRY
{ {
Pos = MAP_APPFONT( 2, 2 ); Pos = MAP_APPFONT( 0, 0 );
Size = MAP_APPFONT( 30, 10 ); Size = MAP_APPFONT( 190, 40 );
Text [ en-US ] = "Condition"; Border = TRUE;
};
FixedText FT_CONDITION FixedText FT_COND_NR
{ {
Pos = MAP_APPFONT( 40, 2 ); Pos = MAP_APPFONT( 2, 2 );
Size = MAP_APPFONT( 30, 10 ); Size = MAP_APPFONT( 30, 10 );
}; Text [ en-US ] = "Condition";
};
ListBox LB_TYPE FixedText FT_CONDITION
{ {
Pos = MAP_APPFONT( 5, 15 ); Pos = MAP_APPFONT( 40, 2 );
Size = MAP_APPFONT( 40, 14 ); Size = MAP_APPFONT( 90, 10 );
Border = TRUE; };
DropDown = TRUE;
StringList [ en-US ] = ListBox LB_TYPE
{ {
"All Cells"; Pos = MAP_APPFONT( 5, 15 );
"Cell value is"; Size = MAP_APPFONT( 40, 14 );
"Formula is"; Border = TRUE;
}; DropDown = TRUE;
}; StringList [ en-US ] =
ListBox LB_CELLIS_TYPE {
{ "All Cells";
Pos = MAP_APPFONT( 50, 15 ); "Cell value is";
Size = MAP_APPFONT( 30, 14 ); "Formula is";
Border = TRUE; };
DropDown = TRUE; };
StringList [ en-US ] = ListBox LB_CELLIS_TYPE
{ {
"equal to"; Pos = MAP_APPFONT( 50, 15 );
"less than"; Size = MAP_APPFONT( 30, 14 );
"greater than"; Border = TRUE;
"less than or equal to"; DropDown = TRUE;
"greater than or equal to"; StringList [ en-US ] =
"not equal to"; {
"between"; "equal to";
"not between"; "less than";
}; "greater than";
}; "less than or equal to";
FixedText FT_STYLE "greater than or equal to";
{ "not equal to";
Pos = MAP_APPFONT( 10, 32 ); "between";
Size = MAP_APPFONT( 35, 14 ); "not between";
Text [ en-US ] = "Apply Style"; };
}; };
Edit ED_VAL1 FixedText FT_STYLE
{ {
Pos = MAP_APPFONT( 90, 15 ); Pos = MAP_APPFONT( 10, 32 );
Size = MAP_APPFONT( 70, 14 ); Size = MAP_APPFONT( 35, 14 );
Border = TRUE; Text [ en-US ] = "Apply Style";
}; };
Edit ED_VAL2 Edit ED_VAL1
{ {
Pos = MAP_APPFONT( 130, 15 ); Pos = MAP_APPFONT( 90, 15 );
Size = MAP_APPFONT( 30, 14 ); Size = MAP_APPFONT( 70, 14 );
Border = TRUE; Border = TRUE;
}; };
ListBox LB_STYLE Edit ED_VAL2
{ {
Pos = MAP_APPFONT( 50, 32 ); Pos = MAP_APPFONT( 130, 15 );
Size = MAP_APPFONT( 30, 14 ); Size = MAP_APPFONT( 30, 14 );
Border = TRUE; Border = TRUE;
DropDown = TRUE; };
StringList [ en-US ] = ListBox LB_STYLE
{ {
"New Style..."; Pos = MAP_APPFONT( 50, 32 );
}; Size = MAP_APPFONT( 30, 14 );
}; Border = TRUE;
DropDown = TRUE;
StringList [ en-US ] =
{
"New Style...";
}; };
}; };
}; };
......
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