errChannel = Tcl_GetStdChannel(TCL_STDERR);
if (code != TCL_OK) {
if (errChannel) {
+#if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 5)))
+ Tcl_Write(errChannel, Tcl_GetStringResult(Interp), -1);
+#else
Tcl_Write(errChannel, Interp->result, -1);
+#endif
Tcl_Write(errChannel, "\n", 1);
}
Tcl_AddErrorInfo(Interp,
# include <strings.h>
#endif
-
-#include <Draw_WindowBase.hxx>
-#include <X11/XWDFile.h>
-
#include <stdio.h>
#include <tk.h>
static unsigned long thePixels[MAXCOLOR];
-
-Display* Draw_WindowDisplay = NULL;
Standard_Integer Draw_WindowScreen = 0;
-Colormap Draw_WindowColorMap;
Standard_Boolean Draw_BlackBackGround = Standard_True;
//======================================================
Draw_Window* Draw_Window::firstWindow = NULL;
+// X11 specific part
#if !defined(__APPLE__) || defined(MACOSX_USE_GLX)
+#include <X11/Xutil.h>
+#include <Aspect_DisplayConnection.hxx>
+
+Display* Draw_WindowDisplay = NULL;
+Colormap Draw_WindowColorMap;
+static Handle(Aspect_DisplayConnection) Draw_DisplayConnection;
+
+// Base_Window struct definition
+//===================================
+struct Base_Window
+{
+ GC gc;
+ XSetWindowAttributes xswa;
+};
+
//=======================================================================
//function : Draw_Window
//purpose :
//=======================================================================
void Draw_Window::Destroy()
{
+ XFreeGC (Draw_WindowDisplay, base.gc);
XDestroyWindow(Draw_WindowDisplay, win);
win = 0;
if (myBuffer != 0)
mainWindow =
Tk_MainWindow(interp) ;
if (mainWindow == NULL) {
+#if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 5)))
+ fprintf(stderr, "%s\n", Tcl_GetStringResult(interp));
+#else
fprintf(stderr, "%s\n", interp->result);
+#endif
exit(1);
}
Tk_Name(mainWindow) =
Tk_GeometryRequest(mainWindow, 200, 200);
#if !defined(__APPLE__) || defined(MACOSX_USE_GLX)
- if (Draw_WindowDisplay == NULL) {
- Draw_WindowDisplay = XOpenDisplay(NULL);
- // Replaced Tk_Display(mainWindow) with XOpenDisplay; On Mac OS X Tk_Display
- // returns a pointer to Display structure defined in system Tcl/Tk libraries.
- // This structure differs from structure defined in X11 library and
- // this caused DRAWEXE crash on startup.
+ if (Draw_DisplayConnection.IsNull())
+ {
+ try
+ {
+ Draw_DisplayConnection = new Aspect_DisplayConnection();
+ }
+ catch (Standard_Failure)
+ {
+ std::cout << "Cannot open display. Interpret commands in batch mode." << std::endl;
+ return Standard_False;
+ }
}
- if (Draw_WindowDisplay == NULL) {
- cout << "Cannot open display : "<<XDisplayName(NULL)<<endl;
- cout << "Interpret commands in batch mode."<<endl;
- return Standard_False;
+ if (Draw_WindowDisplay == NULL)
+ {
+ Draw_WindowDisplay = Draw_DisplayConnection->GetDisplay();
}
//
// synchronize the display server : could be done within Tk_Init
Standard_Integer res = Tk_Init (interp);
if (res != TCL_OK)
{
+#if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 5)))
+ cout << "tkLoop: error in Tk initialization. Tcl reported: " << Tcl_GetStringResult(interp) << endl;
+#else
cout << "tkLoop: error in Tk initialization. Tcl reported: " << interp->result << endl;
+#endif
}
}
catch (Standard_Failure)
mainWindow = Tk_MainWindow (interp);
if (mainWindow == NULL)
{
+#if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 5)))
+ fprintf (stderr, "%s\n", Tcl_GetStringResult(interp));
+#else
fprintf (stderr, "%s\n", interp->result);
+#endif
cout << "tkLoop: Tk_MainWindow() returned NULL. Exiting...\n";
Tcl_Exit (0);
}