// Copyright (c) 1996-1999 Matra Datavision
-// Copyright (c) 1999-2012 OPEN CASCADE SAS
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
+// This file is part of Open CASCADE Technology software library.
//
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
+// 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.
//
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
+#if defined(_WIN32)
+ #include <windows.h>
+#endif
-#include <windows.h>
-#include <WNT_WClass.ixx>
+#include <WNT_WClass.hxx>
-#include <Standard_PCharacter.hxx>
-#include <InterfaceGraphic_WNT.hxx>
+#include <TCollection_ExtendedString.hxx>
+#include <WNT_ClassDefinitionError.hxx>
+#include <WNT_Window.hxx>
-#include <string.h>
+#if defined(_WIN32) && !defined(OCCT_UWP)
+
+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 + sizeof ( WINDOW_DATA* );
- 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 = wc.lpfnWndProc;
-
-} // end constructor
+WNT_WClass::WNT_WClass (const TCollection_AsciiString& theClassName,
+ const Standard_Address theWndProc,
+ const unsigned int 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 = (UINT)theStyle;
+ aWinClass.lpfnWndProc = theWndProc != NULL ? (WNDPROC )theWndProc : DefWindowProcW;
+ aWinClass.cbClsExtra = theClassExtra;
+ aWinClass.cbWndExtra = theWindowExtra;
+ aWinClass.hInstance = (HINSTANCE )myAppInstance;
+ aWinClass.hIcon = theIcon != NULL ? (HICON )theIcon : LoadIcon (NULL, IDI_APPLICATION);
+ aWinClass.hCursor = theCursor != NULL ? (HCURSOR )theCursor : LoadCursor (NULL, IDC_NO);
+ aWinClass.hbrBackground = 0;
+ aWinClass.lpszMenuName = !aMenuNameW.IsEmpty() ? aMenuNameW.ToWideString() : NULL;
+ aWinClass.lpszClassName = aClassNameW.ToWideString();
+ if (!RegisterClassW (&aWinClass))
+ {
+ myClassName.Clear();
+ throw WNT_ClassDefinitionError("Unable to register window class");
+ }
+ myWndProc = (Standard_Address )aWinClass.lpfnWndProc;
+}
//=======================================================================
-//function : Destroy
-//purpose :
+//function : ~WNT_WClass
+//purpose :
//=======================================================================
-
-void WNT_WClass::Destroy ()
+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