wxDECLARE_COMMON_FONT_METHODS();
+ // Set Pango attributes for the span 0..len (or
+ // without any bounds if len == 0) in the specified layout. Currently only
+ // underlined and strike-through attributes are handled by this function.
+ //
+ // Special "addDummyAttrs" parameter is used to work around a bug in old Pango
+ // versions in wxWindowDCImpl::DoDrawText(), see comment there.
+ //
+ // If neither of them is specified, returns false, otherwise sets up the
+ // attributes and returns true.
+ bool GTKSetPangoAttrs(PangoLayout* layout, size_t len = 0, bool addDummyAttrs = false) const;
+
// implementation from now on
void Unshare();
#include "wx/gtk/private/string.h"
#include "wx/gtk/private/gtk2-compat.h"
-class WXDLLIMPEXP_FWD_CORE wxFont;
-
// pango_version_check symbol is quite recent ATM (4/2007)... so we
// use our own wrapper which implements a smart trick.
// Use this function as you'd use pango_version_check:
GtkWidget *GetTextEntryWidget();
GtkWidget *GetTreeWidget();
-// Set Pango attributes corresponding to the given font for the span 0..len (or
-// without any bounds if len == 0) in the specified layout. Currently only
-// underlined and strike-through attributes are handled by this function.
-//
-// Special "addDummyAttrs" parameter is used to work around a bug in old Pango
-// versions in wxWindowDCImpl::DoDrawText(), see comment there.
-//
-// If neither of them is specified, returns false, otherwise sets up the
-// attributes and returns true.
-//
-// This function is implemented in src/gtk/dcclient.cpp.
-bool
-SetPangoAttrsForFont(const wxFont& font, PangoLayout* layout, size_t len = 0,
- bool addDummyAttrs = false);
-
} // wxGTKPrivate
#endif // _WX_GTK_PRIVATE_H_
-
#include "wx/gtk/private.h"
#include "wx/gtk/private/object.h"
-using wxGTKPrivate::SetPangoAttrsForFont;
-
//-----------------------------------------------------------------------------
// local defines
//-----------------------------------------------------------------------------
pango_layout_set_text(m_layout, data, datalen);
const bool
- setAttrs = SetPangoAttrsForFont(m_font, m_layout, datalen, needshack);
+ setAttrs = m_font.GTKSetPangoAttrs(m_layout, datalen, needshack);
int oldSize = 0;
const bool isScaled = fabs(m_scaleY - 1.0) > 0.00001;
y = YLOG2DEV(y);
pango_layout_set_text(m_layout, wxGTK_CONV(text), -1);
- SetPangoAttrsForFont( m_font, m_layout );
+ m_font.GTKSetPangoAttrs(m_layout);
int oldSize = 0;
const bool isScaled = fabs(m_scaleY - 1.0) > 0.00001;
if (isScaled)
return gdk_drawable_get_depth(m_gdkwindow);
}
-bool
-wxGTKPrivate::SetPangoAttrsForFont(const wxFont& font,
- PangoLayout *layout,
- size_t len,
- bool addDummyAttrs)
-{
- if ( !font.IsOk() || !(font.GetUnderlined() || font.GetStrikethrough()) )
- return false;
-
- PangoAttrList* attrs = pango_attr_list_new();
-
- if ( font.GetUnderlined() )
- {
- PangoAttribute *a = pango_attr_underline_new(PANGO_UNDERLINE_SINGLE);
- if ( len )
- {
- a->start_index = 0;
- a->end_index = len;
- }
- pango_attr_list_insert(attrs, a);
-
- // Add dummy attributes (use colour as it's invisible anyhow for 0
- // width spaces) to ensure that the spaces in the beginning/end of the
- // string are underlined too.
- if ( addDummyAttrs )
- {
- wxASSERT_MSG( len > 2, "Must have 0-width spaces at string ends" );
-
- a = pango_attr_foreground_new (0x0057, 0x52A9, 0xD614);
- a->start_index = 0;
- a->end_index = 1;
- pango_attr_list_insert(attrs, a);
-
- a = pango_attr_foreground_new (0x0057, 0x52A9, 0xD614);
- a->start_index = len - 1;
- a->end_index = len;
- pango_attr_list_insert(attrs, a);
- }
- }
-
- if ( font.GetStrikethrough() )
- {
- PangoAttribute *a = pango_attr_strikethrough_new( TRUE );
- if ( len )
- {
- a->start_index = 0;
- a->end_index = len;
- }
- pango_attr_list_insert(attrs, a);
- }
-
- pango_layout_set_attributes(layout, attrs);
- pango_attr_list_unref(attrs);
-
- return true;
-}
-
//-----------------------------------------------------------------------------
// wxClientDCImpl
//-----------------------------------------------------------------------------
{
return new wxFontRefData(*static_cast<const wxFontRefData*>(data));
}
+
+bool wxFont::GTKSetPangoAttrs(PangoLayout* layout, size_t len, bool addDummyAttrs) const
+{
+ if (!IsOk() || !(GetUnderlined() || GetStrikethrough()))
+ return false;
+
+ PangoAttrList* attrs = pango_attr_list_new();
+ PangoAttribute* a;
+
+ if (GetUnderlined())
+ {
+ a = pango_attr_underline_new(PANGO_UNDERLINE_SINGLE);
+ if (len)
+ {
+ a->start_index = 0;
+ a->end_index = len;
+ }
+ pango_attr_list_insert(attrs, a);
+
+ // Add dummy attributes (use colour as it's invisible anyhow for 0
+ // width spaces) to ensure that the spaces in the beginning/end of the
+ // string are underlined too.
+ if ( addDummyAttrs )
+ {
+ wxASSERT_MSG( len > 2, "Must have 0-width spaces at string ends" );
+
+ a = pango_attr_foreground_new(0x0057, 0x52A9, 0xD614);
+ a->start_index = 0;
+ a->end_index = 1;
+ pango_attr_list_insert(attrs, a);
+
+ a = pango_attr_foreground_new(0x0057, 0x52A9, 0xD614);
+ a->start_index = len - 1;
+ a->end_index = len;
+ pango_attr_list_insert(attrs, a);
+ }
+ }
+
+ if (GetStrikethrough())
+ {
+ a = pango_attr_strikethrough_new(true);
+ if (len)
+ {
+ a->start_index = 0;
+ a->end_index = len;
+ }
+ pango_attr_list_insert(attrs, a);
+ }
+
+ pango_layout_set_attributes(layout, attrs);
+ pango_attr_list_unref(attrs);
+
+ return true;
+}
#endif
#include "wx/fontutil.h"
-#include "wx/gtk/private.h"
#include "wx/dynlib.h"
#include "wx/paper.h"
const wxScopedCharBuffer data = text.utf8_str();
- size_t datalen = strlen(data);
- pango_layout_set_text( m_layout, data, datalen);
+ pango_layout_set_text(m_layout, data, data.length());
- const bool
- setAttrs = wxGTKPrivate::SetPangoAttrsForFont(m_font, m_layout, datalen);
+ const bool setAttrs = m_font.GTKSetPangoAttrs(m_layout);
if (m_textForegroundColour.IsOk())
{
unsigned char red = m_textForegroundColour.Red();