Page MenuHome
Paste P1122

Ghost message box
ActivePublic

Authored by Jeroen Bakker (jbakker) on Oct 1 2019, 2:34 PM.
diff --git a/intern/ghost/GHOST_C-api.h b/intern/ghost/GHOST_C-api.h
index 20bb144a924..96c2017c697 100644
--- a/intern/ghost/GHOST_C-api.h
+++ b/intern/ghost/GHOST_C-api.h
@@ -949,6 +949,22 @@ extern void GHOST_BeginIME(GHOST_WindowHandle windowhandle,
*/
extern void GHOST_EndIME(GHOST_WindowHandle windowhandle);
+/**
+ * Display a warning with OS Native messaging
+ * \param systemhandle The handle to the system
+ * \param title caption for the warning
+ * \param text text body for the warning
+ */
+extern void GHOST_Warning(GHOST_SystemHandle systemhandle, const char *title, const char *text);
+
+/**
+ * Display an error with OS Native messaging
+ * \param systemhandle The handle to the system
+ * \param title caption for the error
+ * \param text text body for the error
+ */
+extern void GHOST_Error(GHOST_SystemHandle systemhandle, const char *title, const char *text);
+
#ifdef __cplusplus
}
#endif
diff --git a/intern/ghost/GHOST_ISystem.h b/intern/ghost/GHOST_ISystem.h
index 27be80a2f20..0d793888eaa 100644
--- a/intern/ghost/GHOST_ISystem.h
+++ b/intern/ghost/GHOST_ISystem.h
@@ -435,6 +435,20 @@ class GHOST_ISystem {
*/
virtual void putClipboard(GHOST_TInt8 *buffer, bool selection) const = 0;
+ /**
+ * Display a warning with OS Native messaging
+ * \param title caption for the warning
+ * \param text text body for the warning
+ */
+ virtual void warning(const STR_String &title, const STR_String &text) const = 0;
+
+ /**
+ * Display a error with OS Native messaging
+ * \param title caption for the warning
+ * \param text text body for the warning
+ */
+ virtual void error(const STR_String &title, const STR_String &text) const = 0;
+
protected:
/**
* Initialize the system.
diff --git a/intern/ghost/intern/GHOST_C-api.cpp b/intern/ghost/intern/GHOST_C-api.cpp
index a1a209af77a..c2b94038247 100644
--- a/intern/ghost/intern/GHOST_C-api.cpp
+++ b/intern/ghost/intern/GHOST_C-api.cpp
@@ -838,3 +838,15 @@ void GHOST_EndIME(GHOST_WindowHandle windowhandle)
}
#endif /* WITH_INPUT_IME */
+
+void GHOST_Warning(GHOST_SystemHandle systemhandle, const char *title, const char *text)
+{
+ GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
+ system->warning(title, text);
+}
+
+void GHOST_Error(GHOST_SystemHandle systemhandle, const char *title, const char *text)
+{
+ GHOST_ISystem *system = (GHOST_ISystem *)systemhandle;
+ system->error(title, text);
+}
\ No newline at end of file
diff --git a/intern/ghost/intern/GHOST_System.h b/intern/ghost/intern/GHOST_System.h
index fbf8af01e59..46bfe35f6b1 100644
--- a/intern/ghost/intern/GHOST_System.h
+++ b/intern/ghost/intern/GHOST_System.h
@@ -40,6 +40,7 @@ class GHOST_Event;
class GHOST_TimerManager;
class GHOST_Window;
class GHOST_WindowManager;
+class STR_String;
#ifdef WITH_INPUT_NDOF
class GHOST_NDOFManager;
#endif
@@ -317,6 +318,20 @@ class GHOST_System : public GHOST_ISystem {
*/
virtual void putClipboard(GHOST_TInt8 *buffer, bool selection) const = 0;
+ /**
+ * Display a warning with OS Native messaging
+ * \param title caption for the warning
+ * \param text text body for the warning
+ */
+ virtual void warning(const STR_String &title, const STR_String &text) const = 0;
+
+ /**
+ * Display a error with OS Native messaging
+ * \param title caption for the warning
+ * \param text text body for the warning
+ */
+ virtual void error(const STR_String &title, const STR_String &text) const = 0;
+
protected:
/**
* Initialize the system.
diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp
index 9073ed9944b..59aee00f2e1 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemWin32.cpp
@@ -356,12 +356,10 @@ GHOST_IContext *GHOST_SystemWin32::createOffscreenContext()
goto finished;
}
else {
- MessageBox(NULL,
- "A graphics card and driver with support for OpenGL 3.3 or higher is required.\n"
- "Installing the latest driver for your graphics card may resolve the issue.\n\n"
- "The program will now close.",
- "Blender - Unsupported Graphics Card or Driver",
- MB_OK | MB_ICONERROR);
+ error("Blender - Unsupported Graphics Card or Driver",
+ "A graphics card and driver with support for OpenGL 3.3 or higher is required.\n"
+ "Installing the latest driver for your graphics card may resolve the issue.\n\n"
+ "The program will now close.");
delete context;
exit();
}
@@ -1871,3 +1869,11 @@ int GHOST_SystemWin32::toggleConsole(int action)
return m_consoleStatus;
}
+
+void GHOST_SystemWin32::warning(const STR_String &title, const STR_String &text) const
+{
+}
+
+void GHOST_SystemWin32::error(const STR_String &title, const STR_String &text) const
+{
+}
diff --git a/intern/ghost/intern/GHOST_SystemWin32.h b/intern/ghost/intern/GHOST_SystemWin32.h
index 7ac6a3e3e20..b2d4a86a86f 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.h
+++ b/intern/ghost/intern/GHOST_SystemWin32.h
@@ -203,6 +203,20 @@ class GHOST_SystemWin32 : public GHOST_System {
*/
void putClipboard(GHOST_TInt8 *buffer, bool selection) const;
+ /**
+ * Display a warning with OS Native messaging
+ * \param title caption for the warning
+ * \param text text body for the warning
+ */
+ void warning(const STR_String &title, const STR_String &text) const;
+
+ /**
+ * Display a error with OS Native messaging
+ * \param title caption for the warning
+ * \param text text body for the warning
+ */
+ void error(const STR_String &title, const STR_String &text) const;
+
/**
* Creates a drag'n'drop event and pushes it immediately onto the event queue.
* Called by GHOST_DropTargetWin32 class.
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 568b904dcb7..544157df81a 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -818,6 +818,9 @@ void WM_generic_callback_free(struct wmGenericCallback *callback);
void WM_generic_user_data_free(struct wmGenericUserData *user_data);
+void WM_system_warning(const char *title, const char *text);
+void WM_system_error(const char *title, const char *text);
+
#ifdef __cplusplus
}
#endif
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index 2c26a15dce0..52bc65c8354 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -2394,4 +2394,14 @@ void WM_opengl_context_release(void *context)
GHOST_ReleaseOpenGLContext((GHOST_ContextHandle)context);
}
+void WM_system_warning(const char *title, const char *text)
+{
+ GHOST_Warning(g_system, title, text);
+}
+
+void WM_system_error(const char *title, const char *text)
+{
+ GHOST_Error(g_system, title, text);
+}
+
/** \} */