#endif
#include "wx/helpbase.h"
+#include "wx/frame.h"
/// Name for map file.
#define WXEXTHELP_MAPFILE "wxhelp.map"
wxPoint *pos = NULL,
bool *newFrameEachTime = NULL)
{
- return NULL;// does nothing by default
+ return (wxFrame*) NULL;// does nothing by default
}
protected:
class WXDLLEXPORT wxListMainWindow;
class WXDLLEXPORT wxListRenameTimer;
-//class wxListTextCtrl;
+class WXDLLEXPORT wxListTextCtrl;
//-----------------------------------------------------------------------------
// types
wxList m_lines;
wxList m_columns;
wxListLineData *m_current;
+ wxListLineData *m_currentEdit;
int m_visibleLines;
wxBrush *m_hilightBrush;
wxColour *m_hilightColour;
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 );
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 );
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 );
+ bool GetItemPosition( long item, wxPoint& pos );
+ 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);
+ long FindItem( long start, const wxString& str, bool partial = FALSE );
+ long FindItem( long start, long data);
long HitTest( int x, int y, int &flags );
void InsertItem( wxListItem &item );
// void AddItem( wxListItem &item );
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,
{
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,
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 );
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) {};
- 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) ;
+ void SetWindowStyleFlag( long style );
+ 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);
- long FindItem(long start, const wxPoint& pt, int direction); // not supported in wxGLC
- long HitTest(const wxPoint& point, int& flags);
+ long FindItem( long start, const wxString& str, bool partial = FALSE );
+ long FindItem( long start, long data );
+ long FindItem( long start, const wxPoint& pt, int direction ); // not supported in wxGLC
+ long HitTest( const wxPoint& point, int& flags);
long InsertItem(wxListItem& info);
- long InsertItem(long index, const wxString& label);
- long InsertItem(long index, int imageIndex);
- long InsertItem(long index, const wxString& label, int imageIndex);
- long InsertColumn(long col, wxListItem& info);
- long InsertColumn(long col, const wxString& heading, int format = wxLIST_FORMAT_LEFT,
- int width = -1);
- bool ScrollList(int dx, int dy);
- bool SortItems(wxListCtrlCompare fn, long data);
- bool Update(long item);
+ long InsertItem( long index, const wxString& label );
+ long InsertItem( long index, int imageIndex );
+ long InsertItem( long index, const wxString& label, int imageIndex );
+ long InsertColumn( long col, wxListItem& info );
+ long InsertColumn( long col, const wxString& heading, int format = wxLIST_FORMAT_LEFT,
+ int width = -1 );
+ bool ScrollList( int dx, int dy );
+ bool SortItems( wxListCtrlCompare fn, long data );
+ bool Update( long item );
void OnIdle( wxIdleEvent &event );
// We have to hand down a few functions
{ m_mainWin->SetFocus(); }
// implementation
-
-// wxListTextCtrl m_textCtrl;
+
wxImageList *m_imageListNormal;
wxImageList *m_imageListSmall;
wxImageList *m_imageListState; // what's that ?
#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
// 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
// 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;
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
// -----------------------------------------------------------------------------
{ 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
// or +1 if the first item is less than, equal to or greater than the
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;
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();
void RefreshSubtree( wxGenericTreeItem *item );
void RefreshLine( wxGenericTreeItem *item );
+
+ void OnRenameTimer();
+ void OnRenameAccept();
void FillArray(wxGenericTreeItem*, wxArrayTreeItemIds&) const;
void SelectItemRange( wxGenericTreeItem *item1, wxGenericTreeItem *item2 );
#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
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
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:
// 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);
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;
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()
const wxSize& size, long style):
wxFrame(parent, id, title, pos, size, style)
{
- m_textWindow = new wxTextCtrl(this, -1, "", wxPoint(0, 0), wxSize(-1, -1), wxTE_MULTILINE);
+ m_textWindow = new wxTextCtrl(this, -1, "", wxPoint(0, 0), wxSize(-1, -1), wxTE_MULTILINE);
}
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
// - must delete all frames except for the main one.
void MyFrame::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
{
- Destroy();
+ Destroy();
}
void MyFrame::OnToolLeftClick(wxCommandEvent& event)
{
- wxString str;
- str.Printf( _T("Clicked on tool %d"), event.GetId());
- SetStatusText(str);
+ wxString 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)
#endif //__BORLANDC__
#ifndef WX_PRECOMP
- #include <wx/wx.h>
+ #include "wx/string.h"
#endif //WX_PRECOMP
#if wxUSE_ODBC
#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
#endif
#ifndef WX_PRECOMP
- #include "wx/wx.h"
+ #include "wx/window.h"
+ #include "wx/dcclient.h"
#endif //WX_PRECOMP
#include "wx/caret.h"
#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"
(*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();
{
(*m_accept) = FALSE;
(*m_res) = "";
-// Show( FALSE );
- Destroy();
+ if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this);
return;
}
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 );
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 )
}
}
-void wxListMainWindow::MoveToFocus( void )
+void wxListMainWindow::MoveToFocus()
{
if (!m_current) return;
}
}
-int wxListMainWindow::GetColumnCount( void )
+int wxListMainWindow::GetColumnCount()
{
return m_columns.Number();
}
-int wxListMainWindow::GetCountPerPage( void )
+int wxListMainWindow::GetCountPerPage()
{
return m_visibleLines;
}
}
}
-int wxListMainWindow::GetItemCount( void )
+int wxListMainWindow::GetItemCount()
{
return m_lines.Number();
}
return TRUE;
}
-int wxListMainWindow::GetSelectedItemCount( void )
+int wxListMainWindow::GetSelectedItemCount()
{
int ret = 0;
wxNode *node = m_lines.First();
}
}
-long wxListMainWindow::GetMode( void ) const
+long wxListMainWindow::GetMode() const
{
return m_mode;
}
-void wxListMainWindow::CalculatePositions( void )
+void wxListMainWindow::CalculatePositions()
{
if (!m_lines.First()) return;
return m_mainWin->GetCountPerPage(); // different from Windows ?
}
-/*
-wxText& wxListCtrl::GetEditControl(void) const
-{
-}
-*/
-
bool wxListCtrl::GetItem( wxListItem &info ) const
{
m_mainWin->GetItem( info );
return TRUE;
}
-/*
-wxText& wxListCtrl::Edit( long WXUNUSED(item ) )
+void wxListCtrl::Edit( long item )
{
+ m_mainWin->Edit( item );
}
-*/
bool wxListCtrl::EnsureVisible( long item )
{
// 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 )
{
m_imageListState = (wxImageList *) NULL;
m_dragCount = 0;
+
+ m_renameTimer = new wxTreeRenameTimer( this );
}
bool wxTreeCtrl::Create(wxWindow *parent, wxWindowID id,
wxDELETE( m_hilightBrush );
DeleteAllItems();
+
+ delete m_renameTimer;
}
// -----------------------------------------------------------------------------
}
}
-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;
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;
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));
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();
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();