#include "wx/imaglist.h"
#include "wx/listctrl.h"
-#ifdef __WXGTK__
+#if defined(__WXGTK__)
#include <gtk/gtk.h>
#include "wx/gtk/win_gtk.h"
#endif
#ifdef __WXMAC__
return *wxWHITE;
#else
- return wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DLIGHT);
+ return wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT);
#endif
}
wxColour colText;
if ( highlighted )
{
- colText = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_HIGHLIGHTTEXT);
+ colText = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT);
}
else
{
m_owner = owner;
m_resizeCursor = new wxCursor( wxCURSOR_SIZEWE );
- SetBackgroundColour( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE ) );
+ SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) );
}
wxListHeaderWindow::~wxListHeaderWindow()
void wxListHeaderWindow::DoDrawRect( wxDC *dc, int x, int y, int w, int h )
{
-#ifdef __WXGTK__
+#if defined(__WXGTK__) && !defined(__WXUNIVERSAL__)
GtkStateType state = m_parent->IsEnabled() ? GTK_STATE_NORMAL
: GTK_STATE_INSENSITIVE;
gtk_paint_box (m_wxwindow->style, GTK_PIZZA(m_wxwindow)->bin_window,
state, GTK_SHADOW_OUT,
- (GdkRectangle*) NULL, m_wxwindow, "button",
+ (GdkRectangle*) NULL, m_wxwindow,
+ (char *)"button", // const_cast
x-1, y-1, w+2, h+2);
#elif defined( __WXMAC__ )
const int m_corner = 1;
dc->SetBrush( *wxTRANSPARENT_BRUSH );
- dc->SetPen( wxPen( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNSHADOW ) , 1 , wxSOLID ) );
+ dc->SetPen( wxPen( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNSHADOW ) , 1 , wxSOLID ) );
dc->DrawLine( x+w-m_corner+1, y, x+w, y+h ); // right (outer)
dc->DrawRectangle( x, y+h, w+1, 1 ); // bottom (outer)
dc->DrawLine( x+w-m_corner+1, y, x+w, y+h ); // right (outer)
dc->DrawRectangle( x, y+h, w+1, 1 ); // bottom (outer)
- wxPen pen( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNSHADOW ), 1, wxSOLID );
+ wxPen pen( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNSHADOW ), 1, wxSOLID );
dc->SetPen( pen );
dc->DrawLine( x+w-m_corner, y, x+w-1, y+h ); // right (inner)
void wxListHeaderWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
{
-#ifdef __WXGTK__
+#if defined(__WXGTK__)
wxClientDC dc( this );
#else
wxPaintDC dc( this );
{
int x1 = m_currentX;
int y1 = 0;
- ClientToScreen( &x1, &y1 );
+ m_owner->ClientToScreen( &x1, &y1 );
- int x2 = m_currentX-1;
+ int x2 = m_currentX;
int y2 = 0;
m_owner->GetClientSize( NULL, &y2 );
m_owner->ClientToScreen( &x2, &y2 );
m_highlightBrush = new wxBrush
(
- wxSystemSettings::GetSystemColour
+ wxSystemSettings::GetColour
(
wxSYS_COLOUR_HIGHLIGHT
),
m_highlightUnfocusedBrush = new wxBrush
(
- wxSystemSettings::GetSystemColour
+ wxSystemSettings::GetColour
(
wxSYS_COLOUR_BTNSHADOW
),
InitScrolling();
SetScrollbars( m_xScroll, m_yScroll, 0, 0, 0, 0 );
- SetBackgroundColour( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_LISTBOX ) );
+ SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOX ) );
}
wxListMainWindow::~wxListMainWindow()
else
iconSpacing = 0;
+ // Note that we do not call GetClientSize() here but
+ // GetSize() and substract the border size for sunken
+ // borders manually. This is technically incorrect,
+ // but we need to know the client area's size WITHOUT
+ // scrollbars here. Since we don't know if there are
+ // any scrollbars, we use GetSize() instead. Another
+ // solution would be to call SetScrollbars() here to
+ // remove the scrollbars and call GetClientSize() then,
+ // but this might result in flicker and - worse - will
+ // reset the scrollbars to 0 which is not good at all
+ // if you resize a dialog/window, but don't want to
+ // reset the window scrolling. RR.
+ // Furthermore, we actually do NOT subtract the border
+ // width as 2 pixels is just the extra space which we
+ // need around the actual content in the window. Other-
+ // wise the text would e.g. touch the upper border. RR.
int clientWidth,
clientHeight;
- GetClientSize( &clientWidth, &clientHeight );
-
+ GetSize( &clientWidth, &clientHeight );
+
if ( HasFlag(wxLC_REPORT) )
{
// all lines have the same height
// fit into the window, we recalculate after subtracting an
// approximated 15 pt for the horizontal scrollbar
- clientHeight -= 4; // sunken frame
-
int entireWidth = 0;
for (int tries = 0; tries < 2; tries++)
{
- entireWidth = 0;
+ // We start with 4 for the border around all items
+ entireWidth = 4;
+
+ if (tries == 1)
+ {
+ // Now we have decided that the items do not fit into the
+ // client area. Unfortunately, wxWindows sometimes thinks
+ // that it does fit and therefore NO horizontal scrollbar
+ // is inserted. This looks ugly, so we fudge here and make
+ // the calculated width bigger than was actually has been
+ // calculated. This ensures that wxScrolledWindows puts
+ // a scrollbar at the bottom of its client area.
+ entireWidth += SCROLL_UNIT_X;
+ }
+
+ // Start at 2,2 so the text does not touch the border
int x = 2;
int y = 2;
int maxWidth = 0;
currentlyVisibleLines++;
wxListLineData *line = GetLine(i);
line->CalculateSize( &dc, iconSpacing );
- line->SetPosition( x, y, clientWidth, iconSpacing );
+ line->SetPosition( x, y, clientWidth, iconSpacing ); // Why clientWidth? (FIXME)
wxSize sizeLine = GetLineSize(i);
if (currentlyVisibleLines > m_linesPerPage)
m_linesPerPage = currentlyVisibleLines;
- // assume that the size of the next one is the same... (FIXME)
- if ( y + sizeLine.y - 6 >= clientHeight )
+ // Assume that the size of the next one is the same... (FIXME)
+ if ( y + sizeLine.y >= clientHeight )
{
currentlyVisibleLines = 0;
y = 2;
entireWidth += maxWidth+6;
maxWidth = 0;
}
+
+ // We have reached the last item.
if ( i == count - 1 )
entireWidth += maxWidth;
- if ((tries == 0) && (entireWidth > clientWidth))
+
+ if ( (tries == 0) && (entireWidth+SCROLL_UNIT_X > clientWidth) )
{
- clientHeight -= 15; // scrollbar height
+ clientHeight -= 15; // We guess the scrollbar height. (FIXME)
m_linesPerPage = 0;
currentlyVisibleLines = 0;
break;
}
+
if ( i == count - 1 )
- tries = 1; // everything fits, no second try required
+ tries = 1; // Everything fits, no second try required.
}
}