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
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 #ifndef _CTRLBOX_HXX
25 #define _CTRLBOX_HXX
26
27 #include "svtools/svtdllapi.h"
28
29 #ifndef _LSTBOX_HXX
30 #include <vcl/lstbox.hxx>
31 #endif
32 #ifndef _COMBOBOX_HXX
33 #include <vcl/combobox.hxx>
34 #endif
35 #ifndef _IMAGE_HXX
36 #include <vcl/image.hxx>
37 #endif
38 #ifndef _VIRDEV_HXX
39 #include <vcl/virdev.hxx>
40 #endif
41 #ifndef _METRIC_HXX
42 #include <vcl/metric.hxx>
43 #endif
44 #ifndef _FIELD_HXX
45 #include <vcl/field.hxx>
46 #endif
47
48 class ImplFontList;
49 class ImpColorList;
50 class ImpLineList;
51 class FontList;
52
53 /*************************************************************************
54
55 Beschreibung
56 ============
57
58 class ColorListBox
59
60 Beschreibung
61
62 Erlaubt die Auswahl von Farben.
63
64 --------------------------------------------------------------------------
65
66 class LineListBox
67
68 Beschreibung
69
70 Erlaubt die Auswahl von Linien-Styles und Groessen. Es ist darauf zu achten,
71 das vor dem ersten Insert die Units und die Fesntergroesse gesetzt sein
72 muessen. An Unit wird Point und mm unterstuetzt und als SourceUnit Point,
73 mm und Twips. Alle Angaben muessen in 100teln der jeweiligen Einheit
74 vorliegen.
75
76 Line1 ist aeussere, Line2 die innere und Distance die Distanz zwischen
77 den beiden Linien. Wenn Line2 = 0 ist, wird nur Line1 angezeigt. Als
78 Default sind sowohl Source als auch Ziel-Unit FUNIT_POINT.
79
80 Mit SetColor() kann die Linienfarbe eingestellt werden.
81
82 Anmerkungen und Ausnahmen
83
84 Gegenueber einer normalen ListBox, koennen keine User-Daten gesetzt
85 werden. Ausserdem sollte wenn der UpdateMode ausgeschaltet ist, keine
86 Daten abgefragt oder die Selektion gesetzt werden, da in diesem Zustand
87 die Daten nicht definiert sind. Wenn der UpdateMode ausgeschaltet ist,
88 sollte der Rueckgabewert bei Insert nicht ausgewertet werden, da er keine
89 Bedeutung hat. Ausserdem darf nicht das WinBit WB_SORT gesetzt sein.
90
91 --------------------------------------------------------------------------
92
93 class FontNameBox
94
95 Beschreibung
96
97 Erlaubt die Auswahl von Fonts. Die ListBox wird mit Fill gefuellt, wo
98 ein Pointer auf eine FontList uebergeben werden muss.
99
100 Mit EnableWYSIWYG() kann man einstellen, das die Fontnamen in Ihrer Schrift
101 angezeigt werden und mit EnableSymbols() kann eingestellt werden, das
102 vor dem Namen ueber ein Symbol angezeigt wird, ob es sich um eine
103 Drucker oder Bildschirmschrift handelt.
104
105 Querverweise
106
107 FontList; FontStyleBox; FontSizeBox; FontNameMenu
108
109 --------------------------------------------------------------------------
110
111 class FontStyleBox
112
113 Beschreibung
114
115 Erlaubt die Auswahl eines FontStyles. Mit Fill wird die ListBox mit
116 den Styles zum uebergebenen Font gefuellt. Nachgebildete Styles werden
117 immer mit eingefuegt (kann sich aber noch aendern, da vielleicht
118 nicht alle Applikationen [StarDraw,Formel,FontWork] mit Syntetic-Fonts
119 umgehen koennen). Bei Fill bleibt vorherige Name soweit wie moeglich
120 erhalten.
121
122 Fuer DontKnow sollte die FontStyleBox mit String() gefuellt werden.
123 Dann enthaellt die Liste die Standardattribute. Der Style, der gerade
124 angezeigt wird, muss gegebenenfalls noch vom Programm zurueckgesetzt werden.
125
126 Querverweise
127
128 FontList; FontNameBox; FontSizeBox; FontStyleMenu
129
130 --------------------------------------------------------------------------
131
132 class FontSizeBox
133
134 Beschreibung
135
136 Erlaubt die Auswahl von Fontgroessen. Werte werden ueber GetValue()
137 abgefragt und ueber SetValue() gesetzt. Fill fuellt die ListBox mit den
138 Groessen zum uebergebenen Font. Alle Groessen werden in 10tel Point
139 angegeben. Die FontListe, die bei Fill uebergeben wird, muss bis zum
140 naechsten Fill-Aufruf erhalten bleiben.
141
142 Zusaetzlich erlaubt die FontSizeBox noch einen Relative-Mode. Dieser
143 dient dazu, Prozent-Werte eingeben zu koennen. Dies kann zum Beispiel
144 nuetzlich sein, wenn man die Box in einem Vorlagen-Dialog anbietet.
145 Dieser Modus ist nur anschaltbar, jedoch nicht wieder abschaltbar.
146
147 Fuer DontKnow sollte die FontSizeBox mit FontInfo() gefuellt werden.
148 Dann enthaellt die Liste die Standardgroessen. Die Groesse, die gerade
149 angezeigt wird, muss gegebenenfalls noch vom Programm zurueckgesetzt werden.
150
151 Querverweise
152
153 FontList; FontNameBox; FontStyleBox; FontSizeMenu
154
155 *************************************************************************/
156
157 // ----------------
158 // - ColorListBox -
159 // ----------------
160
161 class SVT_DLLPUBLIC ColorListBox : public ListBox
162 {
163 ImpColorList* pColorList; // Separate Liste, falls UserDaten von aussen verwendet werden.
164 Size aImageSize;
165
166 #ifdef _CTRLBOX_CXX
167 using Window::ImplInit;
168 SVT_DLLPRIVATE void ImplInit();
169 SVT_DLLPRIVATE void ImplDestroyColorEntries();
170 #endif
171 public:
172 ColorListBox( Window* pParent,
173 WinBits nWinStyle = WB_BORDER );
174 ColorListBox( Window* pParent, const ResId& rResId );
175 virtual ~ColorListBox();
176
177 virtual void UserDraw( const UserDrawEvent& rUDEvt );
178
179 using ListBox::InsertEntry;
180 virtual sal_uInt16 InsertEntry( const XubString& rStr,
181 sal_uInt16 nPos = LISTBOX_APPEND );
182 virtual sal_uInt16 InsertEntry( const Color& rColor, const XubString& rStr,
183 sal_uInt16 nPos = LISTBOX_APPEND );
184 void InsertAutomaticEntry();
185 using ListBox::RemoveEntry;
186 virtual void RemoveEntry( sal_uInt16 nPos );
187 virtual void Clear();
188 void CopyEntries( const ColorListBox& rBox );
189
190 using ListBox::GetEntryPos;
191 virtual sal_uInt16 GetEntryPos( const Color& rColor ) const;
192 virtual Color GetEntryColor( sal_uInt16 nPos ) const;
GetImageSize() const193 Size GetImageSize() const { return aImageSize; }
194
SelectEntry(const XubString & rStr,sal_Bool bSelect=sal_True)195 void SelectEntry( const XubString& rStr, sal_Bool bSelect = sal_True )
196 { ListBox::SelectEntry( rStr, bSelect ); }
197 void SelectEntry( const Color& rColor, sal_Bool bSelect = sal_True );
GetSelectEntry(sal_uInt16 nSelIndex=0) const198 XubString GetSelectEntry( sal_uInt16 nSelIndex = 0 ) const
199 { return ListBox::GetSelectEntry( nSelIndex ); }
200 Color GetSelectEntryColor( sal_uInt16 nSelIndex = 0 ) const;
IsEntrySelected(const XubString & rStr) const201 sal_Bool IsEntrySelected( const XubString& rStr ) const
202 { return ListBox::IsEntrySelected( rStr ); }
203
204 sal_Bool IsEntrySelected( const Color& rColor ) const;
205
206 private:
207 // declared as private because some compilers would generate the default functions
208 ColorListBox( const ColorListBox& );
209 ColorListBox& operator =( const ColorListBox& );
210
211 void SetEntryData( sal_uInt16 nPos, void* pNewData );
212 void* GetEntryData( sal_uInt16 nPos ) const;
213 };
214
SelectEntry(const Color & rColor,sal_Bool bSelect)215 inline void ColorListBox::SelectEntry( const Color& rColor, sal_Bool bSelect )
216 {
217 sal_uInt16 nPos = GetEntryPos( rColor );
218 if ( nPos != LISTBOX_ENTRY_NOTFOUND )
219 ListBox::SelectEntryPos( nPos, bSelect );
220 }
221
IsEntrySelected(const Color & rColor) const222 inline sal_Bool ColorListBox::IsEntrySelected( const Color& rColor ) const
223 {
224 sal_uInt16 nPos = GetEntryPos( rColor );
225 if ( nPos != LISTBOX_ENTRY_NOTFOUND )
226 return IsEntryPosSelected( nPos );
227 else
228 return sal_False;
229 }
230
GetSelectEntryColor(sal_uInt16 nSelIndex) const231 inline Color ColorListBox::GetSelectEntryColor( sal_uInt16 nSelIndex ) const
232 {
233 sal_uInt16 nPos = GetSelectEntryPos( nSelIndex );
234 Color aColor;
235 if ( nPos != LISTBOX_ENTRY_NOTFOUND )
236 aColor = GetEntryColor( nPos );
237 return aColor;
238 }
239
240 // ---------------
241 // - LineListBox -
242 // ---------------
243
244 class SVT_DLLPUBLIC LineListBox : public ListBox
245 {
246 ImpLineList* pLineList;
247 VirtualDevice aVirDev;
248 Size aTxtSize;
249 Color aColor;
250 Color maPaintCol;
251 FieldUnit eUnit;
252 FieldUnit eSourceUnit;
253
254 SVT_DLLPRIVATE void ImpGetLine( long nLine1, long nLine2, long nDistance, Bitmap& rBmp, XubString& rStr );
255 using Window::ImplInit;
256 SVT_DLLPRIVATE void ImplInit();
257 void UpdateLineColors( void );
258 sal_Bool UpdatePaintLineColor( void ); // returns sal_True if maPaintCol has changed
259 inline const Color& GetPaintColor( void ) const;
260 virtual void DataChanged( const DataChangedEvent& rDCEvt );
261
262 public:
263 LineListBox( Window* pParent, WinBits nWinStyle = WB_BORDER );
264 LineListBox( Window* pParent, const ResId& rResId );
265 virtual ~LineListBox();
266
267 using ListBox::InsertEntry;
268 virtual sal_uInt16 InsertEntry( const XubString& rStr, sal_uInt16 nPos = LISTBOX_APPEND );
269 virtual sal_uInt16 InsertEntry( long nLine1, long nLine2 = 0, long nDistance = 0, sal_uInt16 nPos = LISTBOX_APPEND );
270 using ListBox::RemoveEntry;
271 virtual void RemoveEntry( sal_uInt16 nPos );
272 virtual void Clear();
273
274 using ListBox::GetEntryPos;
275 sal_uInt16 GetEntryPos( long nLine1, long nLine2 = 0, long nDistance = 0 ) const;
276 long GetEntryLine1( sal_uInt16 nPos ) const;
277 long GetEntryLine2( sal_uInt16 nPos ) const;
278 long GetEntryDistance( sal_uInt16 nPos ) const;
279
SelectEntry(const XubString & rStr,sal_Bool bSelect=sal_True)280 inline void SelectEntry( const XubString& rStr, sal_Bool bSelect = sal_True ) { ListBox::SelectEntry( rStr, bSelect ); }
281 void SelectEntry( long nLine1, long nLine2 = 0, long nDistance = 0, sal_Bool bSelect = sal_True );
282 long GetSelectEntryLine1( sal_uInt16 nSelIndex = 0 ) const;
283 long GetSelectEntryLine2( sal_uInt16 nSelIndex = 0 ) const;
284 long GetSelectEntryDistance( sal_uInt16 nSelIndex = 0 ) const;
IsEntrySelected(const XubString & rStr) const285 inline sal_Bool IsEntrySelected( const XubString& rStr ) const { return ListBox::IsEntrySelected( rStr ); }
286 sal_Bool IsEntrySelected( long nLine1, long nLine2 = 0, long nDistance = 0 ) const;
287
SetUnit(FieldUnit eNewUnit)288 inline void SetUnit( FieldUnit eNewUnit ) { eUnit = eNewUnit; }
GetUnit() const289 inline FieldUnit GetUnit() const { return eUnit; }
SetSourceUnit(FieldUnit eNewUnit)290 inline void SetSourceUnit( FieldUnit eNewUnit ) { eSourceUnit = eNewUnit; }
GetSourceUnit() const291 inline FieldUnit GetSourceUnit() const { return eSourceUnit; }
292
293 void SetColor( const Color& rColor );
294 inline Color GetColor( void ) const;
295
296 private:
297 // declared as private because some compilers would generate the default methods
298 LineListBox( const LineListBox& );
299 LineListBox& operator =( const LineListBox& );
300 void SetEntryData( sal_uInt16 nPos, void* pNewData );
301 void* GetEntryData( sal_uInt16 nPos ) const;
302 };
303
SelectEntry(long nLine1,long nLine2,long nDistance,sal_Bool bSelect)304 inline void LineListBox::SelectEntry( long nLine1, long nLine2, long nDistance, sal_Bool bSelect )
305 {
306 sal_uInt16 nPos = GetEntryPos( nLine1, nLine2, nDistance );
307 if ( nPos != LISTBOX_ENTRY_NOTFOUND )
308 ListBox::SelectEntryPos( nPos, bSelect );
309 }
310
GetSelectEntryLine1(sal_uInt16 nSelIndex) const311 inline long LineListBox::GetSelectEntryLine1( sal_uInt16 nSelIndex ) const
312 {
313 sal_uInt16 nPos = GetSelectEntryPos( nSelIndex );
314 if ( nPos != LISTBOX_ENTRY_NOTFOUND )
315 return GetEntryLine1( nPos );
316 else
317 return 0;
318 }
319
GetSelectEntryLine2(sal_uInt16 nSelIndex) const320 inline long LineListBox::GetSelectEntryLine2( sal_uInt16 nSelIndex ) const
321 {
322 sal_uInt16 nPos = GetSelectEntryPos( nSelIndex );
323 if ( nPos != LISTBOX_ENTRY_NOTFOUND )
324 return GetEntryLine2( nPos );
325 else
326 return 0;
327 }
328
GetSelectEntryDistance(sal_uInt16 nSelIndex) const329 inline long LineListBox::GetSelectEntryDistance( sal_uInt16 nSelIndex ) const
330 {
331 sal_uInt16 nPos = GetSelectEntryPos( nSelIndex );
332 if ( nPos != LISTBOX_ENTRY_NOTFOUND )
333 return GetEntryDistance( nPos );
334 else
335 return 0;
336 }
337
IsEntrySelected(long nLine1,long nLine2,long nDistance) const338 inline sal_Bool LineListBox::IsEntrySelected( long nLine1, long nLine2, long nDistance ) const
339 {
340 sal_uInt16 nPos = GetEntryPos( nLine1, nLine2, nDistance );
341 if ( nPos != LISTBOX_ENTRY_NOTFOUND )
342 return IsEntryPosSelected( nPos );
343 else
344 return sal_False;
345 }
346
SetColor(const Color & rColor)347 inline void LineListBox::SetColor( const Color& rColor )
348 {
349 aColor = rColor;
350
351 UpdateLineColors();
352 }
353
GetColor(void) const354 inline Color LineListBox::GetColor( void ) const
355 {
356 return aColor;
357 }
358
359
360 // ---------------
361 // - FontNameBox -
362 // ---------------
363
364 class SVT_DLLPUBLIC FontNameBox : public ComboBox
365 {
366 private:
367 ImplFontList* mpFontList;
368 Image maImagePrinterFont;
369 Image maImageBitmapFont;
370 Image maImageScalableFont;
371 sal_Bool mbWYSIWYG;
372 sal_Bool mbSymbols;
373
374 #ifdef _CTRLBOX_CXX
375 SVT_DLLPRIVATE void ImplCalcUserItemSize();
376 SVT_DLLPRIVATE void ImplDestroyFontList();
377 #endif
378
379 void InitBitmaps( void );
380 protected:
381 virtual void DataChanged( const DataChangedEvent& rDCEvt );
382 public:
383 FontNameBox( Window* pParent,
384 WinBits nWinStyle = WB_SORT );
385 FontNameBox( Window* pParent, const ResId& rResId );
386 virtual ~FontNameBox();
387
388 virtual void UserDraw( const UserDrawEvent& rUDEvt );
389
390 void Fill( const FontList* pList );
391
392 void EnableWYSIWYG( sal_Bool bEnable = sal_True );
IsWYSIWYGEnabled() const393 sal_Bool IsWYSIWYGEnabled() const { return mbWYSIWYG; }
394
395 void EnableSymbols( sal_Bool bEnable = sal_True );
IsSymbolsEnabled() const396 sal_Bool IsSymbolsEnabled() const { return mbSymbols; }
397
398 private:
399 // declared as private because some compilers would generate the default functions
400 FontNameBox( const FontNameBox& );
401 FontNameBox& operator =( const FontNameBox& );
402 };
403
404 // ----------------
405 // - FontStyleBox -
406 // ----------------
407
408 class SVT_DLLPUBLIC FontStyleBox : public ComboBox
409 {
410 XubString aLastStyle;
411
412 private:
413 using ComboBox::SetText;
414 public:
415 FontStyleBox( Window* pParent, WinBits nWinStyle = 0 );
416 FontStyleBox( Window* pParent, const ResId& rResId );
417 virtual ~FontStyleBox();
418
419 virtual void Select();
420 virtual void LoseFocus();
421 virtual void Modify();
422
423 void SetText( const XubString& rText );
424 void Fill( const XubString& rName, const FontList* pList );
425
426 private:
427 // declared as private because some compilers would generate the default functions
428 FontStyleBox( const FontStyleBox& );
429 FontStyleBox& operator =( const FontStyleBox& );
430 };
431
SetText(const XubString & rText)432 inline void FontStyleBox::SetText( const XubString& rText )
433 {
434 aLastStyle = rText;
435 ComboBox::SetText( rText );
436 }
437
438 // ---------------
439 // - FontSizeBox -
440 // ---------------
441
442 class SVT_DLLPUBLIC FontSizeBox : public MetricBox
443 {
444 FontInfo aFontInfo;
445 const FontList* pFontList;
446 sal_uInt16 nRelMin;
447 sal_uInt16 nRelMax;
448 sal_uInt16 nRelStep;
449 short nPtRelMin;
450 short nPtRelMax;
451 short nPtRelStep;
452 sal_Bool bRelativeMode:1,
453 bRelative:1,
454 bPtRelative:1,
455 bStdSize:1;
456
457 #ifdef _CTRLBOX_CXX
458 using Window::ImplInit;
459 SVT_DLLPRIVATE void ImplInit();
460 #endif
461
462 protected:
463 virtual XubString CreateFieldText( sal_Int64 nValue ) const;
464
465 public:
466 FontSizeBox( Window* pParent, WinBits nWinStyle = 0 );
467 FontSizeBox( Window* pParent, const ResId& rResId );
468 virtual ~FontSizeBox();
469
470 void Reformat();
471 void Modify();
472
473 void Fill( const FontInfo* pInfo, const FontList* pList );
474
475 void EnableRelativeMode( sal_uInt16 nMin = 50, sal_uInt16 nMax = 150,
476 sal_uInt16 nStep = 5 );
477 void EnablePtRelativeMode( short nMin = -200, short nMax = 200,
478 short nStep = 10 );
IsRelativeMode() const479 sal_Bool IsRelativeMode() const { return bRelativeMode; }
480 void SetRelative( sal_Bool bRelative = sal_False );
IsRelative() const481 sal_Bool IsRelative() const { return bRelative; }
SetPtRelative(sal_Bool bPtRel=sal_True)482 void SetPtRelative( sal_Bool bPtRel = sal_True )
483 { bPtRelative = bPtRel; SetRelative( sal_True ); }
IsPtRelative() const484 sal_Bool IsPtRelative() const { return bPtRelative; }
485
486 virtual void SetValue( sal_Int64 nNewValue, FieldUnit eInUnit );
487 virtual void SetValue( sal_Int64 nNewValue );
488 virtual sal_Int64 GetValue( FieldUnit eOutUnit ) const;
489 virtual sal_Int64 GetValue() const;
490 sal_Int64 GetValue( sal_uInt16 nPos, FieldUnit eOutUnit ) const;
491 void SetUserValue( sal_Int64 nNewValue, FieldUnit eInUnit );
SetUserValue(sal_Int64 nNewValue)492 void SetUserValue( sal_Int64 nNewValue ) { SetUserValue( nNewValue, FUNIT_NONE ); }
493
494 private:
495 // declared as private because some compilers would generate the default functions
496 FontSizeBox( const FontSizeBox& );
497 FontSizeBox& operator =( const FontSizeBox& );
498 };
499
500 #endif // _CTRLBOX_HXX
501