Index: headers/OGBox.h ================================================================== --- headers/OGBox.h +++ headers/OGBox.h @@ -22,32 +22,38 @@ */ #import "OGWidget.h" #ifdef OG_WIN32 -typedef struct s_OGBoxChild -{ - HWND hwnd; - BOOL expand; - BOOL fill; - int padding; - int originalSize; - float currentSize; - struct s_OGBoxChild *next; -} OGBoxChild; +typedef struct og_box_child_t +{ + 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 fill: (BOOL)fill padding: (float)padding; - (void)prependChild: (OGWidget*)child expand: (BOOL)expand fill: (BOOL)fill padding: (float)padding; + +#ifdef OG_WIN32 +- (void)OG_resizeChildren; +#endif @end Index: headers/OGComboBox.h ================================================================== --- headers/OGComboBox.h +++ headers/OGComboBox.h @@ -41,16 +41,20 @@ { id delegate; 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 Index: win32/OGBox.m ================================================================== --- win32/OGBox.m +++ win32/OGBox.m @@ -1,7 +1,8 @@ /* * Copyright (c) 2011, 2012, Dillon Aumiller + * Copyright (c) 2012, Jonathan Schleifer * * https://webkeks.org/hg/objgui/ * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -23,11 +24,15 @@ //================================================================================================================================== // OGBox.m //================================================================================================================================== #include #include + +#import + #import "OGBox.h" + //================================================================================================================================== @implementation OGBox //---------------------------------------------------------------------------------------------------------------------------------- + box { @@ -65,12 +70,14 @@ fill: (BOOL)fill padding: (float)padding { } //---------------------------------------------------------------------------------------------------------------------------------- -- (void)resizeChildren +- (void)OG_resizeChildren { + @throw [OFNotImplementedException exceptionWithClass: isa + selector: _cmd]; } //---------------------------------------------------------------------------------------------------------------------------------- - (int)MessageReceived : (HWND)hwnd : (UINT)msg : (WPARAM)wparam : (LPARAM)lparam { HWND parent; Index: win32/OGHBox.m ================================================================== --- win32/OGHBox.m +++ win32/OGHBox.m @@ -1,7 +1,8 @@ /* * Copyright (c) 2011, 2012, Dillon Aumiller + * Copyright (c) 2012, Jonathan Schleifer * * https://webkeks.org/hg/objgui/ * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -42,11 +43,11 @@ { RECT rc; 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; newChild->padding = (int)padding; newChild->originalSize = (rc.right - rc.left); @@ -55,16 +56,16 @@ if(firstBorn == NULL) 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 expand: (BOOL)expand fill: (BOOL)fill @@ -72,11 +73,11 @@ { RECT rc; 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; newChild->padding = (int)padding; newChild->originalSize = (rc.right - rc.left); @@ -83,17 +84,17 @@ newChild->currentSize = (float)(newChild->originalSize + (newChild->padding << 1)); newChild->next = firstBorn; 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); int width = rc.right; int height = rc.bottom; @@ -119,11 +120,11 @@ curr->currentSize = curr->originalSize; curr = curr->next; } 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; } } else @@ -168,19 +169,19 @@ - (int)MessageReceived : (HWND)hwnd : (UINT)msg : (WPARAM)wparam : (LPARAM)lparam { 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; } return [(id)super MessageReceived : hwnd : msg : wparam : lparam]; } //---------------------------------------------------------------------------------------------------------------------------------- @end //================================================================================================================================== Index: win32/OGVBox.m ================================================================== --- win32/OGVBox.m +++ win32/OGVBox.m @@ -1,7 +1,8 @@ /* * Copyright (c) 2011, 2012, Dillon Aumiller + * Copyright (c) 2012, Jonathan Schleifer * * https://webkeks.org/hg/objgui/ * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -42,11 +43,11 @@ { RECT rc; 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; newChild->padding = (int)padding; newChild->originalSize = (rc.bottom - rc.top); @@ -55,16 +56,16 @@ if(firstBorn == NULL) 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 expand: (BOOL)expand fill: (BOOL)fill @@ -72,11 +73,11 @@ { RECT rc; 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; newChild->padding = (int)padding; newChild->originalSize = (rc.bottom - rc.top); @@ -84,17 +85,17 @@ newChild->next = firstBorn; 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); int width = rc.right; int height = rc.bottom; @@ -120,11 +121,11 @@ curr->currentSize = curr->originalSize; curr = curr->next; } 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; } } else @@ -169,19 +170,19 @@ - (int)MessageReceived : (HWND)hwnd : (UINT)msg : (WPARAM)wparam : (LPARAM)lparam { 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; } return [(id)super MessageReceived : hwnd : msg : wparam : lparam]; } //---------------------------------------------------------------------------------------------------------------------------------- @end //==================================================================================================================================