1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 _SV_TABCTRL_HXX
21 #define _SV_TABCTRL_HXX
23 #include "tools/solar.h"
24 #include "vcl/dllapi.h"
25 #include "vcl/ctrl.hxx"
28 struct ImplTabCtrlData
;
33 // --------------------
34 // - TabControl-Types -
35 // --------------------
38 #define TAB_APPEND ((sal_uInt16)0xFFFF)
39 #define TAB_PAGE_NOTFOUND ((sal_uInt16)0xFFFF)
40 #endif /* !TAB_APPEND */
46 class VCL_DLLPUBLIC TabControl
: public Control
49 ImplTabCtrlData
* mpTabCtrlData
;
54 sal_uInt16 mnActPageId
;
55 sal_uInt16 mnCurPageId
;
57 sal_Bool mbRestoreHelpId
;
58 sal_Bool mbRestoreUnqId
;
59 sal_Bool mbSmallInvalidate
;
64 using Control::ImplInitSettings
;
65 SAL_DLLPRIVATE
void ImplInitSettings( sal_Bool bFont
, sal_Bool bForeground
, sal_Bool bBackground
);
66 SAL_DLLPRIVATE ImplTabItem
* ImplGetItem( sal_uInt16 nId
) const;
67 SAL_DLLPRIVATE Size
ImplGetItemSize( ImplTabItem
* pItem
, long nMaxWidth
);
68 SAL_DLLPRIVATE Rectangle
ImplGetTabRect( sal_uInt16 nPos
, long nWidth
= -1, long nHeight
= -1 );
69 SAL_DLLPRIVATE
void ImplChangeTabPage( sal_uInt16 nId
, sal_uInt16 nOldId
);
70 SAL_DLLPRIVATE sal_Bool
ImplPosCurTabPage();
71 SAL_DLLPRIVATE
void ImplActivateTabPage( sal_Bool bNext
);
72 SAL_DLLPRIVATE
void ImplShowFocus();
73 SAL_DLLPRIVATE
void ImplDrawItem( ImplTabItem
* pItem
, const Rectangle
& rCurRect
, bool bLayout
= false, bool bFirstInGroup
= false, bool bLastInGroup
= false, bool bIsCurrentItem
= false );
74 SAL_DLLPRIVATE
void ImplPaint( const Rectangle
& rRect
, bool bLayout
= false );
75 SAL_DLLPRIVATE
void ImplFreeLayoutData();
76 SAL_DLLPRIVATE
long ImplHandleKeyEvent( const KeyEvent
& rKeyEvent
);
78 DECL_DLLPRIVATE_LINK( ImplListBoxSelectHdl
, void* );
79 DECL_DLLPRIVATE_LINK( ImplWindowEventListener
, VclSimpleEvent
* );
83 using Window::ImplInit
;
84 SAL_DLLPRIVATE
void ImplInit( Window
* pParent
, WinBits nStyle
);
85 SAL_DLLPRIVATE
void ImplLoadRes( const ResId
& rResId
);
87 virtual void FillLayoutData() const;
88 virtual const Font
& GetCanonicalFont( const StyleSettings
& _rStyle
) const;
89 virtual const Color
& GetCanonicalTextColor( const StyleSettings
& _rStyle
) const;
90 SAL_DLLPRIVATE Rectangle
* ImplFindPartRect( const Point
& rPt
);
93 TabControl( Window
* pParent
,
94 WinBits nStyle
= WB_STDTABCONTROL
);
95 TabControl( Window
* pParent
, const ResId
& rResId
);
98 virtual void MouseButtonDown( const MouseEvent
& rMEvt
);
99 virtual void KeyInput( const KeyEvent
& rKEvt
);
100 virtual void Paint( const Rectangle
& rRect
);
101 virtual void Resize();
102 virtual void GetFocus();
103 virtual void LoseFocus();
104 virtual void RequestHelp( const HelpEvent
& rHEvt
);
105 virtual void Command( const CommandEvent
& rCEvt
);
106 virtual long Notify( NotifyEvent
& rNEvt
);
107 virtual void StateChanged( StateChangedType nType
);
108 virtual void DataChanged( const DataChangedEvent
& rDCEvt
);
109 virtual long PreNotify( NotifyEvent
& rNEvt
);
111 virtual void ActivatePage();
112 virtual long DeactivatePage();
114 virtual Size
GetOptimalSize() const;
116 void SetTabPageSizePixel( const Size
& rSize
);
117 Size
GetTabPageSizePixel() const;
119 // pixel offset for the tab items, default is (0,0)
120 void SetItemsOffset( const Point
& rOffs
);
121 Point
GetItemsOffset() const;
123 void InsertPage( const ResId
& rResId
,
124 sal_uInt16 nPos
= TAB_APPEND
);
125 void InsertPage( sal_uInt16 nPageId
, const XubString
& rText
,
126 sal_uInt16 nPos
= TAB_APPEND
);
127 void RemovePage( sal_uInt16 nPageId
);
129 void EnablePage( sal_uInt16 nPageId
, bool bEnable
= true );
131 sal_uInt16
GetPagePos( sal_uInt16 nPageId
) const;
132 sal_uInt16
GetPageCount() const;
133 sal_uInt16
GetPageId( sal_uInt16 nPos
) const;
134 sal_uInt16
GetPageId( const Point
& rPos
) const;
135 sal_uInt16
GetPageId( const TabPage
& rPage
) const;
136 sal_uInt16
GetPageId( const OString
& rName
) const;
138 void SetCurPageId( sal_uInt16 nPageId
);
139 sal_uInt16
GetCurPageId() const;
141 void SelectTabPage( sal_uInt16 nPageId
);
143 void SetMaxPageWidth( long nMaxWidth
) { mnMaxPageWidth
= nMaxWidth
; }
144 long GetMaxPageWidth() const { return mnMaxPageWidth
; }
145 void ResetMaxPageWidth() { SetMaxPageWidth( 0 ); }
146 sal_Bool
IsMaxPageWidth() const { return mnMaxPageWidth
!= 0; }
148 void SetTabPage( sal_uInt16 nPageId
, TabPage
* pPage
);
149 TabPage
* GetTabPage( sal_uInt16 nPageId
) const;
151 void SetPageText( sal_uInt16 nPageId
, const XubString
& rText
);
152 XubString
GetPageText( sal_uInt16 nPageId
) const;
154 void SetHelpText( sal_uInt16 nPageId
, const XubString
& rText
);
155 const XubString
& GetHelpText( sal_uInt16 nPageId
) const;
157 void SetHelpId( sal_uInt16 nPageId
, const OString
& rId
) const;
158 OString
GetHelpId( sal_uInt16 nPageId
) const;
160 void SetPageName( sal_uInt16 nPageId
, const OString
& rName
) const;
161 OString
GetPageName( sal_uInt16 nPageId
) const;
163 void SetPageImage( sal_uInt16 nPageId
, const Image
& rImage
);
165 void SetHelpText( const XubString
& rText
)
166 { Control::SetHelpText( rText
); }
167 const XubString
& GetHelpText() const
168 { return Control::GetHelpText(); }
170 void SetHelpId( const OString
& rId
)
171 { Control::SetHelpId( rId
); }
172 const OString
& GetHelpId() const
173 { return Control::GetHelpId(); }
175 void SetActivatePageHdl( const Link
& rLink
) { maActivateHdl
= rLink
; }
176 const Link
& GetActivatePageHdl() const { return maActivateHdl
; }
177 void SetDeactivatePageHdl( const Link
& rLink
) { maDeactivateHdl
= rLink
; }
178 const Link
& GetDeactivatePageHdl() const { return maDeactivateHdl
; }
180 // returns (control relative) bounding rectangle for the
181 // character at index nIndex relative to the text of page nPageId
182 using Control::GetCharacterBounds
;
183 Rectangle
GetCharacterBounds( sal_uInt16 nPageId
, long nIndex
) const;
185 // returns the index relative to the text of page nPageId (also returned)
186 // at position rPoint (control relative)
187 using Control::GetIndexForPoint
;
188 long GetIndexForPoint( const Point
& rPoint
, sal_uInt16
& rPageId
) const;
190 // returns the rectangle of the tab for page nPageId
191 Rectangle
GetTabBounds( sal_uInt16 nPageId
) const;
193 virtual void SetPosPixel(const Point
& rPos
);
194 virtual void SetSizePixel(const Size
& rNewSize
);
195 virtual void SetPosSizePixel(const Point
& rNewPos
, const Size
& rNewSize
);
197 Size
calculateRequisition() const;
198 void setAllocation(const Size
&rAllocation
);
200 void markLayoutDirty()
202 mbLayoutDirty
= true;
206 #endif // _SV_TABCTRL_HXX
208 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */