And added uiControlOSVtable on Windows. We're now back to building everywhere! :D

This commit is contained in:
Pietro Gagliardi 2019-06-18 20:31:28 -04:00
parent 80ada0a06b
commit c17f854d04
11 changed files with 114 additions and 1 deletions

View File

@ -4,5 +4,9 @@
* [Initialization and the Main Loop](init-main.md)
* [Event Handling](events.md)
* [Controls](controls.md)
* Windows
** [Controls](windows-controls.md)
* Unix
** [Controls](unix-controls.md)
* macOS
** [Controls](darwin-controls.md)

View File

@ -23,4 +23,4 @@ You are responsible for allocating and initializing this struct. To do so, you s
Each method takes at least two parameters. The first, `c`, is the `uiControl` itself. The second, `implData`, is the implementation data pointer; it is the same as the pointer returned by `uiControlImplData(c)`, and is provided here as a convenience.
Each method is named for the `uiDarwinControl` function that it implements. As such, details on how to implement these methods are documented alongside those functions. For instance, instructions on implementing `TODO()` are given under the documentation for `TOOD()`.
Each method is named for the `uiDarwinControl` function that it implements. As such, details on how to implement these methods are documented alongside those functions. For instance, instructions on implementing `TODO()` are given under the documentation for `TODO()`.

26
doc/unix-controls.md Normal file
View File

@ -0,0 +1,26 @@
<!-- 10 june 2019 -->
# Controls on Unix systems other than macOS
## Overview
TODO
## Reference
### `uiControlOSVtable`
```c
typedef struct uiControlOSVtable uiControlOSVtable;
struct uiControlOSVtable {
size_t Size;
};
```
`uiControlOSVtable` describes the set of functions that control implementations on Unix need to implement. When registering your control type, you pass this in as a parameter to `uiRegisterControlType()`. Each method here is required.
You are responsible for allocating and initializing this struct. To do so, you simply zero the memory for this struct and set its `Size` field to `sizeof (uiControlOSVtable)`. (TODO put this in a common place)
Each method takes at least two parameters. The first, `c`, is the `uiControl` itself. The second, `implData`, is the implementation data pointer; it is the same as the pointer returned by `uiControlImplData(c)`, and is provided here as a convenience.
Each method is named for the `uiUnixControl` function that it implements. As such, details on how to implement these methods are documented alongside those functions. For instance, instructions on implementing `TODO()` are given under the documentation for `TODO()`.

26
doc/windows-controls.md Normal file
View File

@ -0,0 +1,26 @@
<!-- 10 june 2019 -->
# Controls on Windows
## Overview
TODO
## Reference
### `uiControlOSVtable`
```c
typedef struct uiControlOSVtable uiControlOSVtable;
struct uiControlOSVtable {
size_t Size;
};
```
`uiControlOSVtable` describes the set of functions that control implementations on Windows need to implement. When registering your control type, you pass this in as a parameter to `uiRegisterControlType()`. Each method here is required.
You are responsible for allocating and initializing this struct. To do so, you simply zero the memory for this struct and set its `Size` field to `sizeof (uiControlOSVtable)`. (TODO put this in a common place)
Each method takes at least two parameters. The first, `c`, is the `uiControl` itself. The second, `implData`, is the implementation data pointer; it is the same as the pointer returned by `uiControlImplData(c)`, and is provided here as a convenience.
Each method is named for the `uiWindowsControl` function that it implements. As such, details on how to implement these methods are documented alongside those functions. For instance, instructions on implementing `TODO()` are given under the documentation for `TODO()`.

11
test/controls_windows.c Normal file
View File

@ -0,0 +1,11 @@
// 10 june 2019
#include "test_windows.h"
static const uiControlOSVtable vtable = {
.Size = sizeof (uiControlOSVtable),
};
const uiControlOSVtable *testOSVtable(void)
{
return &vtable;
}

View File

@ -0,0 +1,17 @@
// 16 june 2019
#include "test_windows.h"
const struct checkErrorCase controlOSVtableCases[] = {
{
"uiRegisterControlType() with OS vtable with wrong size",
[](void) {
uiControlOSVtable vtable;
memset(&vtable, 0, sizeof (uiControlOSVtable));
vtable.Size = 1;
uiRegisterControlType("name", testVtable(), &vtable, 0);
},
"uiRegisterControlType(): wrong size 1 for uiControlOSVtable",
},
{ NULL, NULL, NULL },
};

View File

@ -14,6 +14,7 @@ libui_test_sources = [
if libui_OS == 'windows'
libui_test_sources += [
'controls_windows.c',
'controls_windows_errors.cpp',
]
elif libui_OS == 'darwin'
libui_test_sources += [

3
test/test_windows.h Normal file
View File

@ -0,0 +1,3 @@
// 10 june 2019
#define libuiOSHeader "../ui_windows.h"
#include "test.h"

View File

@ -11,6 +11,10 @@ This file assumes that you have included <windows.h> and "ui.h" beforehand. It p
extern "C" {
#endif
struct uiControlOSVtable {
size_t Size;
};
#ifdef __cplusplus
}
#endif

20
windows/controls.cpp Normal file
View File

@ -0,0 +1,20 @@
// 8 june 2019
#include "uipriv_windows.hpp"
bool uiprivOSVtableValid(const uiControlOSVtable *osVtable, const char *func)
{
if (osVtable->Size != sizeof (uiControlOSVtable)) {
uiprivProgrammerErrorWrongStructSize(osVtable->Size, "uiControlOSVtable", func);
return false;
}
return true;
}
uiControlOSVtable *uiprivCloneOSVtable(const uiControlOSVtable *osVtable)
{
uiControlOSVtable *v2;
v2 = uiprivNew(uiControlOSVtable);
*v2 = *osVtable;
return v2;
}

View File

@ -3,6 +3,7 @@
windows = import('windows')
libui_sources += [
'windows/controls.cpp',
'windows/main.cpp',
'windows/utilwin.cpp',
'windows/winhresult.cpp',