Allow displaying Japanese character with wxMotif/ANSI under a
Japanese EUC-JP locale: - add a #define (wxMOTIF_NEW_FONT_HANDLING) defaulting to off - factor the code for getting text extents in a central wxGetTextExtent function - when the new font handling is enabled load a fontset instead of a single font. For non-Japanese locales this should load a fontset containing a single font. - on a Japanese locale set the default point size to 15: the Japanese fonts I have are much more readable like this. - do not set the wordwrap property for multiline wxTextCtrl with OpenMotif 2.1, otherwise it crashes when text is added git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35035 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -43,6 +43,7 @@ wxGTK:
|
||||
|
||||
- ShowFullScreen() shows the window if it was still hidden (rpedroso)
|
||||
- Implemented wxTopLevelWindow::RequestUserAttention() (Mart Raudsepp)
|
||||
- Base library is now binary compatible when built with wxGTK and wxMotif
|
||||
|
||||
wxOS2
|
||||
|
||||
@@ -53,6 +54,11 @@ wxUniv:
|
||||
- Window creation now honours wxVSCROLL.
|
||||
- Standalone scrollbars generate events of correct type (Jochen Roemmler)
|
||||
|
||||
wxMotif:
|
||||
|
||||
- Base library is now binary compatible when built with wxGTK and wxMotif
|
||||
- wxMotif can now display Japanese text under Japanese locale.
|
||||
|
||||
|
||||
2.6.1
|
||||
-----
|
||||
|
@@ -2677,6 +2677,7 @@ typedef void* WXRegion;
|
||||
typedef void* WXFont;
|
||||
typedef void* WXImage;
|
||||
typedef void* WXFontList;
|
||||
typedef void* WXFontSet;
|
||||
typedef void* WXRendition;
|
||||
typedef void* WXRenderTable;
|
||||
typedef void* WXFontType; /* either a XmFontList or XmRenderTable */
|
||||
|
@@ -16,6 +16,10 @@
|
||||
#pragma interface "font.h"
|
||||
#endif
|
||||
|
||||
#if __WXMOTIF20__ && !__WXLESSTIF__ && !defined(wxMOTIF_NEW_FONT_HANDLING)
|
||||
#define wxMOTIF_NEW_FONT_HANDLING 0 // safe default
|
||||
#endif
|
||||
|
||||
class wxXFont;
|
||||
|
||||
// Font
|
||||
@@ -95,14 +99,18 @@ public:
|
||||
WXDisplay* display = NULL) const;
|
||||
|
||||
// These two are helper functions for convenient access of the above.
|
||||
#if !wxMOTIF_NEW_FONT_HANDLING
|
||||
WXFontStructPtr GetFontStruct(double scale = 1.0,
|
||||
WXDisplay* display = NULL) const;
|
||||
WXFontList GetFontList(double scale = 1.0,
|
||||
WXDisplay* display = NULL) const;
|
||||
#if __WXMOTIF20__
|
||||
#else
|
||||
WXFontSet GetFontSet(double scale, WXDisplay* display = NULL) const;
|
||||
#endif
|
||||
#if __WXMOTIF20__ // && !__WXLESSTIF__ for 2.7
|
||||
WXRenderTable GetRenderTable(WXDisplay* display) const;
|
||||
#endif
|
||||
// returns either a XmFontList or XmRendition, depending
|
||||
// returns either a XmFontList or XmRenderTable, depending
|
||||
// on Motif version
|
||||
WXFontType GetFontType(WXDisplay* display) const;
|
||||
// like the function above but does a copy for XmFontList
|
||||
|
@@ -36,7 +36,7 @@ class WXDLLEXPORT wxColour;
|
||||
#define wxCHECK_LESSTIF_VERSION( major, minor ) \
|
||||
( LesstifVersion >= (major) * 1000 + (minor) )
|
||||
|
||||
#define wxCHECK_LESSTIF() ( defined(LesstifVersion) && LesstifVersion > 0 )
|
||||
#define wxCHECK_LESSTIF() ( __WXLESSTIF__ )
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Miscellaneous functions
|
||||
@@ -96,6 +96,10 @@ extern void wxDoChangeBackgroundColour(WXWidget widget,
|
||||
wxColour& backgroundColour,
|
||||
bool changeArmColour = false);
|
||||
extern void wxDoChangeFont(WXWidget widget, wxFont& font);
|
||||
extern void wxGetTextExtent(WXDisplay* display, const wxFont& font,
|
||||
double scale,
|
||||
const wxString& string, int* width, int* height,
|
||||
int* ascent, int* descent);
|
||||
|
||||
#define wxNO_COLORS 0x00
|
||||
#define wxBACK_COLORS 0x01
|
||||
|
@@ -131,8 +131,10 @@ bool MyApp::OnInit()
|
||||
wxLANGUAGE_CZECH,
|
||||
wxLANGUAGE_POLISH,
|
||||
wxLANGUAGE_SWEDISH,
|
||||
#if wxUSE_UNICODE
|
||||
#if wxUSE_UNICODE || defined(__WXMOTIF__)
|
||||
wxLANGUAGE_JAPANESE,
|
||||
#endif
|
||||
#if wxUSE_UNICODE
|
||||
wxLANGUAGE_GEORGIAN,
|
||||
#endif
|
||||
wxLANGUAGE_ENGLISH,
|
||||
@@ -153,8 +155,10 @@ bool MyApp::OnInit()
|
||||
_T("Czech"),
|
||||
_T("Polish"),
|
||||
_T("Swedish"),
|
||||
#if wxUSE_UNICODE
|
||||
#if wxUSE_UNICODE || defined(__WXMOTIF__)
|
||||
_T("Japanese"),
|
||||
#endif
|
||||
#if wxUSE_UNICODE
|
||||
_T("Georgian"),
|
||||
#endif
|
||||
_T("English"),
|
||||
|
@@ -1035,7 +1035,7 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
|
||||
int cx = 0;
|
||||
int cy = 0;
|
||||
int ascent = 0;
|
||||
int slen;
|
||||
int slen = text.length();
|
||||
|
||||
// Set FillStyle, otherwise X will use current stipple!
|
||||
XGCValues gcV, gcBackingV;
|
||||
@@ -1049,27 +1049,9 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
|
||||
XSetFillStyle ((Display*) m_display, (GC) m_gcBacking, FillSolid);
|
||||
}
|
||||
|
||||
slen = strlen(text);
|
||||
|
||||
if (m_font.Ok())
|
||||
{
|
||||
WXFontStructPtr pFontStruct = m_font.GetFontStruct(m_userScaleY*m_logicalScaleY, m_display);
|
||||
int direction, descent;
|
||||
XCharStruct overall_return;
|
||||
#if 0
|
||||
if (use16)
|
||||
(void)XTextExtents16((XFontStruct*) pFontStruct, (XChar2b *)(const char*) text, slen, &direction,
|
||||
&ascent, &descent, &overall_return);
|
||||
else
|
||||
#endif // 0
|
||||
(void)XTextExtents((XFontStruct*) pFontStruct,
|
||||
wxConstCast(text.c_str(), char),
|
||||
slen, &direction,
|
||||
&ascent, &descent, &overall_return);
|
||||
|
||||
cx = overall_return.width;
|
||||
cy = ascent + descent;
|
||||
}
|
||||
wxGetTextExtent (m_display, m_font, m_userScaleY * m_logicalScaleY,
|
||||
text, &cx, &cy, &ascent, NULL);
|
||||
|
||||
// First draw a rectangle representing the text background, if a text
|
||||
// background is specified
|
||||
@@ -1145,7 +1127,12 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
|
||||
(XChar2b *)(char*) (const char*) text, slen);
|
||||
else
|
||||
#endif // 0
|
||||
#if wxMOTIF_NEW_FONT_HANDLING
|
||||
XFontSet fset = (XFontSet) m_font.GetFontSet (m_userScaleY * m_logicalScaleY, m_display);
|
||||
XmbDrawString((Display*) m_display, (Pixmap) m_pixmap, fset, (GC) m_gc, XLOG2DEV (x), YLOG2DEV (y) + ascent, text, slen);
|
||||
#else
|
||||
XDrawString((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, XLOG2DEV (x), YLOG2DEV (y) + ascent, text, slen);
|
||||
#endif
|
||||
|
||||
if (m_window && m_window->GetBackingPixmap()) {
|
||||
#if 0
|
||||
@@ -1155,9 +1142,15 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y )
|
||||
(XChar2b *)(char*) (const char*) text, slen);
|
||||
else
|
||||
#endif // 0
|
||||
#if wxMOTIF_NEW_FONT_HANDLING
|
||||
XmbDrawString((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), fset, (GC) m_gcBacking,
|
||||
XLOG2DEV_2 (x), YLOG2DEV_2 (y) + ascent,
|
||||
wxConstCast(text.c_str(), char), slen);
|
||||
#else
|
||||
XDrawString((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking,
|
||||
XLOG2DEV_2 (x), YLOG2DEV_2 (y) + ascent,
|
||||
wxConstCast(text.c_str(), char), slen);
|
||||
#endif
|
||||
}
|
||||
|
||||
// restore fill style
|
||||
@@ -1208,31 +1201,10 @@ void wxWindowDC::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord y,
|
||||
int cx = 0;
|
||||
int cy = 0;
|
||||
int ascent = 0;
|
||||
int slen = text.length();
|
||||
|
||||
if (m_font.Ok())
|
||||
{
|
||||
// Calculate text extent.
|
||||
WXFontStructPtr pFontStruct =
|
||||
m_font.GetFontStruct(m_userScaleY*m_logicalScaleY, m_display);
|
||||
int direction, descent;
|
||||
XCharStruct overall_return;
|
||||
#if 0
|
||||
if (use16)
|
||||
(void)XTextExtents16((XFontStruct*) pFontStruct,
|
||||
(XChar2b *)(const char*) text,
|
||||
slen, &direction,
|
||||
&ascent, &descent, &overall_return);
|
||||
else
|
||||
#endif // 0
|
||||
(void)XTextExtents((XFontStruct*) pFontStruct,
|
||||
wxConstCast(text.c_str(), char),
|
||||
slen, &direction,
|
||||
&ascent, &descent, &overall_return);
|
||||
|
||||
cx = overall_return.width;
|
||||
cy = ascent + descent;
|
||||
}
|
||||
wxGetTextExtent (m_display, m_font, m_userScaleY * m_logicalScaleY,
|
||||
text, &cx, &cy, &ascent, NULL);
|
||||
|
||||
wxBitmap src(cx, cy);
|
||||
wxMemoryDC dc;
|
||||
@@ -1340,9 +1312,7 @@ void wxWindowDC::DoGetTextExtent( const wxString &string, wxCoord *width, wxCoor
|
||||
{
|
||||
wxCHECK_RET( Ok(), "invalid dc" );
|
||||
|
||||
wxFont* theFont = font;
|
||||
if (!theFont)
|
||||
theFont = (wxFont *)&m_font; // const_cast
|
||||
const wxFont* theFont = font ? font : &m_font;
|
||||
|
||||
if (!theFont->Ok())
|
||||
{
|
||||
@@ -1354,33 +1324,11 @@ void wxWindowDC::DoGetTextExtent( const wxString &string, wxCoord *width, wxCoor
|
||||
return;
|
||||
}
|
||||
|
||||
WXFontStructPtr pFontStruct = theFont->GetFontStruct(m_userScaleY*m_logicalScaleY, m_display);
|
||||
wxGetTextExtent(m_display, *theFont, m_userScaleY * m_logicalScaleY,
|
||||
string, width, height, NULL, descent);
|
||||
|
||||
int direction, ascent, descent2;
|
||||
XCharStruct overall;
|
||||
int slen;
|
||||
|
||||
#if 0
|
||||
if (use16)
|
||||
slen = str16len(string);
|
||||
else
|
||||
#endif // 0
|
||||
slen = strlen(string);
|
||||
|
||||
#if 0
|
||||
if (use16)
|
||||
XTextExtents16((XFontStruct*) pFontStruct, (XChar2b *) (char*) (const char*) string, slen, &direction,
|
||||
&ascent, &descent2, &overall);
|
||||
else
|
||||
#endif // 0
|
||||
XTextExtents((XFontStruct*) pFontStruct,
|
||||
wxConstCast(string.c_str(), char), slen, &direction,
|
||||
&ascent, &descent2, &overall);
|
||||
|
||||
if (width) *width = XDEV2LOGREL (overall.width);
|
||||
if (height) *height = YDEV2LOGREL (ascent + descent2);
|
||||
if (descent)
|
||||
*descent = descent2;
|
||||
if (width) *width = XDEV2LOGREL (*width);
|
||||
if (height) *height = YDEV2LOGREL (*height);
|
||||
if (externalLeading)
|
||||
*externalLeading = 0;
|
||||
}
|
||||
@@ -1390,13 +1338,12 @@ wxCoord wxWindowDC::GetCharWidth() const
|
||||
wxCHECK_MSG( Ok(), 0, "invalid dc" );
|
||||
wxCHECK_MSG( m_font.Ok(), 0, "invalid font" );
|
||||
|
||||
WXFontStructPtr pFontStruct = m_font.GetFontStruct(m_userScaleY * m_logicalScaleY, m_display);
|
||||
int width;
|
||||
|
||||
int direction, ascent, descent;
|
||||
XCharStruct overall;
|
||||
XTextExtents ((XFontStruct*) pFontStruct, "x", 1, &direction, &ascent,
|
||||
&descent, &overall);
|
||||
return XDEV2LOGREL(overall.width);
|
||||
wxGetTextExtent (m_display, m_font, m_userScaleY * m_logicalScaleY,
|
||||
"x", &width, NULL, NULL, NULL);
|
||||
|
||||
return XDEV2LOGREL(width);
|
||||
}
|
||||
|
||||
wxCoord wxWindowDC::GetCharHeight() const
|
||||
@@ -1404,14 +1351,12 @@ wxCoord wxWindowDC::GetCharHeight() const
|
||||
wxCHECK_MSG( Ok(), 0, "invalid dc" );
|
||||
wxCHECK_MSG( m_font.Ok(), 0, "invalid font" );
|
||||
|
||||
WXFontStructPtr pFontStruct = m_font.GetFontStruct(m_userScaleY*m_logicalScaleY, m_display);
|
||||
int height;
|
||||
|
||||
int direction, ascent, descent;
|
||||
XCharStruct overall;
|
||||
XTextExtents ((XFontStruct*) pFontStruct, "x", 1, &direction, &ascent,
|
||||
&descent, &overall);
|
||||
// return XDEV2LOGREL(overall.ascent + overall.descent);
|
||||
return XDEV2LOGREL(ascent + descent);
|
||||
wxGetTextExtent (m_display, m_font, m_userScaleY * m_logicalScaleY,
|
||||
"x", NULL, &height, NULL, NULL);
|
||||
|
||||
return XDEV2LOGREL(height);
|
||||
}
|
||||
|
||||
void wxWindowDC::DoGetSize( int *width, int *height ) const
|
||||
@@ -1480,6 +1425,7 @@ void wxWindowDC::SetFont( const wxFont &font )
|
||||
return;
|
||||
}
|
||||
|
||||
#if !wxMOTIF_NEW_FONT_HANDLING
|
||||
WXFontStructPtr pFontStruct = m_font.GetFontStruct(m_userScaleY*m_logicalScaleY, m_display);
|
||||
|
||||
Font fontId = ((XFontStruct*)pFontStruct)->fid;
|
||||
@@ -1487,6 +1433,7 @@ void wxWindowDC::SetFont( const wxFont &font )
|
||||
|
||||
if (m_window && m_window->GetBackingPixmap())
|
||||
XSetFont ((Display*) m_display,(GC) m_gcBacking, fontId);
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxWindowDC::SetForegroundPixelWithLogicalFunction(int pixel)
|
||||
|
@@ -64,11 +64,14 @@ public:
|
||||
wxXFont();
|
||||
~wxXFont();
|
||||
|
||||
#if !wxMOTIF_NEW_FONT_HANDLING
|
||||
WXFontStructPtr m_fontStruct; // XFontStruct
|
||||
#if !wxUSE_RENDER_TABLE
|
||||
#endif
|
||||
#if !wxUSE_RENDER_TABLE && !wxMOTIF_NEW_FONT_HANDLING
|
||||
WXFontList m_fontList; // Motif XmFontList
|
||||
#else // if wxUSE_RENDER_TABLE
|
||||
WXRenderTable m_renderTable; // Motif XmRenderTable
|
||||
WXRendition m_rendition; // Motif XmRendition
|
||||
#endif
|
||||
WXDisplay* m_display; // XDisplay
|
||||
int m_scale; // Scale * 100
|
||||
@@ -133,11 +136,14 @@ protected:
|
||||
|
||||
wxXFont::wxXFont()
|
||||
{
|
||||
#if !wxMOTIF_NEW_FONT_HANDLING
|
||||
m_fontStruct = (WXFontStructPtr) 0;
|
||||
#if !wxUSE_RENDER_TABLE
|
||||
#endif
|
||||
#if !wxUSE_RENDER_TABLE && !wxMOTIF_NEW_FONT_HANDLING
|
||||
m_fontList = (WXFontList) 0;
|
||||
#else // if wxUSE_RENDER_TABLE
|
||||
m_renderTable = (WXRenderTable) 0;
|
||||
m_rendition = (WXRendition) 0;
|
||||
#endif
|
||||
m_display = (WXDisplay*) 0;
|
||||
m_scale = 100;
|
||||
@@ -536,6 +542,7 @@ wxXFont* wxFont::GetInternalFont(double scale, WXDisplay* display) const
|
||||
}
|
||||
|
||||
// not found, create a new one
|
||||
wxString xFontSpec;
|
||||
XFontStruct *font = (XFontStruct *)
|
||||
wxLoadQueryNearestFont(pointSize,
|
||||
M_FONTDATA->m_family,
|
||||
@@ -543,7 +550,8 @@ wxXFont* wxFont::GetInternalFont(double scale, WXDisplay* display) const
|
||||
M_FONTDATA->m_weight,
|
||||
M_FONTDATA->m_underlined,
|
||||
wxT(""),
|
||||
M_FONTDATA->m_encoding);
|
||||
M_FONTDATA->m_encoding,
|
||||
&xFontSpec);
|
||||
|
||||
if ( !font )
|
||||
{
|
||||
@@ -553,21 +561,27 @@ wxXFont* wxFont::GetInternalFont(double scale, WXDisplay* display) const
|
||||
}
|
||||
|
||||
wxXFont* f = new wxXFont;
|
||||
#if wxMOTIF_NEW_FONT_HANDLING
|
||||
XFreeFont( (Display*) display, font );
|
||||
#else
|
||||
f->m_fontStruct = (WXFontStructPtr)font;
|
||||
#endif
|
||||
f->m_display = ( display ? display : wxGetDisplay() );
|
||||
f->m_scale = intScale;
|
||||
|
||||
M_FONTDATA->m_fonts.Append(f);
|
||||
|
||||
#if !wxUSE_RENDER_TABLE
|
||||
f->m_fontList = XmFontListCreate ((XFontStruct*) font, XmSTRING_DEFAULT_CHARSET);
|
||||
#else // if wxUSE_RENDER_TABLE
|
||||
#if wxUSE_RENDER_TABLE
|
||||
XmRendition rendition;
|
||||
XmRenderTable renderTable;
|
||||
Arg args[5];
|
||||
int count = 0;
|
||||
|
||||
#if wxMOTIF_NEW_FONT_HANDLING
|
||||
wxChar* fontSpec = wxStrdup( xFontSpec.c_str() );
|
||||
XtSetArg( args[count], XmNfontName, fontSpec ); ++count;
|
||||
XtSetArg( args[count], XmNfontType, XmFONT_IS_FONTSET ); ++count;
|
||||
#else
|
||||
XtSetArg( args[count], XmNfont, font ); ++count;
|
||||
#endif
|
||||
XtSetArg( args[count], XmNunderlineType,
|
||||
GetUnderlined() ? XmSINGLE_LINE : XmNO_LINE ); ++count;
|
||||
rendition = XmRenditionCreate( XmGetXmDisplay( (Display*)f->m_display ),
|
||||
@@ -577,11 +591,20 @@ wxXFont* wxFont::GetInternalFont(double scale, WXDisplay* display) const
|
||||
XmMERGE_REPLACE );
|
||||
|
||||
f->m_renderTable = (WXRenderTable)renderTable;
|
||||
f->m_rendition = (WXRendition)rendition;
|
||||
wxASSERT( f->m_renderTable != NULL );
|
||||
#else // if !wxUSE_RENDER_TABLE
|
||||
f->m_fontList = XmFontListCreate ((XFontStruct*) font, XmSTRING_DEFAULT_CHARSET);
|
||||
wxASSERT( f->m_fontList != NULL );
|
||||
#endif
|
||||
|
||||
M_FONTDATA->m_fonts.Append(f);
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
#if !wxMOTIF_NEW_FONT_HANDLING
|
||||
|
||||
WXFontStructPtr wxFont::GetFontStruct(double scale, WXDisplay* display) const
|
||||
{
|
||||
wxXFont* f = GetInternalFont(scale, display);
|
||||
@@ -600,6 +623,8 @@ WXFontList wxFont::GetFontList(double scale, WXDisplay* display) const
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // !wxMOTIF_NEW_FONT_HANDLING
|
||||
|
||||
// declared in the header, can't use wxUSE_RENDER_TABLE
|
||||
#if wxCHECK_MOTIF_VERSION( 2, 0 )
|
||||
|
||||
@@ -614,7 +639,7 @@ WXRenderTable wxFont::GetRenderTable(WXDisplay* display) const
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // wxCHECK_MOTIF_VERSION( 2, 0 )
|
||||
|
||||
WXFontType wxFont::GetFontType(WXDisplay* display) const
|
||||
{
|
||||
@@ -642,3 +667,62 @@ WXFontType wxFont::GetFontTypeC(WXDisplay* display) const
|
||||
return (WXString)XmNfontList;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if wxMOTIF_NEW_FONT_HANDLING
|
||||
|
||||
WXFontSet wxFont::GetFontSet(double scale, WXDisplay* display) const
|
||||
{
|
||||
wxXFont* f = GetInternalFont(scale, display);
|
||||
|
||||
if( !f ) return (WXFontSet) 0;
|
||||
|
||||
Arg args[2];
|
||||
int count = 0;
|
||||
|
||||
XtSetArg( args[count], XmNfont, 0 ); ++count;
|
||||
XmRenditionRetrieve( (XmRendition) f->m_rendition, args, count );
|
||||
|
||||
return (WXFontSet) args[0].value;
|
||||
}
|
||||
|
||||
void wxGetTextExtent(WXDisplay* display, const wxFont& font, double scale,
|
||||
const wxString& str,
|
||||
int* width, int* height, int* ascent, int* descent)
|
||||
{
|
||||
XRectangle ink, logical;
|
||||
WXFontSet fset = font.GetFontSet(scale, display);
|
||||
|
||||
XmbTextExtents( (XFontSet)fset, str.c_str(), str.length(), &ink, &logical);
|
||||
|
||||
if( width ) *width = logical.width;
|
||||
if( height ) *height = logical.height;
|
||||
if( ascent ) *ascent = -logical.y;
|
||||
if( descent ) *descent = logical.height + logical.y;
|
||||
}
|
||||
|
||||
#else // if !wxMOTIF_NEW_FONT_HANDLING
|
||||
|
||||
void wxGetTextExtent(WXDisplay* display, const wxFont& font,
|
||||
double scale, const wxString& str,
|
||||
int* width, int* height, int* ascent, int* descent)
|
||||
{
|
||||
WXFontStructPtr pFontStruct = font.GetFontStruct(scale, display);
|
||||
|
||||
int direction, ascent2, descent2;
|
||||
XCharStruct overall;
|
||||
int slen = str.Len();
|
||||
|
||||
XTextExtents((XFontStruct*) pFontStruct, (char*) str.c_str(), slen,
|
||||
&direction, &ascent2, &descent2, &overall);
|
||||
|
||||
if ( width )
|
||||
*width = (overall.width);
|
||||
if ( height )
|
||||
*height = (ascent2 + descent2);
|
||||
if ( descent )
|
||||
*descent = descent2;
|
||||
if ( ascent )
|
||||
*ascent = ascent2;
|
||||
}
|
||||
|
||||
#endif // !wxMOTIF_NEW_FONT_HANDLING
|
||||
|
@@ -161,11 +161,17 @@ wxColour wxSystemSettingsNative::GetColour(wxSystemColour index)
|
||||
|
||||
wxFont wxSystemSettingsNative::GetFont(wxSystemFont index)
|
||||
{
|
||||
int pointSize = 12;
|
||||
|
||||
if ( wxFont::GetDefaultEncoding() == wxFONTENCODING_SHIFT_JIS
|
||||
|| wxFont::GetDefaultEncoding() == wxFONTENCODING_EUC_JP)
|
||||
pointSize = 15;
|
||||
|
||||
switch (index)
|
||||
{
|
||||
case wxSYS_SYSTEM_FIXED_FONT:
|
||||
{
|
||||
return wxFont(12, wxMODERN, wxNORMAL, wxNORMAL, false);
|
||||
return wxFont(pointSize, wxMODERN, wxNORMAL, wxNORMAL, false);
|
||||
break;
|
||||
}
|
||||
case wxSYS_DEVICE_DEFAULT_FONT:
|
||||
@@ -173,7 +179,7 @@ wxFont wxSystemSettingsNative::GetFont(wxSystemFont index)
|
||||
case wxSYS_DEFAULT_GUI_FONT:
|
||||
default:
|
||||
{
|
||||
return wxFont(12, wxSWISS, wxNORMAL, wxNORMAL, false);
|
||||
return wxFont(pointSize, wxSWISS, wxNORMAL, wxNORMAL, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@@ -121,25 +121,35 @@ bool wxTextCtrl::Create(wxWindow *parent,
|
||||
|
||||
Widget parentWidget = (Widget) parent->GetClientWidget();
|
||||
|
||||
bool wantHorizScrolling = ((m_windowStyle & wxHSCROLL) != 0);
|
||||
|
||||
Bool wantHorizScroll = (m_windowStyle & wxHSCROLL) != 0 ? True : False;
|
||||
// If we don't have horizontal scrollbars, we want word wrap.
|
||||
bool wantWordWrap = !wantHorizScrolling;
|
||||
// OpenMotif 2.1 crashes if wantWordWrap is True in Japanese
|
||||
// locale (and probably other multibyte locales). The check might be
|
||||
// more precise
|
||||
#if wxCHECK_LESSTIF() || wxCHECK_MOTIF_VERSION( 2, 2 )
|
||||
Bool wantWordWrap = wantHorizScroll == True ? False : True;
|
||||
#else
|
||||
Bool wantWordWrap = False;
|
||||
#endif
|
||||
|
||||
if (m_windowStyle & wxTE_MULTILINE)
|
||||
{
|
||||
Arg args[2];
|
||||
XtSetArg (args[0], XmNscrollHorizontal, wantHorizScrolling ? True : False);
|
||||
XtSetArg (args[1], XmNwordWrap, wantWordWrap ? True : False);
|
||||
Arg args[8];
|
||||
int count = 0;
|
||||
XtSetArg (args[count], XmNscrollHorizontal, wantHorizScroll); ++count;
|
||||
XtSetArg (args[count], (String) wxFont::GetFontTag(),
|
||||
m_font.GetFontType( XtDisplay(parentWidget) ) ); ++count;
|
||||
XtSetArg (args[count], XmNwordWrap, wantWordWrap); ++count;
|
||||
XtSetArg (args[count], XmNvalue, value.c_str()); ++count;
|
||||
XtSetArg (args[count], XmNeditable,
|
||||
style & wxTE_READONLY ? False : True); ++count;
|
||||
XtSetArg (args[count], XmNeditMode, XmMULTI_LINE_EDIT ); ++count;
|
||||
|
||||
m_mainWidget = (WXWidget) XmCreateScrolledText(parentWidget,
|
||||
m_mainWidget =
|
||||
(WXWidget) XmCreateScrolledText(parentWidget,
|
||||
wxConstCast(name.c_str(), char),
|
||||
args, 2);
|
||||
args, count);
|
||||
|
||||
XtVaSetValues ((Widget) m_mainWidget,
|
||||
XmNeditable, ((style & wxTE_READONLY) ? False : True),
|
||||
XmNeditMode, XmMULTI_LINE_EDIT,
|
||||
NULL);
|
||||
XtManageChild ((Widget) m_mainWidget);
|
||||
}
|
||||
else
|
||||
@@ -149,13 +159,14 @@ bool wxTextCtrl::Create(wxWindow *parent,
|
||||
wxConstCast(name.c_str(), char),
|
||||
xmTextWidgetClass,
|
||||
parentWidget,
|
||||
wxFont::GetFontTag(), m_font.GetFontType( XtDisplay(parentWidget) ),
|
||||
XmNvalue, value.c_str(),
|
||||
XmNeditable, (style & wxTE_READONLY) ?
|
||||
False : True,
|
||||
NULL
|
||||
);
|
||||
|
||||
XtVaSetValues ((Widget) m_mainWidget,
|
||||
XmNeditable, ((style & wxTE_READONLY) ? False : True),
|
||||
NULL);
|
||||
|
||||
#if 0
|
||||
// TODO: Is this relevant? What does it do?
|
||||
int noCols = 2;
|
||||
if (!value.IsNull() && (value.Length() > (unsigned int) noCols))
|
||||
@@ -163,6 +174,7 @@ bool wxTextCtrl::Create(wxWindow *parent,
|
||||
XtVaSetValues((Widget) m_mainWidget,
|
||||
XmNcolumns, noCols,
|
||||
NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
// remove border if asked for
|
||||
@@ -173,15 +185,6 @@ bool wxTextCtrl::Create(wxWindow *parent,
|
||||
NULL);
|
||||
}
|
||||
|
||||
if ( !value.empty() )
|
||||
{
|
||||
// do this instead... MB
|
||||
//
|
||||
XtVaSetValues( (Widget) m_mainWidget,
|
||||
XmNvalue, wxConstCast(value.c_str(), char),
|
||||
NULL);
|
||||
}
|
||||
|
||||
// install callbacks
|
||||
XtAddCallback((Widget) m_mainWidget, XmNvalueChangedCallback, (XtCallbackProc)wxTextWindowChangedProc, (XtPointer)this);
|
||||
|
||||
@@ -193,9 +196,6 @@ bool wxTextCtrl::Create(wxWindow *parent,
|
||||
|
||||
XtAddCallback((Widget) m_mainWidget, XmNlosingFocusCallback, (XtCallbackProc)wxTextWindowLoseFocusProc, (XtPointer)this);
|
||||
|
||||
// font
|
||||
ChangeFont(false);
|
||||
|
||||
AttachWidget (parent, m_mainWidget, (WXWidget) NULL,
|
||||
pos.x, pos.y, size.x, size.y);
|
||||
|
||||
@@ -242,21 +242,18 @@ wxString wxTextCtrl::GetValue() const
|
||||
return str;
|
||||
}
|
||||
|
||||
void wxTextCtrl::SetValue(const wxString& value)
|
||||
void wxTextCtrl::SetValue(const wxString& text)
|
||||
{
|
||||
m_inSetValue = true;
|
||||
|
||||
// do this instead... MB
|
||||
//
|
||||
// with (at least) OpenMotif 2.1 this causes a lot of flicker
|
||||
#if 0
|
||||
XtVaSetValues( (Widget) m_mainWidget,
|
||||
XmNvalue, wxConstCast(value.c_str(), char),
|
||||
XmTextSetString ((Widget) m_mainWidget, wxConstCast(text.c_str(), char));
|
||||
XtVaSetValues ((Widget) m_mainWidget,
|
||||
XmNcursorPosition, text.length(),
|
||||
NULL);
|
||||
#endif
|
||||
|
||||
Clear();
|
||||
AppendText( value );
|
||||
SetInsertionPoint(text.length());
|
||||
XmTextShowPosition ((Widget) m_mainWidget, text.length());
|
||||
m_modified = TRUE;
|
||||
|
||||
m_inSetValue = false;
|
||||
}
|
||||
|
@@ -1464,29 +1464,24 @@ int wxWindow::GetCharHeight() const
|
||||
{
|
||||
wxCHECK_MSG( m_font.Ok(), 0, "valid window font needed" );
|
||||
|
||||
WXFontStructPtr pFontStruct = m_font.GetFontStruct(1.0, GetXDisplay());
|
||||
int height;
|
||||
|
||||
int direction, ascent, descent;
|
||||
XCharStruct overall;
|
||||
XTextExtents ((XFontStruct*) pFontStruct, "x", 1, &direction, &ascent,
|
||||
&descent, &overall);
|
||||
wxGetTextExtent (GetXDisplay(), m_font, 1.0,
|
||||
"x", NULL, &height, NULL, NULL);
|
||||
|
||||
// return (overall.ascent + overall.descent);
|
||||
return (ascent + descent);
|
||||
return height;
|
||||
}
|
||||
|
||||
int wxWindow::GetCharWidth() const
|
||||
{
|
||||
wxCHECK_MSG( m_font.Ok(), 0, "valid window font needed" );
|
||||
|
||||
WXFontStructPtr pFontStruct = m_font.GetFontStruct(1.0, GetXDisplay());
|
||||
int width;
|
||||
|
||||
int direction, ascent, descent;
|
||||
XCharStruct overall;
|
||||
XTextExtents ((XFontStruct*) pFontStruct, "x", 1, &direction, &ascent,
|
||||
&descent, &overall);
|
||||
wxGetTextExtent (GetXDisplay(), m_font, 1.0,
|
||||
"x", &width, NULL, NULL, NULL);
|
||||
|
||||
return overall.width;
|
||||
return width;
|
||||
}
|
||||
|
||||
void wxWindow::GetTextExtent(const wxString& string,
|
||||
@@ -1494,36 +1489,14 @@ void wxWindow::GetTextExtent(const wxString& string,
|
||||
int *descent, int *externalLeading,
|
||||
const wxFont *theFont) const
|
||||
{
|
||||
wxFont *fontToUse = (wxFont *)theFont;
|
||||
if (!fontToUse)
|
||||
fontToUse = (wxFont *) & m_font;
|
||||
const wxFont *fontToUse = theFont ? theFont : &m_font;
|
||||
|
||||
wxCHECK_RET( fontToUse->Ok(), "valid window font needed" );
|
||||
|
||||
WXFontStructPtr pFontStruct = fontToUse->GetFontStruct(1.0, GetXDisplay());
|
||||
|
||||
int direction, ascent, descent2;
|
||||
XCharStruct overall;
|
||||
int slen = string.Len();
|
||||
|
||||
#if 0
|
||||
if (use16)
|
||||
XTextExtents16((XFontStruct*) pFontStruct, (XChar2b *) (char*) (const char*) string, slen, &direction,
|
||||
&ascent, &descent2, &overall);
|
||||
#endif
|
||||
|
||||
XTextExtents((XFontStruct*) pFontStruct, string, slen,
|
||||
&direction, &ascent, &descent2, &overall);
|
||||
|
||||
if ( x )
|
||||
*x = (overall.width);
|
||||
if ( y )
|
||||
*y = (ascent + descent2);
|
||||
if (descent)
|
||||
*descent = descent2;
|
||||
if (externalLeading)
|
||||
*externalLeading = 0;
|
||||
|
||||
wxGetTextExtent (GetXDisplay(), *fontToUse, 1.0,
|
||||
string, x, y, NULL, descent);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@@ -31,6 +31,7 @@
|
||||
*wxEVT_MEDIA_LOADED*;
|
||||
*wxGenericListCtrl*SetItemFont*wxFont*;
|
||||
*wxGenericListCtrl*GetItemFont*;
|
||||
*wxGetTextExtent*wxFont*wxString*;
|
||||
*wxImage*HSVValue*;
|
||||
*wxImage*RGBValue*;
|
||||
*wxImage*RotateHue*;
|
||||
|
Reference in New Issue
Block a user