Branch libreoffice-5-0-4
[LibreOffice.git] / include / vcl / btndlg.hxx
blob156a50d416e8c7b67f521078f5db82be3f282f79
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 <boost/ptr_container/ptr_vector.hpp>
24 #include <vcl/dllapi.h>
25 #include <vcl/dialog.hxx>
26 #include <o3tl/typed_flags_set.hxx>
28 struct ImplBtnDlgItem;
29 class PushButton;
31 #define BUTTONDIALOG_BUTTON_NOTFOUND ((sal_uInt16)0xFFFF)
33 enum class ButtonDialogFlags
35 NONE = 0x0000,
36 Default = 0x0001,
37 OK = 0x0002,
38 Cancel = 0x0004,
39 Help = 0x0008,
40 Focus = 0x0010,
42 namespace o3tl
44 template<> struct typed_flags<ButtonDialogFlags> : is_typed_flags<ButtonDialogFlags, 0x001f> {};
47 class VCL_DLLPUBLIC ButtonDialog : public Dialog
49 public:
50 ButtonDialog( vcl::Window* pParent, WinBits nStyle = WB_STDDIALOG );
51 virtual ~ButtonDialog();
52 virtual void dispose() SAL_OVERRIDE;
54 virtual void Resize() SAL_OVERRIDE;
55 virtual void StateChanged( StateChangedType nStateChange ) SAL_OVERRIDE;
57 void Click();
59 void SetPageSizePixel( const Size& rSize ) { maPageSize = rSize; }
60 const Size& GetPageSizePixel() const { return maPageSize; }
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 = BUTTONDIALOG_BUTTON_NOTFOUND ) { mnFocusButtonId = nId; }
75 sal_uInt16 GetFocusButton() const { return mnFocusButtonId; }
77 void SetClickHdl( const Link<>& rLink ) { maClickHdl = rLink; }
78 const Link<>& GetClickHdl() const { return maClickHdl; }
80 protected:
81 ButtonDialog( WindowType nType );
82 SAL_DLLPRIVATE long ImplGetButtonSize();
84 private:
85 ButtonDialog( const ButtonDialog & ) SAL_DELETED_FUNCTION;
86 ButtonDialog& operator=( const ButtonDialog& ) SAL_DELETED_FUNCTION;
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;
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();
106 #endif // INCLUDED_VCL_BTNDLG_HXX
108 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */