Exemple #1
0
void wxGtkFileChooser::SetWildcard( const wxString& wildCard )
{
    m_wildcards.Empty();

    // parse filters
    wxArrayString wildDescriptions, wildFilters;

    if ( !wxParseCommonDialogsFilter( wildCard, wildDescriptions, wildFilters ) )
    {
        wxFAIL_MSG( wxT( "wxGtkFileChooser::SetWildcard - bad wildcard string" ) );
    }
    else
    {
        // Parsing went fine. Set m_wildCard to be returned by wxGtkFileChooserBase::GetWildcard
        GtkFileChooser* chooser = m_widget;

        // empty current filter list:
        GSList* ifilters = gtk_file_chooser_list_filters( chooser );
        GSList* filters = ifilters;

        m_ignoreNextFilterEvent = true;
        wxON_BLOCK_EXIT_SET(m_ignoreNextFilterEvent, false);

        while ( ifilters )
        {
            gtk_file_chooser_remove_filter( chooser, GTK_FILE_FILTER( ifilters->data ) );
            ifilters = ifilters->next;
        }
        g_slist_free( filters );

        if (!wildCard.empty())
        {
            // add parsed to GtkChooser
            for ( size_t n = 0; n < wildFilters.GetCount(); ++n )
            {
                GtkFileFilter* filter = gtk_file_filter_new();

                gtk_file_filter_set_name( filter, wxGTK_CONV_SYS( wildDescriptions[n] ) );

                wxStringTokenizer exttok( wildFilters[n], wxT( ";" ) );

                int n1 = 1;
                while ( exttok.HasMoreTokens() )
                {
                    wxString token = exttok.GetNextToken();
                    gtk_file_filter_add_pattern( filter, wxGTK_CONV_SYS( token ) );

                    if (n1 == 1)
                        m_wildcards.Add( token ); // Only add first pattern to list, used later when saving
                    n1++;
                }

                gtk_file_chooser_add_filter( chooser, filter );
            }

            // Reset the filter index
            SetFilterIndex( 0 );
        }
    }
}
Exemple #2
0
void wxFontRefData::Init(int pointSize,
                         wxFontFamily family,
                         wxFontStyle style,
                         wxFontWeight weight,
                         bool underlined,
                         bool strikethrough,
                         const wxString& faceName,
                         wxFontEncoding WXUNUSED(encoding))
{
    if (family == wxFONTFAMILY_DEFAULT)
        family = wxFONTFAMILY_SWISS;

    m_underlined = underlined;
    m_strikethrough = strikethrough;

    // Create native font info
    m_nativeFontInfo.description = pango_font_description_new();

    // And set its values
    if (!faceName.empty())
    {
        pango_font_description_set_family( m_nativeFontInfo.description,
                                           wxGTK_CONV_SYS(faceName) );
    }
    else
    {
        SetFamily(family);
    }

    SetStyle( style == wxDEFAULT ? wxFONTSTYLE_NORMAL : style );
    SetPointSize( (pointSize == wxDEFAULT || pointSize == -1)
                    ? wxDEFAULT_FONT_SIZE
                    : pointSize );
    SetWeight( weight == wxDEFAULT ? wxFONTWEIGHT_NORMAL : weight );
}
Exemple #3
0
    GtkArray(const wxArrayString& a)
    {
        m_count = a.size();
        m_strings = new const gchar *[m_count + 1];
        for ( size_t n = 0; n < m_count; n++ )
            m_strings[n] = wxGTK_CONV_SYS(a[n]).release();

        // array must be NULL-terminated
        m_strings[m_count] = NULL;
    }
Exemple #4
0
bool wxColour::FromString(const wxString& str)
{
    GdkColor colGDK;
    if ( gdk_color_parse( wxGTK_CONV_SYS( str ), &colGDK ) )
    {
        *this = wxColour(colGDK);
        return true;
    }

    return wxColourBase::FromString(str);
}
Exemple #5
0
void wxFontRefData::Init(int pointSize,
                         wxFontFamily family,
                         wxFontStyle style,
                         wxFontWeight weight,
                         bool underlined,
                         const wxString& faceName,
                         wxFontEncoding encoding)
{
    m_family = family == wxFONTFAMILY_DEFAULT ? wxFONTFAMILY_SWISS : family;

    m_underlined = underlined;
    m_encoding = encoding;
    if ( m_encoding == wxFONTENCODING_DEFAULT )
        m_encoding = wxFont::GetDefaultEncoding();

    m_noAA = false;

    // Create native font info
    m_nativeFontInfo.description = pango_font_description_new();

    // And set its values
    if (!faceName.empty())
    {
       pango_font_description_set_family( m_nativeFontInfo.description,
                                           wxGTK_CONV_SYS(faceName) );
    }
    else
    {
        switch (m_family)
        {
            case wxFONTFAMILY_MODERN:
            case wxFONTFAMILY_TELETYPE:
               pango_font_description_set_family( m_nativeFontInfo.description, "monospace" );
               break;
            case wxFONTFAMILY_ROMAN:
               pango_font_description_set_family( m_nativeFontInfo.description, "serif" );
               break;
            case wxFONTFAMILY_SWISS:
               // SWISS = sans serif
            default:
               pango_font_description_set_family( m_nativeFontInfo.description, "sans" );
               break;
        }
    }

    SetStyle( style == wxDEFAULT ? wxFONTSTYLE_NORMAL : style );
    SetPointSize( (pointSize == wxDEFAULT || pointSize == -1)
                    ? wxDEFAULT_FONT_SIZE
                    : pointSize );
    SetWeight( weight == wxDEFAULT ? wxFONTWEIGHT_NORMAL : weight );
}
Exemple #6
0
void wxToolTip::GTKApply( wxWindow *win )
{
    if (!win)
        return;

    if ( !gs_tooltips )
        gs_tooltips = gtk_tooltips_new();

    m_window = win;

    if (m_text.empty())
        m_window->GTKApplyToolTip( gs_tooltips, NULL );
    else
        m_window->GTKApplyToolTip( gs_tooltips, wxGTK_CONV_SYS(m_text) );
}
Exemple #7
0
void wxMenuItem::SetGtkLabel()
{
    const wxString text = wxConvertMnemonicsToGTK(m_text.BeforeFirst('\t'));
    GtkLabel* label = GTK_LABEL(gtk_bin_get_child(GTK_BIN(m_menuItem)));
    gtk_label_set_text_with_mnemonic(label, wxGTK_CONV_SYS(text));
#if wxUSE_ACCEL
    guint accel_key;
    GdkModifierType accel_mods;
    wxGetGtkAccel(this, &accel_key, &accel_mods);
    if (accel_key)
    {
        gtk_widget_add_accelerator(
            m_menuItem, "activate", m_parentMenu->m_accel,
            accel_key, accel_mods, GTK_ACCEL_VISIBLE);
    }
#endif // wxUSE_ACCEL
}
Exemple #8
0
static void
wxGetGtkAccel(const wxMenuItem* item, guint* accel_key, GdkModifierType* accel_mods)
{
    *accel_key = 0;
    const wxString string = GetGtkHotKey(*item);
    if (!string.empty())
        gtk_accelerator_parse(wxGTK_CONV_SYS(string), accel_key, accel_mods);
    else
    {
        GtkStockItem stock_item;
        const char* stockid = wxGetStockGtkID(item->GetId());
        if (stockid && gtk_stock_lookup(stockid, &stock_item))
        {
            *accel_key = stock_item.keyval;
            *accel_mods = stock_item.modifier;
        }
    }
}
Exemple #9
0
void wxFontRefData::Init(int pointSize,
                         wxFontFamily family,
                         wxFontStyle style,
                         wxFontWeight weight,
                         bool underlined,
                         bool strikethrough,
                         const wxString& faceName,
                         wxFontEncoding WXUNUSED(encoding))
{
    // Old code could wrongly specify wxDEFAULT instead of -1 or wxNORMAL or,
    // preferably, wxFONTSTYLE_NORMAL or wxFONTWEIGHT_NORMAL, continue handling
    // this for compatibility.
    if ( pointSize == wxDEFAULT )
        pointSize = -1;

    if ( static_cast<int>(style) == wxDEFAULT )
        style = wxFONTSTYLE_NORMAL;

    if ( static_cast<int>(weight) == wxDEFAULT )
        weight = wxFONTWEIGHT_NORMAL;

    if (family == wxFONTFAMILY_DEFAULT)
        family = wxFONTFAMILY_SWISS;

    // Create native font info
    m_nativeFontInfo.description = pango_font_description_new();

    // And set its values
    if (!faceName.empty())
    {
        pango_font_description_set_family( m_nativeFontInfo.description,
                                           wxGTK_CONV_SYS(faceName) );
    }
    else
    {
        SetFamily(family);
    }

    SetStyle( style );
    SetPointSize( pointSize == -1 ? wxDEFAULT_FONT_SIZE : pointSize );
    SetWeight( weight );
    SetUnderlined( underlined );
    SetStrikethrough( strikethrough );
}
Exemple #10
0
static
gboolean statusbar_query_tooltip(GtkWidget*   WXUNUSED(widget),
                                 gint        x,
                                 gint        y,
                                 gboolean     WXUNUSED(keyboard_mode),
                                 GtkTooltip *tooltip,
                                 wxStatusBar* statbar)
{
    int n = statbar->GetFieldFromPoint(wxPoint(x,y));
    if (n == wxNOT_FOUND)
        return FALSE;

    // should we show the tooltip for the n-th pane of the statusbar?
    if (!statbar->GetField(n).IsEllipsized())
        return FALSE;   // no, it's not useful

    const wxString& str = statbar->GetStatusText(n);
    if (str.empty())
        return FALSE;

    gtk_tooltip_set_text(tooltip, wxGTK_CONV_SYS(str));
    return TRUE;
}
Exemple #11
0
void wxAboutBox(const wxAboutDialogInfo& info, wxWindow* WXUNUSED(parent))
{
    if ( !gtk_check_version(2,6,0) )
    {
        // don't create another dialog if one is already present
        if ( !gs_aboutDialog )
            gs_aboutDialog = GTK_ABOUT_DIALOG(gtk_about_dialog_new());

        GtkAboutDialog * const dlg = gs_aboutDialog;
        gtk_about_dialog_set_program_name(dlg, wxGTK_CONV_SYS(info.GetName()));
        if ( info.HasVersion() )
            gtk_about_dialog_set_version(dlg, wxGTK_CONV_SYS(info.GetVersion()));
        else
            gtk_about_dialog_set_version(dlg, NULL);
        if ( info.HasCopyright() )
            gtk_about_dialog_set_copyright(dlg, wxGTK_CONV_SYS(info.GetCopyrightToDisplay()));
        else
            gtk_about_dialog_set_copyright(dlg, NULL);
        if ( info.HasDescription() )
            gtk_about_dialog_set_comments(dlg, wxGTK_CONV_SYS(info.GetDescription()));
        else
            gtk_about_dialog_set_comments(dlg, NULL);
        if ( info.HasLicence() )
            gtk_about_dialog_set_license(dlg, wxGTK_CONV_SYS(info.GetLicence()));
        else
            gtk_about_dialog_set_license(dlg, NULL);

        wxIcon icon = info.GetIcon();
        if ( icon.IsOk() )
            gtk_about_dialog_set_logo(dlg, info.GetIcon().GetPixbuf());

        if ( info.HasWebSite() )
        {
            // NB: must be called before gtk_about_dialog_set_website() as
            //     otherwise it has no effect (although GTK+ docs don't mention
            //     this...)
            gtk_about_dialog_set_url_hook(wxGtkAboutDialogOnLink, NULL, NULL);

            gtk_about_dialog_set_website(dlg, wxGTK_CONV_SYS(info.GetWebSiteURL()));
            gtk_about_dialog_set_website_label
            (
                dlg,
                wxGTK_CONV_SYS(info.GetWebSiteDescription())
            );
        }
        else
        {
            gtk_about_dialog_set_website(dlg, NULL);
            gtk_about_dialog_set_website_label(dlg, NULL);
            gtk_about_dialog_set_url_hook(NULL, NULL, NULL);
        }

        if ( info.HasDevelopers() )
            gtk_about_dialog_set_authors(dlg, GtkArray(info.GetDevelopers()));
        else
            gtk_about_dialog_set_authors(dlg, GtkArray());
        if ( info.HasDocWriters() )
            gtk_about_dialog_set_documenters(dlg, GtkArray(info.GetDocWriters()));
        else
            gtk_about_dialog_set_documenters(dlg, GtkArray());
        if ( info.HasArtists() )
            gtk_about_dialog_set_artists(dlg, GtkArray(info.GetArtists()));
        else
            gtk_about_dialog_set_artists(dlg, GtkArray());

        wxString transCredits;
        if ( info.HasTranslators() )
        {
            const wxArrayString& translators = info.GetTranslators();
            const size_t count = translators.size();
            for ( size_t n = 0; n < count; n++ )
            {
                transCredits << translators[n] << wxT('\n');
            }
        }
        else // no translators explicitly specified
        {
            // maybe we have translator credits in the message catalog?
            wxString translator = _("translator-credits");

            // gtk_about_dialog_set_translator_credits() is smart enough to
            // detect if "translator-credits" is untranslated and hide the
            // translators tab in that case, however it will still show the
            // "credits" button, (at least GTK 2.10.6) even if there are no
            // credits informations at all, so we still need to do the check
            // ourselves
            if ( translator != wxT("translator-credits") ) // untranslated!
                transCredits = translator;
        }

        if ( !transCredits.empty() )
            gtk_about_dialog_set_translator_credits(dlg, wxGTK_CONV_SYS(transCredits));
        else
            gtk_about_dialog_set_translator_credits(dlg, NULL);

        g_signal_connect(dlg, "response",
                            G_CALLBACK(wxGtkAboutDialogOnClose), NULL);

        gtk_window_present(GTK_WINDOW(dlg));
        return;
    }

    // native about dialog not available, fall back to the generic one
    wxGenericAboutBox(info);
}
void wxToolTip::GTKSetWindow(wxWindow* win)
{
    wxASSERT(win);
    m_window = win;
    m_window->GTKApplyToolTip(wxGTK_CONV_SYS(m_text));
}
void wxToolTip::SetTip( const wxString &tip )
{
    m_text = tip;
    if (m_window)
        m_window->GTKApplyToolTip(wxGTK_CONV_SYS(m_text));
}