Clean up headers a little.

This commit is contained in:
Jonathan Schleifer 2012-01-05 16:08:37 +01:00
parent 50c5df7fa2
commit 34cfdb8154
5 changed files with 57 additions and 38 deletions

View file

@ -24,7 +24,7 @@
#import "OGWidget.h"
#ifdef OG_WIN32
typedef struct s_OGBoxChild
typedef struct og_box_child_t
{
HWND hwnd;
BOOL expand;
@ -32,15 +32,17 @@ typedef struct s_OGBoxChild
int padding;
int originalSize;
float currentSize;
struct s_OGBoxChild *next;
} OGBoxChild;
struct og_box_child_t *next;
} og_box_child_t;
#endif
@interface OGBox: OGWidget
#ifdef OG_WIN32
{ OGBoxChild *firstBorn; }
- (void)resizeChildren;
{
og_child_box_t *firstBorn;
}
#endif
+ box;
- (void)appendChild: (OGWidget*)child
expand: (BOOL)expand
@ -50,4 +52,8 @@ typedef struct s_OGBoxChild
expand: (BOOL)expand
fill: (BOOL)fill
padding: (float)padding;
#ifdef OG_WIN32
- (void)OG_resizeChildren;
#endif
@end

View file

@ -43,14 +43,18 @@
id <OGComboBoxDataSource> dataSource;
}
#ifdef OG_WIN32
//unfortunately, the built-in Win32 ListBox stores a pointer to it's parent (for sending selection changed notifications) during CreateWindow().
//it does not update it after a SetParent()... unless we implement a custom ListBox control i don't see a way around this...
- initWithParent : (OGWidget *)parent;
#endif
@property (assign) id <OGComboBoxDelegate> delegate;
@property (assign) id <OGComboBoxDataSource> dataSource;
+ comboBox;
#ifdef OG_WIN32
/*
* Unfortunately, the built-in Win32 ListBox stores a pointer to it's parent
* (for sending selection changed notifications) during CreateWindow(). It does
* not update it after a SetParent() unless we implement a custom ListBox
* control, so there seems to be no way around this.
*/
- initWithParent: (OGWidget*)parent;
#endif
@end

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 2011, 2012, Dillon Aumiller <dillonaumiller@gmail.com>
* Copyright (c) 2012, Jonathan Schleifer <js@webkeks.org>
*
* https://webkeks.org/hg/objgui/
*
@ -25,7 +26,11 @@
//==================================================================================================================================
#include <malloc.h>
#include <windows.h>
#import <ObjFW/OFNotImplementedException.h>
#import "OGBox.h"
//==================================================================================================================================
@implementation OGBox
//----------------------------------------------------------------------------------------------------------------------------------
@ -67,8 +72,10 @@
{
}
//----------------------------------------------------------------------------------------------------------------------------------
- (void)resizeChildren
- (void)OG_resizeChildren
{
@throw [OFNotImplementedException exceptionWithClass: isa
selector: _cmd];
}
//----------------------------------------------------------------------------------------------------------------------------------
- (int)MessageReceived : (HWND)hwnd : (UINT)msg : (WPARAM)wparam : (LPARAM)lparam

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 2011, 2012, Dillon Aumiller <dillonaumiller@gmail.com>
* Copyright (c) 2012, Jonathan Schleifer <js@webkeks.org>
*
* https://webkeks.org/hg/objgui/
*
@ -44,7 +45,7 @@
SetParent(child->widget, widget);
GetWindowRect(child->widget, &rc);
OGBoxChild *newChild = (OGBoxChild *)malloc(sizeof(OGBoxChild));
og_box_child_t *newChild = malloc(sizeof(og_box_child_t));
newChild->hwnd = child->widget;
newChild->expand = expand;
newChild->fill = fill;
@ -57,12 +58,12 @@
firstBorn = newChild;
else
{
OGBoxChild *curr = firstBorn;
og_box_child_t *curr = firstBorn;
while(curr->next != NULL) curr = curr->next;
curr->next = newChild;
}
[self resizeChildren];
[self OG_resizeChildren];
}
//----------------------------------------------------------------------------------------------------------------------------------
- (void)prependChild: (OGWidget*)child
@ -74,7 +75,7 @@
SetParent(child->widget, widget);
GetWindowRect(child->widget, &rc);
OGBoxChild *newChild = (OGBoxChild *)malloc(sizeof(OGBoxChild));
og_box_child_t *newChild = malloc(sizeof(og_box_child_t));
newChild->hwnd = child->widget;
newChild->expand = expand;
newChild->fill = fill;
@ -85,13 +86,13 @@
firstBorn = newChild;
[self resizeChildren];
[self OG_resizeChildren];
}
//----------------------------------------------------------------------------------------------------------------------------------
- (void)resizeChildren
- (void)OG_resizeChildren
{
RECT rc;
OGBoxChild *curr;
og_box_child_t *curr;
//get our available size
GetClientRect(widget, &rc);
@ -121,7 +122,7 @@
}
if(extra < 0)
{
//this will generate a WM_SIZE message, and we'll come back to resizeChildren
//this will generate a WM_SIZE message, and we'll come back to OG_resizeChildren
SetWindowPos(widget, NULL, 0, 0, childOriginal, height, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOMOVE);
return;
}
@ -170,12 +171,12 @@
switch(msg)
{
case WM_SIZE:
[self resizeChildren];
[self OG_resizeChildren];
return DefWindowProc(hwnd, msg, wparam, lparam);
break;
case WM_SIZING:
[self resizeChildren];
[self OG_resizeChildren];
return DefWindowProc(hwnd, msg, wparam, lparam);
break;
}

View file

@ -1,5 +1,6 @@
/*
* Copyright (c) 2011, 2012, Dillon Aumiller <dillonaumiller@gmail.com>
* Copyright (c) 2012, Jonathan Schleifer <js@webkeks.org>
*
* https://webkeks.org/hg/objgui/
*
@ -44,7 +45,7 @@
SetParent(child->widget, widget);
GetWindowRect(child->widget, &rc);
OGBoxChild *newChild = (OGBoxChild *)malloc(sizeof(OGBoxChild));
og_box_child_t *newChild = malloc(sizeof(og_box_child_t));
newChild->hwnd = child->widget;
newChild->expand = expand;
newChild->fill = fill;
@ -57,12 +58,12 @@
firstBorn = newChild;
else
{
OGBoxChild *curr = firstBorn;
og_box_child_t *curr = firstBorn;
while(curr->next != NULL) curr = curr->next;
curr->next = newChild;
}
[self resizeChildren];
[self OG_resizeChildren];
}
//----------------------------------------------------------------------------------------------------------------------------------
- (void)prependChild: (OGWidget*)child
@ -74,7 +75,7 @@
SetParent(child->widget, widget);
GetWindowRect(child->widget, &rc);
OGBoxChild *newChild = (OGBoxChild *)malloc(sizeof(OGBoxChild));
og_box_child_t *newChild = malloc(sizeof(og_box_child_t));
newChild->hwnd = child->widget;
newChild->expand = expand;
newChild->fill = fill;
@ -86,13 +87,13 @@
firstBorn = newChild;
SetParent(child->widget, widget);
[self resizeChildren];
[self OG_resizeChildren];
}
//----------------------------------------------------------------------------------------------------------------------------------
- (void)resizeChildren
- (void)OG_resizeChildren
{
RECT rc;
OGBoxChild *curr;
og_box_child_t *curr;
//get our available size
GetClientRect(widget, &rc);
@ -122,7 +123,7 @@
}
if(extra < 0)
{
//this will generate a WM_SIZE message, and we'll come back to resizeChildren
//this will generate a WM_SIZE message, and we'll come back to OG_resizeChildren
SetWindowPos(widget, NULL, 0, 0, width, childOriginal, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOMOVE);
return;
}
@ -171,12 +172,12 @@
switch(msg)
{
case WM_SIZE:
[self resizeChildren];
[self OG_resizeChildren];
return DefWindowProc(hwnd, msg, wparam, lparam);
break;
case WM_SIZING:
[self resizeChildren];
[self OG_resizeChildren];
return DefWindowProc(hwnd, msg, wparam, lparam);
break;
}