コード例 #1
0
bool wxGenericFontButton::Create( wxWindow *parent, wxWindowID id,
                        const wxFont &initial, const wxPoint &pos,
                        const wxSize &size, long style,
                        const wxValidator& validator, const wxString &name)
{
    wxString label = (style & wxFNTP_FONTDESC_AS_LABEL) ?
                        wxString() : // label will be updated by UpdateFont
                        _("Choose font");

    // create this button
    if (!wxButton::Create( parent, id, label, pos,
                           size, style, validator, name ))
    {
        wxFAIL_MSG( wxT("wxGenericFontButton creation failed") );
        return false;
    }

    // and handle user clicks on it
    Connect(GetId(), wxEVT_COMMAND_BUTTON_CLICKED,
            wxCommandEventHandler(wxGenericFontButton::OnButtonClick),
            NULL, this);

    m_selectedFont = initial.IsOk() ? initial : *wxNORMAL_FONT;
    UpdateFont();
    InitFontData();

    return true;
}
コード例 #2
0
ファイル: fontpickercmn.cpp プロジェクト: EdgarTx/wx
bool wxFontPickerCtrl::Create( wxWindow *parent, wxWindowID id,
                               const wxFont &initial,
                               const wxPoint &pos, const wxSize &size,
                               long style, const wxValidator& validator,
                               const wxString &name )
{
    if (!wxPickerBase::CreateBase(parent, id,
                                  Font2String(initial.IsOk() ? initial
                                          : *wxNORMAL_FONT),
                                  pos, size, style, validator, name))
        return false;

    // the picker of a wxFontPickerCtrl is a wxFontPickerWidget
    m_picker = new wxFontPickerWidget(this, wxID_ANY, initial,
                                      wxDefaultPosition, wxDefaultSize,
                                      GetPickerStyle(style));
    // complete sizer creation
    wxPickerBase::PostCreation();

    m_picker->Connect(wxEVT_COMMAND_FONTPICKER_CHANGED,
                      wxFontPickerEventHandler(wxFontPickerCtrl::OnFontChange),
                      NULL, this);

    return true;
}
コード例 #3
0
void wxGraphicsContext::SetFont( const wxFont& font, const wxColour& colour )
{
    if ( font.IsOk() )
        SetFont( CreateFont( font, colour ) );
    else
        SetFont( wxNullGraphicsFont );
}
コード例 #4
0
ファイル: TextPoint.cpp プロジェクト: Hakansv/ocpn_draw_pi
TextPoint::TextPoint( double lat, double lon, const wxString& icon_ident, const wxString& name,
                  const wxString &pGUID, bool bAddToList )
: ODPoint( lat, lon, icon_ident, name, pGUID, bAddToList )
{
    m_sTypeString = wxT("Text Point");
    switch ( g_iTextPosition )
    {
        case ID_TEXT_TOP:
        case ID_TEXT_CENTRE_TOP:
            m_TextLocationOffsetX = g_iTextTopOffsetX;
            m_TextLocationOffsetY = g_iTextTopOffsetY;
            break;
        case ID_TEXT_BOTTOM:
        case ID_TEXT_CENTRE_BOTTOM:
            m_TextLocationOffsetX = g_iTextBottomOffsetX;
            m_TextLocationOffsetY = g_iTextBottomOffsetY;
            break;
        case ID_TEXT_CENTRE:
            m_TextLocationOffsetX = g_iTextCentreOffsetX;
            m_TextLocationOffsetY = g_iTextCentreOffsetY;
            break;
        case ID_TEXT_RIGHT:
            m_TextLocationOffsetX = g_iTextRightOffsetX;
            m_TextLocationOffsetY = g_iTextRightOffsetY;
            break;
        case ID_TEXT_LEFT:
            m_TextLocationOffsetX = g_iTextLeftOffsetX;
            m_TextLocationOffsetY = g_iTextLeftOffsetY;
            break;
    }
    m_iTextPosition = g_iTextPosition;
    m_iBackgroundTransparency = g_iTextBackgroundTransparency;
    m_colourTextColour = g_colourDefaultTextColour;
    m_colourTextBackgroundColour = g_colourDefaultTextBackgroundColour;
    m_iWrapLen = 250;
    if(g_DisplayTextFont.IsOk()) m_DisplayTextFont = g_DisplayTextFont;
    m_bTextChanged = true;
    m_bShowDisplayTextOnRollover = false;
    m_iDisplayTextWhen = g_iTextPointDisplayTextWhen;
#ifdef ocpnUSE_GL
    m_iDisplayTextTexture = 0;
#endif
    
    m_pstText = NULL;
    wxSize tSize;
    tSize.x = 250;
    tSize.y = 75;
    
    wxColour wxCol;
    GetGlobalColor( wxT("YELO1"), &wxCol );
    
    m_natural_scale = g_ocpn_draw_pi->m_chart_scale;
    m_scale_factor = 0;
}
コード例 #5
0
ファイル: settings.cpp プロジェクト: emutavchi/pxCore
wxFont wxSystemSettingsNative::GetFont( wxSystemFont index )
{
    wxFont font;
    switch (index)
    {
        case wxSYS_OEM_FIXED_FONT:
        case wxSYS_ANSI_FIXED_FONT:
        case wxSYS_SYSTEM_FIXED_FONT:
            font = *wxNORMAL_FONT;
            break;

        case wxSYS_ANSI_VAR_FONT:
        case wxSYS_SYSTEM_FONT:
        case wxSYS_DEVICE_DEFAULT_FONT:
        case wxSYS_DEFAULT_GUI_FONT:
            if (!gs_fontSystem.IsOk())
            {
                wxNativeFontInfo info;
#ifdef __WXGTK3__
                GtkStyleContext* sc = gtk_widget_get_style_context(ButtonWidget());
                gtk_style_context_set_state(sc, GTK_STATE_FLAG_NORMAL);
                gtk_style_context_get(sc, GTK_STATE_FLAG_NORMAL,
                    GTK_STYLE_PROPERTY_FONT, &info.description, NULL);
#else
                info.description = ButtonStyle()->font_desc;
#endif
                gs_fontSystem = wxFont(info);

#if wxUSE_FONTENUM
                // (try to) heal the default font (on some common systems e.g. Ubuntu
                // it's "Sans Serif" but the real font is called "Sans"):
                if (!wxFontEnumerator::IsValidFacename(gs_fontSystem.GetFaceName()) &&
                    gs_fontSystem.GetFaceName() == "Sans Serif")
                {
                    gs_fontSystem.SetFaceName("Sans");
                }
#endif // wxUSE_FONTENUM

#ifndef __WXGTK3__
                info.description = NULL;
#endif
            }
            font = gs_fontSystem;
            break;

        default:
            break;
    }

    wxASSERT( font.IsOk() );

    return font;
}
コード例 #6
0
ファイル: fontpicker.cpp プロジェクト: Bluehorn/wxPython
bool wxFontButton::Create( wxWindow *parent, wxWindowID id,
                        const wxFont &initial,
                        const wxPoint &pos, const wxSize &size,
                        long style, const wxValidator& validator,
                        const wxString &name )
{
    if (!gtk_check_version(2,4,0))
    {
        m_needParent = true;
        m_acceptsFocus = true;

        if (!PreCreation( parent, pos, size ) ||
            !wxControl::CreateBase(parent, id, pos, size, style, validator, name))
        {
            wxFAIL_MSG( wxT("wxFontButton creation failed") );
            return false;
        }

        m_widget = gtk_font_button_new();

        // set initial font
        m_selectedFont = initial.IsOk() ? initial : *wxNORMAL_FONT;
        UpdateFont();

        // honour the fontbutton styles
        bool showall = (style & wxFNTP_FONTDESC_AS_LABEL) != 0,
             usefont = (style & wxFNTP_USEFONT_FOR_LABEL) != 0;
        gtk_font_button_set_show_style(GTK_FONT_BUTTON(m_widget), showall);
        gtk_font_button_set_show_size(GTK_FONT_BUTTON(m_widget), showall);

        gtk_font_button_set_use_size(GTK_FONT_BUTTON(m_widget), usefont);
        gtk_font_button_set_use_font(GTK_FONT_BUTTON(m_widget), usefont);

        gtk_widget_show( GTK_WIDGET(m_widget) );

        // GtkFontButton signals
        g_signal_connect(m_widget, "font-set",
                        G_CALLBACK(gtk_fontbutton_setfont_callback), this);


        m_parent->DoAddChild( this );

        PostCreation(size);
        SetInitialSize(size);
    }
    else
        return wxGenericFontButton::Create(parent, id, initial, pos, size,
                                           style, validator, name);
    return true;
}
コード例 #7
0
ファイル: util.cpp プロジェクト: Emmavw/wxExtension
bool wxExForEach(wxAuiNotebook* notebook, int id, const wxFont& font)
{
  for (
	// no auto, should be int
    int page = notebook->GetPageCount() - 1;
    page >= 0;
    page--)
  {
    // Required by wxExFileDialog.
    wxExListViewFile* lv = (wxExListViewFile*)notebook->GetPage(page);

    if (lv == NULL)
    {
      return false;
    }

    switch (id)
    {
    case ID_LIST_ALL_ITEMS:
      {
        if (font.IsOk())
        {
          lv->SetFont(font);
        }

        lv->ItemsUpdate();
      }
      break;

    case ID_LIST_ALL_CLOSE:
      {
      wxExFileDialog dlg(notebook, lv);
      if (dlg.ShowModalIfChanged() == wxID_CANCEL) return false;
      if (!notebook->DeletePage(page)) return false;
      }
      break;

    default: wxFAIL;
    }
  }

  return true;
}
コード例 #8
0
// Get attributes from font.
bool wxTextAttr::GetFontAttributes(const wxFont& font, int flags)
{
    if (!font.IsOk())
        return false;

    if (flags & wxTEXT_ATTR_FONT_SIZE)
        m_fontSize = font.GetPointSize();

    if (flags & wxTEXT_ATTR_FONT_ITALIC)
        m_fontStyle = font.GetStyle();

    if (flags & wxTEXT_ATTR_FONT_WEIGHT)
        m_fontWeight = font.GetWeight();

    if (flags & wxTEXT_ATTR_FONT_UNDERLINE)
        m_fontUnderlined = font.GetUnderlined();

    if (flags & wxTEXT_ATTR_FONT_STRIKETHROUGH)
        m_fontStrikethrough = font.GetStrikethrough();

    if (flags & wxTEXT_ATTR_FONT_FACE)
        m_fontFaceName = font.GetFaceName();

    if (flags & wxTEXT_ATTR_FONT_ENCODING)
        m_fontEncoding = font.GetEncoding();

    if (flags & wxTEXT_ATTR_FONT_FAMILY)
    {
        // wxFont might not know its family, avoid setting m_fontFamily to an
        // invalid value and rather pretend that we don't have any font family
        // information at all in this case
        const wxFontFamily fontFamily = font.GetFamily();
        if ( fontFamily == wxFONTFAMILY_UNKNOWN )
            flags &= ~wxTEXT_ATTR_FONT_FAMILY;
        else
            m_fontFamily = fontFamily;
    }

    m_flags |= flags;

    return true;
}
コード例 #9
0
ファイル: settings.cpp プロジェクト: Annovae/Dolphin-Core
wxFont wxSystemSettingsNative::GetFont( wxSystemFont index )
{
    wxFont font;
    switch (index)
    {
        case wxSYS_OEM_FIXED_FONT:
        case wxSYS_ANSI_FIXED_FONT:
        case wxSYS_SYSTEM_FIXED_FONT:
            font = *wxNORMAL_FONT;
            break;

        case wxSYS_ANSI_VAR_FONT:
        case wxSYS_SYSTEM_FONT:
        case wxSYS_DEVICE_DEFAULT_FONT:
        case wxSYS_DEFAULT_GUI_FONT:
            if (!gs_fontSystem.IsOk())
            {
                wxNativeFontInfo info;
                info.description = ButtonStyle()->font_desc;
                gs_fontSystem = wxFont(info);

#if wxUSE_FONTENUM
                // (try to) heal the default font (on some common systems e.g. Ubuntu
                // it's "Sans Serif" but the real font is called "Sans"):
                if (!wxFontEnumerator::IsValidFacename(gs_fontSystem.GetFaceName()) &&
                    gs_fontSystem.GetFaceName() == "Sans Serif")
                    gs_fontSystem.SetFaceName("Sans");
#endif // wxUSE_FONTENUM

                info.description = NULL;
            }
            font = gs_fontSystem;
            break;

        default:
            break;
    }

    wxASSERT( font.IsOk() );

    return font;
}
コード例 #10
0
ファイル: fontdata.cpp プロジェクト: 0ryuO/dolphin-avsync
wxFont wxGetFontFromUser(wxWindow *parent, const wxFont& fontInit, const wxString& caption)
{
    wxFontData data;
    if ( fontInit.IsOk() )
    {
        data.SetInitialFont(fontInit);
    }

    wxFont fontRet;
    wxFontDialog dialog(parent, data);
    if (!caption.empty())
        dialog.SetTitle(caption);
    if ( dialog.ShowModal() == wxID_OK )
    {
        fontRet = dialog.GetFontData().GetChosenFont();
    }
    //else: leave it invalid

    return fontRet;
}
コード例 #11
0
ファイル: fontcmn.cpp プロジェクト: madnessw/thesnow
bool wxFontBase::operator==(const wxFont& font) const
{
    // either it is the same font, i.e. they share the same common data or they
    // have different ref datas but still describe the same font
    return IsSameAs(font) ||
           (
            IsOk() == font.IsOk() &&
            GetPointSize() == font.GetPointSize() &&
            // in wxGTK1 GetPixelSize() calls GetInternalFont() which uses
            // operator==() resulting in infinite recursion so we can't use it
            // in that port
#if !defined(__WXGTK__) || defined(__WXGTK20__)
            GetPixelSize() == font.GetPixelSize() &&
#endif
            GetFamily() == font.GetFamily() &&
            GetStyle() == font.GetStyle() &&
            GetWeight() == font.GetWeight() &&
            GetUnderlined() == font.GetUnderlined() &&
            GetFaceName().IsSameAs(font.GetFaceName(), false) &&
            GetEncoding() == font.GetEncoding()
           );
}
コード例 #12
0
ファイル: font.cpp プロジェクト: ruifig/nutcracker
void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )
{
    wxPaintDC dc(this);
    PrepareDC(dc);

    // set background
    dc.SetBackground(*wxWHITE_BRUSH);
    dc.Clear();
    dc.SetFont(m_font);

    // one text line height
    wxCoord hLine = dc.GetCharHeight();

    // the current text origin
    wxCoord x = 5,
            y = 5;

    // output the font name/info
    wxString fontInfo;

    fontInfo.Printf(wxT("Face name: %s, family: %s"),
                    m_font.GetFaceName().c_str(),
                    m_font.GetFamilyString().c_str());

    dc.DrawText(fontInfo, x, y);
    y += hLine;

    fontInfo.Printf(wxT("Size: %d points or %d pixels; %d*%d average char size"),
                    m_font.GetPointSize(),
                    m_font.GetPixelSize().y,
                    dc.GetCharWidth(), dc.GetCharHeight());

    dc.DrawText(fontInfo, x, y);
    y += hLine;

    fontInfo.Printf(wxT("Style: %s, weight: %s, fixed width: %s, encoding: %s"),
                    m_font.GetStyleString().c_str(),
                    m_font.GetWeightString().c_str(),
                    m_font.IsFixedWidth() ? wxT("yes") : wxT("no"),
                    wxFontMapper::GetEncodingDescription(m_font.GetEncoding()));

    dc.DrawText(fontInfo, x, y);
    y += hLine;

    if ( m_font.IsOk() )
    {
        const wxNativeFontInfo *info = m_font.GetNativeFontInfo();
        if ( info )
        {
            wxString fontDesc = m_font.GetNativeFontInfoUserDesc();
            fontInfo.Printf(wxT("Native font info: %s"), fontDesc.c_str());

            dc.DrawText(fontInfo, x, y);
            y += hLine;
        }
    }

    y += hLine;

    // prepare to draw the font
    dc.SetTextForeground(m_colour);

    // the size of one cell (Normally biggest char + small margin)
    wxCoord maxCharWidth, maxCharHeight;
    dc.GetTextExtent(wxT("W"), &maxCharWidth, &maxCharHeight);
    int w = maxCharWidth + 5,
        h = maxCharHeight + 4;


    // print all font symbols from 32 to 256 in 7 rows of 32 chars each
    for ( int i = 0; i < 7; i++ )
    {
        for ( int j = 0; j < 32; j++ )
        {
            wxChar c = (wxChar)(32 * (i + 1) + j);

            wxCoord charWidth, charHeight;
            dc.GetTextExtent(c, &charWidth, &charHeight);
            dc.DrawText
            (
                c,
                x + w*j + (maxCharWidth - charWidth) / 2 + 1,
                y + h*i + (maxCharHeight - charHeight) / 2
            );
        }
    }

    // draw the lines between them
    dc.SetPen(*wxBLUE_PEN);
    int l;

    // horizontal
    for ( l = 0; l < 8; l++ )
    {
        int yl = y + h*l - 2;
        dc.DrawLine(x - 2, yl, x + 32*w - 1, yl);
    }

    // and vertical
    for ( l = 0; l < 33; l++ )
    {
        int xl = x + w*l - 2;
        dc.DrawLine(xl, y - 2, xl, y + 7*h - 1);
    }
}
コード例 #13
0
ファイル: textcmn.cpp プロジェクト: djbarry004/Ishiiruka
// Get attributes from font.
bool wxTextAttr::GetFontAttributes(const wxFont& font, int flags)
{
    if (!font.IsOk())
        return false;

    // If we pass both pixel and point size attributes, this is an indication
    // to choose the most appropriate units.
    if ((flags & wxTEXT_ATTR_FONT) == wxTEXT_ATTR_FONT)
    {
        if (font.IsUsingSizeInPixels())
        {
            m_fontSize = font.GetPixelSize().y;
            flags &= ~wxTEXT_ATTR_FONT_POINT_SIZE;
        }
        else
        {
            m_fontSize = font.GetPointSize();
            flags &= ~wxTEXT_ATTR_FONT_PIXEL_SIZE;
        }
    }
    else if (flags & wxTEXT_ATTR_FONT_POINT_SIZE)
    {
        m_fontSize = font.GetPointSize();
        flags &= ~wxTEXT_ATTR_FONT_PIXEL_SIZE;
    }
    else if (flags & wxTEXT_ATTR_FONT_PIXEL_SIZE)
    {
        m_fontSize = font.GetPixelSize().y;
    }

    if (flags & wxTEXT_ATTR_FONT_ITALIC)
        m_fontStyle = font.GetStyle();

    if (flags & wxTEXT_ATTR_FONT_WEIGHT)
        m_fontWeight = font.GetWeight();

    if (flags & wxTEXT_ATTR_FONT_UNDERLINE)
        m_fontUnderlined = font.GetUnderlined();

    if (flags & wxTEXT_ATTR_FONT_STRIKETHROUGH)
        m_fontStrikethrough = font.GetStrikethrough();

    if (flags & wxTEXT_ATTR_FONT_FACE)
        m_fontFaceName = font.GetFaceName();

    if (flags & wxTEXT_ATTR_FONT_ENCODING)
        m_fontEncoding = font.GetEncoding();

    if (flags & wxTEXT_ATTR_FONT_FAMILY)
    {
        // wxFont might not know its family, avoid setting m_fontFamily to an
        // invalid value and rather pretend that we don't have any font family
        // information at all in this case
        const wxFontFamily fontFamily = font.GetFamily();
        if ( fontFamily == wxFONTFAMILY_UNKNOWN )
            flags &= ~wxTEXT_ATTR_FONT_FAMILY;
        else
            m_fontFamily = fontFamily;
    }

    m_flags |= flags;

    return true;
}
コード例 #14
0
ファイル: menuitem.cpp プロジェクト: emutavchi/pxCore
void wxMenuItem::GetFontToUse(wxFont& font) const
{
    font = GetFont();
    if ( !font.IsOk() )
        font = MenuDrawData::Get()->Font;
}