Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / vcl / btndlg.hxx
blob5c239d72fb8eeca1472b7f65a451b3b3cb9d7ca1
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_VCL_BTNDLG_HXX
21 #define INCLUDED_VCL_BTNDLG_HXX
23 #include <vcl/dllapi.h>
24 #include <vcl/dialog.hxx>
25 #include <o3tl/typed_flags_set.hxx>
27 #include <vector>
28 #include <memory>
30 struct ImplBtnDlgItem;
31 class PushButton;
32 class Button;
34 #define BUTTONDIALOG_BUTTON_NOTFOUND ((sal_uInt16)0xFFFF)
36 enum class ButtonDialogFlags
38 NONE = 0x0000,
39 Default = 0x0001,
40 OK = 0x0002,
41 Cancel = 0x0004,
42 Help = 0x0008,
43 Focus = 0x0010,
45 namespace o3tl
47 template<> struct typed_flags<ButtonDialogFlags> : is_typed_flags<ButtonDialogFlags, 0x001f> {};
50 class VCL_DLLPUBLIC ButtonDialog : public Dialog
52 public:
53 ButtonDialog( vcl::Window* pParent, WinBits nStyle );
54 virtual ~ButtonDialog() override;
55 virtual void dispose() override;
57 virtual void Resize() override;
58 virtual void StateChanged( StateChangedType nStateChange ) override;
60 void SetPageSizePixel( const Size& rSize ) { maPageSize = rSize; }
62 sal_uInt16 GetCurButtonId() const { return mnCurButtonId; }
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 );
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 );
74 void SetFocusButton( sal_uInt16 nId ) { mnFocusButtonId = nId; }
76 protected:
77 ButtonDialog( WindowType nType );
78 SAL_DLLPRIVATE long ImplGetButtonSize();
80 private:
81 ButtonDialog( const ButtonDialog & ) = delete;
82 ButtonDialog& operator=( const ButtonDialog& ) = delete;
84 private:
85 std::vector<std::unique_ptr<ImplBtnDlgItem>> m_ItemList;
86 Size maPageSize;
87 Size maCtrlSize;
88 long mnButtonSize;
89 sal_uInt16 mnCurButtonId;
90 sal_uInt16 mnFocusButtonId;
91 bool mbFormat;
93 SAL_DLLPRIVATE void ImplInitButtonDialogData();
94 SAL_DLLPRIVATE VclPtr<PushButton> ImplCreatePushButton( ButtonDialogFlags nBtnFlags );
95 SAL_DLLPRIVATE ImplBtnDlgItem* ImplGetItem( sal_uInt16 nId ) const;
96 DECL_DLLPRIVATE_LINK( ImplClickHdl, Button* pBtn, void );
97 SAL_DLLPRIVATE void ImplPosControls();
101 #endif // INCLUDED_VCL_BTNDLG_HXX
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */