]> OCCT Git - occt-copy.git/commitdiff
0028110: Configuration - specify Unicode charset instead of multibyte in project...
authorski <ski@opencascade.com>
Mon, 14 Nov 2016 11:31:00 +0000 (14:31 +0300)
committerapn <apn@opencascade.com>
Thu, 29 Dec 2016 11:29:16 +0000 (14:29 +0300)
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.

27 files changed:
CMakeLists.txt
adm/genproj.tcl
src/Draw/COMMANDWINDOW.h
src/Draw/CommandWindow.cxx
src/Draw/Draw.cxx
src/Draw/Draw_Appli.hxx
src/Draw/Draw_Main.cxx
src/Draw/Draw_Viewer.cxx
src/Draw/Draw_Window.cxx
src/Draw/Draw_Window.hxx
src/Draw/Draw_Window_1.mm
src/Draw/MainWindow.cxx
src/Draw/init.cxx
src/Draw/init.h
src/IVtkDraw/IVtkDraw.cxx
src/IVtkDraw/IVtkDraw.hxx
src/OSD/OSD_Environment.cxx
src/OSD/OSD_File.cxx
src/OSD/OSD_Host.cxx
src/OSD/OSD_Process.cxx
src/ViewerTest/ViewerTest.hxx
src/ViewerTest/ViewerTest_ViewerCommands.cxx
src/WNT/FILES
src/WNT/WNT_WClass.cxx
src/WNT/WNT_WClass.hxx
src/WNT/WNT_WClass.lxx [deleted file]
src/WNT/WNT_Window.cxx

index 6c2510ee1b6a22bfcd0131b94fb938c6dd058531..174cdeea6f326a4c17681fe960383c6c50d29f01 100644 (file)
@@ -37,6 +37,11 @@ endif()
 # 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")
 
index 88fb1e091bebe16be4e9b982d81d6461d017850a..57848aa3bc4810aea739a975c142f62a925c73fc 100644 (file)
@@ -1154,7 +1154,7 @@ proc osutils:vcproj:readtemplate {theVcVer isexec} {
   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"
@@ -1175,7 +1175,6 @@ proc osutils:vcproj:readtemplate {theVcVer isexec} {
       }
       set aCmpl${bitness} "[set aCmpl${bitness}]${indent}${UwpWinRt}"
     }
-    set aCharSet "Unicode"
   }
 
   foreach bitness {32 64} {
index 6077ca198d12214e0c207c888867992db9a35fae..01304f33f7fef0916c440c856d5bc562c8a6e3d4 100644 (file)
 #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);
index 52f2f91a136af02e8e0d726404690f730a623ac9..e7bf9065351a01475ea8604b9bb7477f7bc0a126 100644 (file)
 #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);
+
+  // 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 CallWindowProc(OldEditProc, hWnd, wMsg, wParam, lParam);
 }
 #endif
-
-
index 216ade1ec0cc0abedacd459d24503ad8b3466c58..f1d79898d6b5ff98181e933e430bdf89cdd2eb54 100644 (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();
index 4df133cf8e3b6f3d2297c15b1fb151ed8754b03e..f529b2c935c7aba023c4d9ba0f19db906af15042 100644 (file)
 // 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
 
index c33a54f77a191c2d0ca61b45d2a4a09db7ff3443..de9ad382bf943babe455548a91c4174db611ba7c 100644 (file)
 // 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
-
index 9f5f031a5e3ff160cfdf18dd4c27c46f23c4fbab..ec9848f662e8ca713699e44f3a91b83bfe104aac 100644 (file)
 // 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);
 }
 
 //=======================================================================
index 1948e0aca62c01ef9c4e41ed8dfe8ee2bc343540..ab84f6976c36d4547703609e221ff228d97d491f 100644 (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)
+  {
+    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);
 }
 
 
@@ -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);
+  SetWindowLongPtr(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 (GetMessage(&msg, NULL, 0, 0) > 0)
   {
-    if (!TranslateAccelerator(hWnd, hAccel, &msg))
+    if (!TranslateAccelerator(hWnd, hAccel, &msg))
     {
-      TranslateMessage(&msg);
-      DispatchMessage(&msg);
+      TranslateMessage (&msg);
+      DispatchMessage(&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);
+  GetMessage(&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);
index 6bab4708387d350013dda436e112d3df792c822c..55c9629763643481f7cbbdaa17b68d61f96295af 100644 (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();
index 222d72881af37be2df5cd8a2279300f3e19b21c0..cb3c72964e4a238b8b812559371efd92ea24da45 100644 (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);
 }
 
 //=======================================================================
index ccbc4611acaecd40beb535086077cff7f927f88c..17ea35e2e472d5f9bec6506b444db87266893948 100644 (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);
+    SetWindowLongPtr(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);
index b61919814b8010c26d1c58ce842e0cc490a7cb91..34d2176910c95bfbd6da56b822d4ca85f704ab9a 100644 (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,
index 4e41748624588cc01f25a87277bc3a66fd1a90b6..478a0eb6a3b15670634e086e9e005c23512f9ce3 100644 (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);
index 042626a29901f5d870ce0610435207cc4e004f24..8e7b04c559c214b3d90346ece13e46174c082fd7 100644 (file)
@@ -251,15 +251,15 @@ Standard_Integer GenerateId()
 // 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;
index 16f3eda0f5f85a67fca328533c039956b5ecbc48..6c485bea5e41fa6be70dc98974520cffd86f617d 100644 (file)
 #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
 {
@@ -38,7 +37,7 @@ public:
   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
index 8a4e4e9eb53f79f6eb12941437499e2f13d7a7db..dfa7ecf3983f17db73bc25482d7361a7d44b8af1 100644 (file)
@@ -14,7 +14,6 @@
 
 #ifndef _WIN32
 
-
 #include <OSD_Environment.hxx>
 #include <OSD_OSDError.hxx>
 #include <OSD_WhoAmI.hxx>
@@ -234,20 +233,16 @@ Standard_Integer OSD_Environment::Error() const
 //------------------------------------------------------------------------
 
 #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
 {
@@ -381,28 +376,22 @@ Standard_Integer OSD_Environment :: Error () const {
 }  // 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
index 1b5e64ad1b39488c1e53dfa47f10f846ed26757f..61e90711c6867541268b1040855bb142e0aa5ba0 100644 (file)
@@ -1430,7 +1430,7 @@ OSD_KindFile OSD_File :: KindOfFile () const {
 typedef struct _osd_wnt_key {
 
                 HKEY   hKey;
-                const char* keyPath;
+                wchar_t* keyPath;
 
                } OSD_WNT_KEY;
 
@@ -1448,17 +1448,17 @@ typedef struct _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
   ) {
index 4ab93a99a89b559386fe3fc40675505445958bb8..8b5c8850a67d7d83808b46c6ab115e4074d31cf2 100644 (file)
@@ -14,7 +14,6 @@
 
 #ifndef _WIN32
 
-
 #include <OSD_Host.hxx>
 #include <OSD_OSDError.hxx>
 #include <OSD_WhoAmI.hxx>
@@ -202,13 +201,13 @@ static Standard_Integer        memSize;
 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 ) {
 
@@ -216,25 +215,24 @@ OSD_Host :: OSD_Host () {
   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)
@@ -248,7 +246,7 @@ OSD_Host :: OSD_Host () {
    
     _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 );
    
index 17ed7074c732804318f84165d47f509dc4ed68ac..c2373463b5483c2ae2b8f7323231e9c560485064 100644 (file)
@@ -14,7 +14,6 @@
 
 #ifndef _WIN32
 
-
 #include <OSD_Environment.hxx>
 #include <OSD_OSDError.hxx>
 #include <OSD_Path.hxx>
@@ -195,65 +194,60 @@ Standard_Integer OSD_Process::Error()const{
 #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 ) {
 
@@ -276,27 +270,26 @@ Quantity_Date OSD_Process :: SystemDate () {
 
 }  // 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
@@ -341,31 +334,41 @@ Standard_Boolean OSD_Process :: IsSuperUser () {
 #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 ) {
 
index 1e16d9a71b4b7ae348f3534859406ed6dd5448e1..e4d57833a4578833554bf90f2bd829c17760b82f 100644 (file)
@@ -208,7 +208,7 @@ private:
   //! 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
index 417771ce22bf781e5620fa6f75876178650f7acb..b107406d00760dd1de311c3977df61d2abd3d465 100644 (file)
@@ -247,15 +247,15 @@ static LRESULT WINAPI AdvViewerWindowProc(
 //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;
@@ -451,8 +451,8 @@ void SetWindowTitle (const Handle(Aspect_Window)& theWindow,
                      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
@@ -2007,7 +2007,7 @@ static LRESULT WINAPI ViewerWindowProc( HWND hwnd,
   const Handle(V3d_View)& aView = ViewerTest::CurrentView();
   if (aView.IsNull())
   {
-    return DefWindowProc( hwnd, Msg, wParam, lParam );
+    return DefWindowProcW (hwnd, Msg, wParam, lParam);
   }
 
     PAINTSTRUCT    ps;
@@ -2175,14 +2175,11 @@ static LRESULT WINAPI ViewerWindowProc( HWND hwnd,
       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
@@ -2203,9 +2200,10 @@ int ViewerMainLoop(Standard_Integer argc, const char** argv)
 
     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);
       }
     }
 
@@ -9489,7 +9487,7 @@ static Standard_Integer VProgressiveMode (Draw_Interpretor& /*theDI*/,
     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))
       {
@@ -9497,7 +9495,7 @@ static Standard_Integer VProgressiveMode (Draw_Interpretor& /*theDI*/,
       }
 
       TranslateMessage (&aMsg);
-      DispatchMessage  (&aMsg);
+      DispatchMessageW (&aMsg);
     }
 
     if (toExit)
index 9a673ac53951a1f5a8c50c3988db82fdd9e74eed..2054f3b03465f7dd278c2e435a5fb379b12cc058 100755 (executable)
@@ -4,7 +4,6 @@ WNT_OrientationType.hxx
 WNT_Uint.hxx
 WNT_WClass.cxx
 WNT_WClass.hxx
-WNT_WClass.lxx
 WNT_Window.cxx
 WNT_Window.hxx
 WNT_Window.lxx
index e3f727172733539072e90bca73030e1be8332dd1..519cbae8f7587fcdadb09ba82e59c4dd43989db7 100644 (file)
 
 #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
index b6809b1766c007e2511a714e6412a315faafc874..b2c339e776e7a30399b242dc51548deb2052c46f 100644 (file)
 
 #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
@@ -54,41 +49,43 @@ DEFINE_STANDARD_HANDLE(WNT_WClass, MMgt_TShared)
 //! 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
diff --git a/src/WNT/WNT_WClass.lxx b/src/WNT/WNT_WClass.lxx
deleted file mode 100644 (file)
index 6240eca..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-// 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
index 99f3bbd811024c0953c7fa3a2fef880a580254f9..31e7c8a8bb4c7939c826a3536ff064e4aefb9ac9 100644 (file)
 #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
@@ -53,45 +51,43 @@ WNT_Window::WNT_Window (const Standard_CString           theTitle,
   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");
@@ -146,7 +142,7 @@ WNT_Window::~WNT_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);
 }
 
 // =======================================================================