0028110: Configuration - specify Unicode charset instead of multibyte in project...
[occt.git] / src / Draw / Draw_Main.cxx
index c63bc69..de9ad38 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>
 #include <string.h>
 #include <Draw_Appli.hxx>
 #include <OSD.hxx>
+#include <TCollection_AsciiString.hxx>
 
 #include <tcl.h>
 
-#ifdef WNT
+#ifdef _WIN32
 #include <sys/stat.h>
 #include <Draw_Window.hxx>
 
 
 extern Draw_Viewer dout;
 
-static char* ColorNames[MAXCOLOR] = {
-  "White","Red","Green","Blue","Cyan","Gold","Magenta",
-  "Maroon","Orange","Pink","Salmon","Violet","Yellow","Khaki","Coral"
-  };
-
-static   Standard_Boolean XLoop;
-
 // extern Standard_IMPORT Standard_Boolean Draw_Interprete(char* command); //for C21
 Standard_IMPORT Standard_Boolean Draw_Interprete(const char* command); //for C30
 // true if complete command
@@ -78,7 +45,7 @@ Standard_IMPORT Standard_Boolean Draw_Interprete(const char* command); //for C30
 static FDraw_InitAppli theDraw_InitAppli; //pointer to the Draw_InitAppli
 #endif
 
-#ifdef WNT
+#ifdef _WIN32
 //=======================================================================
 //NOTE: OCC11
 //     On Windows NT, both console (UNIX-like) and windowed (classical on 
@@ -101,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;
-
 }
 
 //=======================================================================
@@ -120,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
@@ -143,4 +112,3 @@ Standard_Integer _main_ (Standard_Integer argc, char* argv[], const FDraw_InitAp
   return 0;
 }
 #endif
-