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.
# the name of the project
project (OCCT)
+if (WIN32)
+ add_definitions(-DUNICODE)
+ add_definitions(-D_UNICODE)
+endif()
+
# include occt macros
OCCT_INCLUDE_CMAKE_FILE ("adm/cmake/occt_macros")
set aVerExt "v${aVerExt}0"
set aCmpl32 ""
set aCmpl64 ""
- set aCharSet "MultiByte"
+ set aCharSet "Unicode"
if { $isexec } {
set anExt "${anExt}x"
set what "$what executable"
}
set aCmpl${bitness} "[set aCmpl${bitness}]${indent}${UwpWinRt}"
}
- set aCharSet "Unicode"
}
foreach bitness {32 64} {
#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);
#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;
\*--------------------------------------------------------*/
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);
+
+ // Save hWndEdit in the extra memory in 0 of CommandWindow
+ if (hWndEdit != NULL)
+ {
+ SetWindowLongPtrW (hWnd, CLIENTWND, (LONG_PTR )hWndEdit);
+ }
- HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtr(hWnd, GWLP_HINSTANCE);
-
- 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
-
-
// *******************************************************************
#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;
}
} 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
// 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)
{
// *****************************************************************
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";
}
}
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;
+ }
}
}
for (;;)
{
cout << "Viewer>";
- i = -1;
+ int i = -1;
do {
cin.get(cmd[++i]);
} while ((cmd[i] != '\n') && (!cin.fail()));
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
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();
// 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>
#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
// 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>
#include <string.h>
#include <Draw_Appli.hxx>
#include <OSD.hxx>
+#include <TCollection_AsciiString.hxx>
#include <tcl.h>
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;
-
}
//=======================================================================
//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
return 0;
}
#endif
-
// 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>
#include <gp_Pnt2d.hxx>
#include <Draw_Window.hxx>
#include <Draw_Display.hxx>
-
+#include <TCollection_AsciiString.hxx>
#define precpers 0.95
#define ButtonPress 4
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);
}
//=======================================================================
#include <Draw_Window.hxx>
#include <Draw_Appli.hxx>
#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
#include <Image_AlienPixMap.hxx>
#include <NCollection_List.hxx>
//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);
}
//=======================================================================
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);
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);
\*--------------------------------------------------------*/
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)
+ {
+ return Draw_IsConsoleSubsystem
+ ? DefWindowProcW (hWnd, wMsg, wParam, lParam)
+ : DefMDIChildProcW (hWnd, wMsg, wParam, lParam);
+ }
+
+ switch (wMsg)
+ {
+ case WM_PAINT:
{
- if (Draw_IsConsoleSubsystem)
- return (DefWindowProc(hWnd, wMsg, wParam, lParam));
+ PAINTSTRUCT ps;
+ BeginPaint (hWnd, &ps);
+ if (localObjet->GetUseBuffer())
+ {
+ localObjet->Redraw();
+ }
else
- return(DefMDIChildProc(hWnd, wMsg, wParam, lParam));
+ {
+ localObjet->WExpose();
+ }
+ EndPaint (hWnd, &ps);
+ return 0;
}
-
- 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;
+ case WM_SIZE:
+ {
+ if (localObjet->GetUseBuffer())
+ {
+ localObjet->InitBuffer();
+ localObjet->WExpose();
+ localObjet->Redraw();
+ return 0;
+ }
+ break;
}
-
- 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);
}
// 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;
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;
/*--------------------------------------------------------*\
| 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);
}
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);
//* 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;
/*--------------------------------------------------------*\
/*--------------------------------------------------------*\
| 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;
+ }
}
}
{
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
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);
}
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
}
}
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);
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);
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);
#include <Standard_Boolean.hxx>
#include <Standard_Integer.hxx>
+#include <TCollection_AsciiString.hxx>
#if !defined(_WIN32) && !defined(__WIN32__) && (!defined(__APPLE__) || defined(MACOSX_USE_GLX))
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();
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();
#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)
__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();
//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];
}
//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);
}
//=======================================================================
\*--------------------------------------------------------*/
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);
}
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);
}
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;
}
\*--------------------------------------------------------------------------*/
VOID DestroyProc(HWND hWnd)
{
- HINSTANCE hInst = (HINSTANCE)GetWindowLongPtr(hWnd, GWLP_HINSTANCE);
+ HINSTANCE hInst = (HINSTANCE )GetWindowLongPtrW (hWnd, GWLP_HINSTANCE);
Destroy_Appli(hInst);
PostQuitMessage(0);
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);
}
\*--------------------------------------------------------*/
VOID UnregisterAppClass(HINSTANCE hInstance)
{
- UnregisterClass(APPCLASS, hInstance);
- UnregisterClass(DRAWCLASS, hInstance);
+ UnregisterClassW(APPCLASS, hInstance);
+ UnregisterClassW(DRAWCLASS, hInstance);
}
\*--------------------------------------------------------*/
HWND CreateAppWindow(HINSTANCE hInstance)
{
- return(CreateWindow(APPCLASS, APPTITLE,
+ return(CreateWindowW(APPCLASS, APPTITLE,
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
400,0,
623,767,
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,
#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);
// Function : WClass
// Purpose :
//=========================================================
-const Handle(MMgt_TShared)& IVtkDraw::WClass()
+const Handle(Standard_Transient)& IVtkDraw::WClass()
{
- static Handle(MMgt_TShared) aWindowClass;
+ static Handle(Standard_Transient) aWindowClass;
#ifdef _WIN32
if (aWindowClass.IsNull())
{
aWindowClass = new WNT_WClass ("GWVTK_Class", DefWindowProc,
CS_VREDRAW | CS_HREDRAW, 0, 0,
- ::LoadCursor (NULL, IDC_ARROW));
+ ::LoadCursorW (NULL, IDC_ARROW));
}
#endif
return aWindowClass;
#ifndef _IVtkDraw_HeaderFile
#define _IVtkDraw_HeaderFile
-#include <MMgt_TShared.hxx>
+#include <Standard_Transient.hxx>
#include <Standard.hxx>
#include <Standard_Macro.hxx>
class Draw_Interpretor;
-class MMgt_TShared;
class IVtkDraw
{
Standard_EXPORT static void Commands (Draw_Interpretor& theCommands);
private:
- Standard_EXPORT static const Handle(MMgt_TShared)& WClass();
+ Standard_EXPORT static const Handle(Standard_Transient)& WClass();
};
#endif
#ifndef _WIN32
-
#include <OSD_Environment.hxx>
#include <OSD_OSDError.hxx>
#include <OSD_WhoAmI.hxx>
//------------------------------------------------------------------------
#define STRICT
+#include <windows.h>
+
#include <OSD_Environment.hxx>
#include <OSD_WNT.hxx>
-#include <windows.h>
-
#include <NCollection_DataMap.hxx>
#include <NCollection_UtfString.hxx>
#include <Standard_Mutex.hxx>
-#if defined(_MSC_VER)
- #pragma warning( disable : 4700 )
-#endif
-
#ifdef OCCT_UWP
namespace
{
} // end OSD_Environment :: Error
#ifndef OCCT_UWP
-static void __fastcall _set_error ( OSD_Error& err, DWORD code ) {
-
- DWORD errCode;
- Standard_Character buffer[ 2048 ];
-
- errCode = code ? code : GetLastError ();
-
- if ( !FormatMessage (
- FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ARGUMENT_ARRAY,
- 0, errCode, MAKELANGID( LANG_NEUTRAL, SUBLANG_NEUTRAL ),
- buffer, 2048, NULL
- )
- ) {
-
- sprintf ( buffer, "error code %d", (Standard_Integer)errCode );
- SetLastError ( errCode );
-
- } // end if
-
- err.SetValue ( errCode, OSD_WEnvironment, buffer );
-
-} // end _set_error
+static void __fastcall _set_error (OSD_Error& theErr, DWORD theCode)
+{
+ wchar_t aBuffer[2048];
+ const DWORD anErrCode = theCode != 0 ? theCode : GetLastError();
+ if (!FormatMessageW (FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ARGUMENT_ARRAY,
+ 0, anErrCode, MAKELANGID( LANG_NEUTRAL, SUBLANG_NEUTRAL ),
+ aBuffer, 2048, NULL))
+ {
+ theErr.SetValue (anErrCode, OSD_WEnvironment, TCollection_AsciiString ("error code ") + (Standard_Integer)anErrCode);
+ SetLastError (anErrCode);
+ }
+ else
+ {
+ theErr.SetValue (anErrCode, OSD_WEnvironment, TCollection_AsciiString (aBuffer));
+ }
+}
#endif
#endif
typedef struct _osd_wnt_key {
HKEY hKey;
- const char* keyPath;
+ wchar_t* keyPath;
} OSD_WNT_KEY;
OSD_WNT_KEY regKey[ 2 ] = {
{ HKEY_LOCAL_MACHINE,
- "SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment"
+ L"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Environment"
},
{ HKEY_USERS,
- ".DEFAULT\\Environment"
+ L".DEFAULT\\Environment"
}
};
for ( int i = 0; i < 2; ++i ) {
- if ( RegOpenKeyEx (
+ if ( RegOpenKeyExW (
regKey[ i ].hKey, regKey[ i ].keyPath, 0, KEY_QUERY_VALUE, &hKey
) == ERROR_SUCCESS
) {
#ifndef _WIN32
-
#include <OSD_Host.hxx>
#include <OSD_OSDError.hxx>
#include <OSD_WhoAmI.hxx>
OSD_Host :: OSD_Host () {
#ifndef OCCT_UWP
DWORD nSize;
- Standard_Character szHostName[ MAX_COMPUTERNAME_LENGTH + 1 ];
+ char szHostName[MAX_COMPUTERNAME_LENGTH + 1];
char* hostAddr = 0;
MEMORYSTATUS ms;
WSADATA wd;
PHOSTENT phe;
IN_ADDR inAddr;
- OSVERSIONINFO osVerInfo;
+ OSVERSIONINFOW osVerInfo;
if ( !fInit ) {
osVerInfo.dwOSVersionInfoSize = sizeof ( OSVERSIONINFO );
ZeroMemory (&ms, sizeof(ms));
- ZeroMemory ( szHostName, sizeof ( Standard_Character ) * (MAX_COMPUTERNAME_LENGTH + 1) );
+ ZeroMemory (szHostName, sizeof(char) * (MAX_COMPUTERNAME_LENGTH + 1));
#ifdef _MSC_VER
// suppress GetVersionEx() deprecation warning
#pragma warning(disable : 4996)
#endif
- if ( !GetVersionEx ( &osVerInfo ) ) {
-
- _osd_wnt_set_error ( myError, OSD_WHost );
-
- } else if ( !GetComputerName ( szHostName, &nSize ) ) {
-
- _osd_wnt_set_error ( myError, OSD_WHost );
-
- } else {
-
- ms.dwLength = sizeof ( MEMORYSTATUS );
- GlobalMemoryStatus ( &ms );
-
+ if (!GetVersionExW (&osVerInfo))
+ {
+ _osd_wnt_set_error (myError, OSD_WHost);
+ }
+ else if (!GetComputerNameA (szHostName, &nSize))
+ {
+ _osd_wnt_set_error (myError, OSD_WHost);
+ }
+ else
+ {
+ ms.dwLength = sizeof(MEMORYSTATUS);
+ GlobalMemoryStatus (&ms);
} // end else
#ifdef _MSC_VER
#pragma warning(default : 4996)
_osd_wnt_set_error ( myError, OSD_WHost );
- } else if ( ( phe = gethostbyname ( szHostName ) ) == NULL ) {
+ } else if ( ( phe = gethostbyname (szHostName) ) == NULL ) {
_osd_wnt_set_error ( myError, OSD_WHost );
#ifndef _WIN32
-
#include <OSD_Environment.hxx>
#include <OSD_OSDError.hxx>
#include <OSD_Path.hxx>
#include <TCollection_ExtendedString.hxx>
#include <OSD_WNT_1.hxx>
-#include <LMCONS.H> /// pour UNLEN ( see MSDN about GetUserName() )
-
-#if defined(_MSC_VER)
- #pragma warning( disable : 4700 )
-#endif
+#include <LMCONS.H> // for UNLEN - maximum user name length GetUserName()
void _osd_wnt_set_error ( OSD_Error&, OSD_WhoAmI, ... );
-OSD_Process :: OSD_Process () {
-
-} // end constructor
-
+// =======================================================================
+// function : OSD_Process
+// purpose :
+// =======================================================================
+OSD_Process::OSD_Process()
+{
+ //
+}
-Standard_Integer OSD_Process::Spawn (const TCollection_AsciiString& cmd,
- const Standard_Boolean ShowWindow /* = Standard_True */) {
+// =======================================================================
+// function : Spawn
+// purpose :
+// =======================================================================
+Standard_Integer OSD_Process::Spawn (const TCollection_AsciiString& theCmd,
+ const Standard_Boolean theToShowWindow)
+{
#ifndef OCCT_UWP
- STARTUPINFO si;
- PROCESS_INFORMATION pi;
- DWORD aRes = 0;
-
- ZeroMemory ( &si, sizeof ( STARTUPINFO ) );
-
- si.cb = sizeof ( STARTUPINFO );
- //============================================
- //---> Added by Stephane Routelous ( stephane.routelous@altavista.net ) [16.03.01]
- //---> Reason : to allow to hide the window
- if ( !ShowWindow )
- {
- si.dwFlags = STARTF_USESHOWWINDOW;
- si.wShowWindow = SW_HIDE;
- }
- //<--- End Added by Stephane Routelous ( stephane.routelous@altavista.net ) [16.03.01]
- //============================================
-
- if (!CreateProcess (
- NULL, (char *)cmd.ToCString (), NULL, NULL, TRUE, CREATE_NEW_CONSOLE, NULL, NULL, &si, &pi
- )
- ) {
-
- _osd_wnt_set_error ( myError, OSD_WProcess );
- aRes = myError.Error();
- }
- else {
-
- CloseHandle ( pi.hThread );
+ STARTUPINFOW aStartupInfo;
+ ZeroMemory (&aStartupInfo, sizeof(STARTUPINFO));
+ aStartupInfo.cb = sizeof(STARTUPINFO);
+ if (!theToShowWindow)
+ {
+ aStartupInfo.dwFlags = STARTF_USESHOWWINDOW;
+ aStartupInfo.wShowWindow = SW_HIDE;
+ }
- WaitForSingleObject ( pi.hProcess, INFINITE );
- GetExitCodeProcess (pi.hProcess, &aRes);
- CloseHandle ( pi.hProcess );
-
- } // end else
+ DWORD aRes = 0;
+ TCollection_ExtendedString aCmdWide (theCmd);
+ wchar_t* aCmdWidePtr = const_cast<wchar_t*>(aCmdWide.ToWideString()); // CreateProcessW() can modify content of this string
+ PROCESS_INFORMATION aProcessInfo;
+ if (!CreateProcessW (NULL, aCmdWidePtr, NULL, NULL, TRUE, CREATE_NEW_CONSOLE, NULL, NULL, &aStartupInfo, &aProcessInfo))
+ {
+ _osd_wnt_set_error (myError, OSD_WProcess);
+ aRes = myError.Error();
+ }
+ else
+ {
+ CloseHandle (aProcessInfo.hThread);
+ WaitForSingleObject (aProcessInfo.hProcess, INFINITE);
+ GetExitCodeProcess (aProcessInfo.hProcess, &aRes);
+ CloseHandle (aProcessInfo.hProcess);
+ }
- return aRes;
+ return aRes;
#else
- (void)cmd;
- (void)ShowWindow;
+ (void )theCmd;
+ (void )theToShowWindow;
return 0;
#endif
-} // end OSD_Process :: Spawn
+}
void OSD_Process :: TerminalType ( TCollection_AsciiString& Name ) {
} // end OSD_Process :: SystemDate
-TCollection_AsciiString OSD_Process :: UserName ()
+// =======================================================================
+// function : UserName
+// purpose :
+// =======================================================================
+TCollection_AsciiString OSD_Process::UserName()
{
#ifndef OCCT_UWP
- Standard_PCharacter pBuff = new char[UNLEN + 1];
- DWORD dwSize = UNLEN + 1;
- TCollection_AsciiString retVal;
- if ( !GetUserName ( pBuff, &dwSize ) )
- {
- _osd_wnt_set_error ( myError, OSD_WProcess );
- }
- else
- {
- TCollection_AsciiString theTmpUserName(pBuff,(int)dwSize -1 );
- retVal = theTmpUserName;
- }
- delete [] pBuff;
- return retVal;
+ wchar_t aUserName[UNLEN + 1];
+ DWORD aNameSize = UNLEN + 1;
+ TCollection_AsciiString retVal;
+ if (!GetUserNameW (aUserName, &aNameSize))
+ {
+ _osd_wnt_set_error(myError, OSD_WProcess);
+ return TCollection_AsciiString();
+ }
+ return TCollection_AsciiString (aUserName);
#else
- return "";
+ return TCollection_AsciiString();
#endif
-} // end OSD_Process :: UserName
+}
Standard_Boolean OSD_Process :: IsSuperUser () {
#ifndef OCCT_UWP
#endif
} // end OSD_Process :: IsSuperUser
-Standard_Integer OSD_Process :: ProcessId () {
-
- return ( Standard_Integer )GetCurrentProcessId ();
-
-} // end OSD_Process :: ProcessId
+// =======================================================================
+// function : ProcessId
+// purpose :
+// =======================================================================
+Standard_Integer OSD_Process::ProcessId()
+{
+ return (Standard_Integer )GetCurrentProcessId();
+}
-OSD_Path OSD_Process :: CurrentDirectory () {
+// =======================================================================
+// function : CurrentDirectory
+// purpose :
+// =======================================================================
+OSD_Path OSD_Process::CurrentDirectory()
+{
OSD_Path anCurrentDirectory;
#ifndef OCCT_UWP
- DWORD dwSize = PATHLEN + 1;
- Standard_WideChar* pBuff = new wchar_t[dwSize];
-
- if (GetCurrentDirectoryW (dwSize, pBuff) > 0)
+ const DWORD aBuffLen = GetCurrentDirectoryW (0, NULL);
+ if (aBuffLen > 0)
{
- // conversion to UTF-8 is performed inside
- TCollection_AsciiString aPath (pBuff);
- anCurrentDirectory = OSD_Path ( aPath );
+ wchar_t* aBuff = new wchar_t[aBuffLen + 1];
+ GetCurrentDirectoryW (aBuffLen, aBuff);
+ aBuff[aBuffLen] = L'\0';
+ const TCollection_AsciiString aPath (aBuff);
+ delete[] aBuff;
+
+ anCurrentDirectory = OSD_Path (aPath);
}
else
- _osd_wnt_set_error ( myError, OSD_WProcess );
-
- delete[] pBuff;
+ {
+ _osd_wnt_set_error (myError, OSD_WProcess);
+ }
#endif
return anCurrentDirectory;
-} // end OSD_Process :: CurrentDirectory
+}
void OSD_Process :: SetCurrentDirectory ( const OSD_Path& where ) {
//! Ctrl+MB2 for pan, etc) and keyboard shortcuts.
//! This method is relevant for MS Windows only and respectively
//! returns WNT_WClass handle.
- Standard_EXPORT static const Handle(MMgt_TShared)& WClass();
+ static const Handle(Standard_Transient)& WClass();
};
#endif // _ViewerTest_HeaderFile
//purpose :
//==============================================================================
-const Handle(MMgt_TShared)& ViewerTest::WClass()
+const Handle(Standard_Transient)& ViewerTest::WClass()
{
- static Handle(MMgt_TShared) theWClass;
+ static Handle(Standard_Transient) theWClass;
#if defined(_WIN32)
if (theWClass.IsNull())
{
theWClass = new WNT_WClass ("GW3D_Class", (Standard_Address )AdvViewerWindowProc,
- CS_VREDRAW | CS_HREDRAW, 0, 0,
- ::LoadCursor (NULL, IDC_ARROW));
+ CS_VREDRAW | CS_HREDRAW, 0, 0,
+ ::LoadCursorW (NULL, IDC_ARROW));
}
#endif
return theWClass;
Standard_CString theTitle)
{
#if defined(_WIN32)
- SetWindowText ((HWND)Handle(WNT_Window)::DownCast(theWindow)->HWindow(),
- theTitle);
+ const TCollection_ExtendedString theTitleW (theTitle);
+ SetWindowTextW ((HWND )Handle(WNT_Window)::DownCast(theWindow)->HWindow(), theTitleW.ToWideString());
#elif defined(__APPLE__) && !defined(MACOSX_USE_GLX)
SetCocoaWindowTitle (Handle(Cocoa_Window)::DownCast(theWindow), theTitle);
#else
const Handle(V3d_View)& aView = ViewerTest::CurrentView();
if (aView.IsNull())
{
- return DefWindowProc( hwnd, Msg, wParam, lParam );
+ return DefWindowProcW (hwnd, Msg, wParam, lParam);
}
PAINTSTRUCT ps;
break;
default:
- return( DefWindowProc( hwnd, Msg, wParam, lParam ));
+ return DefWindowProcW (hwnd, Msg, wParam, lParam);
}
return 0L;
}
-
-
-
//==============================================================================
//function : ViewerMainLoop
//purpose : Get a Event on the view and dispatch it
while ( Ppick == 1 ) {
// Wait for a VT_ProcessButton1Press() to toggle pick to 1 or 0
- if (GetMessage(&msg, NULL, 0, 0) ) {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
+ if (GetMessageW (&msg, NULL, 0, 0))
+ {
+ TranslateMessage (&msg);
+ DispatchMessageW (&msg);
}
}
Standard_Boolean toExit = Standard_False;
MSG aMsg;
- while (PeekMessage (&aMsg, NULL, 0, 0, PM_REMOVE))
+ while (PeekMessageW (&aMsg, NULL, 0, 0, PM_REMOVE))
{
if (aMsg.message == WM_KEYDOWN && (aMsg.wParam == 0x0d || aMsg.wParam == 0x1b))
{
}
TranslateMessage (&aMsg);
- DispatchMessage (&aMsg);
+ DispatchMessageW (&aMsg);
}
if (toExit)
WNT_Uint.hxx
WNT_WClass.cxx
WNT_WClass.hxx
-WNT_WClass.lxx
WNT_Window.cxx
WNT_Window.hxx
WNT_Window.lxx
#include <WNT_WClass.hxx>
-#include <Standard_PCharacter.hxx>
-#include <Standard_Type.hxx>
+#include <TCollection_ExtendedString.hxx>
#include <WNT_ClassDefinitionError.hxx>
#include <WNT_Window.hxx>
#if defined(_WIN32) && !defined(OCCT_UWP)
-#include <string.h>
-IMPLEMENT_STANDARD_RTTIEXT(WNT_WClass,MMgt_TShared)
+IMPLEMENT_STANDARD_RTTIEXT(WNT_WClass, Standard_Transient)
//=======================================================================
//function : WNT_WClass
-//purpose :
+//purpose :
//=======================================================================
-WNT_WClass::WNT_WClass (
- const Standard_CString aClassName,
- const Standard_Address aWndProc,
- const WNT_Uint& aStyle,
- const Standard_Integer aClassExtra,
- const Standard_Integer aWindowExtra,
- const Aspect_Handle aCursor,
- const Aspect_Handle anIcon,
- const Standard_CString aMenuName
- ) {
-
- WNDCLASS wc;
-
- hInstance = GetModuleHandle ( NULL );
-
- wc.style = aStyle;
- wc.lpfnWndProc = ( aWndProc ) ? ( WNDPROC )aWndProc : DefWindowProc;
- wc.cbClsExtra = aClassExtra;
- wc.cbWndExtra = aWindowExtra;
- wc.hInstance = ( HINSTANCE )hInstance;
- wc.hIcon = ( anIcon ) ? ( HICON )anIcon :
- LoadIcon ( NULL, IDI_APPLICATION );
- wc.hCursor = ( aCursor ) ? ( HCURSOR )aCursor :
- LoadCursor ( NULL, IDC_NO );
- wc.hbrBackground = 0;
- wc.lpszMenuName = aMenuName;
- wc.lpszClassName = aClassName;
-
- if ( !RegisterClass ( &wc ) )
-
- WNT_ClassDefinitionError :: Raise ( "Unable to register window class" );
-
- lpszName = new char[ strlen ( aClassName ) + 1 ];
- strcpy ( (Standard_PCharacter)lpszName, aClassName );
- lpfnWndProc = (void* )wc.lpfnWndProc;
-
-} // end constructor
+WNT_WClass::WNT_WClass (const TCollection_AsciiString& theClassName,
+ const Standard_Address theWndProc,
+ const WNT_Uint& theStyle,
+ const Standard_Integer theClassExtra,
+ const Standard_Integer theWindowExtra,
+ const Aspect_Handle theCursor,
+ const Aspect_Handle theIcon,
+ const TCollection_AsciiString& theMenuName)
+: myClassName (theClassName),
+ myAppInstance (GetModuleHandleW (NULL)),
+ myWndProc (NULL)
+{
+ const TCollection_ExtendedString aClassNameW (theClassName);
+ const TCollection_ExtendedString aMenuNameW (theMenuName);
+ WNDCLASSW aWinClass;
+ aWinClass.style = theStyle;
+ aWinClass.lpfnWndProc = theWndProc != NULL ? (WNDPROC )theWndProc : DefWindowProcW;
+ aWinClass.cbClsExtra = theClassExtra;
+ aWinClass.cbWndExtra = theWindowExtra;
+ aWinClass.hInstance = (HINSTANCE )myAppInstance;
+ aWinClass.hIcon = theIcon != NULL ? (HICON )theIcon : LoadIconW (NULL, IDI_APPLICATION);
+ aWinClass.hCursor = theCursor != NULL ? (HCURSOR )theCursor : LoadCursorW (NULL, IDC_NO);
+ aWinClass.hbrBackground = 0;
+ aWinClass.lpszMenuName = !aMenuNameW.IsEmpty() ? aMenuNameW.ToWideString() : NULL;
+ aWinClass.lpszClassName = aClassNameW.ToWideString();
+ if (!RegisterClassW (&aWinClass))
+ {
+ myClassName.Clear();
+ WNT_ClassDefinitionError::Raise ("Unable to register window class");
+ }
+ myWndProc = (Standard_Address )aWinClass.lpfnWndProc;
+}
//=======================================================================
//function : ~WNT_WClass
-//purpose :
+//purpose :
//=======================================================================
-
-WNT_WClass::~WNT_WClass ()
+WNT_WClass::~WNT_WClass()
{
-
- UnregisterClass ( lpszName, ( HINSTANCE )hInstance );
- delete [] (Standard_PCharacter)lpszName;
-
-} // end WNT_WClass :: Destroy
+ if (!myClassName.IsEmpty())
+ {
+ const TCollection_ExtendedString aClassNameW (myClassName);
+ UnregisterClassW (aClassNameW.ToWideString(), (HINSTANCE )myAppInstance);
+ }
+}
#endif // _WIN32
#if defined(_WIN32) && !defined(OCCT_UWP)
-#include <Standard_Type.hxx>
-#include <Standard_CString.hxx>
#include <Aspect_Handle.hxx>
#include <Standard_Address.hxx>
-#include <MMgt_TShared.hxx>
-#include <WNT_Uint.hxx>
+#include <Standard_CString.hxx>
#include <Standard_Integer.hxx>
-class WNT_ClassDefinitionError;
-class WNT_Window;
-
-
-class WNT_WClass;
-DEFINE_STANDARD_HANDLE(WNT_WClass, MMgt_TShared)
+#include <Standard_Transient.hxx>
+#include <Standard_Type.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <WNT_Uint.hxx>
//! This class defines a Windows NT window class.
//! A window in Windows NT is always created based on a
//! the Window class and do not use the WClass at all.
//! We implemented this class for sake of flexibility of
//! event processing.
-class WNT_WClass : public MMgt_TShared
+class WNT_WClass : public Standard_Transient
{
-
+ friend class WNT_Window;
+ DEFINE_STANDARD_RTTIEXT(WNT_WClass, Standard_Transient)
public:
-
//! Creates a Windows NT window class and registers it.
- Standard_EXPORT WNT_WClass(const Standard_CString aClassName, const Standard_Address aWndProc, const WNT_Uint& aStyle, const Standard_Integer aClassExtra = 0, const Standard_Integer aWindowExtra = 0, const Aspect_Handle aCursor = 0, const Aspect_Handle anIcon = 0, const Standard_CString aMenuName = 0);
-
+ Standard_EXPORT WNT_WClass (const TCollection_AsciiString& theClassName,
+ const Standard_Address theWndProc,
+ const WNT_Uint& theStyle,
+ const Standard_Integer theClassExtra = 0,
+ const Standard_Integer theWindowExtra = 0,
+ const Aspect_Handle theCursor = NULL,
+ const Aspect_Handle theIcon = NULL,
+ const TCollection_AsciiString& theMenuName = TCollection_AsciiString());
+
//! Destroys all resources attached to the class
Standard_EXPORT ~WNT_WClass();
-
- //! Returns address of window procedure.
- Standard_Address WndProc() const;
-
- //! Returns a class name.
- Standard_CString Name() const;
-
- //! Returns a program instance handle.
- Aspect_Handle Instance() const;
-friend class WNT_Window;
+ //! Returns address of window procedure.
+ Standard_Address WndProc() const { return myWndProc; }
+ //! Returns a class name.
+ const TCollection_AsciiString& Name() const { return myClassName; }
- DEFINE_STANDARD_RTTIEXT(WNT_WClass,MMgt_TShared)
+ //! Returns a program instance handle.
+ Aspect_Handle Instance() const { return myAppInstance; }
protected:
- Standard_CString lpszName;
- Aspect_Handle hInstance;
- Standard_Address lpfnWndProc;
+ TCollection_AsciiString myClassName;
+ Aspect_Handle myAppInstance;
+ Standard_Address myWndProc;
};
-#include <WNT_WClass.lxx>
+DEFINE_STANDARD_HANDLE(WNT_WClass, Standard_Transient)
#endif // _WIN32
#endif // _WNT_WClass_HeaderFile
+++ /dev/null
-// Copyright (c) 1996-1999 Matra Datavision
-// Copyright (c) 1999-2014 OPEN CASCADE SAS
-//
-// This file is part of Open CASCADE Technology software library.
-//
-// This library is free software; you can redistribute it and/or modify it under
-// the terms of the GNU Lesser General Public License version 2.1 as published
-// by the Free Software Foundation, with special exception defined in the file
-// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
-// distribution for complete text of the license and disclaimer of any warranty.
-//
-// Alternatively, this file may be used under the terms of Open CASCADE
-// commercial license or contractual agreement.
-
-inline Standard_CString WNT_WClass :: Name () const {
-
- return lpszName;
-
-} // end WNT_WClass :: Name
-
-inline Aspect_Handle WNT_WClass :: Instance () const {
-
- return hInstance;
-
-} // end WNT_WClass :: Instance
-
-inline Standard_Address WNT_WClass :: WndProc () const {
-
- return lpfnWndProc;
-
-} // end WNT_WClass :: WndProc
#include <Aspect_Convert.hxx>
#include <Aspect_WindowDefinitionError.hxx>
#include <Aspect_WindowError.hxx>
-#include <Image_AlienPixMap.hxx>
#include <Standard_Type.hxx>
+#include <TCollection_ExtendedString.hxx>
#include <WNT_WClass.hxx>
-#include <stdio.h>
-
-IMPLEMENT_STANDARD_RTTIEXT(WNT_Window,Aspect_Window)
+IMPLEMENT_STANDARD_RTTIEXT(WNT_Window, Aspect_Window)
// =======================================================================
// function : WNT_Window
myWClass (theClass),
myIsForeign (Standard_False)
{
- DWORD dwStyle = theStyle;
-
if (thePxWidth <= 0 || thePxHeight <= 0)
{
Aspect_WindowDefinitionError::Raise ("Coordinate(s) out of range");
}
+ DWORD aStyle = theStyle;
if (theParent && !(theStyle & WS_CHILD))
{
- dwStyle |= WS_CHILD | WS_CLIPSIBLINGS;
+ aStyle |= WS_CHILD | WS_CLIPSIBLINGS;
}
else if (!theParent && !(theStyle & WS_CLIPCHILDREN))
{
- dwStyle |= WS_CLIPCHILDREN;
+ aStyle |= WS_CLIPCHILDREN;
}
- // include decorations in the window dimensions
- // to reproduce same behaviour of Xw_Window.
+ // include decorations in the window dimensions to reproduce same behavior of Xw_Window
RECT aRect;
aRect.top = aYTop;
aRect.bottom = aYBottom;
aRect.left = aXLeft;
aRect.right = aXRight;
- AdjustWindowRect (&aRect, dwStyle, theMenu != NULL ? TRUE : FALSE);
+ AdjustWindowRect (&aRect, aStyle, theMenu != NULL ? TRUE : FALSE);
aXLeft = aRect.left;
aYTop = aRect.top;
aXRight = aRect.right;
aYBottom = aRect.bottom;
- myHWindow = CreateWindow (
- myWClass->Name(), // window's class name
- theTitle, // window's name
- dwStyle, // window's style
- aXLeft, aYTop, // window's coordinates
- (aXRight - aXLeft), (aYBottom - aYTop),
- (HWND )theParent, // window's parent
- (HMENU )theMenu, // window's menu
- (HINSTANCE )myWClass->Instance(), // application's instance
- theClientStruct); // pointer to CLIENTCREATESTRUCT
+ const TCollection_ExtendedString aTitleW (theTitle);
+ const TCollection_ExtendedString aClassNameW (myWClass->Name());
+ myHWindow = CreateWindowW (aClassNameW.ToWideString(), aTitleW.ToWideString(),
+ aStyle,
+ aXLeft, aYTop,
+ (aXRight - aXLeft), (aYBottom - aYTop),
+ (HWND )theParent,
+ (HMENU )theMenu,
+ (HINSTANCE )myWClass->Instance(),
+ theClientStruct);
if (!myHWindow)
{
Aspect_WindowDefinitionError::Raise ("Unable to create window");
// =======================================================================
void WNT_Window::SetCursor (const Aspect_Handle theCursor) const
{
- ::SetClassLongPtr ((HWND )myHWindow, GCLP_HCURSOR, (LONG_PTR )theCursor);
+ ::SetClassLongPtrW ((HWND )myHWindow, GCLP_HCURSOR, (LONG_PTR )theCursor);
}
// =======================================================================