[Commits] (davids) colheader:
commits at osafoundation.org
commits at osafoundation.org
Fri Apr 22 10:55:03 PDT 2005
Commit by: davids
Modified files:
internal/wxPython-2.5/include/wx/colheader.h 1.10 1.11
internal/wxPython-2.5/include/wx/generic/colheader.h 1.38 1.39
internal/wxPython-2.5/src/generic/colheader.cpp 1.77 1.78
internal/wxPython-2.5/wxPython/demo/ColumnHeader.py 1.28 1.29
internal/wxPython-2.5/wxPython/src/colheader.i 1.18 1.19
Log message:
colheader:
- made item class member var protected
- added color text selection style stub
- checkpoint for label text ellipses truncation
r=TBD
ViewCVS links:
http://cvs.osafoundation.org/index.cgi/internal/wxPython-2.5/include/wx/colheader.h.diff?r1=text&tr1=1.10&r2=text&tr2=1.11
http://cvs.osafoundation.org/index.cgi/internal/wxPython-2.5/include/wx/generic/colheader.h.diff?r1=text&tr1=1.38&r2=text&tr2=1.39
http://cvs.osafoundation.org/index.cgi/internal/wxPython-2.5/src/generic/colheader.cpp.diff?r1=text&tr1=1.77&r2=text&tr2=1.78
http://cvs.osafoundation.org/index.cgi/internal/wxPython-2.5/wxPython/demo/ColumnHeader.py.diff?r1=text&tr1=1.28&r2=text&tr2=1.29
http://cvs.osafoundation.org/index.cgi/internal/wxPython-2.5/wxPython/src/colheader.i.diff?r1=text&tr1=1.18&r2=text&tr2=1.19
Index: internal/wxPython-2.5/src/generic/colheader.cpp
diff -u internal/wxPython-2.5/src/generic/colheader.cpp:1.77 internal/wxPython-2.5/src/generic/colheader.cpp:1.78
--- internal/wxPython-2.5/src/generic/colheader.cpp:1.77 Thu Apr 21 11:45:45 2005
+++ internal/wxPython-2.5/src/generic/colheader.cpp Fri Apr 22 10:54:59 2005
@@ -709,7 +709,7 @@
long newWidth )
{
long scaleItemCount, scaleItemAmount, i;
-long deltaX, summerX, originX, incX;
+long deltaX, summerX, resultX, originX, incX;
if ((newWidth <= 0) || (m_ItemList == NULL))
return false;
@@ -749,7 +749,13 @@
incX = (deltaX * m_ItemList[i]->m_ExtentX) / scaleItemAmount;
else
incX = summerX;
- m_ItemList[i]->m_ExtentX += incX;
+
+ if (incX != 0)
+ {
+ resultX = m_ItemList[i]->m_ExtentX + incX;
+ m_ItemList[i]->ResizeToWidth( resultX );
+ }
+
summerX -= incX;
}
@@ -1745,6 +1751,7 @@
info->m_TextJust = m_TextJust;
info->m_LabelTextExtent = m_LabelTextExtent;
+ info->m_LabelTextVisibleCharCount = m_LabelTextVisibleCharCount;
info->m_OriginX = m_OriginX;
info->m_ExtentX = m_ExtentX;
info->m_BEnabled = m_BEnabled;
@@ -1768,6 +1775,7 @@
m_TextJust = info->m_TextJust;
m_LabelTextExtent = info->m_LabelTextExtent;
+ m_LabelTextVisibleCharCount = info->m_LabelTextVisibleCharCount;
m_OriginX = info->m_OriginX;
m_ExtentX = info->m_ExtentX;
m_BEnabled = info->m_BEnabled;
@@ -1867,6 +1875,12 @@
// if ((originX >= 0) && (m_OriginX != originX))
// m_OriginX = originX;
+ ResizeToWidth( extentX );
+}
+
+void wxColumnHeaderItem::ResizeToWidth(
+ long extentX )
+{
if ((extentX >= 0) && (m_ExtentX != extentX))
m_ExtentX = extentX;
}
@@ -2113,7 +2127,7 @@
descentY = 1;
if ((m_LabelTextExtent.y > 0) && (m_LabelTextExtent.y < localBoundsR.height))
- descentY = ((localBoundsR.height - m_LabelTextExtent.y) / 2);
+ descentY = (localBoundsR.height - m_LabelTextExtent.y) / 2;
// FIXME: need to clip long text items
dc->DrawText( m_LabelTextRef.c_str(), startX, localBoundsR.y + descentY );
@@ -2137,6 +2151,46 @@
return 0;
}
+long wxColumnHeaderItem::CalculateTextExtent(
+ wxDC *dc,
+ bool bForceRecalc )
+{
+wxCoord targetWidth, targetHeight;
+long startX, originX, maxExtentX;
+long charCount;
+
+ if (dc == NULL)
+ return (-1);
+
+ if (bForceRecalc || (m_LabelTextExtent.x < 0) || (m_LabelTextExtent.y < 0))
+ {
+ charCount = m_LabelTextRef.length();
+ if (charCount > 0)
+ {
+ dc->GetTextExtent(
+ m_LabelTextRef,
+ &targetWidth, &targetHeight,
+ NULL, NULL, NULL );
+
+ m_LabelTextExtent.x = targetWidth;
+ m_LabelTextExtent.y = targetHeight;
+ }
+ else
+ {
+ m_LabelTextExtent.x =
+ m_LabelTextExtent.y = 0;
+ }
+
+ m_LabelTextVisibleCharCount = charCount;
+
+ GetTextUIExtent( startX, originX, maxExtentX );
+ if (m_LabelTextExtent.x > maxExtentX)
+ m_LabelTextVisibleCharCount = (-m_LabelTextVisibleCharCount);
+ }
+
+ return m_LabelTextExtent.x;
+}
+
long wxColumnHeaderItem::TruncateLabelText(
wxDC *dc,
wxString &targetStr,
@@ -2252,33 +2306,12 @@
startX += leftDeltaX;
}
-long wxColumnHeaderItem::CalculateTextExtent(
- wxDC *dc,
- bool bForceRecalc )
-{
-wxCoord targetWidth, targetHeight;
-
- if (dc == NULL)
- return (-1);
-
- if (bForceRecalc || (m_LabelTextExtent.x < 0) || (m_LabelTextExtent.y < 0))
- {
- dc->GetTextExtent(
- m_LabelTextRef,
- &targetWidth, &targetHeight,
- NULL, NULL, NULL );
-
- m_LabelTextExtent.x = targetWidth;
- m_LabelTextExtent.y = targetHeight;
- }
-
- return m_LabelTextExtent.x;
-}
-
void wxColumnHeaderItem::InvalidateTextExtent( void )
{
m_LabelTextExtent.x =
m_LabelTextExtent.y = (-1);
+
+ m_LabelTextVisibleCharCount = (-1);
}
// ================
@@ -2358,6 +2391,7 @@
// performed elsewheres or not at all
break;
+ case CH_SELECTIONDRAWSTYLE_ColourLabel:
case CH_SELECTIONDRAWSTYLE_Grey:
case CH_SELECTIONDRAWSTYLE_InvertBevel:
case CH_SELECTIONDRAWSTYLE_Bullet:
Index: internal/wxPython-2.5/include/wx/colheader.h
diff -u internal/wxPython-2.5/include/wx/colheader.h:1.10 internal/wxPython-2.5/include/wx/colheader.h:1.11
--- internal/wxPython-2.5/include/wx/colheader.h:1.10 Mon Apr 18 14:55:58 2005
+++ internal/wxPython-2.5/include/wx/colheader.h Fri Apr 22 10:54:58 2005
@@ -66,6 +66,7 @@
CH_SELECTIONDRAWSTYLE_None,
CH_SELECTIONDRAWSTYLE_Native,
CH_SELECTIONDRAWSTYLE_BoldLabel,
+ CH_SELECTIONDRAWSTYLE_ColourLabel,
CH_SELECTIONDRAWSTYLE_Grey,
CH_SELECTIONDRAWSTYLE_InvertBevel,
CH_SELECTIONDRAWSTYLE_Underline,
Index: internal/wxPython-2.5/wxPython/demo/ColumnHeader.py
diff -u internal/wxPython-2.5/wxPython/demo/ColumnHeader.py:1.28 internal/wxPython-2.5/wxPython/demo/ColumnHeader.py:1.29
--- internal/wxPython-2.5/wxPython/demo/ColumnHeader.py:1.28 Mon Apr 18 14:56:00 2005
+++ internal/wxPython-2.5/wxPython/demo/ColumnHeader.py Fri Apr 22 10:54:59 2005
@@ -82,7 +82,7 @@
btn = wx.Button( self, -1, "Resize Bounds", (self.colStartX, miscControlsY + 30) )
self.Bind( wx.EVT_BUTTON, self.OnButtonTestResizeBounds, btn )
- styleList = ['None', 'Native', 'BoldLabel', 'Grey', 'InvertBevel', 'Underline', 'Overline', 'Frame', 'Bullet']
+ styleList = ['None', 'Native', 'BoldLabel', 'ColourLabel', 'Grey', 'InvertBevel', 'Underline', 'Overline', 'Frame', 'Bullet']
wx.StaticText( self, -1, "Selection Style:", (self.colStartX, miscControlsY + 75), (150, -1) )
choice = wx.Choice( self, -1, (self.colStartX, miscControlsY + 95), choices = styleList )
choice.SetSelection( ch1.GetSelectionDrawStyle() )
Index: internal/wxPython-2.5/include/wx/generic/colheader.h
diff -u internal/wxPython-2.5/include/wx/generic/colheader.h:1.38 internal/wxPython-2.5/include/wx/generic/colheader.h:1.39
--- internal/wxPython-2.5/include/wx/generic/colheader.h:1.38 Tue Apr 19 15:22:21 2005
+++ internal/wxPython-2.5/include/wx/generic/colheader.h Fri Apr 22 10:54:58 2005
@@ -24,8 +24,8 @@
// forward decls
-// class wxColumnHeaderItem;
// class wxBitmap;
+class wxColumnHeaderItem;
// ----------------------------------------------------------------------------
// private data definitions
@@ -42,128 +42,6 @@
}
wxColumnHeaderMetric;
-class wxColumnHeaderItem
-{
-public:
- wxColumnHeaderItem(
- const wxColumnHeaderItem *info );
- wxColumnHeaderItem();
- virtual ~wxColumnHeaderItem();
-
- long HitTest(
- const wxPoint &locationPt ) const;
-
- void GetItemData(
- wxColumnHeaderItem *info ) const;
- void SetItemData(
- const wxColumnHeaderItem *info );
-
- void GetBitmapRef(
- wxBitmap &bitmapRef ) const;
- void SetBitmapRef(
- wxBitmap &bitmapRef,
- const wxRect *boundsR );
-
- void GetLabelText(
- wxString &textBuffer ) const;
- void SetLabelText(
- const wxString &textBuffer );
-
- long GetLabelJustification( void ) const;
- void SetLabelJustification(
- long textJust );
-
- void GetUIExtent(
- long &originX,
- long &extentX ) const;
- void SetUIExtent(
- long originX,
- long extentX );
-
- void GetTextUIExtent(
- long &startX,
- long &originX,
- long &extentX ) const;
-
- bool GetAttribute(
- wxColumnHeaderItemAttribute flagEnum ) const;
- bool SetAttribute(
- wxColumnHeaderItemAttribute flagEnum,
- bool bFlagValue );
-
- long GenericDrawItem(
- wxWindow *parentW,
- wxDC *dc,
- const wxRect *boundsR,
- bool bUseUnicode,
- bool bVisibleSelection );
-
-#if defined(__WXMAC__)
- long MacDrawItem(
- wxWindow *parentW,
- wxDC *dc,
- const wxRect *boundsR,
- bool bUseUnicode,
- bool bVisibleSelection );
-#endif
-
- long TruncateLabelText(
- wxDC *dc,
- wxString &targetStr,
- long maxWidth,
- long &charCount );
- long CalculateTextExtent(
- wxDC *dc,
- bool bForceRecalc );
- void InvalidateTextExtent( void );
-
-public:
- static void GenericDrawSelection(
- wxDC *dc,
- const wxRect *boundsR,
- const wxColour *targetColour,
- long drawStyle );
-
- static void GenericDrawSortArrow(
- wxDC *dc,
- const wxRect *boundsR,
- bool bSortAscending );
- static void GenericGetSortArrowBounds(
- const wxRect *itemBoundsR,
- wxRect *targetBoundsR );
- static void GenericGetBitmapItemBounds(
- const wxRect *itemBoundsR,
- long targetJustification,
- const wxBitmap *targetBitmap,
- wxRect *targetBoundsR );
-
-#if defined(__WXMAC__)
- static void MacDrawThemeBackgroundNoArrows(
- const void *boundsR,
- bool bSelected );
-#endif
-
- static bool HasValidBitmapRef(
- const wxBitmap *bitmapRef );
-
- static long ConvertJustification(
- long sourceEnum,
- bool bToNative );
-
-public:
- wxString m_LabelTextRef;
- wxSize m_LabelTextExtent;
- long m_TextJust;
- wxBitmap *m_BitmapRef;
- long m_OriginX;
- long m_ExtentX;
- bool m_BEnabled;
- bool m_BSelected;
- bool m_BSortEnabled;
- bool m_BSortAscending;
- bool m_BFixedWidth;
-};
-
class WXDLLIMPEXP_ADV wxColumnHeader : public wxControl
{
public:
@@ -378,4 +256,130 @@
DECLARE_NO_COPY_CLASS(wxColumnHeader)
};
+class wxColumnHeaderItem
+{
+friend class wxColumnHeader;
+
+public:
+ wxColumnHeaderItem(
+ const wxColumnHeaderItem *info );
+ wxColumnHeaderItem();
+ virtual ~wxColumnHeaderItem();
+
+ long HitTest(
+ const wxPoint &locationPt ) const;
+
+ void GetItemData(
+ wxColumnHeaderItem *info ) const;
+ void SetItemData(
+ const wxColumnHeaderItem *info );
+
+ void GetBitmapRef(
+ wxBitmap &bitmapRef ) const;
+ void SetBitmapRef(
+ wxBitmap &bitmapRef,
+ const wxRect *boundsR );
+
+ void GetLabelText(
+ wxString &textBuffer ) const;
+ void SetLabelText(
+ const wxString &textBuffer );
+
+ long GetLabelJustification( void ) const;
+ void SetLabelJustification(
+ long textJust );
+
+ void GetUIExtent(
+ long &originX,
+ long &extentX ) const;
+ void SetUIExtent(
+ long originX,
+ long extentX );
+
+ bool GetAttribute(
+ wxColumnHeaderItemAttribute flagEnum ) const;
+ bool SetAttribute(
+ wxColumnHeaderItemAttribute flagEnum,
+ bool bFlagValue );
+
+ long GenericDrawItem(
+ wxWindow *parentW,
+ wxDC *dc,
+ const wxRect *boundsR,
+ bool bUseUnicode,
+ bool bVisibleSelection );
+
+#if defined(__WXMAC__)
+ long MacDrawItem(
+ wxWindow *parentW,
+ wxDC *dc,
+ const wxRect *boundsR,
+ bool bUseUnicode,
+ bool bVisibleSelection );
+#endif
+
+ void ResizeToWidth(
+ long extentX );
+ void GetTextUIExtent(
+ long &startX,
+ long &originX,
+ long &extentX ) const;
+ long TruncateLabelText(
+ wxDC *dc,
+ wxString &targetStr,
+ long maxWidth,
+ long &charCount );
+ long CalculateTextExtent(
+ wxDC *dc,
+ bool bForceRecalc );
+ void InvalidateTextExtent( void );
+
+public:
+ static void GenericDrawSelection(
+ wxDC *dc,
+ const wxRect *boundsR,
+ const wxColour *targetColour,
+ long drawStyle );
+
+ static void GenericDrawSortArrow(
+ wxDC *dc,
+ const wxRect *boundsR,
+ bool bSortAscending );
+ static void GenericGetSortArrowBounds(
+ const wxRect *itemBoundsR,
+ wxRect *targetBoundsR );
+ static void GenericGetBitmapItemBounds(
+ const wxRect *itemBoundsR,
+ long targetJustification,
+ const wxBitmap *targetBitmap,
+ wxRect *targetBoundsR );
+
+#if defined(__WXMAC__)
+ static void MacDrawThemeBackgroundNoArrows(
+ const void *boundsR,
+ bool bSelected );
+#endif
+
+ static bool HasValidBitmapRef(
+ const wxBitmap *bitmapRef );
+
+ static long ConvertJustification(
+ long sourceEnum,
+ bool bToNative );
+
+protected:
+ wxString m_LabelTextRef;
+ wxSize m_LabelTextExtent;
+ long m_LabelTextVisibleCharCount;
+ long m_TextJust;
+ wxBitmap *m_BitmapRef;
+ long m_OriginX;
+ long m_ExtentX;
+ bool m_BEnabled;
+ bool m_BSelected;
+ bool m_BSortEnabled;
+ bool m_BSortAscending;
+ bool m_BFixedWidth;
+};
+
#endif // _WX_GENERIC_COLUMNHEADER_H
Index: internal/wxPython-2.5/wxPython/src/colheader.i
diff -u internal/wxPython-2.5/wxPython/src/colheader.i:1.18 internal/wxPython-2.5/wxPython/src/colheader.i:1.19
--- internal/wxPython-2.5/wxPython/src/colheader.i:1.18 Mon Apr 18 14:56:00 2005
+++ internal/wxPython-2.5/wxPython/src/colheader.i Fri Apr 22 10:55:00 2005
@@ -67,6 +67,7 @@
CH_SELECTIONDRAWSTYLE_None,
CH_SELECTIONDRAWSTYLE_Native,
CH_SELECTIONDRAWSTYLE_BoldLabel,
+ CH_SELECTIONDRAWSTYLE_ColourLabel,
CH_SELECTIONDRAWSTYLE_Grey,
CH_SELECTIONDRAWSTYLE_InvertBevel,
CH_SELECTIONDRAWSTYLE_Underline,
More information about the Commits
mailing list