wxObject *userData = (wxObject *) NULL )
{ Connect(id, -1, eventType, func, userData); }
+ bool Disconnect( int id, int lastId = -1, wxEventType eventType = wxEVT_NULL,
+ wxObjectEventFunction func = NULL,
+ wxObject *userData = (wxObject *) NULL );
+
+ // Convenience function: take just one id
+ bool Disconnect( int id, wxEventType eventType = wxEVT_NULL,
+ wxObjectEventFunction func = NULL,
+ wxObject *userData = (wxObject *) NULL )
+ { return Disconnect(id, -1, eventType, func, userData); }
+
// implementation from now on
virtual bool SearchEventTable(wxEventTable& table, wxEvent& event);
bool SearchDynamicEventTable( wxEvent& event );
// Add space
virtual void AddSeparator();
+ // Delete tool by index (=id)
+ virtual bool DeleteTool(int toolIndex);
+
+ // Delete all tools
virtual void ClearTools();
+ // Has to be called after adding tools or changing something
virtual bool Realize();
virtual void EnableTool(int toolIndex, bool enable);
// Add space
virtual void AddSeparator();
+ // Delete tool by index (=id)
+ virtual bool DeleteTool(int toolIndex);
+
+ // Delete all tools
virtual void ClearTools();
+ // Has to be called after adding tools or changing something
virtual bool Realize();
virtual void EnableTool(int toolIndex, bool enable);
#include "wx/gtk/setup.h"
#endif
-/*
- * Compatibility defines: note that, in general, there is a a reason for not
- * compatible changes, so you should try to avoid defining WXWIN_COMPATIBILITY
- * and do so only if your program really can't be compiled otherwise.
- */
-
-/*
- * Compatibility with 1.66 API.
- * Level 0: no backward compatibility, all new features
- * Level 1: wxDC, OnSize (etc.) compatibility, but
- * some new features such as event tables
- */
-#define WXWIN_COMPATIBILITY 0
-
-/*
- * wxWindows 2.0 API compatibility. Possible values are:
- * 0: no backwards compatibility
- * 1: some backwards compatibility, but if it conflicts with the new
- * features, use the new code, not the old one
- * 2: maximum backwards compatiblity: even if compatibility can only be
- * achieved by disabling new features, do it.
- */
-#define WXWIN_COMPATIBILITY_2 1
-
-/*
- * wxWindows 2.0 uses long for wxPoint/wxRect/wxSize member fields and wxDC
- * method arguments, wxWindows 2.1 and later uses wxCoord typedef which is
- * usually int. Using long leads to (justified) warnings about long to int
- * conversions from some compilers and is, generally speaking, unneeded.
- */
-#define wxUSE_COMPATIBLE_COORD_TYPES 0
-
-/*
- * Maximum compatibility with 2.0 API
- */
-#if WXWIN_COMPATIBILITY_2 == 2
-#undef wxUSE_COMPATIBLE_COORD_TYPES
-#define wxUSE_COMPATIBLE_COORD_TYPES 1
-#endif /* WXWIN_COMPATIBILITY_2_MAX */
-
#endif
/* _WX_SETUP_H_BASE_ */
void OnToggleToolbar(wxCommandEvent& event);
void OnEnablePrint(wxCommandEvent& event) { DoEnablePrint(); }
+ void OnDeletePrint(wxCommandEvent& event) { DoDeletePrint(); }
void OnToggleHelp(wxCommandEvent& event) { DoToggleHelp(); }
- void OnAppendMenu(wxCommandEvent& event);
- void OnDeleteMenu(wxCommandEvent& event);
- void OnToggleMenu(wxCommandEvent& event);
-
void OnToolLeftClick(wxCommandEvent& event);
void OnToolEnter(wxCommandEvent& event);
private:
void DoEnablePrint();
+ void DoDeletePrint();
void DoToggleHelp();
bool m_smallToolbar;
{
IDM_TOOLBAR_TOGGLETOOLBAR = 200,
IDM_TOOLBAR_ENABLEPRINT,
+ IDM_TOOLBAR_DELETEPRINT,
IDM_TOOLBAR_TOGGLEHELP,
ID_COMBO = 1000
EVT_MENU(IDM_TOOLBAR_TOGGLETOOLBAR, MyFrame::OnToggleToolbar)
EVT_MENU(IDM_TOOLBAR_ENABLEPRINT, MyFrame::OnEnablePrint)
+ EVT_MENU(IDM_TOOLBAR_DELETEPRINT, MyFrame::OnDeletePrint)
EVT_MENU(IDM_TOOLBAR_TOGGLEHELP, MyFrame::OnToggleHelp)
EVT_MENU(-1, MyFrame::OnToolLeftClick)
currentX += width + 5;
toolBar->AddTool(wxID_SAVE, *(toolBarBitmaps[2]), wxNullBitmap, TRUE, currentX, -1, (wxObject *) NULL, "Toggle button 1");
- toolBar->AddSeparator();
-
wxComboBox *combo = new wxComboBox(toolBar, ID_COMBO);
combo->Append("This");
combo->Append("is a");
combo->Append("toolbar");
toolBar->AddControl(combo);
- toolBar->AddSeparator();
-
if ( !smallicons )
{
currentX += width + 5;
currentX += width + 5;
toolBar->AddTool(wxID_PASTE, *(toolBarBitmaps[5]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Paste");
currentX += width + 5;
- toolBar->AddSeparator();
- toolBar->AddTool(wxID_PRINT, *(toolBarBitmaps[6]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Print");
+ toolBar->AddTool(wxID_PRINT, *(toolBarBitmaps[6]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Delete this tool");
currentX += width + 5;
toolBar->AddSeparator();
toolBar->AddTool(wxID_HELP, *(toolBarBitmaps[7]), wxNullBitmap, TRUE, currentX, -1, (wxObject *) NULL, "Help button");
wxMenu *tbarMenu = new wxMenu;
tbarMenu->Append(IDM_TOOLBAR_TOGGLETOOLBAR, "&Toggle toolbar", "Change the toolbar kind");
tbarMenu->Append(IDM_TOOLBAR_ENABLEPRINT, "&Enable print button", "");
+ tbarMenu->Append(IDM_TOOLBAR_DELETEPRINT, "&Delete print button", "");
tbarMenu->Append(IDM_TOOLBAR_TOGGLEHELP, "Toggle &help button", "");
wxMenu *fileMenu = new wxMenu;
{
DoToggleHelp();
}
+
+ if (event.GetId() == wxID_PRINT)
+ {
+ DoDeletePrint();
+ }
}
void MyFrame::OnCombo(wxCommandEvent& event)
tb->EnableTool( wxID_PRINT, TRUE );
}
+void MyFrame::DoDeletePrint()
+{
+ wxToolBar *tb = GetToolBar();
+ tb->DeleteTool( wxID_PRINT );
+}
+
void MyFrame::DoToggleHelp()
{
wxToolBar *tb = GetToolBar();
}
return FALSE;
}
+
void wxEvtHandler::Connect( int id, int lastId,
wxEventType eventType,
wxObjectEventFunction func,
m_dynamicEvents->Append( (wxObject*) entry );
}
+bool wxEvtHandler::Disconnect( int id, int lastId, wxEventType eventType,
+ wxObjectEventFunction func,
+ wxObject *userData )
+{
+ if (!m_dynamicEvents)
+ return FALSE;
+
+ wxNode *node = m_dynamicEvents->First();
+ while (node)
+ {
+ wxEventTableEntry *entry = (wxEventTableEntry*)node->Data();
+ if ((entry->m_id == id) &&
+ ((entry->m_lastId == lastId) || (lastId == -1)) &&
+ ((entry->m_eventType == eventType) || (eventType == wxEVT_NULL)) &&
+ ((entry->m_fn == func) || (func == (wxObjectEventFunction)NULL)) &&
+ ((entry->m_callbackUserData == userData) || (userData == (wxObject*)NULL)))
+ {
+ if (entry->m_callbackUserData) delete entry->m_callbackUserData;
+ m_dynamicEvents->DeleteNode( node );
+ delete entry;
+ return TRUE;
+ }
+ node = node->Next();
+ }
+ return FALSE;
+}
+
bool wxEvtHandler::SearchDynamicEventTable( wxEvent& event )
{
wxCHECK_MSG( m_dynamicEvents, FALSE,
}
m_shortHelpString = helpS1;
m_longHelpString = helpS2;
+ m_control = (wxControl*) NULL;
}
wxToolBarTool::wxToolBarTool(wxControl *control)
void wxTreeCtrl::Delete(const wxTreeItemId& itemId)
{
- wxGenericTreeItem *item = itemId.m_pItem;
- wxGenericTreeItem *parent = item->GetParent();
+ wxGenericTreeItem *item = itemId.m_pItem;
+ wxGenericTreeItem *parent = item->GetParent();
- if ( parent )
- {
- parent->GetChildren().Remove(item);
- }
+ if ( parent )
+ {
+ parent->GetChildren().Remove( item ); // remove by value
+ }
- item->DeleteChildren(this);
- SendDeleteEvent(item);
- delete item;
+ item->DeleteChildren(this);
+ SendDeleteEvent(item);
+ delete item;
- m_dirty = TRUE;
+ m_dirty = TRUE;
}
void wxTreeCtrl::DeleteAllItems()
{
- if ( m_anchor )
- {
- m_anchor->DeleteChildren(this);
- delete m_anchor;
+ if ( m_anchor )
+ {
+ m_anchor->DeleteChildren(this);
+ delete m_anchor;
- m_anchor = NULL;
+ m_anchor = NULL;
- m_dirty = TRUE;
- }
+ m_dirty = TRUE;
+ }
}
void wxTreeCtrl::Expand(const wxTreeItemId& itemId)
// effect of changing the control size which might not be desirable
wxControl::SetLabel(label);
m_widget = gtk_label_new( m_label.mbc_str() );
+
+ gtk_label_set_line_wrap( GTK_LABEL(m_widget), FALSE );
SetFont( parent->GetFont() );
GtkRequisition req;
(* GTK_WIDGET_CLASS( GTK_OBJECT(m_widget)->klass )->size_request ) (m_widget, &req );
-
+
wxSize newSize = size;
if (newSize.x == -1) newSize.x = req.width;
if (newSize.y == -1) newSize.y = req.height;
m_toolbar = GTK_TOOLBAR( gtk_toolbar_new( GTK_ORIENTATION_HORIZONTAL,
GTK_TOOLBAR_ICONS ) );
+// gtk_toolbar_set_space_style( m_toolbar, GTK_TOOLBAR_SPACE_LINE );
m_separation = 5;
gtk_toolbar_set_space_size( m_toolbar, m_separation );
m_hasToolAlready = FALSE;
gtk_toolbar_append_space( m_toolbar );
}
+bool wxToolBar::DeleteTool(int toolIndex)
+{
+ wxNode *node = m_tools.First();
+ while (node)
+ {
+ wxToolBarTool *tool = (wxToolBarTool*)node->Data();
+ if (tool->m_index == toolIndex)
+ {
+ if (tool->m_control)
+ tool->m_control->Destroy();
+ else
+ gtk_widget_destroy( tool->m_item );
+ m_tools.DeleteNode( node );
+
+ return TRUE;
+ }
+ node = node->Next();
+ }
+
+ return FALSE;
+}
+
void wxToolBar::ClearTools()
{
wxFAIL_MSG( wxT("wxToolBar::ClearTools not implemented") );
// effect of changing the control size which might not be desirable
wxControl::SetLabel(label);
m_widget = gtk_label_new( m_label.mbc_str() );
+
+ gtk_label_set_line_wrap( GTK_LABEL(m_widget), FALSE );
SetFont( parent->GetFont() );
GtkRequisition req;
(* GTK_WIDGET_CLASS( GTK_OBJECT(m_widget)->klass )->size_request ) (m_widget, &req );
-
+
wxSize newSize = size;
if (newSize.x == -1) newSize.x = req.width;
if (newSize.y == -1) newSize.y = req.height;
m_toolbar = GTK_TOOLBAR( gtk_toolbar_new( GTK_ORIENTATION_HORIZONTAL,
GTK_TOOLBAR_ICONS ) );
+// gtk_toolbar_set_space_style( m_toolbar, GTK_TOOLBAR_SPACE_LINE );
m_separation = 5;
gtk_toolbar_set_space_size( m_toolbar, m_separation );
m_hasToolAlready = FALSE;
gtk_toolbar_append_space( m_toolbar );
}
+bool wxToolBar::DeleteTool(int toolIndex)
+{
+ wxNode *node = m_tools.First();
+ while (node)
+ {
+ wxToolBarTool *tool = (wxToolBarTool*)node->Data();
+ if (tool->m_index == toolIndex)
+ {
+ if (tool->m_control)
+ tool->m_control->Destroy();
+ else
+ gtk_widget_destroy( tool->m_item );
+ m_tools.DeleteNode( node );
+
+ return TRUE;
+ }
+ node = node->Next();
+ }
+
+ return FALSE;
+}
+
void wxToolBar::ClearTools()
{
wxFAIL_MSG( wxT("wxToolBar::ClearTools not implemented") );