Same, but for OS X.

This commit is contained in:
Pietro Gagliardi 2015-05-07 13:48:41 -04:00
parent 38a5341603
commit 7270b54e81
4 changed files with 11 additions and 12 deletions

View File

@ -1,4 +1,3 @@
- change all private names away from uiXxxx and uipXxxx
- make it so Windows API calls that do logLastError(), etc. abort whatever they're doing and not try to continue, just like wintable
- figure out what to cleanup in darwin terminate:
- delegate

View File

@ -1,7 +1,7 @@
// 7 april 2015
#import "uipriv_darwin.h"
@interface uipButtonDelegate : NSObject {
@interface buttonDelegate : NSObject {
uiButton *b;
void (*onClicked)(uiButton *, void *);
void *onClickedData;
@ -11,7 +11,7 @@
- (void)setOnClicked:(void (*)(uiButton *, void *))f data:(void *)data;
@end
@implementation uipButtonDelegate
@implementation buttonDelegate
- (IBAction)buttonClicked:(id)sender
{
@ -34,7 +34,7 @@
struct button {
uiButton b;
NSButton *button;
uipButtonDelegate *delegate;
buttonDelegate *delegate;
};
static void defaultOnClicked(uiButton *b, void *data)
@ -88,7 +88,7 @@ uiButton *uiNewButton(const char *text)
[b->button setBezelStyle:NSRoundedBezelStyle];
setStandardControlFont(b->button);
b->delegate = [uipButtonDelegate new];
b->delegate = [buttonDelegate new];
[b->button setTarget:b->delegate];
[b->button setAction:@selector(buttonClicked:)];
[b->delegate setButton:uiButton(b)];

View File

@ -1,7 +1,7 @@
// 7 april 2015
#import "uipriv_darwin.h"
@interface uipCheckboxDelegate : NSObject {
@interface checkboxDelegate : NSObject {
uiCheckbox *c;
void (*onToggled)(uiCheckbox *, void *);
void *onToggledData;
@ -11,7 +11,7 @@
- (void)setOnToggled:(void (*)(uiCheckbox *, void *))f data:(void *)data;
@end
@implementation uipCheckboxDelegate
@implementation checkboxDelegate
- (IBAction)checkboxToggled:(id)sender
{
@ -34,7 +34,7 @@
struct checkbox {
uiCheckbox c;
NSButton *checkbox;
uipCheckboxDelegate *delegate;
checkboxDelegate *delegate;
};
static void defaultOnToggled(uiCheckbox *c, void *data)
@ -105,7 +105,7 @@ uiCheckbox *uiNewCheckbox(const char *text)
[c->checkbox setBordered:NO];
setStandardControlFont(c->checkbox);
c->delegate = [uipCheckboxDelegate new];
c->delegate = [checkboxDelegate new];
[c->checkbox setTarget:c->delegate];
[c->checkbox setAction:@selector(checkboxToggled:)];
[c->delegate setCheckbox:uiCheckbox(c)];

View File

@ -1,10 +1,10 @@
// 6 april 2015
#import "uipriv_darwin.h"
@interface uiApplication : NSApplication
@interface applicationClass : NSApplication
@end
@implementation uiApplication
@implementation applicationClass
// hey look! we're overriding terminate:!
// we're going to make sure we can go back to main() whether Cocoa likes it or not!
@ -47,7 +47,7 @@ uiInitOptions options;
const char *uiInit(uiInitOptions *o)
{
options = *o;
[uiApplication sharedApplication];
[applicationClass sharedApplication];
// don't check for a NO return; something (launch services?) causes running from application bundles to always return NO when asking to change activation policy, even if the change is to the same activation policy!
// see https://github.com/andlabs/ui/issues/6
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];