xref: /AOO41X/main/vcl/inc/vcl/btndlg.hxx (revision 0d63794c5b3715d9f8da2f4b7b451b7426ee7897)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SV_BTNDLG_HXX
25 #define _SV_BTNDLG_HXX
26 
27 #include <vcl/sv.h>
28 #include <vcl/dllapi.h>
29 #include <vcl/dialog.hxx>
30 
31 struct ImplBtnDlgItem;
32 class ImplBtnDlgItemList;
33 class PushButton;
34 
35 // ----------------------
36 // - ButtonDialog-Types -
37 // ----------------------
38 
39 #define BUTTONDIALOG_BUTTON_NOTFOUND            ((sal_uInt16)0xFFFF)
40 
41 #define BUTTONDIALOG_DEFBUTTON                  ((sal_uInt16)0x0001)
42 #define BUTTONDIALOG_OKBUTTON                   ((sal_uInt16)0x0002)
43 #define BUTTONDIALOG_CANCELBUTTON               ((sal_uInt16)0x0004)
44 #define BUTTONDIALOG_HELPBUTTON                 ((sal_uInt16)0x0008)
45 #define BUTTONDIALOG_FOCUSBUTTON                ((sal_uInt16)0x0010)
46 
47 // ----------------
48 // - ButtonDialog -
49 // ----------------
50 
51 class VCL_DLLPUBLIC ButtonDialog : public Dialog
52 {
53 private:
54     ImplBtnDlgItemList* mpItemList;
55     Size                maPageSize;
56     Size                maCtrlSize;
57     long                mnButtonSize;
58     sal_uInt16              mnCurButtonId;
59     sal_uInt16              mnFocusButtonId;
60     sal_Bool                mbFormat;
61     Link                maClickHdl;
62 
63     SAL_DLLPRIVATE void             ImplInitButtonDialogData();
64     SAL_DLLPRIVATE PushButton*      ImplCreatePushButton( sal_uInt16 nBtnFlags );
65     SAL_DLLPRIVATE ImplBtnDlgItem*  ImplGetItem( sal_uInt16 nId ) const;
66     DECL_DLLPRIVATE_LINK(           ImplClickHdl, PushButton* pBtn );
67     SAL_DLLPRIVATE void             ImplPosControls();
68 
69     // Copy assignment is forbidden and not implemented.
70     SAL_DLLPRIVATE      ButtonDialog( const ButtonDialog & );
71     SAL_DLLPRIVATE      ButtonDialog& operator=( const ButtonDialog& );
72 protected:
73                         ButtonDialog( WindowType nType );
74     SAL_DLLPRIVATE long ImplGetButtonSize();
75 
76 public:
77                         ButtonDialog( Window* pParent, WinBits nStyle = WB_STDDIALOG );
78                         ButtonDialog( Window* pParent, const ResId& rResId );
79                         ~ButtonDialog();
80 
81     virtual void        Resize();
82     virtual void        StateChanged( StateChangedType nStateChange );
83 
84     virtual void        Click();
85 
SetPageSizePixel(const Size & rSize)86     void                SetPageSizePixel( const Size& rSize ) { maPageSize = rSize; }
GetPageSizePixel() const87     const Size&         GetPageSizePixel() const { return maPageSize; }
88 
GetCurButtonId() const89     sal_uInt16              GetCurButtonId() const { return mnCurButtonId; }
90 
91     void                AddButton( const XubString& rText, sal_uInt16 nId, sal_uInt16 nBtnFlags, long nSepPixel = 0 );
92     void                AddButton( StandardButtonType eType, sal_uInt16 nId, sal_uInt16 nBtnFlags, long nSepPixel = 0 );
93     void                AddButton( PushButton* pBtn, sal_uInt16 nId, sal_uInt16 nBtnFlags, long nSepPixel = 0 );
94     void                RemoveButton( sal_uInt16 nId );
95     void                Clear();
96     sal_uInt16              GetButtonCount() const;
97     sal_uInt16              GetButtonId( sal_uInt16 nButton ) const;
98     PushButton*         GetPushButton( sal_uInt16 nId ) const;
99     void                SetButtonText( sal_uInt16 nId, const XubString& rText );
100     XubString           GetButtonText( sal_uInt16 nId ) const;
101     void                SetButtonHelpText( sal_uInt16 nId, const XubString& rText );
102     XubString           GetButtonHelpText( sal_uInt16 nId ) const;
103     void                SetButtonHelpId( sal_uInt16 nId, const rtl::OString& rHelpId );
104     rtl::OString        GetButtonHelpId( sal_uInt16 nId ) const;
105 
SetFocusButton(sal_uInt16 nId=BUTTONDIALOG_BUTTON_NOTFOUND)106     void                SetFocusButton( sal_uInt16 nId = BUTTONDIALOG_BUTTON_NOTFOUND ) { mnFocusButtonId = nId; }
GetFocusButton() const107     sal_uInt16              GetFocusButton() const { return mnFocusButtonId; }
108 
SetClickHdl(const Link & rLink)109     void                SetClickHdl( const Link& rLink ) { maClickHdl = rLink; }
GetClickHdl() const110     const Link&         GetClickHdl() const { return maClickHdl; }
111 };
112 
113 #endif  // _SV_BTNDLG_HXX
114