diff --git a/sources/ewol/context/MacOs/AppDelegate.h b/sources/ewol/context/MacOs/AppDelegate.h index 8ace805c..686d0bab 100644 --- a/sources/ewol/context/MacOs/AppDelegate.h +++ b/sources/ewol/context/MacOs/AppDelegate.h @@ -11,5 +11,6 @@ @interface MacOsAppDelegate : NSObject @property (assign) IBOutlet NSWindow *window; - +- (void)sendEvent:(NSEvent *)event; +- (void)applicationWillResignActive:(MacOsAppDelegate *)application; @end diff --git a/sources/ewol/context/MacOs/AppDelegate.mm b/sources/ewol/context/MacOs/AppDelegate.mm index 44796d49..a13289da 100644 --- a/sources/ewol/context/MacOs/AppDelegate.mm +++ b/sources/ewol/context/MacOs/AppDelegate.mm @@ -20,6 +20,7 @@ // Override point for customization after application launch. [self.window addSubview:view]; [self.window makeKeyAndVisible]; + EWOL_INFO("lkjlkjlkj"); return YES; } @@ -28,6 +29,7 @@ Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. */ + EWOL_INFO("move windows in applicationWillResignActive"); } - (void)applicationDidEnterBackground:(MacOsAppDelegate *)application { @@ -35,18 +37,21 @@ Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. */ + EWOL_INFO("move windows in applicationDidEnterBackground"); } - (void)applicationWillEnterForeground:(MacOsAppDelegate *)application { /* Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. */ + EWOL_INFO("move windows in applicationWillEnterForeground"); } - (void)applicationDidBecomeActive:(MacOsAppDelegate *)application { /* Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. */ + EWOL_INFO("move windows in applicationDidBecomeActive"); } - (void)applicationWillTerminate:(MacOsAppDelegate *)application { @@ -55,6 +60,7 @@ Save data if appropriate. See also applicationDidEnterBackground:. */ + EWOL_INFO("move windows in applicationWillTerminate"); } - (void)dealloc { @@ -62,6 +68,12 @@ [super dealloc]; } + +- (void)sendEvent:(NSEvent *)event { + EWOL_WARNING(" EVENT ... "); +} + + @end diff --git a/sources/ewol/context/MacOs/Context.cpp b/sources/ewol/context/MacOs/Context.cpp index f6e35735..f7ec4bcb 100644 --- a/sources/ewol/context/MacOs/Context.cpp +++ b/sources/ewol/context/MacOs/Context.cpp @@ -12,7 +12,6 @@ #include #include #include -#include #include #include diff --git a/sources/ewol/context/MacOs/Interface.mm b/sources/ewol/context/MacOs/Interface.mm index e0e3df49..a2c0a6b1 100644 --- a/sources/ewol/context/MacOs/Interface.mm +++ b/sources/ewol/context/MacOs/Interface.mm @@ -10,6 +10,7 @@ #include "ewol/context/MacOs/Interface.h" #import +#import #import int mm_main(int argc, const char *argv[]) { @@ -47,10 +48,14 @@ int mm_main(int argc, const char *argv[]) { // -- basic windows creation : // --------------------------------------------------------------- // create a windows of size 800/600 - id window = [ [ [NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600) - styleMask:(NSTitledWindowMask|NSMiniaturizableWindowMask|NSClosableWindowMask) backing:NSBackingStoreBuffered defer:NO] - autorelease]; - // set the windows at a specific position : +#if 1 + id window = [ [ [EwolMainWindows alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600) + styleMask:(NSTitledWindowMask|NSMiniaturizableWindowMask|NSClosableWindowMask) backing:NSBackingStoreBuffered defer:NO] + autorelease]; + + //id window = [ [MacOsAppDelegate alloc] autorelease]; + + // set the windows at a specific position : [window cascadeTopLeftFromPoint:NSMakePoint(50,50)]; // set the windows resizable [window setStyleMask:[window styleMask] | NSResizableWindowMask]; @@ -75,6 +80,19 @@ int mm_main(int argc, const char *argv[]) { //[window makeKeyAndVisible]; [window setDelegate:view]; +#else + @autoreleasepool + { + const ProcessSerialNumber psn = { 0, kCurrentProcess }; + TransformProcessType(&psn, kProcessTransformToForegroundApplication); + SetFrontProcess(&psn); + + [MyApplication sharedApplication]; + [NSApp setDelegate: NSApp]; + + [NSApp run]; + } +#endif // return no error return 0; } diff --git a/sources/ewol/context/MacOs/Windows.h b/sources/ewol/context/MacOs/Windows.h new file mode 100644 index 00000000..e197a552 --- /dev/null +++ b/sources/ewol/context/MacOs/Windows.h @@ -0,0 +1,22 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license BSD v3 (see license file) + */ + +#import + +@interface EwolMainWindows : NSWindow ++ (id)alloc; +- (id)init; ++ (void)dealloc; +@end + + +@interface MyApplication : NSApplication + +@property (strong, nonatomic) NSWindow *window; + +@end \ No newline at end of file diff --git a/sources/ewol/context/MacOs/Windows.mm b/sources/ewol/context/MacOs/Windows.mm new file mode 100644 index 00000000..83db12d4 --- /dev/null +++ b/sources/ewol/context/MacOs/Windows.mm @@ -0,0 +1,101 @@ +/** + * @author Edouard DUPIN + * + * @copyright 2011, Edouard DUPIN, all right reserved + * + * @license BSD v3 (see license file) + */ + + +#import +#import + +#include + +@implementation EwolMainWindows + ++ (id)alloc { + id windowsID = [super alloc]; + EWOL_DEBUG("ALLOCATE ..."); + return windowsID; +} + +- (id)init { + id windowsID = [super init]; + EWOL_DEBUG("INIT ..."); + // set the windows at a specific position : + [windowsID cascadeTopLeftFromPoint:NSMakePoint(50,50)]; + EWOL_DEBUG("ALLOCATE ..."); + // set the windows resizable + [windowsID setStyleMask:[windowsID styleMask] | NSResizableWindowMask]; + EWOL_DEBUG("ALLOCATE ..."); + // oposite : [window setStyleMask:[window styleMask] & ~NSResizableWindowMask]; + // set the title + id appName = [[NSProcessInfo processInfo] processName]; + EWOL_DEBUG("ALLOCATE ..."); + [windowsID setTitle:appName]; + EWOL_DEBUG("ALLOCATE ..."); + + [windowsID setAcceptsMouseMovedEvents:YES]; + EWOL_DEBUG("ALLOCATE ..."); + // ??? + [windowsID makeKeyAndOrderFront:nil]; + EWOL_DEBUG("ALLOCATE ..."); + [NSApp activateIgnoringOtherApps:YES]; + EWOL_DEBUG("ALLOCATE ..."); + + NSRect window_frame = [windowsID frame]; + EWOL_DEBUG("ALLOCATE ..."); + + OpenGLView* view=[[OpenGLView alloc]initWithFrame:window_frame]; //NSMakeRect(0, 0, 800, 600)]; + EWOL_DEBUG("ALLOCATE ..."); + [windowsID setContentView:view]; + EWOL_DEBUG("ALLOCATE ..."); + [view setAutoresizesSubviews:YES]; + EWOL_DEBUG("ALLOCATE ..."); + + // Override point for customization after application launch. + //[window addSubview:view]; + //[window addChildWindow:view]; + //[window makeKeyAndVisible]; + + [windowsID setDelegate:view]; + EWOL_DEBUG("ALLOCATE ..."); + return windowsID; +} + + ++ (void)dealloc { + EWOL_DEBUG("FREE ..."); + //[_window release]; + [super dealloc]; +} +/* + +- (void)sendEvent:(NSEvent *)event { + EWOL_WARNING(" EVENT ... "); +} +*/ + +@end + + + + +@implementation MyApplication + +- (void) applicationDidFinishLaunching: (NSNotification *) note +{ + NSWindow *window = [[NSWindow alloc] initWithContentRect:NSMakeRect(100, 100, 100, 100) + styleMask:NSTitledWindowMask backing:NSBackingStoreBuffered defer:YES]; + + self.window = window; + + [window close]; + + [super stop: self]; +} + +@end + + diff --git a/sources/lutin_ewol.py b/sources/lutin_ewol.py index 67badc3e..7c1e0942 100755 --- a/sources/lutin_ewol.py +++ b/sources/lutin_ewol.py @@ -47,16 +47,17 @@ def create(target): ]) if target.name=="Linux": myModule.add_src_file('ewol/context/X11/Context.cpp') - elif target.name=="Android": - myModule.add_src_file("ewol/context/Android/Context.cpp") elif target.name=="Windows": - myModule.add_src_file("ewol/context/Windows/Context.cpp") + myModule.add_src_file('ewol/context/Windows/Context.cpp') + elif target.name=="Android": + myModule.add_src_file('ewol/context/Android/Context.cpp') elif target.name=="MacOs": myModule.add_src_file([ - "ewol/context/MacOs/Context.cpp", - "ewol/context/MacOs/Interface.mm", - "ewol/context/MacOs/AppDelegate.mm", - "ewol/context/MacOs/OpenglView.mm"]) + 'ewol/context/MacOs/Context.cpp', + 'ewol/context/MacOs/Interface.mm', + 'ewol/context/MacOs/Windows.mm', + 'ewol/context/MacOs/OpenglView.mm', + 'ewol/context/MacOs/AppDelegate.mm']) else: debug.error("unknow mode...") @@ -163,7 +164,7 @@ def create(target): myModule.add_module_depend(['etk', 'freetype', 'exml', 'ejson', 'egami', 'date']) myModule.add_export_path(tools.get_current_path(__file__)) - + tagFile = tools.get_current_path(__file__) + "/tag" ewolVersionID = tools.file_read_data(tagFile) myModule.compile_flags_CC([