PCL
TabBox.h
Go to the documentation of this file.
1 // ____ ______ __
2 // / __ \ / ____// /
3 // / /_/ // / / /
4 // / ____// /___ / /___ PixInsight Class Library
5 // /_/ \____//_____/ PCL 2.6.11
6 // ----------------------------------------------------------------------------
7 // pcl/TabBox.h - Released 2024-05-07T15:27:32Z
8 // ----------------------------------------------------------------------------
9 // This file is part of the PixInsight Class Library (PCL).
10 // PCL is a multiplatform C++ framework for development of PixInsight modules.
11 //
12 // Copyright (c) 2003-2024 Pleiades Astrophoto S.L. All Rights Reserved.
13 //
14 // Redistribution and use in both source and binary forms, with or without
15 // modification, is permitted provided that the following conditions are met:
16 //
17 // 1. All redistributions of source code must retain the above copyright
18 // notice, this list of conditions and the following disclaimer.
19 //
20 // 2. All redistributions in binary form must reproduce the above copyright
21 // notice, this list of conditions and the following disclaimer in the
22 // documentation and/or other materials provided with the distribution.
23 //
24 // 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
25 // of their contributors, may be used to endorse or promote products derived
26 // from this software without specific prior written permission. For written
27 // permission, please contact info@pixinsight.com.
28 //
29 // 4. All products derived from this software, in any form whatsoever, must
30 // reproduce the following acknowledgment in the end-user documentation
31 // and/or other materials provided with the product:
32 //
33 // "This product is based on software from the PixInsight project, developed
34 // by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
35 //
36 // Alternatively, if that is where third-party acknowledgments normally
37 // appear, this acknowledgment must be reproduced in the product itself.
38 //
39 // THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
40 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
41 // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
43 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
44 // EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
45 // INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
46 // DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
47 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
49 // POSSIBILITY OF SUCH DAMAGE.
50 // ----------------------------------------------------------------------------
51 
52 #ifndef __PCL_TabBox_h
53 #define __PCL_TabBox_h
54 
56 
57 #ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
58 
59 #include <pcl/Defs.h>
60 
61 #include <pcl/AutoPointer.h>
62 #include <pcl/Bitmap.h>
63 #include <pcl/Control.h>
64 
65 namespace pcl
66 {
67 
68 // ----------------------------------------------------------------------------
69 
79 namespace TabPosition
80 {
81  enum value_type
82  {
83  Top, // Tabs are located at the top side of the tab box control
84  Bottom // Tabs are located at the bottom side of the tab box control
85  };
86 }
87 
88 // ----------------------------------------------------------------------------
89 
96 class PCL_CLASS TabBox : public Control
97 {
98 public:
99 
103  using tab_position = TabPosition::value_type;
104 
108  TabBox( Control& parent = Control::Null() );
109 
113  ~TabBox() override
114  {
115  }
116 
120  int NumberOfPages() const;
121 
126  int CurrentPageIndex() const;
127 
131  void SetCurrentPageIndex( int index );
132 
136  void SelectPage( int index )
137  {
138  SetCurrentPageIndex( index );
139  }
140 
146 
152  Control& PageControlByIndex( int index ) const;
153 
172  void InsertPage( int index, Control& page, const String& label, const Bitmap& icon = Bitmap::Null() );
173 
182  void AddPage( Control& page, const String& label, const Bitmap& icon = Bitmap::Null() )
183  {
184  InsertPage( NumberOfPages(), page, label, icon );
185  }
186 
195  void RemovePage( int idx );
196 
202  tab_position TabPosition() const;
203 
209  void SetTabPosition( tab_position pos );
210 
216  bool IsPageEnabled( int index ) const;
217 
223  void EnablePage( int index, bool enable = true );
224 
233  void DisablePage( int index, bool disable = true )
234  {
235  EnablePage( index, !disable );
236  }
237 
240  String PageLabel( int idx ) const;
241 
244  void SetPageLabel( int idx, const String& );
245 
248  void ClearPageLabel( int idx )
249  {
250  SetPageLabel( idx, String() );
251  }
252 
255  Bitmap PageIcon( int idx ) const;
256 
259  void SetPageIcon( int idx, const Bitmap& );
260 
263  void ClearPageIcon( int idx )
264  {
265  SetPageIcon( idx, Bitmap::Null() );
266  }
267 
270  String PageToolTip( int idx ) const;
271 
274  void SetPageToolTip( int idx, const String& );
275 
278  void ClearPageToolTip( int idx )
279  {
280  SetPageToolTip( idx, String() );
281  }
282 
286 
290 
293  void SetControls( Control& left, Control& right );
294 
298  {
299  SetControls( w, RightControl() );
300  }
301 
305  {
306  SetControls( LeftControl(), w );
307  }
308 
312  {
313  SetLeftControl( Control::Null() );
314  }
315 
319  {
320  SetRightControl( Control::Null() );
321  }
322 
326  {
327  SetControls( Control::Null(), Control::Null() );
328  }
329 
330  // -------------------------------------------------------------------------
331  // Event handlers
332  //
333  // void OnPageSelected( TabBox& sender, int pageIndex );
334 
351  using page_event_handler = void (Control::*)( TabBox& sender, int pageIndex );
352 
364  void OnPageSelected( page_event_handler handler, Control& receiver );
365 
366 private:
367 
368  struct EventHandlers
369  {
370  page_event_handler onPageSelected = nullptr;
371 
372  EventHandlers() = default;
373  EventHandlers( const EventHandlers& ) = default;
374  EventHandlers& operator =( const EventHandlers& ) = default;
375  };
376 
377  AutoPointer<EventHandlers> m_handlers;
378 
379  friend class TabBoxEventDispatcher;
380 };
381 
382 // ----------------------------------------------------------------------------
383 
384 } // pcl
385 
386 #endif // __PCL_BUILDING_PIXINSIGHT_APPLICATION
387 
388 #endif // __PCL_TabBox_h
389 
390 // ----------------------------------------------------------------------------
391 // EOF pcl/TabBox.h - Released 2024-05-07T15:27:32Z
Client-side interface to a PixInsight Bitmap object.
Definition: Bitmap.h:204
static Bitmap & Null()
Client-side interface to a PixInsight Control object.
Definition: Control.h:126
static Control & Null()
Unicode (UTF-16) string.
Definition: String.h:8113
Client-side interface to a PixInsight TabBox control.
Definition: TabBox.h:97
void ClearPageIcon(int idx)
Definition: TabBox.h:263
String PageLabel(int idx) const
String PageToolTip(int idx) const
void SetPageIcon(int idx, const Bitmap &)
Control & CurrentPageControl() const
void EnablePage(int index, bool enable=true)
void ClearLeftControl()
Definition: TabBox.h:311
Bitmap PageIcon(int idx) const
Control & PageControlByIndex(int index) const
void RemovePage(int idx)
void AddPage(Control &page, const String &label, const Bitmap &icon=Bitmap::Null())
Definition: TabBox.h:182
void SetPageToolTip(int idx, const String &)
void SetTabPosition(tab_position pos)
void ClearPageLabel(int idx)
Definition: TabBox.h:248
Control & RightControl() const
int NumberOfPages() const
int CurrentPageIndex() const
TabBox(Control &parent=Control::Null())
void ClearControls()
Definition: TabBox.h:325
void SelectPage(int index)
Definition: TabBox.h:136
void SetCurrentPageIndex(int index)
Control & LeftControl() const
bool IsPageEnabled(int index) const
void SetControls(Control &left, Control &right)
void ClearPageToolTip(int idx)
Definition: TabBox.h:278
tab_position TabPosition() const
void SetRightControl(Control &w)
Definition: TabBox.h:304
void SetLeftControl(Control &w)
Definition: TabBox.h:297
void SetPageLabel(int idx, const String &)
void ClearRightControl()
Definition: TabBox.h:318
~TabBox() override
Definition: TabBox.h:113
void DisablePage(int index, bool disable=true)
Definition: TabBox.h:233
void InsertPage(int index, Control &page, const String &label, const Bitmap &icon=Bitmap::Null())
void OnPageSelected(page_event_handler handler, Control &receiver)
void(Control::*)(TabBox &sender, int pageIndex) page_event_handler
Definition: TabBox.h:351
PCL root namespace.
Definition: AbstractImage.h:77