[Commits] (davids) colheader - cleaned up font handling;
checkpoint of text measurement support
commits at osafoundation.org
commits at osafoundation.org
Wed Apr 6 10:11:32 PDT 2005
Commit by: davids
Modified files:
internal/wxPython-2.5/include/wx/generic/colheader.h 1.21 1.22
internal/wxPython-2.5/src/generic/colheader.cpp 1.48 1.49
Log message:
colheader - cleaned up font handling; checkpoint of text measurement support
r=TBD
ViewCVS links:
http://cvs.osafoundation.org/index.cgi/internal/wxPython-2.5/include/wx/generic/colheader.h.diff?r1=text&tr1=1.21&r2=text&tr2=1.22
http://cvs.osafoundation.org/index.cgi/internal/wxPython-2.5/src/generic/colheader.cpp.diff?r1=text&tr1=1.48&r2=text&tr2=1.49
Index: internal/wxPython-2.5/src/generic/colheader.cpp
diff -u internal/wxPython-2.5/src/generic/colheader.cpp:1.48 internal/wxPython-2.5/src/generic/colheader.cpp:1.49
--- internal/wxPython-2.5/src/generic/colheader.cpp:1.48 Tue Apr 5 11:35:08 2005
+++ internal/wxPython-2.5/src/generic/colheader.cpp Wed Apr 6 10:11:31 2005
@@ -166,6 +166,13 @@
m_BProportionalResizing = true;
m_BVisibleSelection = true;
+#if defined(__WXMAC__)
+ // NB: or kThemeSystemFontTag, kThemeViewsFontTag
+ m_Font.MacCreateThemeFont( kThemeSmallSystemFont );
+#else
+ m_Font.SetFamily( 0 );
+#endif
+
#if wxUSE_UNICODE
m_BUseUnicode = true;
#else
@@ -831,12 +838,6 @@
// set invariant values
itemInfo.m_BEnabled = true;
-#if defined(__WXMAC__)
- itemInfo.m_FontID = kThemeSmallSystemFont; // or kThemeSystemFontTag, kThemeViewsFontTag
-#else
- itemInfo.m_FontID = 0;
-#endif
-
// set specified values
itemInfo.m_LabelTextRef = textBuffer;
itemInfo.m_TextJust = textJust;
@@ -1274,12 +1275,12 @@
#else
wxClientDC dc( this );
- // NB: this case being used for both Mac and Generic
+ dc.SetFont( m_Font );
+
for (long i=0; i<m_ItemCount; i++)
if (GetItemBounds( i, &boundsR ))
{
#if defined(__WXMAC__)
- // no DC needed for Mac rendering (except for bitmaps)
resultV |= m_ItemList[i]->MacDrawItem( this, &dc, &boundsR, m_BUseUnicode, m_BVisibleSelection );
#else
resultV |= m_ItemList[i]->GenericDrawItem( this, &dc, &boundsR, m_BUseUnicode, m_BVisibleSelection );
@@ -1320,6 +1321,51 @@
}
}
+long wxColumnHeader::GetLabelWidth(
+ wxClientDC *dc,
+ const wxString &targetStr )
+{
+long resultV;
+
+ resultV = 0;
+
+ if (targetStr.IsEmpty())
+ return 0;
+
+#if defined(__WXMAC__)
+wxMacCFStringHolder cfString( targetStr, m_Font.GetEncoding() );
+Point xyPt;
+SInt16 baselineV;
+
+ xyPt.h = xyPt.v = 0;
+
+ GetThemeTextDimensions(
+ (CFStringRef)cfString,
+ m_Font.MacGetThemeFontID(),
+ kThemeStateActive,
+ false,
+ &xyPt,
+ &baselineV );
+
+ resultV = (long)(xyPt.h);
+
+#else
+wxCoord targetWidth;
+
+ if (dc != NULL)
+ {
+ dc->SetFont( m_Font );
+ dc->DoGetTextExtent(
+ targetStr, &targetWidth,
+ NULL, NULL, NULL, NULL );
+
+ resultV = (long)targetWidth;
+ }
+#endif
+
+ return resultV;
+}
+
// ================
#if 0
#pragma mark -
@@ -1562,8 +1608,7 @@
wxColumnHeaderItem::wxColumnHeaderItem()
:
- m_FontID( 0 )
- , m_TextJust( 0 )
+ m_TextJust( 0 )
, m_BitmapRef( NULL )
, m_OriginX( 0 )
, m_ExtentX( 0 )
@@ -1578,8 +1623,7 @@
wxColumnHeaderItem::wxColumnHeaderItem(
const wxColumnHeaderItem *info )
:
- m_FontID( 0 )
- , m_TextJust( 0 )
+ m_TextJust( 0 )
, m_BitmapRef( NULL )
, m_OriginX( 0 )
, m_ExtentX( 0 )
@@ -1605,7 +1649,6 @@
if (info == NULL)
return;
- info->m_FontID = m_FontID;
info->m_TextJust = m_TextJust;
info->m_OriginX = m_OriginX;
info->m_ExtentX = m_ExtentX;
@@ -1628,7 +1671,6 @@
if (info == NULL)
return;
- m_FontID = info->m_FontID;
m_TextJust = info->m_TextJust;
m_OriginX = info->m_OriginX;
m_ExtentX = info->m_ExtentX;
@@ -1830,6 +1872,7 @@
RgnHandle savedClipRgn;
Rect qdBoundsR;
long nativeTextJust;
+SInt16 nativeFontID;
bool bSelected, bHasIcon;
OSStatus errStatus;
@@ -1895,13 +1938,16 @@
// render the label text as/if specified
if (! bHasIcon && ! m_LabelTextRef.IsEmpty())
{
+ nativeFontID = dc->GetFont().MacGetThemeFontID();
+
if (bUseUnicode)
{
wxMacCFStringHolder localCFSHolder( m_LabelTextRef, wxFONTENCODING_UNICODE );
errStatus =
(OSStatus)DrawThemeTextBox(
- (CFStringRef)localCFSHolder, m_FontID, drawInfo.state, true,
+ (CFStringRef)localCFSHolder,
+ nativeFontID, drawInfo.state, true,
&qdBoundsR, nativeTextJust, NULL );
}
else
@@ -1913,7 +1959,8 @@
{
errStatus =
(OSStatus)DrawThemeTextBox(
- cfLabelText, m_FontID, drawInfo.state, true,
+ cfLabelText,
+ nativeFontID, drawInfo.state, true,
&qdBoundsR, nativeTextJust, NULL );
CFRelease( cfLabelText );
Index: internal/wxPython-2.5/include/wx/generic/colheader.h
diff -u internal/wxPython-2.5/include/wx/generic/colheader.h:1.21 internal/wxPython-2.5/include/wx/generic/colheader.h:1.22
--- internal/wxPython-2.5/include/wx/generic/colheader.h:1.21 Tue Apr 5 11:35:07 2005
+++ internal/wxPython-2.5/include/wx/generic/colheader.h Wed Apr 6 10:11:30 2005
@@ -135,7 +135,6 @@
public:
wxString m_LabelTextRef;
- unsigned long m_FontID;
long m_TextJust;
wxBitmap *m_BitmapRef;
long m_OriginX;
@@ -295,9 +294,13 @@
void RefreshItem(
long itemIndex );
+ long GetLabelWidth(
+ wxClientDC *dc,
+ const wxString &targetStr );
+
+ void DisposeItemList( void );
void SetViewDirty( void );
void RecalculateItemExtents( void );
- void DisposeItemList( void );
long Draw( void );
@@ -328,7 +331,7 @@
#endif
protected:
- // common part of all ctors
+ // called by all ctors
void Init( void );
// event handlers
@@ -341,6 +344,7 @@
protected:
wxRect m_NativeBoundsR;
+ wxFont m_Font;
wxColumnHeaderItem **m_ItemList;
long m_ItemCount;
long m_ItemSelected;
@@ -348,10 +352,6 @@
bool m_BVisibleSelection;
bool m_BUseUnicode;
- // fonts
- wxFont m_normalFont;
- wxFont m_boldFont;
-
DECLARE_DYNAMIC_CLASS(wxColumnHeader)
DECLARE_EVENT_TABLE()
DECLARE_NO_COPY_CLASS(wxColumnHeader)
More information about the Commits
mailing list