Migrated fontbutton.m back.
This commit is contained in:
parent
0b3176cead
commit
1fc9f137bc
|
@ -1,7 +1,8 @@
|
||||||
// 14 april 2016
|
// 14 april 2016
|
||||||
#import "uipriv_darwin.h"
|
#import "uipriv_darwin.h"
|
||||||
|
#import "attrstr.h"
|
||||||
|
|
||||||
@interface fontButton : NSButton {
|
@interface uiprivFontButton : NSButton {
|
||||||
uiFontButton *libui_b;
|
uiFontButton *libui_b;
|
||||||
NSFont *libui_font;
|
NSFont *libui_font;
|
||||||
}
|
}
|
||||||
|
@ -15,16 +16,16 @@
|
||||||
@end
|
@end
|
||||||
|
|
||||||
// only one may be active at one time
|
// only one may be active at one time
|
||||||
static fontButton *activeFontButton = nil;
|
static uiprivFontButton *activeFontButton = nil;
|
||||||
|
|
||||||
struct uiFontButton {
|
struct uiFontButton {
|
||||||
uiDarwinControl c;
|
uiDarwinControl c;
|
||||||
fontButton *button;
|
uiprivFontButton *button;
|
||||||
void (*onChanged)(uiFontButton *, void *);
|
void (*onChanged)(uiFontButton *, void *);
|
||||||
void *onChangedData;
|
void *onChangedData;
|
||||||
};
|
};
|
||||||
|
|
||||||
@implementation fontButton
|
@implementation uiprivFontButton
|
||||||
|
|
||||||
- (id)initWithFrame:(NSRect)frame libuiFontButton:(uiFontButton *)b
|
- (id)initWithFrame:(NSRect)frame libuiFontButton:(uiFontButton *)b
|
||||||
{
|
{
|
||||||
|
@ -145,7 +146,7 @@ struct uiFontButton {
|
||||||
|
|
||||||
ctfont = (CTFontRef) (self->libui_font);
|
ctfont = (CTFontRef) (self->libui_font);
|
||||||
ctdesc = CTFontCopyFontDescriptor(ctfont);
|
ctdesc = CTFontCopyFontDescriptor(ctfont);
|
||||||
fontdescFromCTFontDescriptor(ctdesc, uidesc);
|
uiprivDrawFontDescriptorFromCTFontDescriptor(ctdesc, uidesc);
|
||||||
CFRelease(ctdesc);
|
CFRelease(ctdesc);
|
||||||
uidesc->Size = CTFontGetSize(ctfont);
|
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
|
// we do not want font change events to be sent to any controls other than the font buttons
|
||||||
// see main.m for more details
|
// 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:))
|
if (sel != @selector(changeFont:))
|
||||||
return NO;
|
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
|
// 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
|
// 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)
|
if (activeFontButton == nil)
|
||||||
return NO;
|
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
|
// 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
|
// unfortunately the panel seems to ignore -setWorksWhenModal: so we'll have to do things ourselves
|
||||||
@interface nonModalFontPanel : NSFontPanel
|
@interface uiprivNonModalFontPanel : NSFontPanel
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation nonModalFontPanel
|
@implementation uiprivNonModalFontPanel
|
||||||
|
|
||||||
- (BOOL)worksWhenModal
|
- (BOOL)worksWhenModal
|
||||||
{
|
{
|
||||||
|
@ -189,9 +190,9 @@ BOOL fontButtonOverrideTargetForAction(SEL sel, id from, id to, id *override)
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
void setupFontPanel(void)
|
void uiprivSetupFontPanel(void)
|
||||||
{
|
{
|
||||||
[NSFontManager setFontPanelFactory:[nonModalFontPanel class]];
|
[NSFontManager setFontPanelFactory:[uiprivNonModalFontPanel class]];
|
||||||
}
|
}
|
||||||
|
|
||||||
static void defaultOnChanged(uiFontButton *b, void *data)
|
static void defaultOnChanged(uiFontButton *b, void *data)
|
||||||
|
@ -216,7 +217,7 @@ uiFontButton *uiNewFontButton(void)
|
||||||
|
|
||||||
uiDarwinNewControl(uiFontButton, b);
|
uiDarwinNewControl(uiFontButton, b);
|
||||||
|
|
||||||
b->button = [[fontButton alloc] initWithFrame:NSZeroRect libuiFontButton:b];
|
b->button = [[uiprivFontButton alloc] initWithFrame:NSZeroRect libuiFontButton:b];
|
||||||
uiDarwinSetControlFont(b->button, NSRegularControlSize);
|
uiDarwinSetControlFont(b->button, NSRegularControlSize);
|
||||||
|
|
||||||
uiFontButtonOnChanged(b, defaultOnChanged, NULL);
|
uiFontButtonOnChanged(b, defaultOnChanged, NULL);
|
|
@ -26,7 +26,7 @@ static BOOL stepsIsRunning;
|
||||||
{
|
{
|
||||||
if (colorButtonInhibitSendAction(sel, from, to))
|
if (colorButtonInhibitSendAction(sel, from, to))
|
||||||
return NO;
|
return NO;
|
||||||
if (fontButtonInhibitSendAction(sel, from, to))
|
if (uiprivFontButtonInhibitSendAction(sel, from, to))
|
||||||
return NO;
|
return NO;
|
||||||
return [super sendAction:sel to:to from:from];
|
return [super sendAction:sel to:to from:from];
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ static BOOL stepsIsRunning;
|
||||||
{
|
{
|
||||||
id override;
|
id override;
|
||||||
|
|
||||||
if (fontButtonOverrideTargetForAction(sel, from, to, &override))
|
if (uiprivFontButtonOverrideTargetForAction(sel, from, to, &override))
|
||||||
return override;
|
return override;
|
||||||
return [super targetForAction:sel to:to from:from];
|
return [super targetForAction:sel to:to from:from];
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ const char *uiInit(uiInitOptions *o)
|
||||||
appDelegate().menuManager = [[menuManager new] autorelease];
|
appDelegate().menuManager = [[menuManager new] autorelease];
|
||||||
[realNSApp() setMainMenu:[appDelegate().menuManager makeMenubar]];
|
[realNSApp() setMainMenu:[appDelegate().menuManager makeMenubar]];
|
||||||
|
|
||||||
setupFontPanel();
|
uiprivSetupFontPanel();
|
||||||
|
|
||||||
initUnderlineColors();
|
initUnderlineColors();
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,9 +111,9 @@ extern uiDrawContext *newContext(CGContextRef, CGFloat);
|
||||||
extern void freeContext(uiDrawContext *);
|
extern void freeContext(uiDrawContext *);
|
||||||
|
|
||||||
// fontbutton.m
|
// fontbutton.m
|
||||||
extern BOOL fontButtonInhibitSendAction(SEL sel, id from, id to);
|
extern BOOL uiprivFontButtonInhibitSendAction(SEL sel, id from, id to);
|
||||||
extern BOOL fontButtonOverrideTargetForAction(SEL sel, id from, id to, id *override);
|
extern BOOL uiprivFontButtonOverrideTargetForAction(SEL sel, id from, id to, id *override);
|
||||||
extern void setupFontPanel(void);
|
extern void uiprivSetupFontPanel(void);
|
||||||
|
|
||||||
// colorbutton.m
|
// colorbutton.m
|
||||||
extern BOOL colorButtonInhibitSendAction(SEL sel, id from, id to);
|
extern BOOL colorButtonInhibitSendAction(SEL sel, id from, id to);
|
||||||
|
|
Loading…
Reference in New Issue