Added layout constraints call to wxNotebook

Renamed key_down events to match MSW equivalents
  Invened activated events to tree and list ctrl
  Added patches to text ctrl from georg


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1207 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
1998-12-16 08:06:02 +00:00
parent 655822f3a7
commit 435fe83e74
15 changed files with 57 additions and 9 deletions

View File

@@ -164,6 +164,7 @@ const wxEventType wxEVT_COMMAND_TREE_ITEM_COLLAPSING = wxEVT_FIRST + 610;
const wxEventType wxEVT_COMMAND_TREE_SEL_CHANGED = wxEVT_FIRST + 611; const wxEventType wxEVT_COMMAND_TREE_SEL_CHANGED = wxEVT_FIRST + 611;
const wxEventType wxEVT_COMMAND_TREE_SEL_CHANGING = wxEVT_FIRST + 612; const wxEventType wxEVT_COMMAND_TREE_SEL_CHANGING = wxEVT_FIRST + 612;
const wxEventType wxEVT_COMMAND_TREE_KEY_DOWN = wxEVT_FIRST + 613; const wxEventType wxEVT_COMMAND_TREE_KEY_DOWN = wxEVT_FIRST + 613;
const wxEventType wxEVT_COMMAND_TREE_ITEM_ACTIVATED = wxEVT_FIRST + 614;
/* List control event types */ /* List control event types */
const wxEventType wxEVT_COMMAND_LIST_BEGIN_DRAG = wxEVT_FIRST + 700; const wxEventType wxEVT_COMMAND_LIST_BEGIN_DRAG = wxEVT_FIRST + 700;
@@ -181,6 +182,7 @@ 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_COL_CLICK = wxEVT_FIRST + 712;
const wxEventType wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK = wxEVT_FIRST + 713; const wxEventType wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK = wxEVT_FIRST + 713;
const wxEventType wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK = wxEVT_FIRST + 714; const wxEventType wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK = wxEVT_FIRST + 714;
const wxEventType wxEVT_COMMAND_LIST_ITEM_ACTIVATED = wxEVT_FIRST + 715;
/* Tab and notebook control event types */ /* Tab and notebook control event types */
const wxEventType wxEVT_COMMAND_TAB_SEL_CHANGED = wxEVT_FIRST + 800; const wxEventType wxEVT_COMMAND_TAB_SEL_CHANGED = wxEVT_FIRST + 800;

View File

@@ -224,6 +224,7 @@ typedef void (wxEvtHandler::*wxListEventFunction)(wxListEvent&);
#define EVT_LIST_COL_CLICK(id, fn) { wxEVT_COMMAND_LIST_COL_CLICK, 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_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 }, #define EVT_LIST_ITEM_MIDDLE_CLICK(id, fn) { wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL },
#define EVT_LIST_ITEM_ACTIVATED(id, fn) { wxEVT_COMMAND_LIST_ITEM_ACTIVATED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL },
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxListItemData (internal) // wxListItemData (internal)

View File

@@ -168,6 +168,9 @@ typedef void (wxEvtHandler::*wxTreeEventFunction)(wxTreeEvent&);
// be deleted just after the return of this event handler (if any) // be deleted just after the return of this event handler (if any)
#define EVT_TREE_DELETE_ITEM(id, fn) { wxEVT_COMMAND_TREE_DELETE_ITEM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL }, #define EVT_TREE_DELETE_ITEM(id, fn) { wxEVT_COMMAND_TREE_DELETE_ITEM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
// GetItem() returns the item that was activated (double click, enter, space)
#define EVT_TREE_ITEM_ACTIVATED(id, fn) { wxEVT_COMMAND_TREE_ITEM_ACTIVATED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL },
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// wxTreeCtrl - the tree control // wxTreeCtrl - the tree control
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------

View File

@@ -474,6 +474,7 @@ typedef void (wxEvtHandler::*wxListEventFunction)(wxListEvent&);
#define EVT_LIST_KEY_DOWN(id, fn) { wxEVT_COMMAND_LIST_KEY_DOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL }, #define EVT_LIST_KEY_DOWN(id, fn) { wxEVT_COMMAND_LIST_KEY_DOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
#define EVT_LIST_INSERT_ITEM(id, fn) { wxEVT_COMMAND_LIST_INSERT_ITEM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL }, #define EVT_LIST_INSERT_ITEM(id, fn) { wxEVT_COMMAND_LIST_INSERT_ITEM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
#define EVT_LIST_COL_CLICK(id, fn) { wxEVT_COMMAND_LIST_COL_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL }, #define EVT_LIST_COL_CLICK(id, fn) { wxEVT_COMMAND_LIST_COL_CLICK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, NULL },
#define EVT_LIST_ITEM_ACTIVATED(id, fn) { wxEVT_COMMAND_LIST_ITEM_ACTIVATED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxListEventFunction) & fn, (wxObject *) NULL },
#endif #endif
// _WX_LISTCTRL_H_ // _WX_LISTCTRL_H_

View File

@@ -535,5 +535,8 @@ typedef void (wxEvtHandler::*wxTreeEventFunction)(wxTreeEvent&);
// be deleted just after the return of this event handler (if any) // be deleted just after the return of this event handler (if any)
#define EVT_TREE_DELETE_ITEM(id, fn) { wxEVT_COMMAND_TREE_DELETE_ITEM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL }, #define EVT_TREE_DELETE_ITEM(id, fn) { wxEVT_COMMAND_TREE_DELETE_ITEM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, (wxObject *) NULL },
// GetItem() returns the item that was activated (double click, enter, space)
#define EVT_TREE_ITEM_ACTIVATED(id, fn) { wxEVT_COMMAND_TREE_ITEM_ACTIVATED, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxTreeEventFunction) & fn, NULL },
#endif #endif
// _WX_TREECTRL_H_ // _WX_TREECTRL_H_

View File

@@ -56,6 +56,7 @@ BEGIN_EVENT_TABLE(MyListCtrl, wxListCtrl)
EVT_LIST_ITEM_SELECTED(LIST_CTRL, MyListCtrl::OnSelected) EVT_LIST_ITEM_SELECTED(LIST_CTRL, MyListCtrl::OnSelected)
EVT_LIST_ITEM_DESELECTED(LIST_CTRL, MyListCtrl::OnDeselected) EVT_LIST_ITEM_DESELECTED(LIST_CTRL, MyListCtrl::OnDeselected)
EVT_LIST_KEY_DOWN(LIST_CTRL, MyListCtrl::OnListKeyDown) EVT_LIST_KEY_DOWN(LIST_CTRL, MyListCtrl::OnListKeyDown)
EVT_LIST_ITEM_ACTIVATED(LIST_CTRL, MyListCtrl::OnActivated)
END_EVENT_TABLE() END_EVENT_TABLE()
IMPLEMENT_APP(MyApp) IMPLEMENT_APP(MyApp)
@@ -449,6 +450,18 @@ void MyListCtrl::OnDeselected(wxListEvent& WXUNUSED(event))
text->WriteText("OnDeselected\n"); text->WriteText("OnDeselected\n");
} }
void MyListCtrl::OnActivated(wxListEvent& WXUNUSED(event))
{
if ( !wxGetApp().GetTopWindow() )
return;
wxTextCtrl *text = ((MyFrame *)wxGetApp().GetTopWindow())->m_logWindow;
if ( !text )
return;
text->WriteText("OnActivated\n");
}
void MyListCtrl::OnListKeyDown(wxListEvent& WXUNUSED(event)) void MyListCtrl::OnListKeyDown(wxListEvent& WXUNUSED(event))
{ {
if ( !wxGetApp().GetTopWindow() ) if ( !wxGetApp().GetTopWindow() )
@@ -461,3 +474,4 @@ void MyListCtrl::OnListKeyDown(wxListEvent& WXUNUSED(event))
text->WriteText("OnListKeyDown\n"); text->WriteText("OnListKeyDown\n");
} }

View File

@@ -37,6 +37,7 @@ public:
void OnSelected(wxListEvent& event); void OnSelected(wxListEvent& event);
void OnDeselected(wxListEvent& event); void OnDeselected(wxListEvent& event);
void OnListKeyDown(wxListEvent& event); void OnListKeyDown(wxListEvent& event);
void OnActivated(wxListEvent& event);
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };

View File

@@ -65,6 +65,7 @@ BEGIN_EVENT_TABLE(MyTreeCtrl, wxTreeCtrl)
EVT_TREE_SEL_CHANGED(TreeTest_Ctrl, MyTreeCtrl::OnSelChanged) EVT_TREE_SEL_CHANGED(TreeTest_Ctrl, MyTreeCtrl::OnSelChanged)
EVT_TREE_SEL_CHANGING(TreeTest_Ctrl, MyTreeCtrl::OnSelChanging) EVT_TREE_SEL_CHANGING(TreeTest_Ctrl, MyTreeCtrl::OnSelChanging)
EVT_TREE_KEY_DOWN(TreeTest_Ctrl, MyTreeCtrl::OnTreeKeyDown) EVT_TREE_KEY_DOWN(TreeTest_Ctrl, MyTreeCtrl::OnTreeKeyDown)
EVT_TREE_ITEM_ACTIVATED(TreeTest_Ctrl, MyTreeCtrl::OnItemActivated)
END_EVENT_TABLE() END_EVENT_TABLE()
IMPLEMENT_APP(MyApp) IMPLEMENT_APP(MyApp)
@@ -318,6 +319,11 @@ void MyTreeCtrl::OnItemCollapsing(wxTreeEvent& event)
} }
void MyTreeCtrl::OnTreeKeyDown(wxTreeEvent&WXUNUSED(event)) void MyTreeCtrl::OnTreeKeyDown(wxTreeEvent&WXUNUSED(event))
{
wxLogMessage("OnTreeKeyDown");
}
void MyTreeCtrl::OnItemActivated(wxTreeEvent&WXUNUSED(event))
{ {
// show some info about this item // show some info about this item
wxTreeItemId itemId = GetSelection(); wxTreeItemId itemId = GetSelection();
@@ -328,7 +334,7 @@ void MyTreeCtrl::OnTreeKeyDown(wxTreeEvent&WXUNUSED(event))
item->ShowInfo(this); item->ShowInfo(this);
} }
wxLogMessage("OnTreeKeyDown"); wxLogMessage("OnItemActivated");
} }
static inline const char *Bool2String(bool b) static inline const char *Bool2String(bool b)

View File

@@ -55,6 +55,7 @@ public:
void OnSelChanged(wxTreeEvent& event); void OnSelChanged(wxTreeEvent& event);
void OnSelChanging(wxTreeEvent& event); void OnSelChanging(wxTreeEvent& event);
void OnTreeKeyDown(wxTreeEvent& event); void OnTreeKeyDown(wxTreeEvent& event);
void OnItemActivated(wxTreeEvent& event);
void GetItemsRecursively(const wxTreeItemId& idParent, long cookie); void GetItemsRecursively(const wxTreeItemId& idParent, long cookie);

View File

@@ -1216,7 +1216,7 @@ void wxListMainWindow::OnMouse( wxMouseEvent &event )
m_lastOnSame = FALSE; m_lastOnSame = FALSE;
m_renameTimer->Stop(); m_renameTimer->Stop();
SendNotify( line, wxEVT_COMMAND_LIST_KEY_DOWN ); SendNotify( line, wxEVT_COMMAND_LIST_ITEM_ACTIVATED );
return; return;
} }
@@ -1369,6 +1369,11 @@ void wxListMainWindow::OnArrowChar( wxListLineData *newCurrent, bool shiftDown )
void wxListMainWindow::OnChar( wxKeyEvent &event ) void wxListMainWindow::OnChar( wxKeyEvent &event )
{ {
wxListEvent le( wxEVT_COMMAND_LIST_KEY_DOWN, m_parent->GetId() );
le.m_code = event.KeyCode();
le.SetEventObject( m_parent );
m_parent->GetEventHandler()->ProcessEvent( le );
/* /*
if (event.KeyCode() == WXK_TAB) if (event.KeyCode() == WXK_TAB)
{ {
@@ -1482,7 +1487,7 @@ void wxListMainWindow::OnChar( wxKeyEvent &event )
case WXK_RETURN: case WXK_RETURN:
case WXK_EXECUTE: case WXK_EXECUTE:
{ {
wxListEvent le( wxEVT_COMMAND_LIST_KEY_DOWN, GetParent()->GetId() ); wxListEvent le( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, GetParent()->GetId() );
le.SetEventObject( GetParent() ); le.SetEventObject( GetParent() );
le.m_itemIndex = GetIndexOfLine( m_current ); le.m_itemIndex = GetIndexOfLine( m_current );
m_current->GetItem( 0, le.m_item ); m_current->GetItem( 0, le.m_item );

View File

@@ -1112,6 +1112,11 @@ void wxTreeCtrl::OnKillFocus( wxFocusEvent &WXUNUSED(event) )
void wxTreeCtrl::OnChar( wxKeyEvent &event ) void wxTreeCtrl::OnChar( wxKeyEvent &event )
{ {
wxTreeEvent te( wxEVT_COMMAND_TREE_KEY_DOWN, GetId() );
te.m_code = event.KeyCode();
te.SetEventObject( this );
GetEventHandler()->ProcessEvent( te );
if (m_current == 0) if (m_current == 0)
{ {
event.Skip(); event.Skip();
@@ -1144,7 +1149,7 @@ void wxTreeCtrl::OnChar( wxKeyEvent &event )
case ' ': case ' ':
case WXK_RETURN: case WXK_RETURN:
{ {
wxTreeEvent event( wxEVT_COMMAND_TREE_KEY_DOWN, GetId() ); wxTreeEvent event( wxEVT_COMMAND_TREE_ITEM_ACTIVATED, GetId() );
event.m_item = m_current; event.m_item = m_current;
event.m_code = 0; event.m_code = 0;
event.SetEventObject( this ); event.SetEventObject( this );
@@ -1236,7 +1241,7 @@ void wxTreeCtrl::OnMouse( wxMouseEvent &event )
if ( event.LeftDClick() ) if ( event.LeftDClick() )
{ {
wxTreeEvent event( wxEVT_COMMAND_TREE_KEY_DOWN, GetId() ); wxTreeEvent event( wxEVT_COMMAND_TREE_ITEM_ACTIVATED, GetId() );
event.m_item = item; event.m_item = item;
event.m_code = 0; event.m_code = 0;
event.SetEventObject( this ); event.SetEventObject( this );

View File

@@ -99,6 +99,8 @@ static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation*
} }
win->SetSize( alloc->x, alloc->y, alloc->width, alloc->height ); win->SetSize( alloc->x, alloc->y, alloc->width, alloc->height );
if (win->GetAutoLayout()) win->Layout();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@@ -303,7 +303,8 @@ bool wxTextCtrl::LoadFile( const wxString &file )
if (m_windowStyle & wxTE_MULTILINE) if (m_windowStyle & wxTE_MULTILINE)
{ {
gtk_editable_insert_text( GTK_EDITABLE(m_text), text, 0, &len ); gint pos = 0;
gtk_editable_insert_text( GTK_EDITABLE(m_text), text, len, &pos );
} }
else else
{ {
@@ -555,7 +556,7 @@ void wxTextCtrl::Replace( long from, long to, const wxString &value )
gtk_editable_delete_text( GTK_EDITABLE(m_text), (gint)from, (gint)to ); gtk_editable_delete_text( GTK_EDITABLE(m_text), (gint)from, (gint)to );
if (value.IsNull()) return; if (value.IsNull()) return;
gint pos = (gint)to; gint pos = (gint)from;
gtk_editable_insert_text( GTK_EDITABLE(m_text), value, value.Length(), &pos ); gtk_editable_insert_text( GTK_EDITABLE(m_text), value, value.Length(), &pos );
} }

View File

@@ -99,6 +99,8 @@ static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation*
} }
win->SetSize( alloc->x, alloc->y, alloc->width, alloc->height ); win->SetSize( alloc->x, alloc->y, alloc->width, alloc->height );
if (win->GetAutoLayout()) win->Layout();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@@ -303,7 +303,8 @@ bool wxTextCtrl::LoadFile( const wxString &file )
if (m_windowStyle & wxTE_MULTILINE) if (m_windowStyle & wxTE_MULTILINE)
{ {
gtk_editable_insert_text( GTK_EDITABLE(m_text), text, 0, &len ); gint pos = 0;
gtk_editable_insert_text( GTK_EDITABLE(m_text), text, len, &pos );
} }
else else
{ {
@@ -555,7 +556,7 @@ void wxTextCtrl::Replace( long from, long to, const wxString &value )
gtk_editable_delete_text( GTK_EDITABLE(m_text), (gint)from, (gint)to ); gtk_editable_delete_text( GTK_EDITABLE(m_text), (gint)from, (gint)to );
if (value.IsNull()) return; if (value.IsNull()) return;
gint pos = (gint)to; gint pos = (gint)from;
gtk_editable_insert_text( GTK_EDITABLE(m_text), value, value.Length(), &pos ); gtk_editable_insert_text( GTK_EDITABLE(m_text), value, value.Length(), &pos );
} }