1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0032308: Configuration - make Xlib dependency optional

MACOSX_USE_GLX has been renamed to HAVE_XLIB and now configurable on Linux target.

Xw_Window.hxx now export class on non-Linux platforms.
OpenGl_Window now creates an off-screen EGL surface also in case of
window-less desktop setup (e.g. with disabled Xlib on Linux).

Draw_Window - code has been cleaned up.
Class definition has been unified across platforms when possible.
Unusued constructors have been removed.
Internal header files (MainWindow.h, init.h, etc.) have been renamed to .pxx
to avoid their unexpected distribution in "inc".
This commit is contained in:
kgv
2021-04-16 16:12:16 +03:00
committed by bugmaster
parent e8e157df45
commit b69e576af0
48 changed files with 2288 additions and 3044 deletions

View File

@@ -348,6 +348,11 @@ static Standard_Integer dversion(Draw_Interpretor& di, Standard_Integer, const c
#else
di << "Tk disabled\n";
#endif
#ifdef HAVE_XLIB
di << "Xlib enabled (HAVE_XLIB)\n";
#elif !defined(_WIN32)
di << "Xlib disabled\n";
#endif
#ifdef HAVE_TBB
di << "TBB enabled (HAVE_TBB)\n";
#else

View File

@@ -20,42 +20,17 @@
//function : Draw_View
//purpose : Constructor
//=======================================================================
Draw_View::Draw_View(Standard_Integer theId,
Draw_Viewer* theViewer,
Standard_Integer theX,
Standard_Integer theY,
Standard_Integer theWidth,
Standard_Integer theHeight)
: Draw_Window("Win", theX, theY, theWidth, theHeight),
myId (theId),
myViewer (theViewer),
myIsPers (Standard_False),
myIs2D (Standard_False),
myFocalDistance(0.0),
myZoom (0.0),
myDx (0),
myDy (0),
myFrameX0 (0),
myFrameY0 (0),
myFrameX1 (0),
myFrameY1 (0)
{
memset (myType, 0, sizeof (myType));
}
//=======================================================================
//function : Draw_View
//purpose : Constructor
//=======================================================================
#if defined(_WIN32) || defined(__WIN32__)
Draw_View::Draw_View(Standard_Integer theId,
Draw_Viewer* theViewer,
Standard_Integer theX,
Standard_Integer theY,
Standard_Integer theWidth,
Standard_Integer theHeight,
HWND theWindow)
: Draw_Window("Win", theX, theY, theWidth, theHeight, theWindow),
Aspect_Drawable theWindow)
: Draw_Window ("Win",
NCollection_Vec2<int> (theX, theY),
NCollection_Vec2<int> (theWidth, theHeight),
0, theWindow),
myId (theId),
myViewer (theViewer),
myIsPers (Standard_False),
@@ -72,56 +47,28 @@ Draw_View::Draw_View(Standard_Integer theId,
memset (myType, 0, sizeof (myType));
}
//=======================================================================
//function : Draw_View
//purpose : Constructor
//=======================================================================
#elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
Draw_View::Draw_View(Standard_Integer theId,
Draw_Viewer* theViewer,
Standard_Integer theX,
Standard_Integer theY,
Standard_Integer theWidth,
Standard_Integer theHeight,
NSWindow* theWindow)
: Draw_Window(theWindow, "Win", theX, theY, theWidth, theHeight),
myId (theId),
myViewer (theViewer),
myIsPers (Standard_False),
myIs2D (Standard_False),
myFocalDistance(0.0),
myZoom (0.0),
myDx (0),
myDy (0),
myFrameX0 (0),
myFrameY0 (0),
myFrameX1 (0),
myFrameY1 (0)
//! Find window by it's XID - applicable only to X11.
static Aspect_Drawable findWindow (const char* theWindow)
{
memset (myType, 0, sizeof (myType));
}
#endif
//=======================================================================
//function : Draw_View
//purpose : Constructor
//=======================================================================
#if defined(_WIN32) || defined (__WIN32__) || (defined(__APPLE__) && !defined(MACOSX_USE_GLX))
Draw_View::Draw_View(Standard_Integer /*theId*/,
Draw_Viewer* /*theViewer*/,
const char* /*theTitle*/)
: Draw_Window (),
myId (-1),
myViewer (NULL),
Aspect_Drawable aWindow = 0;
#ifdef HAVE_XLIB
sscanf (theWindow, "%lx", &aWindow);
#else
(void )theWindow;
#endif
return aWindow;
}
//=======================================================================
//function : Draw_View
//purpose : Constructor
//=======================================================================
Draw_View::Draw_View(Standard_Integer theId,
Draw_Viewer* theViewer,
const char* theTitle)
: Draw_Window (theTitle),
: Draw_Window (theTitle, NCollection_Vec2<int>(0), NCollection_Vec2<int>(50), 0, findWindow (theTitle)),
myId (theId),
myViewer (theViewer),
#endif
myIsPers (Standard_False),
myIs2D (Standard_False),
myFocalDistance(0.0),

View File

@@ -24,30 +24,13 @@ class Draw_View : public Draw_Window
public:
//! Constructor
Draw_View(Standard_Integer theId,
Draw_Viewer* theViewer,
Standard_Integer theX,
Standard_Integer theY,
Standard_Integer theWidth,
Standard_Integer theHeight);
#if defined(_WIN32) || defined(__WIN32__)
Draw_View(Standard_Integer theId,
Draw_Viewer* theViewer,
Standard_Integer theX,
Standard_Integer theY,
Standard_Integer theWidth,
Standard_Integer theHeight,
HWND theWindow);
#elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
Draw_View(Standard_Integer theId,
Draw_Viewer* theViewer,
Standard_Integer theX,
Standard_Integer theY,
Standard_Integer theWidth,
Standard_Integer theHeight,
NSWindow* theWindow);
#endif
Aspect_Drawable theWindow = 0);
//! Constructor.
Draw_View(Standard_Integer theId,
@@ -59,85 +42,44 @@ public:
public: // @name getters and setters
//! Sets horizontal offset.
void SetDx(const Standard_Integer theDx)
{
myDx = theDx;
}
//! Sets vertical offset.
void SetDy(const Standard_Integer theDy)
{
myDy = theDy;
}
//! Sets parameter of zoom.
void SetZoom(const Standard_Real theZoom)
{
myZoom = theZoom;
}
//! Sets view matrix.
void SetMatrix(const gp_Trsf& theMatrix)
{
myMatrix = theMatrix;
}
//! Sets focal distance.
void SetFocalDistance(const Standard_Real theDistance)
{
myFocalDistance = theDistance;
}
//! Gets horizontal offset.
Standard_Integer GetDx() const
{
return myDx;
}
Standard_Integer GetDx() const { return myDx; }
//! Sets horizontal offset.
void SetDx (const Standard_Integer theDx) { myDx = theDx; }
//! Gets vertical offset.
Standard_Integer GetDy() const
{
return myDy;
}
Standard_Integer GetDy() const { return myDy; }
//! Sets vertical offset.
void SetDy (const Standard_Integer theDy) { myDy = theDy; }
//! Gets parameter of zoom.
Standard_Real GetZoom() const
{
return myZoom;
}
Standard_Real GetZoom() const { return myZoom; }
//! Sets parameter of zoom.
void SetZoom (const Standard_Real theZoom) { myZoom = theZoom; }
//! Gets matrix of view.
const gp_Trsf& GetMatrix() const
{
return myMatrix;
}
const gp_Trsf& GetMatrix() const { return myMatrix; }
//! Sets view matrix.
void SetMatrix (const gp_Trsf& theMatrix) { myMatrix = theMatrix; }
//! Gets focal distance.
Standard_Real GetFocalDistance() const
{
return myFocalDistance;
}
Standard_Real GetFocalDistance() const { return myFocalDistance; }
public: //! @name public inline methods
//! Sets focal distance.
void SetFocalDistance (const Standard_Real theDistance) { myFocalDistance = theDistance; }
//! Returns type of view.
const char* Type()
{
return myType;
}
const char* Type() { return myType; }
//! Returns true value if current view in 2D mode.
Standard_Boolean Is2D() const
{
return myIs2D;
}
Standard_Boolean Is2D() const { return myIs2D; }
//! Returns true value if current view in perspective mode.
Standard_Real IsPerspective() const
{
return myIsPers;
}
Standard_Real IsPerspective() const { return myIsPers; }
public: //! @name view API
@@ -155,7 +97,7 @@ public: //! @name view API
Standard_Integer& theX1,Standard_Integer& theY1);
//! Perform window exposing.
void WExpose();
virtual void WExpose() Standard_OVERRIDE;
protected:

View File

@@ -30,7 +30,7 @@ static const Standard_Real DRAWINFINITE = 1e50;
Standard_EXPORT Standard_Boolean Draw_Bounds = Standard_True;
extern Standard_Boolean Draw_Batch;
const Standard_Integer MAXSEGMENT = 1000;
Segment segm[MAXSEGMENT];
Draw_XSegment segm[MAXSEGMENT];
static int nbseg=0;
static Draw_View* curview = NULL;
static Standard_Integer curviewId = 0;
@@ -943,12 +943,17 @@ Draw_Display Draw_Viewer::MakeDisplay (const Standard_Integer id) const
//function : Select
//purpose :
//=======================================================================
void Draw_Viewer::Select (Standard_Integer& id, Standard_Integer& X, Standard_Integer& Y,
Standard_Integer& Button, Standard_Boolean wait)
void Draw_Viewer::Select (Standard_Integer& theId,
Standard_Integer& theX, Standard_Integer& theY,
Standard_Integer& theButton,
Standard_Boolean theToWait)
{
if (Draw_Batch) return;
id = X = Y = Button = 0;
if (Draw_Batch)
{
return;
}
theId = theX = theY = theButton = 0;
Standard_Boolean hasView = Standard_False;
for (int aViewIter = 0; aViewIter < MAXVIEW; ++aViewIter)
{
@@ -965,105 +970,142 @@ void Draw_Viewer::Select (Standard_Integer& id, Standard_Integer& X, Standard_In
return;
}
Flush();
#if !defined(_WIN32) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
if (!wait) {
if (id >=0 && id < MAXVIEW) {
if (myViews[id]) myViews[id]->Wait(wait);
#ifdef _WIN32
HANDLE hWnd = NULL;
theId = MAXVIEW; //:abv 29.05.02: cycle for working in console mode
while (theId >= MAXVIEW)
{
if (theToWait)
{
Draw_Window::SelectWait (hWnd, theX, theY, theButton);
}
else
{
Draw_Window::SelectNoWait (hWnd, theX, theY, theButton);
}
// Recherche du numero de la vue grace au HANDLE
for (int aViewIter = 0; aViewIter < MAXVIEW; ++aViewIter)
{
if (myViews[aViewIter] != NULL
&& myViews[aViewIter]->IsEqualWindows (hWnd))
{
theId = aViewIter;
}
}
}
else {
for(int i=0 ; i<MAXVIEW ; i++)
if (myViews[i]) myViews[i]->Wait(wait);
theX = theX - myViews[theId]->GetDx();
theY = -theY - myViews[theId]->GetDy();
#elif defined(HAVE_XLIB)
if (!theToWait)
{
if (theId >= 0 && theId < MAXVIEW)
{
if (myViews[theId] != NULL)
{
myViews[theId]->Wait (theToWait);
}
}
}
else
{
for (int aViewIter = 0; aViewIter < MAXVIEW; ++aViewIter)
{
if (myViews[aViewIter] != NULL)
{
myViews[aViewIter]->Wait (theToWait);
}
}
}
Standard_Boolean again = Standard_True;
while (again) {
Event ev;
while (again)
{
Draw_Window::Draw_XEvent ev;
ev.type = 0;
GetNextEvent(ev);
switch (ev.type) {
case ButtonPress :
Standard_Integer iv;
for (iv = 0; iv < MAXVIEW; iv++) {
if (myViews[iv]) {
if (myViews[iv]->win == ev.window)
break;
}
Draw_Window::GetNextEvent (ev);
switch (ev.type)
{
case ButtonPress:
{
Standard_Integer aViewIter = 0;
for (; aViewIter < MAXVIEW; ++aViewIter)
{
if (myViews[aViewIter] != NULL
&& myViews[aViewIter]->IsEqualWindows (ev.window))
{
break;
}
}
if (theToWait || theId == aViewIter)
{
if (aViewIter < MAXVIEW)
{
theId = aViewIter;
theX = ev.x;
theY = ev.y;
theButton = ev.button;
}
else
{
theId = -1;
}
again = Standard_False;
}
break;
}
if (wait || id == iv) {
if (iv < MAXVIEW) {
id = iv;
X = ev.x;
Y = ev.y;
Button = ev.button;
}
else {
id = -1;
}
again = Standard_False;
case MotionNotify:
{
if (theToWait)
{
break;
}
theX = ev.x;
theY = ev.y;
theButton = 0;
again = Standard_False;
break;
}
break;
case MotionNotify :
if (wait) break;
X = ev.x;
Y = ev.y;
Button = 0;
again = Standard_False;
break;
}
}
if (id != -1) {
X = X - myViews[id]->GetDx();
Y = -Y - myViews[id]->GetDy();
}
if (!wait) myViews[id]->Wait(!wait);
#elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
Standard_Integer aWindowNumber;
id = MAXVIEW;
while (id >= MAXVIEW)
if (theId != -1)
{
GetNextEvent(wait, aWindowNumber, X, Y, Button);
if (Y < 0)
theX = theX - myViews[theId]->GetDx();
theY = -theY - myViews[theId]->GetDy();
}
if (!theToWait)
{
myViews[theId]->Wait (!theToWait);
}
#elif defined(__APPLE__)
theId = MAXVIEW;
while (theId >= MAXVIEW)
{
Standard_Integer aWindowNumber = 0;
Draw_Window::GetNextEvent (theToWait, aWindowNumber, theX, theY, theButton);
if (theY < 0)
{
continue; // mouse clicked on window title
}
for (Standard_Integer anIter = 0; anIter < MAXVIEW; anIter++)
for (Standard_Integer aViewIter = 0; aViewIter < MAXVIEW; ++aViewIter)
{
if (myViews[anIter] && myViews[anIter]->IsEqualWindows (aWindowNumber))
if (myViews[aViewIter] != NULL
&& myViews[aViewIter]->IsEqualWindows (aWindowNumber))
{
id = anIter;
theId = aViewIter;
}
}
}
X = X - myViews[id]->GetDx();
Y = -Y - myViews[id]->GetDy();
theX = theX - myViews[theId]->GetDx();
theY = -theY - myViews[theId]->GetDy();
#else
HANDLE hWnd;
id = MAXVIEW; //:abv 29.05.02: cycle for working in console mode
while ( id >= MAXVIEW ) {
if (wait)
Draw_Window::SelectWait(hWnd, X, Y, Button);
else
Draw_Window::SelectNoWait(hWnd, X, Y, Button);
// Recherche du numero de la vue grace au HANDLE
for(int i=0 ; i<MAXVIEW ; i++)
if (myViews[i] && myViews[i]->win == hWnd ) id = i;
}
X = X - myViews[id]->GetDx();
Y = -Y - myViews[id]->GetDy();
// not implemented
(void )theToWait;
#endif
}

View File

@@ -15,14 +15,15 @@
// commercial license or contractual agreement.
#ifdef _WIN32
#include <windows.h>
#include <Draw_Window.hxx>
#include <Draw_Appli.hxx>
#include <TCollection_AsciiString.hxx>
#include <MainWindow.h>
#include <CommandWindow.h>
#include "Draw_WNTMainWindow.pxx"
#include "Draw_WNTCommandWindow.pxx"
#define CLIENTWND 0
@@ -49,11 +50,10 @@ HWND CreateCommandWindow(HWND hWnd, int /*nitem*/)
0, 0, 400, 100,
hWnd, NULL, hInstance, NULL);
ShowWindow(hWndCommand, SW_SHOW);
ShowWindow (hWndCommand, SW_SHOW);
return hWndCommand;
}
/*--------------------------------------------------------*\
| COMMAND WINDOW PROCEDURE
\*--------------------------------------------------------*/
@@ -125,7 +125,7 @@ BOOL CommandCreateProc(HWND hWnd)
/*--------------------------------------------------------*\
| GET COMMAND
|
|
\*--------------------------------------------------------*/
int GetCommand (HWND hWnd, wchar_t* theBuffer)
{
@@ -141,7 +141,7 @@ int GetCommand (HWND hWnd, wchar_t* theBuffer)
// Initialization of the 1st WORD to the nb of characters to read
WORD* aNbMaxChar = (WORD* )aTempBuff;
*aNbMaxChar = COMMANDSIZE - 1;
const int aNbCharRead = (int )SendMessageW (hWnd, EM_GETLINE, aNbLine - 1, (LPARAM )aTempBuff);
aNbChar += aNbCharRead;
const bool isPromp = wcsncmp (aTempBuff, THE_PROMPT, 10) == 0;
@@ -162,7 +162,7 @@ int GetCommand (HWND hWnd, wchar_t* theBuffer)
\*--------------------------------------------------------*/
LRESULT APIENTRY EditProc(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam )
{
static LRESULT nbline; // Process the buffer of the edit window
static LRESULT nbline; // Process the buffer of the edit window
switch (wMsg)
{
case WM_CHAR:

View File

@@ -16,25 +16,19 @@
#ifdef _WIN32
#define COMMANDCLASS L"COMMANDWINDOW"
#define COMMANDTITLE L"Command Window"
HWND CreateCommandWindow(HWND, int);
LRESULT APIENTRY CommandProc(HWND, UINT, WPARAM, LPARAM);
BOOL CommandCreateProc(HWND);
VOID CommandDestroyProc(HWND);
BOOL CommandHandler(HWND, WPARAM, LPARAM);
#include <sys/stat.h>
#include <tcl.h>
#include <Standard_Stream.hxx>
#include <stdio.h>
//#include <io.h>
#include <fcntl.h>
#endif

View File

@@ -20,22 +20,19 @@
#include <windows.h>
#include "Draw_Window.hxx"
#include "DrawRessource.h"
#include "init.h"
#include "MainWindow.h"
#include "CommandWindow.h"
#include "Draw_WNTRessource.pxx"
#include "Draw_WNTInit.pxx"
#include "Draw_WNTMainWindow.pxx"
#include "Draw_WNTCommandWindow.pxx"
#define USEDEFAULT 200
/*--------------------------------------------------------*\
| REGISTER APPLICATION CLASS
| Enregistrement des classes de fenetres de l'application
|
d\*--------------------------------------------------------*/
BOOL RegisterAppClass(HINSTANCE hInstance)
\*--------------------------------------------------------*/
BOOL RegisterAppClass (HINSTANCE theInstance)
{
WNDCLASSW wndClass;
@@ -44,36 +41,35 @@ BOOL RegisterAppClass(HINSTANCE hInstance)
wndClass.style = CS_HREDRAW | CS_VREDRAW | CS_CLASSDC;
wndClass.cbClsExtra = 0;
wndClass.hCursor = LoadCursor (NULL, IDC_ARROW);
wndClass.hInstance = hInstance;
wndClass.hInstance = theInstance;
// Enregistrement de la fenetre principale
//-----
wndClass.cbWndExtra = sizeof(void*);
wndClass.lpfnWndProc = (WNDPROC)WndProc;
wndClass.hIcon = LoadIconW (hInstance, MAKEINTRESOURCEW(IDI_ICON1));
wndClass.hIcon = LoadIconW (theInstance, MAKEINTRESOURCEW(IDI_ICON1));
wndClass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
wndClass.lpszMenuName = MAKEINTRESOURCEW(APPMENU);
wndClass.lpszClassName = APPCLASS;
if(!RegisterClassW(&wndClass))
return(FALSE);
if (!RegisterClassW (&wndClass))
{
return FALSE;
}
// Enregistrement de la fenetre DrawWindow
//------
wndClass.cbWndExtra = sizeof(void*); // Extra Memory
wndClass.lpfnWndProc = (WNDPROC)DrawWindow::DrawProc;
wndClass.lpfnWndProc = (WNDPROC)Draw_Window::DrawProc;
wndClass.hIcon = 0;
wndClass.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);
wndClass.lpszMenuName = NULL;
wndClass.lpszClassName = DRAWCLASS;
if(!RegisterClassW(&wndClass))
if (!RegisterClassW (&wndClass))
{
UnregisterClassW(APPCLASS, hInstance);
return(FALSE);
UnregisterClassW (APPCLASS, theInstance);
return FALSE;
}
// Enregistrement de la fenetre CommandWindow
//------
wndClass.lpfnWndProc = (WNDPROC)CommandProc;
@@ -81,68 +77,58 @@ BOOL RegisterAppClass(HINSTANCE hInstance)
wndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndClass.lpszMenuName = NULL;
wndClass.lpszClassName = COMMANDCLASS;
if(!RegisterClassW(&wndClass))
if (!RegisterClassW (&wndClass))
{
UnregisterClassW(APPCLASS, hInstance);
UnregisterClassW(DRAWCLASS, hInstance);
return(FALSE);
UnregisterClassW (APPCLASS, theInstance);
UnregisterClassW (DRAWCLASS, theInstance);
return FALSE;
}
return(TRUE);
return TRUE;
}
/*--------------------------------------------------------*\
| UNREGISTER APPLICATION CLASS
| Suppression des classes de fenetres de l'application
|
\*--------------------------------------------------------*/
VOID UnregisterAppClass(HINSTANCE hInstance)
VOID UnregisterAppClass (HINSTANCE theInstance)
{
UnregisterClassW(APPCLASS, hInstance);
UnregisterClassW(DRAWCLASS, hInstance);
UnregisterClassW (APPCLASS, theInstance);
UnregisterClassW (DRAWCLASS, theInstance);
}
/*--------------------------------------------------------*\
| CREATE APPLICATION WINDOW
| Creation de la fenetre Top-Level
|
\*--------------------------------------------------------*/
HWND CreateAppWindow(HINSTANCE hInstance)
HWND CreateAppWindow (HINSTANCE theInstance)
{
return(CreateWindowW(APPCLASS, APPTITLE,
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
400,0,
623,767,
NULL, NULL, hInstance, NULL));
return CreateWindowW (APPCLASS, APPTITLE,
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
400, 0,
623,767,
NULL, NULL, theInstance, NULL);
}
/*--------------------------------------------------------*\
| CREATE MDI CLIENT WINDOW
| Creation de la fenetre qui contient des fenetres MDI
|
\*--------------------------------------------------------*/
HWND CreateMDIClientWindow(HWND hWndFrame)
HWND CreateMDIClientWindow (HWND theWndFrame)
{
HWND hWndClient;
HANDLE hInstance;
CLIENTCREATESTRUCT ccs;
// Initialisation de la structure client
ccs.hWindowMenu = NULL;
ccs.idFirstChild = 0;
hInstance = (HANDLE)GetWindowLongPtrW(hWndFrame, GWLP_HINSTANCE);
hWndClient = CreateWindowW(L"MDICLIENT",NULL,
WS_CHILD | WS_CLIPSIBLINGS |
WS_VISIBLE | MDIS_ALLCHILDSTYLES,
0, 0, 1, 1,
hWndFrame, NULL,
(HINSTANCE)hInstance, (LPVOID)&ccs);
return(hWndClient);
HINSTANCE hInstance = (HINSTANCE )GetWindowLongPtrW (theWndFrame, GWLP_HINSTANCE);
HWND hWndClient = CreateWindowW (L"MDICLIENT", NULL,
WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | MDIS_ALLCHILDSTYLES,
0, 0, 1, 1,
theWndFrame, NULL,
hInstance, (LPVOID )&ccs);
return hWndClient;
}
#endif

View File

@@ -25,5 +25,4 @@ VOID UnregisterAppClass(HINSTANCE);
HWND CreateAppWindow(HINSTANCE);
HWND CreateMDIClientWindow(HWND);
#endif

View File

@@ -17,18 +17,17 @@
#ifdef _WIN32
#include <windows.h>
#include <DrawRessource.h>
#include <init.h>
#include <Draw_Window.hxx>
#include <MainWindow.h>
#include <CommandWindow.h>
#include "Draw_WNTCommandWindow.pxx"
#include "Draw_WNTInit.pxx"
#include "Draw_WNTMainWindow.pxx"
#include "Draw_WNTRessource.pxx"
Standard_Boolean Draw_Interprete(const char* command); // Implemented in Draw.cxx
extern Standard_Boolean Draw_IsConsoleSubsystem;
//extern "C" int compat_unlink(const char *fname); // Implemente dans TCL
/*--------------------------------------------------------*\
| CLIENT WINDOW PROCEDURE
|
@@ -42,7 +41,7 @@ LRESULT APIENTRY WndProc(HWND hWndFrame, UINT wMsg, WPARAM wParam, LPARAM lParam
{
CreateProc (hWndFrame);
HWND hWndClient = (HWND )GetWindowLongPtrW (hWndFrame, CLIENTWND);
DrawWindow::hWndClientMDI = hWndClient;
Draw_Window::hWndClientMDI = hWndClient;
if (!Draw_IsConsoleSubsystem)
{
CreateCommandWindow (hWndFrame, 0);
@@ -82,10 +81,9 @@ BOOL CreateProc(HWND hWndFrame)
return(TRUE);
}
/*--------------------------------------------------------------------------*\
| COMMAND PROCEDURE
| Handler for message WM_COMMAND
| Handler for message WM_COMMAND
| It is used when Draw_IsConsoleSubsystem = Standard_False
| i.e. in non-console mode (see Draw_main() in Draw_Main.cxx).
\*--------------------------------------------------------------------------*/
@@ -138,7 +136,6 @@ LRESULT APIENTRY CmdProc(HWND hWndFrame, UINT wMsg, WPARAM /*wParam*/, LPARAM /*
return 0;
}
/*--------------------------------------------------------------------------*\
| CLIENT DESTROY PROCEDURE
| Handler for message WM_DESTROY.
@@ -152,4 +149,3 @@ VOID DestroyProc(HWND hWnd)
PostQuitMessage(0);
}
#endif

View File

@@ -15,10 +15,10 @@
*/
/****************************************************\
*/
*/
/** MainWindow.h
*/
/*\****************************************************/
*/
/*****************************************************/
#ifdef _WIN32
#define CLIENTWND 0
@@ -33,5 +33,4 @@ BOOL CreateProc(HWND);
VOID DestroyProc(HWND);
LRESULT APIENTRY CmdProc(HWND, UINT, WPARAM, LPARAM);
#endif

View File

@@ -31,7 +31,7 @@
#define ID_COMMAND_SHOW 40006
// Next default values for new objects
//
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 109
@@ -41,6 +41,4 @@
#endif
#endif
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -17,211 +17,78 @@
#ifndef Draw_Window_HeaderFile
#define Draw_Window_HeaderFile
#if defined(_WIN32)
#include <windows.h>
#endif
#include <Aspect_Drawable.hxx>
#include <NCollection_Vec2.hxx>
#include <Standard_Boolean.hxx>
#include <Standard_Integer.hxx>
#include <TCollection_AsciiString.hxx>
#if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
#include <memory>
const Standard_Integer MAXCOLOR = 15;
//! Segment definition.
struct Draw_XSegment
{
NCollection_Vec2<short> Points[2]; // same as XSegment
NCollection_Vec2<short>& operator[](int theIndex) { return Points[theIndex]; }
const NCollection_Vec2<short>& operator[](int theIndex) const { return Points[theIndex]; }
void Init (Standard_Integer theXStart, Standard_Integer theYStart, Standard_Integer theXEnd, Standard_Integer theYEnd)
{
Points[0].SetValues ((short )theXStart, (short )theYStart);
Points[1].SetValues ((short )theXEnd, (short )theYEnd);
}
};
#if defined(_WIN32)
#define DRAWCLASS L"DRAWWINDOW"
#define DRAWTITLE L"Draw View"
enum console_semaphore_value
{
STOP_CONSOLE,
WAIT_CONSOLE_COMMAND,
HAS_CONSOLE_COMMAND
};
// global variable describing console state
extern console_semaphore_value volatile console_semaphore;
// Console command buffer
#define DRAW_COMMAND_SIZE 1000
extern wchar_t console_command[DRAW_COMMAND_SIZE + 1];
// PROCEDURE DE DRAW WINDOW
Standard_EXPORT Standard_Boolean Init_Appli(HINSTANCE,HINSTANCE,int,HWND&);
Standard_EXPORT void Run_Appli(HWND);
Standard_EXPORT void Destroy_Appli(HINSTANCE);
#else
//! Run the application.
//! interp will be called to interpret a command and return True if the command is complete.
void Run_Appli (Standard_Boolean (*inteprete) (const char*));
//! Initialize application.
Standard_Boolean Init_Appli();
//! Destroy application.
void Destroy_Appli();
#if defined(HAVE_XLIB)
typedef unsigned long Window;
typedef unsigned long Pixmap;
typedef unsigned long Drawable;
// Definition de la class Base_Window (Definie dans Draw_Window.cxx)
//===================================
struct Base_Window;
// Definition de la classe Segment
//================================
struct Segment
{
short xx1;
short yy1;
short xx2;
short yy2;
void Init(short x1, short y1, short x2, short y2) {
xx1 = x1; yy1 = y1; xx2 = x2; yy2 = y2;
}
};
// Definition de la structure Event
//=================================
typedef struct Event
{
Standard_Integer type;
Window window;
Standard_Integer button;
Standard_Integer x;
Standard_Integer y;
} Event;
// Definition de la classe Draw_Window
//====================================
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 useful 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,
Standard_Integer DX = 50, Standard_Integer DY = 50);
Draw_Window (Window mother);
Draw_Window (Window mother,char* title,
Standard_Integer X = 0, Standard_Integer Y = 0,
Standard_Integer DX = 50, Standard_Integer DY = 50);
Draw_Window(const char *window);
void Init (Standard_Integer X = 0, Standard_Integer Y = 0,
Standard_Integer DX = 50, Standard_Integer DY = 50);
void Init (Window mother,
Standard_Integer X = 0, Standard_Integer Y = 0,
Standard_Integer DX = 50, Standard_Integer DY = 50);
void StopWinManager();
void SetPosition (Standard_Integer NewXpos,
Standard_Integer NewYpos);
void SetDimension(Standard_Integer NewDx,
Standard_Integer NewDy);
void GetPosition(Standard_Integer &PosX,
Standard_Integer &PosY);
Standard_Integer HeightWin() const;
Standard_Integer WidthWin() const;
void SetTitle (const TCollection_AsciiString& theTitle);
TCollection_AsciiString GetTitle() const;
//! Return true if window is displayed on the screen.
bool IsMapped() const;
void DisplayWindow();
void Hide();
void Destroy();
void Clear();
void Wait(Standard_Boolean wait = Standard_True);
Drawable GetDrawable() const;
// Initializes off-screen image buffer according to current window size
void InitBuffer();
static Standard_Boolean DefineColor(const Standard_Integer, const char*);
void SetColor(int);
void SetMode(int);
void DrawString(int, int, char*);
void DrawSegments(Segment* ,int);
void Redraw();
static void Flush();
// save snapshot
Standard_Boolean Save(const char* theFileName) const;
virtual ~Draw_Window ();
// X Event management
virtual void WExpose();
virtual void WButtonPress(const Standard_Integer X,
const Standard_Integer Y,
const Standard_Integer& button);
virtual void WButtonRelease(const Standard_Integer X,
const Standard_Integer Y,
const Standard_Integer& button);
//virtual void WKeyPress(char, KeySym& );
virtual void WMotionNotify(const Standard_Integer X,
const Standard_Integer Y);
virtual void WConfigureNotify(const Standard_Integer X,
const Standard_Integer Y,
const Standard_Integer dx,
const Standard_Integer dy);
virtual void WUnmapNotify();
Base_Window& base;
Window win;
Window myMother; // default : myMother is the root window
Pixmap myBuffer;
static Draw_Window* firstWindow;
Draw_Window* next;
Draw_Window* previous;
Standard_Boolean myUseBuffer;
Standard_Boolean withWindowManager;
};
//======================================================
// function : Run_Appli
// purpose : run the application
// interp will be called to interpret a command
// and return True if the command is complete
//======================================================
void Run_Appli(Standard_Boolean (*inteprete) (const char*));
//======================================================
// function : Init_Appli
// purpose :
//======================================================
Standard_Boolean Init_Appli();
//======================================================
// function : Destroy_Appli()
// purpose :
//======================================================
void Destroy_Appli();
//======================================================
// function : GetNextEvent()
// purpose :
//======================================================
void GetNextEvent(Event&);
#elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
const Standard_Integer MAXCOLOR = 15;
struct Segment
{
Standard_Integer myXStart;
Standard_Integer myYStart;
Standard_Integer myXEnd;
Standard_Integer myYEnd;
void Init(short theXStart, short theYStart, short theXEnd, short theYEnd) {
myXStart = theXStart; myYStart = theYStart; myXEnd = theXEnd; myYEnd = theYEnd;
}
};
#elif defined(__APPLE__)
#ifdef __OBJC__
@class NSView;
@class NSWindow;
@@ -233,308 +100,198 @@ struct Segment
struct NSImage;
struct Draw_CocoaView;
#endif
#endif
#endif
//! Draw window.
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 useful 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,
const Standard_Integer& theWidth = 50, const Standard_Integer& theHeight = 50);
Draw_Window (NSWindow* theWindow, Standard_CString theTitle,
const Standard_Integer& theXLeft = 0, const Standard_Integer& theYTop = 0,
const Standard_Integer& theWidth = 50, const Standard_Integer& theHeight = 50);
void Init (const Standard_Integer& theXLeft = 0, const Standard_Integer& theYLeft = 0,
const Standard_Integer& theWidth = 50, const Standard_Integer& theHeight = 50);
virtual ~Draw_Window ();
void SetPosition (const Standard_Integer& theNewXpos,
const Standard_Integer& theNewYpos);
void SetDimension (const Standard_Integer& theNewWidth,
const Standard_Integer& theNewHeight);
void GetPosition (Standard_Integer &thePosX,
Standard_Integer &thePosY);
Standard_Integer HeightWin() const;
Standard_Integer WidthWin() const;
void SetTitle (const TCollection_AsciiString& theTitle);
TCollection_AsciiString GetTitle() const;
//! Return true if window is displayed on the screen.
bool IsMapped() const;
void DisplayWindow();
void Hide();
void Destroy();
void Clear();
void InitBuffer();
static Standard_Boolean DefineColor (const Standard_Integer&, Standard_CString);
void SetColor (const Standard_Integer& theColor);
void SetMode (const Standard_Integer& theMode);
void DrawString (const Standard_Integer& theX, const Standard_Integer& theY, char* theText);
void DrawSegments (Segment* theSegment, const Standard_Integer& theNumberOfElements);
void Redraw();
static void Flush();
// save snapshot
Standard_Boolean Save (Standard_CString theFileName) const;
Standard_Boolean IsEqualWindows (const Standard_Integer& theWindowNumber);
private:
NSWindow* myWindow;
Draw_CocoaView* myView;
NSImage* myImageBuffer;
Standard_Boolean myUseBuffer;
Standard_Integer myCurrentColor;
static Draw_Window* firstWindow;
Draw_Window* nextWindow;
Draw_Window* previousWindow;
};
//======================================================
// function : Run_Appli
// purpose : run the application
// interp will be called to interpret a command
// and return True if the command is complete
//======================================================
void Run_Appli(Standard_Boolean (*inteprete) (const char*));
//======================================================
// function : Init_Appli
// purpose :
//======================================================
Standard_Boolean Init_Appli();
//======================================================
// function : Destroy_Appli()
// purpose :
//======================================================
void Destroy_Appli();
//======================================================
// function : GetNextEvent()
// purpose :
//======================================================
void GetNextEvent (Standard_Boolean theWait,
Standard_Integer& theWindowNumber,
Standard_Integer& theX,
Standard_Integer& theY,
Standard_Integer& theButton);
#else
// Specifique WNT
#include <windows.h>
#define DRAWCLASS L"DRAWWINDOW"
#define DRAWTITLE L"Draw View"
#define MAXCOLOR 15
// definition de la classe Segment
class DrawWindow;
class Segment
{
friend class DrawWindow;
public :
//constructeur
Segment ()
: x1(0),
y1(0),
x2(0),
y2(0)
{
}
//destructeur
~Segment () {}
//methods
void Init(Standard_Integer,
Standard_Integer,
Standard_Integer,
Standard_Integer);
private:
//atributs :
Standard_Integer x1;
Standard_Integer y1;
Standard_Integer x2;
Standard_Integer y2;
};
//definition de la classe DRAWWINDOW
class DrawWindow
{
//constructeur
public:
/**
* Type of the callback function that is to be passed to the method
* AddCallbackBeforeTerminate().
*/
//! 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 useful especially for Windows platform, on which Draw is normally
* self-terminated instead of exiting.
*/
Standard_EXPORT static void AddCallbackBeforeTerminate(FCallbackBeforeTerminate theCB);
//! This method registers a callback function that will be called just before exit.
//! This is useful 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);
//! Just in case method for un-registering a callback previously registered by AddCallbackBeforeTerminate().
Standard_EXPORT static void RemoveCallbackBeforeTerminate (FCallbackBeforeTerminate theCB);
Standard_EXPORT DrawWindow();
Standard_EXPORT DrawWindow(const char*, Standard_Integer, Standard_Integer,
Standard_Integer, Standard_Integer);
Standard_EXPORT DrawWindow(const char*, Standard_Integer, Standard_Integer,
Standard_Integer, Standard_Integer, HWND);
//destructeur
Standard_EXPORT virtual ~DrawWindow();
//! @sa SetColor()
Standard_EXPORT static Standard_Boolean DefineColor (const Standard_Integer theIndex,
const char* theColorName);
//! XFlush() wrapper (X11), has no effect on other platforms.
Standard_EXPORT static void Flush();
//methods
public:
Standard_EXPORT void Init(Standard_Integer, Standard_Integer,
Standard_Integer, Standard_Integer);
Standard_EXPORT void SetUseBuffer(Standard_Boolean);
// Turns on/off usage of off-screen image buffer (can be used for redrawing optimization)
//! Destructor.
Standard_EXPORT virtual ~Draw_Window();
Standard_Boolean GetUseBuffer() const { return myUseBuffer; }
// Returns Standard_True if off-screen image buffer is being used
//! Get window position.
Standard_EXPORT void GetPosition (Standard_Integer& thePosX,
Standard_Integer& thePosY);
//taille et position
Standard_EXPORT void SetPosition (Standard_Integer,Standard_Integer);
Standard_EXPORT void SetDimension(Standard_Integer,Standard_Integer);
Standard_EXPORT void GetPosition (Standard_Integer&,Standard_Integer&);
//! Set window position.
Standard_EXPORT void SetPosition (Standard_Integer theNewXpos,
Standard_Integer theNewYpos);
//! Return window height.
Standard_EXPORT Standard_Integer HeightWin() const;
Standard_EXPORT Standard_Integer WidthWin() const;
//Title
Standard_EXPORT void SetTitle (const TCollection_AsciiString& );
//! Return window width.
Standard_EXPORT Standard_Integer WidthWin() const;
//! Set window dimensions.
Standard_EXPORT void SetDimension (Standard_Integer theNewDx,
Standard_Integer theNewDy);
//! Return window title.
Standard_EXPORT TCollection_AsciiString GetTitle() const;
//Affichage
//! Return true if window is displayed on the screen.
bool IsMapped() const;
//! Set window title.
Standard_EXPORT void SetTitle (const TCollection_AsciiString& theTitle);
//! Return true if window is displayed on the screen.
Standard_EXPORT bool IsMapped() const;
//! Display window on the screen.
Standard_EXPORT void DisplayWindow();
//! Hide window.
Standard_EXPORT void Hide();
//! Destroy window.
Standard_EXPORT void Destroy();
//! Clear window content.
Standard_EXPORT void Clear();
static void Flush() {} ;
// save snapshot
Standard_EXPORT Standard_Boolean Save(const char* theFileName) const;
//! Returns Standard_True if off-screen image buffer is being used
Standard_Boolean GetUseBuffer() const { return myUseBuffer; }
//Dessin
Standard_EXPORT void DrawString(int,int,char*);
Standard_EXPORT void DrawSegments(Segment*,int);
// Turns on/off usage of off-screen image buffer (can be used for redrawing optimization)
Standard_EXPORT void SetUseBuffer (Standard_Boolean theToUse);
Standard_EXPORT void InitBuffer();
// Initializes off-screen image buffer according to current window size
//! Set active color index for further paintings.
//! @sa DefineColor()
Standard_EXPORT void SetColor (Standard_Integer theColor);
//! Set active paint mode (3 for COPY; 6 for XOR).
Standard_EXPORT void SetMode (Standard_Integer theMode);
//! Draw the string.
Standard_EXPORT void DrawString (Standard_Integer theX, Standard_Integer theY,
const char* theText);
//! Draw array of segments.
Standard_EXPORT void DrawSegments (const Draw_XSegment* theSegments,
Standard_Integer theNumberOfElements);
//! Redraw window content.
Standard_EXPORT void Redraw();
// Copies an image from memory buffer to screen
//Couleur
Standard_EXPORT void SetColor(Standard_Integer);
Standard_EXPORT void SetMode(int);
Standard_EXPORT static Standard_Boolean DefineColor ( const Standard_Integer,const char*);
//! Save snapshot.
Standard_EXPORT Standard_Boolean Save (const char* theFileName) const;
//Gestion des Messages
Standard_EXPORT virtual void WExpose ();
Standard_EXPORT virtual void WButtonPress(const Standard_Integer,const Standard_Integer,
const Standard_Integer&);
Standard_EXPORT virtual void WButtonRelease(const Standard_Integer,const Standard_Integer,
const Standard_Integer&);
Standard_EXPORT virtual void WMotionNotify(const Standard_Integer,const Standard_Integer);
Standard_EXPORT virtual void WConfigureNotify(const Standard_Integer,const Standard_Integer,
const Standard_Integer,const Standard_Integer);
Standard_EXPORT virtual void WUnmapNotify();
//! Perform window exposing.
virtual void WExpose() = 0;
//Gestion souris
Standard_EXPORT static void SelectWait (HANDLE&,int&,int&,int&);
Standard_EXPORT static void SelectNoWait (HANDLE&,int&,int&,int&);
//! (Re)initializes off-screen image buffer according to current window size.
Standard_EXPORT void InitBuffer();
// Procedure de fenetre
Standard_EXPORT static LRESULT APIENTRY DrawProc (HWND,UINT,WPARAM,LPARAM);
protected:
private:
//! Main constructor.
//! @param theTitle [in] window title
//! @param theXY [in] top-left position
//! @param theSize [in] window dimensions
//! @param theParent [in] optional native parent window
//! @param theWin [in] optional native window
Standard_EXPORT Draw_Window (const char* theTitle,
const NCollection_Vec2<int>& theXY,
const NCollection_Vec2<int>& theSize,
Aspect_Drawable theParent,
Aspect_Drawable theWin);
Standard_EXPORT static HWND CreateDrawWindow(HWND,int);
Standard_EXPORT HDC GetMemDC(HDC);
Standard_EXPORT void ReleaseMemDC(HDC);
//! Initialize the window.
Standard_EXPORT void init (const NCollection_Vec2<int>& theXY,
const NCollection_Vec2<int>& theSize);
//atributs
public:
HWND win;
#if defined(_WIN32)
Standard_Boolean IsEqualWindows (HANDLE theWindow) { return myWindow == theWindow; }
Standard_EXPORT static void SelectWait (HANDLE& theWindow, int& theX, int& theY, int& theButton);
Standard_EXPORT static void SelectNoWait (HANDLE& theWindow, int& theX, int& theY, int& theButton);
// Procedure de fenetre
Standard_EXPORT static LRESULT APIENTRY DrawProc (HWND, UINT, WPARAM, LPARAM);
static HWND hWndClientMDI;
#elif defined(HAVE_XLIB)
Standard_Boolean IsEqualWindows (Window theWindow) { return myWindow == theWindow; }
//! Event structure.
struct Draw_XEvent
{
Standard_Integer type;
Window window;
Standard_Integer button;
Standard_Integer x;
Standard_Integer y;
};
//! Retrieve event.
static void GetNextEvent (Draw_XEvent& theEvent);
void Wait (Standard_Boolean theToWait = Standard_True);
#elif defined(__APPLE__)
Standard_Boolean IsEqualWindows (const Standard_Integer& theWindowNumber);
static void GetNextEvent (Standard_Boolean theWait,
Standard_Integer& theWindowNumber,
Standard_Integer& theX,
Standard_Integer& theY,
Standard_Integer& theButton);
#endif
private:
static DrawWindow* firstWindow;
DrawWindow* next;
DrawWindow* previous;
HBITMAP myMemHbm;
HBITMAP myOldHbm;
Standard_Boolean myUseBuffer;
#if defined(_WIN32)
Standard_EXPORT static HWND createDrawWindow (HWND , int );
Standard_EXPORT HDC getMemDC (HDC theWinDC);
Standard_EXPORT void releaseMemDC(HDC theMemDC);
#elif defined(HAVE_XLIB)
Drawable GetDrawable() const { return myUseBuffer ? myImageBuffer : myWindow; }
struct Base_Window; // opaque structure with extra Xlib parameters
#endif
private:
#if defined(_WIN32)
HWND myWindow; //!< native window
HBITMAP myMemHbm;
HBITMAP myOldHbm;
Standard_Integer myCurrPen;
Standard_Integer myCurrMode;
#elif defined(HAVE_XLIB)
Window myWindow; //!< native window
Window myMother; //!< parent native window
Pixmap myImageBuffer;
std::unique_ptr<Base_Window> myBase;
#elif defined(__APPLE__)
NSWindow* myWindow; //!< native window
Draw_CocoaView* myView;
NSImage* myImageBuffer;
#else
Aspect_Drawable myWindow;
#endif
Standard_Integer myCurrentColor;
Standard_Boolean myUseBuffer;
};
typedef DrawWindow Draw_Window;
typedef enum {
STOP_CONSOLE,
WAIT_CONSOLE_COMMAND,
HAS_CONSOLE_COMMAND} console_semaphore_value;
// global variable describing console state
extern console_semaphore_value volatile console_semaphore;
// Console command buffer
#define DRAW_COMMAND_SIZE 1000
extern wchar_t console_command[DRAW_COMMAND_SIZE + 1];
// PROCEDURE DE DRAW WINDOW
Standard_EXPORT Standard_Boolean Init_Appli(HINSTANCE,HINSTANCE,int,HWND&);
Standard_EXPORT void Run_Appli(HWND);
Standard_EXPORT void Destroy_Appli(HINSTANCE);
#endif
#endif
#endif // Draw_Window_HeaderFile

View File

@@ -11,7 +11,7 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#if defined(__APPLE__) && !defined(MACOSX_USE_GLX)
#if defined(__APPLE__) && !defined(HAVE_XLIB)
#import <Cocoa/Cocoa.h>
@@ -121,52 +121,23 @@ Standard_Real Draw_RGBColorsArray[MAXCOLOR][3] = {{1.0, 1.0, 1.0},
//function : Draw_Window
//purpose :
//=======================================================================
Draw_Window::Draw_Window() :
myWindow (NULL),
Draw_Window::Draw_Window (const char* theTitle,
const NCollection_Vec2<int>& theXY,
const NCollection_Vec2<int>& theSize,
Aspect_Drawable theParent,
Aspect_Drawable theWindow)
: myWindow (NULL),
myView (NULL),
myImageBuffer (NULL),
myUseBuffer (Standard_False),
nextWindow (firstWindow),
previousWindow (NULL)
myCurrentColor (0),
myUseBuffer (Standard_False)
{
if (firstWindow != NULL) firstWindow->previousWindow = this;
firstWindow = this;
}
//=======================================================================
//function : Draw_Window
//purpose :
//=======================================================================
Draw_Window::Draw_Window (Standard_CString theTitle,
const Standard_Integer& theXLeft, const Standard_Integer& theYTop,
const Standard_Integer& theWidth, const Standard_Integer& theHeight):
myWindow (NULL),
myView (NULL),
myImageBuffer (NULL),
myUseBuffer (Standard_False),
nextWindow (firstWindow),
previousWindow (NULL)
{
if (firstWindow != NULL) firstWindow->previousWindow = this;
firstWindow = this;
Init (theXLeft, theYTop, theWidth, theHeight);
SetTitle (theTitle);
}
Draw_Window::Draw_Window (NSWindow* theWindow, Standard_CString theTitle,
const Standard_Integer& theXLeft, const Standard_Integer& theYTop,
const Standard_Integer& theWidth, const Standard_Integer& theHeight):
myWindow (NULL),
myView (NULL),
myImageBuffer (NULL),
myUseBuffer (Standard_False),
nextWindow (firstWindow),
previousWindow (NULL)
{
myWindow = [theWindow retain];
if (firstWindow != NULL) firstWindow->previousWindow = this;
firstWindow = this;
Init (theXLeft, theYTop, theWidth, theHeight);
(void )theParent;
if (theWindow != 0)
{
myWindow = [(NSWindow* )theWindow retain];
}
init (theXY, theSize);
SetTitle (theTitle);
}
@@ -176,20 +147,6 @@ Draw_Window::Draw_Window (NSWindow* theWindow, Standard_CString
//=======================================================================
Draw_Window::~Draw_Window()
{
if (previousWindow != NULL)
{
previousWindow->nextWindow = nextWindow;
}
else
{
firstWindow = nextWindow;
}
if (nextWindow != NULL)
{
nextWindow->previousWindow = previousWindow;
}
if (myWindow != NULL)
{
[myWindow release];
@@ -210,20 +167,20 @@ Draw_Window::~Draw_Window()
}
//=======================================================================
//function : Init
//function : init
//purpose :
//=======================================================================
void Draw_Window::Init (const Standard_Integer& theXLeft, const Standard_Integer& theYTop,
const Standard_Integer& theWidth, const Standard_Integer& theHeight)
void Draw_Window::init (const NCollection_Vec2<int>& theXY,
const NCollection_Vec2<int>& theSize)
{
Cocoa_LocalPool aLocalPool;
// converting left-bottom coordinate to left-top coordinate
Standard_Integer anYTop = getScreenBottom() - theYTop - theHeight;
Standard_Integer anYTop = getScreenBottom() - theXY.y() - theSize.y();
if (myWindow == NULL)
{
NSRect aRectNs = NSMakeRect (theXLeft, anYTop, theWidth, theHeight);
NSRect aRectNs = NSMakeRect (theXY.x(), anYTop, theSize.x(), theSize.y());
NSUInteger aWinStyle = NSWindowStyleMaskTitled | NSWindowStyleMaskClosable | NSWindowStyleMaskResizable;
myWindow = [[NSWindow alloc] initWithContentRect: aRectNs
@@ -269,8 +226,8 @@ void Draw_Window::InitBuffer()
//function : SetPosition
//purpose :
//=======================================================================
void Draw_Window::SetPosition (const Standard_Integer& theNewXpos,
const Standard_Integer& theNewYpos)
void Draw_Window::SetPosition (Standard_Integer theNewXpos,
Standard_Integer theNewYpos)
{
NSPoint aNewPosition = NSMakePoint (theNewXpos, theNewYpos);
[myWindow setFrameTopLeftPoint: aNewPosition];
@@ -280,8 +237,8 @@ void Draw_Window::SetPosition (const Standard_Integer& theNewXpos,
//function : SetDimension
//purpose :
//=======================================================================
void Draw_Window::SetDimension (const Standard_Integer& theNewWidth,
const Standard_Integer& theNewHeight)
void Draw_Window::SetDimension (Standard_Integer theNewWidth,
Standard_Integer theNewHeight)
{
NSRect aWindowRect = [myWindow frame];
Standard_Integer aNewY = aWindowRect.origin.y + aWindowRect.size.height - theNewHeight;
@@ -347,7 +304,7 @@ TCollection_AsciiString Draw_Window::GetTitle() const
//function :DefineColor
//purpose :
//=======================================================================
Standard_Boolean Draw_Window::DefineColor (const Standard_Integer&, Standard_CString)
Standard_Boolean Draw_Window::DefineColor (const Standard_Integer , Standard_CString )
{
return Standard_True; // unused
}
@@ -452,7 +409,8 @@ void Draw_Window::Flush()
//function : DrawString
//purpose :
//=======================================================================
void Draw_Window::DrawString (const Standard_Integer& theXLeft, const Standard_Integer& theYTop, char* theText)
void Draw_Window::DrawString (Standard_Integer theXLeft, Standard_Integer theYTop,
const char* theText)
{
Cocoa_LocalPool aLocalPool;
@@ -477,7 +435,8 @@ void Draw_Window::DrawString (const Standard_Integer& theXLeft, const Standard_I
//function : DrawSegments
//purpose :
//=======================================================================
void Draw_Window::DrawSegments (Segment *theSegment, const Standard_Integer& theNumberOfElements)
void Draw_Window::DrawSegments (const Draw_XSegment* theSegments,
Standard_Integer theNumberOfElements)
{
Cocoa_LocalPool aLocalPool;
@@ -498,11 +457,12 @@ void Draw_Window::DrawSegments (Segment *theSegment, const Standard_Integer& the
}
for (; anIter < theNumberOfElements; anIter++)
for (; anIter < theNumberOfElements; ++anIter)
{
NSPoint aPoint = NSMakePoint (theSegment[anIter].myXStart, myImageBuffer.size.height - theSegment[anIter].myYStart);
const Draw_XSegment& aSeg = theSegments[anIter];
NSPoint aPoint = NSMakePoint (aSeg[0].x(), myImageBuffer.size.height - aSeg[0].y());
[aPath moveToPoint: aPoint];
aPoint = NSMakePoint (theSegment[anIter].myXEnd, myImageBuffer.size.height - theSegment[anIter].myYEnd);
aPoint = NSMakePoint (aSeg[1].x(), myImageBuffer.size.height - aSeg[1].y());
[aPath lineToPoint: aPoint];
}
@@ -540,7 +500,7 @@ void Draw_Window::Redraw()
//function : SetColor
//purpose :
//=======================================================================
void Draw_Window::SetColor (const Standard_Integer& theColor)
void Draw_Window::SetColor (Standard_Integer theColor)
{
myCurrentColor = theColor;
}
@@ -549,7 +509,7 @@ void Draw_Window::SetColor (const Standard_Integer& theColor)
//function : SetMode
//purpose :
//=======================================================================
void Draw_Window::SetMode (const Standard_Integer& theMode)
void Draw_Window::SetMode (Standard_Integer theMode)
{
// unsupported
(void )theMode;
@@ -597,11 +557,11 @@ Standard_Boolean Draw_Window::IsEqualWindows (const Standard_Integer& theWindowN
return ([myWindow windowNumber] == theWindowNumber);
}
void GetNextEvent (Standard_Boolean theWait,
Standard_Integer& theWindowNumber,
Standard_Integer& theX,
Standard_Integer& theY,
Standard_Integer& theButton)
void Draw_Window::GetNextEvent (Standard_Boolean theWait,
Standard_Integer& theWindowNumber,
Standard_Integer& theX,
Standard_Integer& theY,
Standard_Integer& theButton)
{
Cocoa_LocalPool aLocalPool;
@@ -642,4 +602,5 @@ void GetNextEvent (Standard_Boolean theWait,
theButton = 0;
}
}
#endif // __APPLE__

View File

@@ -1,5 +1,3 @@
CommandWindow.cxx
CommandWindow.h
Draw.cxx
Draw.hxx
Draw_Appli.hxx
@@ -71,8 +69,10 @@ Draw_Viewer.hxx
Draw_Window.cxx
Draw_Window.hxx
Draw_Window_1.mm
DrawRessource.h
init.cxx
init.h
MainWindow.cxx
MainWindow.h
Draw_WNTCommandWindow.cxx
Draw_WNTCommandWindow.pxx
Draw_WNTInit.cxx
Draw_WNTInit.pxx
Draw_WNTMainWindow.cxx
Draw_WNTMainWindow.pxx
Draw_WNTRessource.pxx