1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-09-03 14:10:33 +03:00

0028110: Configuration - specify Unicode charset instead of multibyte in project files for Visual Studio

Eliminated usage of ANSI methods.
All Visual Studio projects generated by genproj or CMake use Unicode character set.

Draw Harness now handles Unicode input on Windows.
Tcl test scripts are now expected in UTF-8 encoding by default.
This commit is contained in:
ski
2016-11-14 14:31:00 +03:00
committed by apn
parent 0a40a30da5
commit ad03c23449
27 changed files with 728 additions and 755 deletions

View File

@@ -17,12 +17,12 @@
#ifdef _WIN32
#define COMMANDCLASS "COMMANDWINDOW"
#define COMMANDTITLE "Command Window"
#define COMMANDCLASS L"COMMANDWINDOW"
#define COMMANDTITLE L"Command Window"
HWND CreateCommandWindow(HWND, int);
LONG APIENTRY CommandProc(HWND, UINT, WPARAM, LONG);
LRESULT APIENTRY CommandProc(HWND, UINT, WPARAM, LPARAM);
BOOL CommandCreateProc(HWND);
VOID CommandDestroyProc(HWND);
BOOL CommandHandler(HWND, WPARAM, LPARAM);

View File

@@ -17,50 +17,36 @@
#ifdef _WIN32
#include <windows.h>
#define COMMANDCLASS "COMMANDWINDOW"
#define COMMANDTITLE "Command Window"
#include <CommandWindow.h>
#include <Draw_Window.hxx>
#include <MainWindow.h>
#include <Draw_Appli.hxx>
/****************************************************\
* CommandWindow.cxx :
*
\****************************************************/
#include <TCollection_AsciiString.hxx>
#define CLIENTWND 0
#define PROMPT "Command >> "
#define THE_PROMPT L"Command >> "
#define COMMANDSIZE 1000 // Max nb of characters for a command
Standard_Boolean Draw_Interprete (const char* command);
// Definition of global variables
#ifdef STRICT
WNDPROC OldEditProc; // Save the standard procedure of the edition (sub-class)
#else
FARPROC OldEditProc;
#endif
namespace
{
// Definition of global variables
static WNDPROC OldEditProc; // Save the standard procedure of the edition (sub-class)
}
/*--------------------------------------------------------*\
| CREATE COMMAND WINDOW PROCEDURE
\*--------------------------------------------------------*/
HWND CreateCommandWindow(HWND hWnd, int /*nitem*/)
{
HINSTANCE hInstance;
hInstance = (HINSTANCE)GetWindowLongPtr(hWnd,GWLP_HINSTANCE);
HINSTANCE hInstance = (HINSTANCE )GetWindowLongPtrW (hWnd, GWLP_HINSTANCE);
HWND hWndCommand = (CreateWindow(COMMANDCLASS, COMMANDTITLE,
WS_CLIPCHILDREN | WS_OVERLAPPED |
WS_THICKFRAME | WS_CAPTION ,
0, 0,
400, 100,
hWnd, NULL, hInstance, NULL));
HWND hWndCommand = CreateWindowW (COMMANDCLASS, COMMANDTITLE,
WS_CLIPCHILDREN | WS_OVERLAPPED | WS_THICKFRAME | WS_CAPTION,
0, 0, 400, 100,
hWnd, NULL, hInstance, NULL);
ShowWindow(hWndCommand, SW_SHOW);
return hWndCommand;
@@ -72,185 +58,180 @@ HWND CreateCommandWindow(HWND hWnd, int /*nitem*/)
\*--------------------------------------------------------*/
LRESULT APIENTRY CommandProc(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam )
{
HWND hWndEdit;
MINMAXINFO* lpmmi;
switch(wMsg)
switch (wMsg)
{
case WM_CREATE :
CommandCreateProc(hWnd);
hWndEdit = (HWND)GetWindowLongPtr(hWnd, CLIENTWND);
SendMessage(hWndEdit,EM_REPLACESEL, 0,(LPARAM)PROMPT);
break;
case WM_GETMINMAXINFO :
lpmmi = (LPMINMAXINFO)lParam;
lpmmi->ptMinTrackSize.x = 200;
lpmmi->ptMinTrackSize.y = 50;
break;
case WM_SIZE :
case WM_CREATE:
{
hWndEdit = (HWND)GetWindowLongPtr(hWnd, CLIENTWND);
MoveWindow(hWndEdit, 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);
// Place the cursor at the end of the buffer
// Nb of characters in the buffer of hWndEdit
LRESULT index = SendMessage(hWnd, WM_GETTEXTLENGTH, 0l, 0l);
SendMessage(hWnd, EM_SETSEL, index, index);
break;
CommandCreateProc (hWnd);
HWND hWndEdit = (HWND )GetWindowLongPtrW (hWnd, CLIENTWND);
SendMessageW (hWndEdit, EM_REPLACESEL, 0, (LPARAM )THE_PROMPT);
return 0;
}
case WM_GETMINMAXINFO:
{
MINMAXINFO* lpmmi = (MINMAXINFO* )lParam;
lpmmi->ptMinTrackSize.x = 200;
lpmmi->ptMinTrackSize.y = 50;
return 0;
}
case WM_SIZE:
{
HWND hWndEdit = (HWND )GetWindowLongPtrW(hWnd, CLIENTWND);
MoveWindow (hWndEdit, 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);
// Place the cursor at the end of the buffer
// Nb of characters in the buffer of hWndEdit
LRESULT index = SendMessageW (hWnd, WM_GETTEXTLENGTH, 0l, 0l);
SendMessageW (hWnd, EM_SETSEL, index, index);
return 0;
}
case WM_SETFOCUS:
{
HWND hWndEdit = (HWND )GetWindowLongPtrW (hWnd, CLIENTWND);
SetFocus (hWndEdit);
return 0;
}
case WM_SETFOCUS :
hWndEdit = (HWND)GetWindowLongPtr(hWnd, CLIENTWND);
SetFocus(hWndEdit);
break;
default :
return(DefWindowProc(hWnd, wMsg, wParam, lParam));
}
return(0l);
return DefWindowProcW(hWnd, wMsg, wParam, lParam);
}
LRESULT APIENTRY EditProc(HWND, UINT, WPARAM, LPARAM);
/*--------------------------------------------------------*\
| COMMAND CREATE PROCEDURE
\*--------------------------------------------------------*/
BOOL CommandCreateProc(HWND hWnd)
{
HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtrW(hWnd, GWLP_HINSTANCE);
HWND hWndEdit = CreateWindowW (L"EDIT", NULL,
WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL,
0, 0, 0, 0,
hWnd, 0,
hInstance, NULL);
HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtr(hWnd, GWLP_HINSTANCE);
// Save hWndEdit in the extra memory in 0 of CommandWindow
if (hWndEdit != NULL)
{
SetWindowLongPtrW (hWnd, CLIENTWND, (LONG_PTR )hWndEdit);
}
HWND hWndEdit = CreateWindow("EDIT",NULL,
WS_CHILD | WS_VISIBLE | WS_VSCROLL |
ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL,
0, 0, 0, 0,
hWnd, 0,
hInstance, NULL);
// Save hWndEdit in the extra memory in 0 of CommandWindow
if (hWndEdit)
SetWindowLongPtr(hWnd, CLIENTWND, (LONG_PTR)hWndEdit);
// Sub-Class of the window
//-------
// Save the pointer on the existing procedure
#ifdef STRICT
OldEditProc = (WNDPROC)GetWindowLongPtr(hWndEdit, GWLP_WNDPROC);
#else
OldEditProc = (FARPROC)GetWindowLongPtr(hWndEdit, GWLP_WNDPROC);
#endif
// Implement the new function
SetWindowLongPtr(hWndEdit, GWLP_WNDPROC, (LONG_PTR) EditProc);
return(TRUE);
// Sub-Class of the window
//-------
// Save the pointer on the existing procedure
OldEditProc = (WNDPROC )GetWindowLongPtrW (hWndEdit, GWLP_WNDPROC);
// Implement the new function
SetWindowLongPtrW (hWndEdit, GWLP_WNDPROC, (LONG_PTR) EditProc);
return TRUE;
}
/*--------------------------------------------------------*\
| GET COMMAND
|
\*--------------------------------------------------------*/
int GetCommand(HWND hWnd, char* buffer)
int GetCommand (HWND hWnd, wchar_t* theBuffer)
{
int again = 1;
char temp[COMMANDSIZE]="";
bool isAgain = true;
wchar_t aTempBuff[COMMANDSIZE] = L"";
int nbLine = (int )SendMessage(hWnd, EM_GETLINECOUNT, 0l, 0l);
int nbChar = 0;
buffer[0]='\0';
while ( again && nbLine > -1 && nbChar < COMMANDSIZE-1)
{
strcat(buffer, strrev(temp));
// Initialization of the 1st WORD to the nb of characters to read
WORD* nbMaxChar = (WORD*)temp;
*nbMaxChar = COMMANDSIZE-1;
int aNbLine = (int )SendMessageW (hWnd, EM_GETLINECOUNT, 0l, 0l);
int aNbChar = 0;
theBuffer[0] = L'\0';
while (isAgain && aNbLine > -1 && aNbChar < COMMANDSIZE - 1)
{
wcscat (theBuffer, _wcsrev (aTempBuff));
// Initialization of the 1st WORD to the nb of characters to read
WORD* aNbMaxChar = (WORD* )aTempBuff;
*aNbMaxChar = COMMANDSIZE - 1;
int nbCharRead = (int )SendMessage(hWnd, EM_GETLINE, nbLine-1, (LPARAM)temp);
nbChar += nbCharRead ;
int cmp = strncmp(temp, PROMPT, 10);
temp[nbCharRead]='\0';
if( cmp == 0 )
{
strcat(buffer, strrev(temp));
again = 0;
}
nbLine -= 1;
}
strrev(buffer);
return nbChar;
const int aNbCharRead = (int )SendMessageW (hWnd, EM_GETLINE, aNbLine - 1, (LPARAM )aTempBuff);
aNbChar += aNbCharRead;
const bool isPromp = wcsncmp (aTempBuff, THE_PROMPT, 10) == 0;
aTempBuff[aNbCharRead]='\0';
if (isPromp)
{
wcscat (theBuffer, _wcsrev (aTempBuff));
isAgain = false;
}
aNbLine -= 1;
}
_wcsrev (theBuffer);
return aNbChar;
}
extern console_semaphore_value volatile console_semaphore;
extern char console_command[1000];
extern wchar_t console_command[1000];
/*--------------------------------------------------------*\
| EDIT WINDOW PROCEDURE
\*--------------------------------------------------------*/
LRESULT APIENTRY EditProc(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam )
{
char buffer[COMMANDSIZE];
POINT pos;
BOOL rep = 0;
static LRESULT nbline; // Process the buffer of the edit window
LRESULT index;
switch(wMsg)
switch (wMsg)
{
case WM_CHAR :
if (console_semaphore != WAIT_CONSOLE_COMMAND)
return 0l;
switch(LOWORD(wParam))
{
// Overload of character \n
case 0x0d :
GetCommand(hWnd, buffer);
// Standard processing
CallWindowProc(OldEditProc, hWnd, wMsg, wParam, lParam);
// Display of PROMPT
rep = GetCaretPos(&pos);
SendMessage(hWnd, EM_REPLACESEL, 0, (LPARAM)PROMPT);
// Display the command in the console
cout << buffer << endl;
/*if (Draw_Interprete(buffer+strlen(PROMPT))== -2)
DestroyProc(hWnd); */
strcpy(console_command, buffer+strlen(PROMPT));
console_semaphore = HAS_CONSOLE_COMMAND;
// Purge the buffer
nbline = SendMessage(hWnd, EM_GETLINECOUNT, 0l, 0l);
if(nbline > 200)
{
nbline = 0;
GetCommand(hWnd, buffer);
index = SendMessage(hWnd, EM_LINEINDEX, 100, 0);
SendMessage(hWnd, EM_SETSEL, 0, index);
SendMessage(hWnd, WM_CUT, 0, 0);
// Place the cursor at the end of text
index = SendMessage(hWnd, WM_GETTEXTLENGTH, 0l, 0l);
SendMessage(hWnd, EM_SETSEL, index, index);
}
return(0l);
break;
default :
if (IsAlphanumeric((Standard_Character)LOWORD(wParam)))
{
// Place the cursor at the end of text before display
index = SendMessage(hWnd, WM_GETTEXTLENGTH, 0l, 0l);
SendMessage(hWnd, EM_SETSEL, index, index);
CallWindowProc(OldEditProc, hWnd, wMsg, wParam, lParam);
return 0l;
}
break;
}
break;
case WM_KEYDOWN:
if (console_semaphore != WAIT_CONSOLE_COMMAND)
return 0l;
case WM_CHAR:
{
if (console_semaphore != WAIT_CONSOLE_COMMAND)
{
return 0;
}
switch (LOWORD(wParam))
{
// Overload of character \n
case 0x0d:
{
wchar_t aCmdBuffer[COMMANDSIZE];
GetCommand (hWnd, aCmdBuffer);
// Standard processing
CallWindowProcW (OldEditProc, hWnd, wMsg, wParam, lParam);
// Display of PROMPT
POINT pos;
GetCaretPos (&pos);
SendMessageW (hWnd, EM_REPLACESEL, 0, (LPARAM )THE_PROMPT);
// Display the command in the console
std::wcout << aCmdBuffer << std::endl;
//TCollection_AsciiString aCmdUtf8 (aCmdBuffer + sizeof(THE_PROMPT) / sizeof(wchar_t) - 1);
//Draw_Interprete (aCmdUtf8.ToCString());
//if (toExit) { DestroyProc (hWnd); }
wcscpy (console_command, aCmdBuffer + sizeof(THE_PROMPT) / sizeof(wchar_t) - 1);
console_semaphore = HAS_CONSOLE_COMMAND;
// Purge the buffer
nbline = SendMessageW (hWnd, EM_GETLINECOUNT, 0l, 0l);
if (nbline > 200)
{
nbline = 0;
GetCommand (hWnd, aCmdBuffer);
LRESULT index = SendMessageW (hWnd, EM_LINEINDEX, 100, 0);
SendMessageW (hWnd, EM_SETSEL, 0, index);
SendMessageW (hWnd, WM_CUT, 0, 0);
// Place the cursor at the end of text
index = SendMessageW (hWnd, WM_GETTEXTLENGTH, 0l, 0l);
SendMessageW (hWnd, EM_SETSEL, index, index);
}
return 0;
}
default:
{
if (IsAlphanumeric ((Standard_Character)LOWORD(wParam)))
{
// Place the cursor at the end of text before display
LRESULT index = SendMessageW (hWnd, WM_GETTEXTLENGTH, 0l, 0l);
SendMessageW (hWnd, EM_SETSEL, index, index);
CallWindowProcW (OldEditProc, hWnd, wMsg, wParam, lParam);
return 0;
}
break;
}
}
break;
}
case WM_KEYDOWN:
{
if (console_semaphore != WAIT_CONSOLE_COMMAND)
{
return 0;
}
break;
}
}
return CallWindowProc(OldEditProc, hWnd, wMsg, wParam, lParam);
return CallWindowProcW (OldEditProc, hWnd, wMsg, wParam, lParam);
}
#endif

View File

@@ -78,21 +78,27 @@ Standard_EXPORT Standard_Boolean Draw_Interprete(const char* command);
// *******************************************************************
#ifdef _WIN32
extern console_semaphore_value volatile console_semaphore;
extern char console_command[1000];
extern wchar_t console_command[1000];
#endif
static void ReadInitFile (const TCollection_AsciiString& theFileName)
{
TCollection_AsciiString aPath = theFileName;
#ifdef _WIN32
if (!Draw_Batch) {
try {
if (!Draw_Batch)
{
try
{
aPath.ChangeAll ('\\', '/');
Sprintf(console_command, "source \"%.980s\"", aPath.ToCString());
{
const TCollection_ExtendedString aCmdWide = TCollection_ExtendedString ("source -encoding utf-8 \"") + TCollection_ExtendedString (aPath) + "\"";
memcpy (console_command, aCmdWide.ToWideString(), Min (aCmdWide.Length() + 1, 980) * sizeof(wchar_t));
}
console_semaphore = HAS_CONSOLE_COMMAND;
while (console_semaphore == HAS_CONSOLE_COMMAND)
{
Sleep(10);
}
}
catch(...) {
cout << "Error while reading a script file." << endl;
@@ -100,8 +106,8 @@ static void ReadInitFile (const TCollection_AsciiString& theFileName)
}
} else {
#endif
char* com = new char [aPath.Length() + strlen ("source ") + 2];
Sprintf (com, "source %s", aPath.ToCString());
char* com = new char [aPath.Length() + strlen ("source -encoding utf-8 ") + 2];
Sprintf (com, "source -encoding utf-8 %s", aPath.ToCString());
Draw_Interprete (com);
delete [] com;
#ifdef _WIN32
@@ -140,32 +146,31 @@ void exitProc(ClientData /*dc*/)
// main
// *******************************************************************
#ifdef _WIN32
//Standard_EXPORT void Draw_Appli(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lps
Standard_EXPORT void Draw_Appli(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpszLine, int nShow,const FDraw_InitAppli Draw_InitAppli)
Standard_EXPORT void Draw_Appli(HINSTANCE hInst, HINSTANCE hPrevInst, int nShow, int argc, wchar_t** argv, const FDraw_InitAppli Draw_InitAppli)
#else
void Draw_Appli(Standard_Integer argc, char** argv,const FDraw_InitAppli Draw_InitAppli)
void Draw_Appli(int argc, char** argv, const FDraw_InitAppli Draw_InitAppli)
#endif
{
// prepend extra DLL search path to override system libraries like opengl32.dll
#ifdef _WIN32
OSD_Environment aUserDllEnv ("CSF_UserDllPath");
TCollection_AsciiString aUserDllPath = aUserDllEnv.Value();
const TCollection_ExtendedString aUserDllPath (aUserDllEnv.Value());
if (!aUserDllPath.IsEmpty())
{
// This function available since Win XP SP1 #if (_WIN32_WINNT >= 0x0502).
// We retrieve dynamically here (kernel32 should be always preloaded).
typedef BOOL (WINAPI *SetDllDirectoryA_t)(const char* thePathName);
HMODULE aKern32Module = GetModuleHandleA ("kernel32");
SetDllDirectoryA_t aFunc = (aKern32Module != NULL)
? (SetDllDirectoryA_t )GetProcAddress (aKern32Module, "SetDllDirectoryA") : NULL;
typedef BOOL (WINAPI *SetDllDirectoryW_t)(const wchar_t* thePathName);
HMODULE aKern32Module = GetModuleHandleW (L"kernel32");
SetDllDirectoryW_t aFunc = (aKern32Module != NULL)
? (SetDllDirectoryW_t )GetProcAddress (aKern32Module, "SetDllDirectoryW") : NULL;
if (aFunc != NULL)
{
aFunc (aUserDllPath.ToCString());
aFunc (aUserDllPath.ToWideString());
}
else
{
//std::cerr << "SetDllDirectoryA() is not available on this system!\n";
//std::cerr << "SetDllDirectoryW() is not available on this system!\n";
}
if (aKern32Module != NULL)
{
@@ -179,64 +184,71 @@ void Draw_Appli(Standard_Integer argc, char** argv,const FDraw_InitAppli Draw_In
// *****************************************************************
Draw_Batch = Standard_False;
TCollection_AsciiString aRunFile, aCommand;
Standard_Integer i;
Standard_Boolean isInteractiveForced = Standard_False;
#ifdef _WIN32
// On NT command line arguments are in the lpzline and not in argv
int argc = 0;
const int MAXARGS = 1024;
const char* argv[MAXARGS];
for (const char* p = strtok(lpszLine, " \t"); p != NULL; p = strtok(NULL, " \t")) {
argv[argc++] = p;
}
#endif
// parse command line
for (i = 1; i < argc; i++) {
if (strcasecmp (argv[i], "-h") == 0 || strcasecmp (argv[i], "--help") == 0)
for (int anArgIter = 1; anArgIter < argc; ++anArgIter)
{
TCollection_AsciiString anArg (argv[anArgIter]);
anArg.LowerCase();
if (anArg == "-h"
|| anArg == "--help")
{
cout << "Open CASCADE " << OCC_VERSION_STRING_EXT << " DRAW Test Harness" << endl << endl;
cout << "Options: " << endl;
cout << " -b: batch mode (no GUI, no viewers)" << endl;
cout << " -v: no GUI, use virtual (off-screen) windows for viewers" << endl;
cout << " -i: interactive mode" << endl;
cout << " -f file: execute script from file" << endl;
cout << " -c command args...: execute command (with optional arguments)" << endl << endl;
cout << "Options -b, -v, and -i are mutually exclusive." << endl;
cout << "If -c or -f are given, -v is default; otherwise default is -i." << endl;
cout << "Options -c and -f are alternatives and should be at the end " << endl;
cout << "of the command line. " << endl;
cout << "Option -c can accept set of commands separated by ';'." << endl;
std::cout << "Open CASCADE " << OCC_VERSION_STRING_EXT << " DRAW Test Harness\n\n";
std::cout << "Options:\n";
std::cout << " -b: batch mode (no GUI, no viewers)\n";
std::cout << " -v: no GUI, use virtual (off-screen) windows for viewers\n";
std::cout << " -i: interactive mode\n";
std::cout << " -f file: execute script from file\n";
std::cout << " -c command args...: execute command (with optional arguments)\n\n";
std::cout << "Options -b, -v, and -i are mutually exclusive.\n";
std::cout << "If -c or -f are given, -v is default; otherwise default is -i.\n";
std::cout << "Options -c and -f are alternatives and should be at the end \n";
std::cout << "of the command line.\n";
std::cout << "Option -c can accept set of commands separated by ';'.\n";
return;
}
else if (strcasecmp (argv[i], "-b") == 0)
else if (anArg == "-b")
{
Draw_Batch = Standard_True;
else if (strcasecmp (argv[i], "-v") == 0) {
}
else if (anArg == "-v")
{
// force virtual windows
Draw_VirtualWindows = Standard_True;
} else if (strcasecmp (argv[i], "-i") == 0) {
}
else if (anArg == "-i")
{
// force interactive
Draw_VirtualWindows = Standard_False;
isInteractiveForced = Standard_True;
} else if (strcasecmp (argv[i], "-f") == 0) { // -f option should be LAST!
}
else if (anArg == "-f") // -f option should be LAST!
{
Draw_VirtualWindows = !isInteractiveForced;
if (++i < argc) {
aRunFile = TCollection_AsciiString (argv[i]);
if (++anArgIter < argc)
{
aRunFile = TCollection_AsciiString (argv[anArgIter]);
}
break;
} else if (strcasecmp (argv[i], "-c") == 0) { // -c option should be LAST!
}
else if (anArg == "-c") // -c option should be LAST!
{
Draw_VirtualWindows = !isInteractiveForced;
if (++i < argc) {
aCommand = TCollection_AsciiString (argv[i]);
if (++anArgIter < argc)
{
aCommand = TCollection_AsciiString (argv[anArgIter]);
}
while (++i < argc) {
while (++anArgIter < argc)
{
aCommand.AssignCat (" ");
aCommand.AssignCat (argv[i]);
aCommand.AssignCat (argv[anArgIter]);
}
break;
} else {
cout << "Error: unsupported option " << argv[i] << endl;
}
else
{
std::cout << "Error: unsupported option " << TCollection_AsciiString (argv[anArgIter]) << "\n";
}
}
@@ -268,11 +280,15 @@ void Draw_Appli(Standard_Integer argc, char** argv,const FDraw_InitAppli Draw_In
cout << "DRAW is running in batch mode" << endl;
XLoop = !Draw_Batch;
if (XLoop) {
if (XLoop)
{
// Default colors
for (i=0;i<MAXCOLOR;i++) {
if (!dout.DefineColor(i,ColorNames[i]))
cout <<"Could not allocate default color "<<ColorNames[i]<<endl;
for (int i = 0; i < MAXCOLOR; ++i)
{
if (!dout.DefineColor (i, ColorNames[i]))
{
std::cout <<"Could not allocate default color " << ColorNames[i] << std::endl;
}
}
}
@@ -366,7 +382,7 @@ void Draw_Appli(Standard_Integer argc, char** argv,const FDraw_InitAppli Draw_In
for (;;)
{
cout << "Viewer>";
i = -1;
int i = -1;
do {
cin.get(cmd[++i]);
} while ((cmd[i] != '\n') && (!cin.fail()));
@@ -396,7 +412,10 @@ Standard_Boolean Draw_Interprete(const char* com)
Tcl_DStringInit(&command);
}
#if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 1)))
#ifdef _WIN32
// string is already converted into UTF-8
Tcl_DStringAppend(&command, com, -1);
#elif ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 1)))
// OCC63: Since Tcl 8.1 it uses UTF-8 encoding for internal representation of strings
Tcl_ExternalToUtfDString ( NULL, com, -1, &command );
#else
@@ -435,7 +454,14 @@ Standard_Boolean Draw_Interprete(const char* com)
dout.Flush();
if (*theCommands.Result())
cout << theCommands.Result() << endl;
{
#ifdef _WIN32
const TCollection_ExtendedString aResWide (theCommands.Result());
std::wcout << aResWide.ToWideString() << std::endl;
#else
std::cout << theCommands.Result() << std::endl;
#endif
}
if (Draw_Chrono && hadchrono) {
tictac.Stop();

View File

@@ -14,16 +14,9 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
// JR 21 Oct 1999 : Change for Draw_Init_Appli which is in main and is
// called from Draw ===> undefined symbol on UNIX
// ===> duplication of code on NT :
// One argument added to DrawAppli : Draw_Init_Appli ===>
// Draw_Appli of Draw/TKDraw may call Draw_Init_Appli
#ifndef Draw_Appli_HeaderFile
#define Draw_Appli_HeaderFile
#include <Draw_Viewer.hxx>
#include <Draw.hxx>
@@ -31,11 +24,11 @@ typedef void (*FDraw_InitAppli)(Draw_Interpretor&);
#ifdef _WIN32
#include <windows.h>
//extern void Draw_Appli(HINSTANCE,HINSTANCE,LPSTR,int);
Standard_EXPORT void Draw_Appli(HINSTANCE,HINSTANCE,LPSTR,int,
const FDraw_InitAppli Draw_InitAppli);
Standard_EXPORT void Draw_Appli(HINSTANCE,HINSTANCE,int,
int argc, wchar_t** argv,
const FDraw_InitAppli Draw_InitAppli);
#else
extern void Draw_Appli(Standard_Integer argc, char** argv,
extern void Draw_Appli(int argc, char** argv,
const FDraw_InitAppli Draw_InitAppli);
#endif

View File

@@ -14,35 +14,8 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
// *******************************************************************
// RLN 06 January 2000
// *******************************************************************
// This file is built from former NTMain.pxx duplicated in many executables
// extending DRAW Test Harness.
// Now is implemented only in one instance.
// Differences between CAS.CADE versions:
// - in C21 Draw_Appli is defined in Draw.cxx (DRAW UL) and calls externally
// defined Draw_InitAppli. Moreover, on WNT Draw_Appli was not declared as
// Standard_EXPORT and therefore it has to be duplicated explicitly in this
// code as in Draw.cxx.
// - in C30 Draw_Appli accepts Draw_InitAppli as parameter which is given to
// it in each executable. Draw_Appli is declared as Standard_EXPORT and
// therefore it needs not to be duplicated.
// To have only one instance of this file and to call it from all the executables
// thereare defined macros in .hxx that replace main/WinMain functions and which
// calls _main_/_WinMain_ defined in this file with specified Draw_InitAppli.
// To avoid Unresolved symbols on WNT, Draw_InitAppli is explicitly defined in this
// is initialized by main/_WinMain_.
// WARNING: Although versions C21 and C30 are synchronised as much as they can,
// there are two versions of this file for both configurations. This is explained by:
// - Standard_IMPOR is differently defined,
// - Draw_Appli is differently declared.
#ifdef _WIN32
#include <windows.h> /* SW_SHOW */
#include <windows.h>
#endif
#include <Draw_Main.hxx>
@@ -50,6 +23,7 @@
#include <string.h>
#include <Draw_Appli.hxx>
#include <OSD.hxx>
#include <TCollection_AsciiString.hxx>
#include <tcl.h>
@@ -94,18 +68,18 @@ extern Standard_Boolean Draw_IsConsoleSubsystem;
Standard_Integer _main_ (int /*argc*/, char* argv[], char* /*envp*/[], const FDraw_InitAppli fDraw_InitAppli)
{
Draw_IsConsoleSubsystem = Standard_True;
//return _WinMain_(::GetModuleHandle(NULL), NULL, GetCommandLine(), SW_SHOW, fDraw_InitAppli);
theDraw_InitAppli = fDraw_InitAppli;
//ParseCommandLine(GetCommandLine());
// MKV 01.02.05
#if ((TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 4)))
Tcl_FindExecutable(argv[0]);
#endif
Draw_Appli(::GetModuleHandle(NULL), NULL, GetCommandLine(), SW_SHOW, fDraw_InitAppli);
int aNbArgs = 0;
wchar_t** anArgVec = CommandLineToArgvW (GetCommandLineW(), &aNbArgs);
Draw_Appli (::GetModuleHandleW (NULL), NULL, SW_SHOW, aNbArgs, anArgVec, fDraw_InitAppli);
LocalFree (anArgVec);
return 0;
}
//=======================================================================
@@ -113,11 +87,13 @@ Standard_Integer _main_ (int /*argc*/, char* argv[], char* /*envp*/[], const FDr
//purpose :
//=======================================================================
Standard_Integer _WinMain_ (HINSTANCE /*hInstance*/, HINSTANCE /*hPrevinstance*/, LPSTR /*lpCmdLine*/, int /*nCmdShow*/, const FDraw_InitAppli /*fDraw_InitAppli*/)
Standard_Integer _WinMain_ (HINSTANCE hInstance, HINSTANCE hPrevinstance, LPSTR /*lpCmdLine*/, int nCmdShow, const FDraw_InitAppli fDraw_InitAppli)
{
// theDraw_InitAppli = fDraw_InitAppli;
// ParseCommandLine (lpCmdLine);
// Draw_Appli(hInstance, hPrevinstance, lpCmdLine, nCmdShow, Draw_InitAppli); // for C30;
theDraw_InitAppli = fDraw_InitAppli;
int aNbArgs = 0;
wchar_t** anArgVec = CommandLineToArgvW(GetCommandLineW(), &aNbArgs);
Draw_Appli (hInstance, hPrevinstance, nCmdShow, aNbArgs, anArgVec, fDraw_InitAppli);
LocalFree (anArgVec);
return 0;
}
#else
@@ -136,4 +112,3 @@ Standard_Integer _main_ (Standard_Integer argc, char* argv[], const FDraw_InitAp
return 0;
}
#endif

View File

@@ -14,11 +14,6 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
// Updated by GG Tue Oct 22 16:22:10 1996
// reason : Try to compress the pixel image
// in PseudoColor 8 planes format
// see : SaveView(filename)
#include <Draw_Viewer.hxx>
#include <Draw_View.hxx>
@@ -26,7 +21,7 @@
#include <gp_Pnt2d.hxx>
#include <Draw_Window.hxx>
#include <Draw_Display.hxx>
#include <TCollection_AsciiString.hxx>
#define precpers 0.95
#define ButtonPress 4
@@ -179,7 +174,7 @@ void Draw_Viewer::MakeView (const Standard_Integer id,
void Draw_Viewer::SetTitle (const Standard_Integer id, const char* name)
{
if (Draw_Batch) return;
if(myViews[id]) myViews[id]->SetTitle((char*)name);
if(myViews[id]) myViews[id]->SetTitle (name);
}
//=======================================================================

View File

@@ -26,6 +26,7 @@
#include <Draw_Window.hxx>
#include <Draw_Appli.hxx>
#include <TCollection_AsciiString.hxx>
#include <TCollection_ExtendedString.hxx>
#include <Image_AlienPixMap.hxx>
#include <NCollection_List.hxx>
@@ -526,20 +527,20 @@ Standard_Integer Draw_Window::WidthWin() const
//function : SetTitle
//purpose :
//=======================================================================
void Draw_Window::SetTitle(const char* title)
void Draw_Window::SetTitle(const TCollection_AsciiString& theTitle)
{
XStoreName(Draw_WindowDisplay, win, title);
XStoreName (Draw_WindowDisplay, win, theTitle.ToCString());
}
//=======================================================================
//function : GetTitle
//purpose :
//=======================================================================
char* Draw_Window::GetTitle()
TCollection_AsciiString Draw_Window::GetTitle() const
{
char* title;
XFetchName(Draw_WindowDisplay, win, &title);
return title;
char* aTitle = NULL;
XFetchName (Draw_WindowDisplay, win, &aTitle);
return TCollection_AsciiString (aTitle);
}
//=======================================================================
@@ -1332,7 +1333,7 @@ int modeTab[16] = {R2_BLACK, R2_MASKPEN, R2_MASKPENNOT, R2_COPYPEN,
HWND DrawWindow::CreateDrawWindow(HWND hWndClient, int nitem)
{
if (Draw_IsConsoleSubsystem) {
HWND aWin = CreateWindow (DRAWCLASS, DRAWTITLE,
HWND aWin = CreateWindowW (DRAWCLASS, DRAWTITLE,
WS_OVERLAPPEDWINDOW,
1,1,1,1,
NULL, NULL,::GetModuleHandle(NULL), NULL);
@@ -1344,10 +1345,9 @@ HWND DrawWindow::CreateDrawWindow(HWND hWndClient, int nitem)
return aWin;
}
else {
HANDLE hInstance;
hInstance = (HANDLE)GetWindowLongPtr(hWndClient,GWLP_HINSTANCE);
HANDLE hInstance = (HANDLE )GetWindowLongPtrW (hWndClient, GWLP_HINSTANCE);
return CreateMDIWindow(DRAWCLASS, DRAWTITLE,
return CreateMDIWindowW(DRAWCLASS, DRAWTITLE,
WS_CAPTION | WS_CHILD | WS_THICKFRAME,
1,1,0,0,
hWndClient, (HINSTANCE)hInstance, nitem);
@@ -1360,43 +1360,46 @@ HWND DrawWindow::CreateDrawWindow(HWND hWndClient, int nitem)
\*--------------------------------------------------------*/
LRESULT APIENTRY DrawWindow::DrawProc(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam )
{
DrawWindow* localObjet = (DrawWindow*)GetWindowLongPtr(hWnd, CLIENTWND);
DrawWindow* localObjet = (DrawWindow* )GetWindowLongPtrW (hWnd, CLIENTWND);
if (!localObjet)
{
if (Draw_IsConsoleSubsystem)
return (DefWindowProc(hWnd, wMsg, wParam, lParam));
else
return(DefMDIChildProc(hWnd, wMsg, wParam, lParam));
}
PAINTSTRUCT ps;
switch(wMsg)
{
case WM_PAINT :
BeginPaint(hWnd, &ps);
if (localObjet->GetUseBuffer())
localObjet->Redraw();
else
localObjet->WExpose();
EndPaint(hWnd, &ps);
return 0l;
break;
case WM_SIZE:
if (localObjet->GetUseBuffer()) {
localObjet->InitBuffer();
localObjet->WExpose();
localObjet->Redraw();
return 0l;
}
default:
if (Draw_IsConsoleSubsystem)
return (DefWindowProc(hWnd, wMsg, wParam, lParam));
else
return(DefMDIChildProc(hWnd, wMsg, wParam, lParam));
return Draw_IsConsoleSubsystem
? DefWindowProcW (hWnd, wMsg, wParam, lParam)
: DefMDIChildProcW (hWnd, wMsg, wParam, lParam);
}
switch (wMsg)
{
case WM_PAINT:
{
PAINTSTRUCT ps;
BeginPaint (hWnd, &ps);
if (localObjet->GetUseBuffer())
{
localObjet->Redraw();
}
else
{
localObjet->WExpose();
}
EndPaint (hWnd, &ps);
return 0;
}
case WM_SIZE:
{
if (localObjet->GetUseBuffer())
{
localObjet->InitBuffer();
localObjet->WExpose();
localObjet->Redraw();
return 0;
}
break;
}
}
return Draw_IsConsoleSubsystem
? DefWindowProcW (hWnd, wMsg, wParam, lParam)
: DefMDIChildProcW (hWnd, wMsg, wParam, lParam);
}
@@ -1488,8 +1491,8 @@ void DrawWindow::Init(Standard_Integer theXLeft, Standard_Integer theYTop,
// include decorations in the window dimensions
// to reproduce same behaviour of Xlib window.
DWORD aWinStyle = GetWindowLong (win, GWL_STYLE);
DWORD aWinStyleEx = GetWindowLong (win, GWL_EXSTYLE);
DWORD aWinStyle = GetWindowLongW (win, GWL_STYLE);
DWORD aWinStyleEx = GetWindowLongW (win, GWL_EXSTYLE);
HMENU aMenu = GetMenu (win);
RECT aRect;
@@ -1502,7 +1505,7 @@ void DrawWindow::Init(Standard_Integer theXLeft, Standard_Integer theYTop,
SetPosition (aRect.left, aRect.top);
SetDimension (aRect.right - aRect.left, aRect.bottom - aRect.top);
// Save the pointer at the instance associated to the window
SetWindowLongPtr(win, CLIENTWND, (LONG_PTR)this);
SetWindowLongPtrW (win, CLIENTWND, (LONG_PTR)this);
HDC hDC = GetDC(win);
SetBkColor(hDC, RGB(0, 0, 0));
myCurrPen = 3;
@@ -1657,21 +1660,21 @@ Standard_Integer DrawWindow::WidthWin() const
/*--------------------------------------------------------*\
| SetTitle
\*--------------------------------------------------------*/
void DrawWindow::SetTitle(const char* title)
void DrawWindow::SetTitle (const TCollection_AsciiString& theTitle)
{
SetWindowText(win, title);
const TCollection_ExtendedString aTitleW (theTitle);
SetWindowTextW (win, aTitleW.ToWideString());
}
/*--------------------------------------------------------*\
| GetTitle
| Attention do not forget to unallocate the memory
\*--------------------------------------------------------*/
char* DrawWindow::GetTitle()
TCollection_AsciiString DrawWindow::GetTitle() const
{
char* title=new char[31];
GetWindowText(win, title, 30);
return title;
wchar_t aTitleW[32];
GetWindowTextW (win, aTitleW, 30);
return TCollection_AsciiString (aTitleW);
}
@@ -1810,7 +1813,8 @@ void DrawWindow::DrawString(int x,int y, char* text)
HDC hDC = GetDC(win);
HDC aWorkDC = myUseBuffer ? GetMemDC(hDC) : hDC;
TextOut(aWorkDC, x, y, text, (int )strlen(text));
TCollection_ExtendedString textW (text);
TextOutW(aWorkDC, x, y, (const wchar_t*)textW.ToExtString(), (int )strlen(text));
if (myUseBuffer) ReleaseMemDC(aWorkDC);
ReleaseDC(win,hDC);
@@ -1960,9 +1964,8 @@ static Tk_Window mainWindow;
//* threads sinchronization *//
DWORD dwMainThreadId;
console_semaphore_value volatile console_semaphore = WAIT_CONSOLE_COMMAND;
//char console_command[1000];
#define COMMAND_SIZE 1000 /* Console Command size */
char console_command[COMMAND_SIZE];
#define THE_COMMAND_SIZE 1000 /* Console Command size */
wchar_t console_command[THE_COMMAND_SIZE];
bool volatile isTkLoopStarted = false;
/*--------------------------------------------------------*\
@@ -2031,16 +2034,41 @@ Standard_Boolean Draw_Interprete (const char*);
/*--------------------------------------------------------*\
| readStdinThreadFunc
\*--------------------------------------------------------*/
static DWORD WINAPI readStdinThreadFunc(VOID)
static DWORD WINAPI readStdinThreadFunc()
{
if (!Draw_IsConsoleSubsystem) return 1;
for(;;) {
if (!Draw_IsConsoleSubsystem)
{
return 1;
}
// set console locale
//setlocale (LC_ALL, ".OCP");
for (;;)
{
while (console_semaphore != WAIT_CONSOLE_COMMAND)
Sleep(100);
if (fgets(console_command,COMMAND_SIZE,stdin))
{
Sleep (100);
}
DWORD aNbRead = 0;
if (ReadConsoleW (GetStdHandle(STD_INPUT_HANDLE), console_command, THE_COMMAND_SIZE, &aNbRead, NULL))
//if (fgetws (console_command, THE_COMMAND_SIZE, stdin)) // fgetws() works only for characters within active locale (see setlocale())
{
console_command[aNbRead] = L'\0';
// tcl will skip newline symbols - no need to strip them here
/*--aNbRead;
for (; aNbRead >= 0; --aNbRead)
{
console_semaphore = HAS_CONSOLE_COMMAND;
}
if (console_command[aNbRead] == L'\r'
|| console_command[aNbRead] == L'\n')
{
console_command[aNbRead] = '\0';
continue;
}
break;
}*/
console_semaphore = HAS_CONSOLE_COMMAND;
}
}
}
@@ -2065,9 +2093,23 @@ static DWORD WINAPI tkLoop(VOID)
{
Tcl_CreateExitHandler(exitProc, 0);
#if (TCL_MAJOR_VERSION > 8) || ((TCL_MAJOR_VERSION == 8) && (TCL_MINOR_VERSION >= 5))
Tcl_RegisterChannel(theCommands.Interp(), Tcl_GetStdChannel(TCL_STDIN));
Tcl_RegisterChannel(theCommands.Interp(), Tcl_GetStdChannel(TCL_STDOUT));
Tcl_RegisterChannel(theCommands.Interp(), Tcl_GetStdChannel(TCL_STDERR));
{
Tcl_Channel aChannelIn = Tcl_GetStdChannel (TCL_STDIN);
Tcl_Channel aChannelOut = Tcl_GetStdChannel (TCL_STDOUT);
Tcl_Channel aChannelErr = Tcl_GetStdChannel (TCL_STDERR);
if (aChannelIn != NULL)
{
Tcl_RegisterChannel (theCommands.Interp(), aChannelIn);
}
if (aChannelOut != NULL)
{
Tcl_RegisterChannel (theCommands.Interp(), aChannelOut);
}
if (aChannelErr != NULL)
{
Tcl_RegisterChannel (theCommands.Interp(), aChannelErr);
}
}
#endif
#ifdef _TK
@@ -2128,7 +2170,8 @@ static DWORD WINAPI tkLoop(VOID)
while(Tcl_DoOneEvent(TCL_ALL_EVENTS | TCL_DONT_WAIT));
if (console_semaphore == HAS_CONSOLE_COMMAND)
{
if (Draw_Interprete (console_command))
TCollection_AsciiString aCmdUtf8 (console_command);
if (Draw_Interprete (aCmdUtf8.ToCString()))
{
if (Draw_IsConsoleSubsystem) Prompt (interp, 0);
}
@@ -2176,9 +2219,9 @@ void Run_Appli(HWND hWnd)
if (!hThread) {
cout << "pb in creation of the thread reading stdin" << endl;
Draw_IsConsoleSubsystem = Standard_False;
Init_Appli(GetModuleHandle(NULL),
GetModuleHandle(NULL),
1, hWnd); // reinit => create MDI client wnd
Init_Appli (GetModuleHandleW (NULL),
GetModuleHandleW (NULL),
1, hWnd); // reinit => create MDI client wnd
}
}
@@ -2187,12 +2230,12 @@ void Run_Appli(HWND hWnd)
console_semaphore = WAIT_CONSOLE_COMMAND;
//simple Win32 message loop
while (GetMessage(&msg, NULL, 0, 0) > 0)
while (GetMessageW (&msg, NULL, 0, 0) > 0)
{
if (!TranslateAccelerator(hWnd, hAccel, &msg))
if (!TranslateAcceleratorW (hWnd, hAccel, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
TranslateMessage (&msg);
DispatchMessageW (&msg);
}
}
ExitProcess(0);
@@ -2218,10 +2261,12 @@ void DrawWindow::SelectWait(HANDLE& hWnd, int& x, int& y, int& button)
msg.wParam = 1;
GetMessage(&msg,NULL,0,0);
GetMessageW (&msg, NULL, 0, 0);
while((msg.message != WM_RBUTTONDOWN && msg.message != WM_LBUTTONDOWN) ||
! ( Draw_IsConsoleSubsystem || IsChild(DrawWindow::hWndClientMDI,msg.hwnd)) )
GetMessage(&msg,NULL,0,0);
{
GetMessageW (&msg, NULL, 0, 0);
}
hWnd = msg.hwnd;
x = LOWORD(msg.lParam);
@@ -2241,11 +2286,13 @@ void DrawWindow::SelectNoWait(HANDLE& hWnd, int& x, int& y, int& button)
msg.wParam = 1;
GetMessage(&msg,NULL,0,0);
GetMessageW (&msg,NULL,0,0);
while((msg.message != WM_RBUTTONDOWN && msg.message != WM_LBUTTONDOWN &&
msg.message != WM_MOUSEMOVE) ||
! ( Draw_IsConsoleSubsystem || IsChild(DrawWindow::hWndClientMDI,msg.hwnd) ) )
GetMessage(&msg,NULL,0,0);
{
GetMessageW(&msg,NULL,0,0);
}
hWnd = msg.hwnd;
x = LOWORD(msg.lParam);
y = HIWORD(msg.lParam);

View File

@@ -19,6 +19,7 @@
#include <Standard_Boolean.hxx>
#include <Standard_Integer.hxx>
#include <TCollection_AsciiString.hxx>
#if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
@@ -116,8 +117,8 @@ class Draw_Window
Standard_Integer HeightWin() const;
Standard_Integer WidthWin() const;
void SetTitle(const char* title);
char* GetTitle();
void SetTitle (const TCollection_AsciiString& theTitle);
TCollection_AsciiString GetTitle() const;
void DisplayWindow();
void Hide();
@@ -281,8 +282,8 @@ class Draw_Window
Standard_Integer HeightWin() const;
Standard_Integer WidthWin() const;
void SetTitle (Standard_CString theTitle);
Standard_CString GetTitle ();
void SetTitle (const TCollection_AsciiString& theTitle);
TCollection_AsciiString GetTitle() const;
void DisplayWindow();
void Hide();
@@ -353,8 +354,8 @@ void GetNextEvent (Standard_Boolean theWait,
#include <windows.h>
#define DRAWCLASS "DRAWWINDOW"
#define DRAWTITLE "Draw View"
#define DRAWCLASS L"DRAWWINDOW"
#define DRAWTITLE L"Draw View"
#define MAXCOLOR 15
#if !defined(__Draw_API) && !defined(HAVE_NO_DLL)
@@ -443,8 +444,8 @@ public:
__Draw_API Standard_Integer WidthWin() const;
//Title
__Draw_API void SetTitle(const char*);
__Draw_API char* GetTitle();
__Draw_API void SetTitle (const TCollection_AsciiString& );
__Draw_API TCollection_AsciiString GetTitle() const;
//Affichage
__Draw_API void DisplayWindow();

View File

@@ -301,9 +301,9 @@ Standard_Integer Draw_Window::WidthWin() const
//function : SetTitle
//purpose :
//=======================================================================
void Draw_Window::SetTitle (Standard_CString theTitle)
void Draw_Window::SetTitle (const TCollection_AsciiString& theTitle)
{
NSString* aTitleNs = [[NSString alloc] initWithUTF8String: theTitle];
NSString* aTitleNs = [[NSString alloc] initWithUTF8String: theTitle.ToCString()];
[myWindow setTitle: aTitleNs];
[aTitleNs release];
}
@@ -312,10 +312,10 @@ void Draw_Window::SetTitle (Standard_CString theTitle)
//function : GetTitle
//purpose :
//=======================================================================
Standard_CString Draw_Window::GetTitle()
TCollection_AsciiString Draw_Window::GetTitle() const
{
Standard_CString aTitle = [[myWindow title] UTF8String];
return aTitle;
return TCollection_AsciiString (aTitle);
}
//=======================================================================

View File

@@ -35,33 +35,33 @@ extern Standard_Boolean Draw_IsConsoleSubsystem;
\*--------------------------------------------------------*/
LRESULT APIENTRY WndProc(HWND hWndFrame, UINT wMsg, WPARAM wParam, LPARAM lParam )
{
HWND hWndClient;
switch(wMsg)
switch (wMsg)
{
case WM_CREATE :
case WM_CREATE:
{
CreateProc (hWndFrame);
HWND hWndClient = (HWND )GetWindowLongPtrW (hWndFrame, CLIENTWND);
DrawWindow::hWndClientMDI = hWndClient;
if (!Draw_IsConsoleSubsystem)
{
CreateProc(hWndFrame);
hWndClient = (HWND)GetWindowLongPtr(hWndFrame, CLIENTWND);
DrawWindow::hWndClientMDI = hWndClient;
if (!Draw_IsConsoleSubsystem)
CreateCommandWindow(hWndFrame,0);
CreateCommandWindow (hWndFrame, 0);
}
break;
case WM_COMMAND :
CmdProc(hWndFrame, LOWORD(wParam), wParam, lParam);
break;
case WM_DESTROY :
Draw_Interprete("exit");
DestroyProc(hWndFrame);
break;
default :
hWndClient = (HWND)GetWindowLongPtr(hWndFrame, CLIENTWND);
return(DefFrameProc(hWndFrame, hWndClient, wMsg, wParam, lParam));
return 0;
}
case WM_COMMAND:
{
CmdProc (hWndFrame, LOWORD(wParam), wParam, lParam);
return 0;
}
case WM_DESTROY:
{
Draw_Interprete ("exit");
DestroyProc (hWndFrame);
return 0;
}
}
return(0l);
HWND hWndClient = (HWND)GetWindowLongPtrW(hWndFrame, CLIENTWND);
return DefFrameProcW(hWndFrame, hWndClient, wMsg, wParam, lParam);
}
@@ -76,7 +76,7 @@ BOOL CreateProc(HWND hWndFrame)
if (hWnd != NULL)
{
// Save hWnd in the main window in extra memory in 0
SetWindowLongPtr(hWndFrame, CLIENTWND, (LONG_PTR)hWnd);
SetWindowLongPtrW (hWndFrame, CLIENTWND, (LONG_PTR)hWnd);
}
return(TRUE);
}
@@ -91,40 +91,50 @@ BOOL CreateProc(HWND hWndFrame)
LRESULT APIENTRY CmdProc(HWND hWndFrame, UINT wMsg, WPARAM /*wParam*/, LPARAM /*lParam*/)
{
// Handle on window MDI
HWND hWndClient = (HWND)GetWindowLongPtr (hWndFrame, CLIENTWND);
HWND hWndClient = (HWND )GetWindowLongPtrW (hWndFrame, CLIENTWND);
switch (wMsg)
{
case IDM_WINDOW_NEXT :
if(hWndClient)
{
HWND hWndActive = (HWND)SendMessage(hWndClient, WM_MDIGETACTIVE, 0, 0l);
SendMessage(hWndClient, WM_MDINEXT, (WPARAM)hWndActive, 0l);
}
break;
case IDM_WINDOW_CASCADE :
if(hWndClient)
SendMessage(hWndClient, WM_MDICASCADE, 0, 0l);
break;
case IDM_WINDOW_TILEHOR :
if(hWndClient)
SendMessage(hWndClient, WM_MDITILE, MDITILE_HORIZONTAL, 0l);
break;
case IDM_WINDOW_TILEVERT :
if(hWndClient)
SendMessage(hWndClient, WM_MDITILE, MDITILE_VERTICAL, 0l);
break;
case IDM_FILE_EXIT :
Draw_Interprete("exit");
//compat_unlink(NULL);
DestroyProc(hWndFrame);
break;
{
case IDM_WINDOW_NEXT:
{
if (hWndClient != NULL)
{
HWND hWndActive = (HWND )SendMessageW (hWndClient, WM_MDIGETACTIVE, 0, 0l);
SendMessageW (hWndClient, WM_MDINEXT, (WPARAM )hWndActive, 0l);
}
break;
}
case IDM_WINDOW_CASCADE:
{
if (hWndClient != NULL)
{
SendMessageW (hWndClient, WM_MDICASCADE, 0, 0l);
}
break;
}
case IDM_WINDOW_TILEHOR:
{
if (hWndClient != NULL)
{
SendMessageW (hWndClient, WM_MDITILE, MDITILE_HORIZONTAL, 0l);
}
break;
}
case IDM_WINDOW_TILEVERT:
{
if (hWndClient != NULL)
{
SendMessageW (hWndClient, WM_MDITILE, MDITILE_VERTICAL, 0l);
}
break;
}
case IDM_FILE_EXIT:
{
Draw_Interprete ("exit");
DestroyProc (hWndFrame);
break;
}
}
return(0l);
return 0;
}
@@ -135,7 +145,7 @@ LRESULT APIENTRY CmdProc(HWND hWndFrame, UINT wMsg, WPARAM /*wParam*/, LPARAM /*
\*--------------------------------------------------------------------------*/
VOID DestroyProc(HWND hWnd)
{
HINSTANCE hInst = (HINSTANCE)GetWindowLongPtr(hWnd, GWLP_HINSTANCE);
HINSTANCE hInst = (HINSTANCE )GetWindowLongPtrW (hWnd, GWLP_HINSTANCE);
Destroy_Appli(hInst);
PostQuitMessage(0);

View File

@@ -37,55 +37,55 @@ d\*--------------------------------------------------------*/
BOOL RegisterAppClass(HINSTANCE hInstance)
{
WNDCLASS wndClass;
WNDCLASSW wndClass;
// Parametres communs aux classes
//-----
wndClass.style = CS_HREDRAW | CS_VREDRAW | CS_CLASSDC;
wndClass.cbClsExtra = 0;
wndClass.hCursor = LoadCursor(NULL,IDC_ARROW);
wndClass.hCursor = LoadCursorW (NULL, IDC_ARROW);
wndClass.hInstance = hInstance;
// Enregistrement de la fenetre principale
//-----
wndClass.cbWndExtra = sizeof(LONG);
wndClass.cbWndExtra = sizeof(void*);
wndClass.lpfnWndProc = (WNDPROC)WndProc;
wndClass.hIcon = (HICON)LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));
wndClass.hIcon = (HICON )LoadIconW (hInstance, MAKEINTRESOURCE(IDI_ICON1));
wndClass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
wndClass.lpszMenuName = MAKEINTRESOURCE(APPMENU);
wndClass.lpszMenuName = MAKEINTRESOURCEW(APPMENU);
wndClass.lpszClassName = APPCLASS;
if(!RegisterClass(&wndClass))
if(!RegisterClassW(&wndClass))
return(FALSE);
// Enregistrement de la fenetre DrawWindow
//------
wndClass.cbWndExtra = sizeof(LONG); // Extra Memory
wndClass.cbWndExtra = sizeof(void*); // Extra Memory
wndClass.lpfnWndProc = (WNDPROC)DrawWindow::DrawProc;
wndClass.hIcon = 0;
wndClass.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);
wndClass.lpszMenuName = NULL;
wndClass.lpszClassName = DRAWCLASS;
if(!RegisterClass(&wndClass))
if(!RegisterClassW(&wndClass))
{
UnregisterClass(APPCLASS, hInstance);
UnregisterClassW(APPCLASS, hInstance);
return(FALSE);
}
// Enregistrement de la fenetre CommandWindow
//------
wndClass.lpfnWndProc = (WNDPROC)CmdProc;
wndClass.lpfnWndProc = (WNDPROC)CommandProc;
wndClass.hIcon = 0;
wndClass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndClass.lpszMenuName = NULL;
wndClass.lpszClassName = COMMANDCLASS;
if(!RegisterClass(&wndClass))
if(!RegisterClassW(&wndClass))
{
UnregisterClass(APPCLASS, hInstance);
UnregisterClass(DRAWCLASS, hInstance);
UnregisterClassW(APPCLASS, hInstance);
UnregisterClassW(DRAWCLASS, hInstance);
return(FALSE);
}
@@ -100,8 +100,8 @@ BOOL RegisterAppClass(HINSTANCE hInstance)
\*--------------------------------------------------------*/
VOID UnregisterAppClass(HINSTANCE hInstance)
{
UnregisterClass(APPCLASS, hInstance);
UnregisterClass(DRAWCLASS, hInstance);
UnregisterClassW(APPCLASS, hInstance);
UnregisterClassW(DRAWCLASS, hInstance);
}
@@ -112,7 +112,7 @@ VOID UnregisterAppClass(HINSTANCE hInstance)
\*--------------------------------------------------------*/
HWND CreateAppWindow(HINSTANCE hInstance)
{
return(CreateWindow(APPCLASS, APPTITLE,
return(CreateWindowW(APPCLASS, APPTITLE,
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
400,0,
623,767,
@@ -135,9 +135,9 @@ HWND CreateMDIClientWindow(HWND hWndFrame)
ccs.hWindowMenu = NULL;
ccs.idFirstChild = 0;
hInstance = (HANDLE)GetWindowLongPtr(hWndFrame, GWLP_HINSTANCE);
hInstance = (HANDLE)GetWindowLongPtrW(hWndFrame, GWLP_HINSTANCE);
hWndClient = CreateWindow("MDICLIENT",NULL,
hWndClient = CreateWindowW(L"MDICLIENT",NULL,
WS_CHILD | WS_CLIPSIBLINGS |
WS_VISIBLE | MDIS_ALLCHILDSTYLES,
0, 0, 1, 1,

View File

@@ -16,8 +16,8 @@
#ifdef _WIN32
#define APPCLASS "TDRAW"
#define APPTITLE "Windows NT TDRAW"
#define APPCLASS L"TDRAW"
#define APPTITLE L"Windows NT TDRAW"
#include <windows.h>
BOOL RegisterAppClass(HINSTANCE);