Re-Added wxStream::StreamSize()
Added in-place editting to wxTreeCtrl, modified wxListCtrl in-place editting Corrected behaviour of wxToolBar::Toggle() to not send messages and to report the correct state Removed many #include "wx/wx.h" to speed up compilation Some more compile fixes and tests. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3132 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -44,7 +44,7 @@
|
||||
#endif //__BORLANDC__
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include <wx/wx.h>
|
||||
#include "wx/string.h"
|
||||
#endif //WX_PRECOMP
|
||||
|
||||
#if wxUSE_ODBC
|
||||
|
@@ -21,7 +21,10 @@
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#include "wx/settings.h"
|
||||
#include "wx/window.h"
|
||||
#include "wx/dcclient.h"
|
||||
#include "wx/dcmemory.h"
|
||||
#endif
|
||||
|
||||
#if wxUSE_TOOLBAR
|
||||
|
@@ -29,7 +29,8 @@
|
||||
#endif
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/wx.h"
|
||||
#include "wx/window.h"
|
||||
#include "wx/dcclient.h"
|
||||
#endif //WX_PRECOMP
|
||||
|
||||
#include "wx/caret.h"
|
||||
|
@@ -27,6 +27,8 @@
|
||||
#include "wx/utils.h"
|
||||
#include "wx/list.h"
|
||||
#include "wx/intl.h"
|
||||
#include "wx/msgdlg.h"
|
||||
#include "wx/choicdlg.h"
|
||||
#endif
|
||||
|
||||
#include "wx/helpbase.h"
|
||||
|
@@ -908,16 +908,14 @@ void wxListTextCtrl::OnChar( wxKeyEvent &event )
|
||||
(*m_accept) = TRUE;
|
||||
(*m_res) = GetValue();
|
||||
m_owner->OnRenameAccept();
|
||||
// Show( FALSE );
|
||||
Destroy();
|
||||
if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this);
|
||||
return;
|
||||
}
|
||||
if (event.m_keyCode == WXK_ESCAPE)
|
||||
{
|
||||
(*m_accept) = FALSE;
|
||||
(*m_res) = "";
|
||||
// Show( FALSE );
|
||||
Destroy();
|
||||
if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this);
|
||||
return;
|
||||
}
|
||||
event.Skip();
|
||||
@@ -927,8 +925,7 @@ void wxListTextCtrl::OnKillFocus( wxFocusEvent &WXUNUSED(event) )
|
||||
{
|
||||
(*m_accept) = FALSE;
|
||||
(*m_res) = "";
|
||||
// Show( FALSE );
|
||||
Destroy();
|
||||
if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1140,31 +1137,30 @@ void wxListMainWindow::DeleteLine( wxListLineData *line )
|
||||
SendNotify( line, wxEVT_COMMAND_LIST_DELETE_ITEM );
|
||||
}
|
||||
|
||||
void wxListMainWindow::StartLabelEdit( wxListLineData *line )
|
||||
{
|
||||
SendNotify( line, wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT );
|
||||
}
|
||||
/* *** */
|
||||
|
||||
void wxListMainWindow::RenameLine( wxListLineData *line, const wxString &newName )
|
||||
void wxListMainWindow::Edit( long item )
|
||||
{
|
||||
wxNode *node = m_lines.Nth( item );
|
||||
wxCHECK_RET( node, "wrong index in wxListCtrl::Edit() ");
|
||||
|
||||
m_currentEdit = (wxListLineData*) node->Data();
|
||||
|
||||
wxListEvent le( wxEVT_COMMAND_LIST_END_LABEL_EDIT, GetParent()->GetId() );
|
||||
le.SetEventObject( GetParent() );
|
||||
le.m_itemIndex = GetIndexOfLine( line );
|
||||
line->GetItem( 0, le.m_item );
|
||||
le.m_item.m_text = newName;
|
||||
le.m_itemIndex = GetIndexOfLine( m_currentEdit );
|
||||
m_currentEdit->GetItem( 0, le.m_item );
|
||||
GetParent()->GetEventHandler()->ProcessEvent( le );
|
||||
}
|
||||
|
||||
void wxListMainWindow::OnRenameTimer()
|
||||
{
|
||||
StartLabelEdit( m_current );
|
||||
|
||||
if (!le.IsAllowed()) return;
|
||||
|
||||
wxString s;
|
||||
m_current->GetText( 0, s );
|
||||
m_currentEdit->GetText( 0, s );
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int w = 0;
|
||||
int h = 0;
|
||||
m_current->GetLabelExtent( x, y, w, h );
|
||||
m_currentEdit->GetLabelExtent( x, y, w, h );
|
||||
|
||||
wxClientDC dc(this);
|
||||
PrepareDC( dc );
|
||||
@@ -1176,9 +1172,25 @@ void wxListMainWindow::OnRenameTimer()
|
||||
text->SetFocus();
|
||||
}
|
||||
|
||||
void wxListMainWindow::OnRenameTimer()
|
||||
{
|
||||
wxCHECK_RET( m_current, "invalid m_current" );
|
||||
|
||||
Edit( m_lines.IndexOf( m_current ) );
|
||||
}
|
||||
|
||||
void wxListMainWindow::OnRenameAccept()
|
||||
{
|
||||
RenameLine( m_current, m_renameRes );
|
||||
wxListEvent le( wxEVT_COMMAND_LIST_END_LABEL_EDIT, GetParent()->GetId() );
|
||||
le.SetEventObject( GetParent() );
|
||||
le.m_itemIndex = GetIndexOfLine( m_currentEdit );
|
||||
m_currentEdit->GetItem( 0, le.m_item );
|
||||
le.m_item.m_text = m_renameRes;
|
||||
GetParent()->GetEventHandler()->ProcessEvent( le );
|
||||
|
||||
if (!le.IsAllowed()) return;
|
||||
|
||||
/* DO CHANGE LABEL */
|
||||
}
|
||||
|
||||
void wxListMainWindow::OnMouse( wxMouseEvent &event )
|
||||
@@ -1340,7 +1352,7 @@ void wxListMainWindow::OnMouse( wxMouseEvent &event )
|
||||
}
|
||||
}
|
||||
|
||||
void wxListMainWindow::MoveToFocus( void )
|
||||
void wxListMainWindow::MoveToFocus()
|
||||
{
|
||||
if (!m_current) return;
|
||||
|
||||
@@ -1788,12 +1800,12 @@ int wxListMainWindow::GetColumnWidth( int col )
|
||||
}
|
||||
}
|
||||
|
||||
int wxListMainWindow::GetColumnCount( void )
|
||||
int wxListMainWindow::GetColumnCount()
|
||||
{
|
||||
return m_columns.Number();
|
||||
}
|
||||
|
||||
int wxListMainWindow::GetCountPerPage( void )
|
||||
int wxListMainWindow::GetCountPerPage()
|
||||
{
|
||||
return m_visibleLines;
|
||||
}
|
||||
@@ -1899,7 +1911,7 @@ void wxListMainWindow::GetItem( wxListItem &item )
|
||||
}
|
||||
}
|
||||
|
||||
int wxListMainWindow::GetItemCount( void )
|
||||
int wxListMainWindow::GetItemCount()
|
||||
{
|
||||
return m_lines.Number();
|
||||
}
|
||||
@@ -1940,7 +1952,7 @@ bool wxListMainWindow::GetItemPosition(long item, wxPoint& pos)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int wxListMainWindow::GetSelectedItemCount( void )
|
||||
int wxListMainWindow::GetSelectedItemCount()
|
||||
{
|
||||
int ret = 0;
|
||||
wxNode *node = m_lines.First();
|
||||
@@ -1972,12 +1984,12 @@ void wxListMainWindow::SetMode( long mode )
|
||||
}
|
||||
}
|
||||
|
||||
long wxListMainWindow::GetMode( void ) const
|
||||
long wxListMainWindow::GetMode() const
|
||||
{
|
||||
return m_mode;
|
||||
}
|
||||
|
||||
void wxListMainWindow::CalculatePositions( void )
|
||||
void wxListMainWindow::CalculatePositions()
|
||||
{
|
||||
if (!m_lines.First()) return;
|
||||
|
||||
@@ -2505,12 +2517,6 @@ int wxListCtrl::GetCountPerPage(void) const
|
||||
return m_mainWin->GetCountPerPage(); // different from Windows ?
|
||||
}
|
||||
|
||||
/*
|
||||
wxText& wxListCtrl::GetEditControl(void) const
|
||||
{
|
||||
}
|
||||
*/
|
||||
|
||||
bool wxListCtrl::GetItem( wxListItem &info ) const
|
||||
{
|
||||
m_mainWin->GetItem( info );
|
||||
@@ -2715,11 +2721,10 @@ bool wxListCtrl::DeleteColumn( int col )
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
wxText& wxListCtrl::Edit( long WXUNUSED(item ) )
|
||||
void wxListCtrl::Edit( long item )
|
||||
{
|
||||
m_mainWin->Edit( item );
|
||||
}
|
||||
*/
|
||||
|
||||
bool wxListCtrl::EnsureVisible( long item )
|
||||
{
|
||||
|
@@ -157,12 +157,77 @@ private:
|
||||
// implementation
|
||||
// =============================================================================
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// wxTreeRenameTimer (internal)
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
wxTreeRenameTimer::wxTreeRenameTimer( wxTreeCtrl *owner )
|
||||
{
|
||||
m_owner = owner;
|
||||
}
|
||||
|
||||
void wxTreeRenameTimer::Notify()
|
||||
{
|
||||
m_owner->OnRenameTimer();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxTreeTextCtrl (internal)
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxTreeTextCtrl,wxTextCtrl);
|
||||
|
||||
BEGIN_EVENT_TABLE(wxTreeTextCtrl,wxTextCtrl)
|
||||
EVT_CHAR (wxTreeTextCtrl::OnChar)
|
||||
EVT_KILL_FOCUS (wxTreeTextCtrl::OnKillFocus)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
wxTreeTextCtrl::wxTreeTextCtrl( wxWindow *parent, const wxWindowID id,
|
||||
bool *accept, wxString *res, wxTreeCtrl *owner,
|
||||
const wxString &value, const wxPoint &pos, const wxSize &size,
|
||||
int style, const wxValidator& validator, const wxString &name ) :
|
||||
wxTextCtrl( parent, id, value, pos, size, style, validator, name )
|
||||
{
|
||||
m_res = res;
|
||||
m_accept = accept;
|
||||
m_owner = owner;
|
||||
}
|
||||
|
||||
void wxTreeTextCtrl::OnChar( wxKeyEvent &event )
|
||||
{
|
||||
if (event.m_keyCode == WXK_RETURN)
|
||||
{
|
||||
(*m_accept) = TRUE;
|
||||
(*m_res) = GetValue();
|
||||
m_owner->OnRenameAccept();
|
||||
if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this);
|
||||
return;
|
||||
}
|
||||
if (event.m_keyCode == WXK_ESCAPE)
|
||||
{
|
||||
(*m_accept) = FALSE;
|
||||
(*m_res) = "";
|
||||
if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this);
|
||||
return;
|
||||
}
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
void wxTreeTextCtrl::OnKillFocus( wxFocusEvent &WXUNUSED(event) )
|
||||
{
|
||||
(*m_accept) = FALSE;
|
||||
(*m_res) = "";
|
||||
if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this);
|
||||
}
|
||||
|
||||
#define PIXELS_PER_UNIT 10
|
||||
// -----------------------------------------------------------------------------
|
||||
// wxTreeEvent
|
||||
// -----------------------------------------------------------------------------
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxTreeEvent, wxNotifyEvent)
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxTreeEvent, wxNotifyEvent)
|
||||
|
||||
wxTreeEvent::wxTreeEvent( wxEventType commandType, int id )
|
||||
: wxNotifyEvent( commandType, id )
|
||||
{
|
||||
@@ -393,6 +458,8 @@ void wxTreeCtrl::Init()
|
||||
m_imageListState = (wxImageList *) NULL;
|
||||
|
||||
m_dragCount = 0;
|
||||
|
||||
m_renameTimer = new wxTreeRenameTimer( this );
|
||||
}
|
||||
|
||||
bool wxTreeCtrl::Create(wxWindow *parent, wxWindowID id,
|
||||
@@ -421,6 +488,8 @@ wxTreeCtrl::~wxTreeCtrl()
|
||||
wxDELETE( m_hilightBrush );
|
||||
|
||||
DeleteAllItems();
|
||||
|
||||
delete m_renameTimer;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@@ -1153,26 +1222,6 @@ void wxTreeCtrl::ScrollTo(const wxTreeItemId &item)
|
||||
}
|
||||
}
|
||||
|
||||
wxTextCtrl *wxTreeCtrl::EditLabel( const wxTreeItemId& WXUNUSED(item),
|
||||
wxClassInfo* WXUNUSED(textCtrlClass) )
|
||||
{
|
||||
wxFAIL_MSG(_T("not implemented"));
|
||||
|
||||
return (wxTextCtrl*)NULL;
|
||||
}
|
||||
|
||||
wxTextCtrl *wxTreeCtrl::GetEditControl() const
|
||||
{
|
||||
wxFAIL_MSG(_T("not implemented"));
|
||||
|
||||
return (wxTextCtrl*)NULL;
|
||||
}
|
||||
|
||||
void wxTreeCtrl::EndEditLabel(const wxTreeItemId& WXUNUSED(item), bool WXUNUSED(discardChanges))
|
||||
{
|
||||
wxFAIL_MSG(_T("not implemented"));
|
||||
}
|
||||
|
||||
// FIXME: tree sorting functions are not reentrant and not MT-safe!
|
||||
static wxTreeCtrl *s_treeBeingSorted = NULL;
|
||||
|
||||
@@ -1732,6 +1781,55 @@ wxTreeItemId wxTreeCtrl::HitTest(const wxPoint& point, int& flags)
|
||||
return m_anchor->HitTest( wxPoint(x, y), this, flags);
|
||||
}
|
||||
|
||||
/* **** */
|
||||
|
||||
void wxTreeCtrl::Edit( const wxTreeItemId& item )
|
||||
{
|
||||
if (!item.IsOk()) return;
|
||||
|
||||
m_currentEdit = item.m_pItem;
|
||||
|
||||
wxTreeEvent te( wxEVT_COMMAND_TREE_BEGIN_LABEL_EDIT, GetId() );
|
||||
te.m_item = m_currentEdit;
|
||||
te.SetEventObject( this );
|
||||
GetEventHandler()->ProcessEvent( te );
|
||||
|
||||
if (!te.IsAllowed()) return;
|
||||
|
||||
wxString s = m_currentEdit->GetText();
|
||||
int x = m_currentEdit->GetX();
|
||||
int y = m_currentEdit->GetY();
|
||||
int w = m_currentEdit->GetWidth();
|
||||
int h = m_currentEdit->GetHeight();
|
||||
|
||||
wxClientDC dc(this);
|
||||
PrepareDC( dc );
|
||||
x = dc.LogicalToDeviceX( x );
|
||||
y = dc.LogicalToDeviceY( y );
|
||||
|
||||
wxTreeTextCtrl *text = new wxTreeTextCtrl(
|
||||
this, -1, &m_renameAccept, &m_renameRes, this, s, wxPoint(x-4,y-4), wxSize(w+11,h+8) );
|
||||
text->SetFocus();
|
||||
}
|
||||
|
||||
void wxTreeCtrl::OnRenameTimer()
|
||||
{
|
||||
Edit( m_current );
|
||||
}
|
||||
|
||||
void wxTreeCtrl::OnRenameAccept()
|
||||
{
|
||||
wxTreeEvent le( wxEVT_COMMAND_TREE_END_LABEL_EDIT, GetId() );
|
||||
le.m_item = m_currentEdit;
|
||||
le.SetEventObject( this );
|
||||
le.m_label = m_renameRes;
|
||||
GetEventHandler()->ProcessEvent( le );
|
||||
|
||||
if (!le.IsAllowed()) return;
|
||||
|
||||
/* DO CHANGE LABEL */
|
||||
}
|
||||
|
||||
void wxTreeCtrl::OnMouse( wxMouseEvent &event )
|
||||
{
|
||||
if (!event.LeftIsDown()) m_dragCount = 0;
|
||||
@@ -1769,6 +1867,14 @@ void wxTreeCtrl::OnMouse( wxMouseEvent &event )
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.LeftUp() && (item == m_current) &&
|
||||
(flags & wxTREE_HITTEST_ONITEMLABEL) &&
|
||||
HasFlag(wxTR_EDIT_LABELS) )
|
||||
{
|
||||
m_renameTimer->Start( 100, TRUE );
|
||||
return;
|
||||
}
|
||||
|
||||
bool is_multiple=(GetWindowStyleFlag() & wxTR_MULTIPLE);
|
||||
bool extended_select=(event.ShiftDown() && is_multiple);
|
||||
bool unselect_others=!(extended_select || (event.ControlDown() && is_multiple));
|
||||
|
@@ -381,9 +381,32 @@ void wxToolBar::ToggleTool( int toolIndex, bool toggle )
|
||||
wxToolBarTool *tool = (wxToolBarTool*)node->Data();
|
||||
if (tool->m_index == toolIndex)
|
||||
{
|
||||
tool->m_toggleState = toggle;
|
||||
if ((tool->m_item) && (GTK_IS_TOGGLE_BUTTON(tool->m_item)))
|
||||
{
|
||||
tool->m_toggleState = toggle;
|
||||
|
||||
if (tool->m_bitmap2.Ok())
|
||||
{
|
||||
wxBitmap bitmap = tool->m_bitmap1;
|
||||
if (tool->m_toggleState) bitmap = tool->m_bitmap2;
|
||||
|
||||
GtkPixmap *pixmap = GTK_PIXMAP( tool->m_pixmap );
|
||||
|
||||
GdkBitmap *mask = (GdkBitmap *) NULL;
|
||||
if (bitmap.GetMask()) mask = bitmap.GetMask()->GetBitmap();
|
||||
|
||||
gtk_pixmap_set( pixmap, bitmap.GetPixmap(), mask );
|
||||
}
|
||||
|
||||
gtk_signal_disconnect_by_func( GTK_OBJECT(tool->m_item),
|
||||
GTK_SIGNAL_FUNC(gtk_toolbar_callback), (gpointer*)tool );
|
||||
|
||||
gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(tool->m_item), toggle );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(tool->m_item), "clicked",
|
||||
GTK_SIGNAL_FUNC(gtk_toolbar_callback), (gpointer*)tool );
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
node = node->Next();
|
||||
|
@@ -381,9 +381,32 @@ void wxToolBar::ToggleTool( int toolIndex, bool toggle )
|
||||
wxToolBarTool *tool = (wxToolBarTool*)node->Data();
|
||||
if (tool->m_index == toolIndex)
|
||||
{
|
||||
tool->m_toggleState = toggle;
|
||||
if ((tool->m_item) && (GTK_IS_TOGGLE_BUTTON(tool->m_item)))
|
||||
{
|
||||
tool->m_toggleState = toggle;
|
||||
|
||||
if (tool->m_bitmap2.Ok())
|
||||
{
|
||||
wxBitmap bitmap = tool->m_bitmap1;
|
||||
if (tool->m_toggleState) bitmap = tool->m_bitmap2;
|
||||
|
||||
GtkPixmap *pixmap = GTK_PIXMAP( tool->m_pixmap );
|
||||
|
||||
GdkBitmap *mask = (GdkBitmap *) NULL;
|
||||
if (bitmap.GetMask()) mask = bitmap.GetMask()->GetBitmap();
|
||||
|
||||
gtk_pixmap_set( pixmap, bitmap.GetPixmap(), mask );
|
||||
}
|
||||
|
||||
gtk_signal_disconnect_by_func( GTK_OBJECT(tool->m_item),
|
||||
GTK_SIGNAL_FUNC(gtk_toolbar_callback), (gpointer*)tool );
|
||||
|
||||
gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(tool->m_item), toggle );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(tool->m_item), "clicked",
|
||||
GTK_SIGNAL_FUNC(gtk_toolbar_callback), (gpointer*)tool );
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
node = node->Next();
|
||||
|
Reference in New Issue
Block a user