PCL
Control.h
Go to the documentation of this file.
1 // ____ ______ __
2 // / __ \ / ____// /
3 // / /_/ // / / /
4 // / ____// /___ / /___ PixInsight Class Library
5 // /_/ \____//_____/ PCL 2.6.11
6 // ----------------------------------------------------------------------------
7 // pcl/Control.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_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 
191 
195  int FrameWidth() const
196  {
197  return FrameRect().Width();
198  }
199 
203  int FrameHeight() const
204  {
205  return FrameRect().Height();
206  }
207 
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 
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 
582 
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 
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 
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 
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 
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 
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 
859 
862  bool IsFocused() const;
863 
866  void Focus( bool focus = true );
867 
870  void Unfocus()
871  {
872  Focus( false );
873  }
874 
878 
882 
886 
890 
894 
898 
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 
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 
1001 
1006  {
1007  return this->Cursor();
1008  }
1009 
1012  void SetCursor( const pcl::Cursor& );
1013 
1017 
1021 
1024  void SetStyleSheet( const String& css );
1025 
1029 
1033 
1037 
1041 
1045 
1049 
1053 
1057 
1060  RGBA TextColor() const;
1061 
1065 
1069 
1073 
1077 
1081 
1085 
1089 
1093 
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 
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 
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 
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 
1622 
1627 
1632 
1637 
1642 
1647 
1652 
1657 
1662 
1667 
1672 
1677 
1682 
1687 
1692 
1697 
1702 
1707 
1712 
1717 
1722 
1727 
1732 
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-05-07T15:27:32Z
Client-side interface to a PixInsight Control object.
Definition: Control.h:126
int ClientWidth() const
Definition: Control.h:216
void SetMinWidth()
Definition: Control.h:304
void BringToFront()
void SetToolTip(const String &)
Control(Control &&)=delete
bool IsFocused() const
pcl::Point LocalToControl(const Control &w, const pcl::Point &p) const
Definition: Control.h:729
bool IsModal() const
pcl::Rect BoundsRect() const
Definition: Control.h:250
void Scroll(int dx, int dy)
void SetAlternateCanvasColor(RGBA)
Control & NextSiblingToFocus() const
String WindowTitle() const
void SetFixedHeight(int h)
Definition: Control.h:409
bool IsActiveWindow() const
int ClientHeight() const
Definition: Control.h:232
void SetScaledFixedSize(int w, int h)
Definition: Control.h:574
void SetSizer(pcl::Sizer &)
void SetFont(const pcl::Font &)
String StyleSheet() const
bool IsAncestorOf(const Control &) const
void Repaint()
void SetBackgroundColor(RGBA)
RGBA CanvasColor()
void Restyle()
bool IsFixedWidth() const
Definition: Control.h:434
void SetClientRect(const pcl::Rect &r)
Definition: Control.h:258
pcl::Point GlobalToLocal(const pcl::Point &p) const
Definition: Control.h:674
bool IsUnderMouse() const
String ToolTip() const
pcl::Sizer GetSizer() const
Definition: Control.h:663
bool CanUpdate() const
void DisableExpansion(bool horzDisable=true, bool vertDisable=true)
Definition: Control.h:593
RGBA TextColor() const
bool IsVerticalExpansionEnabled() const
bool IsTrackViewActive() const
void AdjustToContents()
void GetMaxSize(int &w, int &h) const
pcl::Sizer Sizer() const
bool IsMaximized() const
int ScaledMaxWidth() const
Definition: Control.h:517
void LocalToControl(const Control &, int &x, int &y) const
void SetCursor(const pcl::Cursor &)
void SetMaxHeight()
Definition: Control.h:377
void SetWindowOpacity(double)
Control & ChildByPos(const pcl::Point &p) const
Definition: Control.h:740
static Control & Null()
void SetVariableSize()
Definition: Control.h:448
void EnableUpdates(bool enable=true)
void DisableUpdates(bool disable=true)
Definition: Control.h:913
virtual void Enable(bool enabled=true)
static void ShowToolTip(int x, int y, const String &text, const Control &control=Control::Null(), const Rect &rect=Rect(0))
RGBA HighlightColor() const
void SetNextSiblingToFocus(Control &)
void Move(int x, int y)
void SetTrackViewActive(bool=true)
bool IsHorizontalExpansionEnabled() const
Control & ChildByPos(int x, int y) const
void SetMinSize(int w, int h)
void ControlToLocal(const Control &, int &x, int &y) const
int X() const
Definition: Control.h:613
void SetMinHeight()
Definition: Control.h:318
bool IsVisible() const
Control(const Control &)=delete
void Focus(bool focus=true)
void SetScaledMinSize(int w, int h)
Definition: Control.h:509
pcl::Rect VisibleRect() const
pcl::Point ParentToLocal(const pcl::Point &p) const
Definition: Control.h:696
void SetScaledMaxSize(int w, int h)
Definition: Control.h:553
pcl::Font Font() const
void SetScaledMaxHeight(int h)
Definition: Control.h:546
void SetButtonColor(RGBA)
void SendToBack()
void SetFixedHeight()
Definition: Control.h:416
static void ShowToolTip(const Point &pos, const String &text, const Control &control=Control::Null(), const Rect &rect=Rect(0))
Definition: Control.h:1245
void Repaint(int x0, int y0, int x1, int y1)
void Move(const pcl::Point &p)
Definition: Control.h:630
int FrameHeight() const
Definition: Control.h:203
void LocalToGlobal(int &x, int &y) const
pcl::Point Position() const
void SetVariableWidth()
Definition: Control.h:456
void EnableExpansion(bool horzEnable=true, bool vertEnable=true)
void GetScaledMinSize(int &w, int &h) const
Definition: Control.h:488
void Scroll(int dx, int dy, int x0, int y0, int x1, int y1)
void StackUnder(Control &)
void DeactivateRealTimePreview()
Definition: Control.h:1196
int MinWidth() const
Definition: Control.h:278
pcl::Font GetFont() const
Definition: Control.h:1105
void SetChildToFocus(Control &)
void ParentToLocal(int &x, int &y) const
void SetScaledFixedWidth(int w)
Definition: Control.h:560
void SetButtonTextColor(RGBA)
pcl::Rect ClientRect() const
void SetVisible(bool visible)
Definition: Control.h:809
void ActivateRealTimePreview()
Definition: Control.h:1189
bool IsHidden() const
Definition: Control.h:827
int Y() const
Definition: Control.h:623
~Control() override
Definition: Control.h:142
int ScaledMinHeight() const
Definition: Control.h:481
void SetMaxHeight(int h)
Definition: Control.h:370
pcl::Point LocalToGlobal(const pcl::Point &p) const
Definition: Control.h:685
void SetInfoText(const String &)
void SetParent(Control &)
void SetFocusStyle(FocusStyles)
void SetForegroundColor(RGBA)
void SetMaxSize(int w, int h)
void SetClientRect(int x0, int y0, int x1, int y1)
void SetFixedSize()
Definition: Control.h:427
void LocalToParent(int &x, int &y) const
bool IsMinimized() const
void SetTextColor(RGBA)
void SetRealTimePreviewActive(bool=true)
bool IsWindow() const
static String ToolTipText()
void SetMinSize()
Definition: Control.h:329
void SetScaledFixedHeight(int h)
Definition: Control.h:567
pcl::Cursor Cursor() const
void SetCanvasColor(RGBA)
static void HideToolTip()
void ActivateTrackView()
Definition: Control.h:1163
void SetCursorToParent()
void Scroll(const pcl::Point &d)
Definition: Control.h:978
Control & FocusedChild() const
void SetFixedSize(int w, int h)
void SetFixedWidth()
Definition: Control.h:402
void GetScaledMaxSize(int &w, int &h) const
Definition: Control.h:532
int Height() const
Definition: Control.h:240
void EnableMouseTracking(bool=true)
RGBA ButtonTextColor() const
void SetMaxWidth()
Definition: Control.h:363
pcl::Point ControlToLocal(const Control &w, const pcl::Point &p) const
Definition: Control.h:718
void SetMaxWidth(int w)
Definition: Control.h:356
RGBA HighlightedTextColor() const
Control & Window() const
void SetStyleSheet(const String &css)
void DeactivateTrackView()
Definition: Control.h:1170
void Disable(bool disabled=true)
Definition: Control.h:783
Control & ChildToFocus() const
virtual bool IsEnabled() const
void SetFixedWidth(int w)
Definition: Control.h:395
int MaxWidth() const
Definition: Control.h:337
void SetMinWidth(int w)
Definition: Control.h:297
void SetVariableHeight()
Definition: Control.h:464
void SetHighlightedTextColor(RGBA)
void SetScaledMinWidth(int w)
Definition: Control.h:495
void ClearInfoText()
Definition: Control.h:1144
Control & Parent() const
void DisableMouseTracking(bool disable=true)
Definition: Control.h:798
void EnsureLayoutUpdated()
RGBA ForegroundColor() const
RGBA AlternateCanvasColor() const
int ScaledMinWidth() const
Definition: Control.h:473
void GlobalToLocal(int &x, int &y) const
void SetMaxSize()
Definition: Control.h:388
void Scroll(const pcl::Point &d, const pcl::Rect &r)
Definition: Control.h:989
double WindowOpacity() const
void EnsureUnique() override
Definition: Control.h:177
void Unfocus()
Definition: Control.h:870
void Resize(int w, int h)
void Update(const pcl::Rect &r)
Definition: Control.h:924
pcl::Point LocalToParent(const pcl::Point &p) const
Definition: Control.h:707
pcl::Rect FrameRect() const
void SetScaledMaxWidth(int w)
Definition: Control.h:539
void Repaint(const pcl::Rect &r)
Definition: Control.h:939
bool IsRealTimePreviewActive() const
Control(Control &parent=Null(), uint32=0)
void SetHighlightColor(RGBA)
FocusStyles FocusStyle() const
bool IsFixedHeight() const
Definition: Control.h:441
bool IsMouseTrackingEnabled() const
int Width() const
Definition: Control.h:224
void Update(int x0, int y0, int x1, int y1)
pcl::Rect ChildrenRect() const
pcl::Cursor GetCursor() const
Definition: Control.h:1005
int MinHeight() const
Definition: Control.h:286
void SetScaledMinHeight(int h)
Definition: Control.h:502
void SetWindowTitle(const String &)
int MaxHeight() const
Definition: Control.h:345
void GetMinSize(int &w, int &h) const
RGBA ButtonColor() const
String InfoText() const
RGBA BackgroundColor() const
int FrameWidth() const
Definition: Control.h:195
void ActivateWindow()
int ScaledMaxHeight() const
Definition: Control.h:525
void SetMinHeight(int h)
Definition: Control.h:311
Client-side interface to a PixInsight Cursor object.
Definition: Cursor.h:168
A type-safe collection of enumerated flags.
Definition: Flags.h:85
Client-side interface to a PixInsight Font object.
Definition: Font.h:207
A generic point in the two-dimensional space.
Definition: Point.h:100
component x
Abscissa (horizontal, or X-axis coordinate).
Definition: Point.h:111
component y
Ordinate (vertical, or Y-axis coordinate).
Definition: Point.h:112
A generic rectangle in the two-dimensional space.
Definition: Rectangle.h:314
component x1
Horizontal coordinate of the lower right corner.
Definition: Rectangle.h:334
component y1
Vertical coordinate of the lower right corner.
Definition: Rectangle.h:335
component y0
Vertical coordinate of the upper left corner.
Definition: Rectangle.h:333
component x0
Horizontal coordinate of the upper left corner.
Definition: Rectangle.h:332
component Width() const noexcept
Definition: Rectangle.h:635
component Height() const noexcept
Definition: Rectangle.h:644
Reduction of planetary and stellar positions.
Definition: Position.h:346
Base class for PixInsight sizer objects.
Definition: Sizer.h:147
Unicode (UTF-16) string.
Definition: String.h:8113
Root base class for all user interface objects.
Definition: UIObject.h:95
High-level interface to a PixInsight view object.
Definition: View.h:213
void(Control::*)(Control &sender, const pcl::Point &pos, const View &view, unsigned modifiers) view_drop_event_handler
Definition: Control.h:1611
void OnMousePress(mouse_button_event_handler, Control &)
void OnDestroy(event_handler, Control &)
void(Control::*)(Control &sender, const pcl::Point &pos, int button, unsigned buttons, unsigned modifiers) mouse_button_event_handler
Definition: Control.h:1586
void OnResize(resize_event_handler, Control &)
void OnLoseFocus(event_handler, Control &)
void(Control::*)(Control &sender, bool &allowClose) close_event_handler
Definition: Control.h:1556
void(Control::*)(Control &sender, const pcl::Point &pos, const View &view, unsigned modifiers, bool &wantsView) view_drag_event_handler
Definition: Control.h:1606
void(Control::*)(Control &sender, const pcl::Point &newPos, const pcl::Point &oldPos) move_event_handler
Definition: Control.h:1561
void OnChildDestroy(child_event_handler, Control &)
void OnMouseWheel(mouse_wheel_event_handler, Control &)
void OnMouseRelease(mouse_button_event_handler, Control &)
void OnClose(close_event_handler, Control &)
void OnGetFocus(event_handler, Control &)
void OnLeave(event_handler, Control &)
void(Control::*)(Control &sender) event_handler
Definition: Control.h:1551
void OnMouseDoubleClick(mouse_event_handler, Control &)
void OnFileDrop(file_drop_event_handler, Control &)
void(Control::*)(Control &sender, const pcl::Point &pos, const StringList &files, unsigned modifiers) file_drop_event_handler
Definition: Control.h:1601
void OnViewDrag(view_drag_event_handler, Control &)
void OnFileDrag(file_drag_event_handler, Control &)
void(Control::*)(Control &sender, int newWidth, int newHeight, int oldWidth, int oldHeight) resize_event_handler
Definition: Control.h:1566
void OnShow(event_handler, Control &)
void OnPaint(paint_event_handler, Control &)
void OnHide(event_handler, Control &)
void(Control::*)(Control &sender, const pcl::Point &pos, int delta, unsigned buttons, unsigned modifiers) mouse_wheel_event_handler
Definition: Control.h:1591
void OnViewDrop(view_drop_event_handler, Control &)
void(Control::*)(Control &sender, const pcl::Rect &updateRect) paint_event_handler
Definition: Control.h:1571
void(Control::*)(Control &sender, Control &child) child_event_handler
Definition: Control.h:1616
void(Control::*)(Control &sender, const pcl::Point &pos, const StringList &files, unsigned modifiers, bool &wantsFiles) file_drag_event_handler
Definition: Control.h:1596
void OnChildCreate(child_event_handler, Control &)
void(Control::*)(Control &sender, int key, unsigned modifiers, bool &wantsKey) keyboard_event_handler
Definition: Control.h:1576
void OnKeyPress(keyboard_event_handler, Control &)
void OnKeyRelease(keyboard_event_handler, Control &)
void(Control::*)(Control &sender, const pcl::Point &pos, unsigned buttons, unsigned modifiers) mouse_event_handler
Definition: Control.h:1581
void OnMouseMove(mouse_event_handler, Control &)
void OnEnter(event_handler, Control &)
void OnMove(move_event_handler, Control &)
int RoundInt(T x) noexcept
Definition: Math.h:1503
unsigned int uint32
Definition: Defs.h:666
uint32 RGBA
Definition: Color.h:92
double ResourcePixelRatio() const
int LogicalPixelsToResource(int size) const
Definition: Control.h:1499
Point ScaledCursorHotSpot(const Point &hotSpot) const
Definition: Control.h:1457
String ScaledStyleSheet(S cssCode, int fontDPI=0) const
Definition: Control.h:1412
int PhysicalPixelsToLogical(int size) const
Definition: Control.h:1483
double DisplayPixelRatio() const
String UIScaledStyleSheet(double displayScalingFactor, double resourceScalingFactor, S styleSheet, int fontDPI=0)
Definition: UIScaling.h:259
String UIScaledResource(double scalingFactor, R resource)
Definition: UIScaling.h:203
int ResourcePixelsToLogical(int size) const
Definition: Control.h:1512
int LogicalPixelsToPhysical(int size) const
Definition: Control.h:1470
Point ScaledCursorHotSpot(int xHot, int yHot) const
Definition: Control.h:1441
String ScaledResource(R resource) const
Definition: Control.h:1340
PCL root namespace.
Definition: AbstractImage.h:77