xref: /trunk/main/vcl/inc/vcl/tabctrl.hxx (revision 0d63794c)
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_TABCTRL_HXX
25 #define _SV_TABCTRL_HXX
26 
27 #include "vcl/sv.h"
28 #include "vcl/dllapi.h"
29 #include "vcl/ctrl.hxx"
30 
31 struct ImplTabItem;
32 struct ImplTabCtrlData;
33 class ImplTabItemList;
34 class TabPage;
35 class PushButton;
36 class ListBox;
37 
38 // --------------------
39 // - TabControl-Types -
40 // --------------------
41 
42 #ifndef TAB_APPEND
43 #define TAB_APPEND          ((sal_uInt16)0xFFFF)
44 #define TAB_PAGE_NOTFOUND   ((sal_uInt16)0xFFFF)
45 #endif /* !TAB_APPEND */
46 
47 // --------------
48 // - TabControl -
49 // --------------
50 
51 class VCL_DLLPUBLIC TabControl : public Control
52 {
53 private:
54     void*               mpDummyPtr; // FIXME: remove before integration
55     ImplTabCtrlData*    mpTabCtrlData;
56     long                mnLastWidth;
57     long                mnLastHeight;
58     long                mnBtnSize;
59     long                mnMaxPageWidth;
60     sal_uInt16              mnActPageId;
61     sal_uInt16              mnCurPageId;
62     sal_Bool                mbFormat;
63     sal_Bool                mbRestoreHelpId;
64     sal_Bool                mbRestoreUnqId;
65     sal_Bool                mbSmallInvalidate;
66     sal_Bool                mbExtraSpace;
67     Link                maActivateHdl;
68     Link                maDeactivateHdl;
69 
70     using Control::ImplInitSettings;
71     SAL_DLLPRIVATE void         ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground );
72     SAL_DLLPRIVATE ImplTabItem* ImplGetItem( sal_uInt16 nId ) const;
73     SAL_DLLPRIVATE Size         ImplGetItemSize( ImplTabItem* pItem, long nMaxWidth );
74     SAL_DLLPRIVATE Rectangle    ImplGetTabRect( sal_uInt16 nPos, long nWidth = -1, long nHeight = -1 );
75     SAL_DLLPRIVATE void         ImplChangeTabPage( sal_uInt16 nId, sal_uInt16 nOldId );
76     SAL_DLLPRIVATE sal_Bool         ImplPosCurTabPage();
77     SAL_DLLPRIVATE void         ImplActivateTabPage( sal_Bool bNext );
78     SAL_DLLPRIVATE void         ImplShowFocus();
79     SAL_DLLPRIVATE void         ImplDrawItem( ImplTabItem* pItem, const Rectangle& rCurRect, bool bLayout = false, bool bFirstInGroup = false, bool bLastInGroup = false, bool bIsCurrentItem = false );
80     SAL_DLLPRIVATE void			ImplPaint( const Rectangle& rRect, bool bLayout = false );
81     SAL_DLLPRIVATE void			ImplFreeLayoutData();
82     SAL_DLLPRIVATE long			ImplHandleKeyEvent( const KeyEvent& rKeyEvent );
83 
84     DECL_DLLPRIVATE_LINK(       ImplListBoxSelectHdl, ListBox* );
85     DECL_DLLPRIVATE_LINK(       ImplWindowEventListener, VclSimpleEvent* );
86 
87 
88 protected:
89     using Window::ImplInit;
90     SAL_DLLPRIVATE void         ImplInit( Window* pParent, WinBits nStyle );
91     SAL_DLLPRIVATE void         ImplLoadRes( const ResId& rResId );
92 
93     virtual void		        FillLayoutData() const;
94     virtual const Font&         GetCanonicalFont( const StyleSettings& _rStyle ) const;
95     virtual const Color&        GetCanonicalTextColor( const StyleSettings& _rStyle ) const;
96     SAL_DLLPRIVATE Rectangle*   ImplFindPartRect( const Point& rPt );
97 
98 public:
99                         TabControl( Window* pParent,
100                                     WinBits nStyle = WB_STDTABCONTROL );
101                         TabControl( Window* pParent, const ResId& rResId );
102                         ~TabControl();
103 
104     virtual void        MouseButtonDown( const MouseEvent& rMEvt );
105     virtual void        KeyInput( const KeyEvent& rKEvt );
106     virtual void        Paint( const Rectangle& rRect );
107     virtual void        Resize();
108     virtual void        GetFocus();
109     virtual void        LoseFocus();
110     virtual void        RequestHelp( const HelpEvent& rHEvt );
111     virtual void        Command( const CommandEvent& rCEvt );
112     virtual long        Notify( NotifyEvent& rNEvt );
113     virtual void        StateChanged( StateChangedType nType );
114     virtual void        DataChanged( const DataChangedEvent& rDCEvt );
115     virtual long        PreNotify( NotifyEvent& rNEvt );
116 
117     virtual void        ActivatePage();
118     virtual long        DeactivatePage();
119 
120     virtual Size GetOptimalSize(WindowSizeType eType) const;
121     void                SetMinimumSizePixel( const Size& );
122 
123     void                SetTabPageSizePixel( const Size& rSize );
124     Size                GetTabPageSizePixel() const;
125 
126     //  pixel offset for the tab items, default is (0,0)
127     void                SetItemsOffset( const Point& rOffs );
128     Point               GetItemsOffset() const;
129 
130     void                InsertPage( const ResId& rResId,
131                                     sal_uInt16 nPos = TAB_APPEND );
132     void                InsertPage( sal_uInt16 nPageId, const XubString& rText,
133                                     sal_uInt16 nPos = TAB_APPEND );
134     void                RemovePage( sal_uInt16 nPageId );
135     void                Clear();
136     void                EnablePage( sal_uInt16 nPageId, bool bEnable = true );
137 
138     sal_uInt16              GetPageCount() const;
139     sal_uInt16              GetPageId( sal_uInt16 nPos ) const;
140     sal_uInt16              GetPagePos( sal_uInt16 nPageId ) const;
141     sal_uInt16              GetPageId( const Point& rPos ) const;
142 
143     void                SetCurPageId( sal_uInt16 nPageId );
144     sal_uInt16              GetCurPageId() const;
145 
146     void                SelectTabPage( sal_uInt16 nPageId );
147 
SetMaxPageWidth(long nMaxWidth)148     void                SetMaxPageWidth( long nMaxWidth ) { mnMaxPageWidth = nMaxWidth; }
GetMaxPageWidth() const149     long                GetMaxPageWidth() const { return mnMaxPageWidth; }
ResetMaxPageWidth()150     void                ResetMaxPageWidth() { SetMaxPageWidth( 0 ); }
IsMaxPageWidth() const151     sal_Bool                IsMaxPageWidth() const { return mnMaxPageWidth != 0; }
152 
153     void                SetTabPage( sal_uInt16 nPageId, TabPage* pPage );
154     TabPage*            GetTabPage( sal_uInt16 nPageId ) const;
155     sal_uInt16              GetTabPageResId( sal_uInt16 nPageId ) const;
156 
157     void                SetPageText( sal_uInt16 nPageId, const XubString& rText );
158     XubString           GetPageText( sal_uInt16 nPageId ) const;
159 
160     void                SetHelpText( sal_uInt16 nPageId, const XubString& rText );
161     const XubString&    GetHelpText( sal_uInt16 nPageId ) const;
162 
163     void                SetHelpId( sal_uInt16 nPageId, const rtl::OString& rHelpId );
164     rtl::OString        GetHelpId( sal_uInt16 nPageId ) const;
165 
166     void                SetPageImage( sal_uInt16 nPageId, const Image& rImage );
167     const Image*        GetPageImage( sal_uInt16 nPageId ) const;
168 
SetHelpText(const XubString & rText)169     void                SetHelpText( const XubString& rText )
170                             { Control::SetHelpText( rText ); }
GetHelpText() const171     const XubString&    GetHelpText() const
172                             { return Control::GetHelpText(); }
173 
SetHelpId(const rtl::OString & rId)174     void                SetHelpId( const rtl::OString& rId )
175                             { Control::SetHelpId( rId ); }
GetHelpId() const176     const rtl::OString& GetHelpId() const
177                             { return Control::GetHelpId(); }
178 
SetActivatePageHdl(const Link & rLink)179     void                SetActivatePageHdl( const Link& rLink ) { maActivateHdl = rLink; }
GetActivatePageHdl() const180     const Link&         GetActivatePageHdl() const { return maActivateHdl; }
SetDeactivatePageHdl(const Link & rLink)181     void                SetDeactivatePageHdl( const Link& rLink ) { maDeactivateHdl = rLink; }
GetDeactivatePageHdl() const182     const Link&         GetDeactivatePageHdl() const { return maDeactivateHdl; }
183 
184     // returns (control relative) bounding rectangle for the
185     // character at index nIndex relative to the text of page nPageId
186     using Control::GetCharacterBounds;
187     Rectangle GetCharacterBounds( sal_uInt16 nPageId, long nIndex ) const;
188 
189     // returns the index relative to the text of page nPageId (also returned)
190     // at position rPoint (control relative)
191     using Control::GetIndexForPoint;
192     long GetIndexForPoint( const Point& rPoint, sal_uInt16& rPageId ) const;
193 
194     // returns the bounding rectangle of the union of tab page area and the
195     // corresponding tab
196     Rectangle GetTabPageBounds( sal_uInt16 nPageId ) const;
197 
198     // returns the rectangle of the tab for page nPageId
199     Rectangle GetTabBounds( sal_uInt16 nPageId ) const;
200 };
201 
202 #endif  // _SV_TABCTRL_HXX
203