diff --git a/ogl_editor/data/macosx/appnib.xib b/ogl_editor/data/macosx/appnib.xib index e7d39f6..fe4b49d 100644 --- a/ogl_editor/data/macosx/appnib.xib +++ b/ogl_editor/data/macosx/appnib.xib @@ -1,23 +1,23 @@ - 1070 - 11D50b - 2182 - 1138.32 - 568.00 + 1080 + 12C60 + 2843 + 1187.34 + 625.00 com.apple.InterfaceBuilder.CocoaPlugin - 2182 + 2843 YES + NSCustomObject NSCustomView - NSWindowTemplate - NSView NSMenu NSMenuItem - NSCustomObject + NSView + NSWindowTemplate YES @@ -209,6 +209,7 @@ 2147483647 + 1 @@ -247,15 +248,6 @@ - - - Close - w - 1048576 - 2147483647 - - - Save @@ -264,6 +256,7 @@ 2147483647 + 2 @@ -273,14 +266,17 @@ 2147483647 + 3 - + - Revert to Saved - + Remote Export... + e + 1048576 2147483647 + 4 @@ -293,25 +289,6 @@ - - - Page Setup... - P - 1179648 - 2147483647 - - - - - - - Print… - p - 1048576 - 2147483647 - - - @@ -429,7 +406,7 @@ - {{0, 0}, {1440, 878}} + {{0, 0}, {1920, 1178}} {800, 622} {10000000000000, 10000000000000} YES @@ -486,22 +463,6 @@ - print: - - - - 86 - - - - runPageLayout: - - - - 87 - - - clearRecentDocuments: @@ -510,14 +471,6 @@ - performClose: - - - - 193 - - - performZoom: @@ -526,30 +479,6 @@ - saveDocument: - - - - 362 - - - - saveDocumentAs: - - - - 363 - - - - revertDocumentToSaved: - - - - 364 - - - hide: @@ -574,22 +503,6 @@ - newDocument: - - - - 373 - - - - openDocument: - - - - 374 - - - showHelp: @@ -604,6 +517,46 @@ 532 + + + buttonClicked: + + + + 543 + + + + buttonClicked: + + + + 544 + + + + buttonClicked: + + + + 545 + + + + buttonClicked: + + + + 546 + + + + buttonClicked: + + + + 547 + @@ -680,44 +633,21 @@ YES - - - - + - 75 - - - - - 80 - - - - - 78 - - - - 72 - 82 - - - - 124 @@ -727,26 +657,11 @@ - 77 - - - - - 73 - - - - 79 - 112 - - - - 74 @@ -936,6 +851,26 @@ + + 82 + + + + + 78 + + + + + 75 + + + + + 80 + + + @@ -945,7 +880,6 @@ -1.IBPluginDependency -2.IBPluginDependency -3.IBPluginDependency - 112.IBPluginDependency 124.IBPluginDependency 125.IBPluginDependency 126.IBPluginDependency @@ -980,10 +914,8 @@ 57.IBPluginDependency 58.IBPluginDependency 72.IBPluginDependency - 73.IBPluginDependency 74.IBPluginDependency 75.IBPluginDependency - 77.IBPluginDependency 78.IBPluginDependency 79.IBPluginDependency 80.IBPluginDependency @@ -1017,7 +949,6 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin {{928, 459}, {480, 360}} com.apple.InterfaceBuilder.CocoaPlugin @@ -1041,8 +972,6 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin @@ -1057,7 +986,7 @@ - 542 + 547 @@ -1114,73 +1043,6 @@ - NSDocument - - YES - - YES - printDocument: - revertDocumentToSaved: - runPageLayout: - saveDocument: - saveDocumentAs: - saveDocumentTo: - - - YES - id - id - id - id - id - id - - - - YES - - YES - printDocument: - revertDocumentToSaved: - runPageLayout: - saveDocument: - saveDocumentAs: - saveDocumentTo: - - - YES - - printDocument: - id - - - revertDocumentToSaved: - id - - - runPageLayout: - id - - - saveDocument: - id - - - saveDocumentAs: - id - - - saveDocumentTo: - id - - - - - IBProjectSource - ./Classes/NSDocument.h - - - RocketView NSView diff --git a/ogl_editor/src/Dialog.h b/ogl_editor/src/Dialog.h new file mode 100644 index 0000000..a096275 --- /dev/null +++ b/ogl_editor/src/Dialog.h @@ -0,0 +1,4 @@ +#pragma once + +int Dialog_open(char* dest); + diff --git a/ogl_editor/src/Editor.c b/ogl_editor/src/Editor.c index 45b02c8..8bef947 100644 --- a/ogl_editor/src/Editor.c +++ b/ogl_editor/src/Editor.c @@ -3,6 +3,8 @@ #include #include #include +#include "Dialog.h" +#include "Editor.h" typedef struct RETrack { @@ -243,6 +245,31 @@ void Editor_keyDown(int key) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +static void onOpen() +{ + char path[512]; + + if (!Dialog_open(path)) + return; + + printf("%s\n", path); +} + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void Editor_menuEvent(int menuItem) +{ + switch (menuItem) + { + //case EDITOR_MENU_NEW : onNew(); break; + case EDITOR_MENU_OPEN : onOpen(); break; + //case EDITOR_MENU_SAVE : onSave(); break; + //case EDITOR_MENU_SAVE_AS : onSaveAs(); break; + } +} + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + void Editor_destroy() { diff --git a/ogl_editor/src/Editor.h b/ogl_editor/src/Editor.h index 80c572b..20bc222 100644 --- a/ogl_editor/src/Editor.h +++ b/ogl_editor/src/Editor.h @@ -5,4 +5,13 @@ void Editor_destroy(); void Editor_init(); void Editor_update(); void Editor_keyDown(int keyCode); +void Editor_menuEvent(int menuItem); + +enum +{ + EDITOR_MENU_NEW, + EDITOR_MENU_OPEN, + EDITOR_MENU_SAVE, + EDITOR_MENU_SAVE_AS, +}; diff --git a/ogl_editor/src/macosx/FileDialog.m b/ogl_editor/src/macosx/FileDialog.m new file mode 100644 index 0000000..eb12f46 --- /dev/null +++ b/ogl_editor/src/macosx/FileDialog.m @@ -0,0 +1,30 @@ +#include "../Dialog.h" +#import + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +int Dialog_open(char* dest) +{ + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + NSOpenPanel* open = [NSOpenPanel openPanel]; + [open setAllowsMultipleSelection:NO]; + + int result = [open runModal]; + + if (result != NSOKButton) + return false; + + // Grab the first file + + NSArray* selectedFiles = [open URLs]; + NSURL* url = [selectedFiles objectAtIndex:0]; + const char* temp = [[url path] UTF8String]; + + strcpy(dest, temp); + + [pool drain]; + + return true; +} + + diff --git a/ogl_editor/src/macosx/delegate.m b/ogl_editor/src/macosx/delegate.m index 8baf7be..21aa4c1 100644 --- a/ogl_editor/src/macosx/delegate.m +++ b/ogl_editor/src/macosx/delegate.m @@ -1,19 +1,23 @@ #import "delegate.h" +#include "../Editor.h" @implementation MinimalAppAppDelegate @synthesize window; @synthesize button; -- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { - // Insert code here to initialize your application +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +- (void)applicationDidFinishLaunching:(NSNotification *)aNotification +{ } -- (IBAction) buttonClicked:(id)sender { - NSRunAlertPanel(@"Hello, world", - @"Hello", - @"OK", nil, nil); +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +- (IBAction) buttonClicked:(id)sender +{ + Editor_menuEvent((int)((NSButton*)sender).tag); } @end