diff options
| author | Pietro Gagliardi <[email protected]> | 2014-06-25 16:32:07 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-06-25 16:32:07 -0400 |
| commit | c0d6293191845294beda76316071bbc5a39028c3 (patch) | |
| tree | 74ad8a1f88e200a2ca1dff3eb178af8088a3aaf1 /prefsize_darwin.go | |
| parent | 76781bc0dedd7d45a070fc12f9e2c9643b9c23d9 (diff) | |
(Somewhat hackily) implemented the new label rules on Mac OS X.
Diffstat (limited to 'prefsize_darwin.go')
| -rw-r--r-- | prefsize_darwin.go | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/prefsize_darwin.go b/prefsize_darwin.go index 629a748..4e10a6a 100644 --- a/prefsize_darwin.go +++ b/prefsize_darwin.go @@ -10,40 +10,46 @@ Cocoa doesn't provide a reliable way to get the preferred size of a control (you */ // 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) +func controlPrefSize(control C.id, alternate C.BOOL) (width int, height int, yoff int) { + r := C.controlPrefSize(control, alternate) + return int(r.width), int(r.height), int(r.yoff) +} + +// Labels have special yoff calculation +func labelPrefSize(control C.id, alternate C.BOOL) (width int, height int, yoff int) { + r := C.labelPrefSize(control, alternate) + return int(r.width), int(r.height), int(r.yoff) } // 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) - return int(r.width), int(r.height) +func listboxPrefSize(control C.id, alternate C.BOOL) (width int, height int, yoff int) { + r := C.listboxPrefSize(control, alternate) + return int(r.width), int(r.height), int(r.yoff) } // 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) +func pbarPrefSize(control C.id, alternate C.BOOL) (width int, height int, yoff int) { + r := C.pbarPrefSize(control, alternate) + return int(r.width), int(r.height), int(r.yoff) } // 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) +func areaPrefSize(control C.id, alternate C.BOOL) (width int, height int, yoff int) { + r := C.areaPrefSize(control, alternate) + return int(r.width), int(r.height), int(r.yoff) } -var prefsizefuncs = [nctypes]func(C.id) (int, int){ +var prefsizefuncs = [nctypes]func(C.id, C.BOOL) (int, int, int){ c_button: controlPrefSize, c_checkbox: controlPrefSize, c_combobox: controlPrefSize, c_lineedit: controlPrefSize, - c_label: controlPrefSize, + c_label: labelPrefSize, c_listbox: listboxPrefSize, c_progressbar: pbarPrefSize, c_area: areaPrefSize, } -func (s *sysData) preferredSize() (width int, height int) { - return prefsizefuncs[s.ctype](s.id) +func (s *sysData) preferredSize() (width int, height int, yoff int) { + return prefsizefuncs[s.ctype](s.id, toBOOL(s.alternate)) } |
