Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Unified Diff: src/views/mac/skia_mac.mm

Issue 1184143011: nibless mac, visual bench working on mac (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix HelloWorld compile on windows Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/views/mac/SkOSWindow_Mac.mm ('k') | tools/VisualBench.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/views/mac/skia_mac.mm
diff --git a/src/views/mac/skia_mac.mm b/src/views/mac/skia_mac.mm
index c20a402c890bd97c38a6c41d792ccac8794e95b1..ea3b75c87afc93fd481d28f2d9f065fd75a63e5b 100644
--- a/src/views/mac/skia_mac.mm
+++ b/src/views/mac/skia_mac.mm
@@ -6,19 +6,119 @@
* found in the LICENSE file.
*/
+#include <crt_externs.h>
#import <Cocoa/Cocoa.h>
#include "SkApplication.h"
+#include "SkNSView.h"
+
+@interface MainView : SkNSView {
+}
+- (id)initWithFrame: (NSRect)frame ;
+- (void)dealloc;
+- (void)begin;
+@end
+
+@implementation MainView : SkNSView
+
+- (id)initWithFrame: (NSRect)frame {
+ self = [super initWithFrame:frame];
+ return self;
+}
+
+- (void)dealloc {
+ delete fWind;
+ [super dealloc];
+}
+
+- (void)begin {
+ fWind = create_sk_window(self, *_NSGetArgc(), *_NSGetArgv());
+ [self setUpWindow];
+}
+@end
+
+@interface AppDelegate : NSObject<NSApplicationDelegate, NSWindowDelegate> {
+}
+- (id)init;
+- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication;
+@end
+
+#
+@implementation AppDelegate : NSObject
+- (id)init {
+ self = [super init];
+ return self;
+}
+
+- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theApplication {
+ return TRUE;
+}
+@end
int main(int argc, char *argv[]) {
signal(SIGPIPE, SIG_IGN);
- /*NSAutoreleasePool* pool = */ [[NSAutoreleasePool alloc] init];
- application_init();
- int retVal = NSApplicationMain(argc, (const char **)argv);
+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
-#if 0
- // we don't expect NSApplicationMain to return. See our applicationShouldTerminate handler.
- application_term();
+ NSApplication* app = [NSApplication sharedApplication];
+
+ NSUInteger windowStyle = (NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask | NSMiniaturizableWindowMask);
+
+ NSRect windowRect = NSMakeRect(100, 100, 1000, 1000);
+ NSWindow* window = [[NSWindow alloc] initWithContentRect:windowRect styleMask:windowStyle backing:NSBackingStoreBuffered defer:NO];
+
+ NSRect rect = [NSWindow contentRectForFrameRect:windowRect styleMask:windowStyle];
+ MainView* customView = [[MainView alloc] initWithFrame:rect];
+ [customView setTranslatesAutoresizingMaskIntoConstraints:NO];
+ NSView* contentView = window.contentView;
+ [contentView addSubview:customView];
+ NSDictionary *views = NSDictionaryOfVariableBindings(customView);
+
+ [contentView addConstraints:
+ [NSLayoutConstraint constraintsWithVisualFormat:@"H:|[customView]|"
+ options:0
+ metrics:nil
+ views:views]];
+
+ [contentView addConstraints:
+ [NSLayoutConstraint constraintsWithVisualFormat:@"V:|[customView]|"
+ options:0
+ metrics:nil
+ views:views]];
+
+ [customView begin];
+ [customView release];
+
+ [window makeKeyAndOrderFront:NSApp];
+
+ AppDelegate * appDelegate = [[[AppDelegate alloc] init] autorelease];
+
+ app.delegate = appDelegate;
+
+ NSMenu* menu=[[NSMenu alloc] initWithTitle:@"AMainMenu"];
+ NSMenuItem* item;
+ NSMenu* subMenu;
+
+ //Create the application menu.
+ item=[[NSMenuItem alloc] initWithTitle:@"Apple" action:NULL keyEquivalent:@""];
+ [menu addItem:item];
+ subMenu=[[NSMenu alloc] initWithTitle:@"Apple"];
+ [menu setSubmenu:subMenu forItem:item];
+ [item release];
+ item=[[NSMenuItem alloc] initWithTitle:@"Quit" action:@selector(terminate:) keyEquivalent:@"q"];
+ [subMenu addItem:item];
+ [item release];
+ [subMenu release];
+
+ //Add the menu to the app.
+ [app setMenu:menu];
+
+ [app setActivationPolicy:NSApplicationActivationPolicyRegular];
+
+ [app run];
+
+ [menu release];
+ [appDelegate release];
+ [window release];
[pool release];
-#endif
- return retVal;
+
+ return EXIT_SUCCESS;
}
« no previous file with comments | « src/views/mac/SkOSWindow_Mac.mm ('k') | tools/VisualBench.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698