1
0
Fork 0

(svn r10730) -Codechange: allow (some) arbitrary data to be send to the WE_CREATE event.

release/0.6
rubidium 2007-07-29 22:57:40 +00:00
parent 809238e634
commit cffc67aae8
2 changed files with 25 additions and 14 deletions

View File

@ -598,10 +598,11 @@ static Window *FindFreeWindow()
* @param cls see WindowClass class of the window, used for identification and grouping * @param cls see WindowClass class of the window, used for identification and grouping
* @param *widget see Widget pointer to the window layout and various elements * @param *widget see Widget pointer to the window layout and various elements
* @param window_number number being assigned to the new window * @param window_number number being assigned to the new window
* @param data the data to be given during the WE_CREATE message
* @return Window pointer of the newly created window */ * @return Window pointer of the newly created window */
static Window *LocalAllocateWindow( static Window *LocalAllocateWindow(
int x, int y, int min_width, int min_height, int def_width, int def_height, int x, int y, int min_width, int min_height, int def_width, int def_height,
WindowProc *proc, WindowClass cls, const Widget *widget, int window_number) WindowProc *proc, WindowClass cls, const Widget *widget, int window_number, void *data)
{ {
Window *w = FindFreeWindow(); Window *w = FindFreeWindow();
@ -654,7 +655,10 @@ static Window *LocalAllocateWindow(
_last_z_window++; _last_z_window++;
} }
CallWindowEventNP(w, WE_CREATE); WindowEvent e;
e.event = WE_CREATE;
e.we.create.data = data;
w->wndproc(w, &e);
/* Try to make windows smaller when our window is too small. /* Try to make windows smaller when our window is too small.
* w->(width|height) is normally the same as min_(width|height), * w->(width|height) is normally the same as min_(width|height),
@ -715,9 +719,9 @@ static Window *LocalAllocateWindow(
* @return Window pointer of the newly created window */ * @return Window pointer of the newly created window */
Window *AllocateWindow( Window *AllocateWindow(
int x, int y, int width, int height, int x, int y, int width, int height,
WindowProc *proc, WindowClass cls, const Widget *widget) WindowProc *proc, WindowClass cls, const Widget *widget, void *data)
{ {
return LocalAllocateWindow(x, y, width, height, width, height, proc, cls, widget, 0); return LocalAllocateWindow(x, y, width, height, width, height, proc, cls, widget, 0, data);
} }
struct SizeRect { struct SizeRect {
@ -829,7 +833,7 @@ restart:
} }
} }
static Window *LocalAllocateWindowDesc(const WindowDesc *desc, int window_number) static Window *LocalAllocateWindowDesc(const WindowDesc *desc, int window_number, void *data)
{ {
Point pt; Point pt;
Window *w; Window *w;
@ -884,7 +888,7 @@ static Window *LocalAllocateWindowDesc(const WindowDesc *desc, int window_number
} }
allocate_window: allocate_window:
w = LocalAllocateWindow(pt.x, pt.y, desc->minimum_width, desc->minimum_height, desc->default_width, desc->default_height, desc->proc, desc->cls, desc->widgets, window_number); w = LocalAllocateWindow(pt.x, pt.y, desc->minimum_width, desc->minimum_height, desc->default_width, desc->default_height, desc->proc, desc->cls, desc->widgets, window_number, data);
w->desc_flags = desc->flags; w->desc_flags = desc->flags;
return w; return w;
} }
@ -892,25 +896,27 @@ allocate_window:
/** /**
* Open a new window. * Open a new window.
* @param *desc The pointer to the WindowDesc to be created * @param *desc The pointer to the WindowDesc to be created
* @param data arbitrary data that is send with the WE_CREATE message
* @return Window pointer of the newly created window * @return Window pointer of the newly created window
*/ */
Window *AllocateWindowDesc(const WindowDesc *desc) Window *AllocateWindowDesc(const WindowDesc *desc, void *data)
{ {
return LocalAllocateWindowDesc(desc, 0); return LocalAllocateWindowDesc(desc, 0, data);
} }
/** /**
* Open a new window. * Open a new window.
* @param *desc The pointer to the WindowDesc to be created * @param *desc The pointer to the WindowDesc to be created
* @param window_number the window number of the new window * @param window_number the window number of the new window
* @param data arbitrary data that is send with the WE_CREATE message
* @return see Window pointer of the newly created window * @return see Window pointer of the newly created window
*/ */
Window *AllocateWindowDescFront(const WindowDesc *desc, int window_number) Window *AllocateWindowDescFront(const WindowDesc *desc, int window_number, void *data)
{ {
Window *w; Window *w;
if (BringWindowToFrontById(desc->cls, window_number)) return NULL; if (BringWindowToFrontById(desc->cls, window_number)) return NULL;
w = LocalAllocateWindowDesc(desc, window_number); w = LocalAllocateWindowDesc(desc, window_number, data);
return w; return w;
} }

View File

@ -127,7 +127,11 @@ enum WindowEventCodes {
struct WindowEvent { struct WindowEvent {
byte event; byte event;
union { union {
struct{ struct {
void *data;
} create;
struct {
Point pt; Point pt;
int widget; int widget;
} click; } click;
@ -581,10 +585,11 @@ Window *AllocateWindow(
int height, int height,
WindowProc *proc, WindowProc *proc,
WindowClass cls, WindowClass cls,
const Widget *widget); const Widget *widget,
void *data = NULL);
Window *AllocateWindowDesc(const WindowDesc *desc); Window *AllocateWindowDesc(const WindowDesc *desc, void *data = NULL);
Window *AllocateWindowDescFront(const WindowDesc *desc, int window_number); Window *AllocateWindowDescFront(const WindowDesc *desc, int window_number, void *data = NULL);
void DrawWindowViewport(const Window *w); void DrawWindowViewport(const Window *w);
void ResizeWindow(Window *w, int x, int y); void ResizeWindow(Window *w, int x, int y);