From 82101036b8b2686ec0394908434629ab6a0b9903 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Thu, 15 May 2014 21:16:28 -0400 Subject: [PATCH] Removed the control font code from bleh_darwin.m and rewrote it in Objective-C in sysdata_darwin.m. --- bleh_darwin.m | 16 ---------------- listbox_darwin.m | 4 ++-- objc_darwin.h | 3 --- sysdata_darwin.m | 6 ++++-- 4 files changed, 6 insertions(+), 23 deletions(-) diff --git a/bleh_darwin.m b/bleh_darwin.m index 41bf839..ca98ffd 100644 --- a/bleh_darwin.m +++ b/bleh_darwin.m @@ -172,19 +172,3 @@ 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 CGFloat (*objc_msgSend_cgfloatret)(id, SEL, ...) = - (CGFloat (*)(id, SEL, ...)) objc_msgSend_fpret; - -void objc_setFont(id what, unsigned int csize) -{ - CGFloat size; - - 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/listbox_darwin.m b/listbox_darwin.m index 0a5ba97..60cc25e 100644 --- a/listbox_darwin.m +++ b/listbox_darwin.m @@ -85,8 +85,8 @@ id makeListboxTableColumn(id identifier) [column setEditable:NO]; // to set the font for each item, we set the font of the "data cell", which is more aptly called the "cell template" dataCell = [column dataCell]; - // TODO pull the one from sysdata_darwin.m - objc_setFont(dataCell, NSRegularControlSize); + // technically not a NSControl, but still accepts the selector, so we can call it anyway + applyStandardControlFont(dataCell); [column setDataCell:dataCell]; // TODO other properties? return column; diff --git a/objc_darwin.h b/objc_darwin.h index fb12203..5eb9b6c 100644 --- a/objc_darwin.h +++ b/objc_darwin.h @@ -62,7 +62,4 @@ extern struct xpoint getTranslatedEventPoint(id, id); /* for objc_darwin.go */ extern char *encodedNSRect; -/* for sysdata_darwin.go */ -extern void objc_setFont(id, unsigned int); - #endif diff --git a/sysdata_darwin.m b/sysdata_darwin.m index e2684cb..3c1124b 100644 --- a/sysdata_darwin.m +++ b/sysdata_darwin.m @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -49,10 +50,11 @@ void controlHide(id what) [toNSView(what) setHidden:YES]; } +#define systemFontOfSize(s) ([NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:(s)]]) + void applyStandardControlFont(id what) { - // TODO inline this - objc_setFont(what, NSRegularControlSize); + [toNSControl(what) setFont:systemFontOfSize(NSRegularControlSize)]; } id makeWindow(id delegate)