diff --git a/headers/OGBox.h b/headers/OGBox.h index 5e03d5d..0f90772 100644 --- a/headers/OGBox.h +++ b/headers/OGBox.h @@ -24,23 +24,25 @@ #import "OGWidget.h" #ifdef OG_WIN32 -typedef struct s_OGBoxChild +typedef struct og_box_child_t { - HWND hwnd; - BOOL expand; - BOOL fill; - int padding; - int originalSize; - float currentSize; - struct s_OGBoxChild *next; -} OGBoxChild; + HWND hwnd; + BOOL expand; + BOOL fill; + int padding; + int originalSize; + float currentSize; + 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 diff --git a/headers/OGComboBox.h b/headers/OGComboBox.h index 3a88390..f007b08 100644 --- a/headers/OGComboBox.h +++ b/headers/OGComboBox.h @@ -43,14 +43,18 @@ id 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 delegate; @property (assign) id 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 diff --git a/win32/OGBox.m b/win32/OGBox.m index a01cec5..528e0fb 100644 --- a/win32/OGBox.m +++ b/win32/OGBox.m @@ -1,5 +1,6 @@ /* * Copyright (c) 2011, 2012, Dillon Aumiller + * Copyright (c) 2012, Jonathan Schleifer * * https://webkeks.org/hg/objgui/ * @@ -25,7 +26,11 @@ //================================================================================================================================== #include #include + +#import + #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 diff --git a/win32/OGHBox.m b/win32/OGHBox.m index efd28ca..2b0d507 100644 --- a/win32/OGHBox.m +++ b/win32/OGHBox.m @@ -1,5 +1,6 @@ /* * Copyright (c) 2011, 2012, Dillon Aumiller + * Copyright (c) 2012, Jonathan Schleifer * * 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; } diff --git a/win32/OGVBox.m b/win32/OGVBox.m index 24d78f0..47cd86a 100644 --- a/win32/OGVBox.m +++ b/win32/OGVBox.m @@ -1,5 +1,6 @@ /* * Copyright (c) 2011, 2012, Dillon Aumiller + * Copyright (c) 2012, Jonathan Schleifer * * 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; }