summaryrefslogtreecommitdiffhomepage
path: root/dev/ZKA/Modules/CoreCG/WindowRenderer.hxx
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-08-24 10:47:51 +0200
committerAmlal El Mahrouss <amlal.elmahrouss@icloud.com>2024-08-24 10:52:24 +0200
commitae87ff9f949a71a398b4355fe9074c0531de34ba (patch)
tree9ea55b396abbfcc699edcc9afb9a964145236129 /dev/ZKA/Modules/CoreCG/WindowRenderer.hxx
parent4185fcc698e237225902646736c6b23f6b5e54be (diff)
[IMP] CoreCG's User Interface Kit, this is a driver/kernel library only.
+ Reserved for pre-boot/boot operations, before user mode jump. Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'dev/ZKA/Modules/CoreCG/WindowRenderer.hxx')
-rw-r--r--dev/ZKA/Modules/CoreCG/WindowRenderer.hxx152
1 files changed, 152 insertions, 0 deletions
diff --git a/dev/ZKA/Modules/CoreCG/WindowRenderer.hxx b/dev/ZKA/Modules/CoreCG/WindowRenderer.hxx
new file mode 100644
index 00000000..a1aadf8a
--- /dev/null
+++ b/dev/ZKA/Modules/CoreCG/WindowRenderer.hxx
@@ -0,0 +1,152 @@
+/* -------------------------------------------
+
+ Copyright ZKA Technologies.
+
+------------------------------------------- */
+
+#pragma once
+
+#include <Modules/CoreCG/Accessibility.hxx>
+#include <KernelKit/Heap.hxx>
+#include <KernelKit/ProcessScheduler.hxx>
+#include <KernelKit/LPC.hxx>
+#include <NewKit/Defines.hxx>
+#include <NewKit/Utils.hxx>
+#include <Modules/CoreCG/FbRenderer.hxx>
+#include <Modules/CoreCG/Rsrc/WndControls.rsrc>
+#include <Modules/CoreCG/TextRenderer.hxx>
+
+namespace CG
+{
+ using namespace Kernel;
+
+ enum
+ {
+ cWndFlagNoShow = 0x04,
+ };
+
+ struct CG_WINDOW
+ {
+ Int32 w_flags{0};
+ Char w_window_name[255]{0};
+ Char w_class_name[255]{0};
+ Int32 w_x{0};
+ Int32 w_y{0};
+ Int32 w_w{0};
+ Int32 w_h{0};
+ UInt32* display_ptr{nullptr};
+ Bool w_needs_repaint{false};
+ };
+
+ typedef struct CG_WINDOW CG_WINDOW;
+
+ inline struct CG_WINDOW* CGCreateWindow(Int32 flags, const Char* window_name, const Char* class_name, Int32 x, Int32 y, Int32 width, Int32 height)
+ {
+ const auto cMaxLimit = 214;
+
+ if (width < cMaxLimit ||
+ height < cMaxLimit)
+ {
+ ErrLocal() = kErrorInvalidData;
+ return nullptr;
+ }
+
+ CG_WINDOW* wnd = new CG_WINDOW();
+
+ if (!wnd)
+ {
+ ErrLocal() = kErrorHeapOutOfMemory;
+ return nullptr;
+ }
+
+ rt_copy_memory((VoidPtr)window_name, wnd->w_window_name, rt_string_len(window_name));
+ rt_copy_memory((VoidPtr)class_name, wnd->w_class_name, rt_string_len(class_name));
+
+ wnd->w_flags = flags;
+ wnd->w_x = x;
+ wnd->w_y = y;
+
+ wnd->w_w = width;
+ wnd->w_h = height;
+
+ wnd->display_ptr = new UInt32[width * height];
+ rt_set_memory(wnd->display_ptr, CGColor(0xF5, 0xF5, 0xF5), width * height);
+
+ return wnd;
+ }
+
+ inline bool CGDestroyWindow(struct CG_WINDOW* wnd)
+ {
+ if (wnd)
+ {
+ delete wnd;
+
+ if (!mm_is_valid_heap(wnd))
+ {
+ wnd = nullptr;
+ return true;
+ }
+
+ wnd = nullptr;
+ }
+
+ return false;
+ }
+
+ inline SizeT CGDrawWindowList(CG_WINDOW** wnd, SizeT wnd_cnt)
+ {
+ if (wnd_cnt == 0 ||
+ !wnd)
+ return 0;
+
+ SizeT cnt = 0;
+
+ for (SizeT index = 0; index < wnd_cnt; ++index)
+ {
+ if (!wnd[index] ||
+ wnd[index]->w_flags & cWndFlagNoShow ||
+ !wnd[index]->w_needs_repaint)
+ continue;
+
+ wnd[index]->w_needs_repaint = false;
+
+ if (UIAccessibilty::The().Width() < wnd[index]->w_x)
+ {
+ if ((wnd[index]->w_x - UIAccessibilty::The().Width()) > 1)
+ {
+ wnd[index]->w_x -= wnd[index]->w_x - UIAccessibilty::The().Width();
+ }
+ else
+ {
+ wnd[index]->w_x = 0;
+ }
+ }
+
+ if (UIAccessibilty::The().Height() < wnd[index]->w_y)
+ {
+ if ((wnd[index]->w_y - UIAccessibilty::The().Height()) > 1)
+ {
+ wnd[index]->w_y -= wnd[index]->w_y - UIAccessibilty::The().Width();
+ }
+ else
+ {
+ wnd[index]->w_y = 0;
+ }
+ }
+
+ ++cnt;
+
+ CGInit();
+
+ CGDrawBitMapInRegionA(wnd[index]->display_ptr, wnd[index]->w_h, wnd[index]->w_w, wnd[index]->w_y, wnd[index]->w_x);
+ CGDrawInRegion(CGColor(0xFF, 0xFF, 0xFF), wnd[index]->w_w, FLATCONTROLS_HEIGHT, wnd[index]->w_y, wnd[index]->w_x);
+ CGDrawBitMapInRegion(FlatControls, FLATCONTROLS_HEIGHT, FLATCONTROLS_WIDTH, wnd[index]->w_y, wnd[index]->w_x+wnd[index]->w_w-FLATCONTROLS_WIDTH);
+
+ cg_write_text(wnd[index]->w_window_name, wnd[index]->w_y + 8, wnd[index]->w_x + 8, CGColor(0x00, 0x00, 0x00));
+
+ CGFini();
+ }
+
+ return cnt;
+ }
+} // namespace CG