]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/app.cpp
Fix UseUintMax definition used by wxAny for VC6.
[wxWidgets.git] / src / os2 / app.cpp
index 3ea50a31ca2fdb54246fc01de155b62d32360d6c..e6a8c71e5437beab43397c30b39ff4346944d415 100644 (file)
@@ -1,5 +1,5 @@
 /////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////
-// Name:        app.cpp
+// Name:        src/os2/app.cpp
 // Purpose:     wxApp
 // Author:      David Webster
 // Modified by:
 // Purpose:     wxApp
 // Author:      David Webster
 // Modified by:
@@ -9,16 +9,14 @@
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
-#ifdef __GNUG__
-    #pragma implementation "app.h"
-#endif
-
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
+#include "wx/app.h"
+
 #ifndef WX_PRECOMP
 #ifndef WX_PRECOMP
+    #include "wx/dynarray.h"
     #include "wx/frame.h"
     #include "wx/frame.h"
-    #include "wx/app.h"
     #include "wx/utils.h"
     #include "wx/gdicmn.h"
     #include "wx/pen.h"
     #include "wx/utils.h"
     #include "wx/gdicmn.h"
     #include "wx/pen.h"
     #include "wx/dialog.h"
     #include "wx/msgdlg.h"
     #include "wx/intl.h"
     #include "wx/dialog.h"
     #include "wx/msgdlg.h"
     #include "wx/intl.h"
-    #include "wx/dynarray.h"
-    #include "wx/wxchar.h"
-    #include "wx/icon.h"
+    #include "wx/crt.h"
+    #include "wx/log.h"
+    #include "wx/module.h"
 #endif
 
 #endif
 
-#include "wx/log.h"
-#include "wx/module.h"
+#include "wx/stdpaths.h"
+#include "wx/filename.h"
+#include "wx/evtloop.h"
 
 #include "wx/os2/private.h"
 
 
 #include "wx/os2/private.h"
 
 
 #endif //
 
 
 #endif //
 
-#ifndef __EMX__
+#if defined(__WATCOMC__)
+
+#include <tcpustd.h>
+
+#elif !defined(__EMX__)
 
 #define select(a,b,c,d,e) bsdselect(a,b,c,d,e)
 extern "C" int _System bsdselect(int,
 
 #define select(a,b,c,d,e) bsdselect(a,b,c,d,e)
 extern "C" int _System bsdselect(int,
@@ -79,9 +82,7 @@ extern "C" int _System bsdselect(int,
 // global variables
 // ---------------------------------------------------------------------------
 
 // global variables
 // ---------------------------------------------------------------------------
 
-extern wxChar*                      wxBuffer;
-extern wxList*                      wxWinHandleList;
-extern wxList WXDLLEXPORT           wxPendingDelete;
+WXDLLEXPORT_DATA(wxChar*) wxBuffer;
 extern wxCursor*                    g_globalCursor;
 
 HAB                                 vHabmain = NULLHANDLE;
 extern wxCursor*                    g_globalCursor;
 
 HAB                                 vHabmain = NULLHANDLE;
@@ -115,38 +116,13 @@ struct GsocketCallbackInfo{
     void* gsock;
 };
 
     void* gsock;
 };
 
-// These defines and wrapper functions are used here and in gsockpm.c
+// These defines are used here and in gsockpm.cpp
 #define wxSockReadMask  0x01
 #define wxSockWriteMask 0x02
 
 #define wxSockReadMask  0x01
 #define wxSockWriteMask 0x02
 
-#ifdef __EMX__
-extern "C"
-int wxAppAddSocketHandler(int handle, int mask,
-                           void (*callback)(void*), void * gsock)
-{
-    return wxTheApp->AddSocketHandler(handle, mask, callback, gsock);
-}
-extern "C"
-void wxAppRemoveSocketHandler(int handle)
-{
-    wxTheApp->RemoveSocketHandler(handle);
-}
-#else
-//  Linkage mode problems using callbacks with extern C in a .cpp module
-int wxAppAddSocketHandler(int handle, int mask,
-                           void (*callback)(void*), void * gsock)
-{
-    return wxTheApp->AddSocketHandler(handle, mask, callback, gsock);
-}
-void wxAppRemoveSocketHandler(int handle)
-{
-    wxTheApp->RemoveSocketHandler(handle);
-}
-#endif
-
 void wxApp::HandleSockets()
 {
 void wxApp::HandleSockets()
 {
-    bool pendingEvent = FALSE;
+    bool pendingEvent = false;
 
     // Check whether it's time for Gsocket operation
     if (m_maxSocketHandles > 0 && m_maxSocketNr > 0)
 
     // Check whether it's time for Gsocket operation
     if (m_maxSocketHandles > 0 && m_maxSocketNr > 0)
@@ -175,7 +151,7 @@ void wxApp::HandleSockets()
                     if (r < m_maxSocketHandles)
                     {
                         CallbackInfo[r].proc(CallbackInfo[r].gsock);
                     if (r < m_maxSocketHandles)
                     {
                         CallbackInfo[r].proc(CallbackInfo[r].gsock);
-                        pendingEvent = TRUE;
+                        pendingEvent = true;
                     }
                 }
                 if (FD_ISSET(i, &writefds))
                     }
                 }
                 if (FD_ISSET(i, &writefds))
@@ -188,7 +164,7 @@ void wxApp::HandleSockets()
                     if (r < m_maxSocketHandles)
                     {
                         CallbackInfo[r].proc(CallbackInfo[r].gsock);
                     if (r < m_maxSocketHandles)
                     {
                         CallbackInfo[r].proc(CallbackInfo[r].gsock);
-                        pendingEvent = TRUE;
+                        pendingEvent = true;
                     }
                 }
             }
                     }
                 }
             }
@@ -244,24 +220,24 @@ bool wxApp::Initialize(int& argc, wxChar **argv)
     // OS2 has to have an anchorblock
     //
     vHabmain = WinInitialize(0);
     // OS2 has to have an anchorblock
     //
     vHabmain = WinInitialize(0);
-
+    wxFileName GetPrefix(argv[0]);
+    GetPrefix.MakeAbsolute();
+    wxStandardPaths::SetInstallPrefix(GetPrefix.GetPath());
     if (!vHabmain)
     {
         // TODO: at least give some error message here...
         wxAppBase::CleanUp();
 
     if (!vHabmain)
     {
         // TODO: at least give some error message here...
         wxAppBase::CleanUp();
 
-        return FALSE;
+        return false;
     }
 
     wxBuffer = new wxChar[1500]; // FIXME; why?
 
     // Some people may wish to use this, but
     // probably it shouldn't be here by default.
     }
 
     wxBuffer = new wxChar[1500]; // FIXME; why?
 
     // Some people may wish to use this, but
     // probably it shouldn't be here by default.
-#ifdef __WXDEBUG__
     //    wxRedirectIOToConsole();
     //    wxRedirectIOToConsole();
-#endif
 
 
-    wxWinHandleList = new wxList(wxKEY_INTEGER);
+    wxWinHandleHash = new wxWinHashTable(wxKEY_INTEGER, 100);
 
     // This is to foil optimizations in Visual C++ that throw out dummy.obj.
     // PLEASE DO NOT ALTER THIS.
 
     // This is to foil optimizations in Visual C++ that throw out dummy.obj.
     // PLEASE DO NOT ALTER THIS.
@@ -274,7 +250,7 @@ bool wxApp::Initialize(int& argc, wxChar **argv)
 
     RegisterWindowClasses(vHabmain);
 
 
     RegisterWindowClasses(vHabmain);
 
-    return TRUE;
+    return true;
 } // end of wxApp::Initialize
 
 const char*                         CANTREGISTERCLASS = " Can't register Class ";
 } // end of wxApp::Initialize
 
 const char*                         CANTREGISTERCLASS = " Can't register Class ";
@@ -282,15 +258,13 @@ const char*                         CANTREGISTERCLASS = " Can't register Class "
 // RegisterWindowClasses
 // ---------------------------------------------------------------------------
 
 // RegisterWindowClasses
 // ---------------------------------------------------------------------------
 
-bool wxApp::RegisterWindowClasses(
-  HAB                               vHab
-)
+bool wxApp::RegisterWindowClasses( HAB vHab )
 {
 {
-    ERRORID                         vError = 0L;
-    wxString                        sError;
+    ERRORID vError = 0L;
+    wxString sError;
 
     if (!::WinRegisterClass( vHab
 
     if (!::WinRegisterClass( vHab
-                            ,wxFrameClassName
+                            ,(PSZ)wxFrameClassName
                             ,wxFrameWndProc
                             ,CS_SIZEREDRAW | CS_SYNCPAINT
                             ,sizeof(ULONG)
                             ,wxFrameWndProc
                             ,CS_SIZEREDRAW | CS_SYNCPAINT
                             ,sizeof(ULONG)
@@ -299,11 +273,11 @@ bool wxApp::RegisterWindowClasses(
         vError = ::WinGetLastError(vHab);
         sError = wxPMErrorToStr(vError);
         wxLogLastError(sError.c_str());
         vError = ::WinGetLastError(vHab);
         sError = wxPMErrorToStr(vError);
         wxLogLastError(sError.c_str());
-        return FALSE;
+        return false;
     }
 
     if (!::WinRegisterClass( vHab
     }
 
     if (!::WinRegisterClass( vHab
-                            ,wxFrameClassNameNoRedraw
+                            ,(PSZ)wxFrameClassNameNoRedraw
                             ,wxWndProc
                             ,0
                             ,sizeof(ULONG)
                             ,wxWndProc
                             ,0
                             ,sizeof(ULONG)
@@ -312,11 +286,11 @@ bool wxApp::RegisterWindowClasses(
         vError = ::WinGetLastError(vHab);
         sError = wxPMErrorToStr(vError);
         wxLogLastError(sError.c_str());
         vError = ::WinGetLastError(vHab);
         sError = wxPMErrorToStr(vError);
         wxLogLastError(sError.c_str());
-        return FALSE;
+        return false;
     }
 
     if (!::WinRegisterClass( vHab
     }
 
     if (!::WinRegisterClass( vHab
-                            ,wxMDIFrameClassName
+                            ,(PSZ)wxMDIFrameClassName
                             ,wxWndProc
                             ,CS_SIZEREDRAW | CS_MOVENOTIFY | CS_SYNCPAINT
                             ,sizeof(ULONG)
                             ,wxWndProc
                             ,CS_SIZEREDRAW | CS_MOVENOTIFY | CS_SYNCPAINT
                             ,sizeof(ULONG)
@@ -325,11 +299,11 @@ bool wxApp::RegisterWindowClasses(
         vError = ::WinGetLastError(vHab);
         sError = wxPMErrorToStr(vError);
         wxLogLastError(sError.c_str());
         vError = ::WinGetLastError(vHab);
         sError = wxPMErrorToStr(vError);
         wxLogLastError(sError.c_str());
-        return FALSE;
+        return false;
     }
 
     if (!::WinRegisterClass( vHab
     }
 
     if (!::WinRegisterClass( vHab
-                            ,wxMDIFrameClassNameNoRedraw
+                            ,(PSZ)wxMDIFrameClassNameNoRedraw
                             ,wxWndProc
                             ,0
                             ,sizeof(ULONG)
                             ,wxWndProc
                             ,0
                             ,sizeof(ULONG)
@@ -338,11 +312,11 @@ bool wxApp::RegisterWindowClasses(
         vError = ::WinGetLastError(vHab);
         sError = wxPMErrorToStr(vError);
         wxLogLastError(sError.c_str());
         vError = ::WinGetLastError(vHab);
         sError = wxPMErrorToStr(vError);
         wxLogLastError(sError.c_str());
-        return FALSE;
+        return false;
     }
 
     if (!::WinRegisterClass( vHab
     }
 
     if (!::WinRegisterClass( vHab
-                            ,wxMDIChildFrameClassName
+                            ,(PSZ)wxMDIChildFrameClassName
                             ,wxWndProc
                             ,CS_MOVENOTIFY | CS_SIZEREDRAW | CS_SYNCPAINT | CS_HITTEST
                             ,sizeof(ULONG)
                             ,wxWndProc
                             ,CS_MOVENOTIFY | CS_SIZEREDRAW | CS_SYNCPAINT | CS_HITTEST
                             ,sizeof(ULONG)
@@ -351,11 +325,11 @@ bool wxApp::RegisterWindowClasses(
         vError = ::WinGetLastError(vHab);
         sError = wxPMErrorToStr(vError);
         wxLogLastError(sError.c_str());
         vError = ::WinGetLastError(vHab);
         sError = wxPMErrorToStr(vError);
         wxLogLastError(sError.c_str());
-        return FALSE;
+        return false;
     }
 
     if (!::WinRegisterClass( vHab
     }
 
     if (!::WinRegisterClass( vHab
-                            ,wxMDIChildFrameClassNameNoRedraw
+                            ,(PSZ)wxMDIChildFrameClassNameNoRedraw
                             ,wxWndProc
                             ,CS_HITTEST
                             ,sizeof(ULONG)
                             ,wxWndProc
                             ,CS_HITTEST
                             ,sizeof(ULONG)
@@ -364,11 +338,11 @@ bool wxApp::RegisterWindowClasses(
         vError = ::WinGetLastError(vHab);
         sError = wxPMErrorToStr(vError);
         wxLogLastError(sError.c_str());
         vError = ::WinGetLastError(vHab);
         sError = wxPMErrorToStr(vError);
         wxLogLastError(sError.c_str());
-        return FALSE;
+        return false;
     }
 
     if (!::WinRegisterClass( vHab
     }
 
     if (!::WinRegisterClass( vHab
-                            ,wxPanelClassName
+                            ,(PSZ)wxPanelClassName
                             ,wxWndProc
                             ,CS_MOVENOTIFY | CS_SIZEREDRAW | CS_HITTEST | CS_SAVEBITS | CS_SYNCPAINT
                             ,sizeof(ULONG)
                             ,wxWndProc
                             ,CS_MOVENOTIFY | CS_SIZEREDRAW | CS_HITTEST | CS_SAVEBITS | CS_SYNCPAINT
                             ,sizeof(ULONG)
@@ -377,11 +351,11 @@ bool wxApp::RegisterWindowClasses(
         vError = ::WinGetLastError(vHab);
         sError = wxPMErrorToStr(vError);
         wxLogLastError(sError.c_str());
         vError = ::WinGetLastError(vHab);
         sError = wxPMErrorToStr(vError);
         wxLogLastError(sError.c_str());
-        return FALSE;
+        return false;
     }
 
     if (!::WinRegisterClass( vHab
     }
 
     if (!::WinRegisterClass( vHab
-                            ,wxCanvasClassName
+                            ,(PSZ)wxCanvasClassName
                             ,wxWndProc
                             ,CS_SIZEREDRAW | CS_HITTEST | CS_SYNCPAINT
                             ,sizeof(ULONG)
                             ,wxWndProc
                             ,CS_SIZEREDRAW | CS_HITTEST | CS_SYNCPAINT
                             ,sizeof(ULONG)
@@ -390,10 +364,10 @@ bool wxApp::RegisterWindowClasses(
         vError = ::WinGetLastError(vHab);
         sError = wxPMErrorToStr(vError);
         wxLogLastError(sError.c_str());
         vError = ::WinGetLastError(vHab);
         sError = wxPMErrorToStr(vError);
         wxLogLastError(sError.c_str());
-        return FALSE;
+        return false;
     }
     if (!::WinRegisterClass( vHab
     }
     if (!::WinRegisterClass( vHab
-                            ,wxCanvasClassNameNR
+                            ,(PSZ)wxCanvasClassNameNR
                             ,wxWndProc
                             ,CS_HITTEST | CS_SYNCPAINT
                             ,sizeof(ULONG)
                             ,wxWndProc
                             ,CS_HITTEST | CS_SYNCPAINT
                             ,sizeof(ULONG)
@@ -402,13 +376,13 @@ bool wxApp::RegisterWindowClasses(
         vError = ::WinGetLastError(vHab);
         sError = wxPMErrorToStr(vError);
         wxLogLastError(sError.c_str());
         vError = ::WinGetLastError(vHab);
         sError = wxPMErrorToStr(vError);
         wxLogLastError(sError.c_str());
-        return FALSE;
+        return false;
     }
     }
-    return TRUE;
+    return true;
 } // end of wxApp::RegisterWindowClasses
 
 //
 } // end of wxApp::RegisterWindowClasses
 
 //
-// Cleans up any wxWindows internal structures left lying around
+// Cleans up any wxWidgets internal structures left lying around
 //
 void wxApp::CleanUp()
 {
 //
 void wxApp::CleanUp()
 {
@@ -419,7 +393,7 @@ void wxApp::CleanUp()
     // PM-SPECIFIC CLEANUP
     //
 
     // PM-SPECIFIC CLEANUP
     //
 
-    // wxSetKeyboardHook(FALSE);
+    // wxSetKeyboardHook(false);
 
     if (wxSTD_FRAME_ICON)
         ::WinFreeFileIcon(wxSTD_FRAME_ICON);
 
     if (wxSTD_FRAME_ICON)
         ::WinFreeFileIcon(wxSTD_FRAME_ICON);
@@ -440,8 +414,8 @@ void wxApp::CleanUp()
 // TODO:        ::DeleteObject( wxDisableButtonBrush );
     }
 
 // TODO:        ::DeleteObject( wxDisableButtonBrush );
     }
 
-    if (wxWinHandleList)
-        delete wxWinHandleList;
+    delete wxWinHandleHash;
+    wxWinHandleHash = NULL;
 
     // Delete Message queue
     if (wxTheApp->m_hMq)
 
     // Delete Message queue
     if (wxTheApp->m_hMq)
@@ -452,11 +426,11 @@ void wxApp::CleanUp()
 
 bool wxApp::OnInitGui()
 {
 
 bool wxApp::OnInitGui()
 {
-    ERRORID                         vError;
-    wxString                        sError;
+    ERRORID vError;
+    wxString sError;
 
     if (!wxAppBase::OnInitGui())
 
     if (!wxAppBase::OnInitGui())
-        return FALSE;
+        return false;
 
     m_hMq = ::WinCreateMsgQueue(vHabmain, 0);
     if (!m_hMq)
 
     m_hMq = ::WinCreateMsgQueue(vHabmain, 0);
     if (!m_hMq)
@@ -464,16 +438,14 @@ bool wxApp::OnInitGui()
         vError = ::WinGetLastError(vHabmain);
         sError = wxPMErrorToStr(vError);
         wxLogDebug(sError);
         vError = ::WinGetLastError(vHabmain);
         sError = wxPMErrorToStr(vError);
         wxLogDebug(sError);
-        return FALSE;
+        return false;
     }
 
     }
 
-    return TRUE;
+    return true;
 } // end of wxApp::OnInitGui
 
 wxApp::wxApp()
 {
 } // end of wxApp::OnInitGui
 
 wxApp::wxApp()
 {
-    argc = 0;
-    argv = NULL;
     m_nPrintMode = wxPRINT_WINDOWS;
     m_hMq = 0;
     m_maxSocketHandles = 0;
     m_nPrintMode = wxPRINT_WINDOWS;
     m_hMq = 0;
     m_maxSocketHandles = 0;
@@ -483,36 +455,19 @@ wxApp::wxApp()
 
 wxApp::~wxApp()
 {
 
 wxApp::~wxApp()
 {
-    //
-    // Delete command-line args
-    //
-#if wxUSE_UNICODE
-    int                             i;
-
-    for (i = 0; i < argc; i++)
-    {
-        delete[] argv[i];
-    }
-    delete[] argv;
-#endif
 } // end of wxApp::~wxApp
 
 } // end of wxApp::~wxApp
 
-bool                                gbInOnIdle = FALSE;
+bool gbInOnIdle = false;
 
 
-void wxApp::OnIdle(
-  wxIdleEvent&                      rEvent
-)
+void wxApp::OnIdle( wxIdleEvent& WXUNUSED(rEvent) )
 {
 {
-
     //
     // Avoid recursion (via ProcessEvent default case)
     //
     if (gbInOnIdle)
         return;
 
     //
     // Avoid recursion (via ProcessEvent default case)
     //
     if (gbInOnIdle)
         return;
 
-    gbInOnIdle = TRUE;
-    
-    wxAppBase::OnIdle(rEvent);
+    gbInOnIdle = true;
 
 #if wxUSE_DC_CACHEING
     // automated DC cache management: clear the cached DCs and bitmap
 
 #if wxUSE_DC_CACHEING
     // automated DC cache management: clear the cached DCs and bitmap
@@ -524,86 +479,29 @@ void wxApp::OnIdle(
         wxDC::ClearCache();
 #endif // wxUSE_DC_CACHEING
 
         wxDC::ClearCache();
 #endif // wxUSE_DC_CACHEING
 
-    gbInOnIdle = FALSE;
+    gbInOnIdle = false;
 } // end of wxApp::OnIdle
 
 void wxApp::OnEndSession(
   wxCloseEvent&                     WXUNUSED(rEvent))
 {
     if (GetTopWindow())
 } // end of wxApp::OnIdle
 
 void wxApp::OnEndSession(
   wxCloseEvent&                     WXUNUSED(rEvent))
 {
     if (GetTopWindow())
-        GetTopWindow()->Close(TRUE);
+        GetTopWindow()->Close(true);
 } // end of wxApp::OnEndSession
 
 //
 // Default behaviour: close the application with prompts. The
 // user can veto the close, and therefore the end session.
 //
 } // end of wxApp::OnEndSession
 
 //
 // Default behaviour: close the application with prompts. The
 // user can veto the close, and therefore the end session.
 //
-void wxApp::OnQueryEndSession(
-  wxCloseEvent&                     rEvent
-)
+void wxApp::OnQueryEndSession( wxCloseEvent& rEvent )
 {
     if (GetTopWindow())
     {
         if (!GetTopWindow()->Close(!rEvent.CanVeto()))
 {
     if (GetTopWindow())
     {
         if (!GetTopWindow()->Close(!rEvent.CanVeto()))
-            rEvent.Veto(TRUE);
+            rEvent.Veto(true);
     }
 } // end of wxApp::OnQueryEndSession
 
     }
 } // end of wxApp::OnQueryEndSession
 
-//
-// Yield to incoming messages
-//
-bool wxApp::Yield(bool onlyIfNeeded)
-{
-    static bool s_inYield = FALSE;
-
-    if ( s_inYield )
-    {
-        if ( !onlyIfNeeded )
-        {
-            wxFAIL_MSG( _T("wxYield() called recursively") );
-        }
-
-        return FALSE;
-    }
-
-    HAB                             vHab = 0;
-    QMSG                            vMsg;
-
-    //
-    // Disable log flushing from here because a call to wxYield() shouldn't
-    // normally result in message boxes popping up &c
-    //
-    wxLog::Suspend();
-
-    s_inYield = TRUE;
-
-    //
-    // We want to go back to the main message loop
-    // if we see a WM_QUIT. (?)
-    //
-    while (::WinPeekMsg(vHab, &vMsg, (HWND)NULL, 0, 0, PM_NOREMOVE) && vMsg.msg != WM_QUIT)
-    {
-#if wxUSE_THREADS
-        wxMutexGuiLeaveOrEnter();
-#endif // wxUSE_THREADS
-        if (!wxTheApp->Dispatch())
-            break;
-    }
-    //
-    // If they are pending events, we must process them.
-    //
-    if (wxTheApp)
-        wxTheApp->ProcessPendingEvents();
-
-    HandleSockets();
-    //
-    // Let the logs be flashed again
-    //
-    wxLog::Resume();
-    s_inYield = FALSE;
-    return TRUE;
-} // end of wxYield
-
 int wxApp::AddSocketHandler(int handle, int mask,
                             void (*callback)(void*), void * gsock)
 {
 int wxApp::AddSocketHandler(int handle, int mask,
                             void (*callback)(void*), void * gsock)
 {
@@ -673,7 +571,7 @@ void wxApp::WakeUpIdle()
             //
             // Should never happen
             //
             //
             // Should never happen
             //
-            wxLogLastError("PostMessage(WM_NULL)");
+            wxLogLastError(wxT("PostMessage(WM_NULL)"));
         }
     }
 } // end of wxWakeUpIdle
         }
     }
 } // end of wxWakeUpIdle
@@ -683,10 +581,7 @@ HAB wxGetInstance()
     return vHabmain;
 }
 
     return vHabmain;
 }
 
-void wxSetInstance(
-  HAB                               vHab
-)
+void wxSetInstance( HAB vHab )
 {
     vHabmain = vHab;
 }
 {
     vHabmain = vHab;
 }
-