summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorPhilipp Lohmann [pl] <Philipp.Lohmann@Sun.COM>2009-12-18 15:29:59 +0100
committerPhilipp Lohmann [pl] <Philipp.Lohmann@Sun.COM>2009-12-18 15:29:59 +0100
commit460919060e77525e3ac3e94054fc0f17fae5ba17 (patch)
treec3c18e3e7ada68f1a4e009fe5a226178c68d11df /vcl
parenta0c826b44af446e44b7dc4e80919c1c7f00c2eee (diff)
vcl108: #i2446# add prominent entry style to listbox and combobox
Diffstat (limited to 'vcl')
-rw-r--r--vcl/inc/vcl/combobox.hxx4
-rw-r--r--vcl/inc/vcl/ilstbox.hxx10
-rw-r--r--vcl/inc/vcl/lstbox.hxx4
-rw-r--r--vcl/inc/vcl/wintypes.hxx6
-rw-r--r--vcl/source/control/combobox.cxx24
-rw-r--r--vcl/source/control/ilstbox.cxx27
-rw-r--r--vcl/source/control/lstbox.cxx21
7 files changed, 86 insertions, 10 deletions
diff --git a/vcl/inc/vcl/combobox.hxx b/vcl/inc/vcl/combobox.hxx
index d57d4b8a7372..cbceffaff6c0 100644
--- a/vcl/inc/vcl/combobox.hxx
+++ b/vcl/inc/vcl/combobox.hxx
@@ -192,8 +192,12 @@ public:
void* GetEntryData( USHORT nPos ) const;
void SetTopEntry( USHORT nPos );
+ void ShowProminentEntry( USHORT nPos );
USHORT GetTopEntry() const;
+ void SetProminentEntryType( ProminentEntry eType );
+ ProminentEntry GetProminentEntryType() const;
+
USHORT GetDisplayLineCount() const;
USHORT GetSelectEntryCount() const;
diff --git a/vcl/inc/vcl/ilstbox.hxx b/vcl/inc/vcl/ilstbox.hxx
index 81dd32ef2705..f38825028080 100644
--- a/vcl/inc/vcl/ilstbox.hxx
+++ b/vcl/inc/vcl/ilstbox.hxx
@@ -227,6 +227,7 @@ private:
long mnLeft; // Ausgabe ab Spalte
long mnBorder; // Abstand Rahmen - Text
long mnTextHeight; // Texthoehe
+ ProminentEntry meProminentType; // where is the "prominent" entry
USHORT mnSelectModifier; // Modifiers
@@ -309,6 +310,11 @@ public:
void SetTopEntry( USHORT nTop );
USHORT GetTopEntry() const { return mnTop; }
+ // ShowProminentEntry will set the entry correspoding to nEntryPos
+ // either at top or in the middle depending on the chosen style
+ void ShowProminentEntry( USHORT nEntryPos );
+ void SetProminentEntryType( ProminentEntry eType ) { meProminentType = eType; }
+ ProminentEntry GetProminentEntryType() const { return meProminentType; }
using Window::IsVisible;
BOOL IsVisible( USHORT nEntry ) const;
@@ -443,9 +449,13 @@ public:
void SetTopEntry( USHORT nTop ) { maLBWindow.SetTopEntry( nTop ); }
USHORT GetTopEntry() const { return maLBWindow.GetTopEntry(); }
+ void ShowProminentEntry( USHORT nPos ) { maLBWindow.ShowProminentEntry( nPos ); }
using Window::IsVisible;
BOOL IsVisible( USHORT nEntry ) const { return maLBWindow.IsVisible( nEntry ); }
+ void SetProminentEntryType( ProminentEntry eType ) { maLBWindow.SetProminentEntryType( eType ); }
+ ProminentEntry GetProminentEntryType() const { return maLBWindow.GetProminentEntryType(); }
+
long GetLeftIndent() const { return maLBWindow.GetLeftIndent(); }
void SetLeftIndent( USHORT n ) { maLBWindow.SetLeftIndent( n ); }
void ScrollHorz( short nDiff ) { maLBWindow.ScrollHorz( nDiff ); }
diff --git a/vcl/inc/vcl/lstbox.hxx b/vcl/inc/vcl/lstbox.hxx
index 0bf281798674..806ff9bb3e0f 100644
--- a/vcl/inc/vcl/lstbox.hxx
+++ b/vcl/inc/vcl/lstbox.hxx
@@ -168,9 +168,13 @@ public:
long GetEntryFlags( USHORT nPos ) const;
void SetTopEntry( USHORT nPos );
+ void ShowProminentEntry( USHORT nPos );
void SetTopEntryStr( const XubString& rStr );
USHORT GetTopEntry() const;
+ void SetProminentEntryType( ProminentEntry eType );
+ ProminentEntry GetProminentEntryType() const;
+
void SaveValue() { mnSaveValue = GetSelectEntryPos(); }
USHORT GetSavedValue() const { return mnSaveValue; }
diff --git a/vcl/inc/vcl/wintypes.hxx b/vcl/inc/vcl/wintypes.hxx
index 968f0e1d255f..1c32001a649b 100644
--- a/vcl/inc/vcl/wintypes.hxx
+++ b/vcl/inc/vcl/wintypes.hxx
@@ -333,5 +333,11 @@ typedef USHORT StandardButtonType;
#define BUTTON_LESS ((StandardButtonType)10)
#define BUTTON_COUNT 11
+// --------------------------------------------
+// - prominent place for ListBox window types -
+// --------------------------------------------
+
+enum ProminentEntry { PROMINENT_TOP, PROMINENT_MIDDLE };
+
#endif // _SV_WINTYPES_HXX
diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx
index 21707d0182f5..1eea72131b86 100644
--- a/vcl/source/control/combobox.cxx
+++ b/vcl/source/control/combobox.cxx
@@ -951,7 +951,7 @@ void ComboBox::ImplUpdateFloatSelection()
if( nSelect != LISTBOX_ENTRY_NOTFOUND )
{
if ( !mpImplLB->IsVisible( nSelect ) )
- mpImplLB->SetTopEntry( nSelect );
+ mpImplLB->ShowProminentEntry( nSelect );
mpImplLB->SelectEntry( nSelect, bSelect );
}
else
@@ -959,7 +959,6 @@ void ComboBox::ImplUpdateFloatSelection()
nSelect = mpImplLB->GetEntryList()->GetSelectEntryPos( 0 );
if( nSelect != LISTBOX_ENTRY_NOTFOUND )
mpImplLB->SelectEntry( nSelect, FALSE );
- // mpImplLB->SetTopEntry( 0 ); #92555# Ugly....
mpImplLB->ResetCurrentPos();
}
}
@@ -1440,6 +1439,13 @@ void ComboBox::SetTopEntry( USHORT nPos )
// -----------------------------------------------------------------------
+void ComboBox::ShowProminentEntry( USHORT nPos )
+{
+ mpImplLB->ShowProminentEntry( nPos + mpImplLB->GetEntryList()->GetMRUCount() );
+}
+
+// -----------------------------------------------------------------------
+
USHORT ComboBox::GetTopEntry() const
{
USHORT nPos = GetEntryCount() ? mpImplLB->GetTopEntry() : LISTBOX_ENTRY_NOTFOUND;
@@ -1450,6 +1456,20 @@ USHORT ComboBox::GetTopEntry() const
// -----------------------------------------------------------------------
+void ComboBox::SetProminentEntryType( ProminentEntry eType )
+{
+ mpImplLB->SetProminentEntryType( eType );
+}
+
+// -----------------------------------------------------------------------
+
+ProminentEntry ComboBox::GetProminentEntryType() const
+{
+ return mpImplLB->GetProminentEntryType();
+}
+
+// -----------------------------------------------------------------------
+
Rectangle ComboBox::GetDropDownPosSizePixel() const
{
return mpFloatWin ? mpFloatWin->GetWindowExtentsRelative( const_cast<ComboBox*>(this) ) : Rectangle();
diff --git a/vcl/source/control/ilstbox.cxx b/vcl/source/control/ilstbox.cxx
index a915d8e6b9e8..490651bd8b17 100644
--- a/vcl/source/control/ilstbox.cxx
+++ b/vcl/source/control/ilstbox.cxx
@@ -565,6 +565,7 @@ ImplListBoxWindow::ImplListBoxWindow( Window* pParent, WinBits nWinStyle ) :
mnCurrentPos = LISTBOX_ENTRY_NOTFOUND;
mnTrackingSaveSelection = LISTBOX_ENTRY_NOTFOUND;
mnSeparatorPos = LISTBOX_ENTRY_NOTFOUND;
+ meProminentType = PROMINENT_TOP;
SetLineColor();
SetTextFillColor();
@@ -1067,11 +1068,11 @@ void ImplListBoxWindow::SelectEntry( USHORT nPos, BOOL bSelect )
if ( !nVisibleEntries || !IsReallyVisible() || ( nPos < GetTopEntry() ) )
{
Resize();
- SetTopEntry( nPos );
+ ShowProminentEntry( nPos );
}
else
{
- SetTopEntry( nPos-nVisibleEntries+1 );
+ ShowProminentEntry( nPos );
}
}
}
@@ -1702,11 +1703,7 @@ BOOL ImplListBoxWindow::ProcessKeyInput( const KeyEvent& rKEvt )
if ( nSelect != LISTBOX_ENTRY_NOTFOUND )
{
- USHORT nCurVis = GetLastVisibleEntry() - mnTop + 1;
- if( nSelect < mnTop )
- SetTopEntry( nSelect );
- else if( nSelect >= (mnTop + nCurVis) )
- SetTopEntry( nSelect - nCurVis + 1 );
+ ShowProminentEntry( nSelect );
if ( mpEntryList->IsEntryPosSelected( nSelect ) )
nSelect = LISTBOX_ENTRY_NOTFOUND;
@@ -2051,6 +2048,20 @@ void ImplListBoxWindow::SetTopEntry( USHORT nTop )
// -----------------------------------------------------------------------
+void ImplListBoxWindow::ShowProminentEntry( USHORT nEntryPos )
+{
+ if( meProminentType == PROMINENT_MIDDLE )
+ {
+ USHORT nPos = nEntryPos;
+ long nWHeight = PixelToLogic( GetSizePixel() ).Height();
+ while( nEntryPos > 0 && mpEntryList->GetAddedHeight( nPos+1, nEntryPos ) < nWHeight/2 )
+ nEntryPos--;
+ }
+ SetTopEntry( nEntryPos );
+}
+
+// -----------------------------------------------------------------------
+
void ImplListBoxWindow::SetLeftIndent( long n )
{
ScrollHorz( n - mnLeft );
@@ -3204,7 +3215,7 @@ void ImplListBoxFloatingWindow::StartFloat( BOOL bStartTracking )
StartPopupMode( aRect, FLOATWIN_POPUPMODE_DOWN );
if( nPos != LISTBOX_ENTRY_NOTFOUND )
- mpImplLB->SetTopEntry( nPos );
+ mpImplLB->ShowProminentEntry( nPos );
if( bStartTracking )
mpImplLB->GetMainWindow()->EnableMouseMoveSelect( TRUE );
diff --git a/vcl/source/control/lstbox.cxx b/vcl/source/control/lstbox.cxx
index ceabbe4ab166..37ce438fa79e 100644
--- a/vcl/source/control/lstbox.cxx
+++ b/vcl/source/control/lstbox.cxx
@@ -1209,6 +1209,13 @@ void ListBox::SetTopEntry( USHORT nPos )
// -----------------------------------------------------------------------
+void ListBox::ShowProminentEntry( USHORT nPos )
+{
+ mpImplLB->ShowProminentEntry( nPos + mpImplLB->GetEntryList()->GetMRUCount() );
+}
+
+// -----------------------------------------------------------------------
+
USHORT ListBox::GetTopEntry() const
{
USHORT nPos = GetEntryCount() ? mpImplLB->GetTopEntry() : LISTBOX_ENTRY_NOTFOUND;
@@ -1219,6 +1226,20 @@ USHORT ListBox::GetTopEntry() const
// -----------------------------------------------------------------------
+void ListBox::SetProminentEntryType( ProminentEntry eType )
+{
+ mpImplLB->SetProminentEntryType( eType );
+}
+
+// -----------------------------------------------------------------------
+
+ProminentEntry ListBox::GetProminentEntryType() const
+{
+ return mpImplLB->GetProminentEntryType();
+}
+
+// -----------------------------------------------------------------------
+
BOOL ListBox::IsTravelSelect() const
{
return mpImplLB->IsTravelSelect();