Download Now

    Reference TSurfaceGraphicControl

    Declared in Codebot.Controls.pas on line 129

    TSurfaceGraphicControl is the base class for custom graphic controls which require an ISurface object
      TSurfaceGraphicControl = class(TGraphicControl, IFloatPropertyNotify)
      protected
        { Allow controls direct access to draw state }
        FDrawState: TDrawState;
        { Areas are clickable regions of a control, such as the arrow of a drop down
          button. AreaClick is invoked when an area is clicked. }
        procedure AreaClick(Area: Integer); virtual;
        { Return the number of areas }
        function GetAreaCount: Integer; virtual;
        { Return the bounds of an area }
        function GetAreaRect(Index: Integer): TRectI; virtual;
        { Return the draw state of an area }
        function GetAreaState(Index: Integer): TDrawState;
        procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
        procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
        procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
        procedure MouseEnter; override;
        procedure MouseLeave; override;
        { Add an item to the draw state }
        procedure IncludeStateItem(Item: TDrawStateItem); virtual;
        { Remove an item from the draw state }
        procedure ExcludeStateItem(Item: TDrawStateItem); virtual;
        { Float property change notification }
        procedure PropChange(Prop: PFloat); virtual;
        procedure SetParent(NewParent: TWinControl); override;
        { Create a default size }
        class function GetControlClassDefaultSize: TSize; override;
        { Update draw state when enabled is changed }
        procedure EnabledChanged; override;
        { Override ThemeAware and return true to subscribe to global theme changes }
        function ThemeAware: Boolean; virtual;
        { Invoked when the theme is changed }
        procedure ThemeChanged; virtual;
        { Paint is now final, so use Draw to access Surface }
        procedure Paint; override; final;
        { While Draw is executing Surface refers to a valid ISurface }
        procedure Draw; virtual;
        { Surface is only valid while Draw is executing }
        property Surface: ISurface read GetSurface;
        { Visual representation of the control. Is it pressed, hot, checked, etc }
        property DrawState: TDrawState read FDrawState write SetDrawState;
        { Theme name determines the styling for a control }
        property ThemeName: string read FThemeName write SetThemeName;
        { Draw event handler }
        property OnDraw: TDrawEvent read FOnDraw write FOnDraw;
        { The point where the mouse was pressed inside the control }
        property MousePoint: TPointI read FMousePoint;
      public
        { Create a new control }
        constructor Create(AOwner: TComponent); override;
        destructor Destroy; override;
      end;

    See also

    IFloatPropertyNotify in Codebot.System.pas
    ISurface in Codebot.Graphics.Types.pas
    PFloat in Codebot.System.pas
    TDrawEvent in Codebot.Graphics.pas
    TDrawState in Codebot.Graphics.Types.pas
    TDrawStateItem in Codebot.Graphics.Types.pas
    TPointI in Codebot.Graphics.Types.pas
    TRectI in Codebot.Graphics.Types.pas