PCL
Control.h
Go to the documentation of this file.
1 // ____ ______ __
2 // / __ \ / ____// /
3 // / /_/ // / / /
4 // / ____// /___ / /___ PixInsight Class Library
5 // /_/ \____//_____/ PCL 2.6.5
6 // ----------------------------------------------------------------------------
7 // pcl/Control.h - Released 2024-01-13T15:47:58Z
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_Control_h
53 #define __PCL_Control_h
54 
56 
57 #ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
58 
59 #include <pcl/Defs.h>
60 
61 #include <pcl/AutoPointer.h>
62 #include <pcl/ButtonCodes.h>
63 #include <pcl/Color.h>
64 #include <pcl/Cursor.h>
65 #include <pcl/Flags.h>
66 #include <pcl/Font.h>
67 #include <pcl/KeyCodes.h>
68 #include <pcl/Rectangle.h>
69 #include <pcl/Sizer.h>
70 #include <pcl/UIObject.h>
71 #include <pcl/UIScaling.h>
72 
73 #endif // !__PCL_BUILDING_PIXINSIGHT_APPLICATION
74 
75 namespace pcl
76 {
77 
78 // ----------------------------------------------------------------------------
79 
94 namespace FocusStyle
95 {
96  enum mask_type
97  {
98  NoFocus = 0x00, // The control doesn't accept focus
99  Tab = 0x01, // Can focus control by pressing the tab key
100  Click = 0x02, // Can focus control by mouse clicking
101  Wheel = 0x04, // Can focus control with the mouse wheel
102  TextListTab = 0x08 // macOS only
103  };
104 }
105 
110 
111 // ----------------------------------------------------------------------------
112 
113 #ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
114 
115 // ----------------------------------------------------------------------------
116 
117 class PCL_CLASS View;
118 
125 class PCL_CLASS Control : public UIObject
126 {
127 public:
128 
137  Control( Control& parent = Null(), uint32 = 0 );
138 
142  ~Control() override
143  {
144  }
145 
150  Control( const Control& ) = delete;
151 
156  Control& operator =( const Control& ) = delete;
157 
162  Control( Control&& ) = delete;
163 
168  Control& operator =( Control&& ) = delete;
169 
177  void EnsureUnique() override
178  {
179  }
180 
185  static Control& Null();
186 
190  pcl::Rect FrameRect() const;
191 
195  int FrameWidth() const
196  {
197  return FrameRect().Width();
198  }
199 
203  int FrameHeight() const
204  {
205  return FrameRect().Height();
206  }
207 
211  pcl::Rect ClientRect() const;
212 
216  int ClientWidth() const
217  {
218  return ClientRect().Width();
219  }
220 
224  int Width() const
225  {
226  return ClientWidth();
227  }
228 
232  int ClientHeight() const
233  {
234  return ClientRect().Height();
235  }
236 
240  int Height() const
241  {
242  return ClientHeight();
243  }
244 
251  {
252  pcl::Rect r( ClientRect() );
253  return pcl::Rect( r.Width(), r.Height() );
254  }
255 
258  void SetClientRect( const pcl::Rect& r )
259  {
260  SetClientRect( r.x0, r.y0, r.x1, r.y1 );
261  }
262 
265  void SetClientRect( int x0, int y0, int x1, int y1 );
266 
269  void Resize( int w, int h );
270 
273  void AdjustToContents();
274 
278  int MinWidth() const
279  {
280  int w, dum; GetMinSize( w, dum ); return w;
281  }
282 
286  int MinHeight() const
287  {
288  int dum, h; GetMinSize( dum, h ); return h;
289  }
290 
293  void GetMinSize( int& w, int& h ) const;
294 
297  void SetMinWidth( int w )
298  {
299  SetMinSize( w, -1 );
300  }
301 
304  void SetMinWidth()
305  {
306  SetMinWidth( Width() );
307  }
308 
311  void SetMinHeight( int h )
312  {
313  SetMinSize( -1, h );
314  }
315 
319  {
320  SetMinHeight( Height() );
321  }
322 
325  void SetMinSize( int w, int h );
326 
329  void SetMinSize()
330  {
331  SetMinSize( Width(), Height() );
332  }
333 
337  int MaxWidth() const
338  {
339  int w, dum; GetMaxSize( w, dum ); return w;
340  }
341 
345  int MaxHeight() const
346  {
347  int dum, h; GetMaxSize( dum, h ); return h;
348  }
349 
352  void GetMaxSize( int& w, int& h ) const;
353 
356  void SetMaxWidth( int w )
357  {
358  SetMaxSize( w, -1 );
359  }
360 
363  void SetMaxWidth()
364  {
365  SetMaxWidth( Width() );
366  }
367 
370  void SetMaxHeight( int h )
371  {
372  SetMaxSize( -1, h );
373  }
374 
378  {
379  SetMaxHeight( Height() );
380  }
381 
384  void SetMaxSize( int w, int h );
385 
388  void SetMaxSize()
389  {
390  SetMaxSize( Width(), Height() );
391  }
392 
395  void SetFixedWidth( int w )
396  {
397  SetFixedSize( w, -1 );
398  }
399 
403  {
404  SetFixedWidth( Width() );
405  }
406 
409  void SetFixedHeight( int h )
410  {
411  SetFixedSize( -1, h );
412  }
413 
417  {
418  SetFixedHeight( Height() );
419  }
420 
423  void SetFixedSize( int w, int h );
424 
428  {
429  SetFixedSize( Width(), Height() );
430  }
431 
434  bool IsFixedWidth() const
435  {
436  return MinWidth() == MaxWidth();
437  }
438 
441  bool IsFixedHeight() const
442  {
443  return MinHeight() == MaxHeight();
444  }
445 
449  {
450  SetMinSize( 0, 0 );
451  SetMaxSize( int_max, int_max );
452  }
453 
457  {
458  SetMinWidth( 0 );
459  SetMaxWidth( int_max );
460  }
461 
465  {
466  SetMinHeight( 0 );
467  SetMaxHeight( int_max );
468  }
469 
473  int ScaledMinWidth() const
474  {
475  int w, dum; GetMinSize( w, dum ); return PhysicalPixelsToLogical( w );
476  }
477 
481  int ScaledMinHeight() const
482  {
483  int dum, h; GetMinSize( dum, h ); return PhysicalPixelsToLogical( h );
484  }
485 
488  void GetScaledMinSize( int& w, int& h ) const
489  {
490  GetMinSize( w, h ); w = PhysicalPixelsToLogical( w ); h = PhysicalPixelsToLogical( h );
491  }
492 
495  void SetScaledMinWidth( int w )
496  {
497  SetMinSize( LogicalPixelsToPhysical( w ), -1 );
498  }
499 
502  void SetScaledMinHeight( int h )
503  {
504  SetMinSize( -1, LogicalPixelsToPhysical( h ) );
505  }
506 
509  void SetScaledMinSize( int w, int h )
510  {
511  SetMinSize( LogicalPixelsToPhysical( w ), LogicalPixelsToPhysical( h ) );
512  }
513 
517  int ScaledMaxWidth() const
518  {
519  int w, dum; GetMaxSize( w, dum ); return PhysicalPixelsToLogical( w );
520  }
521 
525  int ScaledMaxHeight() const
526  {
527  int dum, h; GetMaxSize( dum, h ); return PhysicalPixelsToLogical( h );
528  }
529 
532  void GetScaledMaxSize( int& w, int& h ) const
533  {
534  GetMaxSize( w, h ); w = PhysicalPixelsToLogical( w ); h = PhysicalPixelsToLogical( h );
535  }
536 
539  void SetScaledMaxWidth( int w )
540  {
541  SetMaxSize( LogicalPixelsToPhysical( w ), -1 );
542  }
543 
546  void SetScaledMaxHeight( int h )
547  {
548  SetMaxSize( -1, LogicalPixelsToPhysical( h ) );
549  }
550 
553  void SetScaledMaxSize( int w, int h )
554  {
555  SetMaxSize( LogicalPixelsToPhysical( w ), LogicalPixelsToPhysical( h ) );
556  }
557 
560  void SetScaledFixedWidth( int w )
561  {
562  SetFixedSize( LogicalPixelsToPhysical( w ), -1 );
563  }
564 
567  void SetScaledFixedHeight( int h )
568  {
569  SetFixedSize( -1, LogicalPixelsToPhysical( h ) );
570  }
571 
574  void SetScaledFixedSize( int w, int h )
575  {
576  SetFixedSize( LogicalPixelsToPhysical( w ), LogicalPixelsToPhysical( h ) );
577  }
578 
581  bool IsHorizontalExpansionEnabled() const;
582 
585  bool IsVerticalExpansionEnabled() const;
586 
589  void EnableExpansion( bool horzEnable = true, bool vertEnable = true );
590 
593  void DisableExpansion( bool horzDisable = true, bool vertDisable = true )
594  {
595  EnableExpansion( !horzDisable, !vertDisable );
596  }
597 
606  pcl::Point Position() const;
607 
613  int X() const
614  {
615  return Position().x;
616  }
617 
623  int Y() const
624  {
625  return Position().y;
626  }
627 
630  void Move( const pcl::Point& p )
631  {
632  Move( p.x, p.y );
633  }
634 
637  void Move( int x, int y );
638 
642  bool IsUnderMouse() const;
643 
646  void BringToFront();
647 
650  void SendToBack();
651 
654  void StackUnder( Control& );
655 
658  pcl::Sizer Sizer() const;
659 
664  {
665  return this->Sizer();
666  }
667 
670  void SetSizer( pcl::Sizer& );
671 
675  {
676  pcl::Point p1 = p; GlobalToLocal( p1.x, p1.y ); return p1;
677  }
678 
681  void GlobalToLocal( int& x, int& y ) const;
682 
686  {
687  pcl::Point p1 = p; LocalToGlobal( p1.x, p1.y ); return p1;
688  }
689 
692  void LocalToGlobal( int& x, int& y ) const;
693 
697  {
698  pcl::Point p1 = p; ParentToLocal( p1.x, p1.y ); return p1;
699  }
700 
703  void ParentToLocal( int& x, int& y ) const;
704 
708  {
709  pcl::Point p1 = p; LocalToParent( p1.x, p1.y ); return p1;
710  }
711 
714  void LocalToParent( int& x, int& y ) const;
715 
718  pcl::Point ControlToLocal( const Control& w, const pcl::Point& p ) const
719  {
720  pcl::Point p1 = p; ControlToLocal( w, p1.x, p1.y ); return p1;
721  }
722 
725  void ControlToLocal( const Control&, int& x, int& y ) const;
726 
729  pcl::Point LocalToControl( const Control& w, const pcl::Point& p ) const
730  {
731  pcl::Point p1 = p; LocalToControl( w, p1.x, p1.y ); return p1;
732  }
733 
736  void LocalToControl( const Control&, int& x, int& y ) const;
737 
740  Control& ChildByPos( const pcl::Point& p ) const
741  {
742  return ChildByPos( p.x, p.y );
743  }
744 
747  Control& ChildByPos( int x, int y ) const;
748 
751  pcl::Rect ChildrenRect() const;
752 
755  bool IsAncestorOf( const Control& ) const;
756 
761  Control& Parent() const;
762 
765  void SetParent( Control& );
766 
771  Control& Window() const;
772 
775  virtual bool IsEnabled() const;
776 
779  virtual void Enable( bool enabled = true );
780 
783  void Disable( bool disabled = true )
784  {
785  Enable( !disabled );
786  }
787 
790  bool IsMouseTrackingEnabled() const;
791 
794  void EnableMouseTracking( bool = true );
795 
798  void DisableMouseTracking( bool disable = true )
799  {
800  EnableMouseTracking( !disable );
801  }
802 
805  bool IsVisible() const;
806 
809  void SetVisible( bool visible )
810  {
811  if ( visible )
812  Show();
813  else
814  Hide();
815  }
816 
819  void Show();
820 
823  pcl::Rect VisibleRect() const;
824 
827  bool IsHidden() const
828  {
829  return !IsVisible();
830  }
831 
834  void Hide();
835 
838  bool IsMaximized() const;
839 
842  bool IsMinimized() const;
843 
846  bool IsModal() const;
847 
850  bool IsWindow() const;
851 
854  bool IsActiveWindow() const;
855 
858  void ActivateWindow();
859 
862  bool IsFocused() const;
863 
866  void Focus( bool focus = true );
867 
870  void Unfocus()
871  {
872  Focus( false );
873  }
874 
877  FocusStyles FocusStyle() const;
878 
881  void SetFocusStyle( FocusStyles );
882 
885  Control& FocusedChild() const;
886 
889  Control& ChildToFocus() const;
890 
893  void SetChildToFocus( Control& );
894 
897  Control& NextSiblingToFocus() const;
898 
901  void SetNextSiblingToFocus( Control& );
902 
905  bool CanUpdate() const;
906 
909  void EnableUpdates( bool enable = true );
910 
913  void DisableUpdates( bool disable = true )
914  {
915  EnableUpdates( !disable );
916  }
917 
920  void Update();
921 
924  void Update( const pcl::Rect& r )
925  {
926  Update( r.x0, r.y0, r.x1, r.y1 );
927  }
928 
931  void Update( int x0, int y0, int x1, int y1 );
932 
935  void Repaint();
936 
939  void Repaint( const pcl::Rect& r )
940  {
941  Repaint( r.x0, r.y0, r.x1, r.y1 );
942  }
943 
946  void Repaint( int x0, int y0, int x1, int y1 );
947 
956  void Restyle();
957 
974  void EnsureLayoutUpdated();
975 
978  void Scroll( const pcl::Point& d )
979  {
980  Scroll( d.x, d.y );
981  }
982 
985  void Scroll( int dx, int dy );
986 
989  void Scroll( const pcl::Point& d, const pcl::Rect& r )
990  {
991  Scroll( d.x, d.y, r.x0, r.y0, r.x1, r.y1 );
992  }
993 
996  void Scroll( int dx, int dy, int x0, int y0, int x1, int y1 );
997 
1000  pcl::Cursor Cursor() const;
1001 
1006  {
1007  return this->Cursor();
1008  }
1009 
1012  void SetCursor( const pcl::Cursor& );
1013 
1016  void SetCursorToParent();
1017 
1020  String StyleSheet() const;
1021 
1024  void SetStyleSheet( const String& css );
1025 
1028  RGBA BackgroundColor() const;
1029 
1032  void SetBackgroundColor( RGBA );
1033 
1036  RGBA ForegroundColor() const;
1037 
1040  void SetForegroundColor( RGBA );
1041 
1044  RGBA CanvasColor();
1045 
1048  void SetCanvasColor( RGBA );
1049 
1052  RGBA AlternateCanvasColor() const;
1053 
1056  void SetAlternateCanvasColor( RGBA );
1057 
1060  RGBA TextColor() const;
1061 
1064  void SetTextColor( RGBA );
1065 
1068  RGBA ButtonColor() const;
1069 
1072  void SetButtonColor( RGBA );
1073 
1076  RGBA ButtonTextColor() const;
1077 
1080  void SetButtonTextColor( RGBA );
1081 
1084  RGBA HighlightColor() const;
1085 
1088  void SetHighlightColor( RGBA );
1089 
1092  RGBA HighlightedTextColor() const;
1093 
1096  void SetHighlightedTextColor( RGBA );
1097 
1100  pcl::Font Font() const;
1101 
1106  {
1107  return this->Font();
1108  }
1109 
1112  void SetFont( const pcl::Font& );
1113 
1116  double WindowOpacity() const;
1117 
1120  void SetWindowOpacity( double );
1121 
1124  String WindowTitle() const;
1125 
1128  void SetWindowTitle( const String& );
1129 
1130  /*
1131  * Information areas on processing interface control bars.
1132  */
1133 
1136  String InfoText() const;
1137 
1140  void SetInfoText( const String& );
1141 
1145  {
1146  SetInfoText( String() );
1147  }
1148 
1149  /*
1150  * Track View check boxes on processing interface control bars.
1151  */
1152 
1155  bool IsTrackViewActive() const;
1156 
1159  void SetTrackViewActive( bool = true );
1160 
1164  {
1165  SetTrackViewActive( true );
1166  }
1167 
1171  {
1172  SetTrackViewActive( false );
1173  }
1174 
1175  /*
1176  * Real-Time Preview check boxes on processing interface control bars.
1177  */
1178 
1181  bool IsRealTimePreviewActive() const;
1182 
1185  void SetRealTimePreviewActive( bool = true );
1186 
1190  {
1191  SetRealTimePreviewActive( true );
1192  }
1193 
1197  {
1198  SetRealTimePreviewActive( false );
1199  }
1200 
1201  //
1202 
1205  String ToolTip() const;
1206 
1209  void SetToolTip( const String& );
1210 
1236  static void ShowToolTip( int x, int y, const String& text,
1237  const Control& control = Control::Null(), const Rect& rect = Rect( 0 ) );
1238 
1245  static void ShowToolTip( const Point& pos, const String& text,
1246  const Control& control = Control::Null(), const Rect& rect = Rect( 0 ) )
1247  {
1248  ShowToolTip( pos.x, pos.y, text, control, rect );
1249  }
1250 
1254  static void HideToolTip();
1255 
1260  static String ToolTipText();
1261 
1262  //
1263 
1286  double DisplayPixelRatio() const;
1287 
1320  double ResourcePixelRatio() const;
1321 
1339  template <class R>
1340  String ScaledResource( R resource ) const
1341  {
1342  return UIScaledResource( ResourcePixelRatio(), resource );
1343  }
1344 
1411  template <class S>
1412  String ScaledStyleSheet( S cssCode, int fontDPI = 0 ) const
1413  {
1414  return UIScaledStyleSheet( DisplayPixelRatio(), ResourcePixelRatio(), cssCode, fontDPI );
1415  }
1416 
1441  Point ScaledCursorHotSpot( int xHot, int yHot ) const
1442  {
1443  double r = ResourcePixelRatio();
1444  return Point( RoundInt( r*(xHot + 0.499) ), RoundInt( r*(yHot + 0.499) ) );
1445  }
1446 
1457  Point ScaledCursorHotSpot( const Point& hotSpot ) const
1458  {
1459  return ScaledCursorHotSpot( hotSpot.x, hotSpot.y );
1460  }
1461 
1470  int LogicalPixelsToPhysical( int size ) const
1471  {
1472  return RoundInt( DisplayPixelRatio()*size );
1473  }
1474 
1483  int PhysicalPixelsToLogical( int size ) const
1484  {
1485  return RoundInt( size/DisplayPixelRatio() );
1486  }
1487 
1499  int LogicalPixelsToResource( int size ) const
1500  {
1501  return RoundInt( ResourcePixelRatio()*size );
1502  }
1503 
1512  int ResourcePixelsToLogical( int size ) const
1513  {
1514  return RoundInt( size/ResourcePixelRatio() );
1515  }
1516 
1517  // -------------------------------------------------------------------------
1518  // Event handlers
1519  //
1520  // void OnDestroy( Control& sender );
1521  // void OnShow( Control& sender );
1522  // void OnHide( Control& sender );
1523  // void OnGetFocus( Control& sender );
1524  // void OnLoseFocus( Control& sender );
1525  // void OnEnter( Control& sender );
1526  // void OnLeave( Control& sender );
1527  // void OnMove( Control& sender, const pcl::Point& newPos, const pcl::Point& oldPos );
1528  // void OnResize( Control& sender, int newWidth, int newHeight, int oldWidth, int oldHeight );
1529  // void OnPaint( Control& sender, const pcl::Rect& updateRect );
1530  // void OnKeyPress( Control& sender, int key, unsigned modifiers, bool& wantsKey );
1531  // void OnKeyRelease( Control& sender, int key, unsigned modifiers, bool& wantsKey );
1532  // void OnMouseMove( Control& sender, const pcl::Point& pos, unsigned buttons, unsigned modifiers );
1533  // void OnMouseDoubleClick( Control& sender, const pcl::Point& pos, unsigned buttons, unsigned modifiers );
1534  // void OnMousePress( Control& sender, const pcl::Point& pos, int button, unsigned buttons, unsigned modifiers );
1535  // void OnMouseRelease( Control& sender, const pcl::Point& pos, int button, unsigned buttons, unsigned modifiers );
1536  // void OnMouseWheel( Control& sender, const pcl::Point& pos, int delta, unsigned buttons, unsigned modifiers );
1537  // void OnFileDrag( Control& sender, const pcl::Point& pos, const StringList& files, unsigned modifiers, bool& wantsFiles )
1538  // void OnFileDrop( Control& sender, const pcl::Point& pos, const StringList& files, unsigned modifiers )
1539  // void OnViewDrag( Control& sender, const pcl::Point& pos, const View& view, unsigned modifiers, bool& wantsView )
1540  // void OnViewDrop( Control& sender, const pcl::Point& pos, const View& view, unsigned modifiers )
1541  // void OnChildCreate( Control& sender, Control& child );
1542  // void OnChildDestroy( Control& sender, Control& child );
1543 
1551  using event_handler = void (Control::*)( Control& sender );
1552 
1556  using close_event_handler = void (Control::*)( Control& sender, bool& allowClose );
1557 
1561  using move_event_handler = void (Control::*)( Control& sender, const pcl::Point& newPos, const pcl::Point& oldPos );
1562 
1566  using resize_event_handler = void (Control::*)( Control& sender, int newWidth, int newHeight, int oldWidth, int oldHeight );
1567 
1571  using paint_event_handler = void (Control::*)( Control& sender, const pcl::Rect& updateRect );
1572 
1576  using keyboard_event_handler = void (Control::*)( Control& sender, int key, unsigned modifiers, bool& wantsKey );
1577 
1581  using mouse_event_handler = void (Control::*)( Control& sender, const pcl::Point& pos, unsigned buttons, unsigned modifiers );
1582 
1586  using mouse_button_event_handler = void (Control::*)( Control& sender, const pcl::Point& pos, int button, unsigned buttons, unsigned modifiers );
1587 
1591  using mouse_wheel_event_handler = void (Control::*)( Control& sender, const pcl::Point& pos, int delta, unsigned buttons, unsigned modifiers );
1592 
1596  using file_drag_event_handler = void (Control::*)( Control& sender, const pcl::Point& pos, const StringList& files, unsigned modifiers, bool& wantsFiles );
1597 
1601  using file_drop_event_handler = void (Control::*)( Control& sender, const pcl::Point& pos, const StringList& files, unsigned modifiers );
1602 
1606  using view_drag_event_handler = void (Control::*)( Control& sender, const pcl::Point& pos, const View& view, unsigned modifiers, bool& wantsView );
1607 
1611  using view_drop_event_handler = void (Control::*)( Control& sender, const pcl::Point& pos, const View& view, unsigned modifiers );
1612 
1616  using child_event_handler = void (Control::*)( Control& sender, Control& child );
1617 
1621  void OnDestroy( event_handler, Control& );
1622 
1626  void OnShow( event_handler, Control& );
1627 
1631  void OnHide( event_handler, Control& );
1632 
1636  void OnClose( close_event_handler, Control& );
1637 
1641  void OnGetFocus( event_handler, Control& );
1642 
1646  void OnLoseFocus( event_handler, Control& );
1647 
1651  void OnEnter( event_handler, Control& );
1652 
1656  void OnLeave( event_handler, Control& );
1657 
1661  void OnMove( move_event_handler, Control& );
1662 
1666  void OnResize( resize_event_handler, Control& );
1667 
1671  void OnPaint( paint_event_handler, Control& );
1672 
1676  void OnKeyPress( keyboard_event_handler, Control& );
1677 
1681  void OnKeyRelease( keyboard_event_handler, Control& );
1682 
1686  void OnMouseMove( mouse_event_handler, Control& );
1687 
1691  void OnMouseDoubleClick( mouse_event_handler, Control& );
1692 
1696  void OnMousePress( mouse_button_event_handler, Control& );
1697 
1701  void OnMouseRelease( mouse_button_event_handler, Control& );
1702 
1706  void OnMouseWheel( mouse_wheel_event_handler, Control& );
1707 
1711  void OnFileDrag( file_drag_event_handler, Control& );
1712 
1716  void OnFileDrop( file_drop_event_handler, Control& );
1717 
1721  void OnViewDrag( view_drag_event_handler, Control& );
1722 
1726  void OnViewDrop( view_drop_event_handler, Control& );
1727 
1731  void OnChildCreate( child_event_handler, Control& );
1732 
1736  void OnChildDestroy( child_event_handler, Control& );
1737 
1738  // -------------------------------------------------------------------------
1739 
1740 private:
1741 
1742  struct EventHandlers
1743  {
1744  event_handler onDestroy = nullptr;
1745  event_handler onShow = nullptr;
1746  event_handler onHide = nullptr;
1747  close_event_handler onClose = nullptr;
1748  event_handler onGetFocus = nullptr;
1749  event_handler onLoseFocus = nullptr;
1750  event_handler onEnter = nullptr;
1751  event_handler onLeave = nullptr;
1752  move_event_handler onMove = nullptr;
1753  resize_event_handler onResize = nullptr;
1754  paint_event_handler onPaint = nullptr;
1755  keyboard_event_handler onKeyPress = nullptr;
1756  keyboard_event_handler onKeyRelease = nullptr;
1757  mouse_event_handler onMouseMove = nullptr;
1758  mouse_event_handler onMouseDoubleClick = nullptr;
1759  mouse_button_event_handler onMousePress = nullptr;
1760  mouse_button_event_handler onMouseRelease = nullptr;
1761  mouse_wheel_event_handler onMouseWheel = nullptr;
1762  file_drag_event_handler onFileDrag = nullptr;
1763  file_drop_event_handler onFileDrop = nullptr;
1764  view_drag_event_handler onViewDrag = nullptr;
1765  view_drop_event_handler onViewDrop = nullptr;
1766  child_event_handler onChildCreate = nullptr;
1767  child_event_handler onChildDestroy = nullptr;
1768 
1769  EventHandlers() = default;
1770  EventHandlers( const EventHandlers& ) = default;
1771  EventHandlers& operator =( const EventHandlers& ) = default;
1772  };
1773 
1774  AutoPointer<EventHandlers> m_handlers;
1775 
1776 protected:
1777 
1782  Control( void* h ) : UIObject( h )
1783  {
1784  }
1785 
1791  void* CloneHandle() const override;
1792 
1793  friend class BitmapBox;
1794  friend class CheckBox;
1795  friend class CodeEditor;
1796  friend class ComboBox;
1797  friend class ControlEventDispatcher;
1798  friend class Dialog;
1799  friend class Edit;
1800  friend class Frame;
1801  friend class GraphicsContextBase;
1802  friend class GroupBox;
1803  friend class ImageView;
1804  friend class Label;
1805  friend class PushButton;
1806  friend class RadioButton;
1807  friend class ScrollBox;
1808  friend class Sizer;
1809  friend class Slider;
1810  friend class SpinBox;
1811  friend class TabBox;
1812  friend class TextBox;
1813  friend class ToolButton;
1814  friend class TreeBox;
1815  friend class ViewList;
1816  friend class WebView;
1817 };
1818 
1819 // ----------------------------------------------------------------------------
1820 
1821 template <class C> inline
1822 int CanonicalControlHeightImplementation()
1823 {
1824  Control container;
1825  VerticalSizer sizer;
1826  C control;
1827 
1828  sizer.Add( control );
1829  container.SetSizer( sizer );
1830  container.Restyle();
1831  container.AdjustToContents();
1832  container.SetFixedSize();
1833  return container.Height();
1834 }
1835 
1851 #define CanonicalControlHeight( control_type ) \
1852  CanonicalControlHeightImplementation<control_type>()
1853 
1854 // ----------------------------------------------------------------------------
1855 
1856 #define __PCL_NO_ALIAS_HANDLERS \
1857  if ( IsAlias() ) \
1858  throw Error( "Aliased controls cannot set event handlers." )
1859 
1860 // ----------------------------------------------------------------------------
1861 
1862 #endif // !__PCL_BUILDING_PIXINSIGHT_APPLICATION
1863 
1864 } // pcl
1865 
1866 #endif // __PCL_Control_h
1867 
1868 // ----------------------------------------------------------------------------
1869 // EOF pcl/Control.h - Released 2024-01-13T15:47:58Z
pcl
PCL root namespace.
Definition: AbstractImage.h:76
pcl::Control::child_event_handler
void(Control::*)(Control &sender, Control &child) child_event_handler
Definition: Control.h:1616
pcl::CanvasColor
A set of color values used to fill free or unused areas of images.
Definition: CanvasColor.h:77
pcl::Control::IsFixedWidth
bool IsFixedWidth() const
Definition: Control.h:434
pcl::Control::Move
void Move(const pcl::Point &p)
Definition: Control.h:630
pcl::Control::paint_event_handler
void(Control::*)(Control &sender, const pcl::Rect &updateRect) paint_event_handler
Definition: Control.h:1571
pcl::Control::MaxHeight
int MaxHeight() const
Definition: Control.h:345
pcl::Control::ActivateRealTimePreview
void ActivateRealTimePreview()
Definition: Control.h:1189
pcl::Control::SetScaledFixedHeight
void SetScaledFixedHeight(int h)
Definition: Control.h:567
pcl::Control::ChildByPos
Control & ChildByPos(const pcl::Point &p) const
Definition: Control.h:740
pcl::Control::IsFixedHeight
bool IsFixedHeight() const
Definition: Control.h:441
pcl::Control::LocalToParent
pcl::Point LocalToParent(const pcl::Point &p) const
Definition: Control.h:707
pcl::Control::Repaint
void Repaint(const pcl::Rect &r)
Definition: Control.h:939
pcl::Control::MaxWidth
int MaxWidth() const
Definition: Control.h:337
pcl::GenericRectangle::Width
component Width() const noexcept
Definition: Rectangle.h:635
pcl::Control::ScaledMinWidth
int ScaledMinWidth() const
Definition: Control.h:473
pcl::Control::SetVariableWidth
void SetVariableWidth()
Definition: Control.h:456
pcl::Control::GetSizer
pcl::Sizer GetSizer() const
Definition: Control.h:663
pcl::GenericRectangle::y1
component y1
Vertical coordinate of the lower right corner.
Definition: Rectangle.h:335
pcl::Control::DeactivateTrackView
void DeactivateTrackView()
Definition: Control.h:1170
KeyCodes.h
pcl::Control::SetMinHeight
void SetMinHeight()
Definition: Control.h:318
pcl::Control::ScaledMinHeight
int ScaledMinHeight() const
Definition: Control.h:481
pcl::String
Unicode (UTF-16) string.
Definition: String.h:8112
pcl::Control::ControlToLocal
pcl::Point ControlToLocal(const Control &w, const pcl::Point &p) const
Definition: Control.h:718
pcl::Position
Reduction of planetary and stellar positions.
Definition: Position.h:345
pcl::RoundInt
int RoundInt(T x) noexcept
Definition: Math.h:1503
pcl::GenericPoint
A generic point in the two-dimensional space.
Definition: Point.h:99
pcl::Control::SetMinWidth
void SetMinWidth(int w)
Definition: Control.h:297
pcl::Control::Scroll
void Scroll(const pcl::Point &d)
Definition: Control.h:978
pcl::Control::view_drop_event_handler
void(Control::*)(Control &sender, const pcl::Point &pos, const View &view, unsigned modifiers) view_drop_event_handler
Definition: Control.h:1611
pcl::Control::IsHidden
bool IsHidden() const
Definition: Control.h:827
pcl::Control::ScaledMaxHeight
int ScaledMaxHeight() const
Definition: Control.h:525
pcl::Control::SetMinSize
void SetMinSize()
Definition: Control.h:329
pcl::Control::SetFixedWidth
void SetFixedWidth()
Definition: Control.h:402
pcl::Control::SetMinHeight
void SetMinHeight(int h)
Definition: Control.h:311
pcl::View
High-level interface to a PixInsight view object.
Definition: View.h:212
pcl::Control::SetScaledFixedWidth
void SetScaledFixedWidth(int w)
Definition: Control.h:560
pcl::Control::mouse_button_event_handler
void(Control::*)(Control &sender, const pcl::Point &pos, int button, unsigned buttons, unsigned modifiers) mouse_button_event_handler
Definition: Control.h:1586
pcl::Control::Null
static Control & Null()
pcl::Control::LogicalPixelsToPhysical
int LogicalPixelsToPhysical(int size) const
Definition: Control.h:1470
pcl::Control::mouse_wheel_event_handler
void(Control::*)(Control &sender, const pcl::Point &pos, int delta, unsigned buttons, unsigned modifiers) mouse_wheel_event_handler
Definition: Control.h:1591
pcl::Control::ScaledMaxWidth
int ScaledMaxWidth() const
Definition: Control.h:517
pcl::Control::file_drop_event_handler
void(Control::*)(Control &sender, const pcl::Point &pos, const StringList &files, unsigned modifiers) file_drop_event_handler
Definition: Control.h:1601
pcl::Control::SetScaledMaxSize
void SetScaledMaxSize(int w, int h)
Definition: Control.h:553
pcl::uint32
unsigned int uint32
Definition: Defs.h:669
pcl::Control::BoundsRect
pcl::Rect BoundsRect() const
Definition: Control.h:250
pcl::UIObject
Root base class for all user interface objects.
Definition: UIObject.h:94
pcl::Control::DisableMouseTracking
void DisableMouseTracking(bool disable=true)
Definition: Control.h:798
pcl::Control::SetFixedWidth
void SetFixedWidth(int w)
Definition: Control.h:395
pcl::Sizer
Base class for PixInsight sizer objects.
Definition: Sizer.h:146
pcl::Control::ClientHeight
int ClientHeight() const
Definition: Control.h:232
pcl::Control::PhysicalPixelsToLogical
int PhysicalPixelsToLogical(int size) const
Definition: Control.h:1483
pcl::Control::GetFont
pcl::Font GetFont() const
Definition: Control.h:1105
pcl::Control::SetScaledMinHeight
void SetScaledMinHeight(int h)
Definition: Control.h:502
pcl::Control::Height
int Height() const
Definition: Control.h:240
pcl::Control::ClearInfoText
void ClearInfoText()
Definition: Control.h:1144
pcl::Control::SetFixedHeight
void SetFixedHeight()
Definition: Control.h:416
pcl::Control::SetVariableSize
void SetVariableSize()
Definition: Control.h:448
pcl::AutoPointer< EventHandlers >
pcl::Control::keyboard_event_handler
void(Control::*)(Control &sender, int key, unsigned modifiers, bool &wantsKey) keyboard_event_handler
Definition: Control.h:1576
pcl::Control::GlobalToLocal
pcl::Point GlobalToLocal(const pcl::Point &p) const
Definition: Control.h:674
pcl::Control::~Control
~Control() override
Definition: Control.h:142
pcl::Control::Unfocus
void Unfocus()
Definition: Control.h:870
pcl::Control::ScaledStyleSheet
String ScaledStyleSheet(S cssCode, int fontDPI=0) const
Definition: Control.h:1412
pcl::Control::SetMaxSize
void SetMaxSize()
Definition: Control.h:388
pcl::Control::ClientWidth
int ClientWidth() const
Definition: Control.h:216
pcl::Flags
A type-safe collection of enumerated flags.
Definition: Flags.h:84
pcl::GenericRectangle
A generic rectangle in the two-dimensional space.
Definition: Rectangle.h:313
pcl::GenericRectangle::x1
component x1
Horizontal coordinate of the lower right corner.
Definition: Rectangle.h:334
pcl::Array< String >
pcl::Control::FrameHeight
int FrameHeight() const
Definition: Control.h:203
pcl::Control::SetScaledMinWidth
void SetScaledMinWidth(int w)
Definition: Control.h:495
pcl::Control::DisableUpdates
void DisableUpdates(bool disable=true)
Definition: Control.h:913
pcl::Control::event_handler
void(Control::*)(Control &sender) event_handler
Definition: Control.h:1551
pcl::Control::ParentToLocal
pcl::Point ParentToLocal(const pcl::Point &p) const
Definition: Control.h:696
pcl::Control::DeactivateRealTimePreview
void DeactivateRealTimePreview()
Definition: Control.h:1196
pcl::Control::ScaledCursorHotSpot
Point ScaledCursorHotSpot(int xHot, int yHot) const
Definition: Control.h:1441
Rectangle.h
pcl::Control::Scroll
void Scroll(const pcl::Point &d, const pcl::Rect &r)
Definition: Control.h:989
pcl::UIScaledStyleSheet
String UIScaledStyleSheet(double displayScalingFactor, double resourceScalingFactor, S styleSheet, int fontDPI=0)
Definition: UIScaling.h:259
pcl::Control::ScaledResource
String ScaledResource(R resource) const
Definition: Control.h:1340
pcl::Control::MinWidth
int MinWidth() const
Definition: Control.h:278
pcl::GenericRectangle::Height
component Height() const noexcept
Definition: Rectangle.h:644
pcl::Control::SetScaledMaxHeight
void SetScaledMaxHeight(int h)
Definition: Control.h:546
Font.h
pcl::Control::ScaledCursorHotSpot
Point ScaledCursorHotSpot(const Point &hotSpot) const
Definition: Control.h:1457
pcl::Control::LocalToControl
pcl::Point LocalToControl(const Control &w, const pcl::Point &p) const
Definition: Control.h:729
Sizer.h
pcl::Control::view_drag_event_handler
void(Control::*)(Control &sender, const pcl::Point &pos, const View &view, unsigned modifiers, bool &wantsView) view_drag_event_handler
Definition: Control.h:1606
pcl::RGBA
uint32 RGBA
Definition: Color.h:92
AutoPointer.h
UIObject.h
pcl::GenericPoint::x
component x
Abscissa (horizontal, or X-axis coordinate).
Definition: Point.h:111
pcl::Control::resize_event_handler
void(Control::*)(Control &sender, int newWidth, int newHeight, int oldWidth, int oldHeight) resize_event_handler
Definition: Control.h:1566
pcl::Control::X
int X() const
Definition: Control.h:613
pcl::Control::SetScaledMaxWidth
void SetScaledMaxWidth(int w)
Definition: Control.h:539
Cursor.h
pcl::Control::SetScaledFixedSize
void SetScaledFixedSize(int w, int h)
Definition: Control.h:574
pcl::Control::SetFixedHeight
void SetFixedHeight(int h)
Definition: Control.h:409
pcl::UIScaledResource
String UIScaledResource(double scalingFactor, R resource)
Definition: UIScaling.h:203
pcl::Cursor
Client-side interface to a PixInsight Cursor object.
Definition: Cursor.h:167
pcl::Control::file_drag_event_handler
void(Control::*)(Control &sender, const pcl::Point &pos, const StringList &files, unsigned modifiers, bool &wantsFiles) file_drag_event_handler
Definition: Control.h:1596
pcl::Control::SetScaledMinSize
void SetScaledMinSize(int w, int h)
Definition: Control.h:509
pcl::Control::SetMinWidth
void SetMinWidth()
Definition: Control.h:304
pcl::Control::ShowToolTip
static void ShowToolTip(const Point &pos, const String &text, const Control &control=Control::Null(), const Rect &rect=Rect(0))
Definition: Control.h:1245
pcl::Control::GetCursor
pcl::Cursor GetCursor() const
Definition: Control.h:1005
pcl::Control::move_event_handler
void(Control::*)(Control &sender, const pcl::Point &newPos, const pcl::Point &oldPos) move_event_handler
Definition: Control.h:1561
pcl::Control::SetFixedSize
void SetFixedSize()
Definition: Control.h:427
pcl::Control::SetVariableHeight
void SetVariableHeight()
Definition: Control.h:464
pcl::Control::LocalToGlobal
pcl::Point LocalToGlobal(const pcl::Point &p) const
Definition: Control.h:685
pcl::Control::SetMaxWidth
void SetMaxWidth()
Definition: Control.h:363
pcl::Control::close_event_handler
void(Control::*)(Control &sender, bool &allowClose) close_event_handler
Definition: Control.h:1556
pcl::Control::SetMaxHeight
void SetMaxHeight()
Definition: Control.h:377
pcl::Font
Client-side interface to a PixInsight Font object.
Definition: Font.h:206
pcl::Control::SetMaxWidth
void SetMaxWidth(int w)
Definition: Control.h:356
pcl::GenericRectangle::x0
component x0
Horizontal coordinate of the upper left corner.
Definition: Rectangle.h:332
pcl::Control::mouse_event_handler
void(Control::*)(Control &sender, const pcl::Point &pos, unsigned buttons, unsigned modifiers) mouse_event_handler
Definition: Control.h:1581
Color.h
pcl::GenericRectangle::y0
component y0
Vertical coordinate of the upper left corner.
Definition: Rectangle.h:333
pcl::Control
Client-side interface to a PixInsight Control object.
Definition: Control.h:125
ButtonCodes.h
pcl::Control::SetClientRect
void SetClientRect(const pcl::Rect &r)
Definition: Control.h:258
pcl::Control::ResourcePixelsToLogical
int ResourcePixelsToLogical(int size) const
Definition: Control.h:1512
pcl::GenericPoint::y
component y
Ordinate (vertical, or Y-axis coordinate).
Definition: Point.h:112
Flags.h
pcl::Control::Disable
void Disable(bool disabled=true)
Definition: Control.h:783
pcl::Control::Width
int Width() const
Definition: Control.h:224
pcl::Control::EnsureUnique
void EnsureUnique() override
Definition: Control.h:177
pcl::Control::MinHeight
int MinHeight() const
Definition: Control.h:286
pcl::Control::Update
void Update(const pcl::Rect &r)
Definition: Control.h:924
pcl::Control::LogicalPixelsToResource
int LogicalPixelsToResource(int size) const
Definition: Control.h:1499
pcl::Control::Y
int Y() const
Definition: Control.h:623
pcl::Control::DisableExpansion
void DisableExpansion(bool horzDisable=true, bool vertDisable=true)
Definition: Control.h:593
pcl::Control::SetVisible
void SetVisible(bool visible)
Definition: Control.h:809
pcl::Control::FrameWidth
int FrameWidth() const
Definition: Control.h:195
UIScaling.h
Defs.h
pcl::Control::ActivateTrackView
void ActivateTrackView()
Definition: Control.h:1163
pcl::Control::GetScaledMinSize
void GetScaledMinSize(int &w, int &h) const
Definition: Control.h:488
pcl::Control::SetMaxHeight
void SetMaxHeight(int h)
Definition: Control.h:370
pcl::Control::GetScaledMaxSize
void GetScaledMaxSize(int &w, int &h) const
Definition: Control.h:532