diff options
| author | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-06 09:14:11 +0100 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal.elmahrouss@icloud.com> | 2024-01-06 09:14:11 +0100 |
| commit | 5339d016c07bf717ee388f4feb73544087324af0 (patch) | |
| tree | 94be6f67ed626091f24aee24ec3b3be03d01e4e7 /Seeker | |
git: port from mercurial repo.
Signed-off-by: Amlal El Mahrouss <amlal.elmahrouss@icloud.com>
Diffstat (limited to 'Seeker')
| -rw-r--r-- | Seeker/Seeker.hxx | 171 | ||||
| -rw-r--r-- | Seeker/SeekerAbout.cxx | 16 | ||||
| -rw-r--r-- | Seeker/SeekerAssert.cxx | 20 | ||||
| -rw-r--r-- | Seeker/SeekerDriver.cxx | 29 | ||||
| -rw-r--r-- | Seeker/SeekerFileWnd.cxx | 54 | ||||
| -rw-r--r-- | Seeker/SeekerSubsystemStart.cxx | 30 |
6 files changed, 320 insertions, 0 deletions
diff --git a/Seeker/Seeker.hxx b/Seeker/Seeker.hxx new file mode 100644 index 00000000..9a180b88 --- /dev/null +++ b/Seeker/Seeker.hxx @@ -0,0 +1,171 @@ +/* + * ======================================================== + * + * hCore + * Copyright Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +#ifndef __SEEKER__ +#define __SEEKER__ + +#include <CompilerKit/Compiler.hpp> + +/* @brief Seeker SDK. */ +/* Seeker helps with GUI developement. */ + +enum +{ + kRegularFile, + kDirectory, + kJunctionFile, + kNetworkFile, + kNetworkDirectory, + kNetworkJunction, + kDrive, + kDevice, +}; + +enum +{ + kHardDrv = 'hardv', + kOpticalDrv = 'optic', + kUsbDrv = 'usbdr', +}; + +enum +{ + kLangUs = 'lanus', + kLangUk = 'lanuk', + kLangFr = 'lanfr', + kLangNl = 'lannl', +}; + +#define kResourceExt ".rsc" +#define kExecutableExt ".exe" +#define kLibExt ".lib" +#define kShLibExt ".dlib" + +typedef void Void; +typedef void* VoidPtr; + +typedef wchar_t WideChar; +typedef wchar_t* WideCString; + +typedef __SIZE_TYPE__ SizeT; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +struct SeekerProtocol; + +// @brief Opens a Seeker window. +extern "C" VoidPtr SeekerOpenExplorer(const WideCString startCategory); + +// @brief Closes a Seeker window. +extern "C" Void SeekerCloseExplorer(VoidPtr handle); + +// @brief Make Seeker connect to endpoint. +extern "C" Void SeekerExplorerConnectToNetwork(VoidPtr handle, + const WideCString endpoint, + struct SeekerProtocol* proto); + +extern "C" Void SeekerExplorerChangeTo(VoidPtr handle, + const WideCString nodeName); + +// @brief Search for elements inside directory/drive +// returns a class list as voidstar. +extern "C" VoidPtr SeekerSearch(VoidPtr handle, + const WideCString where, + const WideCString forWhat); + +#define kProtocolStrLen 8 + +// @brief Seeker Location Protocol. +// @brief takes a handler class to handle server response. +struct SeekerProtocol +{ + WideChar fProtocol[kProtocolStrLen]; // ftp, sftp, http + VoidPtr fProtocolHandlerClass; + SizeT fProtocolHandlerClassSize; +}; + +//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +typedef void(*WndProcType)(int msg, VoidPtr lparam, VoidPtr wparam); + +extern "C" bool WindowClassCreate(const WideCString name, VoidPtr windowStruct, SizeT windowStructSz); +extern "C" VoidPtr WindowCreate(const WideCString name, const WideCString wndClass, VoidPtr parent); +extern "C" Void WindowFieldSet(const VoidPtr win, const WideCString key, const WideCString value); +extern "C" Void WindowFree(VoidPtr win); +extern "C" Void WindowProcSet(VoidPtr win, void(*winproc)(int msg, VoidPtr lparam, VoidPtr wparam)); +extern "C" Void WindowFreeClass(VoidPtr classPtr); + +// passing nullptr will give a console to the desktop. +extern "C" Void OpenConsole(VoidPtr handle); +extern "C" Void CloseConsole(VoidPtr handle); + +// Runtime functions +extern "C" void RtInitTerm(void); +extern "C" bool RtIsValidHeapPtr(VoidPtr heap); +extern "C" Void RtDialogAssert(const bool expr, const wchar_t* file, const wchar_t* expression); +extern "C" Void RtShellOpen(const WideCString path, int argc, const WideCString* argv); + +#define __WideExpr(x) L##x +#define RtWideString(x) __WideExpr(x) + +#define RtAssert(expr) RtDialogAssert(expr, RtWideString(__FILE__), RtWideString(#expr)) + +typedef VoidPtr HandlePtr; +typedef HandlePtr IdPtr; + +///////////////////////////////////////////////////// + +HandlePtr SeekerAboutDlg(Void); + +#define FINDER_YES L"Yes" +#define FINDER_NO L"No" + +#define kAssertInterrupt "sc $1" + +extern "C" Void QuickDrawRect(float x, float y, + float r, float g, float b, + float w, float h, float strike, + float radius); + +extern "C" Void QuickDrawPattern(float x, float y, + float* pattern, size_t sz, + float w, float h, float strike, + float radius); + +// @brief a C++ class. +typedef VoidPtr SeekerClassPtr; + +typedef struct +{ + float x, y; + float w, h; +} TAreaType; + +///////////////////////////////////////////////////// + +namespace Seeker +{ + class TControl + { + public: + explicit TControl() = default; + virtual ~TControl() = default; + + HCORE_COPY_DEFAULT(TControl); + + public: + virtual void Draw() noexcept = 0; + + public: + TAreaType fVisibleArea; + TAreaType fFullArea; + + }; +} +#endif /* ifndef __SEEKER__ */
\ No newline at end of file diff --git a/Seeker/SeekerAbout.cxx b/Seeker/SeekerAbout.cxx new file mode 100644 index 00000000..bf6add9f --- /dev/null +++ b/Seeker/SeekerAbout.cxx @@ -0,0 +1,16 @@ +/* + * ======================================================== + * + * hCore + * Copyright Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +#include <Seeker/Seeker.hxx> + +HandlePtr SeekerAboutDlg(Void) +{ + HandlePtr windowHandle = WindowCreate(L"hCore", L"OSAboutDialog", nullptr); + return windowHandle; +}
\ No newline at end of file diff --git a/Seeker/SeekerAssert.cxx b/Seeker/SeekerAssert.cxx new file mode 100644 index 00000000..ad18ee19 --- /dev/null +++ b/Seeker/SeekerAssert.cxx @@ -0,0 +1,20 @@ +/* + * ======================================================== + * + * hCore + * Copyright Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +#include <Seeker/Seeker.hxx> + +extern "C" Void RtDialogAssert(const bool expr, const wchar_t* file, const wchar_t* expression) +{ + auto handle = WindowCreate(L"Assertion failed!", L"OSWndAssert", nullptr); + + WindowFieldSet(handle, L"Title", L"Assertion failed!"); + WindowFieldSet(handle, L"ButtonClicked_OK", L"Abort"); + + asm (kAssertInterrupt); +}
\ No newline at end of file diff --git a/Seeker/SeekerDriver.cxx b/Seeker/SeekerDriver.cxx new file mode 100644 index 00000000..b6b7c69f --- /dev/null +++ b/Seeker/SeekerDriver.cxx @@ -0,0 +1,29 @@ +/* + * ======================================================== + * + * hCore + * Copyright Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +#include <Seeker/Seeker.hxx> + +extern "C" Void DrawDesktopService(Void); +extern "C" Void DrawWindowService(Void); +extern "C" Void DrawMenuService(Void); +extern "C" Void DrawDialogService(Void); + +extern "C" Void PumpMessageService(Void); + +extern "C" bool SeekerShutdownRequest(Void); + +// @brief each app must call this for their region, otherwise it'll show a black rectangle. +extern "C" Void SeekerMessageLoop(Void) +{ + DrawDesktopService(); + DrawMenuService(); + DrawWindowService(); + DrawDialogService(); + PumpMessageService(); +} diff --git a/Seeker/SeekerFileWnd.cxx b/Seeker/SeekerFileWnd.cxx new file mode 100644 index 00000000..46692b32 --- /dev/null +++ b/Seeker/SeekerFileWnd.cxx @@ -0,0 +1,54 @@ +/* + * ======================================================== + * + * hCore + * Copyright Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +#include <Seeker/Seeker.hxx> + +// Source code of the Seeker Window. + +// @brief Opens a Seeker window. +extern "C" VoidPtr SeekerOpenExplorer(const WideCString startCategory) +{ + auto win = WindowCreate(L"Seeker", L"OSSeekerWnd", nullptr); + + if (win) + { + WindowFieldSet(win, L"Category", startCategory); + WindowFieldSet(win, L"CanClose", FINDER_NO); + WindowFieldSet(win, L"ClosePolicy", L"Restart"); + + return win; + } + + RtAssert(win != nullptr); + + return nullptr; +} + +// @brief Closes a Seeker window. +extern "C" Void SeekerCloseExplorer(VoidPtr handle) +{ + if (RtIsValidHeapPtr(handle)) + { + WindowFree(handle); + } +} + +extern "C" Void SeekerExplorerConnectToNetwork(VoidPtr handle, + const WideCString endpoint, + struct SeekerProtocol* proto) +{ + if (handle) + { + WindowFieldSet(handle, L"NetworkProtocolEndpoint", endpoint); + WindowFieldSet(handle, L"NetworkProtocolClass", (wchar_t*)proto->fProtocolHandlerClass); + WindowFieldSet(handle, L"NetworkProtocolClassSize", (wchar_t*)proto->fProtocolHandlerClassSize); + + WindowFieldSet(handle, L"NetworkProtocolFire", FINDER_YES); + } +}
\ No newline at end of file diff --git a/Seeker/SeekerSubsystemStart.cxx b/Seeker/SeekerSubsystemStart.cxx new file mode 100644 index 00000000..c694abbd --- /dev/null +++ b/Seeker/SeekerSubsystemStart.cxx @@ -0,0 +1,30 @@ +/* + * ======================================================== + * + * hCore + * Copyright Mahrouss Logic, all rights reserved. + * + * ======================================================== + */ + +#include <Seeker/Seeker.hxx> + +extern "C" Void __InitCxxGlobals(Void); +extern "C" Void __InitCommonCtrls(Void); +extern "C" Void __InitSeekerCtrls(Void); +extern "C" char** __InitArgs(int* argc); + +extern "C" Void __InvokeMain(int argc, char** argv); + +/* @brief As requested by PEF. */ +extern "C" Void __start(Void) +{ + __InitCxxGlobals(); + __InitSeekerCtrls(); + __InitCommonCtrls(); + + int argc = 0; + auto argv = __InitArgs(&argc); + + __InvokeMain(argc, argv); +}
\ No newline at end of file |
