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: dialog.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 ************************************************************************/
33 #include <vcl/image.hxx>
34 #include <vcl/dialog.hxx>
35 #include <vcl/fixed.hxx>
36 #ifndef _SV_BUTTON_HXX //autogen
37 #include <vcl/button.hxx>
39 #include <vcl/image.hxx>
40 #include <sfx2/tabdlg.hxx>
41 #include <vcl/combobox.hxx>
42 #include <svx/charmap.hxx>
43 #include <sfx2/basedlgs.hxx>
44 #include <vcl/field.hxx>
45 #include <vcl/menubtn.hxx>
46 #include <vcl/scrbar.hxx>
47 #include <vcl/ctrl.hxx>
48 #include <vcl/menu.hxx>
49 #include <vcl/outdev.hxx>
50 #include <svtools/ctrlbox.hxx>
51 #include <svtools/ctrltool.hxx>
52 #include "utility.hxx"
57 #define CATEGORY_NONE 0xFFFF
59 /**************************************************************************/
61 const XubString
GetFontStyleName(const Font
&rFont
);
62 void SetFontStyle(const XubString
&rStyleName
, Font
&rFont
);
64 /**************************************************************************/
66 class SmPrintOptionsTabPage
: public SfxTabPage
68 FixedLine aFixedLine1
;
72 FixedLine aFixedLine2
;
73 RadioButton aSizeNormal
;
74 RadioButton aSizeScaled
;
75 RadioButton aSizeZoomed
;
77 FixedLine aFixedLine3
;
78 CheckBox aNoRightSpaces
;
80 DECL_LINK(SizeButtonClickHdl
, Button
*);
82 virtual BOOL
FillItemSet(SfxItemSet
& rSet
);
83 virtual void Reset(const SfxItemSet
& rSet
);
86 static SfxTabPage
* Create(Window
*pWindow
, const SfxItemSet
&rSet
);
88 SmPrintOptionsTabPage(Window
*pParent
, const SfxItemSet
&rOptions
);
91 /**************************************************************************/
93 class SmShowFont
: public Control
95 virtual void Paint(const Rectangle
&);
98 SmShowFont(Window
*pParent
, const ResId
& rResId
) :
99 Control(pParent
, rResId
)
103 void SetFont(const Font
& rFont
);
106 class SmFontDialog
: public ModalDialog
108 FixedText aFixedText1
;
110 CheckBox aBoldCheckBox
;
111 CheckBox aItalicCheckBox
;
113 CancelButton aCancelButton1
;
114 SmShowFont aShowFont
;
115 FixedText aFixedText2
;
119 DECL_LINK(FontSelectHdl
, ComboBox
*);
120 DECL_LINK(FontModifyHdl
, ComboBox
*);
121 DECL_LINK(AttrChangeHdl
, CheckBox
*);
123 void InitColor_Impl();
125 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
128 SmFontDialog(Window
* pParent
, OutputDevice
*pFntListDevice
, BOOL bHideCheckboxes
, BOOL bFreeRes
= TRUE
);
130 const Font
& GetFont() const { return Face
; }
131 void SetFont(const Font
&rFont
);
134 /**************************************************************************/
136 class SmFontSizeDialog
: public ModalDialog
138 FixedText aFixedText1
;
139 MetricField aBaseSize
;
140 FixedText aFixedText4
;
141 MetricField aTextSize
;
142 FixedText aFixedText5
;
143 MetricField aIndexSize
;
144 FixedText aFixedText6
;
145 MetricField aFunctionSize
;
146 FixedText aFixedText7
;
147 MetricField aOperatorSize
;
148 FixedText aFixedText8
;
149 MetricField aBorderSize
;
150 FixedLine aFixedLine1
;
152 CancelButton aCancelButton1
;
153 PushButton aDefaultButton
;
155 DECL_LINK(DefaultButtonClickHdl
, Button
*);
158 SmFontSizeDialog(Window
*pParent
, BOOL bFreeRes
= TRUE
);
160 void ReadFrom(const SmFormat
&rFormat
);
161 void WriteTo (SmFormat
&rFormat
) const;
164 /**************************************************************************/
166 class SmFontTypeDialog
: public ModalDialog
168 FixedText aFixedText1
;
169 SmFontPickListBox aVariableFont
;
170 FixedText aFixedText2
;
171 SmFontPickListBox aFunctionFont
;
172 FixedText aFixedText3
;
173 SmFontPickListBox aNumberFont
;
174 FixedText aFixedText4
;
175 SmFontPickListBox aTextFont
;
176 FixedText aFixedText5
;
177 SmFontPickListBox aSerifFont
;
178 FixedText aFixedText6
;
179 SmFontPickListBox aSansFont
;
180 FixedText aFixedText7
;
181 SmFontPickListBox aFixedFont
;
182 FixedLine aFixedLine1
;
183 FixedLine aFixedLine2
;
185 CancelButton aCancelButton1
;
186 MenuButton aMenuButton
;
187 PushButton aDefaultButton
;
189 OutputDevice
*pFontListDev
;
191 DECL_LINK(MenuSelectHdl
, Menu
*);
192 DECL_LINK(DefaultButtonClickHdl
, Button
*);
195 SmFontTypeDialog(Window
*pParent
, OutputDevice
*pFntListDevice
, BOOL bFreeRes
= TRUE
);
197 void ReadFrom(const SmFormat
&rFormat
);
198 void WriteTo (SmFormat
&rFormat
) const;
201 /**************************************************************************/
203 #define NOCATEGORIES 10
205 class SmCategoryDesc
: public Resource
208 XubString
*Strings
[4];
209 Bitmap
*Graphics
[4]; /* regular bitmaps */
210 Bitmap
*GraphicsH
[4]; /* high contrast bitmaps */
214 BOOL bIsHighContrast
;
217 SmCategoryDesc(const ResId
&rResId
, USHORT nCategoryIdx
);
220 const XubString
& GetName() const { return Name
; }
221 const XubString
* GetString(USHORT Index
) const { return Strings
[Index
]; }
222 USHORT
GetMinimum(USHORT Index
) { return Minimum
[Index
]; }
223 USHORT
GetMaximum(USHORT Index
) { return Maximum
[Index
]; }
224 USHORT
GetValue(USHORT Index
) const { return Value
[Index
]; }
225 void SetValue(USHORT Index
, USHORT nVal
) { Value
[Index
] = nVal
;}
227 void SetHighContrast( BOOL bVal
) { bIsHighContrast
= bVal
; }
228 const Bitmap
* GetGraphic(USHORT Index
) const
230 return bIsHighContrast
? GraphicsH
[Index
] : Graphics
[Index
];
235 class SmDistanceDialog
: public ModalDialog
237 FixedText aFixedText1
;
238 MetricField aMetricField1
;
239 FixedText aFixedText2
;
240 MetricField aMetricField2
;
241 FixedText aFixedText3
;
242 MetricField aMetricField3
;
244 FixedText aFixedText4
;
245 MetricField aMetricField4
;
247 CancelButton aCancelButton1
;
248 MenuButton aMenuButton
;
249 PushButton aDefaultButton
;
251 FixedLine aFixedLine
;
253 SmCategoryDesc
*Categories
[NOCATEGORIES
];
254 USHORT nActiveCategory
;
255 BOOL bScaleAllBrackets
;
257 DECL_LINK(GetFocusHdl
, Control
*);
258 DECL_LINK(MenuSelectHdl
, Menu
*);
259 DECL_LINK(DefaultButtonClickHdl
, Button
*);
260 DECL_LINK(CheckBoxClickHdl
, CheckBox
*);
262 using Window::SetHelpId
;
263 void SetHelpId(MetricField
&rField
, ULONG nHelpId
);
264 void SetCategory(USHORT Category
);
269 SmDistanceDialog(Window
*pParent
, BOOL bFreeRes
= TRUE
);
272 void ReadFrom(const SmFormat
&rFormat
);
273 void WriteTo (SmFormat
&rFormat
) /*const*/;
276 virtual void DataChanged( const DataChangedEvent
&rEvt
);
280 /**************************************************************************/
283 class SmAlignDialog
: public ModalDialog
288 FixedLine aFixedLine1
;
290 CancelButton aCancelButton1
;
291 PushButton aDefaultButton
;
293 DECL_LINK(DefaultButtonClickHdl
, Button
*);
296 SmAlignDialog(Window
*pParent
, BOOL bFreeRes
= TRUE
);
298 void ReadFrom(const SmFormat
&rFormat
);
299 void WriteTo (SmFormat
&rFormat
) const;
302 /**************************************************************************/
304 class SmShowSymbolSet
: public Control
307 ScrollBar aVScrollBar
;
310 Link aDblClickHdlLink
;
312 USHORT nRows
, nColumns
;
313 USHORT nSelectSymbol
;
315 virtual void Paint(const Rectangle
&);
316 virtual void MouseButtonDown(const MouseEvent
& rMEvt
);
317 virtual void KeyInput(const KeyEvent
& rKEvt
);
319 DECL_LINK( ScrollHdl
, ScrollBar
* );
322 SmShowSymbolSet(Window
*pParent
, const ResId
& rResId
);
324 void SetSymbolSet(const SmSymSet
& rSymbolSet
);
326 void SelectSymbol(USHORT nSymbol
);
327 USHORT
GetSelectSymbol() const { return nSelectSymbol
; }
329 void SetSelectHdl(const Link
& rLink
) { aSelectHdlLink
= rLink
; }
330 void SetDblClickHdl(const Link
& rLink
) { aDblClickHdlLink
= rLink
; }
333 ////////////////////////////////////////////////////////////////////////////////
335 class SmShowSymbol
: public Control
337 Link aDblClickHdlLink
;
339 virtual void Paint(const Rectangle
&);
340 virtual void MouseButtonDown(const MouseEvent
& rMEvt
);
343 SmShowSymbol(Window
*pParent
, const ResId
& rResId
) :
344 Control(pParent
, rResId
) {}
346 void SetSymbol(const SmSym
*pSymbol
);
347 void SetDblClickHdl(const Link
&rLink
) { aDblClickHdlLink
= rLink
; }
350 ////////////////////////////////////////////////////////////////////////////////
352 class SmSymDefineDialog
;
354 class SmSymbolDialog
: public ModalDialog
356 FixedText aSymbolSetText
;
358 SmShowSymbolSet aSymbolSetDisplay
;
359 FixedText aSymbolName
;
360 SmShowSymbol aSymbolDisplay
;
362 PushButton aCloseBtn
;
365 SmViewShell
&rViewSh
;
366 SmSymSetManager
&rSymSetMgr
;
367 const SmSymSet
*pSymSet
;
369 OutputDevice
*pFontListDev
;
371 DECL_LINK(SymbolSetChangeHdl
, ListBox
*);
372 DECL_LINK(SymbolChangeHdl
, SmShowSymbolSet
*);
373 DECL_LINK(SymbolDblClickHdl
, SmShowSymbolSet
*);
374 DECL_LINK(CloseClickHdl
, Button
*);
375 DECL_LINK(EditClickHdl
, Button
*);
376 DECL_LINK(GetClickHdl
, Button
*);
378 void FillSymbolSets(BOOL bDeleteText
= TRUE
);
379 void SetSymbolSetManager(SmSymSetManager
&rMgr
);
380 const SmSym
*GetSymbol() const;
381 void InitColor_Impl();
383 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
386 SmSymbolDialog(Window
* pParent
, OutputDevice
*pFntListDevice
,
387 SmSymSetManager
&rSymSetMgr
, SmViewShell
&rViewShell
, BOOL bFreeRes
= TRUE
);
388 virtual ~SmSymbolDialog();
390 BOOL
SelectSymbolSet(const XubString
&rSymbolSetName
);
391 void SelectSymbol(USHORT nSymbolPos
);
392 USHORT
GetSelectedSymbol() const { return aSymbolSetDisplay
.GetSelectSymbol(); }
395 ////////////////////////////////////////////////////////////////////////////////
397 class SmShowChar
: public Control
399 virtual void Paint(const Rectangle
&);
402 SmShowChar(Window
*pParent
, const ResId
& rResId
)
403 : Control(pParent
, rResId
)
407 void SetChar(xub_Unicode aChar
);
408 void SetFont(const Font
&rFont
);
411 ////////////////////////////////////////////////////////////////////////////////
413 class SmSymDefineDialog
: public ModalDialog
415 FixedText aOldSymbolText
;
416 ComboBox aOldSymbols
;
417 FixedText aOldSymbolSetText
;
418 ComboBox aOldSymbolSets
;
419 SvxShowCharSet aCharsetDisplay
;
420 FixedText aSymbolText
;
422 FixedText aSymbolSetText
;
423 ComboBox aSymbolSets
;
426 FixedText aFontsSubsetFT
;
427 ListBox aFontsSubsetLB
;
428 FixedText aStyleText
;
429 FontStyleBox aStyles
;
430 FixedText aOldSymbolName
;
431 SmShowChar aOldSymbolDisplay
;
432 FixedText aOldSymbolSetName
;
433 FixedText aSymbolName
;
434 SmShowChar aSymbolDisplay
;
435 FixedText aSymbolSetName
;
437 CancelButton aCancelBtn
;
439 PushButton aChangeBtn
;
440 PushButton aDeleteBtn
;
441 FixedImage aRightArrow
;
442 Image aRigthArrow_Im
;
443 Image aRigthArrow_Im_HC
; // hi-contrast version
445 SmSymSetManager aSymSetMgrCopy
,
447 const SmSym
*pOrigSymbol
;
449 const SubsetMap
*pSubsetMap
;
452 DECL_LINK(OldSymbolChangeHdl
, ComboBox
*);
453 DECL_LINK(OldSymbolSetChangeHdl
, ComboBox
*);
454 DECL_LINK(ModifyHdl
, ComboBox
*);
455 DECL_LINK(FontChangeHdl
, ListBox
*);
456 DECL_LINK(SubsetChangeHdl
, ListBox
*);
457 DECL_LINK(StyleChangeHdl
, ComboBox
*);
458 DECL_LINK(CharHighlightHdl
, Control
* pControl
);
459 DECL_LINK(AddClickHdl
, Button
*);
460 DECL_LINK(ChangeClickHdl
, Button
*);
461 DECL_LINK(DeleteClickHdl
, Button
*);
463 void FillSymbols(ComboBox
&rComboBox
, BOOL bDeleteText
= TRUE
);
464 void FillSymbolSets(ComboBox
&rComboBox
, BOOL bDeleteText
= TRUE
);
465 void FillFonts(BOOL bDeleteText
= TRUE
);
466 void FillStyles(BOOL bDeleteText
= TRUE
);
468 void SetSymbolSetManager(const SmSymSetManager
&rMgr
);
469 void SetFont(const XubString
&rFontName
, const XubString
&rStyleName
);
470 void SetOrigSymbol(const SmSym
*pSymbol
, const XubString
&rSymbolSetName
);
471 void UpdateButtons();
473 BOOL
SelectSymbolSet(ComboBox
&rComboBox
, const XubString
&rSymbolSetName
,
475 BOOL
SelectSymbol(ComboBox
&rComboBox
, const XubString
&rSymbolName
,
477 BOOL
SelectFont(const XubString
&rFontName
, BOOL bApplyFont
);
478 BOOL
SelectStyle(const XubString
&rStyleName
, BOOL bApplyFont
);
481 SmSymSet
*GetSymbolSet(const ComboBox
&rComboBox
);
482 inline const SmSymSet
*GetSymbolSet(const ComboBox
&rComboBox
) const;
483 SmSym
*GetSymbol(const ComboBox
&rComboBox
);
484 inline const SmSym
*GetSymbol(const ComboBox
&rComboBox
) const;
486 void InitColor_Impl();
488 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
491 SmSymDefineDialog(Window
*pParent
, OutputDevice
*pFntListDevice
, SmSymSetManager
&rMgr
, BOOL bFreeRes
= TRUE
);
492 ~SmSymDefineDialog();
494 using OutputDevice::SetFont
;
497 virtual short Execute();
499 inline BOOL
SelectOldSymbolSet(const XubString
&rSymbolSetName
);
500 inline BOOL
SelectOldSymbol(const XubString
&rSymbolName
);
501 inline BOOL
SelectSymbolSet(const XubString
&rSymbolSetName
);
502 inline BOOL
SelectSymbol(const XubString
&rSymbolName
);
503 BOOL
SelectFont(const XubString
&rFontName
) { return SelectFont(rFontName
, TRUE
); }
504 BOOL
SelectStyle(const XubString
&rStyleName
) { return SelectStyle(rStyleName
, TRUE
); };
505 void SelectChar(xub_Unicode cChar
);
508 inline const SmSymSet
* SmSymDefineDialog::GetSymbolSet(const ComboBox
&rComboBox
) const
510 return ((SmSymDefineDialog
*) this)->GetSymbolSet(rComboBox
);
513 inline const SmSym
* SmSymDefineDialog::GetSymbol(const ComboBox
&rComboBox
) const
515 return ((SmSymDefineDialog
*) this)->GetSymbol(rComboBox
);
518 inline BOOL
SmSymDefineDialog::SelectOldSymbolSet(const XubString
&rSymbolSetName
)
520 return SelectSymbolSet(aOldSymbolSets
, rSymbolSetName
, FALSE
);
523 inline BOOL
SmSymDefineDialog::SelectOldSymbol(const XubString
&rSymbolName
)
525 return SelectSymbol(aOldSymbols
, rSymbolName
, FALSE
);
528 inline BOOL
SmSymDefineDialog::SelectSymbolSet(const XubString
&rSymbolSetName
)
530 return SelectSymbolSet(aSymbolSets
, rSymbolSetName
, FALSE
);
533 inline BOOL
SmSymDefineDialog::SelectSymbol(const XubString
&rSymbolName
)
535 return SelectSymbol(aSymbols
, rSymbolName
, FALSE
);