#include "wx/generic/imaglist.h"
#include "wx/dynarray.h"
+#ifdef __WXGTK__
+#include <gtk/gtk.h>
+#include "wx/gtk/win_gtk.h"
+#endif
+
#ifndef wxUSE_GENERIC_LIST_EXTENSIONS
#define wxUSE_GENERIC_LIST_EXTENSIONS 1
#endif
const wxValidator& validator = wxDefaultValidator,
const wxString &name = "listctrltextctrl" );
void OnChar( wxKeyEvent &event );
+ void OnKeyUp( wxKeyEvent &event );
void OnKillFocus( wxFocusEvent &event );
private:
m_bound_all.height = lh;
node = node->Next();
}
+ m_bound_label.width = m_bound_all.width;
+ m_bound_label.height = m_bound_all.height;
break;
}
}
void wxListHeaderWindow::DoDrawRect( wxDC *dc, int x, int y, int w, int h )
{
+#ifdef __WXGTK__
+ GtkStateType state = GTK_STATE_NORMAL;
+ if (!m_parent->IsEnabled()) state = GTK_STATE_INSENSITIVE;
+
+ x = dc->XLOG2DEV( x );
+
+ gtk_paint_box (m_wxwindow->style, GTK_PIZZA(m_wxwindow)->bin_window, state, GTK_SHADOW_OUT,
+ (GdkRectangle*) NULL, m_wxwindow, "button", x-1, y-1, w+2, h+2);
+#else
const int m_corner = 1;
dc->SetBrush( *wxTRANSPARENT_BRUSH );
dc->DrawRectangle( x, y, 1, h ); // left (outer)
dc->DrawLine( x, y+h-1, x+1, y+h-1 );
dc->DrawLine( x+w-1, y, x+w-1, y+1 );
+#endif
}
// shift the DC origin to match the position of the main window horz
BEGIN_EVENT_TABLE(wxListTextCtrl,wxTextCtrl)
EVT_CHAR (wxListTextCtrl::OnChar)
+ EVT_KEY_UP (wxListTextCtrl::OnKeyUp)
EVT_KILL_FOCUS (wxListTextCtrl::OnKillFocus)
END_EVENT_TABLE()
event.Skip();
}
+void wxListTextCtrl::OnKeyUp( wxKeyEvent &event )
+{
+ // auto-grow the textctrl:
+ wxSize parentSize = m_owner->GetSize();
+ wxPoint myPos = GetPosition();
+ wxSize mySize = GetSize();
+ int sx, sy;
+ GetTextExtent(GetValue() + _T("MM"), &sx, &sy);
+ if (myPos.x + sx > parentSize.x) sx = parentSize.x - myPos.x;
+ if (mySize.x > sx) sx = mySize.x;
+ SetSize(sx, -1);
+
+ event.Skip();
+}
+
void wxListTextCtrl::OnKillFocus( wxFocusEvent &WXUNUSED(event) )
{
if (!wxPendingDelete.Member(this))
dc.SetBrush(* wxTRANSPARENT_BRUSH);
wxSize clientSize = GetClientSize();
- wxRect itemRect;
int lineSpacing = 0;
wxListLineData *line = &m_lines[0];
x += colWidth ;
dc.DrawLine(x, firstItemRect.GetY() - 1, x, lastItemRect.GetBottom() + 1);
}
- }
+ }
}
else
{
if (index >= 0 && (size_t)index < m_lines.GetCount())
{
m_lines[(size_t)index].GetRect( rect );
+ this->CalcScrolledPosition(rect.x,rect.y,&rect.x,&rect.y);
}
else
{
bool wxListMainWindow::GetItemPosition(long item, wxPoint& pos)
{
- if (item >= 0 && (size_t)item < m_lines.GetCount())
- {
- wxRect rect;
- m_lines[(size_t)item].GetRect( rect );
- pos.x = rect.x;
- pos.y = rect.y;
- }
- else
- {
- pos.x = 0;
- pos.y = 0;
- }
+ wxRect rect;
+ this->GetItemRect(item,rect);
+ pos.x=rect.x; pos.y=rect.y;
return TRUE;
}
else
{
m_lines.Add( line );
- item.m_itemId = m_lines.GetCount();
+ item.m_itemId = m_lines.GetCount()-1;
}
}
m_imageListNormal = (wxImageList *) NULL;
m_imageListSmall = (wxImageList *) NULL;
m_imageListState = (wxImageList *) NULL;
+ m_ownsImageListNormal = m_ownsImageListSmall = m_ownsImageListState = FALSE;
m_mainWin = (wxListMainWindow*) NULL;
m_headerWin = (wxListHeaderWindow*) NULL;
}
wxListCtrl::~wxListCtrl()
{
+ if (m_ownsImageListNormal) delete m_imageListNormal;
+ if (m_ownsImageListSmall) delete m_imageListSmall;
+ if (m_ownsImageListState) delete m_imageListState;
}
bool wxListCtrl::Create(wxWindow *parent,
m_imageListNormal = (wxImageList *) NULL;
m_imageListSmall = (wxImageList *) NULL;
m_imageListState = (wxImageList *) NULL;
+ m_ownsImageListNormal = m_ownsImageListSmall = m_ownsImageListState = FALSE;
m_mainWin = (wxListMainWindow*) NULL;
m_headerWin = (wxListHeaderWindow*) NULL;
void wxListCtrl::SetImageList( wxImageList *imageList, int which )
{
+ if ( which == wxIMAGE_LIST_NORMAL )
+ {
+ if (m_ownsImageListNormal) delete m_imageListNormal;
+ m_imageListNormal = imageList;
+ m_ownsImageListNormal = FALSE;
+ }
+ else if ( which == wxIMAGE_LIST_SMALL )
+ {
+ if (m_ownsImageListSmall) delete m_imageListSmall;
+ m_imageListSmall = imageList;
+ m_ownsImageListSmall = FALSE;
+ }
+ else if ( which == wxIMAGE_LIST_STATE )
+ {
+ if (m_ownsImageListState) delete m_imageListState;
+ m_imageListState = imageList;
+ m_ownsImageListState = FALSE;
+ }
+
m_mainWin->SetImageList( imageList, which );
}
+void wxListCtrl::AssignImageList(wxImageList *imageList, int which)
+{
+ SetImageList(imageList, which);
+ if ( which == wxIMAGE_LIST_NORMAL )
+ m_ownsImageListNormal = TRUE;
+ else if ( which == wxIMAGE_LIST_SMALL )
+ m_ownsImageListSmall = TRUE;
+ else if ( which == wxIMAGE_LIST_STATE )
+ m_ownsImageListState = TRUE;
+}
+
bool wxListCtrl::Arrange( int WXUNUSED(flag) )
{
return 0;