Exemple #1
0
wxStatusBar* wxFrame::OnCreateStatusBar(
  int                               nNumber
, long                              lulStyle
, wxWindowID                        vId
, const wxString&                   rName
)
{
    wxStatusBar*                    pStatusBar = NULL;
    wxString                        sError;

    pStatusBar = wxFrameBase::OnCreateStatusBar( nNumber
                                                ,lulStyle
                                                ,vId
                                                ,rName
                                                 );

    if( !pStatusBar )
        return NULL;

    wxClientDC                      vDC(pStatusBar);
    int                             nY;

    //
    // Set the height according to the font and the border size
    //
    vDC.SetFont(pStatusBar->GetFont()); // Screws up the menues for some reason
    vDC.GetTextExtent( wxT("X")
                      ,NULL
                      ,&nY
                     );

    int                             nHeight = ((11 * nY) / 10 + 2 * pStatusBar->GetBorderY());

    pStatusBar->SetSize( wxDefaultCoord
                        ,wxDefaultCoord
                        ,wxDefaultCoord
                        ,nHeight
                       );

    ::WinSetParent( pStatusBar->GetHWND(), m_hFrame, FALSE );
    ::WinSetOwner( pStatusBar->GetHWND(), m_hFrame);
    //
    // to show statusbar
    //
    if(::WinIsWindowShowing(m_hFrame))
        ::WinSendMsg(m_hFrame, WM_UPDATEFRAME, (MPARAM)~0, 0);

    return pStatusBar;
} // end of wxFrame::OnCreateStatusBar
bool wxToolBar::Create( wxWindow* pParent,
                        wxWindowID vId,
                        const wxPoint& rPos,
                        const wxSize& rSize,
                        long lStyle,
                        const wxString& rsName )
{
    if ( !wxWindow::Create( pParent
                           ,vId
                           ,rPos
                           ,rSize
                           ,lStyle
                           ,rsName
                          ))
        return false;

    // Set it to grey (or other 3D face colour)
    SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_MENUBAR));
    SetFont(*wxSMALL_FONT);

    if (GetWindowStyleFlag() & (wxTB_LEFT | wxTB_RIGHT))
    {
        m_vLastX = 7;
        m_vLastY = 3;

        m_maxRows = 32000;      // a lot
        m_maxCols = 1;
    }
    else
    {
        m_vLastX = 3;
        m_vLastY = 7;

        m_maxRows = 1;
        m_maxCols = 32000;      // a lot
    }
    SetCursor(*wxSTANDARD_CURSOR);

    //
    // The toolbar's tools, if they have labels and the winTB_TEXT
    // style is set, then we need to take into account the size of
    // the text when drawing tool bitmaps and the text
    //
    if (HasFlag(wxTB_TEXT))
    {
        wxClientDC                  vDC(this);

        vDC.SetFont(GetFont());
        vDC.GetTextExtent( wxT("XXXX")
                          ,&m_vTextX
                          ,&m_vTextY
                         );
    }

    //
    // Position it
    //
    int                             nX      = rPos.x;
    int                             nY      = rPos.y;
    int                             nWidth  = rSize.x;
    int                             nHeight = rSize.y;

    if (lStyle & (wxTB_TOP | wxTB_BOTTOM))
    {
        if (nWidth <= 0)
        {
            nWidth = pParent->GetClientSize().x;
        }
        if (nHeight <= 0)
        {
            if (lStyle & wxTB_TEXT)
                nHeight = m_defaultHeight + m_vTextY;
            else
                nHeight = m_defaultHeight;
        }
    }
    else
    {
        if (nHeight <= 0)
        {
            nHeight = pParent->GetClientSize().y;
        }
        if (nWidth <= 0)
        {
            if (lStyle & wxTB_TEXT)
                nWidth = m_vTextX + (int)(m_vTextX/2); // a little margin
            else
                nWidth = m_defaultWidth + (int)(m_defaultWidth/2); // a little margin
        }
    }
    if (nX < 0)
        nX = 0;
    if (nY < 0)
        nY = 0;

    SetSize( nX
            ,nY
            ,nWidth
            ,nHeight
           );
    return true;
} // end of wxToolBar::Create
void wxToolBar::RaiseTool ( wxToolBarToolBase* pToolBase,
                            bool bRaise )
{
    wxToolBarTool* pTool = (wxToolBarTool*)pToolBase;
    wxCoord vX;
    wxCoord vY;
    wxCoord vWidth;
    wxCoord vHeight;
    wxColour gray85( 85,85,85 );
    wxPen vDarkGreyPen( gray85, 1, wxSOLID );
    wxPen vClearPen( GetBackgroundColour(), 1, wxSOLID );
    wxClientDC vDC(this);

    if (!pTool)
        return;

    if (pTool->IsSeparator())
        return;

    if (!pTool->IsEnabled())
        return;

    //
    // We only do this for flat toolbars
    //
    if (!HasFlag(wxTB_FLAT))
        return;

    if (HasFlag(wxTB_TEXT) && !pTool->GetLabel().empty())
    {
        if (pTool->GetWidth() > m_vTextX)
        {
            vX = pTool->m_vX - 2;
            vWidth = pTool->GetWidth() + 4;
        }
        else
        {
            vX = pTool->m_vX - (wxCoord)(pTool->GetWidth()/2);
            vWidth = m_vTextX + 4;
        }
        vY = pTool->m_vY - 2;
        vHeight = pTool->GetHeight() + m_vTextY + 2;
    }
    else
    {
        vX = pTool->m_vX - 2;
        vY = pTool->m_vY - 2;
        vWidth = pTool->GetWidth() + 4;
        vHeight = pTool->GetHeight() + 4;
    }
    if (bRaise)
    {
        vDC.SetPen(vDarkGreyPen);
        vDC.DrawLine(vX + vWidth, vY + vHeight, vX, vY + vHeight);
        vDC.DrawLine(vX + vWidth, vY, vX + vWidth, vY + vHeight);
        vDC.SetPen(*wxWHITE_PEN);
        vDC.DrawLine(vX, vY, vX + vWidth, vY);
        vDC.DrawLine(vX, vY + vHeight, vX, vY);
    }
    else
    {
        vDC.SetPen(vClearPen);
        vDC.DrawLine(vX + vWidth, vY + vHeight, vX, vY + vHeight);
        vDC.DrawLine(vX + vWidth, vY, vX + vWidth, vY + vHeight);
        vDC.DrawLine(vX, vY, vX + vWidth, vY);
        vDC.DrawLine(vX, vY + vHeight, vX, vY);
    }
} // end of wxToolBar::RaiseTool
Exemple #4
0
//
// Same as AddPage() but does it at given position
//
bool wxNotebook::InsertPage ( size_t          nPage,
                              wxNotebookPage* pPage,
                              const wxString& rsStrText,
                              bool            bSelect,
                              int             nImageId )
{
    ULONG                           ulApiPage;

    wxASSERT( pPage != NULL );
    wxCHECK( IS_VALID_PAGE(nPage) || nPage == GetPageCount(), false );

    //
    // Under OS/2 we can only insert FIRST, LAST, NEXT or PREV.  Requires
    // two different calls to the API.  Page 1 uses the BKA_FIRST.  Subsequent
    // pages use the previous page ID coupled with a BKA_NEXT call.  Unlike
    // Windows, OS/2 uses an internal Page ID to ID the pages.
    //
    // OS/2 also has a nice auto-size feature that automatically sizes the
    // the attached window so we don't have to worry about the size of the
    // window on the page.
    //
    if (nPage == 0)
    {
        ulApiPage = LONGFROMMR(::WinSendMsg( GetHWND()
                                            ,BKM_INSERTPAGE
                                            ,(MPARAM)0
                                            ,MPFROM2SHORT(BKA_AUTOPAGESIZE | BKA_MAJOR, BKA_FIRST)
                                           ));
        if (ulApiPage == 0L)
        {
            ERRORID                 vError;
            wxString                sError;

            vError = ::WinGetLastError(vHabmain);
            sError = wxPMErrorToStr(vError);
            return false;
        }
        m_alPageId.Insert((long)ulApiPage, nPage);
    }
    else
    {
        ulApiPage = LONGFROMMR(::WinSendMsg( GetHWND()
                                            ,BKM_INSERTPAGE
                                            ,MPFROMLONG((ULONG)m_alPageId[nPage - 1])
                                            ,MPFROM2SHORT(BKA_AUTOPAGESIZE | BKA_MAJOR, BKA_NEXT)
                                           ));
        if (ulApiPage == 0L)
        {
            ERRORID                     vError;
            wxString                    sError;

            vError = ::WinGetLastError(vHabmain);
            sError = wxPMErrorToStr(vError);
            return false;
        }
        m_alPageId.Insert((long)ulApiPage, nPage);
    }

    //
    // Associate a window handle with the page
    //
    if (pPage)
    {
        if (!::WinSendMsg( GetHWND()
                          ,BKM_SETPAGEWINDOWHWND
                          ,MPFROMLONG((ULONG)m_alPageId[nPage])
                          ,MPFROMHWND(pPage->GetHWND())
                         ))
            return false;
    }
    //
    // If the inserted page is before the selected one, we must update the
    // index of the selected page
    //
    if (nPage <= (size_t)m_nSelection)
    {
        //
        // One extra page added
        //
        m_nSelection++;
    }

    if (pPage)
    {
        //
        // Save the pointer to the page
        //
        m_pages.Insert( pPage
                       ,nPage
                      );
    }

    //
    // Now set TAB dimenstions
    //

    wxWindowDC vDC(this);
    wxCoord    nTextX;
    wxCoord    nTextY;

    vDC.GetTextExtent(rsStrText, &nTextX, &nTextY);
    nTextY *= 2;
    nTextX  = (wxCoord)(nTextX * 1.3);
    if (nTextX > m_nTabSize)
    {
        m_nTabSize = nTextX;
        ::WinSendMsg( GetHWND()
                     ,BKM_SETDIMENSIONS
                     ,MPFROM2SHORT((USHORT)m_nTabSize, (USHORT)nTextY)
                     ,(MPARAM)BKA_MAJORTAB
                    );
    }
    //
    // Now set any TAB text
    //
    if (!rsStrText.empty())
    {
        if (!SetPageText( nPage
                         ,rsStrText
                        ))
            return false;
    }

    //
    // Now set any TAB bitmap image
    //
    if (nImageId != -1)
    {
        if (!SetPageImage( nPage
                          ,nImageId
                         ))
            return false;
    }

    if (pPage)
    {
        //
        // Don't show pages by default (we'll need to adjust their size first)
        //
        HWND hWnd = GetWinHwnd(pPage);

        WinSetWindowULong( hWnd
                          ,QWL_STYLE
                          ,WinQueryWindowULong( hWnd
                                               ,QWL_STYLE
                                              ) & ~WS_VISIBLE
                         );

        //
        // This updates internal flag too - otherwise it will get out of sync
        //
        pPage->Show(false);
    }

    //
    // Some page should be selected: either this one or the first one if there is
    // still no selection
    //
    int nSelNew = -1;

    if (bSelect)
        nSelNew = nPage;
    else if ( m_nSelection == -1 )
        nSelNew = 0;

    if (nSelNew != -1)
        SetSelection(nSelNew);

    InvalidateBestSize();

    return true;
} // end of wxNotebook::InsertPage