summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bleh_darwin.m31
-rw-r--r--objc_darwin.h3
-rw-r--r--sysdata_darwin.go5
-rw-r--r--todo.md6
4 files changed, 40 insertions, 5 deletions
diff --git a/bleh_darwin.m b/bleh_darwin.m
index 720da0f..e4b774f 100644
--- a/bleh_darwin.m
+++ b/bleh_darwin.m
@@ -21,6 +21,7 @@ Go wrapper functions (bleh_darwin.go) call these directly and take care of stdin
#include <AppKit/NSEvent.h>
#include <AppKit/NSGraphics.h>
#include <AppKit/NSBitmapImageRep.h>
+#include <AppKit/NSCell.h>
/* exception to the above: cgo doesn't like Nil and delegate_darwin.go has //export so I can't have this there */
Class NilClass = Nil;
@@ -317,3 +318,33 @@ struct xpoint getTranslatedEventPoint(id self, id event)
ret.y = (int64_t) p.y;
return ret;
}
+
+/*
+we don't need this here technically — it can be done in Go just fine — but it's easier here
+*/
+
+static id c_NSFont;
+static SEL s_setFont;
+static SEL s_systemFontOfSize;
+static SEL s_systemFontSizeForControlSize;
+static BOOL setFont_init = NO;
+
+static CGFloat (*objc_msgSend_cgfloatret)(id, SEL, ...) =
+ (CGFloat (*)(id, SEL, ...)) objc_msgSend_fpret;
+
+void objc_setFont(id what, unsigned int csize)
+{
+ CGFloat size;
+
+ if (setFont_init == NO) {
+ c_NSFont = objc_getClass("NSFont");
+ s_setFont = sel_getUid("setFont:");
+ s_systemFontOfSize = sel_getUid("systemFontOfSize:");
+ s_systemFontSizeForControlSize = sel_getUid("systemFontSizeForControlSize:");
+ setFont_init = YES;
+ }
+
+ size = objc_msgSend_cgfloatret(c_NSFont, s_systemFontSizeForControlSize, (NSControlSize) csize);
+ objc_msgSend(what, s_setFont,
+ objc_msgSend(c_NSFont, s_systemFontOfSize, size));
+}
diff --git a/objc_darwin.h b/objc_darwin.h
index 0583d37..c999fe9 100644
--- a/objc_darwin.h
+++ b/objc_darwin.h
@@ -117,4 +117,7 @@ extern BOOL addAreaViewDrawMethod(Class);
extern void drawImage(void *, int64_t, int64_t, int64_t, int64_t, int64_t);
extern struct xpoint getTranslatedEventPoint(id, id);
+/* for sysdata_darwin.go */
+extern void objc_setFont(id, unsigned int);
+
#endif
diff --git a/sysdata_darwin.go b/sysdata_darwin.go
index 3cb0ada..09b7730 100644
--- a/sysdata_darwin.go
+++ b/sysdata_darwin.go
@@ -118,7 +118,7 @@ var classTypes = [nctypes]*classData{
C.BOOL(C.YES)) // defer creation of device until we show the window
objc_setDelegate(win, appDelegate)
// this is needed for Areas in the window to receive mouse move events
- C.objc_msgSend_bool(win, _setAcceptsMouseMovedEvents, C.BOOL(C.YES))
+// C.objc_msgSend_bool(win, _setAcceptsMouseMovedEvents, C.BOOL(C.YES))
return win
},
show: func(what C.id) {
@@ -139,6 +139,9 @@ var classTypes = [nctypes]*classData{
objc_msgSend_uint(button, _setBezelStyle, 1) // NSRoundedBezelStyle
C.objc_msgSend_id(button, _setTarget, appDelegate)
C.objc_msgSend_sel(button, _setAction, _buttonClicked)
+ // by default the button uses the wrong text size
+ // TODO do this for all controls
+ C.objc_setFont(button, 0) // NSRegularControlSize
addControl(parentWindow, button)
return button
},
diff --git a/todo.md b/todo.md
index 0cacb2d..f84178a 100644
--- a/todo.md
+++ b/todo.md
@@ -28,18 +28,16 @@ important things:
- because the main event loop is not called if initialization fails, it is presently impossible for MsgBoxError() to work if UI initialization fails; this basically means we cannot allow initializiation to fail on Mac OS X if we want to be able to report UI init failures to the user with one (which would be desirable, maybe (would violate Windows HIG?))
- figure out where to auto-place windows in Cocoa (also window coordinates are still not flipped properly so (0,0) on screen is the bottom-left)
- also provide a method to center windows; Cocoa provides one for us but
-- I think Cocoa NSButton text is not vertically aligned properly...?
- - and listbox item text is too low?
+- I think Cocoa listbox item text is too low?
- NSPopUpButton does allow no initial selection ([b setSelectedIndex:-1]); use it
- need to use it /after/ adding initial items, otherwise it won't work
- find out if I can do the same with the ListBoxes
- NSComboBox scans the entered text to see if it matches one of the items and returns the index of that item if it does; find out how to suppress this so that it returns -1 unless the item was chosen from the list (like the other platforms)
-- some Cocoa controls don't seem to resize correctly: Buttons have space around the edges and don't satisfy stretchiness
+- some Cocoa controls don't seem to resize correctly: Buttons have space around the edges
- make sure GTK+ documentation version point differences (x in 4.3.x) don't matter
- LineEdit heights on Windows seem too big; either that or LineEdit, Button, and Label text is not vertically centered properly
- are Checkboxes and Comboboxes too small?
- Cocoa has similar margining issues (like Comboboxes having margins)
- - oh, because message boxes use a different font on Windows 7 now, apparently?... Microsoft... TODO find out for sure
- sometimes the size of the drop-down part of a Combobox becomes 0 or 1 or some other impossibly small value on Windows
- make gcc (Unix)/clang (Mac OS X) pedantic about warnings/errors; also -Werror
- make sure scrollbars in Listbox work identically on all platforms (specifically the existence and autohiding of both horizontal and vertical scrollbars)