Go to the documentation of this file.
52 #ifndef __PCL_Control_h
53 #define __PCL_Control_h
57 #ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
73 #endif // !__PCL_BUILDING_PIXINSIGHT_APPLICATION
113 #ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
117 class PCL_CLASS
View;
197 return FrameRect().Width();
205 return FrameRect().Height();
218 return ClientRect().Width();
226 return ClientWidth();
234 return ClientRect().Height();
242 return ClientHeight();
260 SetClientRect( r.
x0, r.
y0, r.
x1, r.
y1 );
265 void SetClientRect(
int x0,
int y0,
int x1,
int y1 );
269 void Resize(
int w,
int h );
273 void AdjustToContents();
280 int w, dum; GetMinSize( w, dum );
return w;
288 int dum, h; GetMinSize( dum, h );
return h;
293 void GetMinSize(
int& w,
int& h )
const;
306 SetMinWidth( Width() );
320 SetMinHeight( Height() );
325 void SetMinSize(
int w,
int h );
331 SetMinSize( Width(), Height() );
339 int w, dum; GetMaxSize( w, dum );
return w;
347 int dum, h; GetMaxSize( dum, h );
return h;
352 void GetMaxSize(
int& w,
int& h )
const;
365 SetMaxWidth( Width() );
379 SetMaxHeight( Height() );
384 void SetMaxSize(
int w,
int h );
390 SetMaxSize( Width(), Height() );
397 SetFixedSize( w, -1 );
404 SetFixedWidth( Width() );
411 SetFixedSize( -1, h );
418 SetFixedHeight( Height() );
423 void SetFixedSize(
int w,
int h );
429 SetFixedSize( Width(), Height() );
436 return MinWidth() == MaxWidth();
443 return MinHeight() == MaxHeight();
451 SetMaxSize( int_max, int_max );
459 SetMaxWidth( int_max );
467 SetMaxHeight( int_max );
475 int w, dum; GetMinSize( w, dum );
return PhysicalPixelsToLogical( w );
483 int dum, h; GetMinSize( dum, h );
return PhysicalPixelsToLogical( h );
490 GetMinSize( w, h ); w = PhysicalPixelsToLogical( w ); h = PhysicalPixelsToLogical( h );
497 SetMinSize( LogicalPixelsToPhysical( w ), -1 );
504 SetMinSize( -1, LogicalPixelsToPhysical( h ) );
511 SetMinSize( LogicalPixelsToPhysical( w ), LogicalPixelsToPhysical( h ) );
519 int w, dum; GetMaxSize( w, dum );
return PhysicalPixelsToLogical( w );
527 int dum, h; GetMaxSize( dum, h );
return PhysicalPixelsToLogical( h );
534 GetMaxSize( w, h ); w = PhysicalPixelsToLogical( w ); h = PhysicalPixelsToLogical( h );
541 SetMaxSize( LogicalPixelsToPhysical( w ), -1 );
548 SetMaxSize( -1, LogicalPixelsToPhysical( h ) );
555 SetMaxSize( LogicalPixelsToPhysical( w ), LogicalPixelsToPhysical( h ) );
562 SetFixedSize( LogicalPixelsToPhysical( w ), -1 );
569 SetFixedSize( -1, LogicalPixelsToPhysical( h ) );
576 SetFixedSize( LogicalPixelsToPhysical( w ), LogicalPixelsToPhysical( h ) );
581 bool IsHorizontalExpansionEnabled()
const;
585 bool IsVerticalExpansionEnabled()
const;
589 void EnableExpansion(
bool horzEnable =
true,
bool vertEnable =
true );
595 EnableExpansion( !horzDisable, !vertDisable );
637 void Move(
int x,
int y );
642 bool IsUnderMouse()
const;
665 return this->
Sizer();
676 pcl::Point p1 = p; GlobalToLocal( p1.
x, p1.
y );
return p1;
681 void GlobalToLocal(
int& x,
int& y )
const;
687 pcl::Point p1 = p; LocalToGlobal( p1.
x, p1.
y );
return p1;
692 void LocalToGlobal(
int& x,
int& y )
const;
698 pcl::Point p1 = p; ParentToLocal( p1.
x, p1.
y );
return p1;
703 void ParentToLocal(
int& x,
int& y )
const;
709 pcl::Point p1 = p; LocalToParent( p1.
x, p1.
y );
return p1;
714 void LocalToParent(
int& x,
int& y )
const;
720 pcl::Point p1 = p; ControlToLocal( w, p1.
x, p1.
y );
return p1;
725 void ControlToLocal(
const Control&,
int& x,
int& y )
const;
731 pcl::Point p1 = p; LocalToControl( w, p1.
x, p1.
y );
return p1;
736 void LocalToControl(
const Control&,
int& x,
int& y )
const;
742 return ChildByPos( p.
x, p.
y );
747 Control& ChildByPos(
int x,
int y )
const;
755 bool IsAncestorOf(
const Control& )
const;
775 virtual bool IsEnabled()
const;
779 virtual void Enable(
bool enabled =
true );
790 bool IsMouseTrackingEnabled()
const;
794 void EnableMouseTracking(
bool =
true );
800 EnableMouseTracking( !disable );
805 bool IsVisible()
const;
838 bool IsMaximized()
const;
842 bool IsMinimized()
const;
846 bool IsModal()
const;
850 bool IsWindow()
const;
854 bool IsActiveWindow()
const;
858 void ActivateWindow();
862 bool IsFocused()
const;
866 void Focus(
bool focus =
true );
893 void SetChildToFocus(
Control& );
897 Control& NextSiblingToFocus()
const;
901 void SetNextSiblingToFocus(
Control& );
905 bool CanUpdate()
const;
909 void EnableUpdates(
bool enable =
true );
915 EnableUpdates( !disable );
931 void Update(
int x0,
int y0,
int x1,
int y1 );
946 void Repaint(
int x0,
int y0,
int x1,
int y1 );
974 void EnsureLayoutUpdated();
985 void Scroll(
int dx,
int dy );
996 void Scroll(
int dx,
int dy,
int x0,
int y0,
int x1,
int y1 );
1016 void SetCursorToParent();
1020 String StyleSheet()
const;
1024 void SetStyleSheet(
const String& css );
1028 RGBA BackgroundColor()
const;
1032 void SetBackgroundColor(
RGBA );
1036 RGBA ForegroundColor()
const;
1040 void SetForegroundColor(
RGBA );
1048 void SetCanvasColor(
RGBA );
1052 RGBA AlternateCanvasColor()
const;
1056 void SetAlternateCanvasColor(
RGBA );
1060 RGBA TextColor()
const;
1064 void SetTextColor(
RGBA );
1068 RGBA ButtonColor()
const;
1072 void SetButtonColor(
RGBA );
1076 RGBA ButtonTextColor()
const;
1080 void SetButtonTextColor(
RGBA );
1084 RGBA HighlightColor()
const;
1088 void SetHighlightColor(
RGBA );
1092 RGBA HighlightedTextColor()
const;
1096 void SetHighlightedTextColor(
RGBA );
1107 return this->
Font();
1116 double WindowOpacity()
const;
1120 void SetWindowOpacity(
double );
1124 String WindowTitle()
const;
1128 void SetWindowTitle(
const String& );
1140 void SetInfoText(
const String& );
1155 bool IsTrackViewActive()
const;
1159 void SetTrackViewActive(
bool =
true );
1165 SetTrackViewActive(
true );
1172 SetTrackViewActive(
false );
1181 bool IsRealTimePreviewActive()
const;
1185 void SetRealTimePreviewActive(
bool =
true );
1191 SetRealTimePreviewActive(
true );
1198 SetRealTimePreviewActive(
false );
1209 void SetToolTip(
const String& );
1236 static void ShowToolTip(
int x,
int y,
const String& text,
1248 ShowToolTip( pos.
x, pos.
y, text, control, rect );
1254 static void HideToolTip();
1260 static String ToolTipText();
1286 double DisplayPixelRatio()
const;
1320 double ResourcePixelRatio()
const;
1414 return UIScaledStyleSheet( DisplayPixelRatio(), ResourcePixelRatio(), cssCode, fontDPI );
1443 double r = ResourcePixelRatio();
1459 return ScaledCursorHotSpot( hotSpot.
x, hotSpot.
y );
1472 return RoundInt( DisplayPixelRatio()*size );
1485 return RoundInt( size/DisplayPixelRatio() );
1501 return RoundInt( ResourcePixelRatio()*size );
1514 return RoundInt( size/ResourcePixelRatio() );
1742 struct EventHandlers
1769 EventHandlers() =
default;
1770 EventHandlers(
const EventHandlers& ) =
default;
1771 EventHandlers& operator =(
const EventHandlers& ) =
default;
1791 void* CloneHandle()
const override;
1793 friend class BitmapBox;
1794 friend class CheckBox;
1795 friend class CodeEditor;
1796 friend class ComboBox;
1797 friend class ControlEventDispatcher;
1798 friend class Dialog;
1801 friend class GraphicsContextBase;
1802 friend class GroupBox;
1803 friend class ImageView;
1805 friend class PushButton;
1806 friend class RadioButton;
1807 friend class ScrollBox;
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;
1821 template <
class C>
inline
1822 int CanonicalControlHeightImplementation()
1825 VerticalSizer sizer;
1828 sizer.Add( control );
1829 container.SetSizer( sizer );
1830 container.Restyle();
1831 container.AdjustToContents();
1832 container.SetFixedSize();
1833 return container.Height();
1851 #define CanonicalControlHeight( control_type ) \
1852 CanonicalControlHeightImplementation<control_type>()
1856 #define __PCL_NO_ALIAS_HANDLERS \
1858 throw Error( "Aliased controls cannot set event handlers." )
1862 #endif // !__PCL_BUILDING_PIXINSIGHT_APPLICATION
1866 #endif // __PCL_Control_h
void(Control::*)(Control &sender, Control &child) child_event_handler
A set of color values used to fill free or unused areas of images.
bool IsFixedWidth() const
void Move(const pcl::Point &p)
void(Control::*)(Control &sender, const pcl::Rect &updateRect) paint_event_handler
void ActivateRealTimePreview()
void SetScaledFixedHeight(int h)
Control & ChildByPos(const pcl::Point &p) const
bool IsFixedHeight() const
pcl::Point LocalToParent(const pcl::Point &p) const
void Repaint(const pcl::Rect &r)
component Width() const noexcept
int ScaledMinWidth() const
pcl::Sizer GetSizer() const
component y1
Vertical coordinate of the lower right corner.
void DeactivateTrackView()
int ScaledMinHeight() const
pcl::Point ControlToLocal(const Control &w, const pcl::Point &p) const
Reduction of planetary and stellar positions.
int RoundInt(T x) noexcept
A generic point in the two-dimensional space.
void Scroll(const pcl::Point &d)
void(Control::*)(Control &sender, const pcl::Point &pos, const View &view, unsigned modifiers) view_drop_event_handler
int ScaledMaxHeight() const
High-level interface to a PixInsight view object.
void SetScaledFixedWidth(int w)
void(Control::*)(Control &sender, const pcl::Point &pos, int button, unsigned buttons, unsigned modifiers) mouse_button_event_handler
int LogicalPixelsToPhysical(int size) const
void(Control::*)(Control &sender, const pcl::Point &pos, int delta, unsigned buttons, unsigned modifiers) mouse_wheel_event_handler
int ScaledMaxWidth() const
void(Control::*)(Control &sender, const pcl::Point &pos, const StringList &files, unsigned modifiers) file_drop_event_handler
void SetScaledMaxSize(int w, int h)
pcl::Rect BoundsRect() const
Root base class for all user interface objects.
void DisableMouseTracking(bool disable=true)
void SetFixedWidth(int w)
Base class for PixInsight sizer objects.
int PhysicalPixelsToLogical(int size) const
pcl::Font GetFont() const
void SetScaledMinHeight(int h)
void(Control::*)(Control &sender, int key, unsigned modifiers, bool &wantsKey) keyboard_event_handler
pcl::Point GlobalToLocal(const pcl::Point &p) const
String ScaledStyleSheet(S cssCode, int fontDPI=0) const
A type-safe collection of enumerated flags.
A generic rectangle in the two-dimensional space.
component x1
Horizontal coordinate of the lower right corner.
void SetScaledMinWidth(int w)
void DisableUpdates(bool disable=true)
void(Control::*)(Control &sender) event_handler
pcl::Point ParentToLocal(const pcl::Point &p) const
void DeactivateRealTimePreview()
Point ScaledCursorHotSpot(int xHot, int yHot) const
void Scroll(const pcl::Point &d, const pcl::Rect &r)
String UIScaledStyleSheet(double displayScalingFactor, double resourceScalingFactor, S styleSheet, int fontDPI=0)
String ScaledResource(R resource) const
component Height() const noexcept
void SetScaledMaxHeight(int h)
Point ScaledCursorHotSpot(const Point &hotSpot) const
pcl::Point LocalToControl(const Control &w, const pcl::Point &p) const
void(Control::*)(Control &sender, const pcl::Point &pos, const View &view, unsigned modifiers, bool &wantsView) view_drag_event_handler
component x
Abscissa (horizontal, or X-axis coordinate).
void(Control::*)(Control &sender, int newWidth, int newHeight, int oldWidth, int oldHeight) resize_event_handler
void SetScaledMaxWidth(int w)
void SetScaledFixedSize(int w, int h)
void SetFixedHeight(int h)
String UIScaledResource(double scalingFactor, R resource)
Client-side interface to a PixInsight Cursor object.
void(Control::*)(Control &sender, const pcl::Point &pos, const StringList &files, unsigned modifiers, bool &wantsFiles) file_drag_event_handler
void SetScaledMinSize(int w, int h)
static void ShowToolTip(const Point &pos, const String &text, const Control &control=Control::Null(), const Rect &rect=Rect(0))
pcl::Cursor GetCursor() const
void(Control::*)(Control &sender, const pcl::Point &newPos, const pcl::Point &oldPos) move_event_handler
pcl::Point LocalToGlobal(const pcl::Point &p) const
void(Control::*)(Control &sender, bool &allowClose) close_event_handler
Client-side interface to a PixInsight Font object.
component x0
Horizontal coordinate of the upper left corner.
void(Control::*)(Control &sender, const pcl::Point &pos, unsigned buttons, unsigned modifiers) mouse_event_handler
component y0
Vertical coordinate of the upper left corner.
Client-side interface to a PixInsight Control object.
void SetClientRect(const pcl::Rect &r)
int ResourcePixelsToLogical(int size) const
component y
Ordinate (vertical, or Y-axis coordinate).
void Disable(bool disabled=true)
void EnsureUnique() override
void Update(const pcl::Rect &r)
int LogicalPixelsToResource(int size) const
void DisableExpansion(bool horzDisable=true, bool vertDisable=true)
void SetVisible(bool visible)
void GetScaledMinSize(int &w, int &h) const
void GetScaledMaxSize(int &w, int &h) const