From ba0f99d51bd360dd2c1de88ce25d5bf62f32039b Mon Sep 17 00:00:00 2001 From: Daniel Collin Date: Mon, 1 Jul 2013 12:48:03 +0200 Subject: [PATCH] Support for showing error dialog --- ogl_editor/src/Dialog.h | 2 ++ ogl_editor/src/linux/main.c | 5 +++++ ogl_editor/src/macosx/FileDialog.m | 13 +++++++++++++ ogl_editor/src/windows/Dialogs.c | 9 ++++++++- 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/ogl_editor/src/Dialog.h b/ogl_editor/src/Dialog.h index 52fa956..3314be2 100644 --- a/ogl_editor/src/Dialog.h +++ b/ogl_editor/src/Dialog.h @@ -4,3 +4,5 @@ int Dialog_open(text_t* dest); int Dialog_save(text_t* dest); +void Dialog_showError(const text_t* text); + diff --git a/ogl_editor/src/linux/main.c b/ogl_editor/src/linux/main.c index 7efc239..6a9946c 100644 --- a/ogl_editor/src/linux/main.c +++ b/ogl_editor/src/linux/main.c @@ -57,6 +57,11 @@ void Dialog_showColorPicker(unsigned int* color) printf("dialog_showColorPicker() not implemented\n"); } +void Dialog_showError(const text_t* text) +{ + printf("Error %s\n", text); +} + int mapSdlEmKeycode(SDLKey key) { switch (key) diff --git a/ogl_editor/src/macosx/FileDialog.m b/ogl_editor/src/macosx/FileDialog.m index 3f0f376..6f4c192 100644 --- a/ogl_editor/src/macosx/FileDialog.m +++ b/ogl_editor/src/macosx/FileDialog.m @@ -52,6 +52,7 @@ int Dialog_save(char* dest) return true; } +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @interface ColorDelegate : NSObject { @@ -139,3 +140,15 @@ void Dialog_showColorPicker(uint32_t* color) [thePool release]; } +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void Dialog_showError(const text_t* text) +{ + NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; + NSString* message = [[[NSString alloc] initWithUTF8String:text] autorelease];// convert + + NSRunAlertPanel(@"Error", message, @"Ok", @"", @""); + + [pool drain]; +} + diff --git a/ogl_editor/src/windows/Dialogs.c b/ogl_editor/src/windows/Dialogs.c index cf04a1b..e2b5771 100644 --- a/ogl_editor/src/windows/Dialogs.c +++ b/ogl_editor/src/windows/Dialogs.c @@ -40,6 +40,13 @@ int Dialog_save(wchar_t* path) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +void Dialog_showError(const wchar_t* text) +{ + MessageBox(NULL, text, L"Error", MB_ICONERROR | MB_OK); +} + +/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + static COLORREF custColors[16]; void Dialog_showColorPicker(unsigned int* color) @@ -53,4 +60,4 @@ void Dialog_showColorPicker(unsigned int* color) cc.hwndOwner = s_window; if (ChooseColor(&cc)) *color = cc.rgbResult | 0xff000000; -} \ No newline at end of file +}