lstbox.cxx (ad3a95a3) lstbox.cxx (a68b38df)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 85 unchanged lines hidden (view full) ---

94
95// -----------------------------------------------------------------------
96
97void ListBox::ImplInitListBoxData()
98{
99 mpFloatWin = NULL;
100 mpImplWin = NULL;
101 mpBtn = NULL;
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 85 unchanged lines hidden (view full) ---

94
95// -----------------------------------------------------------------------
96
97void ListBox::ImplInitListBoxData()
98{
99 mpFloatWin = NULL;
100 mpImplWin = NULL;
101 mpBtn = NULL;
102
103 mnDDHeight = 0;
102 mnDDHeight = 0;
104 mbDDAutoSize = sal_True;
105 mnSaveValue = LISTBOX_ENTRY_NOTFOUND;
106 mnLineCount = 0;
103 mnSaveValue = LISTBOX_ENTRY_NOTFOUND;
104 mnLineCount = 0;
105 mbDDAutoSize = true;
106 mbEdgeBlending = false;
107}
108
109// -----------------------------------------------------------------------
110
111void ListBox::ImplInit( Window* pParent, WinBits nStyle )
112{
113 nStyle = ImplInitStyle( nStyle );
114 if ( !(nStyle & WB_NOBORDER) && ( nStyle & WB_DROPDOWN ) )

--- 32 unchanged lines hidden (view full) ---

147 mpFloatWin->SetPopupModeEndHdl( LINK( this, ListBox, ImplPopupModeEndHdl ) );
148 mpFloatWin->GetDropTarget()->addDropTargetListener(xDrop);
149
150 mpImplWin = new ImplWin( this, (nStyle & (WB_LEFT|WB_RIGHT|WB_CENTER))|WB_NOBORDER );
151 mpImplWin->SetMBDownHdl( LINK( this, ListBox, ImplClickBtnHdl ) );
152 mpImplWin->SetUserDrawHdl( LINK( this, ListBox, ImplUserDrawHdl ) );
153 mpImplWin->Show();
154 mpImplWin->GetDropTarget()->addDropTargetListener(xDrop);
107}
108
109// -----------------------------------------------------------------------
110
111void ListBox::ImplInit( Window* pParent, WinBits nStyle )
112{
113 nStyle = ImplInitStyle( nStyle );
114 if ( !(nStyle & WB_NOBORDER) && ( nStyle & WB_DROPDOWN ) )

--- 32 unchanged lines hidden (view full) ---

147 mpFloatWin->SetPopupModeEndHdl( LINK( this, ListBox, ImplPopupModeEndHdl ) );
148 mpFloatWin->GetDropTarget()->addDropTargetListener(xDrop);
149
150 mpImplWin = new ImplWin( this, (nStyle & (WB_LEFT|WB_RIGHT|WB_CENTER))|WB_NOBORDER );
151 mpImplWin->SetMBDownHdl( LINK( this, ListBox, ImplClickBtnHdl ) );
152 mpImplWin->SetUserDrawHdl( LINK( this, ListBox, ImplUserDrawHdl ) );
153 mpImplWin->Show();
154 mpImplWin->GetDropTarget()->addDropTargetListener(xDrop);
155 mpImplWin->SetEdgeBlending(GetEdgeBlending());
155
156 mpBtn = new ImplBtn( this, WB_NOLIGHTBORDER | WB_RECTSTYLE );
157 ImplInitDropDownButton( mpBtn );
158 mpBtn->SetMBDownHdl( LINK( this, ListBox, ImplClickBtnHdl ) );
159 mpBtn->Show();
160 mpBtn->GetDropTarget()->addDropTargetListener(xDrop);
156
157 mpBtn = new ImplBtn( this, WB_NOLIGHTBORDER | WB_RECTSTYLE );
158 ImplInitDropDownButton( mpBtn );
159 mpBtn->SetMBDownHdl( LINK( this, ListBox, ImplClickBtnHdl ) );
160 mpBtn->Show();
161 mpBtn->GetDropTarget()->addDropTargetListener(xDrop);
161
162 }
163
164 Window* pLBParent = this;
165 if ( mpFloatWin )
166 pLBParent = mpFloatWin;
167 mpImplLB = new ImplListBox( pLBParent, nStyle&(~WB_BORDER) );
168 mpImplLB->SetSelectHdl( LINK( this, ListBox, ImplSelectHdl ) );
169 mpImplLB->SetScrollHdl( LINK( this, ListBox, ImplScrollHdl ) );
170 mpImplLB->SetCancelHdl( LINK( this, ListBox, ImplCancelHdl ) );
171 mpImplLB->SetDoubleClickHdl( LINK( this, ListBox, ImplDoubleClickHdl ) );
172 mpImplLB->SetUserDrawHdl( LINK( this, ListBox, ImplUserDrawHdl ) );
162 }
163
164 Window* pLBParent = this;
165 if ( mpFloatWin )
166 pLBParent = mpFloatWin;
167 mpImplLB = new ImplListBox( pLBParent, nStyle&(~WB_BORDER) );
168 mpImplLB->SetSelectHdl( LINK( this, ListBox, ImplSelectHdl ) );
169 mpImplLB->SetScrollHdl( LINK( this, ListBox, ImplScrollHdl ) );
170 mpImplLB->SetCancelHdl( LINK( this, ListBox, ImplCancelHdl ) );
171 mpImplLB->SetDoubleClickHdl( LINK( this, ListBox, ImplDoubleClickHdl ) );
172 mpImplLB->SetUserDrawHdl( LINK( this, ListBox, ImplUserDrawHdl ) );
173//IAccessibility2 Implementation 2009-----
174 mpImplLB->SetFocusHdl( LINK( this, ListBox, ImplFocusHdl ) );
175 mpImplLB->SetListItemSelectHdl( LINK( this, ListBox, ImplListItemSelectHdl ) );
176//-----IAccessibility2 Implementation 2009
177 mpImplLB->SetPosPixel( Point() );
173 mpImplLB->SetPosPixel( Point() );
174 mpImplLB->SetEdgeBlending(GetEdgeBlending());
178 mpImplLB->Show();
179
180 mpImplLB->GetDropTarget()->addDropTargetListener(xDrop);
181 mpImplLB->SetDropTraget(xDrop);
182
183 if ( mpFloatWin )
184 {
185 mpFloatWin->SetImplListBox( mpImplLB );

--- 61 unchanged lines hidden (view full) ---

247 mpImplWin->Invalidate();
248 }
249
250 if ( ( !IsTravelSelect() || mpImplLB->IsSelectionChanged() ) || ( bPopup && !IsMultiSelectionEnabled() ) )
251 Select();
252
253 return 1;
254}
175 mpImplLB->Show();
176
177 mpImplLB->GetDropTarget()->addDropTargetListener(xDrop);
178 mpImplLB->SetDropTraget(xDrop);
179
180 if ( mpFloatWin )
181 {
182 mpFloatWin->SetImplListBox( mpImplLB );

--- 61 unchanged lines hidden (view full) ---

244 mpImplWin->Invalidate();
245 }
246
247 if ( ( !IsTravelSelect() || mpImplLB->IsSelectionChanged() ) || ( bPopup && !IsMultiSelectionEnabled() ) )
248 Select();
249
250 return 1;
251}
255//IAccessibility2 Implementation 2009-----
256IMPL_LINK( ListBox, ImplFocusHdl, void *, nPos )
257{
258 ImplCallEventListeners( VCLEVENT_LISTBOX_FOCUS , nPos);
259 return 1;
260}
261IMPL_LINK( ListBox, ImplListItemSelectHdl, void*, EMPTYARG )
262{
263 ImplCallEventListeners( VCLEVENT_LISTBOX_SELECT );
264 return 1;
265}
266//-----IAccessibility2 Implementation 2009
267
268// -----------------------------------------------------------------------
269
270IMPL_LINK( ListBox, ImplScrollHdl, void*, EMPTYARG )
271{
272 ImplCallEventListeners( VCLEVENT_LISTBOX_SCROLLED );
273 return 1;
274}

--- 320 unchanged lines hidden (view full) ---

595
596 if ( IsDropDownBox() )
597 Invalidate();
598 }
599}
600
601// -----------------------------------------------------------------------
602
252
253// -----------------------------------------------------------------------
254
255IMPL_LINK( ListBox, ImplScrollHdl, void*, EMPTYARG )
256{
257 ImplCallEventListeners( VCLEVENT_LISTBOX_SCROLLED );
258 return 1;
259}

--- 320 unchanged lines hidden (view full) ---

580
581 if ( IsDropDownBox() )
582 Invalidate();
583 }
584}
585
586// -----------------------------------------------------------------------
587
603void ListBox::EnableAutoSize( sal_Bool bAuto )
588void ListBox::EnableAutoSize( bool bAuto )
604{
605 mbDDAutoSize = bAuto;
606 if ( mpFloatWin )
607 {
608 if ( bAuto && !mpFloatWin->GetDropDownLineCount() )
589{
590 mbDDAutoSize = bAuto;
591 if ( mpFloatWin )
592 {
593 if ( bAuto && !mpFloatWin->GetDropDownLineCount() )
609 mpFloatWin->SetDropDownLineCount( 5 );
594 {
595 // use GetListBoxMaximumLineCount here; before, was on fixed number of five
596 AdaptDropDownLineCountToMaximum();
597 }
610 else if ( !bAuto )
598 else if ( !bAuto )
599 {
611 mpFloatWin->SetDropDownLineCount( 0 );
600 mpFloatWin->SetDropDownLineCount( 0 );
601 }
612 }
613}
614
615// -----------------------------------------------------------------------
616
617void ListBox::EnableDDAutoWidth( sal_Bool b )
618{
619 if ( mpFloatWin )

--- 13 unchanged lines hidden (view full) ---

633{
634 mnLineCount = nLines;
635 if ( mpFloatWin )
636 mpFloatWin->SetDropDownLineCount( mnLineCount );
637}
638
639// -----------------------------------------------------------------------
640
602 }
603}
604
605// -----------------------------------------------------------------------
606
607void ListBox::EnableDDAutoWidth( sal_Bool b )
608{
609 if ( mpFloatWin )

--- 13 unchanged lines hidden (view full) ---

623{
624 mnLineCount = nLines;
625 if ( mpFloatWin )
626 mpFloatWin->SetDropDownLineCount( mnLineCount );
627}
628
629// -----------------------------------------------------------------------
630
631void ListBox::AdaptDropDownLineCountToMaximum()
632{
633 // adapt to maximum allowed number
634 SetDropDownLineCount(std::min(GetEntryCount(), GetSettings().GetStyleSettings().GetListBoxMaximumLineCount()));
635}
636
637// -----------------------------------------------------------------------
638
641sal_uInt16 ListBox::GetDropDownLineCount() const
642{
643 if ( mpFloatWin )
644 return mpFloatWin->GetDropDownLineCount();
645 return mnLineCount;
646}
647
648// -----------------------------------------------------------------------

--- 408 unchanged lines hidden (view full) ---

1057 if( IsDropDownBox() )
1058 {
1059 mpImplWin->SetItemPos( LISTBOX_ENTRY_NOTFOUND );
1060 mpImplWin->SetString( ImplGetSVEmptyStr() );
1061 Image aImage;
1062 mpImplWin->SetImage( aImage );
1063 mpImplWin->Invalidate();
1064 }
639sal_uInt16 ListBox::GetDropDownLineCount() const
640{
641 if ( mpFloatWin )
642 return mpFloatWin->GetDropDownLineCount();
643 return mnLineCount;
644}
645
646// -----------------------------------------------------------------------

--- 408 unchanged lines hidden (view full) ---

1055 if( IsDropDownBox() )
1056 {
1057 mpImplWin->SetItemPos( LISTBOX_ENTRY_NOTFOUND );
1058 mpImplWin->SetString( ImplGetSVEmptyStr() );
1059 Image aImage;
1060 mpImplWin->SetImage( aImage );
1061 mpImplWin->Invalidate();
1062 }
1065 // IAccessible2 implementation 2009
1066 NotifyVCLEvent( VCLEVENT_LISTBOX_STATEUPDATE);
1067}
1068
1069// -----------------------------------------------------------------------
1070
1071sal_uInt16 ListBox::InsertEntry( const XubString& rStr, sal_uInt16 nPos )
1072{
1073 sal_uInt16 nRealPos = mpImplLB->InsertEntry( nPos + mpImplLB->GetEntryList()->GetMRUCount(), rStr );
1074 nRealPos = sal::static_int_cast<sal_uInt16>(nRealPos - mpImplLB->GetEntryList()->GetMRUCount());

--- 128 unchanged lines hidden (view full) ---

1203 SelectEntryPos( GetEntryPos( rStr ), bSelect );
1204}
1205
1206// -----------------------------------------------------------------------
1207
1208void ListBox::SelectEntryPos( sal_uInt16 nPos, sal_Bool bSelect )
1209{
1210 if ( nPos < mpImplLB->GetEntryList()->GetEntryCount() )
1063}
1064
1065// -----------------------------------------------------------------------
1066
1067sal_uInt16 ListBox::InsertEntry( const XubString& rStr, sal_uInt16 nPos )
1068{
1069 sal_uInt16 nRealPos = mpImplLB->InsertEntry( nPos + mpImplLB->GetEntryList()->GetMRUCount(), rStr );
1070 nRealPos = sal::static_int_cast<sal_uInt16>(nRealPos - mpImplLB->GetEntryList()->GetMRUCount());

--- 128 unchanged lines hidden (view full) ---

1199 SelectEntryPos( GetEntryPos( rStr ), bSelect );
1200}
1201
1202// -----------------------------------------------------------------------
1203
1204void ListBox::SelectEntryPos( sal_uInt16 nPos, sal_Bool bSelect )
1205{
1206 if ( nPos < mpImplLB->GetEntryList()->GetEntryCount() )
1211 {
1212 // IAccessible2 implementation 2009
1213 sal_uInt16 oldSelectCount = GetSelectEntryCount(), newSelectCount = 0, nCurrentPos = mpImplLB->GetCurrentPos();
1214 mpImplLB->SelectEntry( nPos + mpImplLB->GetEntryList()->GetMRUCount(), bSelect );
1207 mpImplLB->SelectEntry( nPos + mpImplLB->GetEntryList()->GetMRUCount(), bSelect );
1215 newSelectCount = GetSelectEntryCount();
1216 if (oldSelectCount == 0 && newSelectCount > 0)
1217 NotifyVCLEvent( VCLEVENT_LISTBOX_STATEUPDATE);
1218 //Only when bSelect == true, send both Selection & Focus events
1219 if (nCurrentPos != nPos && bSelect)
1220 {
1221 ImplCallEventListeners( VCLEVENT_LISTBOX_SELECT, reinterpret_cast<void*>(nPos));
1222 if (HasFocus())
1223 ImplCallEventListeners( VCLEVENT_LISTBOX_FOCUS, reinterpret_cast<void*>(nPos));
1224 }
1225 }
1226}
1227
1228// -----------------------------------------------------------------------
1229
1230void ListBox::SetEntryData( sal_uInt16 nPos, void* pNewData )
1231{
1232 mpImplLB->SetEntryData( nPos + mpImplLB->GetEntryList()->GetMRUCount(), pNewData );
1233}

--- 384 unchanged lines hidden (view full) ---

1618}
1619
1620// -----------------------------------------------------------------------
1621
1622sal_uInt16 ListBox::GetMaxMRUCount() const
1623{
1624 return mpImplLB->GetMaxMRUCount();
1625}
1208}
1209
1210// -----------------------------------------------------------------------
1211
1212void ListBox::SetEntryData( sal_uInt16 nPos, void* pNewData )
1213{
1214 mpImplLB->SetEntryData( nPos + mpImplLB->GetEntryList()->GetMRUCount(), pNewData );
1215}

--- 384 unchanged lines hidden (view full) ---

1600}
1601
1602// -----------------------------------------------------------------------
1603
1604sal_uInt16 ListBox::GetMaxMRUCount() const
1605{
1606 return mpImplLB->GetMaxMRUCount();
1607}
1626//IAccessibility2 Implementation 2009-----
1627sal_uInt16 ListBox::GetMRUCount() const
1628{
1629 return mpImplLB->GetEntryList()->GetMRUCount();
1630}
1631//-----IAccessibility2 Implementation 2009
1632
1633// -----------------------------------------------------------------------
1634
1635sal_uInt16 ListBox::GetDisplayLineCount() const
1636{
1637 return mpImplLB->GetDisplayLineCount();
1638}
1639

--- 17 unchanged lines hidden (view full) ---

1657
1658const Wallpaper& ListBox::GetDisplayBackground() const
1659{
1660 // !!! recursion does not occur because the ImplListBox is default
1661 // initialized to a nontransparent color in Window::ImplInitData
1662 return mpImplLB->GetDisplayBackground();
1663}
1664
1608
1609// -----------------------------------------------------------------------
1610
1611sal_uInt16 ListBox::GetDisplayLineCount() const
1612{
1613 return mpImplLB->GetDisplayLineCount();
1614}
1615

--- 17 unchanged lines hidden (view full) ---

1633
1634const Wallpaper& ListBox::GetDisplayBackground() const
1635{
1636 // !!! recursion does not occur because the ImplListBox is default
1637 // initialized to a nontransparent color in Window::ImplInitData
1638 return mpImplLB->GetDisplayBackground();
1639}
1640
1641// -----------------------------------------------------------------------
1642
1643void ListBox::SetEdgeBlending(bool bNew)
1644{
1645 if(mbEdgeBlending != bNew)
1646 {
1647 mbEdgeBlending = bNew;
1648
1649 if(IsDropDownBox())
1650 {
1651 mpImplWin->Invalidate();
1652 }
1653 else
1654 {
1655 mpImplLB->Invalidate();
1656 }
1657
1658 if(mpImplWin)
1659 {
1660 mpImplWin->SetEdgeBlending(GetEdgeBlending());
1661 }
1662
1663 if(mpImplLB)
1664 {
1665 mpImplLB->SetEdgeBlending(GetEdgeBlending());
1666 }
1667
1668 Invalidate();
1669 }
1670}
1671
1665// =======================================================================
1666MultiListBox::MultiListBox( Window* pParent, WinBits nStyle ) :
1667 ListBox( WINDOW_MULTILISTBOX )
1668{
1669 ImplInit( pParent, nStyle );
1670 EnableMultiSelection( sal_True );
1671}
1672

--- 6 unchanged lines hidden (view full) ---

1679 WinBits nStyle = ImplInitRes( rResId );
1680 ImplInit( pParent, nStyle );
1681 ImplLoadRes( rResId );
1682
1683 if ( !(nStyle & WB_HIDE ) )
1684 Show();
1685 EnableMultiSelection( sal_True );
1686}
1672// =======================================================================
1673MultiListBox::MultiListBox( Window* pParent, WinBits nStyle ) :
1674 ListBox( WINDOW_MULTILISTBOX )
1675{
1676 ImplInit( pParent, nStyle );
1677 EnableMultiSelection( sal_True );
1678}
1679

--- 6 unchanged lines hidden (view full) ---

1686 WinBits nStyle = ImplInitRes( rResId );
1687 ImplInit( pParent, nStyle );
1688 ImplLoadRes( rResId );
1689
1690 if ( !(nStyle & WB_HIDE ) )
1691 Show();
1692 EnableMultiSelection( sal_True );
1693}
1694