Clapkit
Loading...
Searching...
No Matches
CKWindow Class Reference

Defines a window. Window type (modal, document) is determined by CKWindowInitParams and CKWindowType. More...

#include <ckWindow.h>

Inheritance diagram for CKWindow:
CKObject

Public Member Functions

 CKWindow (CKWindowInitParams params)
 
virtual ~CKWindow ()
 
void Loop ()
 Called from CKApp to do stuff like blinking the caret, etc.
 
void SetTitle (const char *title)
 
char * GetTitle ()
 
void Show ()
 
void Hide ()
 
void Focus ()
 Make the window foremost window. Make visible if invisible.
 
void Center ()
 
void Close ()
 
bool AddControl (CKControl *control)
 
void RemoveControl (CKControl *control, bool free)
 
void Redraw (CKRect rectToRedraw)
 
void SetOwner (CKApp *owner)
 
CKAppGetOwner ()
 Return the app this window is a part of.
 
CKControlFindControl (CKPoint point)
 
const std::vector< CKControl * > & GetControls () const
 Get the list of controls in this window.
 
template<typename T >
std::vector< T * > GetControlsOfType () const
 Get the list of controls of type T in this window.
 
bool ContainsControl (CKControl *control)
 
CKFocusableControlGetActiveControl ()
 Called by ckApp to determine UI Changes needed, like enabling/disabling menu items.
 
void SetActiveControl (CKControl *control)
 Called by ckApp on a click event - to set the active control (like a textfield.)
 
virtual bool HandleEvent (const CKEvent &evt)
 
CKControlGetLastControl () const
 
void SetLastControl (CKControl *control)
 
const CKWindowPtr GetWindowPtr () const
 
void DirtyArea (const CKRect r)
 
bool GetIsActive ()
 
- Public Member Functions inherited from CKObject
 CKObject ()
 
virtual ~CKObject ()
 
virtual void AddHandler (CKEventType type, CKEventHandlerFunc cb)
 
virtual void RemoveHandler (CKEventType type)
 
virtual bool HasHandler (CKEventType type) const
 
virtual void SetPropertyObserver (CKPropertyObserverFunc cb)
 
virtual void UnsetPropertyObserver ()
 

Public Attributes

CKProperty< CKRectrect
 
CKProperty< bool > visible
 
CKProperty< bool > hasCustomBackgroundColor
 
CKProperty< CKColorbackgroundColor = CKColor(255, 255, 255)
 
CKProperty< bool > closable = true
 
int minimumWidth = 0
 
int minimumHeight = 0
 
int maximumWidth = 1000
 
int maximumHeight = 1000
 
bool shouldReceiveMouseMoveEvents
 True if we should receive mouseMove events. We are storing this as a hack to speed things up as HasHandler is pretty slow.
 

Protected Member Functions

void SetIsActive (bool active)
 
void __ReflectToOS ()
 
virtual void RaisePropertyChange (const char *propertyName)
 

Friends

class CKApp
 

Additional Inherited Members

- Protected Attributes inherited from CKObject
std::map< CKEventType, CKEventHandlerFunc__handlers
 
CKPropertyObserverFunc propertyObserverCB = nullptr
 

Detailed Description

Defines a window. Window type (modal, document) is determined by CKWindowInitParams and CKWindowType.

Constructor & Destructor Documentation

◆ CKWindow()

CKWindow::CKWindow ( CKWindowInitParams  params)

Create a new window with the parameters passed. Check the CKWindowInitParams object for required/optional parameters.

◆ ~CKWindow()

CKWindow::~CKWindow ( )
virtual

Member Function Documentation

◆ __ReflectToOS()

void CKWindow::__ReflectToOS ( )
protected

◆ AddControl()

bool CKWindow::AddControl ( CKControl control)

Add control to the window. Control must NOT be already in another window, or this fails. Returns false if fails (i.e. control already exists)

◆ Center()

void CKWindow::Center ( )

Center the window on screen.

◆ Close()

void CKWindow::Close ( )

Override to stop closage.

◆ ContainsControl()

bool CKWindow::ContainsControl ( CKControl control)

True if we have the control here.

◆ DirtyArea()

void CKWindow::DirtyArea ( const CKRect  r)

◆ FindControl()

CKControl * CKWindow::FindControl ( CKPoint  point)

Try to find a control at the point. Returns nil if nothing is at that point. Due to the way it works, undefined behavior when two controls overlap (so don't do that, perhaps.)

CKPoint passed here MUST be local to the window.

◆ Focus()

void CKWindow::Focus ( )

Make the window foremost window. Make visible if invisible.

◆ GetActiveControl()

CKFocusableControl * CKWindow::GetActiveControl ( )

Called by ckApp to determine UI Changes needed, like enabling/disabling menu items.

Returns

◆ GetControls()

const std::vector< CKControl * > & CKWindow::GetControls ( ) const

Get the list of controls in this window.

Returns

◆ GetControlsOfType()

template<typename T >
std::vector< T * > CKWindow::GetControlsOfType ( ) const
inline

Get the list of controls of type T in this window.

auto buttons = myWindow->GetControlsOfType<CKButton>();
Defines a push button.
Definition ckButton.h:23
Returns

◆ GetIsActive()

bool CKWindow::GetIsActive ( )

◆ GetLastControl()

CKControl * CKWindow::GetLastControl ( ) const

◆ GetOwner()

CKApp * CKWindow::GetOwner ( )

Return the app this window is a part of.

◆ GetTitle()

char * CKWindow::GetTitle ( )

Get the window's title.

◆ GetWindowPtr()

const CKWindowPtr CKWindow::GetWindowPtr ( ) const

◆ HandleEvent()

bool CKWindow::HandleEvent ( const CKEvent evt)
virtual

Called by CKApp when the user interacts with our control. Override for custom controls.

Returns true if handled.

Reimplemented from CKObject.

◆ Hide()

void CKWindow::Hide ( )

Hide the window, but keep in memory.

◆ Loop()

void CKWindow::Loop ( )

Called from CKApp to do stuff like blinking the caret, etc.

◆ RaisePropertyChange()

void CKWindow::RaisePropertyChange ( const char *  propertyName)
protectedvirtual

Reimplemented from CKObject.

◆ Redraw()

void CKWindow::Redraw ( CKRect  rectToRedraw)

Redraw part(s) of the window.

◆ RemoveControl()

void CKWindow::RemoveControl ( CKControl control,
bool  free 
)

Remove control from the window. Does nothing if the control is already not there.

◆ SetActiveControl()

void CKWindow::SetActiveControl ( CKControl control)

Called by ckApp on a click event - to set the active control (like a textfield.)

Parameters
controlCan be nil.

◆ SetIsActive()

void CKWindow::SetIsActive ( bool  active)
protected

Called when the window becomes active/inactive.

◆ SetLastControl()

void CKWindow::SetLastControl ( CKControl control)

◆ SetOwner()

void CKWindow::SetOwner ( CKApp owner)

Set the owner – if this is set to nil, we won't be able to do much.

◆ SetTitle()

void CKWindow::SetTitle ( const char *  title)

Change the window's title.

◆ Show()

void CKWindow::Show ( )

Friends And Related Symbol Documentation

◆ CKApp

friend class CKApp
friend

Member Data Documentation

◆ backgroundColor

CKProperty<CKColor> CKWindow::backgroundColor = CKColor(255, 255, 255)

◆ closable

CKProperty<bool> CKWindow::closable = true

◆ hasCustomBackgroundColor

CKProperty<bool> CKWindow::hasCustomBackgroundColor

◆ maximumHeight

int CKWindow::maximumHeight = 1000

◆ maximumWidth

int CKWindow::maximumWidth = 1000

◆ minimumHeight

int CKWindow::minimumHeight = 0

◆ minimumWidth

int CKWindow::minimumWidth = 0

◆ rect

CKProperty<CKRect> CKWindow::rect

◆ shouldReceiveMouseMoveEvents

bool CKWindow::shouldReceiveMouseMoveEvents

True if we should receive mouseMove events. We are storing this as a hack to speed things up as HasHandler is pretty slow.

◆ visible

CKProperty<bool> CKWindow::visible

The documentation for this class was generated from the following files: