#ifndef WX_PRECOMP
#include "wx/intl.h"
+ #include "wx/settings.h"
#endif
#include "wx/mac/uma.h"
}
/*static*/
-wxVisualAttributes wxListCtrl::GetClassDefaultAttributes(wxWindowVariant variant)
+wxVisualAttributes
+wxListCtrl::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
{
wxVisualAttributes attr;
if (m_dbImpl)
{
- int mywidth = width;
- if (width == wxLIST_AUTOSIZE || width == wxLIST_AUTOSIZE_USEHEADER)
- mywidth = 150;
+ if ( width == wxLIST_AUTOSIZE_USEHEADER )
+ {
+ width = 150; // FIXME
+ }
if (col == -1)
{
for (int column = 0; column < GetColumnCount(); column++)
{
wxListItem colInfo;
- GetColumn(col, colInfo);
+ GetColumn(column, colInfo);
colInfo.SetWidth(width);
- SetColumn(col, colInfo);
+ SetColumn(column, colInfo);
- m_dbImpl->SetColumnWidth(col, mywidth);
+ const int mywidth = (width == wxLIST_AUTOSIZE)
+ ? CalcColumnAutoWidth(column) : width;
+ m_dbImpl->SetColumnWidth(column, mywidth);
}
}
else
{
+ if ( width == wxLIST_AUTOSIZE )
+ width = CalcColumnAutoWidth(col);
+
wxListItem colInfo;
GetColumn(col, colInfo);
colInfo.SetWidth(width);
SetColumn(col, colInfo);
- m_dbImpl->SetColumnWidth(col, mywidth);
+ m_dbImpl->SetColumnWidth(col, width);
}
return true;
}
}
CGContextSaveGState(context);
- CGContextSetRGBFillColor(context, (float)backgroundColor.red / (float)USHRT_MAX,
- (float)backgroundColor.green / (float)USHRT_MAX,
- (float)backgroundColor.blue / (float)USHRT_MAX, 1.0);
+ CGContextSetRGBFillColor(context, (CGFloat)backgroundColor.red / (CGFloat)USHRT_MAX,
+ (CGFloat)backgroundColor.green / (CGFloat)USHRT_MAX,
+ (CGFloat)backgroundColor.blue / (CGFloat)USHRT_MAX, (CGFloat) 1.0);
CGContextFillRect(context, enclosingCGRect);
CGContextRestoreGState(context);
bgColor.GetRGBColor(&backgroundColor);
CGContextSaveGState(context);
- CGContextSetRGBFillColor(context, (float)backgroundColor.red / (float)USHRT_MAX,
- (float)backgroundColor.green / (float)USHRT_MAX,
- (float)backgroundColor.blue / (float)USHRT_MAX, 1.0);
+ CGContextSetRGBFillColor(context, (CGFloat)backgroundColor.red / (CGFloat)USHRT_MAX,
+ (CGFloat)backgroundColor.green / (CGFloat)USHRT_MAX,
+ (CGFloat)backgroundColor.blue / (CGFloat)USHRT_MAX, (CGFloat) 1.0);
CGContextFillRect(context, enclosingCGRect);
CGContextRestoreGState(context);
info.truncationMaxLines = 1;
CGContextSaveGState(context);
- CGContextSetRGBFillColor (context, (float)labelColor.red / (float)USHRT_MAX,
- (float)labelColor.green / (float)USHRT_MAX,
- (float)labelColor.blue / (float)USHRT_MAX, 1.0);
+ CGContextSetRGBFillColor (context, (CGFloat)labelColor.red / (CGFloat)USHRT_MAX,
+ (CGFloat)labelColor.green / (CGFloat)USHRT_MAX,
+ (CGFloat)labelColor.blue / (CGFloat)USHRT_MAX, (CGFloat) 1.0);
HIThemeDrawTextBox(cfString, &textCGRect, &info, context, kHIThemeOrientationNormal);
OSStatus err = errDataBrowserPropertyNotSupported;
wxListCtrl* list = wxDynamicCast( GetPeer() , wxListCtrl );
- wxMacListCtrlItem* lcItem;
+ wxMacListCtrlItem* lcItem = NULL;
if (listColumn >= 0)
{
}
}
+int wxListCtrl::CalcColumnAutoWidth(int col) const
+{
+ int width = 0;
+
+ for ( int i = 0; i < GetItemCount(); i++ )
+ {
+ wxListItem info;
+ info.SetMask(wxLIST_MASK_TEXT | wxLIST_MASK_IMAGE);
+ info.SetId(i);
+ info.SetColumn(col);
+ GetItem(info);
+
+ const wxFont font = info.GetFont();
+
+ int w = 0;
+ if ( font.IsOk() )
+ GetTextExtent(info.GetText(), &w, NULL, NULL, NULL, &font);
+ else
+ GetTextExtent(info.GetText(), &w, NULL);
+
+ w += 2 * kItemPadding;
+
+ if ( info.GetImage() != -1 )
+ w += kIconWidth;
+
+ width = wxMax(width, w);
+ }
+
+ return width;
+}
+
#endif // wxUSE_LISTCTRL