diff options
| author | Pietro Gagliardi <[email protected]> | 2014-04-04 14:52:38 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-04-04 14:52:38 -0400 |
| commit | be668a965a382fc1de2f9711282b5ec897d55ca5 (patch) | |
| tree | 23a3e1403cf313ee9b65b21a9178b81400d22a81 /bleh_darwin.m | |
| parent | 2884d45f0f05fd19442aa2396c55fc97182d3afc (diff) | |
Fixed Mac OS X Button appearance; turns out it was using the wrong font. Also updated the TODO file to mark this fix and remove other stale/already fixed details.
Diffstat (limited to 'bleh_darwin.m')
| -rw-r--r-- | bleh_darwin.m | 31 |
1 files changed, 31 insertions, 0 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)); +} |
