From 1fc9f137bc7ad54333e549f9db3872710c711752 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sun, 4 Mar 2018 19:51:45 -0500 Subject: [PATCH] Migrated fontbutton.m back. --- darwin/{OLD_fontbutton.m => fontbutton.m} | 27 ++++++++++++----------- darwin/main.m | 6 ++--- darwin/uipriv_darwin.h | 6 ++--- 3 files changed, 20 insertions(+), 19 deletions(-) rename darwin/{OLD_fontbutton.m => fontbutton.m} (87%) diff --git a/darwin/OLD_fontbutton.m b/darwin/fontbutton.m similarity index 87% rename from darwin/OLD_fontbutton.m rename to darwin/fontbutton.m index 433f261f..38205135 100644 --- a/darwin/OLD_fontbutton.m +++ b/darwin/fontbutton.m @@ -1,7 +1,8 @@ // 14 april 2016 #import "uipriv_darwin.h" +#import "attrstr.h" -@interface fontButton : NSButton { +@interface uiprivFontButton : NSButton { uiFontButton *libui_b; NSFont *libui_font; } @@ -15,16 +16,16 @@ @end // only one may be active at one time -static fontButton *activeFontButton = nil; +static uiprivFontButton *activeFontButton = nil; struct uiFontButton { uiDarwinControl c; - fontButton *button; + uiprivFontButton *button; void (*onChanged)(uiFontButton *, void *); void *onChangedData; }; -@implementation fontButton +@implementation uiprivFontButton - (id)initWithFrame:(NSRect)frame libuiFontButton:(uiFontButton *)b { @@ -145,7 +146,7 @@ struct uiFontButton { ctfont = (CTFontRef) (self->libui_font); ctdesc = CTFontCopyFontDescriptor(ctfont); - fontdescFromCTFontDescriptor(ctdesc, uidesc); + uiprivDrawFontDescriptorFromCTFontDescriptor(ctdesc, uidesc); CFRelease(ctdesc); uidesc->Size = CTFontGetSize(ctfont); } @@ -156,16 +157,16 @@ uiDarwinControlAllDefaults(uiFontButton, button) // we do not want font change events to be sent to any controls other than the font buttons // see main.m for more details -BOOL fontButtonInhibitSendAction(SEL sel, id from, id to) +BOOL uiprivFontButtonInhibitSendAction(SEL sel, id from, id to) { if (sel != @selector(changeFont:)) return NO; - return ![to isKindOfClass:[fontButton class]]; + return ![to isKindOfClass:[uiprivFontButton class]]; } // we do not want NSFontPanelValidation messages to be sent to any controls other than the font buttons when a font button is active // see main.m for more details -BOOL fontButtonOverrideTargetForAction(SEL sel, id from, id to, id *override) +BOOL uiprivFontButtonOverrideTargetForAction(SEL sel, id from, id to, id *override) { if (activeFontButton == nil) return NO; @@ -177,10 +178,10 @@ BOOL fontButtonOverrideTargetForAction(SEL sel, id from, id to, id *override) // we also don't want the panel to be usable when there's a dialog running; see stddialogs.m for more details on that // unfortunately the panel seems to ignore -setWorksWhenModal: so we'll have to do things ourselves -@interface nonModalFontPanel : NSFontPanel +@interface uiprivNonModalFontPanel : NSFontPanel @end -@implementation nonModalFontPanel +@implementation uiprivNonModalFontPanel - (BOOL)worksWhenModal { @@ -189,9 +190,9 @@ BOOL fontButtonOverrideTargetForAction(SEL sel, id from, id to, id *override) @end -void setupFontPanel(void) +void uiprivSetupFontPanel(void) { - [NSFontManager setFontPanelFactory:[nonModalFontPanel class]]; + [NSFontManager setFontPanelFactory:[uiprivNonModalFontPanel class]]; } static void defaultOnChanged(uiFontButton *b, void *data) @@ -216,7 +217,7 @@ uiFontButton *uiNewFontButton(void) uiDarwinNewControl(uiFontButton, b); - b->button = [[fontButton alloc] initWithFrame:NSZeroRect libuiFontButton:b]; + b->button = [[uiprivFontButton alloc] initWithFrame:NSZeroRect libuiFontButton:b]; uiDarwinSetControlFont(b->button, NSRegularControlSize); uiFontButtonOnChanged(b, defaultOnChanged, NULL); diff --git a/darwin/main.m b/darwin/main.m index d85000dd..12c528ff 100644 --- a/darwin/main.m +++ b/darwin/main.m @@ -26,7 +26,7 @@ static BOOL stepsIsRunning; { if (colorButtonInhibitSendAction(sel, from, to)) return NO; - if (fontButtonInhibitSendAction(sel, from, to)) + if (uiprivFontButtonInhibitSendAction(sel, from, to)) return NO; return [super sendAction:sel to:to from:from]; } @@ -38,7 +38,7 @@ static BOOL stepsIsRunning; { id override; - if (fontButtonOverrideTargetForAction(sel, from, to, &override)) + if (uiprivFontButtonOverrideTargetForAction(sel, from, to, &override)) return override; return [super targetForAction:sel to:to from:from]; } @@ -126,7 +126,7 @@ const char *uiInit(uiInitOptions *o) appDelegate().menuManager = [[menuManager new] autorelease]; [realNSApp() setMainMenu:[appDelegate().menuManager makeMenubar]]; - setupFontPanel(); + uiprivSetupFontPanel(); initUnderlineColors(); } diff --git a/darwin/uipriv_darwin.h b/darwin/uipriv_darwin.h index 4d5ebdc3..0711c68b 100644 --- a/darwin/uipriv_darwin.h +++ b/darwin/uipriv_darwin.h @@ -111,9 +111,9 @@ extern uiDrawContext *newContext(CGContextRef, CGFloat); extern void freeContext(uiDrawContext *); // fontbutton.m -extern BOOL fontButtonInhibitSendAction(SEL sel, id from, id to); -extern BOOL fontButtonOverrideTargetForAction(SEL sel, id from, id to, id *override); -extern void setupFontPanel(void); +extern BOOL uiprivFontButtonInhibitSendAction(SEL sel, id from, id to); +extern BOOL uiprivFontButtonOverrideTargetForAction(SEL sel, id from, id to, id *override); +extern void uiprivSetupFontPanel(void); // colorbutton.m extern BOOL colorButtonInhibitSendAction(SEL sel, id from, id to);