Clapkit
Loading...
Searching...
No Matches
ckControl.h
Go to the documentation of this file.
1/*
2 *
3 * Clapkit
4 * ----------------------------------------------------------------------
5 * A wrapper for creating a 'generalized' app for Classic MacOS
6 * that (hopefully) can be ported easily to other platforms.
7 *
8 * CKControl
9 * ----------------------------------------------------------------------
10 * The base of everything UI Control we have.
11 *
12 */
13
14#pragma once
15
16#include "ckApp.h"
17#include "ckObject.h"
18#include "ckProperty.h"
19#include <functional>
20
21class CKWindow;
22
28 public:
32 const char* title = 0;
33
37 int x = 0;
38
42 int y = 0;
43
47 int width = 100;
48
52 int height = 50;
58 CKControlInitParams(const char* t, CKRect r) {
59 title = t;
60 x = r.origin->x;
61 y = r.origin->y;
62 width = r.size->width;
63 height = r.size->height;
64 }
70 x = r.origin->x;
71 y = r.origin->y;
72 width = r.size->width;
73 height = r.size->height;
74 }
83};
84
89class CKControl : public CKObject {
90
91 public:
93 virtual ~CKControl();
94 virtual void AddedToWindow(CKWindow* window);
95 virtual void RemovedFromWindow();
96 virtual void MarkAsDirty();
97 virtual void RaisePropertyChange(const char* propertyName);
98
99 protected:
100 friend class CKWindow;
101 virtual void Redraw();
102
103 public:
108
109 private:
110 CKRect __lastRect = CKRect(0, 0, 0, 0);
111};
Defines the base of all UI Controls.
Definition ckControl.h:89
virtual void RaisePropertyChange(const char *propertyName)
Definition ckControl.cpp:88
CKProperty< bool > visible
Definition ckControl.h:107
CKProperty< bool > enabled
Definition ckControl.h:106
virtual void MarkAsDirty()
Definition ckControl.cpp:77
CKProperty< CKRect > rect
Definition ckControl.h:105
virtual void RemovedFromWindow()
Definition ckControl.cpp:57
virtual ~CKControl()
Definition ckControl.cpp:31
virtual void AddedToWindow(CKWindow *window)
Definition ckControl.cpp:45
virtual void Redraw()
Definition ckControl.cpp:69
CKProperty< CKWindow * > owner
Definition ckControl.h:104
Defines the base class for all controls and objects.
Definition ckObject.h:43
Defines an observable value.
Definition ckProperty.h:60
Defines a window. Window type (modal, document) is determined by CKWindowInitParams and CKWindowType.
Definition ckWindow.h:89
CKControlType
Defines a control type (i.e. PushButton, Checkbox, etc.)
Definition ckTypes.h:51
Initialization parameters for a CKControl.
Definition ckControl.h:27
int y
Position (Y) of the control. Should be > 0.
Definition ckControl.h:42
CKControlInitParams(const char *t, CKRect r)
Create a control with a text and a size & position.
Definition ckControl.h:58
int width
Width of the control. Must be > 0.
Definition ckControl.h:47
int x
Position (X) of the control. Should be > 0.
Definition ckControl.h:37
CKControlInitParams(CKRect r)
Create a control with a size & position.
Definition ckControl.h:69
int height
Height of the control. Must be > 0. See kCKButtonHeight, kCKCheckboxHeight, etc.
Definition ckControl.h:52
const char * title
Text to be used for window title or control text, if applicable.
Definition ckControl.h:32
CKControlInitParams(CKSize s)
Create a control with a size.
Definition ckControl.h:79
Defines a rectangular area at a specific location.
Definition ckTypes.h:227
CKProperty< CKPoint > origin
Definition ckTypes.h:229
CKProperty< CKSize > size
Definition ckTypes.h:230
Defines a rectangular area.
Definition ckTypes.h:179
CKProperty< int > width
Definition ckTypes.h:181
CKProperty< int > height
Definition ckTypes.h:182