示例#1
0
wxQtAction::wxQtAction( wxMenu *parent, int id, const wxString &text, const wxString &help,
        wxItemKind kind, wxMenu *subMenu, wxMenuItem *handler )
    : QAction( wxQtConvertString( text ), parent->GetHandle() ),
      wxQtSignalHandler< wxMenuItem >( handler )
{
    setStatusTip( wxQtConvertString( help ));

    if ( subMenu != NULL )
        setMenu( subMenu->GetHandle() );

    if ( id == wxID_SEPARATOR )
        setSeparator( true );

    switch ( kind )
    {
        case wxITEM_SEPARATOR:
            setSeparator( true );
            break;
        case wxITEM_CHECK:
        case wxITEM_RADIO:
            setCheckable( true );
            break;
        case wxITEM_NORMAL:
            // Normal for a menu item.
            break;
        case wxITEM_DROPDOWN:
        case wxITEM_MAX:
            // Not applicable for menu items.
            break;
    }

    connect( this, &QAction::triggered, this, &wxQtAction::onActionTriggered );
}
示例#2
0
void wxQtDCImpl::DoDrawText(const wxString& text, wxCoord x, wxCoord y)
{
    QPen savedPen = m_qtPainter->pen();
    m_qtPainter->setPen(QPen(m_textForegroundColour.GetHandle()));

    // Disable logical function
    QPainter::CompositionMode savedOp = m_qtPainter->compositionMode();
    m_qtPainter->setCompositionMode( QPainter::CompositionMode_SourceOver );
    
    if (m_backgroundMode == wxSOLID)
    {
        m_qtPainter->setBackgroundMode(Qt::OpaqueMode);
    
        //Save pen/brush
        QBrush savedBrush = m_qtPainter->background();

        //Use text colors
        m_qtPainter->setBackground(QBrush(m_textBackgroundColour.GetHandle()));

        //Draw
        m_qtPainter->drawText(x, y, 1, 1, Qt::TextDontClip, wxQtConvertString(text));

        //Restore saved settings
        m_qtPainter->setBackground(savedBrush);


        m_qtPainter->setBackgroundMode(Qt::TransparentMode);
    }
    else
        m_qtPainter->drawText(x, y, 1, 1, Qt::TextDontClip, wxQtConvertString(text));

    m_qtPainter->setPen(savedPen);
    m_qtPainter->setCompositionMode( savedOp );
}
示例#3
0
bool wxListBox::Create(wxWindow *parent, wxWindowID id,
            const wxPoint& pos,
            const wxSize& size,
            int n, const wxString choices[],
            long style,
            const wxValidator& validator,
            const wxString& name)
{
    Init();
    QListWidgetItem* item;
    m_qtWindow = m_qtListWidget = new wxQtListWidget( parent, this );

    while ( n-- > 0 )
    {
        item = new QListWidgetItem();
        item->setText(wxQtConvertString( *choices++ ));
        if ( m_hasCheckBoxes )
        {
            item->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
            item->setCheckState(Qt::Unchecked);
        }
        m_qtListWidget->addItem(item);
    }
    return wxListBoxBase::Create( parent, id, pos, size, style, validator, name );
}
示例#4
0
bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
            const wxString& value,
            const wxPoint& pos,
            const wxSize& size,
            int n, const wxString choices[],
            long style,
            const wxValidator& validator,
            const wxString& name )
{
    m_qtComboBox = new wxQtComboBox( parent, this );
    while ( n-- > 0 )
        m_qtComboBox->addItem( wxQtConvertString( *choices++ ));
    m_qtComboBox->setEditText( wxQtConvertString( value ));

    return QtCreateControl( parent, id, pos, size, style, validator, name );
}
示例#5
0
bool wxRadioBox::Create(wxWindow *parent,
            wxWindowID id,
            const wxString& title,
            const wxPoint& pos,
            const wxSize& size,
            int n, const wxString choices[],
            int WXUNUSED(majorDim),
            long style,
            const wxValidator& val,
            const wxString& name)
{
    m_qtGroupBox = new wxQtRadioBox( parent, this );
    m_qtGroupBox->setTitle( wxQtConvertString( title ) );
    m_qtButtonGroup = new wxQtButtonGroup( m_qtGroupBox, this );

    if ( style & wxRA_SPECIFY_ROWS )
        m_qtBoxLayout = new QHBoxLayout;
    else if ( style & wxRA_SPECIFY_COLS )
        m_qtBoxLayout = new QVBoxLayout;

    AddChoices< QRadioButton >( m_qtButtonGroup, m_qtBoxLayout, n, choices );
    m_qtBoxLayout->addStretch(1);
    m_qtGroupBox->setLayout(m_qtBoxLayout);

    return QtCreateControl( parent, id, pos, size, style, val, name );
}
示例#6
0
bool wxListCtrl::GetItem(wxListItem& info) const
{
    const long id = info.GetId();
    QTreeWidgetItem *qitem = QtGetItem(id);
    if ( qitem != NULL )
    {
        if ( !info.m_mask )
            // by default, get everything for backwards compatibility
            info.m_mask = -1;
        if ( info.m_mask & wxLIST_MASK_TEXT )
            info.SetText(wxQtConvertString(qitem->text(info.GetColumn())));
        if ( info.m_mask & wxLIST_MASK_DATA )
        {
            QVariant variant = qitem->data(0, Qt::UserRole);
            info.SetData(variant.value<long>());
        }
        if ( info.m_mask & wxLIST_MASK_STATE )
        {
            info.m_state = wxLIST_STATE_DONTCARE;
            if ( info.m_stateMask & wxLIST_STATE_FOCUSED )
            {
                if ( m_qtTreeWidget->currentIndex().row() == id )
                    info.m_state |= wxLIST_STATE_FOCUSED;
            }
            if ( info.m_stateMask & wxLIST_STATE_SELECTED )
            {
                if ( qitem->isSelected() )
                    info.m_state |= wxLIST_STATE_SELECTED;
            }
        }
        return true;
    }
    else
        return false;
}
示例#7
0
wxString wxRadioBox::GetString(unsigned int n) const
{
    QAbstractButton *qtButton = GetButtonAt( m_qtButtonGroup, n );
    CHECK_BUTTON( qtButton, wxEmptyString );

    return wxQtConvertString( qtButton->text() );
}
示例#8
0
void wxStatusBar::DoUpdateStatusText(int number)
{
    if ( m_qtPanes->count() != m_panes.GetCount() )
        UpdateFields();

    (*m_qtPanes)[number]->setText( wxQtConvertString( m_panes[number].GetText() ) );
}
示例#9
0
bool wxListBox::Create(wxWindow *parent, wxWindowID id,
            const wxPoint& pos,
            const wxSize& size,
            int n, const wxString choices[],
            long style,
            const wxValidator& validator,
            const wxString& name)
{
    Init();
    QListWidgetItem* item;
    m_qtWindow = m_qtListWidget = new wxQtListWidget( parent, this );

#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
#   pragma ivdep
#   pragma swp
#   pragma unroll
#   pragma prefetch
#   if 0
#       pragma simd noassert
#   endif
#endif /* VDM auto patch */
    while ( n-- > 0 )
    {
        item = new QListWidgetItem();
        item->setText(wxQtConvertString( *choices++ ));
        if ( m_hasCheckBoxes )
        {
            item->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled | Qt::ItemIsSelectable);
            item->setCheckState(Qt::Unchecked);
        }
        m_qtListWidget->addItem(item);
    }
    return wxListBoxBase::Create( parent, id, pos, size, style, validator, name );
}
示例#10
0
文件: menu.cpp 项目: 3v1n0/wxWidgets
wxString wxMenuBar::GetMenuLabel(size_t pos) const
{
    QAction *qtAction = GetActionAt( m_qtMenuBar, pos );
    QMenu *qtMenu = qtAction->menu();

    return wxQtConvertString( qtMenu->title() );
}
示例#11
0
文件: menu.cpp 项目: 3v1n0/wxWidgets
wxMenu::wxMenu(const wxString& title, long style)
    : wxMenuBase( title, style )
{
    m_qtMenu = new QMenu( wxQtConvertString( title ));

    ApplyStyle( m_qtMenu, style );
}
示例#12
0
void wxQtDCImpl::DoGetTextExtent(const wxString& string,
                             wxCoord *x, wxCoord *y,
                             wxCoord *descent,
                             wxCoord *externalLeading,
                             const wxFont *theFont ) const
{
    QFont f = m_qtPainter->font();
    if (theFont != NULL)
        f = theFont->GetHandle();

    QFontMetrics metrics(f);
    if (x != NULL || y != NULL)
    {
        // note that boundingRect doesn't return "advance width" for spaces
        if (x != NULL)
            *x = metrics.width( wxQtConvertString(string) );
        if (y != NULL)
            *y = metrics.height();
    }

    if (descent != NULL)
        *descent = metrics.descent();

    if (externalLeading != NULL)
        *externalLeading = metrics.leading();
}
示例#13
0
bool wxFont::SetFaceName(const wxString& facename)
{
    AllocExclusive();
    M_FONTDATA.setFamily(wxQtConvertString(facename));
    // qt uses a "font matching algoritm" so the font will be allways valid
    return true;
}
示例#14
0
文件: menu.cpp 项目: 3v1n0/wxWidgets
static QMenu *SetTitle( wxMenu *menu, const wxString &title )
{
    QMenu *qtMenu = menu->GetHandle();
    qtMenu->setTitle( wxQtConvertString( title ));

    return qtMenu;
}
示例#15
0
void wxRadioBox::SetString(unsigned int n, const wxString& s)
{
    QAbstractButton *qtButton = GetButtonAt( m_qtButtonGroup, n );
    wxCHECK_RET( qtButton != NULL, INVALID_INDEX_MESSAGE );

    qtButton->setText( wxQtConvertString( s ));
}
示例#16
0
wxString wxListCtrl::GetItemText(long item, int WXUNUSED(col)) const
{
    QTreeWidgetItem *qitem = QtGetItem(item);
    if ( qitem )
        return wxQtConvertString( qitem->text(0) );
    else
        return wxString();
}
示例#17
0
wxFont::wxFont(const wxString& nativeFontInfoString)
{
    m_refData = new wxFontRefData();

    QFont font;
    font.fromString(wxQtConvertString( nativeFontInfoString ));
    M_FONTDATA = font;
}
示例#18
0
void wxToolBarTool::SetLabel( const wxString &label )
{
    wxToolBarToolBase::SetLabel( label );

    if (m_qtToolButton) {
        m_qtToolButton->setText(wxQtConvertString( label ));
    }
}
示例#19
0
void wxFileDialog::GetFilenames(wxArrayString& files) const
{
    QStringList selectedfiles = GetHandle()->selectedFiles();
    foreach (QString file, selectedfiles )
    {
        wxFileName fn = wxQtConvertString(file);
        files.Add(fn.GetName());
    }
示例#20
0
    void SetWildcard(const wxString& wildCard)
    {
        QStringList wildCards = wxQtConvertString(wildCard).split("|");
        QStringList filters;
        for (int i=0; i<wildCards.size(); i+=2)
            filters += wildCards.at(i);

        setNameFilters(filters);
    }
示例#21
0
void wxWindowQt::DoSetToolTip( wxToolTip *tip )
{
    wxWindowBase::DoSetToolTip( tip );

    if ( tip != NULL )
        GetHandle()->setToolTip( wxQtConvertString( tip->GetTip() ));
    else
        GetHandle()->setToolTip( QString() );
}
示例#22
0
bool wxFont::Create(wxSize size, wxFontFamily family, wxFontStyle style,
        wxFontWeight weight, bool underlined, const wxString& face,
        wxFontEncoding WXUNUSED(encoding) )
{
    m_refData = new wxFontRefData(size.GetHeight(), ConvertFontFamily(family), style != wxFONTSTYLE_NORMAL,
                                  ConvertFontWeight(weight), underlined, wxQtConvertString(face));

    return true;
}
示例#23
0
bool wxListCtrl::SetItem(wxListItem& info)
{
    const long id = info.GetId();
    QTreeWidgetItem *qitem = QtGetItem(id);
    if ( qitem != NULL )
    {
        if ((info.m_mask & wxLIST_MASK_TEXT) && !info.GetText().IsNull() )
            qitem->setText(info.GetColumn(), wxQtConvertString(info.GetText()));
        qitem->setTextAlignment(info.GetColumn(), wxQtConvertTextAlign(info.GetAlign()));

        if ( info.m_mask & wxLIST_MASK_DATA )
        {
            QVariant variant = qVariantFromValue(info.GetData());
            qitem->setData(0, Qt::UserRole, variant);
        }
        if (info.m_mask & wxLIST_MASK_STATE)
        {
            if ((info.m_stateMask & wxLIST_STATE_FOCUSED) &&
                (info.m_state & wxLIST_STATE_FOCUSED))
                    m_qtTreeWidget->setCurrentItem(qitem, 0);
            if (info.m_stateMask & wxLIST_STATE_SELECTED)
                qitem->setSelected(info.m_state & wxLIST_STATE_SELECTED);
        }
        if (info.m_mask & wxLIST_MASK_IMAGE)
        {
            if (info.m_image >= 0)
            {
                wxImageList *imglst = GetImageList(InReportView() ? wxIMAGE_LIST_SMALL : wxIMAGE_LIST_NORMAL);
                wxCHECK_MSG(imglst, false, "invalid listctrl imagelist");
                const wxBitmap* bitmap = imglst->GetBitmapPtr(info.m_image);
                if (bitmap != NULL)
                {
                    // set the new image:
                    qitem->setIcon( info.GetColumn(), QIcon( *bitmap->GetHandle() ));
                }
            }
            else
            {
                // remove the image using and empty qt icon:
                qitem->setIcon( info.GetColumn(), QIcon() );
            }
        }
        for (int col=0; col<GetColumnCount(); col++)
        {
            if ( info.GetFont().IsOk() )
                qitem->setFont(col, info.GetFont().GetHandle() );
            if ( info.GetTextColour().IsOk() )
                qitem->setTextColor(col, info.GetTextColour().GetHandle());
            if ( info.GetBackgroundColour().IsOk() )
                qitem->setBackgroundColor(col, info.GetBackgroundColour().GetHandle());
        }
        return true;
    }
    else
        return false;
}
示例#24
0
void wxQtButtonGroup::buttonClicked(int index) {
    wxRadioBox *handler = GetHandler();
    if ( handler )
    {
        wxCommandEvent event( wxEVT_RADIOBOX, handler->GetId() );
        event.SetInt(index);
        event.SetString(wxQtConvertString(button(index)->text()));
        EmitEvent( event );
    }
}
示例#25
0
void wxQtDCImpl::DoDrawRotatedText(const wxString& text,
                               wxCoord x, wxCoord y, double angle)
{
    if (m_backgroundMode == wxSOLID)
        m_qtPainter->setBackgroundMode(Qt::OpaqueMode);
    
    //Move and rotate (reverse angle direction in Qt and wx)
    m_qtPainter->translate(x, y);
    m_qtPainter->rotate(-angle);

    QPen savedPen = m_qtPainter->pen();
    m_qtPainter->setPen(QPen(m_textForegroundColour.GetHandle()));

    // Disable logical function
    QPainter::CompositionMode savedOp = m_qtPainter->compositionMode();
    m_qtPainter->setCompositionMode( QPainter::CompositionMode_SourceOver );

    if (m_backgroundMode == wxSOLID)
    {
        m_qtPainter->setBackgroundMode(Qt::OpaqueMode);
        
        //Save pen/brush
        QBrush savedBrush = m_qtPainter->background();
        
        //Use text colors
        m_qtPainter->setBackground(QBrush(m_textBackgroundColour.GetHandle()));
        
        //Draw
        m_qtPainter->drawText(x, y, 1, 1, Qt::TextDontClip, wxQtConvertString(text));
        
        //Restore saved settings
        m_qtPainter->setBackground(savedBrush);
        
        m_qtPainter->setBackgroundMode(Qt::TransparentMode);
    }
    else
        m_qtPainter->drawText(x, y, 1, 1, Qt::TextDontClip, wxQtConvertString(text));

    //Reset to default
    ComputeScaleAndOrigin();
    m_qtPainter->setPen(savedPen);
    m_qtPainter->setCompositionMode( savedOp );
}
示例#26
0
static void AddChoices( QButtonGroup *qtButtonGroup, QBoxLayout *qtBoxLayout, int count, const wxString choices[] )
{
    Button *btn;
    while ( count-- > 0 )
    {
        btn = new Button( wxQtConvertString( *choices++ ));
        qtButtonGroup->addButton( btn );
        qtBoxLayout->addWidget( btn );
    }
}
示例#27
0
QShortcut *ConvertAccelerator( wxAcceleratorEntry *e, QWidget *parent )
{
    // TODO: Not all keys have the same string representation in wx and qt
    QShortcut *s = new QShortcut( wxQtConvertString( e->ToString() ), parent );
    
    // Set a property to save wx Command to send when activated
    s->setProperty( "wxQt_Command", e->GetCommand() );

    return s;
}
示例#28
0
void wxQtComboBox::editTextChanged(const QString &text)
{
    wxComboBox *handler = GetHandler();
    if ( handler )
    {
        wxCommandEvent event( wxEVT_TEXT, handler->GetId() );
        event.SetString( wxQtConvertString( text ) );
        EmitEvent( event );
    }
}
示例#29
0
bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
            const wxString& label,
            const wxPoint& pos,
            const wxSize& size,
            long style,
            const wxString& name)
{
    m_qtGroupBox = new wxQtGroupBox( parent, this );
    m_qtGroupBox->setTitle( wxQtConvertString( label ) );

    return QtCreateControl( parent, id, pos, size, style, wxDefaultValidator, name );
}
示例#30
0
bool wxBitmap::SaveFile(const wxString &name, wxBitmapType type,
              const wxPalette *WXUNUSED(palette) ) const
{   
    #if wxUSE_IMAGE
    //Try to save using wx
    wxImage image = ConvertToImage();
    if (image.IsOk() && image.SaveFile(name, type))
        return true;
    #endif
    
    //Try to save using Qt
    const char* type_name = NULL;
    switch (type)
    {
        case wxBITMAP_TYPE_BMP:  type_name = "bmp";  break;
        case wxBITMAP_TYPE_ICO:  type_name = "ico";  break;
        case wxBITMAP_TYPE_JPEG: type_name = "jpeg"; break;
        case wxBITMAP_TYPE_PNG:  type_name = "png";  break;
        case wxBITMAP_TYPE_GIF:  type_name = "gif";  break;
        case wxBITMAP_TYPE_CUR:  type_name = "cur";  break;
        case wxBITMAP_TYPE_TIFF: type_name = "tif";  break;
        case wxBITMAP_TYPE_XBM:  type_name = "xbm";  break;
        case wxBITMAP_TYPE_PCX:  type_name = "pcx";  break;
        case wxBITMAP_TYPE_BMP_RESOURCE:
        case wxBITMAP_TYPE_ICO_RESOURCE:
        case wxBITMAP_TYPE_CUR_RESOURCE:
        case wxBITMAP_TYPE_XBM_DATA:
        case wxBITMAP_TYPE_XPM:
        case wxBITMAP_TYPE_XPM_DATA:
        case wxBITMAP_TYPE_TIFF_RESOURCE:
        case wxBITMAP_TYPE_GIF_RESOURCE:
        case wxBITMAP_TYPE_PNG_RESOURCE:
        case wxBITMAP_TYPE_JPEG_RESOURCE:
        case wxBITMAP_TYPE_PNM:
        case wxBITMAP_TYPE_PNM_RESOURCE:
        case wxBITMAP_TYPE_PCX_RESOURCE:
        case wxBITMAP_TYPE_PICT:
        case wxBITMAP_TYPE_PICT_RESOURCE:
        case wxBITMAP_TYPE_ICON:
        case wxBITMAP_TYPE_ICON_RESOURCE:
        case wxBITMAP_TYPE_ANI:
        case wxBITMAP_TYPE_IFF:
        case wxBITMAP_TYPE_TGA:
        case wxBITMAP_TYPE_MACCURSOR:
        case wxBITMAP_TYPE_MACCURSOR_RESOURCE:
        case wxBITMAP_TYPE_MAX:
        case wxBITMAP_TYPE_ANY:
        default:
            break;
    }
    return type_name &&
        M_PIXDATA.save(wxQtConvertString(name), type_name);
}