wxListItemData *item = (wxListItemData*)node->Data();
wxString s;
item->GetText( s );
- if (s.IsEmpty()) s = _T("H");
+ if (s.IsEmpty()) s = wxT("H");
long lw,lh;
dc->GetTextExtent( s, &lw, &lh );
m_bound_label.width = lw;
long dev_y = dc->LogicalToDeviceY( m_bound_all.y-2 );
long dev_w = dc->LogicalToDeviceXRel( m_bound_all.width+4 );
long dev_h = dc->LogicalToDeviceYRel( m_bound_all.height+4 );
-
+
if (!m_owner->IsExposed( dev_x, dev_y, dev_w, dev_h ))
- {
+ {
return;
}
dc->DrawRectangle( m_bound_hilight.x, m_bound_hilight.y,
m_bound_hilight.width, m_bound_hilight.height );
}
-
+
dc->SetBackgroundMode(wxTRANSPARENT);
if (m_mode == wxLC_REPORT)
{
bool wxListLineData::IsInRect( int x, int y, const wxRect &rect )
{
- return ((x >= rect.x) && (x <= rect.x+rect.width) &&
+ return ((x >= rect.x) && (x <= rect.x+rect.width) &&
(y >= rect.y) && (y <= rect.y+rect.height));
}
dc->DrawRectangle( x, y+h, w+1, 1 ); // bottom (outer)
wxPen pen( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNSHADOW ), 1, wxSOLID );
-
+
dc->SetPen( pen );
dc->DrawLine( x+w-m_corner, y, x+w-1, y+h ); // right (inner)
dc->DrawRectangle( x+1, y+h-1, w-2, 1 ); // bottom (inner)
for (int j = 0; j < m_owner->GetColumnCount(); j++)
{
xpos += m_owner->GetColumnWidth( j );
+ m_column = j;
if ((abs(x-xpos) < 3) && (y < 22))
{
hit_border = TRUE;
- m_column = j;
break;
}
+ if (x-xpos < 0)
+ {
+ break;
+ }
m_minX = xpos;
}
- if (event.LeftDown() && hit_border)
+ if (event.LeftDown())
{
- m_isDragging = TRUE;
- m_currentX = x;
- DrawCurrent();
- CaptureMouse();
- return;
+ if (hit_border)
+ {
+ m_isDragging = TRUE;
+ m_currentX = x;
+ DrawCurrent();
+ CaptureMouse();
+ return;
+ }
+ else
+ {
+ wxListEvent le( wxEVT_COMMAND_LIST_COL_CLICK, GetParent()->GetId() );
+ le.SetEventObject( GetParent() );
+ le.m_col = m_column;
+ GetParent()->GetEventHandler()->ProcessEvent( le );
+ return;
+ }
}
if (event.Moving())
wxListTextCtrl::wxListTextCtrl( wxWindow *parent, const wxWindowID id,
bool *accept, wxString *res, wxListMainWindow *owner,
const wxString &value, const wxPoint &pos, const wxSize &size,
+#if wxUSE_VALIDATORS
+# if defined(__VISAGECPP__)
+ int style, const wxValidator* validator, const wxString &name ) :
+# else
int style, const wxValidator& validator, const wxString &name ) :
+# endif
+#endif
wxTextCtrl( parent, id, value, pos, size, style, validator, name )
{
m_res = res;
if (wxPendingDelete.Member(this)) return;
wxPendingDelete.Append(this);
-
+
if ((*m_accept) && ((*m_res) != m_startValue))
m_owner->OnRenameAccept();
}
wxListMainWindow::~wxListMainWindow()
{
if (m_hilightBrush) delete m_hilightBrush;
-
+
delete m_renameTimer;
}
PrepareDC( dc );
if (m_dirty) return;
-
+
if (m_lines.GetCount() == 0) return;
dc.BeginDrawing();
dc.SetFont( GetFont() );
-
+
if (m_mode & wxLC_REPORT)
{
int lineSpacing = 0;
for (int i = 0; i < m_visibleLines+2; i++)
{
if (!node) break;
-
+
line = (wxListLineData*)node->Data();
line->Draw( &dc );
node = node->Next();
node = node->Next();
}
}
-
+
if (m_current) m_current->DrawRubberBand( &dc, m_hasFocus );
dc.EndDrawing();
void wxListMainWindow::EditLabel( long item )
{
wxNode *node = m_lines.Nth( item );
- wxCHECK_RET( node, _T("wrong index in wxListCtrl::Edit()") );
-
+ wxCHECK_RET( node, wxT("wrong index in wxListCtrl::Edit()") );
+
m_currentEdit = (wxListLineData*) node->Data();
wxListEvent le( wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT, GetParent()->GetId() );
le.m_itemIndex = GetIndexOfLine( m_currentEdit );
m_currentEdit->GetItem( 0, le.m_item );
GetParent()->GetEventHandler()->ProcessEvent( le );
-
+
if (!le.IsAllowed())
return;
-
+
// We have to call this here because the label in
// question might just have been added and no screen
// update taken place.
int w = 0;
int h = 0;
m_currentEdit->GetLabelExtent( x, y, w, h );
-
+
wxClientDC dc(this);
PrepareDC( dc );
x = dc.LogicalToDeviceX( x );
void wxListMainWindow::OnRenameTimer()
{
- wxCHECK_RET( m_current, _T("invalid m_current") );
-
+ wxCHECK_RET( m_current, wxT("invalid m_current") );
+
Edit( m_lines.IndexOf( m_current ) );
}
m_currentEdit->GetItem( 0, le.m_item );
le.m_item.m_text = m_renameRes;
GetParent()->GetEventHandler()->ProcessEvent( le );
-
+
if (!le.IsAllowed()) return;
-
+
wxListItem info;
info.m_mask = wxLIST_MASK_TEXT;
info.m_itemId = le.m_itemIndex;
PrepareDC(dc);
long x = dc.DeviceToLogicalX( (long)event.GetX() );
long y = dc.DeviceToLogicalY( (long)event.GetY() );
-
+
/* Did we actually hit an item ? */
long hitResult = 0;
wxNode *node = m_lines.First();
m_usedKeys = FALSE;
m_lastOnSame = FALSE;
m_renameTimer->Stop();
-
+
SendNotify( line, wxEVT_COMMAND_LIST_ITEM_ACTIVATED );
-
+
return;
}
SendNotify( line, wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK );
return;
}
-
+
if (event.MiddleDown())
{
SendNotify( line, wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK );
return;
}
-
+
if (event.LeftDown())
{
m_usedKeys = FALSE;
}
if (numOfLine < numOfCurrent)
- {
- int i = numOfLine;
- numOfLine = numOfCurrent;
- numOfCurrent = i;
+ {
+ int i = numOfLine;
+ numOfLine = numOfCurrent;
+ numOfCurrent = i;
}
-
+
wxNode *node = m_lines.Nth( numOfCurrent );
for (int i = 0; i <= numOfLine-numOfCurrent; i++)
{
void wxListMainWindow::MoveToFocus()
{
if (!m_current) return;
-
+
int x = 0;
int y = 0;
int w = 0;
int h = 0;
m_current->GetExtent( x, y, w, h );
-
+
int w_p = 0;
int h_p = 0;
GetClientSize( &w_p, &h_p );
-
+
if (m_mode & wxLC_REPORT)
{
int y_s = m_yScroll*GetScrollPos( wxVERTICAL );
if ((y > y_s) && (y+h < y_s+h_p)) return;
- if (y-y_s < 5) { Scroll( -1, (y-5-h_p/2)/m_yScroll ); Refresh(); }
- if (y+h+5 > y_s+h_p) { Scroll( -1, (y+h-h_p/2+h+15)/m_yScroll); Refresh(); }
+ if (y-y_s < 5) { Scroll( -1, (y-5-h_p/2)/m_yScroll ); }
+ if (y+h+5 > y_s+h_p) { Scroll( -1, (y+h-h_p/2+h+15)/m_yScroll); }
}
else
{
int x_s = m_xScroll*GetScrollPos( wxHORIZONTAL );
if ((x > x_s) && (x+w < x_s+w_p)) return;
- if (x-x_s < 5) { Scroll( (x-5)/m_xScroll, -1 ); Refresh(); }
- if (x+w-5 > x_s+w_p) { Scroll( (x+w-w_p+15)/m_xScroll, -1 ); Refresh(); }
+ if (x-x_s < 5) { Scroll( (x-5)/m_xScroll, -1 ); }
+ if (x+w-5 > x_s+w_p) { Scroll( (x+w-w_p+15)/m_xScroll, -1 ); }
}
}
void wxListMainWindow::OnKeyDown( wxKeyEvent &event )
{
wxWindow *parent = GetParent();
-
+
/* we propagate the key event up */
wxKeyEvent ke( wxEVT_KEY_DOWN );
ke.m_shiftDown = event.m_shiftDown;
ke.m_y = event.m_y;
ke.SetEventObject( parent );
if (parent->GetEventHandler()->ProcessEvent( ke )) return;
-
+
event.Skip();
}
-
+
void wxListMainWindow::OnChar( wxKeyEvent &event )
{
wxWindow *parent = GetParent();
-
+
/* we send a list_key event up */
wxListEvent le( wxEVT_COMMAND_LIST_KEY_DOWN, GetParent()->GetId() );
le.m_code = event.KeyCode();
ke.m_y = event.m_y;
ke.SetEventObject( parent );
if (parent->GetEventHandler()->ProcessEvent( ke )) return;
-
+
if (event.KeyCode() == WXK_TAB)
{
wxNavigationKeyEvent nevent;
nevent.SetCurrentFocus( m_parent );
if (m_parent->GetEventHandler()->ProcessEvent( nevent )) return;
}
-
+
/* no item -> nothing to do */
if (!m_current)
{
case WXK_PRIOR:
{
int steps = 0;
- if (m_mode & wxLC_REPORT)
- {
- steps = m_visibleLines-1;
+ if (m_mode & wxLC_REPORT)
+ {
+ steps = m_visibleLines-1;
}
else
{
case WXK_NEXT:
{
int steps = 0;
- if (m_mode & wxLC_REPORT)
- {
- steps = m_visibleLines-1;
+ if (m_mode & wxLC_REPORT)
+ {
+ steps = m_visibleLines-1;
}
else
{
m_usedKeys = TRUE;
}
+#ifdef __WXGTK__
+extern wxWindow *g_focusWindow;
+#endif
+
void wxListMainWindow::OnSetFocus( wxFocusEvent &WXUNUSED(event) )
{
m_hasFocus = TRUE;
if (!GetParent()) return;
+#ifdef __WXGTK__
+ g_focusWindow = GetParent();
+#endif
+
wxFocusEvent event( wxEVT_SET_FOCUS, GetParent()->GetId() );
event.SetEventObject( GetParent() );
GetParent()->GetEventHandler()->ProcessEvent( event );
{
/*
We don't even allow the wxScrolledWindow::AdjustScrollbars() call
-
+
*/
}
}
else
{
- return 0;
+ return 0;
}
}
int iconSpacing = 0;
if (m_mode & wxLC_ICON) iconSpacing = m_normal_spacing;
if (m_mode & wxLC_SMALL_ICON) iconSpacing = m_small_spacing;
-
+
// we take the first line (which also can be an icon or
// an a text item in wxLC_ICON and wxLC_LIST modes) to
// measure the size of the line
-
+
int lineWidth = 0;
int lineHeight = 0;
int lineSpacing = 0;
// at first we try without any scrollbar. if the items don't
// fit into the window, we recalculate after subtracting an
// approximated 15 pt for the horizontal scrollbar
-
+
GetSize( &clientWidth, &clientHeight );
clientHeight -= 4; // sunken frame
void wxListMainWindow::DeleteColumn( int col )
{
wxCHECK_RET( col < (int)m_columns.GetCount(),
- _T("attempting to delete inexistent column in wxListView") );
+ wxT("attempting to delete inexistent column in wxListView") );
m_dirty = TRUE;
wxNode *node = m_columns.Nth( col );
else if (m_mode & wxLC_LIST) mode = wxLC_LIST;
else if (m_mode & wxLC_ICON) mode = wxLC_ICON;
else if (m_mode & wxLC_SMALL_ICON) mode = wxLC_ICON; // no typo
-
+
wxListLineData *line = new wxListLineData( this, mode, m_hilightBrush );
-
+
if (m_mode & wxLC_REPORT)
{
line->InitItems( GetColumnCount() );
{
line->InitItems( 1 );
}
-
+
line->SetItem( 0, item );
if ((item.m_itemId >= 0) && (item.m_itemId < (int)m_lines.GetCount()))
{
wxListCtrlCompare list_ctrl_compare_func_2;
long list_ctrl_compare_data;
-int list_ctrl_compare_func_1( const void *arg1, const void *arg2 )
+int LINKAGEMODE list_ctrl_compare_func_1( const void *arg1, const void *arg2 )
{
wxListLineData *line1 = *((wxListLineData**)arg1);
wxListLineData *line2 = *((wxListLineData**)arg2);
bool wxListCtrl::Create( wxWindow *parent, wxWindowID id,
const wxPoint &pos, const wxSize &size,
+#if wxUSE_VALIDATORS
+# if defined(__VISAGECPP__)
+ long style, const wxValidator *validator,
+# else
long style, const wxValidator &validator,
+# endif
+#endif
const wxString &name )
{
m_imageListNormal = (wxImageList *) NULL;
#if wxUSE_VALIDATORS
SetValidator( validator );
#endif
-
+
if (s & wxSUNKEN_BORDER) s -= wxSUNKEN_BORDER;
m_mainWin = new wxListMainWindow( this, -1, wxPoint(0,0), size, s );
{
if (!m_headerWin)
{
- m_headerWin = new wxListHeaderWindow( this, -1, m_mainWin,
+ m_headerWin = new wxListHeaderWindow( this, -1, m_mainWin,
wxPoint(0,0), wxSize(width,23), wxTAB_TRAVERSAL );
+ if (HasFlag(wxLC_NO_HEADER))
+ m_headerWin->Show( FALSE );
}
else
- {
- m_headerWin->Show( TRUE );
- }
+ {
+ if (flag & wxLC_NO_HEADER)
+ m_headerWin->Show( FALSE );
+ else
+ m_headerWin->Show( TRUE );
+ }
}
}
else
{
- if (HasFlag(wxLC_REPORT))
+ if (HasFlag(wxLC_REPORT) && !(HasFlag(wxLC_NO_HEADER)))
{
m_headerWin->Show( FALSE );
}
}
}
-
+
wxWindow::SetWindowStyleFlag( flag );
}
long wxListCtrl::InsertItem( wxListItem& info )
{
m_mainWin->InsertItem( info );
- return 0;
+ return info.m_itemId;
}
long wxListCtrl::InsertItem( long index, const wxString &label )
int w = 0;
int h = 0;
- if (HasFlag(wxLC_REPORT))
+ if (HasFlag(wxLC_REPORT) && !HasFlag(wxLC_NO_HEADER))
{
m_headerWin->GetPosition( &x, &y );
m_headerWin->GetSize( &w, &h );
m_mainWin->SetBackgroundColour( colour );
m_mainWin->m_dirty = TRUE;
}
-
+
if (m_headerWin)
{
// m_headerWin->SetBackgroundColour( colour );
{
if ( !wxWindow::SetForegroundColour( colour ) )
return FALSE;
-
+
if (m_mainWin)
{
m_mainWin->SetForegroundColour( colour );
m_mainWin->m_dirty = TRUE;
}
-
+
if (m_headerWin)
{
m_headerWin->SetForegroundColour( colour );
{
if ( !wxWindow::SetFont( font ) )
return FALSE;
-
+
if (m_mainWin)
{
m_mainWin->SetFont( font );
m_mainWin->m_dirty = TRUE;
}
-
+
if (m_headerWin)
{
m_headerWin->SetFont( font );