Index: win32/OGApplication.m ================================================================== --- win32/OGApplication.m +++ win32/OGApplication.m @@ -17,11 +17,11 @@ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ - + //================================================================================================================================== // OGApplication.m //================================================================================================================================== #import //this seems to be needed for "OF_APPLICATION_DELEGATE" #import "OGWidget.h" @@ -87,11 +87,11 @@ wcx.hCursor = LoadCursor(NULL, IDC_ARROW); wcx.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcx.lpszMenuName = NULL; wcx.lpszClassName = clsName; wcx.hIconSm = NULL; - + RegisterClassEx(&wcx); //TODO: although this doesn't ever really fail, we should probably Throw an Exception here... //if(!RegisterClassEx(&wcx)) @throw ...; } //================================================================================================================================== @@ -111,9 +111,9 @@ } //================================================================================================================================== LRESULT CALLBACK win32_OGWndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { void *ptr = (void *)GetWindowLong(hwnd, GWL_USERDATA); - if(ptr == NULL) return DefWindowProc(hwnd, msg, wparam, lparam); + if(ptr == NULL) return DefWindowProc(hwnd, msg, wparam, lparam); return [(id)ptr MessageReceived : hwnd : msg : wparam : lparam]; } //================================================================================================================================== Index: win32/OGBox.m ================================================================== --- win32/OGBox.m +++ win32/OGBox.m @@ -18,11 +18,11 @@ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ - + //================================================================================================================================== // OGBox.m //================================================================================================================================== #include #include @@ -79,11 +79,11 @@ } //---------------------------------------------------------------------------------------------------------------------------------- - (int)MessageReceived : (HWND)hwnd : (UINT)msg : (WPARAM)wparam : (LPARAM)lparam { HWND parent; - + switch(msg) { case WM_COMMAND: parent = GetParent(hwnd); if(parent != NULL) Index: win32/OGButton.m ================================================================== --- win32/OGButton.m +++ win32/OGButton.m @@ -17,11 +17,11 @@ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. */ - + //================================================================================================================================== // OGButton.m //================================================================================================================================== #define BCM_GETIDEALSIZE 0x1601 #import "OGButton.h" @@ -52,20 +52,20 @@ } //---------------------------------------------------------------------------------------------------------------------------------- - init { self = [super init]; - + //we're specifying a different class name... //so we'll have to discard the default OGWidget HWND... DestroyWindow(widget); //and create a new one widget = NULL; HINSTANCE hInst = (HINSTANCE)GetModuleHandle(NULL); widget = CreateWindow("button", "", BS_PUSHBUTTON, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, - NULL, NULL, hInst, NULL); + NULL, NULL, hInst, NULL); SetWindowLong(widget, GWL_STYLE, BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP); //crazy workaround since we don't have control of our WNDPROC for default "button"s CommandHandlerData *chd = (CommandHandlerData *)malloc(sizeof(CommandHandlerData)); chd->funct = CH_Command; chd->object = self; @@ -80,11 +80,11 @@ - (OFString*)label { int tlen = GetWindowTextLength(widget); char *buff = (char *)malloc(tlen + 1); GetWindowText(widget, buff, tlen+1); - + OFString *ret = [OFString stringWithUTF8String : buff]; free(buff); return ret; } //---------------------------------------------------------------------------------------------------------------------------------- Index: win32/OGComboBox.m ================================================================== --- win32/OGComboBox.m +++ win32/OGComboBox.m @@ -59,17 +59,17 @@ DestroyWindow(widget); widget = NULL; HINSTANCE hInst = (HINSTANCE)GetModuleHandle(NULL); widget = CreateWindow("LISTBOX", "", LBS_NOINTEGRALHEIGHT, 0, 0, 32, 32, - NULL, NULL, hInst, NULL); + NULL, NULL, hInst, NULL); SetWindowLong(widget, GWL_STYLE, LBS_NOINTEGRALHEIGHT | LBS_NOTIFY | WS_CHILD | WS_VISIBLE | WS_TABSTOP); CommandHandlerData *chd = (CommandHandlerData *)malloc(sizeof(CommandHandlerData)); chd->funct = CH_Command; chd->object = self; SetProp(widget, "CommandHandlerData", chd); - + [self retain]; return self; } //---------------------------------------------------------------------------------------------------------------------------------- - initWithParent : (OGWidget *)parent @@ -80,16 +80,16 @@ DestroyWindow(widget); widget = NULL; HINSTANCE hInst = (HINSTANCE)GetModuleHandle(NULL); widget = CreateWindow("LISTBOX", "", LBS_NOINTEGRALHEIGHT | LBS_NOTIFY | WS_CHILD | WS_VISIBLE, 0, 0, 32, 32, - parent->widget, NULL, hInst, NULL); + parent->widget, NULL, hInst, NULL); CommandHandlerData *chd = (CommandHandlerData *)malloc(sizeof(CommandHandlerData)); chd->funct = CH_Command; chd->object = self; SetProp(widget, "CommandHandlerData", chd); - + [self retain]; return self; } //---------------------------------------------------------------------------------------------------------------------------------- - (id )dataSource @@ -108,11 +108,11 @@ size_t i, size = [dataSource numberOfItemsInComboBox: self]; for (i = 0; i < size; i++) { OGComboBoxItem *item = itemAtIndex(dataSource, @selector(comboBox:itemAtIndex:), self, i); - + SendMessage(widget, LB_ADDSTRING, 0, (WPARAM)[item.label UTF8String]); } } //---------------------------------------------------------------------------------------------------------------------------------- - (void)OG_changed Index: win32/OGHBox.m ================================================================== --- win32/OGHBox.m +++ win32/OGHBox.m @@ -42,29 +42,29 @@ padding: (float)padding { RECT rc; SetParent(child->widget, widget); GetWindowRect(child->widget, &rc); - + 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); newChild->currentSize = (float)(newChild->originalSize + (newChild->padding << 1)); newChild->next = NULL; - + if(firstBorn == NULL) firstBorn = newChild; else { og_box_child_t *curr = firstBorn; while(curr->next != NULL) curr = curr->next; curr->next = newChild; } - + [self OG_resizeChildren]; } //---------------------------------------------------------------------------------------------------------------------------------- - (void)prependChild: (OGWidget*)child expand: (BOOL)expand @@ -72,48 +72,48 @@ padding: (float)padding { RECT rc; SetParent(child->widget, widget); GetWindowRect(child->widget, &rc); - + 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); newChild->currentSize = (float)(newChild->originalSize + (newChild->padding << 1)); newChild->next = firstBorn; - + firstBorn = newChild; - + [self OG_resizeChildren]; } //---------------------------------------------------------------------------------------------------------------------------------- - (void)OG_resizeChildren { RECT rc; og_box_child_t *curr; - + //get our available size GetClientRect(widget, &rc); int width = rc.right; int height = rc.bottom; - + //get total of childrens' widths int childOriginal = 0; curr = firstBorn; while(curr != NULL) { childOriginal += (curr->originalSize + (curr->padding << 1)); curr = curr->next; } - + //how to divide our extra space int extra = width - childOriginal; float evenShare = 0.0f; - + if(extra <= 0) { curr = firstBorn; while(curr != NULL) { @@ -149,11 +149,11 @@ curr->currentSize = (float)curr->originalSize + evenShare; curr = curr->next; } } } - + //assign new positions/heights float x = 0.0f; curr = firstBorn; while(curr != NULL) { @@ -172,11 +172,11 @@ { case WM_SIZE: [self OG_resizeChildren]; return DefWindowProc(hwnd, msg, wparam, lparam); break; - + case WM_SIZING: [self OG_resizeChildren]; return DefWindowProc(hwnd, msg, wparam, lparam); break; } Index: win32/OGVBox.m ================================================================== --- win32/OGVBox.m +++ win32/OGVBox.m @@ -42,29 +42,29 @@ padding: (float)padding { RECT rc; SetParent(child->widget, widget); GetWindowRect(child->widget, &rc); - + 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); newChild->currentSize = (float)(newChild->originalSize + (newChild->padding << 1)); newChild->next = NULL; - + if(firstBorn == NULL) firstBorn = newChild; else { og_box_child_t *curr = firstBorn; while(curr->next != NULL) curr = curr->next; curr->next = newChild; } - + [self OG_resizeChildren]; } //---------------------------------------------------------------------------------------------------------------------------------- - (void)prependChild: (OGWidget*)child expand: (BOOL)expand @@ -72,49 +72,49 @@ padding: (float)padding { RECT rc; SetParent(child->widget, widget); GetWindowRect(child->widget, &rc); - + 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); newChild->currentSize = (float)(newChild->originalSize + (newChild->padding << 1)); newChild->next = firstBorn; - + firstBorn = newChild; - + SetParent(child->widget, widget); [self OG_resizeChildren]; } //---------------------------------------------------------------------------------------------------------------------------------- - (void)OG_resizeChildren { RECT rc; og_box_child_t *curr; - + //get our available size GetClientRect(widget, &rc); int width = rc.right; int height = rc.bottom; - + //get total of childrens' heights int childOriginal = 0; curr = firstBorn; while(curr != NULL) { childOriginal += (curr->originalSize + (curr->padding << 1)); curr = curr->next; } - + //how to divide our extra space int extra = height - childOriginal; float evenShare = 0.0f; - + if(extra <= 0) { curr = firstBorn; while(curr != NULL) { @@ -150,11 +150,11 @@ curr->currentSize = (float)curr->originalSize + evenShare; curr = curr->next; } } } - + //assign new positions/heights float y = 0; curr = firstBorn; while(curr != NULL) { @@ -173,11 +173,11 @@ { case WM_SIZE: [self OG_resizeChildren]; return DefWindowProc(hwnd, msg, wparam, lparam); break; - + case WM_SIZING: [self OG_resizeChildren]; return DefWindowProc(hwnd, msg, wparam, lparam); break; } Index: win32/OGWidget.m ================================================================== --- win32/OGWidget.m +++ win32/OGWidget.m @@ -36,17 +36,17 @@ @implementation OGWidget //---------------------------------------------------------------------------------------------------------------------------------- - init { self = [super init]; - + widget = NULL; HINSTANCE hInst = (HINSTANCE)GetModuleHandle(NULL); widget = CreateWindowEx(WS_EX_LEFT, "OGWidgetClass", "OGWidget", WS_OVERLAPPEDWINDOW, 0, 0, 1, 1, NULL, NULL, hInst, NULL); SetWindowLong(widget, GWL_USERDATA, (int)self); - + @try { if (isa == [OGWidget class]) @throw [OFNotImplementedException exceptionWithClass: isa selector: @selector(init)]; Index: win32/OGWindow.m ================================================================== --- win32/OGWindow.m +++ win32/OGWindow.m @@ -42,11 +42,11 @@ { //it appears this is actually EnumAncestorWindows, and not EnumDirectChildWindows //so make sure child.parent == use HWND parent = (HWND)lparam; if(GetParent(child) != parent) return 1; - + RECT rc; GetClientRect(parent, &rc); SetWindowPos(child, NULL, 0, 0, rc.right, rc.bottom, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER); return 1; @@ -65,21 +65,21 @@ { self = [super init]; SetWindowLong(widget, GWL_EXSTYLE, WS_EX_OVERLAPPEDWINDOW); //"event connections" are handled in MessageReceived - + [self retain]; return self; } //---------------------------------------------------------------------------------------------------------------------------------- - (OFString*)title { int tlen = GetWindowTextLength(widget); char *buff = (char *)malloc(tlen + 1); GetWindowText(widget, buff, tlen+1); - + OFString *ret = [OFString stringWithUTF8String : buff]; free(buff); return ret; } //---------------------------------------------------------------------------------------------------------------------------------- @@ -136,11 +136,11 @@ } //---------------------------------------------------------------------------------------------------------------------------------- - (int)MessageReceived : (HWND)hwnd : (UINT)msg : (WPARAM)wparam : (LPARAM)lparam { HWND ctrlHwnd; - + switch(msg) { case WM_COMMAND: //NOTE: TODO: IMPLEMENT: this may need revised later for Menus and Accelerators ctrlHwnd = (HWND)lparam; @@ -148,22 +148,22 @@ if(chd == NULL) return DefWindowProc(hwnd, msg, wparam, lparam); if(chd->funct == NULL) return DefWindowProc(hwnd, msg, wparam, lparam); chd->funct(chd->object, wparam); return 0; break; - + case WM_CLOSE: if([self OG_willClose] == YES) og_destroy(hwnd, self); return 0; break; - + case WM_SIZE: //act like GTK; expand our child(ren) to fit EnumChildWindows(widget, Resize_EnumChildren, (LPARAM)widget); break; - + case WM_SIZING: //act like GTK; expand our child(ren) to fit EnumChildWindows(widget, Resize_EnumChildren, (LPARAM)widget); break; } Index: win32/test.m ================================================================== --- win32/test.m +++ win32/test.m @@ -36,17 +36,17 @@ @end @implementation TestSource - init { self = [super init]; - + items = (OGComboBoxItem **)malloc(sizeof(OGComboBoxItem *) << 2); items[0] = [OGComboBoxItem comboBoxItemWithLabel : @"Test Combo Item 0"]; items[1] = [OGComboBoxItem comboBoxItemWithLabel : @"Test Combo Item 1"]; items[2] = [OGComboBoxItem comboBoxItemWithLabel : @"Test Combo Item 2"]; items[3] = [OGComboBoxItem comboBoxItemWithLabel : @"Test Combo Item 3"]; - + [self retain]; return self; } - (size_t)numberOfItemsInComboBox: (OGComboBox*)comboBox { @@ -87,11 +87,11 @@ b.delegate = self; [hboxPre appendChild: b expand: YES fill: YES padding: 0]; - + OGComboBox *cb = [[OGComboBox alloc] initWithParent : hboxPre]; cb.dataSource = [[TestSource alloc] init]; cb.delegate = self; [hboxPre appendChild: cb expand: YES