Clean up headers a little.
This commit is contained in:
parent
50c5df7fa2
commit
34cfdb8154
5 changed files with 57 additions and 38 deletions
|
@ -24,23 +24,25 @@
|
||||||
#import "OGWidget.h"
|
#import "OGWidget.h"
|
||||||
|
|
||||||
#ifdef OG_WIN32
|
#ifdef OG_WIN32
|
||||||
typedef struct s_OGBoxChild
|
typedef struct og_box_child_t
|
||||||
{
|
{
|
||||||
HWND hwnd;
|
HWND hwnd;
|
||||||
BOOL expand;
|
BOOL expand;
|
||||||
BOOL fill;
|
BOOL fill;
|
||||||
int padding;
|
int padding;
|
||||||
int originalSize;
|
int originalSize;
|
||||||
float currentSize;
|
float currentSize;
|
||||||
struct s_OGBoxChild *next;
|
struct og_box_child_t *next;
|
||||||
} OGBoxChild;
|
} og_box_child_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@interface OGBox: OGWidget
|
@interface OGBox: OGWidget
|
||||||
#ifdef OG_WIN32
|
#ifdef OG_WIN32
|
||||||
{ OGBoxChild *firstBorn; }
|
{
|
||||||
- (void)resizeChildren;
|
og_child_box_t *firstBorn;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
+ box;
|
+ box;
|
||||||
- (void)appendChild: (OGWidget*)child
|
- (void)appendChild: (OGWidget*)child
|
||||||
expand: (BOOL)expand
|
expand: (BOOL)expand
|
||||||
|
@ -50,4 +52,8 @@ typedef struct s_OGBoxChild
|
||||||
expand: (BOOL)expand
|
expand: (BOOL)expand
|
||||||
fill: (BOOL)fill
|
fill: (BOOL)fill
|
||||||
padding: (float)padding;
|
padding: (float)padding;
|
||||||
|
|
||||||
|
#ifdef OG_WIN32
|
||||||
|
- (void)OG_resizeChildren;
|
||||||
|
#endif
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -43,14 +43,18 @@
|
||||||
id <OGComboBoxDataSource> dataSource;
|
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 <OGComboBoxDelegate> delegate;
|
||||||
@property (assign) id <OGComboBoxDataSource> dataSource;
|
@property (assign) id <OGComboBoxDataSource> dataSource;
|
||||||
|
|
||||||
+ comboBox;
|
+ 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
|
@end
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011, 2012, Dillon Aumiller <dillonaumiller@gmail.com>
|
* Copyright (c) 2011, 2012, Dillon Aumiller <dillonaumiller@gmail.com>
|
||||||
|
* Copyright (c) 2012, Jonathan Schleifer <js@webkeks.org>
|
||||||
*
|
*
|
||||||
* https://webkeks.org/hg/objgui/
|
* https://webkeks.org/hg/objgui/
|
||||||
*
|
*
|
||||||
|
@ -25,7 +26,11 @@
|
||||||
//==================================================================================================================================
|
//==================================================================================================================================
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
|
#import <ObjFW/OFNotImplementedException.h>
|
||||||
|
|
||||||
#import "OGBox.h"
|
#import "OGBox.h"
|
||||||
|
|
||||||
//==================================================================================================================================
|
//==================================================================================================================================
|
||||||
@implementation OGBox
|
@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
|
- (int)MessageReceived : (HWND)hwnd : (UINT)msg : (WPARAM)wparam : (LPARAM)lparam
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011, 2012, Dillon Aumiller <dillonaumiller@gmail.com>
|
* Copyright (c) 2011, 2012, Dillon Aumiller <dillonaumiller@gmail.com>
|
||||||
|
* Copyright (c) 2012, Jonathan Schleifer <js@webkeks.org>
|
||||||
*
|
*
|
||||||
* https://webkeks.org/hg/objgui/
|
* https://webkeks.org/hg/objgui/
|
||||||
*
|
*
|
||||||
|
@ -44,7 +45,7 @@
|
||||||
SetParent(child->widget, widget);
|
SetParent(child->widget, widget);
|
||||||
GetWindowRect(child->widget, &rc);
|
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->hwnd = child->widget;
|
||||||
newChild->expand = expand;
|
newChild->expand = expand;
|
||||||
newChild->fill = fill;
|
newChild->fill = fill;
|
||||||
|
@ -57,12 +58,12 @@
|
||||||
firstBorn = newChild;
|
firstBorn = newChild;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
OGBoxChild *curr = firstBorn;
|
og_box_child_t *curr = firstBorn;
|
||||||
while(curr->next != NULL) curr = curr->next;
|
while(curr->next != NULL) curr = curr->next;
|
||||||
curr->next = newChild;
|
curr->next = newChild;
|
||||||
}
|
}
|
||||||
|
|
||||||
[self resizeChildren];
|
[self OG_resizeChildren];
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------------------------------------
|
||||||
- (void)prependChild: (OGWidget*)child
|
- (void)prependChild: (OGWidget*)child
|
||||||
|
@ -74,7 +75,7 @@
|
||||||
SetParent(child->widget, widget);
|
SetParent(child->widget, widget);
|
||||||
GetWindowRect(child->widget, &rc);
|
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->hwnd = child->widget;
|
||||||
newChild->expand = expand;
|
newChild->expand = expand;
|
||||||
newChild->fill = fill;
|
newChild->fill = fill;
|
||||||
|
@ -85,13 +86,13 @@
|
||||||
|
|
||||||
firstBorn = newChild;
|
firstBorn = newChild;
|
||||||
|
|
||||||
[self resizeChildren];
|
[self OG_resizeChildren];
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------------------------------------
|
||||||
- (void)resizeChildren
|
- (void)OG_resizeChildren
|
||||||
{
|
{
|
||||||
RECT rc;
|
RECT rc;
|
||||||
OGBoxChild *curr;
|
og_box_child_t *curr;
|
||||||
|
|
||||||
//get our available size
|
//get our available size
|
||||||
GetClientRect(widget, &rc);
|
GetClientRect(widget, &rc);
|
||||||
|
@ -121,7 +122,7 @@
|
||||||
}
|
}
|
||||||
if(extra < 0)
|
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);
|
SetWindowPos(widget, NULL, 0, 0, childOriginal, height, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOMOVE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -170,12 +171,12 @@
|
||||||
switch(msg)
|
switch(msg)
|
||||||
{
|
{
|
||||||
case WM_SIZE:
|
case WM_SIZE:
|
||||||
[self resizeChildren];
|
[self OG_resizeChildren];
|
||||||
return DefWindowProc(hwnd, msg, wparam, lparam);
|
return DefWindowProc(hwnd, msg, wparam, lparam);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_SIZING:
|
case WM_SIZING:
|
||||||
[self resizeChildren];
|
[self OG_resizeChildren];
|
||||||
return DefWindowProc(hwnd, msg, wparam, lparam);
|
return DefWindowProc(hwnd, msg, wparam, lparam);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011, 2012, Dillon Aumiller <dillonaumiller@gmail.com>
|
* Copyright (c) 2011, 2012, Dillon Aumiller <dillonaumiller@gmail.com>
|
||||||
|
* Copyright (c) 2012, Jonathan Schleifer <js@webkeks.org>
|
||||||
*
|
*
|
||||||
* https://webkeks.org/hg/objgui/
|
* https://webkeks.org/hg/objgui/
|
||||||
*
|
*
|
||||||
|
@ -44,7 +45,7 @@
|
||||||
SetParent(child->widget, widget);
|
SetParent(child->widget, widget);
|
||||||
GetWindowRect(child->widget, &rc);
|
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->hwnd = child->widget;
|
||||||
newChild->expand = expand;
|
newChild->expand = expand;
|
||||||
newChild->fill = fill;
|
newChild->fill = fill;
|
||||||
|
@ -57,12 +58,12 @@
|
||||||
firstBorn = newChild;
|
firstBorn = newChild;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
OGBoxChild *curr = firstBorn;
|
og_box_child_t *curr = firstBorn;
|
||||||
while(curr->next != NULL) curr = curr->next;
|
while(curr->next != NULL) curr = curr->next;
|
||||||
curr->next = newChild;
|
curr->next = newChild;
|
||||||
}
|
}
|
||||||
|
|
||||||
[self resizeChildren];
|
[self OG_resizeChildren];
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------------------------------------
|
||||||
- (void)prependChild: (OGWidget*)child
|
- (void)prependChild: (OGWidget*)child
|
||||||
|
@ -74,7 +75,7 @@
|
||||||
SetParent(child->widget, widget);
|
SetParent(child->widget, widget);
|
||||||
GetWindowRect(child->widget, &rc);
|
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->hwnd = child->widget;
|
||||||
newChild->expand = expand;
|
newChild->expand = expand;
|
||||||
newChild->fill = fill;
|
newChild->fill = fill;
|
||||||
|
@ -86,13 +87,13 @@
|
||||||
firstBorn = newChild;
|
firstBorn = newChild;
|
||||||
|
|
||||||
SetParent(child->widget, widget);
|
SetParent(child->widget, widget);
|
||||||
[self resizeChildren];
|
[self OG_resizeChildren];
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------------------------------------
|
||||||
- (void)resizeChildren
|
- (void)OG_resizeChildren
|
||||||
{
|
{
|
||||||
RECT rc;
|
RECT rc;
|
||||||
OGBoxChild *curr;
|
og_box_child_t *curr;
|
||||||
|
|
||||||
//get our available size
|
//get our available size
|
||||||
GetClientRect(widget, &rc);
|
GetClientRect(widget, &rc);
|
||||||
|
@ -122,7 +123,7 @@
|
||||||
}
|
}
|
||||||
if(extra < 0)
|
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);
|
SetWindowPos(widget, NULL, 0, 0, width, childOriginal, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOMOVE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -171,12 +172,12 @@
|
||||||
switch(msg)
|
switch(msg)
|
||||||
{
|
{
|
||||||
case WM_SIZE:
|
case WM_SIZE:
|
||||||
[self resizeChildren];
|
[self OG_resizeChildren];
|
||||||
return DefWindowProc(hwnd, msg, wparam, lparam);
|
return DefWindowProc(hwnd, msg, wparam, lparam);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_SIZING:
|
case WM_SIZING:
|
||||||
[self resizeChildren];
|
[self OG_resizeChildren];
|
||||||
return DefWindowProc(hwnd, msg, wparam, lparam);
|
return DefWindowProc(hwnd, msg, wparam, lparam);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue