More boilerplate. Okay, now we can get to the good stuff: the controls!
This commit is contained in:
parent
f93d9a4c91
commit
3d9aa4ce9a
|
@ -0,0 +1,46 @@
|
||||||
|
// 16 august 2015
|
||||||
|
#include "uipriv_wpf.hpp"
|
||||||
|
|
||||||
|
static uintmax_t type_uiWindowsControl = 0;
|
||||||
|
|
||||||
|
uintmax_t uiWindowsControlType(void)
|
||||||
|
{
|
||||||
|
if (type_uiWindowsControl == 0)
|
||||||
|
type_uiWindowsControl = uiRegisterType("uiWindowsControl", uiControlType(), sizeof (uiWindowsControl));
|
||||||
|
return type_uiWindowsControl;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Control ^genericHandle(uiControl *c)
|
||||||
|
{
|
||||||
|
gcroot<Control ^> *h;
|
||||||
|
|
||||||
|
h = (gcroot<Control ^> *) uiControlHandle(c);
|
||||||
|
return *h;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void defaultCommitShow(uiControl *c)
|
||||||
|
{
|
||||||
|
genericHandle(c)->Visibility = Visibility::Visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void defaultCommitHide(uiControl *c)
|
||||||
|
{
|
||||||
|
// TODO formally document this behavior (it's how GTK+ works)
|
||||||
|
genericHandle(c)->Visibility = Visibility::Collapsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
void osCommitEnable(uiControl *c)
|
||||||
|
{
|
||||||
|
genericHandle(c)->IsEnabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void osCommitDisable(uiControl *c)
|
||||||
|
{
|
||||||
|
genericHandle(c)->IsEnabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void uiWindowsFinishControl(uiControl *c)
|
||||||
|
{
|
||||||
|
c->CommitShow = defaultCommitShow;
|
||||||
|
c->CommitHide = defaultCommitHide;
|
||||||
|
}
|
|
@ -11,6 +11,9 @@
|
||||||
|
|
||||||
static const char *initerr(const char *message, const WCHAR *label, DWORD value)
|
static const char *initerr(const char *message, const WCHAR *label, DWORD value)
|
||||||
{
|
{
|
||||||
|
// TODO
|
||||||
|
return "";
|
||||||
|
#if 0
|
||||||
WCHAR *sysmsg;
|
WCHAR *sysmsg;
|
||||||
BOOL hassysmsg;
|
BOOL hassysmsg;
|
||||||
WCHAR *beforele;
|
WCHAR *beforele;
|
||||||
|
@ -41,6 +44,7 @@ static const char *initerr(const char *message, const WCHAR *label, DWORD value)
|
||||||
logLastError("error freeing system message in loadLastError()");
|
logLastError("error freeing system message in loadLastError()");
|
||||||
uiFree(wmessage);
|
uiFree(wmessage);
|
||||||
return str;
|
return str;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *loadLastError(const char *message)
|
static const char *loadLastError(const char *message)
|
||||||
|
|
|
@ -75,6 +75,7 @@
|
||||||
<ClCompile Include="alloc.c">
|
<ClCompile Include="alloc.c">
|
||||||
<CompileAsManaged>false</CompileAsManaged>
|
<CompileAsManaged>false</CompileAsManaged>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="control.cpp" />
|
||||||
<ClCompile Include="debug.c">
|
<ClCompile Include="debug.c">
|
||||||
<CompileAsManaged>false</CompileAsManaged>
|
<CompileAsManaged>false</CompileAsManaged>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -83,27 +84,38 @@
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="main.cpp" />
|
<ClCompile Include="main.cpp" />
|
||||||
<ClCompile Include="text.cpp" />
|
<ClCompile Include="text.cpp" />
|
||||||
|
<ClCompile Include="util.c">
|
||||||
|
<CompileAsManaged>false</CompileAsManaged>
|
||||||
|
</ClCompile>
|
||||||
|
|
||||||
|
<!-- TODO find a way to get the basename of the source path so we can use dir_file.obj naming automatically -->
|
||||||
<ClCompile Include="..\common\areaevents.c">
|
<ClCompile Include="..\common\areaevents.c">
|
||||||
<CompileAsManaged>false</CompileAsManaged>
|
<CompileAsManaged>false</CompileAsManaged>
|
||||||
|
<ObjectFileName>$(IntDir)common_areaevents.obj</ObjectFileName>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\common\control.c">
|
<ClCompile Include="..\common\control.c">
|
||||||
<CompileAsManaged>false</CompileAsManaged>
|
<CompileAsManaged>false</CompileAsManaged>
|
||||||
|
<ObjectFileName>$(IntDir)common_control.obj</ObjectFileName>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\common\matrix.c">
|
<ClCompile Include="..\common\matrix.c">
|
||||||
<CompileAsManaged>false</CompileAsManaged>
|
<CompileAsManaged>false</CompileAsManaged>
|
||||||
|
<ObjectFileName>$(IntDir)common_matrix.obj</ObjectFileName>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\common\menu.c">
|
<ClCompile Include="..\common\menu.c">
|
||||||
<CompileAsManaged>false</CompileAsManaged>
|
<CompileAsManaged>false</CompileAsManaged>
|
||||||
|
<ObjectFileName>$(IntDir)common_menu.obj</ObjectFileName>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\common\ptrarray.c">
|
<ClCompile Include="..\common\ptrarray.c">
|
||||||
<CompileAsManaged>false</CompileAsManaged>
|
<CompileAsManaged>false</CompileAsManaged>
|
||||||
|
<ObjectFileName>$(IntDir)common_ptrarray.obj</ObjectFileName>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\common\shouldquit.c">
|
<ClCompile Include="..\common\shouldquit.c">
|
||||||
<CompileAsManaged>false</CompileAsManaged>
|
<CompileAsManaged>false</CompileAsManaged>
|
||||||
|
<ObjectFileName>$(IntDir)common_shouldquit.obj</ObjectFileName>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\common\types.c">
|
<ClCompile Include="..\common\types.c">
|
||||||
<CompileAsManaged>false</CompileAsManaged>
|
<CompileAsManaged>false</CompileAsManaged>
|
||||||
|
<ObjectFileName>$(IntDir)common_types.obj</ObjectFileName>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// 7 april 2015
|
// 7 april 2015
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This file assumes that you have included <vccrt.h> and "ui.h" beforehand, as well as #using <System.dll> (but not necessarily beforehand). It provides API-specific functions for interfacing with foreign controls in Windows.
|
This file assumes that you have included <vccrt.h> and "ui.h" beforehand, as well as #using <System.dll> and the three WPF DLLs (TODO) (but not necessarily beforehand). It provides API-specific functions for interfacing with foreign controls in Windows.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __LIBUI_UI_WINDOWS_H__
|
#ifndef __LIBUI_UI_WINDOWS_H__
|
||||||
|
@ -18,6 +18,8 @@ typedef struct uiWindowsSizing uiWindowsSizing;
|
||||||
typedef struct uiWindowsControl uiWindowsControl;
|
typedef struct uiWindowsControl uiWindowsControl;
|
||||||
struct uiWindowsControl {
|
struct uiWindowsControl {
|
||||||
uiControl c;
|
uiControl c;
|
||||||
|
// TODO make truly private
|
||||||
|
gcroot<System::Windows::Controls::Control ^> *genericHandle;
|
||||||
};
|
};
|
||||||
_UI_EXTERN uintmax_t uiWindowsControlType(void);
|
_UI_EXTERN uintmax_t uiWindowsControlType(void);
|
||||||
#define uiWindowsControl(this) ((uiWindowsControl *) uiIsA((this), uiWindowsControlType(), 1))
|
#define uiWindowsControl(this) ((uiWindowsControl *) uiIsA((this), uiWindowsControlType(), 1))
|
||||||
|
@ -35,11 +37,12 @@ _UI_EXTERN uintmax_t uiWindowsControlType(void);
|
||||||
{ \
|
{ \
|
||||||
type *hthis = type(c); \
|
type *hthis = type(c); \
|
||||||
onDestroy; \
|
onDestroy; \
|
||||||
|
delete uiWindowsControl(c)->genericHandle; \
|
||||||
delete hthis->handle; \
|
delete hthis->handle; \
|
||||||
} \
|
} \
|
||||||
static uintptr_t _ ## type ## Handle(uiControl *c) \
|
static uintptr_t _ ## type ## Handle(uiControl *c) \
|
||||||
{ \
|
{ \
|
||||||
return (uintptr_t) (type(c)->handle); \
|
return (uintptr_t) (uiWindowsControl(c)->genericHandle); \
|
||||||
} \
|
} \
|
||||||
static void _ ## type ## ContainerUpdateState(uiControl *c) \
|
static void _ ## type ## ContainerUpdateState(uiControl *c) \
|
||||||
{ \
|
{ \
|
||||||
|
@ -49,10 +52,12 @@ _UI_EXTERN uintmax_t uiWindowsControlType(void);
|
||||||
#define uiWindowsDefineControl(type, typefn, handle) \
|
#define uiWindowsDefineControl(type, typefn, handle) \
|
||||||
uiWindowsDefineControlWithOnDestroy(type, typefn, handle, (void) hthis;)
|
uiWindowsDefineControlWithOnDestroy(type, typefn, handle, (void) hthis;)
|
||||||
|
|
||||||
#define uiWindowsFinishNewControl(variable, type) \
|
#define uiWindowsFinishNewControl(variable, type, handle) \
|
||||||
uiControl(variable)->CommitDestroy = _ ## type ## CommitDestroy; \
|
uiControl(variable)->CommitDestroy = _ ## type ## CommitDestroy; \
|
||||||
uiControl(variable)->Handle = _ ## type ## Handle; \
|
uiControl(variable)->Handle = _ ## type ## Handle; \
|
||||||
uiControl(variable)->ContainerUpdateState = _ ## type ## ContainerUpdateState; \
|
uiControl(variable)->ContainerUpdateState = _ ## type ## ContainerUpdateState; \
|
||||||
|
uiWindowsControl(variable)->genericHandle = new gcroot<System::Windows::Controls::Control ^>(); \
|
||||||
|
*(uiWindowsControl(variable)->genericHandle) = *(variable->handle); \
|
||||||
uiWindowsFinishControl(uiControl(variable));
|
uiWindowsFinishControl(uiControl(variable));
|
||||||
|
|
||||||
// This is a function used to set up a control.
|
// This is a function used to set up a control.
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
using namespace System;
|
using namespace System;
|
||||||
using namespace System::ComponentModel;
|
using namespace System::ComponentModel;
|
||||||
using namespace System::Windows;
|
using namespace System::Windows;
|
||||||
|
using namespace System::Windows::Controls;
|
||||||
|
|
||||||
// text.cpp
|
// text.cpp
|
||||||
String ^fromUTF8(const char *);
|
String ^fromUTF8(const char *);
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
// 6 april 2015
|
||||||
|
#include "unmanaged.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
void complain(const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
fprintf(stderr, "[libui] ");
|
||||||
|
vfprintf(stderr, fmt, ap);
|
||||||
|
fprintf(stderr, "\n");
|
||||||
|
va_end(ap);
|
||||||
|
DebugBreak();
|
||||||
|
abort(); // just in case
|
||||||
|
}
|
Loading…
Reference in New Issue