Kaydet (Commit) a989a0b1 authored tarafından Caolán McNamara's avatar Caolán McNamara

fold ColorListBox and ColorLB together

Change-Id: I485109acd7cd4d6c2dc53e29f4b01bfc202a38f3
üst 760a198e
......@@ -207,7 +207,7 @@ public:
/************************************************************************/
class SAL_WARN_UNUSED SVX_DLLPUBLIC ColorListBox : public ListBox
class SAL_WARN_UNUSED SVX_DLLPUBLIC ColorLB : public ListBox
{
ImpColorList* pColorList; // separate liste, in case of user data are required from outside
Size aImageSize;
......@@ -217,9 +217,9 @@ class SAL_WARN_UNUSED SVX_DLLPUBLIC ColorListBox : public ListBox
SVT_DLLPRIVATE void ImplDestroyColorEntries();
public:
ColorListBox( vcl::Window* pParent,
ColorLB( vcl::Window* pParent,
WinBits nWinStyle = WB_BORDER );
virtual ~ColorListBox() override;
virtual ~ColorLB() override;
virtual void dispose() override;
virtual void UserDraw( const UserDrawEvent& rUDEvt ) override;
......@@ -233,7 +233,7 @@ public:
using ListBox::RemoveEntry;
void RemoveEntry( sal_Int32 nPos );
void Clear();
void CopyEntries( const ColorListBox& rBox );
void CopyEntries( const ColorLB& rBox );
using ListBox::GetEntryPos;
sal_Int32 GetEntryPos( const Color& rColor ) const;
......@@ -241,8 +241,23 @@ public:
void SelectEntry( const OUString& rStr )
{ ListBox::SelectEntry( rStr ); }
void SelectEntry( const Color& rColor );
Color GetSelectEntryColor() const;
void SelectEntry( const Color& rColor )
{
sal_Int32 nPos = GetEntryPos( rColor );
if ( nPos != LISTBOX_ENTRY_NOTFOUND )
ListBox::SelectEntryPos( nPos );
}
Color GetSelectEntryColor() const
{
sal_Int32 nPos = GetSelectEntryPos();
Color aColor;
if ( nPos != LISTBOX_ENTRY_NOTFOUND )
aColor = GetEntryColor( nPos );
return aColor;
}
using ListBox::IsEntrySelected;
bool IsEntrySelected(const Color& rColor) const
......@@ -254,38 +269,14 @@ public:
return false;
}
private:
ColorListBox( const ColorListBox& ) = delete;
ColorListBox& operator =( const ColorListBox& ) = delete;
};
inline void ColorListBox::SelectEntry( const Color& rColor )
{
sal_Int32 nPos = GetEntryPos( rColor );
if ( nPos != LISTBOX_ENTRY_NOTFOUND )
ListBox::SelectEntryPos( nPos );
}
inline Color ColorListBox::GetSelectEntryColor() const
{
sal_Int32 nPos = GetSelectEntryPos();
Color aColor;
if ( nPos != LISTBOX_ENTRY_NOTFOUND )
aColor = GetEntryColor( nPos );
return aColor;
}
class SAL_WARN_UNUSED SVX_DLLPUBLIC ColorLB : public ColorListBox
{
public:
ColorLB( vcl::Window* pParent, WinBits aWB ) : ColorListBox( pParent, aWB ) {}
void Fill( const XColorListRef &pTab );
void Append( const XColorEntry& rEntry );
void Modify( const XColorEntry& rEntry, sal_Int32 nPos );
private:
ColorLB( const ColorLB& ) = delete;
ColorLB& operator =( const ColorLB& ) = delete;
};
/************************************************************************/
......
......@@ -1127,7 +1127,7 @@ public:
explicit ImplColorListData( const Color& rColor ) : aColor( rColor ) { bColor = true; }
};
void ColorListBox::ImplInit()
void ColorLB::ImplInit()
{
pColorList = new ImpColorList();
......@@ -1137,26 +1137,26 @@ void ColorListBox::ImplInit()
SetUserItemSize( aImageSize );
}
void ColorListBox::ImplDestroyColorEntries()
void ColorLB::ImplDestroyColorEntries()
{
for ( size_t n = pColorList->size(); n; )
delete (*pColorList)[ --n ];
pColorList->clear();
}
ColorListBox::ColorListBox( vcl::Window* pParent, WinBits nWinStyle ) :
ColorLB::ColorLB( vcl::Window* pParent, WinBits nWinStyle ) :
ListBox( pParent, nWinStyle )
{
ImplInit();
SetEdgeBlending(true);
}
ColorListBox::~ColorListBox()
ColorLB::~ColorLB()
{
disposeOnce();
}
void ColorListBox::dispose()
void ColorLB::dispose()
{
if ( pColorList )
{
......@@ -1167,7 +1167,7 @@ void ColorListBox::dispose()
ListBox::dispose();
}
sal_Int32 ColorListBox::InsertEntry( const OUString& rStr, sal_Int32 nPos )
sal_Int32 ColorLB::InsertEntry( const OUString& rStr, sal_Int32 nPos )
{
nPos = ListBox::InsertEntry( rStr, nPos );
if ( nPos != LISTBOX_ERROR )
......@@ -1188,7 +1188,7 @@ sal_Int32 ColorListBox::InsertEntry( const OUString& rStr, sal_Int32 nPos )
return nPos;
}
sal_Int32 ColorListBox::InsertEntry( const Color& rColor, const OUString& rStr,
sal_Int32 ColorLB::InsertEntry( const Color& rColor, const OUString& rStr,
sal_Int32 nPos )
{
nPos = ListBox::InsertEntry( rStr, nPos );
......@@ -1210,7 +1210,7 @@ sal_Int32 ColorListBox::InsertEntry( const Color& rColor, const OUString& rStr,
return nPos;
}
void ColorListBox::RemoveEntry( sal_Int32 nPos )
void ColorLB::RemoveEntry( sal_Int32 nPos )
{
ListBox::RemoveEntry( nPos );
if ( 0 <= nPos && static_cast<size_t>(nPos) < pColorList->size() )
......@@ -1222,13 +1222,13 @@ void ColorListBox::RemoveEntry( sal_Int32 nPos )
}
}
void ColorListBox::Clear()
void ColorLB::Clear()
{
ImplDestroyColorEntries();
ListBox::Clear();
}
void ColorListBox::CopyEntries( const ColorListBox& rBox )
void ColorLB::CopyEntries( const ColorLB& rBox )
{
// Liste leeren
ImplDestroyColorEntries();
......@@ -1255,7 +1255,7 @@ void ColorListBox::CopyEntries( const ColorListBox& rBox )
}
}
sal_Int32 ColorListBox::GetEntryPos( const Color& rColor ) const
sal_Int32 ColorLB::GetEntryPos( const Color& rColor ) const
{
for( sal_Int32 n = (sal_Int32) pColorList->size(); n; )
{
......@@ -1266,7 +1266,7 @@ sal_Int32 ColorListBox::GetEntryPos( const Color& rColor ) const
return LISTBOX_ENTRY_NOTFOUND;
}
Color ColorListBox::GetEntryColor( sal_Int32 nPos ) const
Color ColorLB::GetEntryColor( sal_Int32 nPos ) const
{
Color aColor;
ImplColorListData* pData = ( 0 <= nPos && static_cast<size_t>(nPos) < pColorList->size() ) ?
......@@ -1276,7 +1276,7 @@ Color ColorListBox::GetEntryColor( sal_Int32 nPos ) const
return aColor;
}
void ColorListBox::UserDraw( const UserDrawEvent& rUDEvt )
void ColorLB::UserDraw( const UserDrawEvent& rUDEvt )
{
size_t nPos = rUDEvt.GetItemId();
ImplColorListData* pData = ( nPos < pColorList->size() ) ? (*pColorList)[ nPos ] : nullptr;
......
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