blob: 4375189152cd363034746b12f1aa91902b7399c2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
|
/* -------------------------------------------
Copyright Mahrouss Logic
File: Core.hxx
Purpose:
Revision History:
31/01/24: Added file (amlel)
08/02/24: Update Form to GForm. (amlel)
------------------------------------------- */
#pragma once
#include <CompilerKit/CompilerKit.hxx>
#include <NewKit/Array.hpp>
#include <NewKit/Defines.hpp>
#include <NewKit/Ref.hpp>
#include <NewKit/String.hpp>
#define $() HCore::GApplication::Shared()->Document()
#ifndef __EXPORT_LIB
#define G_API __attribute__((pef_container(".IMPORT")))
#else
#define G_API __attribute__((pef_container(".EXPORT")))
#endif // ifdef __EXPORT_LIB
namespace System::Graphics {
template <typename... T>
class GAction;
class GString;
class GNumber;
class GVector2;
class GBoolean;
class GDocument;
class GApplication;
class GFrame;
class G_API GBoolean {
private:
explicit GBoolean() : m_Value(false) {}
HCore::Boolean m_Value;
friend class GForm;
public:
static const GBoolean Construct(HCore::StringView& sw, HCore::Boolean value) {
GBoolean boolean;
boolean.m_Value = value;
return boolean;
}
};
template <typename... T>
class G_API GAction {
explicit GAction(HCore::StringView& sw) { m_Name = sw; }
HCore::StringView m_Name;
void (*m_Action)(T&&... args);
friend class GForm;
public:
static const GAction Construct(HCore::StringView& sw,
void (*action)(T&&... args)) {
GAction actcls{sw};
actcls.m_Action = action;
return actcls;
}
};
class G_API GVector2 {
explicit GVector2(HCore::StringView& sw) : m_Vec2() {}
HCore::Array<HCore::Int, 3> m_Vec2;
friend class GForm;
public:
static const GVector2 Construct(HCore::StringView& sw,
HCore::Array<HCore::Int, 3>& vec2) {
GVector2 vec{sw};
vec.m_Vec2 = vec2;
return vec;
}
};
class G_API GNumber {
HCore::Int m_Number{0};
friend class GForm;
public:
static const GNumber Construct(HCore::Int& number) {
GNumber num;
num.m_Number = number;
return num;
}
};
class G_API GString {
explicit GString(HCore::StringView& content) {
m_Content = new HCore::StringView();
*m_Content = content;
}
HCore::StringView* m_Content;
friend class GForm;
public:
static const GString Construct(HCore::StringView& value) {
GString str{value};
return str;
}
};
class G_API GApplication final {
public:
explicit GApplication() = default;
~GApplication() = default;
HCORE_COPY_DEFAULT(GApplication);
GDocument* Document() noexcept { return nullptr; }
static GApplication* Shared() noexcept {
STATIC GApplication* kApp = nullptr;
if (!kApp) kApp = new GApplication();
return kApp;
}
};
class G_API GDocument final {
public:
explicit GDocument(HCore::StringView& sv) : mString(GString::Construct(sv)) {}
~GDocument() = default;
HCORE_COPY_DEFAULT(GDocument);
GFrame** GetAddressOf() noexcept { return &mFrame; }
GFrame* Get() noexcept { return mFrame; }
GString& Name() { return mString; }
private:
GFrame* mFrame{nullptr};
GString mString;
};
class GException final {
public:
explicit GException() = default;
~GException() = default;
public:
HCORE_COPY_DEFAULT(GException);
public:
const char* Name() { return "User Interface error."; }
const char* Reason() { return mReason; }
private:
const char* mReason{"System.Graphics: User Interface error. Check HError."};
};
template <typename GFrameType, typename GFrameBase>
inline GFrameType* frame_cast(GFrameBase* Frame) {
if (!dynamic_cast<GFrameType*>(Frame)) {
throw GException();
}
return dynamic_cast<GFrameType*>(Frame);
}
} // namespace System::Graphics
|