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 INCLUDED_VCL_BTNDLG_HXX
21 : #define INCLUDED_VCL_BTNDLG_HXX
22 :
23 : #include <boost/ptr_container/ptr_vector.hpp>
24 : #include <vcl/dllapi.h>
25 : #include <vcl/dialog.hxx>
26 : #include <o3tl/typed_flags_set.hxx>
27 :
28 : struct ImplBtnDlgItem;
29 : class PushButton;
30 :
31 : #define BUTTONDIALOG_BUTTON_NOTFOUND ((sal_uInt16)0xFFFF)
32 :
33 : enum class ButtonDialogFlags
34 : {
35 : NONE = 0x0000,
36 : Default = 0x0001,
37 : OK = 0x0002,
38 : Cancel = 0x0004,
39 : Help = 0x0008,
40 : Focus = 0x0010,
41 : };
42 : namespace o3tl
43 : {
44 : template<> struct typed_flags<ButtonDialogFlags> : is_typed_flags<ButtonDialogFlags, 0x001f> {};
45 : }
46 :
47 : class VCL_DLLPUBLIC ButtonDialog : public Dialog
48 : {
49 : public:
50 : ButtonDialog( vcl::Window* pParent, WinBits nStyle = WB_STDDIALOG );
51 : virtual ~ButtonDialog();
52 : virtual void dispose() SAL_OVERRIDE;
53 :
54 : virtual void Resize() SAL_OVERRIDE;
55 : virtual void StateChanged( StateChangedType nStateChange ) SAL_OVERRIDE;
56 :
57 : void Click();
58 :
59 0 : void SetPageSizePixel( const Size& rSize ) { maPageSize = rSize; }
60 : const Size& GetPageSizePixel() const { return maPageSize; }
61 :
62 0 : sal_uInt16 GetCurButtonId() const { return mnCurButtonId; }
63 :
64 : void AddButton( const OUString& rText, sal_uInt16 nId, ButtonDialogFlags nBtnFlags = ButtonDialogFlags::NONE, long nSepPixel = 0 );
65 : void AddButton( StandardButtonType eType, sal_uInt16 nId, ButtonDialogFlags nBtnFlags = ButtonDialogFlags::NONE, long nSepPixel = 0 );
66 : void RemoveButton( sal_uInt16 nId );
67 :
68 : void Clear();
69 : sal_uInt16 GetButtonId( sal_uInt16 nButton ) const;
70 : PushButton* GetPushButton( sal_uInt16 nId ) const;
71 : void SetButtonText( sal_uInt16 nId, const OUString& rText );
72 : void SetButtonHelpText( sal_uInt16 nId, const OUString& rText );
73 :
74 0 : void SetFocusButton( sal_uInt16 nId = BUTTONDIALOG_BUTTON_NOTFOUND ) { mnFocusButtonId = nId; }
75 : sal_uInt16 GetFocusButton() const { return mnFocusButtonId; }
76 :
77 : void SetClickHdl( const Link<>& rLink ) { maClickHdl = rLink; }
78 : const Link<>& GetClickHdl() const { return maClickHdl; }
79 :
80 : protected:
81 : ButtonDialog( WindowType nType );
82 : SAL_DLLPRIVATE long ImplGetButtonSize();
83 :
84 : private:
85 : ButtonDialog( const ButtonDialog & ) SAL_DELETED_FUNCTION;
86 : ButtonDialog& operator=( const ButtonDialog& ) SAL_DELETED_FUNCTION;
87 :
88 : private:
89 : boost::ptr_vector<ImplBtnDlgItem> maItemList;
90 : Size maPageSize;
91 : Size maCtrlSize;
92 : long mnButtonSize;
93 : sal_uInt16 mnCurButtonId;
94 : sal_uInt16 mnFocusButtonId;
95 : bool mbFormat;
96 : Link<> maClickHdl;
97 :
98 : SAL_DLLPRIVATE void ImplInitButtonDialogData();
99 : SAL_DLLPRIVATE PushButton* ImplCreatePushButton( ButtonDialogFlags nBtnFlags );
100 : SAL_DLLPRIVATE ImplBtnDlgItem* ImplGetItem( sal_uInt16 nId ) const;
101 : DECL_DLLPRIVATE_LINK( ImplClickHdl, PushButton* pBtn );
102 : SAL_DLLPRIVATE void ImplPosControls();
103 :
104 : };
105 :
106 : #endif // INCLUDED_VCL_BTNDLG_HXX
107 :
108 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|