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:
Robert Roebling 1999-07-25 12:59:58 +00:00
parent a76015e6eb
commit e179bd6537
15 changed files with 388 additions and 148 deletions

View File

@ -16,6 +16,7 @@
#endif
#include "wx/helpbase.h"
#include "wx/frame.h"
/// Name for map file.
#define WXEXTHELP_MAPFILE "wxhelp.map"
@ -132,7 +133,7 @@ DECLARE_ABSTRACT_CLASS(wxHTMLHelpControllerBase)
wxPoint *pos = NULL,
bool *newFrameEachTime = NULL)
{
return NULL;// does nothing by default
return (wxFrame*) NULL;// does nothing by default
}
protected:

View File

@ -49,7 +49,7 @@ class WXDLLEXPORT wxListHeaderWindow;
class WXDLLEXPORT wxListMainWindow;
class WXDLLEXPORT wxListRenameTimer;
//class wxListTextCtrl;
class WXDLLEXPORT wxListTextCtrl;
//-----------------------------------------------------------------------------
// types
@ -439,6 +439,7 @@ class WXDLLEXPORT wxListMainWindow: public wxScrolledWindow
wxList m_lines;
wxList m_columns;
wxListLineData *m_current;
wxListLineData *m_currentEdit;
int m_visibleLines;
wxBrush *m_hilightBrush;
wxColour *m_hilightColour;
@ -452,18 +453,17 @@ class WXDLLEXPORT wxListMainWindow: public wxScrolledWindow
bool m_usedKeys;
bool m_lastOnSame;
wxTimer *m_renameTimer;
// wxListTextCtrl *m_text;
bool m_renameAccept;
wxString m_renameRes;
bool m_isCreated;
int m_dragCount;
public:
wxListMainWindow(void);
wxListMainWindow();
wxListMainWindow( wxWindow *parent, wxWindowID id,
const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
long style = 0, const wxString &name = "listctrl" );
~wxListMainWindow(void);
~wxListMainWindow();
void RefreshLine( wxListLineData *line );
void OnPaint( wxPaintEvent &event );
void HilightAll( bool on );
@ -473,18 +473,20 @@ class WXDLLEXPORT wxListMainWindow: public wxScrolledWindow
void SelectLine( wxListLineData *line );
void DeselectLine( wxListLineData *line );
void DeleteLine( wxListLineData *line );
void RenameLine( wxListLineData *line, const wxString &newName );
void StartLabelEdit( wxListLineData *line );
void OnRenameTimer(void);
void OnRenameAccept(void);
void Edit( long item );
void OnRenameTimer();
void OnRenameAccept();
void OnMouse( wxMouseEvent &event );
void MoveToFocus( void );
void MoveToFocus();
void OnArrowChar( wxListLineData *newCurrent, bool shiftDown );
void OnChar( wxKeyEvent &event );
void OnKeyDown( wxKeyEvent &event );
void OnSetFocus( wxFocusEvent &event );
void OnKillFocus( wxFocusEvent &event );
void OnSize( wxSizeEvent &event );
void DrawImage( int index, wxDC *dc, int x, int y );
void GetImageSize( int index, int &width, int &height );
int GetIndexOfLine( const wxListLineData *line );
@ -497,25 +499,25 @@ class WXDLLEXPORT wxListMainWindow: public wxScrolledWindow
void SetColumnWidth( int col, int width );
void GetColumn( int col, wxListItem &item );
int GetColumnWidth( int vol );
int GetColumnCount( void );
int GetCountPerPage( void );
int GetColumnCount();
int GetCountPerPage();
void SetItem( wxListItem &item );
void GetItem( wxListItem &item );
void SetItemState( long item, long state, long stateMask );
int GetItemState( long item, long stateMask );
int GetItemCount( void );
int GetItemCount();
void GetItemRect( long index, wxRect &rect );
bool GetItemPosition( long item, wxPoint& pos );
int GetSelectedItemCount( void );
int GetSelectedItemCount();
void SetMode( long mode );
long GetMode( void ) const;
void CalculatePositions( void );
void RealizeChanges(void);
long GetMode() const;
void CalculatePositions();
void RealizeChanges();
long GetNextItem( long item, int geometry, int state );
void DeleteItem( long index );
void DeleteAllItems( void );
void DeleteAllItems();
void DeleteColumn( int col );
void DeleteEverything( void );
void DeleteEverything();
void EnsureVisible( long index );
long FindItem( long start, const wxString& str, bool partial = FALSE );
long FindItem( long start, long data);
@ -538,8 +540,7 @@ class WXDLLEXPORT wxListCtrl: public wxControl
DECLARE_DYNAMIC_CLASS(wxListCtrl);
public:
wxListCtrl(void);
wxListCtrl();
wxListCtrl( wxWindow *parent, wxWindowID id = -1,
const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
long style = wxLC_ICON, const wxValidator& validator = wxDefaultValidator,
@ -547,7 +548,7 @@ class WXDLLEXPORT wxListCtrl: public wxControl
{
Create(parent, id, pos, size, style, validator, name);
}
~wxListCtrl(void);
~wxListCtrl();
bool Create( wxWindow *parent, wxWindowID id = -1,
const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
long style = wxLC_ICON, const wxValidator& validator = wxDefaultValidator,
@ -557,8 +558,7 @@ class WXDLLEXPORT wxListCtrl: public wxControl
bool SetColumn( int col, wxListItem& item );
int GetColumnWidth( int col ) const;
bool SetColumnWidth( int col, int width);
int GetCountPerPage(void) const; // not the same in wxGLC as in Windows, I think
// wxText& GetEditControl(void) const; // not supported in wxGLC
int GetCountPerPage() const; // not the same in wxGLC as in Windows, I think
bool GetItem( wxListItem& info ) const;
bool SetItem( wxListItem& info ) ;
long SetItem( long index, int col, const wxString& label, int imageId = -1 );
@ -572,27 +572,31 @@ class WXDLLEXPORT wxListCtrl: public wxControl
bool GetItemRect( long item, wxRect& rect, int code = wxLIST_RECT_BOUNDS ) const;
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;
int GetItemCount() const;
int GetColumnCount() const;
void SetItemSpacing( int spacing, bool isSmall = FALSE );
int GetItemSpacing( bool isSmall ) const;
int GetSelectedItemCount(void) const;
// wxColour GetTextColour(void) const; // wxGLC has colours for every Item (see wxListItem)
int GetSelectedItemCount() const;
// wxColour GetTextColour() const; // wxGLC has colours for every Item (see wxListItem)
// void SetTextColour(const wxColour& col);
long GetTopItem(void) const;
long GetTopItem() const;
void SetSingleStyle( long style, bool add = TRUE ) ;
void SetWindowStyleFlag( long style );
void RecreateWindow(void) {};
void RecreateWindow() {}
long GetNextItem( long item, int geometry = wxLIST_NEXT_ALL, int state = wxLIST_STATE_DONTCARE ) const;
wxImageList *GetImageList( int which ) const;
void SetImageList( wxImageList *imageList, int which );
bool Arrange( int flag = wxLIST_ALIGN_DEFAULT ); // always wxLIST_ALIGN_LEFT in wxGLC
void ClearAll();
bool DeleteItem( long item );
bool DeleteAllItems(void);
bool DeleteAllColumns(void);
bool DeleteAllItems();
bool DeleteAllColumns();
bool DeleteColumn( int col );
// wxText& Edit(long item) ; // not supported in wxGLC
void EditLabel( long item ) { Edit(item); }
void Edit( long item );
bool EnsureVisible( long item );
long FindItem( long start, const wxString& str, bool partial = FALSE );
long FindItem( long start, long data );
@ -636,7 +640,6 @@ class WXDLLEXPORT wxListCtrl: public wxControl
// implementation
// wxListTextCtrl m_textCtrl;
wxImageList *m_imageListNormal;
wxImageList *m_imageListSmall;
wxImageList *m_imageListState; // what's that ?

View File

@ -30,6 +30,7 @@ WXDLLEXPORT_DATA(extern const char*) wxTreeCtrlNameStr;
#include "wx/textctrl.h"
#include "wx/pen.h"
#include "wx/dynarray.h"
#include "wx/timer.h"
//those defines should only be done in generic/treectrl.h,
//because wxMSW doesn't allow mutiple selection
@ -80,10 +81,13 @@ static const int wxTREE_HITTEST_ONITEM = wxTREE_HITTEST_ONITEMICON |
// forward declaration
// -----------------------------------------------------------------------------
class wxImageList;
class wxGenericTreeItem;
class WXDLLEXPORT wxImageList;
class WXDLLEXPORT wxGenericTreeItem;
class wxTreeItemData;
class WXDLLEXPORT wxTreeItemData;
class WXDLLEXPORT wxTreeRenameTimer;
class WXDLLEXPORT wxTreeTextCtrl;
// -----------------------------------------------------------------------------
// wxTreeItemId - unique identifier of a tree element
@ -123,6 +127,7 @@ WX_DECLARE_OBJARRAY(wxTreeItemId, wxArrayTreeItemIds);
// Because the objects of this class are deleted by the tree, they should
// always be allocated on the heap!
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxTreeItemData: public wxClientData
{
friend class wxTreeCtrl;
@ -142,6 +147,47 @@ protected:
wxTreeItemId m_pItem;
};
//-----------------------------------------------------------------------------
// wxTreeRenameTimer (internal)
//-----------------------------------------------------------------------------
class WXDLLEXPORT wxTreeRenameTimer: public wxTimer
{
private:
wxTreeCtrl *m_owner;
public:
wxTreeRenameTimer( wxTreeCtrl *owner );
void Notify();
};
//-----------------------------------------------------------------------------
// wxTreeTextCtrl (internal)
//-----------------------------------------------------------------------------
class WXDLLEXPORT wxTreeTextCtrl: public wxTextCtrl
{
DECLARE_DYNAMIC_CLASS(wxTreeTextCtrl);
private:
bool *m_accept;
wxString *m_res;
wxTreeCtrl *m_owner;
public:
wxTreeTextCtrl(void) {};
wxTreeTextCtrl( wxWindow *parent, const wxWindowID id,
bool *accept, wxString *res, wxTreeCtrl *owner,
const wxString &value = "",
const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
int style = 0, const wxValidator& validator = wxDefaultValidator,
const wxString &name = "wxTreeTextCtrlText" );
void OnChar( wxKeyEvent &event );
void OnKillFocus( wxFocusEvent &event );
DECLARE_EVENT_TABLE()
};
// -----------------------------------------------------------------------------
// wxTreeCtrl - the tree control
// -----------------------------------------------------------------------------
@ -368,18 +414,11 @@ public:
{ int dummy; return HitTest(point, dummy); }
wxTreeItemId HitTest(const wxPoint& point, int& flags);
// start editing the item label: this (temporarily) replaces the item
// Start editing the item label: this (temporarily) replaces the item
// with a one line edit control. The item will be selected if it hadn't
// been before. textCtrlClass parameter allows you to create an edit
// control of arbitrary user-defined class deriving from wxTextCtrl.
wxTextCtrl* EditLabel(const wxTreeItemId& item,
wxClassInfo* textCtrlClass = CLASSINFO(wxTextCtrl));
// returns the same pointer as StartEdit() if the item is being edited,
// NULL otherwise (it's assumed that no more than one item may be
// edited simultaneously)
wxTextCtrl* GetEditControl() const;
// end editing and accept or discard the changes to item label
void EndEditLabel(const wxTreeItemId& item, bool discardChanges = FALSE);
// been before.
void EditLabel( const wxTreeItemId& item ) { Edit( item ); }
void Edit( const wxTreeItemId& item );
// sorting
// this function is called to compare 2 items and should return -1, 0
@ -410,9 +449,11 @@ public:
protected:
friend class wxGenericTreeItem;
friend class wxTreeRenameTimer;
friend class wxTreeTextCtrl;
wxGenericTreeItem *m_anchor;
wxGenericTreeItem *m_current, *m_key_current;
wxGenericTreeItem *m_current, *m_key_current, *m_currentEdit;
bool m_hasFocus;
bool m_dirty;
int m_xScroll,m_yScroll;
@ -424,6 +465,9 @@ protected:
wxImageList *m_imageListNormal,
*m_imageListState;
int m_dragCount;
wxTimer *m_renameTimer;
bool m_renameAccept;
wxString m_renameRes;
// the common part of all ctors
void Init();
@ -447,6 +491,9 @@ protected:
void RefreshSubtree( wxGenericTreeItem *item );
void RefreshLine( wxGenericTreeItem *item );
void OnRenameTimer();
void OnRenameAccept();
void FillArray(wxGenericTreeItem*, wxArrayTreeItemIds&) const;
void SelectItemRange( wxGenericTreeItem *item1, wxGenericTreeItem *item2 );
bool TagAllChildrenUntilLast(wxGenericTreeItem *crt_item, wxGenericTreeItem *last_item, bool select);

View File

@ -16,7 +16,10 @@
#pragma interface "helpbase.h"
#endif
#include "wx/wx.h"
#include "wx/defs.h"
#include "wx/object.h"
#include "wx/string.h"
#include "wx/gdicmn.h"
#if wxUSE_HELP
@ -29,8 +32,8 @@ class WXDLLEXPORT wxHelpControllerBase: public wxObject
DECLARE_CLASS(wxHelpControllerBase)
public:
inline wxHelpControllerBase(void) {}
inline ~wxHelpControllerBase(void) {};
inline wxHelpControllerBase() {}
inline ~wxHelpControllerBase() {};
// Must call this to set the filename and server name.
// server is only required when implementing TCP/IP-based

View File

@ -58,6 +58,7 @@ class WXDLLEXPORT wxStreamBase {
bool operator!() const { return (LastError() != wxSTR_NOERROR); }
wxStreamError LastError() const { return m_lasterror; }
virtual size_t GetSize() const { return ~((size_t)0); }
size_t StreamSize() const { return GetSize(); }
protected:

View File

@ -146,7 +146,7 @@ bool MyApp::OnInit(void)
// Make a panel with a message
frame->m_listCtrl = new MyListCtrl(frame, LIST_CTRL, wxPoint(0, 0), wxSize(400, 200),
wxLC_LIST|wxSUNKEN_BORDER);
wxLC_LIST|wxSUNKEN_BORDER|wxLC_EDIT_LABELS);
// wxLC_LIST|wxLC_USER_TEXT|wxSUNKEN_BORDER); // wxLC_USER_TEXT requires app to supply all text on demand
frame->m_logWindow = new wxTextCtrl(frame, -1, "", wxPoint(0, 0), wxSize(400, 200), wxTE_MULTILINE|wxSUNKEN_BORDER);

View File

@ -129,9 +129,9 @@ bool MyApp::InitToolbar(wxToolBar* toolBar)
toolBar->AddTool(wxID_SAVE, *(toolBarBitmaps[2]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Save file");
currentX += width + 5;
toolBar->AddSeparator();
toolBar->AddTool(wxID_COPY, *(toolBarBitmaps[3]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Copy");
toolBar->AddTool(wxID_COPY, *(toolBarBitmaps[3]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Disable/Enable print button");
currentX += width + 5;
toolBar->AddTool(wxID_CUT, *(toolBarBitmaps[4]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Cut");
toolBar->AddTool(wxID_CUT, *(toolBarBitmaps[4]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Toggle/Untoggle help button");
currentX += width + 5;
toolBar->AddTool(wxID_PASTE, *(toolBarBitmaps[5]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Paste");
currentX += width + 5;
@ -157,9 +157,8 @@ bool MyApp::InitToolbar(wxToolBar* toolBar)
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(wxID_EXIT, MyFrame::OnQuit)
EVT_MENU(wxID_HELP, MyFrame::OnAbout)
EVT_CLOSE(MyFrame::OnCloseWindow)
EVT_TOOL_RANGE(wxID_OPEN, wxID_PASTE, MyFrame::OnToolLeftClick)
EVT_MENU(-1, MyFrame::OnToolLeftClick)
EVT_TOOL_ENTER(ID_TOOLBAR, MyFrame::OnToolEnter)
END_EVENT_TABLE()
@ -191,8 +190,31 @@ void MyFrame::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
void MyFrame::OnToolLeftClick(wxCommandEvent& event)
{
wxString str;
str.Printf( _T("Clicked on tool %d"), event.GetId());
SetStatusText(str);
str.Printf( _T("Clicked on tool %d\n"), event.GetId());
m_textWindow->WriteText( str );
if (event.GetId() == wxID_HELP)
{
if ((bool)event.GetExtraLong())
m_textWindow->WriteText( _T("Help button down now.\n") );
else
m_textWindow->WriteText( _T("Help button up now.\n") );
}
if (event.GetId() == wxID_COPY)
{
wxToolBar *tb = GetToolBar();
if (tb->GetToolEnabled(wxID_PRINT))
tb->EnableTool( wxID_PRINT, FALSE );
else
tb->EnableTool( wxID_PRINT, TRUE );
}
if (event.GetId() == wxID_CUT)
{
wxToolBar *tb = GetToolBar();
tb->ToggleTool( wxID_HELP, !tb->GetToolState( wxID_HELP ) );
}
}
void MyFrame::OnToolEnter(wxCommandEvent& event)

View File

@ -44,7 +44,7 @@
#endif //__BORLANDC__
#ifndef WX_PRECOMP
#include <wx/wx.h>
#include "wx/string.h"
#endif //WX_PRECOMP
#if wxUSE_ODBC

View File

@ -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

View File

@ -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"

View File

@ -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"

View File

@ -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 )
{

View File

@ -157,10 +157,75 @@ 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)
wxTreeEvent::wxTreeEvent( wxEventType commandType, int 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));

View File

@ -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();

View File

@ -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();