From 0b4c6a9228b5d6c3a69ff55a7b989f8d744b6756 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Thu, 26 Jun 2014 03:24:27 -0400 Subject: Finished implementing the new control sizing system on Mac OS X. The new label behavior needs to be reimplemented next. --- prefsize_darwin.go | 49 ------------------------------------------------- 1 file changed, 49 deletions(-) delete mode 100644 prefsize_darwin.go (limited to 'prefsize_darwin.go') diff --git a/prefsize_darwin.go b/prefsize_darwin.go deleted file mode 100644 index b37e6f6..0000000 --- a/prefsize_darwin.go +++ /dev/null @@ -1,49 +0,0 @@ -// 1 march 2014 - -package ui - -// #include "objc_darwin.h" -import "C" - -/* -Cocoa doesn't provide a reliable way to get the preferred size of a control (you're supposed to use Interface Builder and have it set up autoresizing for you). The best we can do is call [control sizeToFit] (which is defined for NSControls and has a custom implementation for the other types here) and read the preferred size. Though this changes the size, we're immediately overriding the change on return from sysData.preferredSize(), so no harm done. (This is similar to what we are doing with GTK+, except GTK+ does not actually change the size.) -*/ - -// standard case: control immediately passed in -func controlPrefSize(control C.id) (width int, height int) { - r := C.controlPrefSize(control) - return int(r.width), int(r.height) -} - -// NSTableView is actually in a NSScrollView so we have to get it out first -func listboxPrefSize(control C.id) (width int, height int) { - r := C.listboxPrefSize(control, alternate) - return int(r.width), int(r.height) -} - -// and for type checking reasons, progress bars are separate despite responding to -[sizeToFit] -func pbarPrefSize(control C.id) (width int, height int) { - r := C.pbarPrefSize(control) - return int(r.width), int(r.height) -} - -// Areas know their own preferred size -func areaPrefSize(control C.id) (width int, height int) { - r := C.areaPrefSize(control) - return int(r.width), int(r.height) -} - -var prefsizefuncs = [nctypes]func(C.id) (int, int){ - c_button: controlPrefSize, - c_checkbox: controlPrefSize, - c_combobox: controlPrefSize, - c_lineedit: controlPrefSize, - c_label: controlPrefSize, - c_listbox: listboxPrefSize, - c_progressbar: pbarPrefSize, - c_area: areaPrefSize, -} - -func (s *sysData) preferredSize() (width int, height int) { - return prefsizefuncs[s.ctype](s.id) -} -- cgit v1.2.3