⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 window.cpp

📁 很牛的GUI源码wxWidgets-2.8.0.zip 可在多种平台下运行.
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    if ( m_peer->NeedsFocusRect() && m_peer->HasFocus() )        outerBorder += 4 ;    if ( outerBorder == 0 )        return ;    // now we know that we have something to do at all    // as the borders are drawn on the parent we have to properly invalidate all these areas    RgnHandle updateInner , updateOuter;    Rect rect ;    // this rectangle is in HIViewCoordinates under OSX and in Window Coordinates under Carbon    updateInner = NewRgn() ;    updateOuter = NewRgn() ;    m_peer->GetRect( &rect ) ;    RectRgn( updateInner, &rect ) ;    InsetRect( &rect , -outerBorder , -outerBorder ) ;    RectRgn( updateOuter, &rect ) ;    DiffRgn( updateOuter, updateInner , updateOuter ) ;#ifdef __WXMAC_OSX__    GetParent()->m_peer->SetNeedsDisplay( updateOuter ) ;#else    WindowRef tlw = (WindowRef) MacGetTopLevelWindowRef() ;    if ( tlw )        InvalWindowRgn( tlw , updateOuter ) ;#endif    DisposeRgn( updateOuter ) ;    DisposeRgn( updateInner ) ;}void wxWindowMac::DoMoveWindow(int x, int y, int width, int height){    // this is never called for a toplevel window, so we know we have a parent    int former_x , former_y , former_w, former_h ;    // Get true coordinates of former position    DoGetPosition( &former_x , &former_y ) ;    DoGetSize( &former_w , &former_h ) ;    wxWindow *parent = GetParent();    if ( parent )    {        wxPoint pt(parent->GetClientAreaOrigin());        former_x += pt.x ;        former_y += pt.y ;    }    int actualWidth = width ;    int actualHeight = height ;    int actualX = x;    int actualY = y;    if ((m_minWidth != -1) && (actualWidth < m_minWidth))        actualWidth = m_minWidth;    if ((m_minHeight != -1) && (actualHeight < m_minHeight))        actualHeight = m_minHeight;    if ((m_maxWidth != -1) && (actualWidth > m_maxWidth))        actualWidth = m_maxWidth;    if ((m_maxHeight != -1) && (actualHeight > m_maxHeight))        actualHeight = m_maxHeight;    bool doMove = false, doResize = false ;    if ( actualX != former_x || actualY != former_y )        doMove = true ;    if ( actualWidth != former_w || actualHeight != former_h )        doResize = true ;    if ( doMove || doResize )    {        // as the borders are drawn outside the native control, we adjust now        wxRect bounds( wxPoint( actualX + MacGetLeftBorderSize() ,actualY + MacGetTopBorderSize() ),            wxSize( actualWidth - (MacGetLeftBorderSize() + MacGetRightBorderSize()) ,                actualHeight - (MacGetTopBorderSize() + MacGetBottomBorderSize()) ) ) ;        Rect r ;        wxMacRectToNative( &bounds , &r ) ;        if ( !GetParent()->IsTopLevel() )            wxMacWindowToNative( GetParent() , &r ) ;        MacInvalidateBorders() ;        m_cachedClippedRectValid = false ;        m_peer->SetRect( &r ) ;        wxWindowMac::MacSuperChangedPosition() ; // like this only children will be notified        MacInvalidateBorders() ;        MacRepositionScrollBars() ;        if ( doMove )        {            wxPoint point(actualX, actualY);            wxMoveEvent event(point, m_windowId);            event.SetEventObject(this);            GetEventHandler()->ProcessEvent(event) ;        }        if ( doResize )        {            MacRepositionScrollBars() ;            wxSize size(actualWidth, actualHeight);            wxSizeEvent event(size, m_windowId);            event.SetEventObject(this);            GetEventHandler()->ProcessEvent(event);        }    }}wxSize wxWindowMac::DoGetBestSize() const{    if ( m_macIsUserPane || IsTopLevel() )        return wxWindowBase::DoGetBestSize() ;    Rect    bestsize = { 0 , 0 , 0 , 0 } ;    int bestWidth, bestHeight ;    m_peer->GetBestRect( &bestsize ) ;    if ( EmptyRect( &bestsize ) )    {        bestsize.left =        bestsize.top = 0 ;        bestsize.right =        bestsize.bottom = 16 ;        if ( IsKindOf( CLASSINFO( wxScrollBar ) ) )        {            bestsize.bottom = 16 ;        }#if wxUSE_SPINBTN        else if ( IsKindOf( CLASSINFO( wxSpinButton ) ) )        {            bestsize.bottom = 24 ;        }#endif        else        {            // return wxWindowBase::DoGetBestSize() ;        }    }    bestWidth = bestsize.right - bestsize.left ;    bestHeight = bestsize.bottom - bestsize.top ;    if ( bestHeight < 10 )        bestHeight = 13 ;    return wxSize(bestWidth, bestHeight);}// set the size of the window: if the dimensions are positive, just use them,// but if any of them is equal to -1, it means that we must find the value for// it ourselves (unless sizeFlags contains wxSIZE_ALLOW_MINUS_ONE flag, in// which case -1 is a valid value for x and y)//// If sizeFlags contains wxSIZE_AUTO_WIDTH/HEIGHT flags (default), we calculate// the width/height to best suit our contents, otherwise we reuse the current// width/heightvoid wxWindowMac::DoSetSize(int x, int y, int width, int height, int sizeFlags){    // get the current size and position...    int currentX, currentY;    int currentW, currentH;    GetPosition(&currentX, &currentY);    GetSize(&currentW, &currentH);    // ... and don't do anything (avoiding flicker) if it's already ok    if ( x == currentX && y == currentY &&        width == currentW && height == currentH && ( height != -1 && width != -1 ) )    {        // TODO: REMOVE        MacRepositionScrollBars() ; // we might have a real position shift        return;    }    if ( !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) )    {        if ( x == wxDefaultCoord )            x = currentX;        if ( y == wxDefaultCoord )            y = currentY;    }    AdjustForParentClientOrigin( x, y, sizeFlags );    wxSize size = wxDefaultSize;    if ( width == wxDefaultCoord )    {        if ( sizeFlags & wxSIZE_AUTO_WIDTH )        {            size = DoGetBestSize();            width = size.x;        }        else        {            // just take the current one            width = currentW;        }    }    if ( height == wxDefaultCoord )    {        if ( sizeFlags & wxSIZE_AUTO_HEIGHT )        {            if ( size.x == wxDefaultCoord )                size = DoGetBestSize();            // else: already called DoGetBestSize() above            height = size.y;        }        else        {            // just take the current one            height = currentH;        }    }    DoMoveWindow( x, y, width, height );}wxPoint wxWindowMac::GetClientAreaOrigin() const{    RgnHandle rgn = NewRgn() ;    Rect content ;    if ( m_peer->GetRegion( kControlContentMetaPart , rgn ) == noErr )    {        GetRegionBounds( rgn , &content ) ;    }    else    {        content.left =        content.top = 0 ;    }    DisposeRgn( rgn ) ;    return wxPoint( content.left + MacGetLeftBorderSize() , content.top + MacGetTopBorderSize() );}void wxWindowMac::DoSetClientSize(int clientwidth, int clientheight){    if ( clientwidth != wxDefaultCoord || clientheight != wxDefaultCoord )    {        int currentclientwidth , currentclientheight ;        int currentwidth , currentheight ;        GetClientSize( &currentclientwidth , &currentclientheight ) ;        GetSize( &currentwidth , &currentheight ) ;        DoSetSize( wxDefaultCoord , wxDefaultCoord , currentwidth + clientwidth - currentclientwidth ,            currentheight + clientheight - currentclientheight , wxSIZE_USE_EXISTING ) ;    }}void wxWindowMac::SetLabel(const wxString& title){    m_label = wxStripMenuCodes(title, wxStrip_Mnemonics) ;    if ( m_peer && m_peer->Ok() )        m_peer->SetLabel( m_label ) ;    Refresh() ;}wxString wxWindowMac::GetLabel() const{    return m_label ;}bool wxWindowMac::Show(bool show){    bool former = MacIsReallyShown() ;    if ( !wxWindowBase::Show(show) )        return false;    // TODO: use visibilityChanged Carbon Event for OSX    if ( m_peer )        m_peer->SetVisibility( show , true ) ;    if ( former != MacIsReallyShown() )        MacPropagateVisibilityChanged() ;    return true;}bool wxWindowMac::Enable(bool enable){    wxASSERT( m_peer->Ok() ) ;    bool former = MacIsReallyEnabled() ;    if ( !wxWindowBase::Enable(enable) )        return false;    m_peer->Enable( enable ) ;    if ( former != MacIsReallyEnabled() )        MacPropagateEnabledStateChanged() ;    return true;}//// status change propagations (will be not necessary for OSX later )//void wxWindowMac::MacPropagateVisibilityChanged(){#if !TARGET_API_MAC_OSX    MacVisibilityChanged() ;    wxWindowMac *child;    wxWindowList::compatibility_iterator node = GetChildren().GetFirst();    while ( node )    {        child = node->GetData();        if ( child->IsShown() )            child->MacPropagateVisibilityChanged() ;        node = node->GetNext();    }#endif}void wxWindowMac::MacPropagateEnabledStateChanged(){#if !TARGET_API_MAC_OSX    MacEnabledStateChanged() ;    wxWindowMac *child;    wxWindowList::compatibility_iterator node = GetChildren().GetFirst();    while ( node )    {        child = node->GetData();        if ( child->IsEnabled() )            child->MacPropagateEnabledStateChanged() ;        node = node->GetNext();    }#endif}void wxWindowMac::MacPropagateHiliteChanged(){#if !TARGET_API_MAC_OSX    MacHiliteChanged() ;    wxWindowMac *child;    wxWindowList::compatibility_iterator node = GetChildren().GetFirst();    while ( node )    {        child = node->GetData();        if (child /* && child->IsEnabled() */)            child->MacPropagateHiliteChanged() ;        node = node->GetNext();    }#endif}//// status change notifications//void wxWindowMac::MacVisibilityChanged(){}void wxWindowMac::MacHiliteChanged(){}void wxWindowMac::MacEnabledStateChanged(){}//// status queries on the inherited window's state//bool wxWindowMac::MacIsReallyShown(){    // only under OSX the visibility of the TLW is taken into account    if ( m_isBeingDeleted )        return false ;#if TARGET_API_MAC_OSX    if ( m_peer && m_peer->Ok() )        return m_peer->IsVisible();#endif    wxWindow* win = this ;    while ( win->IsShown() )    {        if ( win->IsTopLevel() )            return true ;        win = win->GetParent() ;        if ( win == NULL )            return true ;    }    return false ;}bool wxWindowMac::MacIsReallyEnabled(){    return m_peer->IsEnabled() ;}bool wxWindowMac::MacIsReallyHilited(){    return m_peer->IsActive();}void wxWindowMac::MacFlashInvalidAreas(){#if TARGET_API_MAC_OSX    HIViewFlashDirtyArea( (WindowRef) MacGetTopLevelWindowRef() ) ;#endif}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 wxStr

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -