+ m_label = title ;
+
+ wxString label ;
+
+ if( wxApp::s_macDefaultEncodingIsPC )
+ label = wxMacMakeMacStringFromPC( title ) ;
+ else
+ label = title ;
+
+ if ( m_macWindowData )
+ UMASetWTitleC( m_macWindowData->m_macWindow , label ) ;
+}
+
+wxString wxWindowMac::GetTitle() const
+{
+ return m_label ;
+}
+
+bool wxWindowMac::Show(bool show)
+{
+ if ( !wxWindowBase::Show(show) )
+ return FALSE;
+
+ if ( m_macWindowData )
+ {
+ if (show)
+ {
+ ::ShowWindow( m_macWindowData->m_macWindow ) ;
+ ::SelectWindow( m_macWindowData->m_macWindow ) ;
+ // no need to generate events here, they will get them triggered by macos
+ // actually they should be , but apparently they are not
+ wxSize size(m_width, m_height);
+ wxSizeEvent event(size, m_windowId);
+ event.SetEventObject(this);
+ GetEventHandler()->ProcessEvent(event);
+ }
+ else
+ {
+ ::HideWindow( m_macWindowData->m_macWindow ) ;
+ }
+ }
+ MacSuperShown( show ) ;
+ if ( !show )
+ {
+ WindowRef window = GetMacRootWindow() ;
+ wxWindowMac* win = wxFindWinFromMacWindow( window ) ;
+ if ( win && !win->m_isBeingDeleted )
+ Refresh() ;
+ }
+ else
+ {
+ Refresh() ;
+ }
+
+ return TRUE;
+}
+
+void wxWindowMac::MacSuperShown( bool show )
+{
+ wxNode *node = GetChildren().First();
+ while ( node )
+ {
+ wxWindowMac *child = (wxWindowMac *)node->Data();
+ if ( child->m_isShown )
+ child->MacSuperShown( show ) ;
+ node = node->Next();
+ }
+}
+
+bool wxWindowMac::MacIsReallyShown() const
+{
+ if ( m_isShown && (m_parent != NULL) ) {
+ return m_parent->MacIsReallyShown();
+ }
+ return m_isShown;
+/*
+ bool status = m_isShown ;
+ wxWindowMac * win = this ;
+ while ( status && win->m_parent != NULL )
+ {
+ win = win->m_parent ;
+ status = win->m_isShown ;
+ }
+ return status ;
+*/
+}
+
+int wxWindowMac::GetCharHeight() const
+{
+ wxClientDC dc ( (wxWindowMac*)this ) ;
+ return dc.GetCharHeight() ;
+}
+
+int wxWindowMac::GetCharWidth() const
+{
+ wxClientDC dc ( (wxWindowMac*)this ) ;
+ return dc.GetCharWidth() ;
+}
+
+void wxWindowMac::GetTextExtent(const wxString& string, int *x, int *y,
+ int *descent, int *externalLeading, const wxFont *theFont ) const
+{
+ const wxFont *fontToUse = theFont;
+ if ( !fontToUse )
+ fontToUse = &m_font;
+
+ wxClientDC dc( (wxWindowMac*) this ) ;
+ long lx,ly,ld,le ;
+ dc.GetTextExtent( string , &lx , &ly , &ld, &le, (wxFont *)fontToUse ) ;
+ if ( externalLeading )
+ *externalLeading = le ;
+ if ( descent )
+ *descent = ld ;
+ if ( x )
+ *x = lx ;
+ if ( y )
+ *y = ly ;
+}
+
+void wxWindowMac::MacEraseBackground( Rect *rect )
+{
+/*
+ WindowRef window = GetMacRootWindow() ;
+ if ( m_backgroundColour == wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE) )
+ {
+ UMASetThemeWindowBackground( window , kThemeBrushDocumentWindowBackground , false ) ;
+ }
+ else if ( m_backgroundColour == wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE ) )
+ {
+ // on mac we have the difficult situation, that 3dface gray can be different colours, depending whether
+ // it is on a notebook panel or not, in order to take care of that we walk up the hierarchy until we have
+ // either a non gray background color or a non control window
+
+ wxWindowMac* parent = GetParent() ;
+ while( parent )
+ {
+ if ( parent->m_backgroundColour != wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE ) )
+ {
+ // if we have any other colours in the hierarchy
+ RGBBackColor( &parent->m_backgroundColour.GetPixel()) ;
+ break ;
+ }
+ if( parent->IsKindOf( CLASSINFO( wxControl ) ) && ((wxControl*)parent)->GetMacControl() )
+ {
+ // if we have the normal colours in the hierarchy but another control etc. -> use it's background
+ if ( parent->IsKindOf( CLASSINFO( wxNotebook ) ) || parent->IsKindOf( CLASSINFO( wxTabCtrl ) ))
+ {
+ UMAApplyThemeBackground(kThemeBackgroundTabPane, rect, kThemeStateActive,8,true);
+ break ;
+ }
+ }
+ else
+ {
+ // we have arrived at a non control item
+ parent = NULL ;
+ break ;
+ }
+ parent = parent->GetParent() ;
+ }
+ if ( !parent )
+ {
+ // if there is nothing special -> use default
+ UMASetThemeWindowBackground( window , kThemeBrushDialogBackgroundActive , false ) ;
+ }
+ }
+ else
+ {
+ RGBBackColor( &m_backgroundColour.GetPixel()) ;
+ }
+
+ EraseRect( rect ) ;
+
+ for (wxNode *node = GetChildren().First(); node; node = node->Next())
+ {
+ wxWindowMac *child = (wxWindowMac*)node->Data();
+
+ Rect clientrect = { child->m_x , child->m_y , child->m_x +child->m_width , child->m_y + child->m_height } ;
+ SectRect( &clientrect , rect , &clientrect ) ;
+
+ OffsetRect( &clientrect , -child->m_x , -child->m_y ) ;
+ if ( child->GetMacRootWindow() == window && child->IsShown() )
+ {
+ wxMacDrawingClientHelper focus( this ) ;
+ if ( focus.Ok() )
+ {
+ child->MacEraseBackground( &clientrect ) ;
+ }
+ }
+ }
+*/
+}
+
+void wxWindowMac::Refresh(bool eraseBack, const wxRect *rect)
+{
+// if ( !IsShown() )
+// return ;
+
+ wxMacDrawingClientHelper focus( this ) ;
+ if ( focus.Ok() )
+ {
+ wxPoint client ;
+ client = GetClientAreaOrigin( ) ;
+ Rect clientrect = { -client.y , -client.x , m_height - client.y , m_width - client.x} ;
+ // ClipRect( &clientrect ) ;
+
+ if ( rect )
+ {
+ Rect r = { rect->y , rect->x , rect->y + rect->height , rect->x + rect->width } ;
+ SectRect( &clientrect , &r , &clientrect ) ;
+ }
+ InvalWindowRect( GetMacRootWindow() , &clientrect ) ;
+ }
+ if ( !eraseBack )
+ m_macEraseOnRedraw = false ;
+ else
+ m_macEraseOnRedraw = true ;
+}
+
+// Responds to colour changes: passes event on to children.
+void wxWindowMac::OnSysColourChanged(wxSysColourChangedEvent& event)
+{
+ wxNode *node = GetChildren().First();
+ while ( node )
+ {
+ // Only propagate to non-top-level windows
+ wxWindowMac *win = (wxWindowMac *)node->Data();
+ if ( win->GetParent() )
+ {
+ wxSysColourChangedEvent event2;
+ event.m_eventObject = win;
+ win->GetEventHandler()->ProcessEvent(event2);
+ }
+
+ node = node->Next();
+ }
+}
+
+#if wxUSE_CARET && WXWIN_COMPATIBILITY
+// ---------------------------------------------------------------------------
+// Caret manipulation
+// ---------------------------------------------------------------------------
+
+void wxWindowMac::CreateCaret(int w, int h)
+{
+ SetCaret(new wxCaret(this, w, h));
+}
+
+void wxWindowMac::CreateCaret(const wxBitmap *WXUNUSED(bitmap))
+{
+ wxFAIL_MSG("not implemented");
+}
+
+void wxWindowMac::ShowCaret(bool show)
+{
+ wxCHECK_RET( m_caret, "no caret to show" );
+
+ m_caret->Show(show);
+}
+
+void wxWindowMac::DestroyCaret()
+{
+ SetCaret(NULL);
+}
+
+void wxWindowMac::SetCaretPos(int x, int y)
+{
+ wxCHECK_RET( m_caret, "no caret to move" );
+
+ m_caret->Move(x, y);
+}
+
+void wxWindowMac::GetCaretPos(int *x, int *y) const
+{
+ wxCHECK_RET( m_caret, "no caret to get position of" );
+
+ m_caret->GetPosition(x, y);
+}
+#endif // wxUSE_CARET
+
+wxWindowMac *wxGetActiveWindow()
+{
+ // actually this is a windows-only concept
+ return NULL;
+}
+
+// Coordinates relative to the window
+void wxWindowMac::WarpPointer (int x_pos, int y_pos)
+{
+ // We really dont move the mouse programmatically under mac
+}
+
+void wxWindowMac::OnEraseBackground(wxEraseEvent& event)
+{
+ // TODO : probably we would adopt the EraseEvent structure
+}
+
+int wxWindowMac::GetScrollPos(int orient) const
+{
+ if ( orient == wxHORIZONTAL )
+ {
+ if ( m_hScrollBar )
+ return m_hScrollBar->GetThumbPosition() ;
+ }
+ else
+ {
+ if ( m_vScrollBar )
+ return m_vScrollBar->GetThumbPosition() ;
+ }