1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ivctrl.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
34 #ifndef INCLUDED_SVTDLLAPI_H
35 #include "bf_svtools/svtdllapi.h"
39 #include <tools/string.hxx>
42 #include <vcl/ctrl.hxx>
45 #include <tools/link.hxx>
48 #include <vcl/image.hxx>
50 #ifndef _SV_SELENG_HXX
51 #include <vcl/seleng.hxx>
63 class SvxIconChoiceCtrl_Impl
;
66 #define ICNVIEW_FLAG_POS_LOCKED 0x0001
67 #define ICNVIEW_FLAG_SELECTED 0x0002
68 #define ICNVIEW_FLAG_FOCUSED 0x0004
69 #define ICNVIEW_FLAG_IN_USE 0x0008
70 #define ICNVIEW_FLAG_CURSORED 0x0010 // Rahmen um Image
71 #define ICNVIEW_FLAG_POS_MOVED 0x0020 // per D&D verschoben aber nicht gelockt
72 #define ICNVIEW_FLAG_DROP_TARGET 0x0040 // im QueryDrop gesetzt
73 #define ICNVIEW_FLAG_BLOCK_EMPHASIS 0x0080 // Emphasis nicht painten
74 #define ICNVIEW_FLAG_USER1 0x0100
75 #define ICNVIEW_FLAG_USER2 0x0200
76 #define ICNVIEW_FLAG_PRED_SET 0x0400 // Predecessor wurde umgesetzt
78 enum SvxIconChoiceCtrlTextMode
80 IcnShowTextFull
= 1, // BoundRect nach unten aufplustern
81 IcnShowTextShort
, // Abkuerzung mit "..."
82 IcnShowTextSmart
, // Text komplett anzeigen, wenn moeglich (n.i.)
83 IcnShowTextDontKnow
// Einstellung der View
86 enum SvxIconChoiceCtrlPositionMode
88 IcnViewPositionModeFree
= 0, // freies pixelgenaues Positionieren
89 IcnViewPositionModeAutoArrange
= 1, // automatisches Ausrichten
90 IcnViewPositionModeAutoAdjust
= 2, // automatisches Anordnen
91 IcnViewPositionModeLast
= IcnViewPositionModeAutoAdjust
94 class SvxIconChoiceCtrlEntry
100 String aQuickHelpText
;
103 friend class SvxIconChoiceCtrl_Impl
;
104 friend class IcnCursor_Impl
;
105 friend class EntryList_Impl
;
106 friend class IcnGridMap_Impl
;
108 Rectangle aRect
; // Bounding-Rect des Entries
109 Rectangle aGridRect
; // nur gesetzt im Grid-Modus
112 // die Eintragsposition in der Eintragsliste entspricht der beim Insert vorgegebenen
113 // [Sortier-]Reihenfolge (->Reihenfolge der Anker in der Ankerliste!). Im AutoArrange-Modus
114 // kann die sichtbare Reihenfolge aber anders sein. Die Eintraege werden deshalb dann
116 SvxIconChoiceCtrlEntry
* pblink
; // backward (linker Nachbar)
117 SvxIconChoiceCtrlEntry
* pflink
; // forward (rechter Nachbar)
119 SvxIconChoiceCtrlTextMode eTextMode
;
120 USHORT nX
,nY
; // fuer Tastatursteuerung
123 void ClearFlags( USHORT nMask
) { nFlags
&= (~nMask
); }
124 void SetFlags( USHORT nMask
) { nFlags
|= nMask
; }
125 void AssignFlags( USHORT _nFlags
) { nFlags
= _nFlags
; }
127 // setzt den linken Nachbarn (A <-> B ==> A <-> this <-> B)
128 void SetBacklink( SvxIconChoiceCtrlEntry
* pA
)
130 pA
->pflink
->pblink
= this; // X <- B
131 this->pflink
= pA
->pflink
; // X -> B
132 this->pblink
= pA
; // A <- X
133 pA
->pflink
= this; // A -> X
135 // loest eine Verbindung (A <-> this <-> B ==> A <-> B)
138 this->pblink
->pflink
= this->pflink
;
139 this->pflink
->pblink
= this->pblink
;
145 SvxIconChoiceCtrlEntry( USHORT nFlags
= 0 );
146 SvxIconChoiceCtrlEntry( const String
& rText
, const Image
& rImage
, USHORT nFlags
= 0 );
147 SvxIconChoiceCtrlEntry( const String
& rText
, const Image
& rImage
, const Image
& rImageHC
, USHORT nFlags
= 0 );
148 ~SvxIconChoiceCtrlEntry () {}
150 void SetImage ( const Image
& rImage
) { aImage
= rImage
; }
151 void SetImageHC ( const Image
& rImage
) { aImageHC
= rImage
; }
152 Image
GetImage () const { return aImage
; }
153 Image
GetImageHC () const { return aImageHC
; }
154 void SetText ( const String
& rText
) { aText
= rText
; }
155 String
GetText () const { return aText
; }
156 String
GetDisplayText() const;
157 void SetQuickHelpText( const String
& rText
) { aQuickHelpText
= rText
; }
158 String
GetQuickHelpText() const { return aQuickHelpText
; }
159 void SetUserData ( void* _pUserData
) { pUserData
= _pUserData
; }
160 void* GetUserData () { return pUserData
; }
162 const Rectangle
& GetBoundRect() const { return aRect
; }
164 void SetFocus ( BOOL bSet
)
165 { nFlags
= ( bSet
? nFlags
| ICNVIEW_FLAG_FOCUSED
: nFlags
& ~ICNVIEW_FLAG_FOCUSED
); }
167 SvxIconChoiceCtrlTextMode
GetTextMode() const { return eTextMode
; }
168 USHORT
GetFlags() const { return nFlags
; }
169 BOOL
IsSelected() const { return (BOOL
)((nFlags
& ICNVIEW_FLAG_SELECTED
) !=0); }
170 BOOL
IsFocused() const { return (BOOL
)((nFlags
& ICNVIEW_FLAG_FOCUSED
) !=0); }
171 BOOL
IsInUse() const { return (BOOL
)((nFlags
& ICNVIEW_FLAG_IN_USE
) !=0); }
172 BOOL
IsCursored() const { return (BOOL
)((nFlags
& ICNVIEW_FLAG_CURSORED
) !=0); }
173 BOOL
IsDropTarget() const { return (BOOL
)((nFlags
& ICNVIEW_FLAG_DROP_TARGET
) !=0); }
174 BOOL
IsBlockingEmphasis() const { return (BOOL
)((nFlags
& ICNVIEW_FLAG_BLOCK_EMPHASIS
) !=0); }
175 BOOL
WasMoved() const { return (BOOL
)((nFlags
& ICNVIEW_FLAG_POS_MOVED
) !=0); }
176 void SetMoved( BOOL bMoved
);
177 BOOL
IsPosLocked() const { return (BOOL
)((nFlags
& ICNVIEW_FLAG_POS_LOCKED
) !=0); }
178 void LockPos( BOOL bLock
);
179 // Nur bei AutoArrange gesetzt. Den Kopf der Liste gibts per SvxIconChoiceCtrl::GetPredecessorHead
180 SvxIconChoiceCtrlEntry
* GetSuccessor() const { return pflink
; }
181 SvxIconChoiceCtrlEntry
* GetPredecessor() const { return pblink
; }
183 // sal_Unicode GetMnemonicChar() const;
186 enum SvxIconChoiceCtrlColumnAlign
188 IcnViewAlignLeft
= 1,
193 class SvxIconChoiceCtrlColumnInfo
198 SvxIconChoiceCtrlColumnAlign eAlignment
;
202 SvxIconChoiceCtrlColumnInfo( USHORT nSub
, long nWd
,
203 SvxIconChoiceCtrlColumnAlign eAlign
) :
204 nWidth( nWd
), eAlignment( eAlign
), nSubItem( nSub
) {}
205 SvxIconChoiceCtrlColumnInfo( const SvxIconChoiceCtrlColumnInfo
& );
207 void SetText( const String
& rText
) { aColText
= rText
; }
208 void SetImage( const Image
& rImg
) { aColImage
= rImg
; }
209 void SetWidth( long nWd
) { nWidth
= nWd
; }
210 void SetAlignment( SvxIconChoiceCtrlColumnAlign eAlign
) { eAlignment
= eAlign
; }
211 void SetSubItem( USHORT nSub
) { nSubItem
= nSub
; }
213 const String
& GetText() const { return aColText
; }
214 const Image
& GetImage() const { return aColImage
; }
215 long GetWidth() const { return nWidth
; }
216 SvxIconChoiceCtrlColumnAlign
GetAlignment() const { return eAlignment
; }
217 USHORT
GetSubItem() const { return nSubItem
; }
220 //###################################################################################################################################
223 WB_ICON // Text unter dem Icon
224 WB_SMALL_ICON // Text rechts neben Icon, beliebige Positionierung
225 WB_DETAILS // Text rechts neben Icon, eingeschraenkte Posit.
227 WB_NOHIDESELECTION // Selektion inaktiv zeichnen, wenn kein Fokus
231 WB_SMART_ARRANGE // im Arrange die Vis-Area beibehalten
232 WB_ALIGN_TOP // Anordnung zeilenweise von links nach rechts
233 WB_ALIGN_LEFT // Anordnung spaltenweise von oben nach unten
234 WB_NODRAGSELECTION // Keine Selektion per Tracking-Rect
235 WB_NOCOLUMNHEADER // keine Headerbar in Detailsview (Headerbar not implemented)
236 WB_NOPOINTERFOCUS // Kein GrabFocus im MouseButtonDown
237 WB_HIGHLIGHTFRAME // der unter der Maus befindliche Eintrag wird hervorgehoben
238 WB_NOASYNCSELECTHDL // Selektionshandler synchron aufrufen, d.h. Events nicht sammeln
241 #define WB_ICON WB_RECTSTYLE
242 #define WB_SMALLICON WB_SMALLSTYLE
243 #define WB_DETAILS WB_VCENTER
244 #define WB_NOHSCROLL WB_SPIN
245 #define WB_NOVSCROLL WB_DRAG
246 #define WB_NOSELECTION WB_REPEAT
247 #define WB_NODRAGSELECTION WB_PATHELLIPSIS
248 #define WB_SMART_ARRANGE WB_PASSWORD
249 #define WB_ALIGN_TOP WB_TOP
250 #define WB_ALIGN_LEFT WB_LEFT
251 #define WB_NOCOLUMNHEADER WB_CENTER
252 #define WB_HIGHLIGHTFRAME WB_INFO
253 #define WB_NOASYNCSELECTHDL WB_NOLABEL
255 class MnemonicGenerator
;
257 class SvtIconChoiceCtrl
: public Control
259 friend class SvxIconChoiceCtrl_Impl
;
262 Link _aDocRectChangedHdl
;
263 Link _aVisRectChangedHdl
;
264 KeyEvent
* _pCurKeyEvent
;
265 SvxIconChoiceCtrl_Impl
* _pImp
;
266 BOOL _bAutoFontColor
;
270 virtual void KeyInput( const KeyEvent
& rKEvt
);
271 virtual BOOL
EditedEntry( SvxIconChoiceCtrlEntry
*, const XubString
& rNewText
, BOOL bCancelled
);
272 virtual void DocumentRectChanged();
273 virtual void VisibleRectChanged();
274 virtual BOOL
EditingEntry( SvxIconChoiceCtrlEntry
* pEntry
);
275 virtual void Command( const CommandEvent
& rCEvt
);
276 virtual void Paint( const Rectangle
& rRect
);
277 virtual void MouseButtonDown( const MouseEvent
& rMEvt
);
278 virtual void MouseButtonUp( const MouseEvent
& rMEvt
);
279 virtual void MouseMove( const MouseEvent
& rMEvt
);
280 virtual void Resize();
281 virtual void GetFocus();
282 virtual void LoseFocus();
283 virtual void ClickIcon();
284 virtual void StateChanged( StateChangedType nType
);
285 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
286 virtual void RequestHelp( const HelpEvent
& rHEvt
);
287 virtual void DrawEntryImage(
288 SvxIconChoiceCtrlEntry
* pEntry
,
290 OutputDevice
& rDev
);
292 virtual String
GetEntryText(
293 SvxIconChoiceCtrlEntry
* pEntry
,
296 virtual void FillLayoutData() const;
298 void CallImplEventListeners(ULONG nEvent
, void* pData
);
302 SvtIconChoiceCtrl( Window
* pParent
, WinBits nWinStyle
= WB_ICON
| WB_BORDER
);
303 SvtIconChoiceCtrl( Window
* pParent
, const ResId
& rResId
);
304 virtual ~SvtIconChoiceCtrl();
306 void SetStyle( WinBits nWinStyle
);
307 WinBits
GetStyle() const;
309 BOOL
SetChoiceWithCursor ( BOOL bDo
= TRUE
);
311 void SetUpdateMode( BOOL bUpdateMode
);
312 void SetFont( const Font
& rFont
);
313 void SetPointFont( const Font
& rFont
);
315 void SetClickHdl( const Link
& rLink
) { _aClickIconHdl
= rLink
; }
316 const Link
& GetClickHdl() const { return _aClickIconHdl
; }
318 using OutputDevice::SetBackground
;
319 void SetBackground( const Wallpaper
& rWallpaper
);
324 SvxIconChoiceCtrlEntry
* InsertEntry( ULONG nPos
= LIST_APPEND
,
325 const Point
* pPos
= 0,
327 SvxIconChoiceCtrlEntry
* InsertEntry( const String
& rText
, const Image
& rImage
,
328 ULONG nPos
= LIST_APPEND
,
329 const Point
* pPos
= 0,
331 SvxIconChoiceCtrlEntry
* InsertEntry( const String
& rText
, const Image
& rImage
, const Image
& rImageHC
,
332 ULONG nPos
= LIST_APPEND
,
333 const Point
* pPos
= 0,
336 /** creates automatic mnemonics for all icon texts in the control
338 void CreateAutoMnemonics( void );
340 /** creates automatic mnemonics for all icon texts in the control
342 @param _rUsedMnemonics
343 a <type>MnemonicGenerator</type> at which some other mnemonics are already registered.
344 This can be used if the control needs to share the "mnemonic space" with other elements,
347 void CreateAutoMnemonics( MnemonicGenerator
& _rUsedMnemonics
);
349 void RemoveEntry( SvxIconChoiceCtrlEntry
* pEntry
);
351 BOOL
DoKeyInput( const KeyEvent
& rKEvt
);
353 BOOL
IsEntryEditing() const;
356 ULONG
GetEntryCount() const;
357 SvxIconChoiceCtrlEntry
* GetEntry( ULONG nPos
) const;
358 ULONG
GetEntryListPos( SvxIconChoiceCtrlEntry
* pEntry
) const;
359 using Window::SetCursor
;
360 void SetCursor( SvxIconChoiceCtrlEntry
* pEntry
);
361 SvxIconChoiceCtrlEntry
* GetCursor() const;
363 // Neu-Berechnung gecachter View-Daten und Invalidierung im Fenster
364 void InvalidateEntry( SvxIconChoiceCtrlEntry
* pEntry
);
366 // bHit==FALSE: Eintrag gilt als getroffen, wenn Position im BoundRect liegt
367 // ==TRUE : Bitmap oder Text muss getroffen sein
368 SvxIconChoiceCtrlEntry
* GetEntry( const Point
& rPosPixel
, BOOL bHit
= FALSE
) const;
369 // Gibt den naechsten ueber pCurEntry liegenden Eintrag (ZOrder)
370 SvxIconChoiceCtrlEntry
* GetNextEntry( const Point
& rPosPixel
, SvxIconChoiceCtrlEntry
* pCurEntry
, BOOL
) const;
371 // Gibt den naechsten unter pCurEntry liegenden Eintrag (ZOrder)
372 SvxIconChoiceCtrlEntry
* GetPrevEntry( const Point
& rPosPixel
, SvxIconChoiceCtrlEntry
* pCurEntry
, BOOL
) const;
374 // in dem ULONG wird die Position in der Liste des gefunden Eintrags zurueckgegeben
375 SvxIconChoiceCtrlEntry
* GetSelectedEntry( ULONG
& rPos
) const;
377 void SetEntryTextMode( SvxIconChoiceCtrlTextMode eMode
, SvxIconChoiceCtrlEntry
* pEntry
= 0 );
378 SvxIconChoiceCtrlTextMode
GetEntryTextMode( const SvxIconChoiceCtrlEntry
* pEntry
= 0 ) const;
380 // offene asynchron abzuarbeitende Aktionen ausfuehren. Muss vor dem Speichern von
381 // Eintragspositionen etc. gerufen werden
385 virtual BOOL
HasBackground() const;
386 virtual BOOL
HasFont() const;
387 virtual BOOL
HasFontTextColor() const;
388 virtual BOOL
HasFontFillColor() const;
390 void SetFontColorToBackground ( BOOL bDo
= TRUE
) { _bAutoFontColor
= bDo
; }
391 BOOL
AutoFontColor () { return _bAutoFontColor
; }
393 Point
GetLogicPos( const Point
& rPosPixel
) const;
394 Point
GetPixelPos( const Point
& rPosLogic
) const;
395 void SetSelectionMode( SelectionMode eMode
);
397 BOOL
HandleShortCutKey( const KeyEvent
& rKeyEvent
);
399 Rectangle
GetBoundingBox( SvxIconChoiceCtrlEntry
* pEntry
) const;
400 Rectangle
GetEntryCharacterBounds( const sal_Int32 _nEntryPos
, const sal_Int32 _nCharacterIndex
) const;
402 void SetNoSelection();
404 // ACCESSIBILITY ==========================================================
406 /** Creates and returns the accessible object of the Box. */
407 virtual ::com::sun::star::uno::Reference
<
408 ::com::sun::star::accessibility::XAccessible
> CreateAccessible();