From 92976ab62b850005f9b1e506d0e5ccf2ed465c15 Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Fri, 11 Dec 1998 15:41:28 +0000 Subject: [PATCH] ADDED wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK Corrected inheritence of wxTreeEvent, wxNotebookEvent, wxListEvent on wxMSW and wxGTK Corrected scrolling step etc. in wxListCtrl Built-in correction of out-of-bounds values for position of scrollbar thumb Reverted interpretation of wxVERTICAL for radiobox Applied Phls patch for wxStaticText git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1172 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- Makefile | 4 +- include/wx/event.h | 4 +- include/wx/generic/listctrl.h | 9 +- include/wx/generic/treectrl.h | 2 +- include/wx/gtk/notebook.h | 4 +- include/wx/gtk1/notebook.h | 4 +- samples/controls/controls.cpp | 4 +- src/common/event.cpp | 1 + src/generic/listctrl.cpp | 1163 ++++++++++++++++----------------- src/generic/statusbr.cpp | 5 + src/generic/treectrl.cpp | 4 +- src/gtk/dnd.cpp | 2 +- src/gtk/notebook.cpp | 2 +- src/gtk/radiobox.cpp | 4 +- src/gtk/stattext.cpp | 12 +- src/gtk/window.cpp | 11 +- src/gtk1/dnd.cpp | 2 +- src/gtk1/notebook.cpp | 2 +- src/gtk1/radiobox.cpp | 4 +- src/gtk1/stattext.cpp | 12 +- src/gtk1/window.cpp | 11 +- src/msw/data.cpp | 1 + src/msw/gauge95.cpp | 2 +- src/msw/listctrl.cpp | 2 +- src/msw/notebook.cpp | 2 +- src/msw/treectrl.cpp | 2 +- 26 files changed, 648 insertions(+), 627 deletions(-) diff --git a/Makefile b/Makefile index c35ef5ea06..fdc7eff863 100644 --- a/Makefile +++ b/Makefile @@ -56,8 +56,8 @@ user:: install:: @echo "entering directory src for installing" @cd src; ${MAKE} install - @echo "entering directory utils for installing" - @cd utils; ${MAKE} install +# @echo "entering directory utils for installing" +# @cd utils; ${MAKE} install # the following ones recreate all Makefiles. diff --git a/include/wx/event.h b/include/wx/event.h index a99125394e..576e271156 100644 --- a/include/wx/event.h +++ b/include/wx/event.h @@ -179,6 +179,8 @@ const wxEventType wxEVT_COMMAND_LIST_ITEM_DESELECTED = wxEVT_FIRST + 709; const wxEventType wxEVT_COMMAND_LIST_KEY_DOWN = wxEVT_FIRST + 710; const wxEventType wxEVT_COMMAND_LIST_INSERT_ITEM = wxEVT_FIRST + 711; const wxEventType wxEVT_COMMAND_LIST_COL_CLICK = wxEVT_FIRST + 712; +const wxEventType wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK = wxEVT_FIRST + 713; +const wxEventType wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK = wxEVT_FIRST + 714; /* Tab and notebook control event types */ const wxEventType wxEVT_COMMAND_TAB_SEL_CHANGED = wxEVT_FIRST + 800; @@ -362,7 +364,7 @@ public: private: bool m_bAllow; - DECLARE_DYNAMIC_CLASS(wxCommandEvent) + DECLARE_DYNAMIC_CLASS(wxNotifyEvent) }; // Scroll event class diff --git a/include/wx/generic/listctrl.h b/include/wx/generic/listctrl.h index 96ac43a453..afe4e8a7ce 100644 --- a/include/wx/generic/listctrl.h +++ b/include/wx/generic/listctrl.h @@ -190,7 +190,7 @@ class wxListItem: public wxObject // wxListEvent //----------------------------------------------------------------------------- -class WXDLLEXPORT wxListEvent: public wxCommandEvent +class WXDLLEXPORT wxListEvent: public wxNotifyEvent { DECLARE_DYNAMIC_CLASS(wxListEvent) @@ -222,7 +222,8 @@ typedef void (wxEvtHandler::*wxListEventFunction)(wxListEvent&); #define EVT_LIST_KEY_DOWN(id, fn) { wxEVT_COMMAND_LIST_KEY_DOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL }, #define EVT_LIST_INSERT_ITEM(id, fn) { wxEVT_COMMAND_LIST_INSERT_ITEM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL }, #define EVT_LIST_COL_CLICK(id, fn) { wxEVT_COMMAND_LIST_COL_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL }, - +#define EVT_LIST_ITEM_RIGHT_CLICK(id, fn) { wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL }, +#define EVT_LIST_ITEM_MIDDLE_CLICK(id, fn) { wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL }, //----------------------------------------------------------------------------- // wxListItemData (internal) @@ -461,7 +462,6 @@ class wxListMainWindow: public wxScrolledWindow void RefreshLine( wxListLineData *line ); void OnPaint( wxPaintEvent &event ); void HilightAll( bool on ); - void ActivateLine( wxListLineData *line ); void SendNotify( wxListLineData *line, wxEventType command ); void FocusLine( wxListLineData *line ); void UnfocusLine( wxListLineData *line ); @@ -519,7 +519,6 @@ class wxListMainWindow: public wxScrolledWindow void InsertColumn( long col, wxListItem &item ); // void AddColumn( wxListItem &item ); void SortItems( wxListCtrlCompare fn, long data ); - virtual bool OnListNotify( wxListEvent &event ); DECLARE_EVENT_TABLE() }; @@ -568,6 +567,7 @@ class wxListCtrl: public wxControl bool GetItemPosition( long item, wxPoint& pos ) const; bool SetItemPosition( long item, const wxPoint& pos ); // not supported in wxGLC int GetItemCount(void) const; + int GetColumnCount(void) const; void SetItemSpacing( int spacing, bool isSmall = FALSE ); int GetItemSpacing( bool isSmall ) const; int GetSelectedItemCount(void) const; @@ -601,7 +601,6 @@ class wxListCtrl: public wxControl bool ScrollList(int dx, int dy); bool SortItems(wxListCtrlCompare fn, long data); bool Update(long item); - virtual bool OnListNotify(wxListEvent& WXUNUSED(event)) { return FALSE; } void OnIdle( wxIdleEvent &event ); // We have to hand down a few functions diff --git a/include/wx/generic/treectrl.h b/include/wx/generic/treectrl.h index a9779e9668..49e3e4fb3f 100644 --- a/include/wx/generic/treectrl.h +++ b/include/wx/generic/treectrl.h @@ -91,7 +91,7 @@ protected: // ----------------------------------------------------------------------------- // wxTreeEvent - the event generated by the tree control // ----------------------------------------------------------------------------- -class WXDLLEXPORT wxTreeEvent : public wxCommandEvent +class WXDLLEXPORT wxTreeEvent : public wxNotifyEvent { friend class wxTreeCtrl; public: diff --git a/include/wx/gtk/notebook.h b/include/wx/gtk/notebook.h index d61603dd8f..086aed0175 100644 --- a/include/wx/gtk/notebook.h +++ b/include/wx/gtk/notebook.h @@ -32,12 +32,12 @@ class wxNotebookPage; // notebook events // ---------------------------------------------------------------------------- -class wxNotebookEvent : public wxCommandEvent +class wxNotebookEvent : public wxNotifyEvent { public: wxNotebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0, int nSel = -1, int nOldSel = -1) - : wxCommandEvent(commandType, id) + : wxNotifyEvent(commandType, id) { m_bAllow = TRUE; m_nSel = nSel; diff --git a/include/wx/gtk1/notebook.h b/include/wx/gtk1/notebook.h index d61603dd8f..086aed0175 100644 --- a/include/wx/gtk1/notebook.h +++ b/include/wx/gtk1/notebook.h @@ -32,12 +32,12 @@ class wxNotebookPage; // notebook events // ---------------------------------------------------------------------------- -class wxNotebookEvent : public wxCommandEvent +class wxNotebookEvent : public wxNotifyEvent { public: wxNotebookEvent(wxEventType commandType = wxEVT_NULL, int id = 0, int nSel = -1, int nOldSel = -1) - : wxCommandEvent(commandType, id) + : wxNotifyEvent(commandType, id) { m_bAllow = TRUE; m_nSel = nSel; diff --git a/samples/controls/controls.cpp b/samples/controls/controls.cpp index 2172c7d265..d67b979d0a 100644 --- a/samples/controls/controls.cpp +++ b/samples/controls/controls.cpp @@ -365,9 +365,9 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) : panel = new wxPanel(m_notebook); // panel->SetBackgroundColour("cadet blue"); // panel->SetForegroundColour("blue"); - m_radio = new wxRadioBox( panel, ID_RADIOBOX, "That", wxPoint(10,160), wxSize(-1,-1), 2, choices2, 1, wxRA_HORIZONTAL ); + m_radio = new wxRadioBox( panel, ID_RADIOBOX, "That", wxPoint(10,160), wxSize(-1,-1), 2, choices2, 1, wxRA_VERTICAL ); // m_radio->SetBackgroundColour("wheat"); - m_radio = new wxRadioBox( panel, ID_RADIOBOX, "This", wxPoint(10,10), wxSize(-1,-1), 5, choices, 1, wxRA_VERTICAL ); + m_radio = new wxRadioBox( panel, ID_RADIOBOX, "This", wxPoint(10,10), wxSize(-1,-1), 5, choices, 1, wxRA_HORIZONTAL ); // m_radio->SetBackgroundColour("wheat"); (void)new wxButton( panel, ID_RADIOBOX_SEL_NUM, "Select #2", wxPoint(180,30), wxSize(140,30) ); (void)new wxButton( panel, ID_RADIOBOX_SEL_STR, "Select 'This'", wxPoint(180,80), wxSize(140,30) ); diff --git a/src/common/event.cpp b/src/common/event.cpp index de088d74f0..402ee199c2 100644 --- a/src/common/event.cpp +++ b/src/common/event.cpp @@ -35,6 +35,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxEvtHandler, wxObject) IMPLEMENT_ABSTRACT_CLASS(wxEvent, wxObject) IMPLEMENT_DYNAMIC_CLASS(wxCommandEvent, wxEvent) +IMPLEMENT_DYNAMIC_CLASS(wxNotifyEvent, wxCommandEvent) IMPLEMENT_DYNAMIC_CLASS(wxScrollEvent, wxCommandEvent) IMPLEMENT_DYNAMIC_CLASS(wxMouseEvent, wxEvent) IMPLEMENT_DYNAMIC_CLASS(wxKeyEvent, wxEvent) diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index 3a916fb19f..98cedb189b 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -23,122 +23,122 @@ IMPLEMENT_DYNAMIC_CLASS(wxListItemData,wxObject); wxListItemData::wxListItemData(void) { - m_image = -1; - m_data = 0; - m_xpos = 0; - m_ypos = 0; - m_width = 0; - m_height = 0; - m_colour = wxBLACK; + m_image = -1; + m_data = 0; + m_xpos = 0; + m_ypos = 0; + m_width = 0; + m_height = 0; + m_colour = wxBLACK; } wxListItemData::wxListItemData( const wxListItem &info ) { - m_image = -1; - m_data = 0; - m_colour = info.m_colour; - SetItem( info ); + m_image = -1; + m_data = 0; + m_colour = info.m_colour; + SetItem( info ); } void wxListItemData::SetItem( const wxListItem &info ) { - if (info.m_mask & wxLIST_MASK_TEXT) m_text = info.m_text; - if (info.m_mask & wxLIST_MASK_IMAGE) m_image = info.m_image; - if (info.m_mask & wxLIST_MASK_DATA) m_data = info.m_data; - m_colour = info.m_colour; - m_xpos = 0; - m_ypos = 0; - m_width = info.m_width; - m_height = 0; + if (info.m_mask & wxLIST_MASK_TEXT) m_text = info.m_text; + if (info.m_mask & wxLIST_MASK_IMAGE) m_image = info.m_image; + if (info.m_mask & wxLIST_MASK_DATA) m_data = info.m_data; + m_colour = info.m_colour; + m_xpos = 0; + m_ypos = 0; + m_width = info.m_width; + m_height = 0; } void wxListItemData::SetText( const wxString &s ) { - m_text = s; + m_text = s; } void wxListItemData::SetImage( int image ) { - m_image = image; + m_image = image; } void wxListItemData::SetData( long data ) { - m_data = data; + m_data = data; } void wxListItemData::SetPosition( int x, int y ) { - m_xpos = x; - m_ypos = y; + m_xpos = x; + m_ypos = y; } void wxListItemData::SetSize( int const width, int height ) { - if (width != -1) m_width = width; - if (height != -1) m_height = height; + if (width != -1) m_width = width; + if (height != -1) m_height = height; } void wxListItemData::SetColour( wxColour *col ) { - m_colour = col; + m_colour = col; } bool wxListItemData::HasImage(void) const { - return (m_image >= 0); + return (m_image >= 0); } bool wxListItemData::HasText(void) const { - return (!m_text.IsNull()); + return (!m_text.IsNull()); } bool wxListItemData::IsHit( int x, int y ) const { - return ((x >= m_xpos) && (x <= m_xpos+m_width) && (y >= m_ypos) && (y <= m_ypos+m_height)); + return ((x >= m_xpos) && (x <= m_xpos+m_width) && (y >= m_ypos) && (y <= m_ypos+m_height)); } void wxListItemData::GetText( wxString &s ) { - s = m_text; + s = m_text; } int wxListItemData::GetX( void ) const { - return m_xpos; + return m_xpos; } int wxListItemData::GetY( void ) const { - return m_ypos; + return m_ypos; } int wxListItemData::GetWidth(void) const { - return m_width; + return m_width; } int wxListItemData::GetHeight(void) const { - return m_height; + return m_height; } int wxListItemData::GetImage(void) const { - return m_image; + return m_image; } void wxListItemData::GetItem( wxListItem &info ) { - info.m_text = m_text; - info.m_image = m_image; - info.m_data = m_data; + info.m_text = m_text; + info.m_image = m_image; + info.m_data = m_data; } wxColour *wxListItemData::GetColour(void) { - return m_colour; + return m_colour; } //----------------------------------------------------------------------------- @@ -149,99 +149,99 @@ IMPLEMENT_DYNAMIC_CLASS(wxListHeaderData,wxObject); wxListHeaderData::wxListHeaderData(void) { - m_mask = 0; - m_image = 0; - m_format = 0; - m_width = 0; - m_xpos = 0; - m_ypos = 0; - m_height = 0; + m_mask = 0; + m_image = 0; + m_format = 0; + m_width = 0; + m_xpos = 0; + m_ypos = 0; + m_height = 0; } wxListHeaderData::wxListHeaderData( const wxListItem &item ) { - SetItem( item ); - m_xpos = 0; - m_ypos = 0; - m_height = 0; + SetItem( item ); + m_xpos = 0; + m_ypos = 0; + m_height = 0; } void wxListHeaderData::SetItem( const wxListItem &item ) { - m_mask = item.m_mask; - m_text = item.m_text; - m_image = item.m_image; - m_format = item.m_format; - m_width = item.m_width; - if (m_width < 0) m_width = 80; - if (m_width < 6) m_width = 6; + m_mask = item.m_mask; + m_text = item.m_text; + m_image = item.m_image; + m_format = item.m_format; + m_width = item.m_width; + if (m_width < 0) m_width = 80; + if (m_width < 6) m_width = 6; } void wxListHeaderData::SetPosition( int x, int y ) { - m_xpos = x; - m_ypos = y; + m_xpos = x; + m_ypos = y; } void wxListHeaderData::SetHeight( int h ) { - m_height = h; + m_height = h; } void wxListHeaderData::SetWidth( int w ) { - m_width = w; - if (m_width < 0) m_width = 80; - if (m_width < 6) m_width = 6; + m_width = w; + if (m_width < 0) m_width = 80; + if (m_width < 6) m_width = 6; } void wxListHeaderData::SetFormat( int format ) { - m_format = format; + m_format = format; } bool wxListHeaderData::HasImage(void) const { - return (m_image != 0); + return (m_image != 0); } bool wxListHeaderData::HasText(void) const { - return (m_text.Length() > 0); + return (m_text.Length() > 0); } bool wxListHeaderData::IsHit( int x, int y ) const { - return ((x >= m_xpos) && (x <= m_xpos+m_width) && (y >= m_ypos) && (y <= m_ypos+m_height)); + return ((x >= m_xpos) && (x <= m_xpos+m_width) && (y >= m_ypos) && (y <= m_ypos+m_height)); } void wxListHeaderData::GetItem( wxListItem &item ) { - item.m_mask = m_mask; - item.m_text = m_text; - item.m_image = m_image; - item.m_format = m_format; - item.m_width = m_width; + item.m_mask = m_mask; + item.m_text = m_text; + item.m_image = m_image; + item.m_format = m_format; + item.m_width = m_width; } void wxListHeaderData::GetText( wxString &s ) { - s = m_text; + s = m_text; } int wxListHeaderData::GetImage(void) const { - return m_image; + return m_image; } int wxListHeaderData::GetWidth(void) const { - return m_width; + return m_width; } int wxListHeaderData::GetFormat(void) const { - return m_format; + return m_format; } //----------------------------------------------------------------------------- @@ -252,71 +252,71 @@ IMPLEMENT_DYNAMIC_CLASS(wxListLineData,wxObject); wxListLineData::wxListLineData( wxListMainWindow *owner, int mode, wxBrush *hilightBrush ) { - m_mode = mode; - m_hilighted = FALSE; - m_owner = owner; - m_hilightBrush = hilightBrush; - m_items.DeleteContents( TRUE ); - m_spacing = 0; + m_mode = mode; + m_hilighted = FALSE; + m_owner = owner; + m_hilightBrush = hilightBrush; + m_items.DeleteContents( TRUE ); + m_spacing = 0; } void wxListLineData::CalculateSize( wxPaintDC *dc, int spacing ) { - m_spacing = spacing; - switch (m_mode) - { - case wxLC_ICON: + m_spacing = spacing; + switch (m_mode) { - m_bound_all.width = m_spacing; - m_bound_all.height = m_spacing+13; - wxNode *node = m_items.First(); - if (node) - { - wxListItemData *item = (wxListItemData*)node->Data(); - wxString s; - item->GetText( s ); - long lw,lh; - dc->GetTextExtent( s, &lw, &lh ); - if (lw > m_spacing) m_bound_all.width = lw; - } - break; - } - case wxLC_LIST: - { - wxNode *node = m_items.First(); - if (node) - { - wxListItemData *item = (wxListItemData*)node->Data(); - wxString s; - item->GetText( s ); - long lw,lh; - dc->GetTextExtent( s, &lw, &lh ); - m_bound_all.width = lw; - m_bound_all.height = lh; - } - break; - } - case wxLC_REPORT: - { - m_bound_all.width = 0; - m_bound_all.height = 0; - wxNode *node = m_items.First(); - while (node) - { - wxListItemData *item = (wxListItemData*)node->Data(); - wxString s; - item->GetText( s ); - if (s.IsNull()) s = "H"; - long lw,lh; - dc->GetTextExtent( s, &lw, &lh ); - item->SetSize( item->GetWidth(), lh ); - m_bound_all.width += lw; - m_bound_all.height = lh; - node = node->Next(); - } - break; + case wxLC_ICON: + { + m_bound_all.width = m_spacing; + m_bound_all.height = m_spacing+13; + wxNode *node = m_items.First(); + if (node) + { + wxListItemData *item = (wxListItemData*)node->Data(); + wxString s; + item->GetText( s ); + long lw,lh; + dc->GetTextExtent( s, &lw, &lh ); + if (lw > m_spacing) m_bound_all.width = lw; + } + break; + } + case wxLC_LIST: + { + wxNode *node = m_items.First(); + if (node) + { + wxListItemData *item = (wxListItemData*)node->Data(); + wxString s; + item->GetText( s ); + long lw,lh; + dc->GetTextExtent( s, &lw, &lh ); + m_bound_all.width = lw; + m_bound_all.height = lh; + } + break; + } + case wxLC_REPORT: + { + m_bound_all.width = 0; + m_bound_all.height = 0; + wxNode *node = m_items.First(); + while (node) + { + wxListItemData *item = (wxListItemData*)node->Data(); + wxString s; + item->GetText( s ); + if (s.IsNull()) s = "H"; + long lw,lh; + dc->GetTextExtent( s, &lw, &lh ); + item->SetSize( item->GetWidth(), lh ); + m_bound_all.width += lw; + m_bound_all.height = lh; + node = node->Next(); + } + break; + } } - } } void wxListLineData::SetPosition( wxPaintDC *dc, int x, int y, int window_width ) @@ -381,7 +381,7 @@ void wxListLineData::SetPosition( wxPaintDC *dc, int x, int y, int window_width m_bound_all.x -= 2; m_bound_all.y -= 2; m_bound_all.width += 4; - m_bound_all.height += 4; + m_bound_all.height += 3; AssignRect( m_bound_hilight, m_bound_all ); AssignRect( m_bound_icon, 0, 0, 0, 0 ); break; @@ -404,13 +404,13 @@ void wxListLineData::SetPosition( wxPaintDC *dc, int x, int y, int window_width void wxListLineData::SetColumnPosition( int index, int x ) { - int i = index; - wxNode *node = m_items.Nth( i ); - if (node) - { - wxListItemData *item = (wxListItemData*)node->Data(); - item->SetPosition( x, m_bound_all.y+1 ); - } + int i = index; + wxNode *node = m_items.Nth( i ); + if (node) + { + wxListItemData *item = (wxListItemData*)node->Data(); + item->SetPosition( x, m_bound_all.y+1 ); + } } void wxListLineData::GetSize( int &width, int &height ) @@ -1064,28 +1064,13 @@ void wxListMainWindow::HilightAll( bool on ) } } -void wxListMainWindow::ActivateLine( wxListLineData *line ) -{ - if (!GetParent()) return; - wxListEvent le( wxEVT_COMMAND_LIST_KEY_DOWN, GetParent()->GetId() ); - le.SetEventObject( GetParent() ); - le.m_code = 0; - le.m_itemIndex = GetIndexOfLine( line ); - le.m_col = 0; - line->GetItem( 0, le.m_item ); - OnListNotify( le ); -} - void wxListMainWindow::SendNotify( wxListLineData *line, wxEventType command ) { - if (!GetParent()) return; wxListEvent le( command, GetParent()->GetId() ); le.SetEventObject( GetParent() ); - le.m_code = 0; le.m_itemIndex = GetIndexOfLine( line ); - le.m_col = 0; line->GetItem( 0, le.m_item ); - OnListNotify( le ); + GetParent()->GetEventHandler()->ProcessEvent( le ); } void wxListMainWindow::FocusLine( wxListLineData *WXUNUSED(line) ) @@ -1120,239 +1105,242 @@ void wxListMainWindow::StartLabelEdit( wxListLineData *line ) void wxListMainWindow::RenameLine( wxListLineData *line, const wxString &newName ) { - if (!GetParent()) return; - wxListEvent le( wxEVT_COMMAND_LIST_END_LABEL_EDIT, GetParent()->GetId() ); le.SetEventObject( GetParent() ); - le.m_code = 0; le.m_itemIndex = GetIndexOfLine( line ); - le.m_col = 0; line->GetItem( 0, le.m_item ); le.m_item.m_text = newName; - OnListNotify( le ); + GetParent()->GetEventHandler()->ProcessEvent( le ); } void wxListMainWindow::OnRenameTimer() { - StartLabelEdit( m_current ); - wxString s; - m_current->GetText( 0, s ); - int x = 0; - int y = 0; - int w = 0; - int h = 0; - m_current->GetLabelExtent( x, y, w, h ); + StartLabelEdit( m_current ); + wxString s; + m_current->GetText( 0, s ); + int x = 0; + int y = 0; + int w = 0; + int h = 0; + m_current->GetLabelExtent( x, y, w, h ); - wxClientDC dc(this); - PrepareDC( dc ); - x = dc.LogicalToDeviceX( x ); - y = dc.LogicalToDeviceY( y ); + wxClientDC dc(this); + PrepareDC( dc ); + x = dc.LogicalToDeviceX( x ); + y = dc.LogicalToDeviceY( y ); - wxListTextCtrl *text = new wxListTextCtrl( - this, -1, &m_renameAccept, &m_renameRes, this, s, wxPoint(x-4,y-4), wxSize(w+11,h+8) ); - text->SetFocus(); -/* - m_text->SetSize( x+3, y+3, w+6, h+6 ); - m_text->SetValue( s ); - m_text->Show( TRUE ); - m_text->SetFocus(); -*/ -/* - char *res = wxGetTextFromUser( _("Enter new name:"), "", s ); - if (res) - { - m_dirty = TRUE; - s = res; - RenameLine( m_current, s ); - } - */ + wxListTextCtrl *text = new wxListTextCtrl( + this, -1, &m_renameAccept, &m_renameRes, this, s, wxPoint(x-4,y-4), wxSize(w+11,h+8) ); + text->SetFocus(); } void wxListMainWindow::OnRenameAccept() { - RenameLine( m_current, m_renameRes ); + RenameLine( m_current, m_renameRes ); } void wxListMainWindow::OnMouse( wxMouseEvent &event ) { - if (GetParent()->GetEventHandler()->ProcessEvent( event)) return; + if (GetParent()->GetEventHandler()->ProcessEvent( event)) return; - if (!m_current) return; - if (m_dirty) return; + if (!m_current) return; + if (m_dirty) return; - wxClientDC dc(this); - PrepareDC(dc); - long x = dc.DeviceToLogicalX( (long)event.GetX() ); - long y = dc.DeviceToLogicalY( (long)event.GetY() ); - - long hitResult = 0; - wxNode *node = m_lines.First(); - wxListLineData *line = (wxListLineData *) NULL; - while (node) - { - line = (wxListLineData*)node->Data(); - hitResult = line->IsHit( x, y ); - if (hitResult) break; - line = (wxListLineData *) NULL; - node = node->Next(); - } + wxClientDC dc(this); + 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(); + wxListLineData *line = (wxListLineData *) NULL; + while (node) + { + line = (wxListLineData*)node->Data(); + hitResult = line->IsHit( x, y ); + if (hitResult) break; + line = (wxListLineData *) NULL; + node = node->Next(); + } - if (!event.Dragging()) - m_dragCount = 0; - else - m_dragCount++; + if (!event.Dragging()) + m_dragCount = 0; + else + m_dragCount++; - if (event.Dragging() && (m_dragCount > 3)) - { - m_dragCount = 0; - wxListEvent le( wxEVT_COMMAND_LIST_BEGIN_DRAG, GetParent()->GetId() ); - le.SetEventObject( this ); - le.m_code = 0; - le.m_itemIndex = 0; - le.m_col = 0; - OnListNotify( le ); - } + if (event.Dragging() && (m_dragCount > 3)) + { + m_dragCount = 0; + + wxListEvent le( wxEVT_COMMAND_LIST_BEGIN_DRAG, GetParent()->GetId() ); + le.SetEventObject( GetParent() ); + le.m_pointDrag.x = x; + le.m_pointDrag.y = y; + GetParent()->GetEventHandler()->ProcessEvent( le ); + + return; + } - if (!line) return; + if (!line) return; - if (event.ButtonDClick()) - { - m_usedKeys = FALSE; - m_lastOnSame = FALSE; - m_renameTimer->Stop(); - ActivateLine( line ); - return; - } + if (event.ButtonDClick()) + { + m_usedKeys = FALSE; + m_lastOnSame = FALSE; + m_renameTimer->Stop(); + + SendNotify( line, wxEVT_COMMAND_LIST_KEY_DOWN ); + + return; + } - if (event.LeftUp() && m_lastOnSame) - { - m_usedKeys = FALSE; - if ((line == m_current) && - (hitResult == wxLIST_HITTEST_ONITEMLABEL) && -// (m_mode & wxLC_ICON) && - (m_mode & wxLC_EDIT_LABELS) ) + if (event.LeftUp() && m_lastOnSame) { - m_renameTimer->Start( 100, TRUE ); + m_usedKeys = FALSE; + if ((line == m_current) && + (hitResult == wxLIST_HITTEST_ONITEMLABEL) && + (m_mode & wxLC_EDIT_LABELS) ) + { + m_renameTimer->Start( 100, TRUE ); + } + m_lastOnSame = FALSE; + return; } - m_lastOnSame = FALSE; - return; - } - if (event.LeftDown()) - { - m_usedKeys = FALSE; - wxListLineData *oldCurrent = m_current; - if (m_mode & wxLC_SINGLE_SEL) + if (event.RightDown()) { - m_current = line; - HilightAll( FALSE ); - m_current->ReverseHilight(); - RefreshLine( m_current ); + SendNotify( line, wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK ); + return; } - else + + if (event.MiddleDown()) { - if (event.ShiftDown()) - { - m_current = line; - m_current->ReverseHilight(); - RefreshLine( m_current ); - } - else if (event.ControlDown()) - { - m_current = line; - int numOfCurrent = -1; - node = m_lines.First(); - while (node) + SendNotify( line, wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK ); + return; + } + + if (event.LeftDown()) + { + m_usedKeys = FALSE; + wxListLineData *oldCurrent = m_current; + if (m_mode & wxLC_SINGLE_SEL) { - wxListLineData *test_line = (wxListLineData*)node->Data(); - numOfCurrent++; - if (test_line == oldCurrent) break; - node = node->Next(); + m_current = line; + HilightAll( FALSE ); + m_current->ReverseHilight(); + RefreshLine( m_current ); } - int numOfLine = -1; - node = m_lines.First(); - while (node) + else { - wxListLineData *test_line = (wxListLineData*)node->Data(); - numOfLine++; - if (test_line == line) break; - node = node->Next(); + if (event.ShiftDown()) + { + m_current = line; + m_current->ReverseHilight(); + RefreshLine( m_current ); + } + else if (event.ControlDown()) + { + m_current = line; + + int numOfCurrent = -1; + node = m_lines.First(); + while (node) + { + wxListLineData *test_line = (wxListLineData*)node->Data(); + numOfCurrent++; + if (test_line == oldCurrent) break; + node = node->Next(); + } + + int numOfLine = -1; + node = m_lines.First(); + while (node) + { + wxListLineData *test_line = (wxListLineData*)node->Data(); + numOfLine++; + if (test_line == line) break; + node = node->Next(); + } + + if (numOfLine < numOfCurrent) + { + int i = numOfLine; + numOfLine = numOfCurrent; + numOfCurrent = i; + } + + wxNode *node = m_lines.Nth( numOfCurrent ); + for (int i = 0; i <= numOfLine-numOfCurrent; i++) + { + wxListLineData *test_line= (wxListLineData*)node->Data(); + test_line->Hilight(TRUE); + RefreshLine( test_line ); + node = node->Next(); + } + } + else + { + m_current = line; + HilightAll( FALSE ); + m_current->ReverseHilight(); + RefreshLine( m_current ); + } } - - if (numOfLine < numOfCurrent) - { int i = numOfLine; numOfLine = numOfCurrent; numOfCurrent = i; } - wxNode *node = m_lines.Nth( numOfCurrent ); - for (int i = 0; i <= numOfLine-numOfCurrent; i++) - { - wxListLineData *test_line= (wxListLineData*)node->Data(); - test_line->Hilight(TRUE); - RefreshLine( test_line ); - node = node->Next(); - } - } - else - { - m_current = line; - HilightAll( FALSE ); - m_current->ReverseHilight(); - RefreshLine( m_current ); - } - } - if (m_current != oldCurrent) - { - RefreshLine( oldCurrent ); - UnfocusLine( oldCurrent ); - FocusLine( m_current ); + if (m_current != oldCurrent) + { + RefreshLine( oldCurrent ); + UnfocusLine( oldCurrent ); + FocusLine( m_current ); + } + m_lastOnSame = (m_current == oldCurrent); + return; } - m_lastOnSame = (m_current == oldCurrent); - return; - } - } void wxListMainWindow::MoveToFocus( void ) { - if (!m_current) return; + 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) - { - if (GetScrollPos( wxHORIZONTAL ) != 0) SetScrollPos( wxHORIZONTAL, 0); - int y_s = m_yScroll*GetScrollPos( wxVERTICAL ); - if ((y > y_s) && (y+h < y_s+h_p)) return; - if (y-y_s < 5) SetScrollPos( wxVERTICAL, (y-5)/m_yScroll ); - if (y+h+5 > y_s+h_p) SetScrollPos( wxVERTICAL, (y+h-h_p+h+15)/m_yScroll ); - m_dirty = TRUE; - } - else - { - if (GetScrollPos( wxVERTICAL ) != 0) SetScrollPos( wxVERTICAL, 0); - int x_s = m_xScroll*GetScrollPos( wxHORIZONTAL ); - if ((x > x_s) && (x+w < x_s+w_p)) return; - if (x-x_s < 5) SetScrollPos( wxHORIZONTAL, (x-5)/m_xScroll ); - if (x+w-5 > x_s+w_p) SetScrollPos( wxHORIZONTAL, (x+w-w_p+15)/m_xScroll ); - m_dirty = TRUE; - } + 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) + { + if (GetScrollPos( wxHORIZONTAL ) != 0) SetScrollPos( wxHORIZONTAL, 0); + int y_s = m_yScroll*GetScrollPos( wxVERTICAL ); + if ((y > y_s) && (y+h < y_s+h_p)) return; + if (y-y_s < 5) SetScrollPos( wxVERTICAL, (y-5-h_p/2)/m_yScroll ); + if (y+h+5 > y_s+h_p) SetScrollPos( wxVERTICAL, (y+h-h_p/2+h+15)/m_yScroll ); + m_dirty = TRUE; + } + else + { + if (GetScrollPos( wxVERTICAL ) != 0) SetScrollPos( wxVERTICAL, 0); + int x_s = m_xScroll*GetScrollPos( wxHORIZONTAL ); + if ((x > x_s) && (x+w < x_s+w_p)) return; + if (x-x_s < 5) SetScrollPos( wxHORIZONTAL, (x-5)/m_xScroll ); + if (x+w-5 > x_s+w_p) SetScrollPos( wxHORIZONTAL, (x+w-w_p+15)/m_xScroll ); + m_dirty = TRUE; + } } void wxListMainWindow::OnArrowChar( wxListLineData *newCurrent, bool shiftDown ) { - if ((m_mode & wxLC_SINGLE_SEL) || (m_usedKeys == FALSE)) m_current->Hilight( FALSE ); - wxListLineData *oldCurrent = m_current; - m_current = newCurrent; - MoveToFocus(); - if (shiftDown || (m_mode & wxLC_SINGLE_SEL)) m_current->Hilight( TRUE ); - RefreshLine( m_current ); - RefreshLine( oldCurrent ); - FocusLine( m_current ); - UnfocusLine( oldCurrent ); + if ((m_mode & wxLC_SINGLE_SEL) || (m_usedKeys == FALSE)) m_current->Hilight( FALSE ); + wxListLineData *oldCurrent = m_current; + m_current = newCurrent; + MoveToFocus(); + if (shiftDown || (m_mode & wxLC_SINGLE_SEL)) m_current->Hilight( TRUE ); + RefreshLine( m_current ); + RefreshLine( oldCurrent ); + FocusLine( m_current ); + UnfocusLine( oldCurrent ); } void wxListMainWindow::OnChar( wxKeyEvent &event ) @@ -1460,8 +1448,8 @@ void wxListMainWindow::OnChar( wxKeyEvent &event ) wxNode *node = m_lines.Member( m_current )->Next(); if (node) m_current = (wxListLineData*)node->Data(); MoveToFocus(); - RefreshLine( oldCurrent ); - RefreshLine( m_current ); + RefreshLine( oldCurrent ); + RefreshLine( m_current ); UnfocusLine( oldCurrent ); FocusLine( m_current ); } @@ -1470,7 +1458,11 @@ void wxListMainWindow::OnChar( wxKeyEvent &event ) case WXK_RETURN: case WXK_EXECUTE: { - ActivateLine( m_current ); + wxListEvent le( wxEVT_COMMAND_LIST_KEY_DOWN, GetParent()->GetId() ); + le.SetEventObject( GetParent() ); + le.m_itemIndex = GetIndexOfLine( m_current ); + m_current->GetItem( 0, le.m_item ); + GetParent()->GetEventHandler()->ProcessEvent( le ); } break; default: @@ -1662,195 +1654,197 @@ void wxListMainWindow::GetColumn( int col, wxListItem &item ) int wxListMainWindow::GetColumnWidth( int col ) { - wxNode *node = m_columns.Nth( col ); - if (node) - { - wxListHeaderData *column = (wxListHeaderData*)node->Data(); - return column->GetWidth(); - } - else - return 0; + wxNode *node = m_columns.Nth( col ); + if (node) + { + wxListHeaderData *column = (wxListHeaderData*)node->Data(); + return column->GetWidth(); + } + else + { + return 0; + } } int wxListMainWindow::GetColumnCount( void ) { - return m_columns.Number(); + return m_columns.Number(); } int wxListMainWindow::GetCountPerPage( void ) { - return m_visibleLines; + return m_visibleLines; } void wxListMainWindow::SetItem( wxListItem &item ) { - m_dirty = TRUE; - wxNode *node = m_lines.Nth( item.m_itemId ); - if (node) - { - wxListLineData *line = (wxListLineData*)node->Data(); - if (m_mode & wxLC_REPORT) item.m_width = GetColumnWidth( item.m_col )-3; - line->SetItem( item.m_col, item ); - } + m_dirty = TRUE; + wxNode *node = m_lines.Nth( item.m_itemId ); + if (node) + { + wxListLineData *line = (wxListLineData*)node->Data(); + if (m_mode & wxLC_REPORT) item.m_width = GetColumnWidth( item.m_col )-3; + line->SetItem( item.m_col, item ); + } } void wxListMainWindow::SetItemState( long item, long state, long stateMask ) { - // m_dirty = TRUE; no recalcs needed + // m_dirty = TRUE; no recalcs needed - wxListLineData *oldCurrent = m_current; + wxListLineData *oldCurrent = m_current; - if (stateMask & wxLIST_STATE_FOCUSED) - { - wxNode *node = m_lines.Nth( item ); - if (node) + if (stateMask & wxLIST_STATE_FOCUSED) { - wxListLineData *line = (wxListLineData*)node->Data(); - UnfocusLine( m_current ); - m_current = line; - FocusLine( m_current ); - RefreshLine( m_current ); - RefreshLine( oldCurrent ); + wxNode *node = m_lines.Nth( item ); + if (node) + { + wxListLineData *line = (wxListLineData*)node->Data(); + UnfocusLine( m_current ); + m_current = line; + FocusLine( m_current ); + RefreshLine( m_current ); + RefreshLine( oldCurrent ); + } } - } - - if (stateMask & wxLIST_STATE_SELECTED) - { - bool on = state & wxLIST_STATE_SELECTED; - if (!on && (m_mode & wxLC_SINGLE_SEL)) return; - wxNode *node = m_lines.Nth( item ); - if (node) + if (stateMask & wxLIST_STATE_SELECTED) { - wxListLineData *line = (wxListLineData*)node->Data(); - if (m_mode & wxLC_SINGLE_SEL) - { - UnfocusLine( m_current ); - m_current = line; - FocusLine( m_current ); - oldCurrent->Hilight( FALSE ); - RefreshLine( m_current ); - RefreshLine( oldCurrent ); - } - bool on = state & wxLIST_STATE_SELECTED; - line->Hilight( on ); - RefreshLine( line ); + bool on = state & wxLIST_STATE_SELECTED; + if (!on && (m_mode & wxLC_SINGLE_SEL)) return; + + wxNode *node = m_lines.Nth( item ); + if (node) + { + wxListLineData *line = (wxListLineData*)node->Data(); + if (m_mode & wxLC_SINGLE_SEL) + { + UnfocusLine( m_current ); + m_current = line; + FocusLine( m_current ); + oldCurrent->Hilight( FALSE ); + RefreshLine( m_current ); + RefreshLine( oldCurrent ); + } + bool on = state & wxLIST_STATE_SELECTED; + line->Hilight( on ); + RefreshLine( line ); + } } - } } int wxListMainWindow::GetItemState( long item, long stateMask ) { - int ret = wxLIST_STATE_DONTCARE; - if (stateMask & wxLIST_STATE_FOCUSED) - { - wxNode *node = m_lines.Nth( item ); - if (node) + int ret = wxLIST_STATE_DONTCARE; + if (stateMask & wxLIST_STATE_FOCUSED) { - wxListLineData *line = (wxListLineData*)node->Data(); - if (line == m_current) ret |= wxLIST_STATE_FOCUSED; + wxNode *node = m_lines.Nth( item ); + if (node) + { + wxListLineData *line = (wxListLineData*)node->Data(); + if (line == m_current) ret |= wxLIST_STATE_FOCUSED; + } } - } - if (stateMask & wxLIST_STATE_SELECTED) - { - wxNode *node = m_lines.Nth( item ); - if (node) + if (stateMask & wxLIST_STATE_SELECTED) { - wxListLineData *line = (wxListLineData*)node->Data(); - if (line->IsHilighted()) ret |= wxLIST_STATE_FOCUSED; + wxNode *node = m_lines.Nth( item ); + if (node) + { + wxListLineData *line = (wxListLineData*)node->Data(); + if (line->IsHilighted()) ret |= wxLIST_STATE_FOCUSED; + } } - } - return ret; + return ret; } void wxListMainWindow::GetItem( wxListItem &item ) { - wxNode *node = m_lines.Nth( item.m_itemId ); - if (node) - { - wxListLineData *line = (wxListLineData*)node->Data(); - line->GetItem( item.m_col, item ); - } - else - { - item.m_mask = 0; - item.m_text = ""; - item.m_image = 0; - item.m_data = 0; - } + wxNode *node = m_lines.Nth( item.m_itemId ); + if (node) + { + wxListLineData *line = (wxListLineData*)node->Data(); + line->GetItem( item.m_col, item ); + } + else + { + item.m_mask = 0; + item.m_text = ""; + item.m_image = 0; + item.m_data = 0; + } } int wxListMainWindow::GetItemCount( void ) { - return m_lines.Number(); + return m_lines.Number(); } void wxListMainWindow::GetItemRect( long index, wxRectangle &rect ) { - wxNode *node = m_lines.Nth( index ); - if (node) - { - wxListLineData *line = (wxListLineData*)node->Data(); - line->GetRect( rect ); - } - else - { - rect.x = 0; - rect.y = 0; - rect.width = 0; - rect.height = 0; - } + wxNode *node = m_lines.Nth( index ); + if (node) + { + wxListLineData *line = (wxListLineData*)node->Data(); + line->GetRect( rect ); + } + else + { + rect.x = 0; + rect.y = 0; + rect.width = 0; + rect.height = 0; + } } bool wxListMainWindow::GetItemPosition(long item, wxPoint& pos) { - wxNode *node = m_lines.Nth( item ); - if (node) - { - wxRectangle rect; - wxListLineData *line = (wxListLineData*)node->Data(); - line->GetRect( rect ); - pos.x = rect.x; - pos.y = rect.y; - } - else - { - pos.x = 0; - pos.y = 0; - } - return TRUE; + wxNode *node = m_lines.Nth( item ); + if (node) + { + wxRectangle rect; + wxListLineData *line = (wxListLineData*)node->Data(); + line->GetRect( rect ); + pos.x = rect.x; + pos.y = rect.y; + } + else + { + pos.x = 0; + pos.y = 0; + } + return TRUE; } int wxListMainWindow::GetSelectedItemCount( void ) { - int ret = 0; - wxNode *node = m_lines.First(); - while (node) - { - wxListLineData *line = (wxListLineData*)node->Data(); - if (line->IsHilighted()) ret++; - node = node->Next(); - } - return ret; + int ret = 0; + wxNode *node = m_lines.First(); + while (node) + { + wxListLineData *line = (wxListLineData*)node->Data(); + if (line->IsHilighted()) ret++; + node = node->Next(); + } + return ret; } void wxListMainWindow::SetMode( long mode ) { - m_dirty = TRUE; - m_mode = mode; + m_dirty = TRUE; + m_mode = mode; - DeleteEverything(); + DeleteEverything(); - if (m_mode & wxLC_REPORT) - { - m_xScroll = 0; - m_yScroll = 15; - } - else - { - m_xScroll = 15; - m_yScroll = 0; - } + if (m_mode & wxLC_REPORT) + { + m_xScroll = 0; + m_yScroll = 15; + } + else + { + m_xScroll = 15; + m_yScroll = 0; + } } long wxListMainWindow::GetMode( void ) const @@ -1860,117 +1854,120 @@ long wxListMainWindow::GetMode( void ) const void wxListMainWindow::CalculatePositions( void ) { - if (!m_lines.First()) return; + if (!m_lines.First()) return; - wxPaintDC dc( this ); - dc.SetFont( GetFont() ); + wxPaintDC dc( this ); + dc.SetFont( GetFont() ); - int iconSpacing = 0; - if (m_mode & wxLC_ICON) iconSpacing = m_normal_spacing; - if (m_mode & wxLC_SMALL_ICON) iconSpacing = m_small_spacing; + 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 + // 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; - - wxListLineData *line = (wxListLineData*)m_lines.First()->Data(); - line->CalculateSize( &dc, iconSpacing ); - int dummy = 0; - line->GetSize( dummy, lineSpacing ); - lineSpacing += 4; + int lineWidth = 0; + int lineHeight = 0; + int lineSpacing = 0; - int clientWidth = 0; - int clientHeight = 0; + wxListLineData *line = (wxListLineData*)m_lines.First()->Data(); + line->CalculateSize( &dc, iconSpacing ); + int dummy = 0; + line->GetSize( dummy, lineSpacing ); + lineSpacing += 4; - if (m_mode & wxLC_REPORT) - { - int x = 4; - int y = 1; - int entireHeight = m_lines.Number() * lineSpacing + 10; - int scroll_pos = GetScrollPos( wxVERTICAL ); - SetScrollbars( m_xScroll, m_yScroll, 0, (entireHeight+10) / m_yScroll, 0, scroll_pos, TRUE ); - GetClientSize( &clientWidth, &clientHeight ); + int clientWidth = 0; + int clientHeight = 0; - wxNode* node = m_lines.First(); - while (node) + if (m_mode & wxLC_REPORT) { - wxListLineData *line = (wxListLineData*)node->Data(); - line->CalculateSize( &dc, iconSpacing ); - line->SetPosition( &dc, x, y, clientWidth ); - int col_x = 2; - for (int i = 0; i < GetColumnCount(); i++) - { - line->SetColumnPosition( i, col_x ); - col_x += GetColumnWidth( i ); - } - y += lineSpacing; - node = node->Next(); + int x = 4; + int y = 1; + int entireHeight = m_lines.Number() * lineSpacing + 2; + int scroll_pos = GetScrollPos( wxVERTICAL ); + SetScrollbars( m_xScroll, m_yScroll, 0, (entireHeight+15-6) / m_yScroll, 0, scroll_pos, TRUE ); + GetClientSize( &clientWidth, &clientHeight ); + + wxNode* node = m_lines.First(); + while (node) + { + wxListLineData *line = (wxListLineData*)node->Data(); + line->CalculateSize( &dc, iconSpacing ); + line->SetPosition( &dc, x, y, clientWidth ); + int col_x = 2; + for (int i = 0; i < GetColumnCount(); i++) + { + line->SetColumnPosition( i, col_x ); + col_x += GetColumnWidth( i ); + } + y += lineSpacing; // one pixel blank line between items + node = node->Next(); + } + m_visibleLines = m_lines.GetCount(); } - } - else - { - // 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 + else + { + // 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 ); + GetSize( &clientWidth, &clientHeight ); + clientHeight -= 4; // sunken frame - int entireWidth = 0; + int entireWidth = 0; - for (int tries = 0; tries < 2; tries++) - { - entireWidth = 0; - int x = 5; - int y = 3; - int maxWidth = 0; - wxNode *node = m_lines.First(); - while (node) - { - wxListLineData *line = (wxListLineData*)node->Data(); - line->CalculateSize( &dc, iconSpacing ); - line->SetPosition( &dc, x, y, clientWidth ); - line->GetSize( lineWidth, lineHeight ); - if (lineWidth > maxWidth) maxWidth = lineWidth; - y += lineSpacing; - if (y+lineSpacing-8 > clientHeight-6) - { - y = 3; - x += maxWidth+13; - entireWidth += maxWidth+13; - maxWidth = 0; - } - node = node->Next(); - if (!node) entireWidth += maxWidth; - if ((tries == 0) && (entireWidth > clientWidth)) + for (int tries = 0; tries < 2; tries++) { - clientHeight -= 15; // scrollbar height - break; + entireWidth = 0; + int x = 5; // painting is done at x-2 + int y = 5; // painting is done at y-2 + int maxWidth = 0; + wxNode *node = m_lines.First(); + while (node) + { + wxListLineData *line = (wxListLineData*)node->Data(); + line->CalculateSize( &dc, iconSpacing ); + line->SetPosition( &dc, x, y, clientWidth ); + line->GetSize( lineWidth, lineHeight ); + if (lineWidth > maxWidth) maxWidth = lineWidth; + y += lineSpacing; + if (y+lineSpacing-7 >= clientHeight) // -7 for earlier "line breaking" + { + y = 5; + x += maxWidth+5; + entireWidth += maxWidth+5; + maxWidth = 0; + } + node = node->Next(); + if (!node) entireWidth += maxWidth; + if ((tries == 0) && (entireWidth > clientWidth)) + { + clientHeight -= 15; // scrollbar height + break; + } + if (!node) tries = 1; // everything fits, no second try required + } } - if (!node) tries = 1; // everything fits, no second try required - } + m_visibleLines = (clientHeight+7) / (lineSpacing); // +7 for earlier "line breaking" + + int scroll_pos = GetScrollPos( wxHORIZONTAL ); + SetScrollbars( m_xScroll, m_yScroll, (entireWidth+15) / m_xScroll, 0, scroll_pos, 0, TRUE ); } - int scroll_pos = GetScrollPos( wxHORIZONTAL ); - SetScrollbars( m_xScroll, m_yScroll, (entireWidth+15) / m_xScroll, 0, scroll_pos, 0, TRUE ); - } - m_visibleLines = (clientHeight-4) / (lineSpacing); } void wxListMainWindow::RealizeChanges( void ) { - if (!m_current) - { - wxNode *node = m_lines.First(); - if (node) m_current = (wxListLineData*)node->Data(); - } - if (m_current) - { - FocusLine( m_current ); - if (m_mode & wxLC_SINGLE_SEL) m_current->Hilight( TRUE ); - } + if (!m_current) + { + wxNode *node = m_lines.First(); + if (node) m_current = (wxListLineData*)node->Data(); + } + if (m_current) + { + FocusLine( m_current ); + if (m_mode & wxLC_SINGLE_SEL) m_current->Hilight( TRUE ); + } } long wxListMainWindow::GetNextItem( long item, int WXUNUSED(geometry), int state ) @@ -2178,12 +2175,6 @@ void wxListMainWindow::SortItems( wxListCtrlCompare fn, long data ) m_lines.Sort( list_ctrl_compare_func_1 ); } -bool wxListMainWindow::OnListNotify( wxListEvent &event ) -{ - if (GetParent()) GetParent()->GetEventHandler()->ProcessEvent( event ); - return FALSE; -} - // ------------------------------------------------------------------------------------- // wxListItem // ------------------------------------------------------------------------------------- @@ -2208,15 +2199,18 @@ wxListItem::wxListItem(void) // wxListEvent // ------------------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxListEvent, wxCommandEvent) +IMPLEMENT_DYNAMIC_CLASS(wxListEvent, wxNotifyEvent) wxListEvent::wxListEvent( wxEventType commandType, int id ): - wxCommandEvent( commandType, id ) + wxNotifyEvent( commandType, id ) { m_code = 0; m_itemIndex = 0; + m_oldItemIndex = 0; m_col = 0; m_cancelled = FALSE; + m_pointDrag.x = 0; + m_pointDrag.y = 0; } // ------------------------------------------------------------------------------------- @@ -2486,6 +2480,11 @@ int wxListCtrl::GetItemCount(void) const return m_mainWin->GetItemCount(); } +int wxListCtrl::GetColumnCount(void) const +{ + return m_mainWin->GetColumnCount(); +} + void wxListCtrl::SetItemSpacing( int spacing, bool isSmall ) { m_mainWin->SetItemSpacing( spacing, isSmall ); diff --git a/src/generic/statusbr.cpp b/src/generic/statusbr.cpp index 13c524247e..01321e734a 100644 --- a/src/generic/statusbr.cpp +++ b/src/generic/statusbr.cpp @@ -199,6 +199,11 @@ void wxStatusBar::DrawFieldText(wxDC& dc, int i) int xpos = rect.x + leftMargin; int ypos = (int) (((rect.height - y) / 2 ) + rect.y + 0.5) ; + +#ifdef __WXGTK__ + xpos++; + ypos++; +#endif dc.SetClippingRegion(rect.x, rect.y, rect.width, rect.height); diff --git a/src/generic/treectrl.cpp b/src/generic/treectrl.cpp index 1374ae3187..480eb4c13f 100644 --- a/src/generic/treectrl.cpp +++ b/src/generic/treectrl.cpp @@ -140,10 +140,10 @@ private: // wxTreeEvent // ----------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxTreeEvent, wxCommandEvent) +IMPLEMENT_DYNAMIC_CLASS(wxTreeEvent, wxNotifyEvent) wxTreeEvent::wxTreeEvent( wxEventType commandType, int id ) - : wxCommandEvent( commandType, id ) + : wxNotifyEvent( commandType, id ) { m_code = 0; m_itemOld = (wxGenericTreeItem *)NULL; diff --git a/src/gtk/dnd.cpp b/src/gtk/dnd.cpp index 8df9096096..e36ee810cb 100644 --- a/src/gtk/dnd.cpp +++ b/src/gtk/dnd.cpp @@ -785,7 +785,7 @@ wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) ) shape_motion( drag_icon, (GdkEventMotion *)NULL ); shape_motion( drop_icon, (GdkEventMotion *)NULL ); */ - + while (gdk_dnd.drag_really || gdk_dnd.drag_perhaps) wxYield(); UnregisterWindow(); diff --git a/src/gtk/notebook.cpp b/src/gtk/notebook.cpp index 0a71d34dd3..0ae08846d6 100644 --- a/src/gtk/notebook.cpp +++ b/src/gtk/notebook.cpp @@ -527,5 +527,5 @@ void wxNotebook::ApplyWidgetStyle() // wxNotebookEvent //----------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxCommandEvent) +IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxNotifyEvent) diff --git a/src/gtk/radiobox.cpp b/src/gtk/radiobox.cpp index 7121185c9e..38e1be21dc 100644 --- a/src/gtk/radiobox.cpp +++ b/src/gtk/radiobox.cpp @@ -86,7 +86,7 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title, GtkRadioButton *m_radio = (GtkRadioButton*) NULL; - if (m_windowStyle & wxRA_VERTICAL) + if (m_windowStyle & wxRA_HORIZONTAL) { GSList *radio_button_group = (GSList *) NULL; for (int i = 0; i < n; i++) @@ -194,7 +194,7 @@ void wxRadioBox::OnSize( wxSizeEvent &event ) int x = m_x+5; int y = m_y+15; - if (m_windowStyle & wxRA_VERTICAL) + if (m_windowStyle & wxRA_HORIZONTAL) { wxNode *node = m_boxes.First(); while (node) diff --git a/src/gtk/stattext.cpp b/src/gtk/stattext.cpp index d753dc0155..fd3c5ee83d 100644 --- a/src/gtk/stattext.cpp +++ b/src/gtk/stattext.cpp @@ -66,12 +66,10 @@ bool wxStaticText::Create( wxWindow *parent, wxWindowID id, const wxString &labe int x = gdk_string_measure( m_widget->style->font, s ) + 4; if (x > newSize.x) newSize.x = x; *nl++ = '\n'; - if ((nl = strchr(s = nl, '\n'))) - { - ++y; - } - else - { + ++y; + if (! (nl = strchr(s = nl, '\n'))) + { + int x = gdk_string_measure( m_widget->style->font, s ) + 4; if (x > newSize.x) newSize.x = x; } @@ -87,7 +85,7 @@ bool wxStaticText::Create( wxWindow *parent, wxWindowID id, const wxString &labe if (y == 1) newSize.y = 26; else - newSize.y = 4 + y * (m_widget->style->font->ascent + 2*m_widget->style->font->descent); + newSize.y = 4 + y * (m_widget->style->font->ascent + m_widget->style->font->descent + 2); } SetSize( newSize.x, newSize.y ); diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index c376ff0886..13c4c1d7b5 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -2428,6 +2428,8 @@ void wxWindow::SetScrollbar( int orient, int pos, int thumbVisible, float fpos = (float)pos; float frange = (float)range; float fthumb = (float)thumbVisible; + if (fpos > frange-fthumb) fpos = frange-fthumb; + if (fpos < 0.0) fpos = 0.0; if ((fabs(frange-m_hAdjust->upper) < 0.2) && (fabs(fthumb-m_hAdjust->page_size) < 0.2)) @@ -2450,6 +2452,8 @@ void wxWindow::SetScrollbar( int orient, int pos, int thumbVisible, float fpos = (float)pos; float frange = (float)range; float fthumb = (float)thumbVisible; + if (fpos > frange-fthumb) fpos = frange-fthumb; + if (fpos < 0.0) fpos = 0.0; if ((fabs(frange-m_vAdjust->upper) < 0.2) && (fabs(fthumb-m_vAdjust->page_size) < 0.2)) @@ -2486,10 +2490,12 @@ void wxWindow::SetScrollPos( int orient, int pos, bool WXUNUSED(refresh) ) wxASSERT_MSG( (m_wxwindow != NULL), "window needs client area" ); if (!m_wxwindow) return; - + if (orient == wxHORIZONTAL) { float fpos = (float)pos; + if (fpos > m_hAdjust->upper - m_hAdjust->page_size) fpos = m_hAdjust->upper - m_hAdjust->page_size; + if (fpos < 0.0) fpos = 0.0; m_oldHorizontalPos = fpos; if (fabs(fpos-m_hAdjust->value) < 0.2) return; @@ -2498,7 +2504,10 @@ void wxWindow::SetScrollPos( int orient, int pos, bool WXUNUSED(refresh) ) else { float fpos = (float)pos; + if (fpos > m_vAdjust->upper - m_vAdjust->page_size) fpos = m_vAdjust->upper - m_vAdjust->page_size; + if (fpos < 0.0) fpos = 0.0; m_oldVerticalPos = fpos; + if (fabs(fpos-m_vAdjust->value) < 0.2) return; m_vAdjust->value = fpos; } diff --git a/src/gtk1/dnd.cpp b/src/gtk1/dnd.cpp index 8df9096096..e36ee810cb 100644 --- a/src/gtk1/dnd.cpp +++ b/src/gtk1/dnd.cpp @@ -785,7 +785,7 @@ wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) ) shape_motion( drag_icon, (GdkEventMotion *)NULL ); shape_motion( drop_icon, (GdkEventMotion *)NULL ); */ - + while (gdk_dnd.drag_really || gdk_dnd.drag_perhaps) wxYield(); UnregisterWindow(); diff --git a/src/gtk1/notebook.cpp b/src/gtk1/notebook.cpp index 0a71d34dd3..0ae08846d6 100644 --- a/src/gtk1/notebook.cpp +++ b/src/gtk1/notebook.cpp @@ -527,5 +527,5 @@ void wxNotebook::ApplyWidgetStyle() // wxNotebookEvent //----------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxCommandEvent) +IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxNotifyEvent) diff --git a/src/gtk1/radiobox.cpp b/src/gtk1/radiobox.cpp index 7121185c9e..38e1be21dc 100644 --- a/src/gtk1/radiobox.cpp +++ b/src/gtk1/radiobox.cpp @@ -86,7 +86,7 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title, GtkRadioButton *m_radio = (GtkRadioButton*) NULL; - if (m_windowStyle & wxRA_VERTICAL) + if (m_windowStyle & wxRA_HORIZONTAL) { GSList *radio_button_group = (GSList *) NULL; for (int i = 0; i < n; i++) @@ -194,7 +194,7 @@ void wxRadioBox::OnSize( wxSizeEvent &event ) int x = m_x+5; int y = m_y+15; - if (m_windowStyle & wxRA_VERTICAL) + if (m_windowStyle & wxRA_HORIZONTAL) { wxNode *node = m_boxes.First(); while (node) diff --git a/src/gtk1/stattext.cpp b/src/gtk1/stattext.cpp index d753dc0155..fd3c5ee83d 100644 --- a/src/gtk1/stattext.cpp +++ b/src/gtk1/stattext.cpp @@ -66,12 +66,10 @@ bool wxStaticText::Create( wxWindow *parent, wxWindowID id, const wxString &labe int x = gdk_string_measure( m_widget->style->font, s ) + 4; if (x > newSize.x) newSize.x = x; *nl++ = '\n'; - if ((nl = strchr(s = nl, '\n'))) - { - ++y; - } - else - { + ++y; + if (! (nl = strchr(s = nl, '\n'))) + { + int x = gdk_string_measure( m_widget->style->font, s ) + 4; if (x > newSize.x) newSize.x = x; } @@ -87,7 +85,7 @@ bool wxStaticText::Create( wxWindow *parent, wxWindowID id, const wxString &labe if (y == 1) newSize.y = 26; else - newSize.y = 4 + y * (m_widget->style->font->ascent + 2*m_widget->style->font->descent); + newSize.y = 4 + y * (m_widget->style->font->ascent + m_widget->style->font->descent + 2); } SetSize( newSize.x, newSize.y ); diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index c376ff0886..13c4c1d7b5 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -2428,6 +2428,8 @@ void wxWindow::SetScrollbar( int orient, int pos, int thumbVisible, float fpos = (float)pos; float frange = (float)range; float fthumb = (float)thumbVisible; + if (fpos > frange-fthumb) fpos = frange-fthumb; + if (fpos < 0.0) fpos = 0.0; if ((fabs(frange-m_hAdjust->upper) < 0.2) && (fabs(fthumb-m_hAdjust->page_size) < 0.2)) @@ -2450,6 +2452,8 @@ void wxWindow::SetScrollbar( int orient, int pos, int thumbVisible, float fpos = (float)pos; float frange = (float)range; float fthumb = (float)thumbVisible; + if (fpos > frange-fthumb) fpos = frange-fthumb; + if (fpos < 0.0) fpos = 0.0; if ((fabs(frange-m_vAdjust->upper) < 0.2) && (fabs(fthumb-m_vAdjust->page_size) < 0.2)) @@ -2486,10 +2490,12 @@ void wxWindow::SetScrollPos( int orient, int pos, bool WXUNUSED(refresh) ) wxASSERT_MSG( (m_wxwindow != NULL), "window needs client area" ); if (!m_wxwindow) return; - + if (orient == wxHORIZONTAL) { float fpos = (float)pos; + if (fpos > m_hAdjust->upper - m_hAdjust->page_size) fpos = m_hAdjust->upper - m_hAdjust->page_size; + if (fpos < 0.0) fpos = 0.0; m_oldHorizontalPos = fpos; if (fabs(fpos-m_hAdjust->value) < 0.2) return; @@ -2498,7 +2504,10 @@ void wxWindow::SetScrollPos( int orient, int pos, bool WXUNUSED(refresh) ) else { float fpos = (float)pos; + if (fpos > m_vAdjust->upper - m_vAdjust->page_size) fpos = m_vAdjust->upper - m_vAdjust->page_size; + if (fpos < 0.0) fpos = 0.0; m_oldVerticalPos = fpos; + if (fabs(fpos-m_vAdjust->value) < 0.2) return; m_vAdjust->value = fpos; } diff --git a/src/msw/data.cpp b/src/msw/data.cpp index 53d6991dc3..8999733aef 100644 --- a/src/msw/data.cpp +++ b/src/msw/data.cpp @@ -332,6 +332,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxResourceTable, wxHashTable) IMPLEMENT_DYNAMIC_CLASS(wxEvtHandler, wxObject) IMPLEMENT_ABSTRACT_CLASS(wxEvent, wxObject) IMPLEMENT_DYNAMIC_CLASS(wxCommandEvent, wxEvent) +IMPLEMENT_DYNAMIC_CLASS(wxNotifyEvent, wxCommandEvent) IMPLEMENT_DYNAMIC_CLASS(wxScrollEvent, wxCommandEvent) IMPLEMENT_DYNAMIC_CLASS(wxMouseEvent, wxEvent) IMPLEMENT_DYNAMIC_CLASS(wxKeyEvent, wxEvent) diff --git a/src/msw/gauge95.cpp b/src/msw/gauge95.cpp index f671fb2c7e..31b9f85f19 100644 --- a/src/msw/gauge95.cpp +++ b/src/msw/gauge95.cpp @@ -86,7 +86,7 @@ bool wxGauge95::Create(wxWindow *parent, wxWindowID id, if (width == -1) width = 50; if (height == -1) - height = 50; + height = 28; SetSize(x, y, width, height); ShowWindow((HWND) GetHWND(), SW_SHOW); diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index 66e3278c0e..950b6d809b 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -1430,7 +1430,7 @@ static void wxConvertToMSWListItem(const wxListCtrl *ctrl, wxListItem& info, LV_ } // List event -IMPLEMENT_DYNAMIC_CLASS(wxListEvent, wxCommandEvent) +IMPLEMENT_DYNAMIC_CLASS(wxListEvent, wxNotifyEvent) wxListEvent::wxListEvent(wxEventType commandType, int id) : wxNotifyEvent(commandType, id) diff --git a/src/msw/notebook.cpp b/src/msw/notebook.cpp index 74dfb4cd9d..28577f7992 100644 --- a/src/msw/notebook.cpp +++ b/src/msw/notebook.cpp @@ -69,7 +69,7 @@ END_EVENT_TABLE() IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxControl) - IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxCommandEvent) + IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxNotifyEvent) #endif // ============================================================================ diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index cbecafa355..7fcab3a9a8 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -939,7 +939,7 @@ bool wxTreeCtrl::MSWNotify(WXWPARAM wParam, WXLPARAM lParam, WXLPARAM *result) // Tree event // ---------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxTreeEvent, wxCommandEvent) +IMPLEMENT_DYNAMIC_CLASS(wxTreeEvent, wxNotifyEvent) wxTreeEvent::wxTreeEvent(wxEventType commandType, int id) : wxNotifyEvent(commandType, id) -- 2.45.2