52 #ifndef __PCL_Control_h
53 #define __PCL_Control_h
57 #ifndef __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 );
280 int w, dum; GetMinSize( w, dum );
return w;
288 int dum, h; GetMinSize( dum, h );
return h;
306 SetMinWidth( Width() );
320 SetMinHeight( Height() );
331 SetMinSize( Width(), Height() );
339 int w, dum; GetMaxSize( w, dum );
return w;
347 int dum, h; GetMaxSize( dum, h );
return h;
365 SetMaxWidth( Width() );
379 SetMaxHeight( Height() );
390 SetMaxSize( Width(), Height() );
397 SetFixedSize( w, -1 );
404 SetFixedWidth( Width() );
411 SetFixedSize( -1, h );
418 SetFixedHeight( Height() );
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 ) );
595 EnableExpansion( !horzDisable, !vertDisable );
665 return this->
Sizer();
676 pcl::Point p1 = p; GlobalToLocal( p1.
x, p1.
y );
return p1;
687 pcl::Point p1 = p; LocalToGlobal( p1.
x, p1.
y );
return p1;
698 pcl::Point p1 = p; ParentToLocal( p1.
x, p1.
y );
return p1;
709 pcl::Point p1 = p; LocalToParent( p1.
x, p1.
y );
return p1;
720 pcl::Point p1 = p; ControlToLocal( w, p1.
x, p1.
y );
return p1;
731 pcl::Point p1 = p; LocalToControl( w, p1.
x, p1.
y );
return p1;
742 return ChildByPos( p.
x, p.
y );
779 virtual void Enable(
bool enabled =
true );
800 EnableMouseTracking( !disable );
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 );
996 void Scroll(
int dx,
int dy,
int x0,
int y0,
int x1,
int y1 );
1107 return this->
Font();
1165 SetTrackViewActive(
true );
1172 SetTrackViewActive(
false );
1191 SetRealTimePreviewActive(
true );
1198 SetRealTimePreviewActive(
false );
1248 ShowToolTip( pos.
x, pos.
y, text, control, rect );
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." )
Client-side interface to a PixInsight Control object.
void SetToolTip(const String &)
Control(Control &&)=delete
pcl::Point LocalToControl(const Control &w, const pcl::Point &p) const
pcl::Rect BoundsRect() const
void Scroll(int dx, int dy)
void SetAlternateCanvasColor(RGBA)
Control & NextSiblingToFocus() const
String WindowTitle() const
void SetFixedHeight(int h)
bool IsActiveWindow() const
void SetScaledFixedSize(int w, int h)
void SetSizer(pcl::Sizer &)
void SetFont(const pcl::Font &)
String StyleSheet() const
bool IsAncestorOf(const Control &) const
void SetBackgroundColor(RGBA)
bool IsFixedWidth() const
void SetClientRect(const pcl::Rect &r)
pcl::Point GlobalToLocal(const pcl::Point &p) const
bool IsUnderMouse() const
pcl::Sizer GetSizer() const
void DisableExpansion(bool horzDisable=true, bool vertDisable=true)
bool IsVerticalExpansionEnabled() const
bool IsTrackViewActive() const
void GetMaxSize(int &w, int &h) const
int ScaledMaxWidth() const
void LocalToControl(const Control &, int &x, int &y) const
void SetCursor(const pcl::Cursor &)
void SetWindowOpacity(double)
Control & ChildByPos(const pcl::Point &p) const
void EnableUpdates(bool enable=true)
void DisableUpdates(bool disable=true)
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 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
Control(const Control &)=delete
void Focus(bool focus=true)
void SetScaledMinSize(int w, int h)
pcl::Rect VisibleRect() const
pcl::Point ParentToLocal(const pcl::Point &p) const
void SetScaledMaxSize(int w, int h)
void SetScaledMaxHeight(int h)
void SetButtonColor(RGBA)
static void ShowToolTip(const Point &pos, const String &text, const Control &control=Control::Null(), const Rect &rect=Rect(0))
void Repaint(int x0, int y0, int x1, int y1)
void Move(const pcl::Point &p)
void LocalToGlobal(int &x, int &y) const
pcl::Point Position() const
void EnableExpansion(bool horzEnable=true, bool vertEnable=true)
void GetScaledMinSize(int &w, int &h) const
void Scroll(int dx, int dy, int x0, int y0, int x1, int y1)
void StackUnder(Control &)
void DeactivateRealTimePreview()
pcl::Font GetFont() const
void SetChildToFocus(Control &)
void ParentToLocal(int &x, int &y) const
void SetScaledFixedWidth(int w)
void SetButtonTextColor(RGBA)
pcl::Rect ClientRect() const
void SetVisible(bool visible)
void ActivateRealTimePreview()
int ScaledMinHeight() const
pcl::Point LocalToGlobal(const pcl::Point &p) const
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 LocalToParent(int &x, int &y) const
void SetRealTimePreviewActive(bool=true)
static String ToolTipText()
void SetScaledFixedHeight(int h)
pcl::Cursor Cursor() const
void SetCanvasColor(RGBA)
static void HideToolTip()
void Scroll(const pcl::Point &d)
Control & FocusedChild() const
void SetFixedSize(int w, int h)
void GetScaledMaxSize(int &w, int &h) const
void EnableMouseTracking(bool=true)
RGBA ButtonTextColor() const
pcl::Point ControlToLocal(const Control &w, const pcl::Point &p) const
RGBA HighlightedTextColor() const
void SetStyleSheet(const String &css)
void DeactivateTrackView()
void Disable(bool disabled=true)
Control & ChildToFocus() const
virtual bool IsEnabled() const
void SetFixedWidth(int w)
void SetHighlightedTextColor(RGBA)
void SetScaledMinWidth(int w)
void DisableMouseTracking(bool disable=true)
void EnsureLayoutUpdated()
RGBA ForegroundColor() const
RGBA AlternateCanvasColor() const
int ScaledMinWidth() const
void GlobalToLocal(int &x, int &y) const
void Scroll(const pcl::Point &d, const pcl::Rect &r)
double WindowOpacity() const
void EnsureUnique() override
void Resize(int w, int h)
void Update(const pcl::Rect &r)
pcl::Point LocalToParent(const pcl::Point &p) const
pcl::Rect FrameRect() const
void SetScaledMaxWidth(int w)
void Repaint(const pcl::Rect &r)
bool IsRealTimePreviewActive() const
Control(Control &parent=Null(), uint32=0)
void SetHighlightColor(RGBA)
FocusStyles FocusStyle() const
bool IsFixedHeight() const
bool IsMouseTrackingEnabled() const
void Update(int x0, int y0, int x1, int y1)
pcl::Rect ChildrenRect() const
pcl::Cursor GetCursor() const
void SetScaledMinHeight(int h)
void SetWindowTitle(const String &)
void GetMinSize(int &w, int &h) const
RGBA BackgroundColor() const
int ScaledMaxHeight() const
Client-side interface to a PixInsight Cursor object.
A type-safe collection of enumerated flags.
Client-side interface to a PixInsight Font object.
A generic point in the two-dimensional space.
component x
Abscissa (horizontal, or X-axis coordinate).
component y
Ordinate (vertical, or Y-axis coordinate).
A generic rectangle in the two-dimensional space.
component x1
Horizontal coordinate of the lower right corner.
component y1
Vertical coordinate of the lower right corner.
component y0
Vertical coordinate of the upper left corner.
component x0
Horizontal coordinate of the upper left corner.
component Width() const noexcept
component Height() const noexcept
Reduction of planetary and stellar positions.
Base class for PixInsight sizer objects.
Root base class for all user interface objects.
High-level interface to a PixInsight view object.
void(Control::*)(Control &sender, const pcl::Point &pos, const View &view, unsigned modifiers) view_drop_event_handler
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
void OnResize(resize_event_handler, Control &)
void OnLoseFocus(event_handler, Control &)
void(Control::*)(Control &sender, bool &allowClose) close_event_handler
void(Control::*)(Control &sender, const pcl::Point &pos, const View &view, unsigned modifiers, bool &wantsView) view_drag_event_handler
void(Control::*)(Control &sender, const pcl::Point &newPos, const pcl::Point &oldPos) move_event_handler
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
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
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
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
void OnViewDrop(view_drop_event_handler, Control &)
void(Control::*)(Control &sender, const pcl::Rect &updateRect) paint_event_handler
void(Control::*)(Control &sender, Control &child) child_event_handler
void(Control::*)(Control &sender, const pcl::Point &pos, const StringList &files, unsigned modifiers, bool &wantsFiles) file_drag_event_handler
void OnChildCreate(child_event_handler, Control &)
void(Control::*)(Control &sender, int key, unsigned modifiers, bool &wantsKey) keyboard_event_handler
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
void OnMouseMove(mouse_event_handler, Control &)
void OnEnter(event_handler, Control &)
void OnMove(move_event_handler, Control &)
int RoundInt(T x) noexcept
double ResourcePixelRatio() const
int LogicalPixelsToResource(int size) const
Point ScaledCursorHotSpot(const Point &hotSpot) const
String ScaledStyleSheet(S cssCode, int fontDPI=0) const
int PhysicalPixelsToLogical(int size) const
double DisplayPixelRatio() const
String UIScaledStyleSheet(double displayScalingFactor, double resourceScalingFactor, S styleSheet, int fontDPI=0)
String UIScaledResource(double scalingFactor, R resource)
int ResourcePixelsToLogical(int size) const
int LogicalPixelsToPhysical(int size) const
Point ScaledCursorHotSpot(int xHot, int yHot) const
String ScaledResource(R resource) const