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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « src/views/mac/SkOSWindow_Mac.mm ('k') | tools/VisualBench.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include <crt_externs.h>
9 #import <Cocoa/Cocoa.h> 10 #import <Cocoa/Cocoa.h>
10 #include "SkApplication.h" 11 #include "SkApplication.h"
12 #include "SkNSView.h"
13
14 @interface MainView : SkNSView {
15 }
16 - (id)initWithFrame: (NSRect)frame ;
17 - (void)dealloc;
18 - (void)begin;
19 @end
20
21 @implementation MainView : SkNSView
22
23 - (id)initWithFrame: (NSRect)frame {
24 self = [super initWithFrame:frame];
25 return self;
26 }
27
28 - (void)dealloc {
29 delete fWind;
30 [super dealloc];
31 }
32
33 - (void)begin {
34 fWind = create_sk_window(self, *_NSGetArgc(), *_NSGetArgv());
35 [self setUpWindow];
36 }
37 @end
38
39 @interface AppDelegate : NSObject<NSApplicationDelegate, NSWindowDelegate> {
40 }
41 - (id)init;
42 - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theAppl ication;
43 @end
44
45 #
46 @implementation AppDelegate : NSObject
47 - (id)init {
48 self = [super init];
49 return self;
50 }
51
52 - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)theAppl ication {
53 return TRUE;
54 }
55 @end
11 56
12 int main(int argc, char *argv[]) { 57 int main(int argc, char *argv[]) {
13 signal(SIGPIPE, SIG_IGN); 58 signal(SIGPIPE, SIG_IGN);
14 /*NSAutoreleasePool* pool = */ [[NSAutoreleasePool alloc] init]; 59 NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
15 application_init();
16 int retVal = NSApplicationMain(argc, (const char **)argv);
17 60
18 #if 0 61 NSApplication* app = [NSApplication sharedApplication];
19 // we don't expect NSApplicationMain to return. See our applicationShouldTer minate handler. 62
20 application_term(); 63 NSUInteger windowStyle = (NSTitledWindowMask | NSClosableWindowMask | NSResi zableWindowMask | NSMiniaturizableWindowMask);
64
65 NSRect windowRect = NSMakeRect(100, 100, 1000, 1000);
66 NSWindow* window = [[NSWindow alloc] initWithContentRect:windowRect styleMas k:windowStyle backing:NSBackingStoreBuffered defer:NO];
67
68 NSRect rect = [NSWindow contentRectForFrameRect:windowRect styleMask:windowS tyle];
69 MainView* customView = [[MainView alloc] initWithFrame:rect];
70 [customView setTranslatesAutoresizingMaskIntoConstraints:NO];
71 NSView* contentView = window.contentView;
72 [contentView addSubview:customView];
73 NSDictionary *views = NSDictionaryOfVariableBindings(customView);
74
75 [contentView addConstraints:
76 [NSLayoutConstraint constraintsWithVisualFormat:@"H:|[customView]|"
77 options:0
78 metrics:nil
79 views:views]];
80
81 [contentView addConstraints:
82 [NSLayoutConstraint constraintsWithVisualFormat:@"V:|[customView]|"
83 options:0
84 metrics:nil
85 views:views]];
86
87 [customView begin];
88 [customView release];
89
90 [window makeKeyAndOrderFront:NSApp];
91
92 AppDelegate * appDelegate = [[[AppDelegate alloc] init] autorelease];
93
94 app.delegate = appDelegate;
95
96 NSMenu* menu=[[NSMenu alloc] initWithTitle:@"AMainMenu"];
97 NSMenuItem* item;
98 NSMenu* subMenu;
99
100 //Create the application menu.
101 item=[[NSMenuItem alloc] initWithTitle:@"Apple" action:NULL keyEquivalent:@" "];
102 [menu addItem:item];
103 subMenu=[[NSMenu alloc] initWithTitle:@"Apple"];
104 [menu setSubmenu:subMenu forItem:item];
105 [item release];
106 item=[[NSMenuItem alloc] initWithTitle:@"Quit" action:@selector(terminate:) keyEquivalent:@"q"];
107 [subMenu addItem:item];
108 [item release];
109 [subMenu release];
110
111 //Add the menu to the app.
112 [app setMenu:menu];
113
114 [app setActivationPolicy:NSApplicationActivationPolicyRegular];
115
116 [app run];
117
118 [menu release];
119 [appDelegate release];
120 [window release];
21 [pool release]; 121 [pool release];
22 #endif 122
23 return retVal; 123 return EXIT_SUCCESS;
24 } 124 }
OLDNEW
« 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