Attached Files | unicode.tar.gz [^] (14,809 bytes) 1969-12-31 19:00
unicode.patch [^] (13,339 bytes) 1969-12-31 19:00 [Show Content] [Hide Content]Index: Common/vtkDebugLeaks.cxx
===================================================================
RCS file: /cvsroot/VTK/VTK/Common/vtkDebugLeaks.cxx,v
retrieving revision 1.25
diff -u -3 -p -r1.25 vtkDebugLeaks.cxx
--- Common/vtkDebugLeaks.cxx 14 Nov 2003 20:43:24 -0000 1.25
+++ Common/vtkDebugLeaks.cxx 17 Feb 2004 17:03:14 -0000
@@ -325,7 +325,7 @@ void vtkDebugLeaks::PrintCurrentLeaks()
int vtkDebugLeaks::DisplayMessageBox(const char* msg)
{
#ifdef UNICODE
- wchar_t *wmsg = new wchar_t [mbstowcs(NULL, msg, 32000)];
+ wchar_t *wmsg = new wchar_t [mbstowcs(NULL, msg, 32000)+1];
mbstowcs(wmsg, msg, 32000);
int result = (MessageBox(NULL, wmsg, L"Error",
MB_ICONERROR | MB_OKCANCEL) == IDCANCEL);
Index: Common/vtkDynamicLoader.cxx
===================================================================
RCS file: /cvsroot/VTK/VTK/Common/vtkDynamicLoader.cxx,v
retrieving revision 1.17
diff -u -3 -p -r1.17 vtkDynamicLoader.cxx
--- Common/vtkDynamicLoader.cxx 18 Dec 2003 00:25:08 -0000 1.17
+++ Common/vtkDynamicLoader.cxx 17 Feb 2004 17:03:14 -0000
@@ -154,7 +154,7 @@ const char* vtkDynamicLoader::LastError(
vtkLibHandle vtkDynamicLoader::OpenLibrary(const char* libname )
{
#ifdef UNICODE
- wchar_t *libn = new wchar_t [mbstowcs(NULL, libname, 32000)];
+ wchar_t *libn = new wchar_t [mbstowcs(NULL, libname, 32000)+1];
mbstowcs(libn, libname, 32000);
vtkLibHandle ret = LoadLibrary(libn);
delete [] libn;
@@ -171,8 +171,8 @@ int vtkDynamicLoader::CloseLibrary(vtkLi
void* vtkDynamicLoader::GetSymbolAddress(vtkLibHandle lib, const char* sym)
{
-#ifdef UNICODE
- wchar_t *wsym = new wchar_t [mbstowcs(NULL, sym, 32000)];
+#if defined (UNICODE) && !defined(_MSC_VER)
+ wchar_t *wsym = new wchar_t [mbstowcs(NULL, sym, 32000)+1];
mbstowcs(wsym, sym, 32000);
// Force GetProcAddress to return void* with a c style cast
// This is because you can not cast a function to a void* without
Index: Common/vtkWin32OutputWindow.cxx
===================================================================
RCS file: /cvsroot/VTK/VTK/Common/vtkWin32OutputWindow.cxx,v
retrieving revision 1.18
diff -u -3 -p -r1.18 vtkWin32OutputWindow.cxx
--- Common/vtkWin32OutputWindow.cxx 14 Nov 2003 20:43:26 -0000 1.18
+++ Common/vtkWin32OutputWindow.cxx 17 Feb 2004 17:03:14 -0000
@@ -101,9 +101,19 @@ void vtkWin32OutputWindow::AddText(const
// move to the end of the text area
SendMessage( vtkWin32OutputWindow::OutputWindow, EM_SETSEL,
(WPARAM)-1, (LPARAM)-1 );
+
+#ifdef UNICODE
+ wchar_t *wmsg = new wchar_t [mbstowcs(NULL, someText, 32000)+1];
+ mbstowcs(wmsg, someText, 32000);
+ // Append the text to the control
+ SendMessage( vtkWin32OutputWindow::OutputWindow, EM_REPLACESEL,
+ 0, (LPARAM)wmsg );
+ delete [] wmsg;
+#else
// Append the text to the control
SendMessage( vtkWin32OutputWindow::OutputWindow, EM_REPLACESEL,
0, (LPARAM)someText );
+#endif
}
@@ -155,6 +165,12 @@ int vtkWin32OutputWindow::Initialize()
WS_OVERLAPPED | WS_CLIPCHILDREN,
0, 0, 512, 512,
NULL, NULL, GetModuleHandle(NULL), NULL);
+#elif UNICODE
+ HWND win = CreateWindow(
+ L"vtkOutputWindow", L"vtkOutputWindow",
+ WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN,
+ 0, 0, 512, 512,
+ NULL, NULL, GetModuleHandle(NULL), NULL);
#else
HWND win = CreateWindow(
"vtkOutputWindow", "vtkOutputWindow",
@@ -172,22 +188,27 @@ int vtkWin32OutputWindow::Initialize()
lpParam.cy = 512;
lpParam.x = 0;
lpParam.y = 0;
+#if defined(_WIN32_WCE) || defined(UNICODE)
+ lpParam.lpszName = L"Output Control";
+ lpParam.lpszClass = L"EDIT"; // use the RICHEDIT control widget
+#else
+ lpParam.lpszName = "Output Control";
+ lpParam.lpszClass = "EDIT"; // use the RICHEDIT control widget
+#endif
+
#ifdef _WIN32_WCE
lpParam.style = ES_MULTILINE | ES_READONLY | WS_CHILD
| ES_AUTOVSCROLL | ES_AUTOHSCROLL | WS_VISIBLE
| WS_VSCROLL | WS_HSCROLL;
- lpParam.lpszName = L"Output Control";
- lpParam.lpszClass = L"EDIT"; // use the RICHEDIT control widget
#else
lpParam.style = ES_MULTILINE | ES_READONLY | WS_CHILD
| ES_AUTOVSCROLL | ES_AUTOHSCROLL | WS_VISIBLE | WS_MAXIMIZE
| WS_VSCROLL | WS_HSCROLL;
- lpParam.lpszName = "Output Control";
- lpParam.lpszClass = "EDIT"; // use the RICHEDIT control widget
#endif
+
lpParam.dwExStyle = 0;
// Create the EDIT window as a child of win
-#ifdef _WIN32_WCE
+#if defined(_WIN32_WCE) || defined(UNICODE)
vtkWin32OutputWindow::OutputWindow = CreateWindow(
lpParam.lpszClass, // pointer to registered class name
L"", // pointer to window name
@@ -235,14 +256,14 @@ void vtkWin32OutputWindow::PromptText(co
sprintf(vtkmsg,"%s\nPress Cancel to suppress any further messages.",
someText);
#ifdef UNICODE
- wchar_t *wmsg = new wchar_t [mbstowcs(NULL, vtkmsg, 32000)];
- mbstowcs(wmsg, vtkmsg, 32000);
- if (MessageBox(NULL, wmsg, L"Error",
- MB_ICONERROR | MB_OKCANCEL) == IDCANCEL)
- {
- vtkObject::GlobalWarningDisplayOff();
- }
- delete [] wmsg;
+ wchar_t *wmsg = new wchar_t [mbstowcs(NULL, vtkmsg, 32000)+1];
+ mbstowcs(wmsg, vtkmsg, 32000);
+ if (MessageBox(NULL, wmsg, L"Error",
+ MB_ICONERROR | MB_OKCANCEL) == IDCANCEL)
+ {
+ vtkObject::GlobalWarningDisplayOff();
+ }
+ delete [] wmsg;
#else
if (MessageBox(NULL, vtkmsg, "Error",
MB_ICONERROR | MB_OKCANCEL) == IDCANCEL)
Index: Rendering/vtkWin32OpenGLRenderWindow.cxx
===================================================================
RCS file: /cvsroot/VTK/VTK/Rendering/vtkWin32OpenGLRenderWindow.cxx,v
retrieving revision 1.122
diff -u -3 -p -r1.122 vtkWin32OpenGLRenderWindow.cxx
--- Rendering/vtkWin32OpenGLRenderWindow.cxx 9 Dec 2003 00:01:42 -0000 1.122
+++ Rendering/vtkWin32OpenGLRenderWindow.cxx 17 Feb 2004 17:03:14 -0000
@@ -159,7 +159,14 @@ void vtkWin32OpenGLRenderWindow::SetWind
vtkWindow::SetWindowName(_arg);
if (this->WindowId)
{
- SetWindowText(this->WindowId,this->WindowName);
+#ifdef UNICODE
+ wchar_t *wname = new wchar_t [mbstowcs(NULL, this->WindowName, 32000)+1];
+ mbstowcs(wname, this->WindowName, 32000);
+ SetWindowText(this->WindowId, wname);
+ delete [] wname;
+#else
+ SetWindowText(this->WindowId, this->WindowName);
+#endif
}
}
@@ -212,9 +219,19 @@ void vtkWin32OpenGLRenderWindow::MakeCur
0,
NULL
);
- vtkErrorMacro("wglMakeCurrent failed in MakeCurrent(), error: "
+#ifdef UNICODE
+ wchar_t *wmsg = new wchar_t [mbstowcs(NULL, (const char*)lpMsgBuf, 32000)+1];
+ wchar_t *wtemp = new wchar_t [mbstowcs(NULL, "wglMakeCurrent failed in MakeCurrent(), error: ", 32000)+1];
+ mbstowcs(wmsg, (const char*)lpMsgBuf, 32000);
+ mbstowcs(wtemp, "wglMakeCurrent failed in MakeCurrent(), error: ", 32000);
+ vtkErrorMacro(<< wcscat(wtemp, wmsg));
+ delete [] wmsg;
+ delete [] wtemp;
+#else
+ vtkErrorMacro("wglMakeCurrent failed in MakeCurrent(), error: "
<< (LPCTSTR)lpMsgBuf);
- ::LocalFree( lpMsgBuf );
+#endif
+ ::LocalFree( lpMsgBuf );
}
}
}
@@ -235,7 +252,11 @@ void vtkWin32OpenGLRenderWindow::SetSize
{
resizing = 1;
this->CleanUpOffScreenRendering();
+#ifdef UNICODE
+ HDC dc = CreateDC(L"DISPLAY", 0, 0, 0);
+#else
HDC dc = CreateDC("DISPLAY", 0, 0, 0);
+#endif
this->CreateOffScreenDC(x, y, dc);
DeleteDC(dc);
resizing = 0;
@@ -450,11 +471,18 @@ void vtkWin32OpenGLRenderWindow::SetupPi
DescribePixelFormat(hDC, currentPixelFormat,sizeof(pfd), &pfd);
if (!(pfd.dwFlags & PFD_SUPPORT_OPENGL))
{
+#ifdef UNICODE
+ MessageBox(WindowFromDC(hDC),
+ L"Invalid pixel format, no OpenGL support",
+ L"Error",
+ MB_ICONERROR | MB_OK);
+#else
MessageBox(WindowFromDC(hDC),
"Invalid pixel format, no OpenGL support",
"Error",
MB_ICONERROR | MB_OK);
- if (this->HasObserver(vtkCommand::ExitEvent))
+#endif
+ if (this->HasObserver(vtkCommand::ExitEvent))
{
this->InvokeEvent(vtkCommand::ExitEvent, NULL);
return;
@@ -471,8 +499,13 @@ void vtkWin32OpenGLRenderWindow::SetupPi
pixelFormat = ChoosePixelFormat(hDC, &pfd);
if (pixelFormat == 0)
{
+#ifdef UNICODE
+ MessageBox(WindowFromDC(hDC), L"ChoosePixelFormat failed.", L"Error",
+ MB_ICONERROR | MB_OK);
+#else
MessageBox(WindowFromDC(hDC), "ChoosePixelFormat failed.", "Error",
MB_ICONERROR | MB_OK);
+#endif
if (this->HasObserver(vtkCommand::ExitEvent))
{
this->InvokeEvent(vtkCommand::ExitEvent, NULL);
@@ -487,9 +520,14 @@ void vtkWin32OpenGLRenderWindow::SetupPi
if (SetPixelFormat(hDC, pixelFormat, &pfd) != TRUE)
{
// int err = GetLastError();
+#ifdef UNICODE
+ MessageBox(WindowFromDC(hDC), L"SetPixelFormat failed.", L"Error",
+ MB_ICONERROR | MB_OK);
+#else
MessageBox(WindowFromDC(hDC), "SetPixelFormat failed.", "Error",
MB_ICONERROR | MB_OK);
- if (this->HasObserver(vtkCommand::ExitEvent))
+#endif
+ if (this->HasObserver(vtkCommand::ExitEvent))
{
this->InvokeEvent(vtkCommand::ExitEvent, NULL);
return;
@@ -662,11 +700,15 @@ void vtkWin32OpenGLRenderWindow::CreateA
+ 1;
windowName = new char [ len ];
sprintf(windowName,"Visualization Toolkit - Win32OpenGL #%i",count++);
- this->SetWindowName(windowName);
+ this->SetWindowName(windowName);
delete [] windowName;
// has the class been registered ?
+#ifdef UNICODE
+ if (!GetClassInfo(this->ApplicationInstance,L"vtkOpenGL",&wndClass))
+#else
if (!GetClassInfo(this->ApplicationInstance,"vtkOpenGL",&wndClass))
+#endif
{
wndClass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wndClass.lpfnWndProc = vtkWin32OpenGLRenderWindow::WndProc;
@@ -676,7 +718,11 @@ void vtkWin32OpenGLRenderWindow::CreateA
wndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
wndClass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wndClass.lpszMenuName = NULL;
+#ifdef UNICODE
+ wndClass.lpszClassName = L"vtkOpenGL";
+#else
wndClass.lpszClassName = "vtkOpenGL";
+#endif
// vtk doesn't use the first extra 4 bytes, but app writers
// may want them, so we provide them. VTK does use the second
// four bytes of extra space.
@@ -684,14 +730,28 @@ void vtkWin32OpenGLRenderWindow::CreateA
RegisterClass(&wndClass);
}
- /* create window */
+#ifdef UNICODE
+ wchar_t *wname = new wchar_t [mbstowcs(NULL, this->WindowName, 32000)+1];
+ mbstowcs(wname, this->WindowName, 32000);
+ SetWindowText(this->WindowId, wname);
+#endif
+
+ /* create window */
if (this->ParentId)
{
+#ifdef UNICODE
+ this->WindowId = CreateWindow(
+ L"vtkOpenGL", wname,
+ WS_CHILD | WS_CLIPCHILDREN /*| WS_CLIPSIBLINGS*/,
+ x, y, width, height,
+ this->ParentId, NULL, this->ApplicationInstance, NULL);
+#else
this->WindowId = CreateWindow(
"vtkOpenGL", this->WindowName,
WS_CHILD | WS_CLIPCHILDREN /*| WS_CLIPSIBLINGS*/,
x, y, width, height,
this->ParentId, NULL, this->ApplicationInstance, NULL);
+#endif
}
else
{
@@ -704,12 +764,24 @@ void vtkWin32OpenGLRenderWindow::CreateA
{
style = WS_POPUP | WS_CLIPCHILDREN /*| WS_CLIPSIBLINGS*/;
}
+#ifdef UNICODE
+ this->WindowId = CreateWindow(
+ L"vtkOpenGL", wname, style,
+ x,y, width+2*GetSystemMetrics(SM_CXFRAME),
+ height+2*GetSystemMetrics(SM_CYFRAME) +GetSystemMetrics(SM_CYCAPTION),
+ NULL, NULL, this->ApplicationInstance, NULL);
+#else
this->WindowId = CreateWindow(
"vtkOpenGL", this->WindowName, style,
x,y, width+2*GetSystemMetrics(SM_CXFRAME),
height+2*GetSystemMetrics(SM_CYFRAME) +GetSystemMetrics(SM_CYCAPTION),
NULL, NULL, this->ApplicationInstance, NULL);
+#endif
}
+#ifdef UNICODE
+ delete [] wname;
+#endif
+
if (!this->WindowId)
{
vtkErrorMacro("Could not create window, error: " << GetLastError());
@@ -1107,7 +1179,11 @@ void vtkWin32OpenGLRenderWindow::SetOffS
size[0] = (this->Size[0] > 0) ? this->Size[0] : 300;
size[1] = (this->Size[1] > 0) ? this->Size[1] : 300;
+#ifdef UNICODE
+ HDC dc = CreateDC(L"DISPLAY", 0, 0, 0);
+#else
HDC dc = CreateDC("DISPLAY", 0, 0, 0);
+#endif
this->SetupMemoryRendering(size[0], size[1], dc);
DeleteDC(dc);
}
@@ -1227,7 +1303,11 @@ void vtkWin32OpenGLRenderWindow::SetupMe
void vtkWin32OpenGLRenderWindow::SetupMemoryRendering(HBITMAP hbmp)
{
+#ifdef UNICODE
+ HDC dc = CreateDC(L"DISPLAY", 0, 0, 0);
+#else
HDC dc = CreateDC("DISPLAY", 0, 0, 0);
+#endif
// save the current state
this->ScreenMapped = this->Mapped;
|