xref: /AOO41X/main/vcl/inc/vcl/tabctrl.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _SV_TABCTRL_HXX
29 #define _SV_TABCTRL_HXX
30 
31 #include "vcl/sv.h"
32 #include "vcl/dllapi.h"
33 #include "vcl/ctrl.hxx"
34 
35 struct ImplTabItem;
36 struct ImplTabCtrlData;
37 class ImplTabItemList;
38 class TabPage;
39 class PushButton;
40 class ListBox;
41 
42 // --------------------
43 // - TabControl-Types -
44 // --------------------
45 
46 #ifndef TAB_APPEND
47 #define TAB_APPEND          ((sal_uInt16)0xFFFF)
48 #define TAB_PAGE_NOTFOUND   ((sal_uInt16)0xFFFF)
49 #endif /* !TAB_APPEND */
50 
51 // --------------
52 // - TabControl -
53 // --------------
54 
55 class VCL_DLLPUBLIC TabControl : public Control
56 {
57 private:
58     void*               mpDummyPtr; // FIXME: remove before integration
59     ImplTabCtrlData*    mpTabCtrlData;
60     long                mnLastWidth;
61     long                mnLastHeight;
62     long                mnBtnSize;
63     long                mnMaxPageWidth;
64     sal_uInt16              mnActPageId;
65     sal_uInt16              mnCurPageId;
66     sal_Bool                mbFormat;
67     sal_Bool                mbRestoreHelpId;
68     sal_Bool                mbRestoreUnqId;
69     sal_Bool                mbSmallInvalidate;
70     sal_Bool                mbExtraSpace;
71     Link                maActivateHdl;
72     Link                maDeactivateHdl;
73 
74     using Control::ImplInitSettings;
75     SAL_DLLPRIVATE void         ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground );
76     SAL_DLLPRIVATE ImplTabItem* ImplGetItem( sal_uInt16 nId ) const;
77     SAL_DLLPRIVATE Size         ImplGetItemSize( ImplTabItem* pItem, long nMaxWidth );
78     SAL_DLLPRIVATE Rectangle    ImplGetTabRect( sal_uInt16 nPos, long nWidth = -1, long nHeight = -1 );
79     SAL_DLLPRIVATE void         ImplChangeTabPage( sal_uInt16 nId, sal_uInt16 nOldId );
80     SAL_DLLPRIVATE sal_Bool         ImplPosCurTabPage();
81     SAL_DLLPRIVATE void         ImplActivateTabPage( sal_Bool bNext );
82     SAL_DLLPRIVATE void         ImplShowFocus();
83     SAL_DLLPRIVATE void         ImplDrawItem( ImplTabItem* pItem, const Rectangle& rCurRect, bool bLayout = false, bool bFirstInGroup = false, bool bLastInGroup = false, bool bIsCurrentItem = false );
84     SAL_DLLPRIVATE void			ImplPaint( const Rectangle& rRect, bool bLayout = false );
85     SAL_DLLPRIVATE void			ImplFreeLayoutData();
86     SAL_DLLPRIVATE long			ImplHandleKeyEvent( const KeyEvent& rKeyEvent );
87 
88     DECL_DLLPRIVATE_LINK(       ImplListBoxSelectHdl, ListBox* );
89     DECL_DLLPRIVATE_LINK(       ImplWindowEventListener, VclSimpleEvent* );
90 
91 
92 protected:
93     using Window::ImplInit;
94     SAL_DLLPRIVATE void         ImplInit( Window* pParent, WinBits nStyle );
95     SAL_DLLPRIVATE void         ImplLoadRes( const ResId& rResId );
96 
97     virtual void		        FillLayoutData() const;
98     virtual const Font&         GetCanonicalFont( const StyleSettings& _rStyle ) const;
99     virtual const Color&        GetCanonicalTextColor( const StyleSettings& _rStyle ) const;
100     SAL_DLLPRIVATE Rectangle*   ImplFindPartRect( const Point& rPt );
101 
102 public:
103                         TabControl( Window* pParent,
104                                     WinBits nStyle = WB_STDTABCONTROL );
105                         TabControl( Window* pParent, const ResId& rResId );
106                         ~TabControl();
107 
108     virtual void        MouseButtonDown( const MouseEvent& rMEvt );
109     virtual void        KeyInput( const KeyEvent& rKEvt );
110     virtual void        Paint( const Rectangle& rRect );
111     virtual void        Resize();
112     virtual void        GetFocus();
113     virtual void        LoseFocus();
114     virtual void        RequestHelp( const HelpEvent& rHEvt );
115     virtual void        Command( const CommandEvent& rCEvt );
116     virtual long        Notify( NotifyEvent& rNEvt );
117     virtual void        StateChanged( StateChangedType nType );
118     virtual void        DataChanged( const DataChangedEvent& rDCEvt );
119     virtual long        PreNotify( NotifyEvent& rNEvt );
120 
121     virtual void        ActivatePage();
122     virtual long        DeactivatePage();
123 
124     virtual Size GetOptimalSize(WindowSizeType eType) const;
125     void                SetMinimumSizePixel( const Size& );
126 
127     void                SetTabPageSizePixel( const Size& rSize );
128     Size                GetTabPageSizePixel() const;
129 
130     //  pixel offset for the tab items, default is (0,0)
131     void                SetItemsOffset( const Point& rOffs );
132     Point               GetItemsOffset() const;
133 
134     void                InsertPage( const ResId& rResId,
135                                     sal_uInt16 nPos = TAB_APPEND );
136     void                InsertPage( sal_uInt16 nPageId, const XubString& rText,
137                                     sal_uInt16 nPos = TAB_APPEND );
138     void                RemovePage( sal_uInt16 nPageId );
139     void                Clear();
140     void                EnablePage( sal_uInt16 nPageId, bool bEnable = true );
141 
142     sal_uInt16              GetPageCount() const;
143     sal_uInt16              GetPageId( sal_uInt16 nPos ) const;
144     sal_uInt16              GetPagePos( sal_uInt16 nPageId ) const;
145     sal_uInt16              GetPageId( const Point& rPos ) const;
146 
147     void                SetCurPageId( sal_uInt16 nPageId );
148     sal_uInt16              GetCurPageId() const;
149 
150     void                SelectTabPage( sal_uInt16 nPageId );
151 
152     void                SetMaxPageWidth( long nMaxWidth ) { mnMaxPageWidth = nMaxWidth; }
153     long                GetMaxPageWidth() const { return mnMaxPageWidth; }
154     void                ResetMaxPageWidth() { SetMaxPageWidth( 0 ); }
155     sal_Bool                IsMaxPageWidth() const { return mnMaxPageWidth != 0; }
156 
157     void                SetTabPage( sal_uInt16 nPageId, TabPage* pPage );
158     TabPage*            GetTabPage( sal_uInt16 nPageId ) const;
159     sal_uInt16              GetTabPageResId( sal_uInt16 nPageId ) const;
160 
161     void                SetPageText( sal_uInt16 nPageId, const XubString& rText );
162     XubString           GetPageText( sal_uInt16 nPageId ) const;
163 
164     void                SetHelpText( sal_uInt16 nPageId, const XubString& rText );
165     const XubString&    GetHelpText( sal_uInt16 nPageId ) const;
166 
167     void                SetHelpId( sal_uInt16 nPageId, const rtl::OString& rHelpId );
168     rtl::OString        GetHelpId( sal_uInt16 nPageId ) const;
169 
170     void                SetPageImage( sal_uInt16 nPageId, const Image& rImage );
171     const Image*        GetPageImage( sal_uInt16 nPageId ) const;
172 
173     void                SetHelpText( const XubString& rText )
174                             { Control::SetHelpText( rText ); }
175     const XubString&    GetHelpText() const
176                             { return Control::GetHelpText(); }
177 
178     void                SetHelpId( const rtl::OString& rId )
179                             { Control::SetHelpId( rId ); }
180     const rtl::OString& GetHelpId() const
181                             { return Control::GetHelpId(); }
182 
183     void                SetActivatePageHdl( const Link& rLink ) { maActivateHdl = rLink; }
184     const Link&         GetActivatePageHdl() const { return maActivateHdl; }
185     void                SetDeactivatePageHdl( const Link& rLink ) { maDeactivateHdl = rLink; }
186     const Link&         GetDeactivatePageHdl() const { return maDeactivateHdl; }
187 
188     // returns (control relative) bounding rectangle for the
189     // character at index nIndex relative to the text of page nPageId
190     using Control::GetCharacterBounds;
191     Rectangle GetCharacterBounds( sal_uInt16 nPageId, long nIndex ) const;
192 
193     // returns the index relative to the text of page nPageId (also returned)
194     // at position rPoint (control relative)
195     using Control::GetIndexForPoint;
196     long GetIndexForPoint( const Point& rPoint, sal_uInt16& rPageId ) const;
197 
198     // returns the bounding rectangle of the union of tab page area and the
199     // corresponding tab
200     Rectangle GetTabPageBounds( sal_uInt16 nPageId ) const;
201 
202     // returns the rectangle of the tab for page nPageId
203     Rectangle GetTabBounds( sal_uInt16 nPageId ) const;
204 };
205 
206 #endif  // _SV_TABCTRL_HXX
207