xref: /AOO41X/main/vcl/inc/vcl/tabctrl.hxx (revision 0d63794c5b3715d9f8da2f4b7b451b7426ee7897)
1*0d63794cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*0d63794cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*0d63794cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*0d63794cSAndrew Rist  * distributed with this work for additional information
6*0d63794cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*0d63794cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*0d63794cSAndrew Rist  * "License"); you may not use this file except in compliance
9*0d63794cSAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*0d63794cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*0d63794cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*0d63794cSAndrew Rist  * software distributed under the License is distributed on an
15*0d63794cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*0d63794cSAndrew Rist  * KIND, either express or implied.  See the License for the
17*0d63794cSAndrew Rist  * specific language governing permissions and limitations
18*0d63794cSAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*0d63794cSAndrew Rist  *************************************************************/
21*0d63794cSAndrew Rist 
22*0d63794cSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _SV_TABCTRL_HXX
25cdf0e10cSrcweir #define _SV_TABCTRL_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "vcl/sv.h"
28cdf0e10cSrcweir #include "vcl/dllapi.h"
29cdf0e10cSrcweir #include "vcl/ctrl.hxx"
30cdf0e10cSrcweir 
31cdf0e10cSrcweir struct ImplTabItem;
32cdf0e10cSrcweir struct ImplTabCtrlData;
33cdf0e10cSrcweir class ImplTabItemList;
34cdf0e10cSrcweir class TabPage;
35cdf0e10cSrcweir class PushButton;
36cdf0e10cSrcweir class ListBox;
37cdf0e10cSrcweir 
38cdf0e10cSrcweir // --------------------
39cdf0e10cSrcweir // - TabControl-Types -
40cdf0e10cSrcweir // --------------------
41cdf0e10cSrcweir 
42cdf0e10cSrcweir #ifndef TAB_APPEND
43cdf0e10cSrcweir #define TAB_APPEND          ((sal_uInt16)0xFFFF)
44cdf0e10cSrcweir #define TAB_PAGE_NOTFOUND   ((sal_uInt16)0xFFFF)
45cdf0e10cSrcweir #endif /* !TAB_APPEND */
46cdf0e10cSrcweir 
47cdf0e10cSrcweir // --------------
48cdf0e10cSrcweir // - TabControl -
49cdf0e10cSrcweir // --------------
50cdf0e10cSrcweir 
51cdf0e10cSrcweir class VCL_DLLPUBLIC TabControl : public Control
52cdf0e10cSrcweir {
53cdf0e10cSrcweir private:
54cdf0e10cSrcweir     void*               mpDummyPtr; // FIXME: remove before integration
55cdf0e10cSrcweir     ImplTabCtrlData*    mpTabCtrlData;
56cdf0e10cSrcweir     long                mnLastWidth;
57cdf0e10cSrcweir     long                mnLastHeight;
58cdf0e10cSrcweir     long                mnBtnSize;
59cdf0e10cSrcweir     long                mnMaxPageWidth;
60cdf0e10cSrcweir     sal_uInt16              mnActPageId;
61cdf0e10cSrcweir     sal_uInt16              mnCurPageId;
62cdf0e10cSrcweir     sal_Bool                mbFormat;
63cdf0e10cSrcweir     sal_Bool                mbRestoreHelpId;
64cdf0e10cSrcweir     sal_Bool                mbRestoreUnqId;
65cdf0e10cSrcweir     sal_Bool                mbSmallInvalidate;
66cdf0e10cSrcweir     sal_Bool                mbExtraSpace;
67cdf0e10cSrcweir     Link                maActivateHdl;
68cdf0e10cSrcweir     Link                maDeactivateHdl;
69cdf0e10cSrcweir 
70cdf0e10cSrcweir     using Control::ImplInitSettings;
71cdf0e10cSrcweir     SAL_DLLPRIVATE void         ImplInitSettings( sal_Bool bFont, sal_Bool bForeground, sal_Bool bBackground );
72cdf0e10cSrcweir     SAL_DLLPRIVATE ImplTabItem* ImplGetItem( sal_uInt16 nId ) const;
73cdf0e10cSrcweir     SAL_DLLPRIVATE Size         ImplGetItemSize( ImplTabItem* pItem, long nMaxWidth );
74cdf0e10cSrcweir     SAL_DLLPRIVATE Rectangle    ImplGetTabRect( sal_uInt16 nPos, long nWidth = -1, long nHeight = -1 );
75cdf0e10cSrcweir     SAL_DLLPRIVATE void         ImplChangeTabPage( sal_uInt16 nId, sal_uInt16 nOldId );
76cdf0e10cSrcweir     SAL_DLLPRIVATE sal_Bool         ImplPosCurTabPage();
77cdf0e10cSrcweir     SAL_DLLPRIVATE void         ImplActivateTabPage( sal_Bool bNext );
78cdf0e10cSrcweir     SAL_DLLPRIVATE void         ImplShowFocus();
79cdf0e10cSrcweir     SAL_DLLPRIVATE void         ImplDrawItem( ImplTabItem* pItem, const Rectangle& rCurRect, bool bLayout = false, bool bFirstInGroup = false, bool bLastInGroup = false, bool bIsCurrentItem = false );
80cdf0e10cSrcweir     SAL_DLLPRIVATE void			ImplPaint( const Rectangle& rRect, bool bLayout = false );
81cdf0e10cSrcweir     SAL_DLLPRIVATE void			ImplFreeLayoutData();
82cdf0e10cSrcweir     SAL_DLLPRIVATE long			ImplHandleKeyEvent( const KeyEvent& rKeyEvent );
83cdf0e10cSrcweir 
84cdf0e10cSrcweir     DECL_DLLPRIVATE_LINK(       ImplListBoxSelectHdl, ListBox* );
85cdf0e10cSrcweir     DECL_DLLPRIVATE_LINK(       ImplWindowEventListener, VclSimpleEvent* );
86cdf0e10cSrcweir 
87cdf0e10cSrcweir 
88cdf0e10cSrcweir protected:
89cdf0e10cSrcweir     using Window::ImplInit;
90cdf0e10cSrcweir     SAL_DLLPRIVATE void         ImplInit( Window* pParent, WinBits nStyle );
91cdf0e10cSrcweir     SAL_DLLPRIVATE void         ImplLoadRes( const ResId& rResId );
92cdf0e10cSrcweir 
93cdf0e10cSrcweir     virtual void		        FillLayoutData() const;
94cdf0e10cSrcweir     virtual const Font&         GetCanonicalFont( const StyleSettings& _rStyle ) const;
95cdf0e10cSrcweir     virtual const Color&        GetCanonicalTextColor( const StyleSettings& _rStyle ) const;
96cdf0e10cSrcweir     SAL_DLLPRIVATE Rectangle*   ImplFindPartRect( const Point& rPt );
97cdf0e10cSrcweir 
98cdf0e10cSrcweir public:
99cdf0e10cSrcweir                         TabControl( Window* pParent,
100cdf0e10cSrcweir                                     WinBits nStyle = WB_STDTABCONTROL );
101cdf0e10cSrcweir                         TabControl( Window* pParent, const ResId& rResId );
102cdf0e10cSrcweir                         ~TabControl();
103cdf0e10cSrcweir 
104cdf0e10cSrcweir     virtual void        MouseButtonDown( const MouseEvent& rMEvt );
105cdf0e10cSrcweir     virtual void        KeyInput( const KeyEvent& rKEvt );
106cdf0e10cSrcweir     virtual void        Paint( const Rectangle& rRect );
107cdf0e10cSrcweir     virtual void        Resize();
108cdf0e10cSrcweir     virtual void        GetFocus();
109cdf0e10cSrcweir     virtual void        LoseFocus();
110cdf0e10cSrcweir     virtual void        RequestHelp( const HelpEvent& rHEvt );
111cdf0e10cSrcweir     virtual void        Command( const CommandEvent& rCEvt );
112cdf0e10cSrcweir     virtual long        Notify( NotifyEvent& rNEvt );
113cdf0e10cSrcweir     virtual void        StateChanged( StateChangedType nType );
114cdf0e10cSrcweir     virtual void        DataChanged( const DataChangedEvent& rDCEvt );
115cdf0e10cSrcweir     virtual long        PreNotify( NotifyEvent& rNEvt );
116cdf0e10cSrcweir 
117cdf0e10cSrcweir     virtual void        ActivatePage();
118cdf0e10cSrcweir     virtual long        DeactivatePage();
119cdf0e10cSrcweir 
120cdf0e10cSrcweir     virtual Size GetOptimalSize(WindowSizeType eType) const;
121cdf0e10cSrcweir     void                SetMinimumSizePixel( const Size& );
122cdf0e10cSrcweir 
123cdf0e10cSrcweir     void                SetTabPageSizePixel( const Size& rSize );
124cdf0e10cSrcweir     Size                GetTabPageSizePixel() const;
125cdf0e10cSrcweir 
126cdf0e10cSrcweir     //  pixel offset for the tab items, default is (0,0)
127cdf0e10cSrcweir     void                SetItemsOffset( const Point& rOffs );
128cdf0e10cSrcweir     Point               GetItemsOffset() const;
129cdf0e10cSrcweir 
130cdf0e10cSrcweir     void                InsertPage( const ResId& rResId,
131cdf0e10cSrcweir                                     sal_uInt16 nPos = TAB_APPEND );
132cdf0e10cSrcweir     void                InsertPage( sal_uInt16 nPageId, const XubString& rText,
133cdf0e10cSrcweir                                     sal_uInt16 nPos = TAB_APPEND );
134cdf0e10cSrcweir     void                RemovePage( sal_uInt16 nPageId );
135cdf0e10cSrcweir     void                Clear();
136cdf0e10cSrcweir     void                EnablePage( sal_uInt16 nPageId, bool bEnable = true );
137cdf0e10cSrcweir 
138cdf0e10cSrcweir     sal_uInt16              GetPageCount() const;
139cdf0e10cSrcweir     sal_uInt16              GetPageId( sal_uInt16 nPos ) const;
140cdf0e10cSrcweir     sal_uInt16              GetPagePos( sal_uInt16 nPageId ) const;
141cdf0e10cSrcweir     sal_uInt16              GetPageId( const Point& rPos ) const;
142cdf0e10cSrcweir 
143cdf0e10cSrcweir     void                SetCurPageId( sal_uInt16 nPageId );
144cdf0e10cSrcweir     sal_uInt16              GetCurPageId() const;
145cdf0e10cSrcweir 
146cdf0e10cSrcweir     void                SelectTabPage( sal_uInt16 nPageId );
147cdf0e10cSrcweir 
SetMaxPageWidth(long nMaxWidth)148cdf0e10cSrcweir     void                SetMaxPageWidth( long nMaxWidth ) { mnMaxPageWidth = nMaxWidth; }
GetMaxPageWidth() const149cdf0e10cSrcweir     long                GetMaxPageWidth() const { return mnMaxPageWidth; }
ResetMaxPageWidth()150cdf0e10cSrcweir     void                ResetMaxPageWidth() { SetMaxPageWidth( 0 ); }
IsMaxPageWidth() const151cdf0e10cSrcweir     sal_Bool                IsMaxPageWidth() const { return mnMaxPageWidth != 0; }
152cdf0e10cSrcweir 
153cdf0e10cSrcweir     void                SetTabPage( sal_uInt16 nPageId, TabPage* pPage );
154cdf0e10cSrcweir     TabPage*            GetTabPage( sal_uInt16 nPageId ) const;
155cdf0e10cSrcweir     sal_uInt16              GetTabPageResId( sal_uInt16 nPageId ) const;
156cdf0e10cSrcweir 
157cdf0e10cSrcweir     void                SetPageText( sal_uInt16 nPageId, const XubString& rText );
158cdf0e10cSrcweir     XubString           GetPageText( sal_uInt16 nPageId ) const;
159cdf0e10cSrcweir 
160cdf0e10cSrcweir     void                SetHelpText( sal_uInt16 nPageId, const XubString& rText );
161cdf0e10cSrcweir     const XubString&    GetHelpText( sal_uInt16 nPageId ) const;
162cdf0e10cSrcweir 
163cdf0e10cSrcweir     void                SetHelpId( sal_uInt16 nPageId, const rtl::OString& rHelpId );
164cdf0e10cSrcweir     rtl::OString        GetHelpId( sal_uInt16 nPageId ) const;
165cdf0e10cSrcweir 
166cdf0e10cSrcweir     void                SetPageImage( sal_uInt16 nPageId, const Image& rImage );
167cdf0e10cSrcweir     const Image*        GetPageImage( sal_uInt16 nPageId ) const;
168cdf0e10cSrcweir 
SetHelpText(const XubString & rText)169cdf0e10cSrcweir     void                SetHelpText( const XubString& rText )
170cdf0e10cSrcweir                             { Control::SetHelpText( rText ); }
GetHelpText() const171cdf0e10cSrcweir     const XubString&    GetHelpText() const
172cdf0e10cSrcweir                             { return Control::GetHelpText(); }
173cdf0e10cSrcweir 
SetHelpId(const rtl::OString & rId)174cdf0e10cSrcweir     void                SetHelpId( const rtl::OString& rId )
175cdf0e10cSrcweir                             { Control::SetHelpId( rId ); }
GetHelpId() const176cdf0e10cSrcweir     const rtl::OString& GetHelpId() const
177cdf0e10cSrcweir                             { return Control::GetHelpId(); }
178cdf0e10cSrcweir 
SetActivatePageHdl(const Link & rLink)179cdf0e10cSrcweir     void                SetActivatePageHdl( const Link& rLink ) { maActivateHdl = rLink; }
GetActivatePageHdl() const180cdf0e10cSrcweir     const Link&         GetActivatePageHdl() const { return maActivateHdl; }
SetDeactivatePageHdl(const Link & rLink)181cdf0e10cSrcweir     void                SetDeactivatePageHdl( const Link& rLink ) { maDeactivateHdl = rLink; }
GetDeactivatePageHdl() const182cdf0e10cSrcweir     const Link&         GetDeactivatePageHdl() const { return maDeactivateHdl; }
183cdf0e10cSrcweir 
184cdf0e10cSrcweir     // returns (control relative) bounding rectangle for the
185cdf0e10cSrcweir     // character at index nIndex relative to the text of page nPageId
186cdf0e10cSrcweir     using Control::GetCharacterBounds;
187cdf0e10cSrcweir     Rectangle GetCharacterBounds( sal_uInt16 nPageId, long nIndex ) const;
188cdf0e10cSrcweir 
189cdf0e10cSrcweir     // returns the index relative to the text of page nPageId (also returned)
190cdf0e10cSrcweir     // at position rPoint (control relative)
191cdf0e10cSrcweir     using Control::GetIndexForPoint;
192cdf0e10cSrcweir     long GetIndexForPoint( const Point& rPoint, sal_uInt16& rPageId ) const;
193cdf0e10cSrcweir 
194cdf0e10cSrcweir     // returns the bounding rectangle of the union of tab page area and the
195cdf0e10cSrcweir     // corresponding tab
196cdf0e10cSrcweir     Rectangle GetTabPageBounds( sal_uInt16 nPageId ) const;
197cdf0e10cSrcweir 
198cdf0e10cSrcweir     // returns the rectangle of the tab for page nPageId
199cdf0e10cSrcweir     Rectangle GetTabBounds( sal_uInt16 nPageId ) const;
200cdf0e10cSrcweir };
201cdf0e10cSrcweir 
202cdf0e10cSrcweir #endif  // _SV_TABCTRL_HXX
203