// purpose or non-infringement. Please see the License for the specific terms
// and conditions governing the rights and limitations under the License.
-// Updated by DPF Fri Mar 21 18:40:58 1997
-// Added casting in void to compile
-// on AO1 int 32 bits -> pointer 64 bits ????
-// Robert Boehne 30 May 2000 : Dec Osf
-
// include windows.h first to have all definitions available
#ifdef WNT
#include <windows.h>
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,
}
}
-#ifndef WNT
+#if !defined(_WIN32) && !defined(__WIN32__)
#ifdef HAVE_CONFIG_H
# include <config.h>
# 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
//=======================================================================
void Draw_Window::Destroy()
{
+ XFreeGC (Draw_WindowDisplay, base.gc);
XDestroyWindow(Draw_WindowDisplay, win);
win = 0;
if (myBuffer != 0)
return anImage.Save (theFileName);
}
+//=======================================================================
+//function : Wait
+//purpose :
+//=======================================================================
+
+void Draw_Window::Wait (Standard_Boolean wait)
+{
+ Flush();
+ if (!wait) {
+ XSelectInput(Draw_WindowDisplay,win,
+ ButtonPressMask|ExposureMask | StructureNotifyMask |
+ PointerMotionMask);
+ }
+ else {
+ XSelectInput(Draw_WindowDisplay,win,
+ ButtonPressMask|ExposureMask | StructureNotifyMask);
+ }
+}
+
//=======================================================================
//function : ProcessEvent
//purpose :
{
}
-//=======================================================================
-//function : Wait
-//purpose :
-//=======================================================================
-
-void Draw_Window::Wait (Standard_Boolean wait)
-{
- Flush();
- if (!wait) {
- XSelectInput(Draw_WindowDisplay,win,
- ButtonPressMask|ExposureMask | StructureNotifyMask |
- PointerMotionMask);
- }
- else {
- XSelectInput(Draw_WindowDisplay,win,
- ButtonPressMask|ExposureMask | StructureNotifyMask);
- }
-}
-
//=======================================================================
//function : WUnmapNotify
//purpose :
}
}
+//======================================================
+// funtion : GetNextEvent()
+// purpose :
+//======================================================
+void GetNextEvent(Event& ev)
+{
+ XEvent xev;
+ XNextEvent(Draw_WindowDisplay, &xev);
+ switch(xev.type)
+ {
+ case ButtonPress :
+ ev.type = 4;
+ ev.window = xev.xbutton.window;
+ ev.button = xev.xbutton.button;
+ ev.x = xev.xbutton.x;
+ ev.y = xev.xbutton.y;
+ break;
+
+ case MotionNotify :
+ ev.type = 6;
+ ev.window = xev.xmotion.window;
+ ev.button = 0;
+ ev.x = xev.xmotion.x;
+ ev.y = xev.xmotion.y;
+ break;
+ }
+}
+#endif //__APPLE__
+
//======================================================
// funtion :Run_Appli
// purpose :
// ConnectionNumber(Draw_WindowDisplay) is an int 32 bits
// (void*) is a pointer 64 bits ???????
+#if !defined(__APPLE__) || defined(MACOSX_USE_GLX)
#if TCL_MAJOR_VERSION < 8
Tk_CreateFileHandler((void*) ConnectionNumber(Draw_WindowDisplay),
TK_READABLE, ProcessEvents,(ClientData) 0 );
Tk_CreateFileHandler(ConnectionNumber(Draw_WindowDisplay),
TK_READABLE, ProcessEvents,(ClientData) 0 );
#endif
+#endif // __APPLE__
#endif
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 (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 !defined(__APPLE__) || defined(MACOSX_USE_GLX)
+ 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
Draw_WindowScreen = DefaultScreen(Draw_WindowDisplay);
Draw_WindowColorMap = DefaultColormap(Draw_WindowDisplay,
Draw_WindowScreen);
+#endif // __APPLE__
+
tty = isatty(0);
Tcl_SetVar(interp,"tcl_interactive",(char*)(tty ? "1" : "0"), TCL_GLOBAL_ONLY);
// Tcl_SetVar(interp,"tcl_interactive",tty ? "1" : "0", TCL_GLOBAL_ONLY);
//XCloseDisplay(Draw_WindowDisplay);
}
-//======================================================
-// funtion : GetNextEvent()
-// purpose :
-//======================================================
-void GetNextEvent(Event& ev)
-{
- XEvent xev;
- XNextEvent(Draw_WindowDisplay, &xev);
- switch(xev.type)
- {
- case ButtonPress :
- ev.type = 4;
- ev.window = xev.xbutton.window;
- ev.button = xev.xbutton.button;
- ev.x = xev.xbutton.x;
- ev.y = xev.xbutton.y;
- break;
-
- case MotionNotify :
- ev.type = 6;
- ev.window = xev.xmotion.window;
- ev.button = 0;
- ev.x = xev.xmotion.x;
- ev.y = xev.xmotion.y;
- break;
- }
-}
-
/*
*----------------------------------------------------------------------
*
// include decorations in the window dimensions
// to reproduce same behaviour of Xlib window.
- theXLeft -= GetSystemMetrics(SM_CXSIZEFRAME);
- theYTop -= GetSystemMetrics(SM_CYSIZEFRAME) + GetSystemMetrics(SM_CYCAPTION);
- theWidth += 2 * GetSystemMetrics(SM_CXSIZEFRAME);
- theHeight += 2 * GetSystemMetrics(SM_CYSIZEFRAME) + GetSystemMetrics(SM_CYCAPTION);
+ DWORD aWinStyle = GetWindowLongPtr (win, GWL_STYLE);
+ DWORD aWinStyleEx = GetWindowLongPtr (win, GWL_EXSTYLE);
+ HMENU aMenu = GetMenu (win);
- SetPosition (theXLeft, theYTop);
- SetDimension (theWidth, theHeight);
+ RECT aRect;
+ aRect.top = theYTop;
+ aRect.bottom = theYTop + theHeight;
+ aRect.left = theXLeft;
+ aRect.right = theXLeft + theWidth;
+ AdjustWindowRectEx (&aRect, aWinStyle, aMenu != NULL ? TRUE : FALSE, aWinStyleEx);
+
+ SetPosition (aRect.left, aRect.top);
+ SetDimension (aRect.right - aRect.left, aRect.bottom - aRect.top);
// Save the pointer at the instance associated to the window
SetWindowLong(win, CLIENTWND, (LONG)this);
HDC hDC = GetDC(win);
while (console_semaphore != WAIT_CONSOLE_COMMAND)
Sleep(100);
//if (gets(console_command))
- if (fgets(console_command,COMMAND_SIZE,stdin))
+ if (fgets(console_command,COMMAND_SIZE,stdin))
{
console_semaphore = HAS_CONSOLE_COMMAND;
}
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);
}