diff options
author | RSDuck <RSDuck@users.noreply.github.com> | 2020-05-12 16:07:28 +0200 |
---|---|---|
committer | RSDuck <rsduck@users.noreply.github.com> | 2020-06-16 12:06:42 +0200 |
commit | e7d076403df7afd6dc8304196211b49e3ed7f464 (patch) | |
tree | 1d5ff1e743839f271de77f8bd312c985033c6a89 /src/libui_sdl/libui/darwin/button.m | |
parent | 4cff4b52286a7d1a7e40817d52a5d271a937ddc2 (diff) | |
parent | c17f7b100e36edb1c728dbf21c77f9484d1820c6 (diff) |
Merge branch 'generic_jit' of https://github.com/Arisotura/melonDS into generic_jit
Diffstat (limited to 'src/libui_sdl/libui/darwin/button.m')
-rw-r--r-- | src/libui_sdl/libui/darwin/button.m | 113 |
1 files changed, 0 insertions, 113 deletions
diff --git a/src/libui_sdl/libui/darwin/button.m b/src/libui_sdl/libui/darwin/button.m deleted file mode 100644 index baccabb..0000000 --- a/src/libui_sdl/libui/darwin/button.m +++ /dev/null @@ -1,113 +0,0 @@ -// 13 august 2015 -#import "uipriv_darwin.h" - -struct uiButton { - uiDarwinControl c; - NSButton *button; - void (*onClicked)(uiButton *, void *); - void *onClickedData; -}; - -@interface buttonDelegateClass : NSObject { - struct mapTable *buttons; -} -- (IBAction)onClicked:(id)sender; -- (void)registerButton:(uiButton *)b; -- (void)unregisterButton:(uiButton *)b; -@end - -@implementation buttonDelegateClass - -- (id)init -{ - self = [super init]; - if (self) - self->buttons = newMap(); - return self; -} - -- (void)dealloc -{ - mapDestroy(self->buttons); - [super dealloc]; -} - -- (IBAction)onClicked:(id)sender -{ - uiButton *b; - - b = (uiButton *) mapGet(self->buttons, sender); - (*(b->onClicked))(b, b->onClickedData); -} - -- (void)registerButton:(uiButton *)b -{ - mapSet(self->buttons, b->button, b); - [b->button setTarget:self]; - [b->button setAction:@selector(onClicked:)]; -} - -- (void)unregisterButton:(uiButton *)b -{ - [b->button setTarget:nil]; - mapDelete(self->buttons, b->button); -} - -@end - -static buttonDelegateClass *buttonDelegate = nil; - -uiDarwinControlAllDefaultsExceptDestroy(uiButton, button) - -static void uiButtonDestroy(uiControl *c) -{ - uiButton *b = uiButton(c); - - [buttonDelegate unregisterButton:b]; - [b->button release]; - uiFreeControl(uiControl(b)); -} - -char *uiButtonText(uiButton *b) -{ - return uiDarwinNSStringToText([b->button title]); -} - -void uiButtonSetText(uiButton *b, const char *text) -{ - [b->button setTitle:toNSString(text)]; -} - -void uiButtonOnClicked(uiButton *b, void (*f)(uiButton *, void *), void *data) -{ - b->onClicked = f; - b->onClickedData = data; -} - -static void defaultOnClicked(uiButton *b, void *data) -{ - // do nothing -} - -uiButton *uiNewButton(const char *text) -{ - uiButton *b; - - uiDarwinNewControl(uiButton, b); - - b->button = [[NSButton alloc] initWithFrame:NSZeroRect]; - [b->button setTitle:toNSString(text)]; - [b->button setButtonType:NSMomentaryPushInButton]; - [b->button setBordered:YES]; - [b->button setBezelStyle:NSRoundedBezelStyle]; - uiDarwinSetControlFont(b->button, NSRegularControlSize); - - if (buttonDelegate == nil) { - buttonDelegate = [[buttonDelegateClass new] autorelease]; - [delegates addObject:buttonDelegate]; - } - [buttonDelegate registerButton:b]; - uiButtonOnClicked(b, defaultOnClicked, NULL); - - return b; -} |