コード例 #1
0
ファイル: radiobox.cpp プロジェクト: LuaDist/wxwidgets
bool wxRadioBox::Create( wxWindow* pParent,
                         wxWindowID vId,
                         const wxString& rsTitle,
                         const wxPoint& rPos,
                         const wxSize& rSize,
                         int nNum,
                         const wxString asChoices[],
                         int nMajorDim,
                         long lStyle,
                         const wxValidator& rVal,
                         const wxString& rsName )
{
    wxColour vColour(*wxBLACK);
    LONG     lColor;
    HWND     hWndParent = GetHwndOf(pParent);

    m_backgroundColour = pParent->GetBackgroundColour();
    m_nSelectedButton = -1;
    m_nNoItems = 0;

    //
    // Common initialization
    //
    if (!CreateControl( pParent
                       ,vId
                       ,rPos
                       ,rSize
                       ,lStyle
                       ,rVal
                       ,rsName
                      ))
        return false;
    if (!OS2CreateControl( wxT("STATIC")
                          ,SS_GROUPBOX
                          ,rPos
                          ,rSize
                          ,rsTitle
                         ))
        return false;

    wxAssociateWinWithHandle(m_hWnd, this);

    //
    // Now we can set m_nNoItems and let SetMajorDim set m_numCols/m_numRows
    //
    m_nNoItems = (unsigned int)nNum;
    SetMajorDim(nMajorDim == 0 ? nNum : nMajorDim, lStyle);

    m_ahRadioButtons = new WXHWND[nNum];
    m_pnRadioWidth   = new int[nNum];
    m_pnRadioHeight  = new int[nNum];

    for (int i = 0; i < nNum; i++)
    {
        m_pnRadioWidth[i] = m_pnRadioHeight[i] = -1;
        long                        lStyleBtn = BS_AUTORADIOBUTTON | WS_VISIBLE;
        int                         nNewId = NewControlId();

        if (i == 0)
            lStyleBtn |= WS_GROUP | WS_TABSTOP;

        wxString                    sLabel = ::wxPMTextToLabel(asChoices[i]);

        HWND                        hWndBtn = (WXHWND)::WinCreateWindow ( hWndParent,
                                                                          WC_BUTTON,
                                                                          sLabel.c_str(),
                                                                          lStyleBtn,
                                                                          0, 0, 0, 0,
                                                                          hWndParent,
                                                                          HWND_BOTTOM,
                                                                          (HMENU)nNewId,
                                                                          NULL,
                                                                          NULL
                                                                        );
        if (!hWndBtn)
        {
            return false;
        }
        lColor = (LONG)vColour.GetPixel();
        ::WinSetPresParam( hWndBtn
                          ,PP_FOREGROUNDCOLOR
                          ,sizeof(LONG)
                          ,(PVOID)&lColor
                         );

        lColor = (LONG)m_backgroundColour.GetPixel();
        ::WinSetPresParam( hWndBtn
                          ,PP_BACKGROUNDCOLOR
                          ,sizeof(LONG)
                          ,(PVOID)&lColor
                         );
        m_ahRadioButtons[i] = (WXHWND)hWndBtn;
        SubclassRadioButton((WXHWND)hWndBtn);
        wxAssociateWinWithHandle(hWndBtn, this);
        wxOS2SetFont( hWndBtn
                     ,*wxSMALL_FONT
                    );
        ::WinSetWindowULong(hWndBtn, QWL_USER, (ULONG)this);
        m_aSubControls.Add(nNewId);
    }

    //
    // Create a dummy control to end the group.
    //
    (void)::WinCreateWindow ( hWndParent,
                              WC_BUTTON,
                              "",
                              WS_GROUP,
                              0, 0, 0, 0,
                              hWndParent,
                              HWND_TOP,
                              (HMENU)NewControlId(),
                              NULL,
                              NULL
                            );
    fnWndProcRadioBox = (WXFARPROC)::WinSubclassWindow( GetHwnd()
                                                       ,(PFNWP)wxRadioBoxWndProc
                                                      );
    ::WinSetWindowULong(GetHwnd(), QWL_USER, (ULONG)this);
    lColor = (LONG)vColour.GetPixel();
    ::WinSetPresParam( m_hWnd
                      ,PP_FOREGROUNDCOLOR
                      ,sizeof(LONG)
                      ,(PVOID)&lColor
                     );

    lColor = (LONG)m_backgroundColour.GetPixel();
    ::WinSetPresParam( m_hWnd
                      ,PP_BACKGROUNDCOLOR
                      ,sizeof(LONG)
                      ,(PVOID)&lColor
                     );
    SetXComp(0);
    SetYComp(0);
    SetSelection(0);
    SetSize( rPos.x
            ,rPos.y
            ,rSize.x
            ,rSize.y
           );
    return true;
} // end of wxRadioBox::Create
コード例 #2
0
ファイル: fontdlg.cpp プロジェクト: esrrhs/fuck-music-player
int wxFontDialog::ShowModal()
{
    FONTDLG      vFontDlg;
    char         zCurrentFont[FACESIZE];
    HWND         hWndFontDlg;
    FACENAMEDESC vFn;

    memset(&vFontDlg, '\0', sizeof(FONTDLG));
    zCurrentFont[0] = '\0';

    //
    // Set the fontdlg fields
    //
    vFontDlg.cbSize         = sizeof(FONTDLG);
    vFontDlg.hpsScreen      = ::WinGetScreenPS(HWND_DESKTOP);
    vFontDlg.hpsPrinter     = NULL;
    vFontDlg.pszFamilyname  = zCurrentFont;
    vFontDlg.fxPointSize    = MAKEFIXED(12,0);
    vFontDlg.usFamilyBufLen = FACESIZE;
    vFontDlg.fl             = FNTS_CENTER;
    vFontDlg.clrFore        = CLR_BLACK;
    vFontDlg.clrBack        = CLR_WHITE;

    hWndFontDlg = WinFontDlg( HWND_DESKTOP
                             ,GetParent()->GetHWND()
                             ,&vFontDlg
                            );
    if (hWndFontDlg && vFontDlg.lReturn == DID_OK)
    {
        wxColour                    vColour((unsigned long)0x00000000);
        wxNativeFontInfo            vInfo;

        m_fontData.m_fontColour = vColour;

        memset(&vFn, '\0', sizeof(FACENAMEDESC));
        vFn.usSize        = sizeof(FACENAMEDESC);
        vFn.usWeightClass = vFontDlg.usWeight;
        vFn.usWidthClass  = vFontDlg.usWidth;

        memset(&vInfo.fa, '\0', sizeof(FATTRS));
        memcpy(&vInfo.fn, &vFn, sizeof(FACENAMEDESC));

        vInfo.fa.usRecordLength = vFontDlg.fAttrs.usRecordLength;
        strcpy(vInfo.fa.szFacename, vFontDlg.fAttrs.szFacename);
        vInfo.fa.lMatch = vFontDlg.fAttrs.lMatch;

        //
        // Debugging
        //
        wxFont                      vChosenFont(vInfo);

        int                         nPointSize = vFontDlg.fxPointSize >> 16;

        vChosenFont.SetPointSize(nPointSize);
        m_fontData.m_chosenFont = vChosenFont;

        m_fontData.EncodingInfo().facename = (wxChar*)vFontDlg.fAttrs.szFacename;
        m_fontData.EncodingInfo().charset = vFontDlg.fAttrs.usCodePage;

        return wxID_OK;
    }
コード例 #3
0
ファイル: checklst.cpp プロジェクト: gitrider/wxsj2
bool wxCheckListBoxItem::OnDrawItem (
  wxDC&                             rDc
, const wxRect&                     rRect
, wxODAction                        eAct
, wxODStatus                        eStat
)
{
    wxRect                          vRect = rRect;

    ::WinQueryWindowRect( m_pParent->GetHWND()
                         ,&rDc.m_vRclPaint
                        );
    if (IsChecked())
        eStat = (wxOwnerDrawn::wxODStatus)(eStat | wxOwnerDrawn::wxODChecked);

    //
    // Unfortunately PM doesn't quite get the text position exact.  We need to alter
    // it down and to the right, just a little bit.  The coords in rRect are OS/2
    // coords not wxWidgets coords.
    //
    vRect.x += 5;
    vRect.y -= 3;
    if (wxOwnerDrawn::OnDrawItem( rDc
                                 ,vRect
                                 ,eAct
                                 ,eStat))
    {
        size_t                      nCheckWidth  = GetDefaultMarginWidth();
        size_t                      nCheckHeight = m_pParent->GetItemHeight();
        int                         nParentHeight;
        int                         nX = rRect.GetX();
        int                         nY = rRect.GetY();
        int                         nOldY = nY;
        wxColour                    vColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
        wxPen                       vPenBack;
        wxPen                       vPenGray;
        wxPen                       vPenPrev;

        m_pParent->GetSize( NULL
                           ,&nParentHeight
                          );

        nY = nParentHeight - nY - nCheckHeight;
        vPenBack = wxPen(vColour, 1, wxSOLID);
        vPenGray = wxPen(wxColour(127, 127, 127), 1, wxSOLID);

        //
        // Erase the 1-pixel border
        //
        rDc.SetPen(vPenBack);
        rDc.DrawRectangle( nX
                          ,nY
                          ,nCheckWidth
                          ,nCheckHeight
                         );

        //
        // Now we draw the smaller rectangle
        //
        nY++;
        nCheckWidth  -= 2;
        nCheckHeight -= 2;

        //
        // Draw hollow gray rectangle
        //
        rDc.SetPen(vPenGray);
        rDc.DrawRectangle( nX
                          ,nY
                          ,nCheckWidth
                          ,nCheckHeight
                         );

        nX++;
        if (IsChecked())
        {
            //
            // Draw the check by loading the sys standard bitmap and drawing it
            //
            HBITMAP                 hChkBmp = ::WinGetSysBitmap( HWND_DESKTOP
                                                                ,SBMP_MENUCHECK
                                                               );
            POINTL                  vPoint = {nX, nOldY + 3};

            ::WinDrawBitmap( rDc.GetHPS()
                            ,hChkBmp
                            ,NULL
                            ,&vPoint
                            ,NULL
                            ,NULL
                            ,DBM_NORMAL
                           );
        }
        return TRUE;
    }
    return FALSE;
} // end of wxCheckListBoxItem::OnDrawItem