started an interface to emulate the skygi windowing but actually use win32 apis

svn path=/trunk/; revision=10508
This commit is contained in:
Thomas Bluemel 2004-08-12 19:27:12 +00:00
parent 81ace77431
commit a7d6dcd7c1
4 changed files with 226 additions and 77 deletions

View file

@ -191,7 +191,7 @@ typedef struct s_window
unsigned int width;
unsigned int orgx;
unsigned int orgy;
unsigned long (*win_func)(HANDLE win, s_gi_msg *m);
unsigned long (__cdecl *win_func)(HANDLE win, s_gi_msg *m);
HANDLE handle;
struct s_window *parent;
@ -211,10 +211,10 @@ typedef struct s_window
typedef struct sCreateApplication
{
unsigned char ucApplicationName[255];
unsigned int uiX;
unsigned int uiY;
unsigned int uiWidth;
unsigned int uiHeight;
unsigned int uiX;
unsigned int uiY;
unsigned int uiWidth;
unsigned int uiHeight;
void *fwndClient;
unsigned int uiStyleApplication;

View file

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.1 2004/08/12 02:50:35 weiden Exp $
# $Id: Makefile,v 1.2 2004/08/12 19:27:12 weiden Exp $
PATH_TO_TOP = ../../..
@ -18,7 +18,7 @@ TARGET_CFLAGS = \
TARGET_LFLAGS = -nostartfiles -nostdlib
TARGET_SDKLIBS = ntdll.a kernel32.a
TARGET_SDKLIBS = ntdll.a kernel32.a user32.a
TARGET_ENTRY = 0x00000000

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/* $Id: libskygi.c,v 1.1 2004/08/12 02:50:35 weiden Exp $
/* $Id: libskygi.c,v 1.2 2004/08/12 19:27:12 weiden Exp $
*
* PROJECT: SkyOS GI library
* FILE: lib/libskygi/libskygi.c
@ -30,5 +30,222 @@
#include "libskygi.h"
#include "resource.h"
typedef struct
{
s_window Window;
MSG LastMsg;
HWND hWnd;
s_gi_msg DispatchMsg;
} SKY_WINDOW, *PSKY_WINDOW;
static ATOM SkyClassAtom;
static BOOL SkyClassRegistered = FALSE;
LRESULT CALLBACK
SkyWndDefaultWin32Proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
PSKY_WINDOW skw = (PSKY_WINDOW)GetWindowLong(hWnd, GWL_USERDATA);
if(skw != NULL)
{
switch(msg)
{
case WM_CLOSE:
PostQuitMessage(0);
break;
case WM_NCDESTROY:
/* free the SKY_WINDOW structure */
HeapFree(GetProcessHeap(), 0, skw);
break;
}
}
return DefWindowProc(hWnd, msg, wParam, lParam);
}
ATOM
SkyWndRegisterClass(void)
{
WNDCLASS wc;
wc.lpszClassName = "ROSkyWindow";
wc.lpfnWndProc = SkyWndDefaultWin32Proc;
wc.style = CS_VREDRAW | CS_HREDRAW;
wc.hInstance = GetModuleHandle(NULL);
wc.hIcon = LoadIcon(NULL, (LPCTSTR)IDI_APPLICATION);
wc.hCursor = LoadCursor(NULL, (LPCTSTR)IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
wc.lpszMenuName = NULL;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
return RegisterClass(&wc);
}
/*
* @implemented
*/
s_window* __cdecl
GI_create_app(app_para *p)
{
PSKY_WINDOW skw;
DBG("GI_create_app(0x%x)\n", p);
/* FIXME - lock */
if(!SkyClassRegistered)
{
SkyClassAtom = SkyWndRegisterClass();
SkyClassRegistered = SkyClassAtom != 0;
if(!SkyClassRegistered)
{
DBG("Unable to register the ROSkyWindow class\n");
return NULL;
}
}
/* FIXME - unlock */
skw = (PSKY_WINDOW)HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY,
sizeof(SKY_WINDOW));
if(skw == NULL)
{
DBG("Not enough memory to allocate a SKY_WINDOW structure!\n");
return NULL;
}
skw->hWnd = CreateWindow("ROSkyWindow",
(p->cpName[0] != '\0' ? (char*)p->cpName : ""),
WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL,
p->ulX,
p->ulY,
p->ulWidth,
p->ulHeight,
NULL,
NULL,
GetModuleHandle(NULL),
NULL);
if(skw->hWnd == NULL)
{
DBG("CreateWindow() failed!\n");
HeapFree(GetProcessHeap(), 0, skw);
return NULL;
}
skw->Window.win_func = p->win_func;
/* FIXME - fill the window structure */
/* save the pointer to the structure so we can access it later when dispatching
the win32 messages so we know which sky window it is and dispatch the right
messages */
SetWindowLong(skw->hWnd, GWL_USERDATA, (LONG)skw);
DBG("Created Win32 window: 0x%x\n", skw->hWnd);
return &skw->Window;
}
/*
* @implemented
*/
int __cdecl
GI_destroy_window(s_window *win)
{
PSKY_WINDOW skw = (PSKY_WINDOW)win;
DBG("GI_destroy_window(0x%x)\n", win);
return (int)DestroyWindow(skw->hWnd);
}
/*
* @implemented
*/
unsigned int __cdecl
GI_wait_message(s_gi_msg *m,
s_window* w)
{
MSG Msg;
BOOL Ret;
HWND hwndFilter;
PSKY_WINDOW msgwnd, filterwnd;
DBG("GI_wait_message(0x%x, 0x%x)\n", m, w);
filterwnd = (w != NULL ? (PSKY_WINDOW)w : NULL);
hwndFilter = (w != NULL ? filterwnd->hWnd : NULL);
Ret = GetMessage(&Msg, hwndFilter, 0, 0);
if(Ret)
{
if(Msg.hwnd != NULL)
{
msgwnd = (PSKY_WINDOW)GetWindowLong(Msg.hwnd, GWL_USERDATA);
msgwnd->LastMsg = Msg;
}
else
{
msgwnd = NULL;
}
}
RtlZeroMemory(m, sizeof(s_gi_msg));
m->win = (msgwnd != NULL ? &msgwnd->Window : NULL);
/* FIXME - fill in the other messags */
return (int)Ret;
}
/*
* @implemented
*/
int __cdecl
GI_dispatch_message(s_window *win,
s_gi_msg *m)
{
PSKY_WINDOW skywnd = (PSKY_WINDOW)win;
DBG("GI_dispatch_message(0x%x, 0x%x)\n", win, m);
skywnd->DispatchMsg = *m;
DispatchMessage(&skywnd->LastMsg);
return 1;
}
/*
* @implemented
*/
HRESULT __cdecl
GI_ShowApplicationWindow(s_window *win)
{
PSKY_WINDOW skywnd = (PSKY_WINDOW)win;
DBG("GI_ShowApplicationWindow(0x%x)\n", win);
DBG("->0x%x\n", skywnd->hWnd);
ShowWindow(skywnd->hWnd, SW_SHOW);
return 1;
}
/*
* @implemented
*/
sCreateApplication* __cdecl
GI_CreateApplicationStruct(void)
{
sCreateApplication *app;
app = (sCreateApplication*)HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY,
sizeof(sCreateApplication));
STUB("GI_CreateApplicationStruct() returns 0x%x (allocated structure on the heap)!\n", app);
return app;
}
/* EOF */

View file

@ -1,4 +1,4 @@
/* $Id: stubs.c,v 1.2 2004/08/12 15:41:36 weiden Exp $
/* $Id: stubs.c,v 1.3 2004/08/12 19:27:12 weiden Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: SkyOS GI library
@ -116,17 +116,6 @@ GC_set_bg_color(GC *gc,
}
/*
* @unimplemented
*/
HRESULT __cdecl
GI_ShowApplicationWindow(HANDLE hWnd)
{
STUB("GI_ShowApplicationWindow(0x%x) returns 0!\n", hWnd);
return 0;
}
/*
* @unimplemented
*/
@ -163,17 +152,6 @@ GI_create_DDB_from_DIB(DIB *dib)
}
/*
* @unimplemented
*/
HANDLE __cdecl
GI_create_app(app_para *p)
{
STUB("GI_create_app(0x%x) returns NULL!\n", p);
return NULL;
}
/*
* @unimplemented
*/
@ -199,29 +177,6 @@ GI_create_menu_item(unsigned char *text,
}
/*
* @unimplemented
*/
int __cdecl
GI_destroy_window(s_window *win)
{
STUB("GI_destroy_window(0x%x) returns 0!\n", win);
return 0;
}
/*
* @unimplemented
*/
int __cdecl
GI_dispatch_message(s_window *win,
s_gi_msg *m)
{
STUB("GI_dispatch_message(0x%x, 0x%x) returns 0!\n", win, m);
return 0;
}
/*
* @unimplemented
*/
@ -280,18 +235,6 @@ GI_set_high_timer(HANDLE w,
}
/*
* @unimplemented
*/
unsigned int __cdecl
GI_wait_message(s_gi_msg *m,
s_window* w)
{
STUB("GI_wait_message(0x%x, 0x%x) returns 0!\n", m, w);
return 0;
}
/*
* @unimplemented
*/
@ -368,17 +311,6 @@ GC_set_font_param(GC *gc,
}
/*
* @unimplemented
*/
sCreateApplication* __cdecl
GI_CreateApplicationStruct(void)
{
STUB("GI_CreateApplicationStruct() returns NULL!\n");
return NULL;
}
/*
* @unimplemented
*/