#include <tcl.h>
#include <Draw_Interpretor.hxx>
+#include <Draw_Window.hxx>
#include <Draw_Appli.hxx>
#include <TCollection_AsciiString.hxx>
#include <Image_AlienPixMap.hxx>
+#include <NCollection_List.hxx>
extern Draw_Interpretor theCommands;
extern Standard_Boolean Draw_VirtualWindows;
static Tcl_Interp *interp; /* Interpreter for this application. */
+static NCollection_List<Draw_Window::FCallbackBeforeTerminate> MyCallbacks;
+
+void Draw_Window::AddCallbackBeforeTerminate(FCallbackBeforeTerminate theCB)
+{
+ MyCallbacks.Append(theCB);
+}
+
+void Draw_Window::RemoveCallbackBeforeTerminate(FCallbackBeforeTerminate theCB)
+{
+ NCollection_List<Draw_Window::FCallbackBeforeTerminate>::Iterator Iter(MyCallbacks);
+ for(; Iter.More(); Iter.Next())
+ {
+ if (Iter.Value() == theCB)
+ {
+ MyCallbacks.Remove(Iter);
+ break;
+ }
+ }
+}
/*
*----------------------------------------------------------------------
}
#endif
+ NCollection_List<Draw_Window::FCallbackBeforeTerminate>::Iterator Iter(MyCallbacks);
+ for(; Iter.More(); Iter.Next())
+ {
+ (*Iter.Value())();
+ }
}
//======================================================
\*--------------------------------------------------------*/
void exitProc(ClientData /*dc*/)
{
+ NCollection_List<Draw_Window::FCallbackBeforeTerminate>::Iterator Iter(MyCallbacks);
+ for(; Iter.More(); Iter.Next())
+ {
+ (*Iter.Value())();
+ }
HANDLE proc = GetCurrentProcess();
TerminateProcess(proc, 0);
}
//====================================
class Draw_Window
{
-
public :
+ /**
+ * Type of the callback function that is to be passed to the method
+ * AddCallbackBeforeTerminate().
+ */
+ typedef void (*FCallbackBeforeTerminate)();
+
+ /**
+ * This method registers a callback function that will be called just before exit.
+ * This is usefull especially for Windows platform, on which Draw is normally
+ * self-terminated instead of exiting.
+ */
+ Standard_EXPORT static void AddCallbackBeforeTerminate(FCallbackBeforeTerminate theCB);
+
+ /**
+ * Just in case method for un-registering a callback previously registered by
+ * AddCallbackBeforeTerminate()
+ */
+ Standard_EXPORT static void RemoveCallbackBeforeTerminate(FCallbackBeforeTerminate theCB);
+
Draw_Window (); // the window is not initialized
Draw_Window (const char* title,
Standard_Integer X, Standard_Integer Y = 0,
{
public :
+ /**
+ * Type of the callback function that is to be passed to the method
+ * AddCallbackBeforeTerminate().
+ */
+ typedef void (*FCallbackBeforeTerminate)();
+
+ /**
+ * This method registers a callback function that will be called just before exit.
+ * This is usefull especially for Windows platform, on which Draw is normally
+ * self-terminated instead of exiting.
+ */
+ Standard_EXPORT static void AddCallbackBeforeTerminate(FCallbackBeforeTerminate theCB);
+
+ /**
+ * Just in case method for un-registering a callback previously registered by
+ * AddCallbackBeforeTerminate()
+ */
+ Standard_EXPORT static void RemoveCallbackBeforeTerminate(FCallbackBeforeTerminate theCB);
+
Draw_Window (); // the window is not initialized
Draw_Window (Standard_CString theTitle,
const Standard_Integer& theXLeft = 0, const Standard_Integer& theYTop = 0,
{
//constructeur
public:
+
+ /**
+ * Type of the callback function that is to be passed to the method
+ * AddCallbackBeforeTerminate().
+ */
+ typedef void (*FCallbackBeforeTerminate)();
+
+ /**
+ * This method registers a callback function that will be called just before exit.
+ * This is usefull especially for Windows platform, on which Draw is normally
+ * self-terminated instead of exiting.
+ */
+ Standard_EXPORT static void AddCallbackBeforeTerminate(FCallbackBeforeTerminate theCB);
+
+ /**
+ * Just in case method for un-registering a callback previously registered by
+ * AddCallbackBeforeTerminate()
+ */
+ Standard_EXPORT static void RemoveCallbackBeforeTerminate(FCallbackBeforeTerminate theCB);
+
__Draw_API DrawWindow();
__Draw_API DrawWindow(char*, Standard_Integer, Standard_Integer,
Standard_Integer, Standard_Integer);