Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef _SV_BTNDLG_HXX
21 : #define _SV_BTNDLG_HXX
22 :
23 : #include <boost/ptr_container/ptr_vector.hpp>
24 :
25 : #include <tools/solar.h>
26 : #include <vcl/dllapi.h>
27 : #include <vcl/dialog.hxx>
28 :
29 : struct ImplBtnDlgItem;
30 : class PushButton;
31 :
32 : // ----------------------
33 : // - ButtonDialog-Types -
34 : // ----------------------
35 :
36 : #define BUTTONDIALOG_BUTTON_NOTFOUND ((sal_uInt16)0xFFFF)
37 :
38 : #define BUTTONDIALOG_DEFBUTTON ((sal_uInt16)0x0001)
39 : #define BUTTONDIALOG_OKBUTTON ((sal_uInt16)0x0002)
40 : #define BUTTONDIALOG_CANCELBUTTON ((sal_uInt16)0x0004)
41 : #define BUTTONDIALOG_HELPBUTTON ((sal_uInt16)0x0008)
42 : #define BUTTONDIALOG_FOCUSBUTTON ((sal_uInt16)0x0010)
43 :
44 : // ----------------
45 : // - ButtonDialog -
46 : // ----------------
47 :
48 : class VCL_DLLPUBLIC ButtonDialog : public Dialog
49 : {
50 : private:
51 : boost::ptr_vector<ImplBtnDlgItem> maItemList;
52 : Size maPageSize;
53 : Size maCtrlSize;
54 : long mnButtonSize;
55 : sal_uInt16 mnCurButtonId;
56 : sal_uInt16 mnFocusButtonId;
57 : sal_Bool mbFormat;
58 : Link maClickHdl;
59 :
60 : SAL_DLLPRIVATE void ImplInitButtonDialogData();
61 : SAL_DLLPRIVATE PushButton* ImplCreatePushButton( sal_uInt16 nBtnFlags );
62 : SAL_DLLPRIVATE ImplBtnDlgItem* ImplGetItem( sal_uInt16 nId ) const;
63 : DECL_DLLPRIVATE_LINK( ImplClickHdl, PushButton* pBtn );
64 : SAL_DLLPRIVATE void ImplPosControls();
65 :
66 : // Copy assignment is forbidden and not implemented.
67 : SAL_DLLPRIVATE ButtonDialog( const ButtonDialog & );
68 : SAL_DLLPRIVATE ButtonDialog& operator=( const ButtonDialog& );
69 : protected:
70 : ButtonDialog( WindowType nType );
71 : SAL_DLLPRIVATE long ImplGetButtonSize();
72 :
73 : public:
74 : ButtonDialog( Window* pParent, WinBits nStyle = WB_STDDIALOG );
75 : ~ButtonDialog();
76 :
77 : virtual void Resize();
78 : virtual void StateChanged( StateChangedType nStateChange );
79 :
80 : virtual void Click();
81 :
82 0 : void SetPageSizePixel( const Size& rSize ) { maPageSize = rSize; }
83 : const Size& GetPageSizePixel() const { return maPageSize; }
84 :
85 0 : sal_uInt16 GetCurButtonId() const { return mnCurButtonId; }
86 :
87 : void AddButton( const OUString& rText, sal_uInt16 nId, sal_uInt16 nBtnFlags, long nSepPixel = 0 );
88 : void AddButton( StandardButtonType eType, sal_uInt16 nId, sal_uInt16 nBtnFlags, long nSepPixel = 0 );
89 : void RemoveButton( sal_uInt16 nId );
90 : void Clear();
91 : sal_uInt16 GetButtonId( sal_uInt16 nButton ) const;
92 : PushButton* GetPushButton( sal_uInt16 nId ) const;
93 : void SetButtonText( sal_uInt16 nId, const OUString& rText );
94 : void SetButtonHelpText( sal_uInt16 nId, const OUString& rText );
95 :
96 0 : void SetFocusButton( sal_uInt16 nId = BUTTONDIALOG_BUTTON_NOTFOUND ) { mnFocusButtonId = nId; }
97 : sal_uInt16 GetFocusButton() const { return mnFocusButtonId; }
98 :
99 : void SetClickHdl( const Link& rLink ) { maClickHdl = rLink; }
100 : const Link& GetClickHdl() const { return maClickHdl; }
101 : };
102 :
103 : #endif // _SV_BTNDLG_HXX
104 :
105 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|