many fixes to wxTextCrtl, wxTreeCrtl, wxListBox,

wxDialog, wxFrame
two more samples work now, docview and treectrl


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@316 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
1998-07-20 18:05:48 +00:00
parent 035b704a46
commit e2414cbe8c
25 changed files with 334 additions and 190 deletions

View File

@@ -40,6 +40,13 @@
#define wxIMAGELIST_DRAW_SELECTED 0x0004 #define wxIMAGELIST_DRAW_SELECTED 0x0004
#define wxIMAGELIST_DRAW_FOCUSED 0x0008 #define wxIMAGELIST_DRAW_FOCUSED 0x0008
// Flag values for Set/GetImageList
enum {
wxIMAGE_LIST_NORMAL, // Normal icons
wxIMAGE_LIST_SMALL, // Small icons
wxIMAGE_LIST_STATE // State icons: unimplemented (see WIN32 documentation)
};
class wxImageList: public wxObject class wxImageList: public wxObject
{ {
DECLARE_DYNAMIC_CLASS(wxImageList) DECLARE_DYNAMIC_CLASS(wxImageList)

View File

@@ -276,6 +276,9 @@ public:
void DeleteItem( long item ); void DeleteItem( long item );
void DeleteChildren( long item ); void DeleteChildren( long item );
bool DeleteAllItems(); bool DeleteAllItems();
bool ExpandItem(long item) { return ExpandItem(item, wxTREE_EXPAND_EXPAND); }
bool CollapseItem(long item) { return ExpandItem(item, wxTREE_EXPAND_COLLAPSE); }
bool ToggleItem(long item) { return ExpandItem(item, wxTREE_EXPAND_TOGGLE); }
bool ExpandItem( long item, int action ); bool ExpandItem( long item, int action );
bool GetItem( wxTreeItem &info ) const; bool GetItem( wxTreeItem &info ) const;
long GetItemData( long item ) const; long GetItemData( long item ) const;
@@ -302,8 +305,8 @@ public:
void OnChar( wxKeyEvent &event ); void OnChar( wxKeyEvent &event );
void OnMouse( const wxMouseEvent &event ); void OnMouse( const wxMouseEvent &event );
void SetImageList(wxImageList *imageList) { m_imageList = imageList; } wxImageList *GetImageList(int which = wxIMAGE_LIST_NORMAL) const;
wxImageList *GetImageList() const { return m_imageList; } void SetImageList(wxImageList *imageList, int which = wxIMAGE_LIST_NORMAL);
private: private:
wxGenericTreeItem *m_anchor; wxGenericTreeItem *m_anchor;
@@ -318,6 +321,7 @@ private:
wxPaintDC *m_dc; wxPaintDC *m_dc;
wxBrush *m_hilightBrush; wxBrush *m_hilightBrush;
wxImageList *m_imageList; wxImageList *m_imageList;
wxImageList *m_smallImageList;
void CalculateLevel( wxGenericTreeItem *item, wxPaintDC &dc, int level, int &y ); void CalculateLevel( wxGenericTreeItem *item, wxPaintDC &dc, int level, int &y );
void CalculatePositions(); void CalculatePositions();

View File

@@ -65,6 +65,7 @@ class wxDialog: public wxWindow
void OnCancel( wxCommandEvent &event ); void OnCancel( wxCommandEvent &event );
void OnOk( wxCommandEvent &event ); void OnOk( wxCommandEvent &event );
void OnPaint(wxPaintEvent& event); void OnPaint(wxPaintEvent& event);
bool Destroy(void);
void OnCloseWindow(wxCloseEvent& event); void OnCloseWindow(wxCloseEvent& event);
/* /*
void OnCharHook(wxKeyEvent& event); void OnCharHook(wxKeyEvent& event);
@@ -74,11 +75,6 @@ class wxDialog: public wxWindow
virtual void EndModal(int retCode); virtual void EndModal(int retCode);
virtual bool IsModal(void) const { return ((GetWindowStyleFlag() & wxDIALOG_MODAL) == wxDIALOG_MODAL); } virtual bool IsModal(void) const { return ((GetWindowStyleFlag() & wxDIALOG_MODAL) == wxDIALOG_MODAL); }
virtual void InitDialog(void); virtual void InitDialog(void);
/*
void OnOK(wxCommandEvent& event);
void OnApply(wxCommandEvent& event);
void OnCancel(wxCommandEvent& event);
*/
private: private:

View File

@@ -69,10 +69,13 @@ class wxFrame: public wxWindow
void SetTitle( const wxString &title ); void SetTitle( const wxString &title );
wxString GetTitle(void) const; wxString GetTitle(void) const;
void OnActivate( wxActivateEvent &WXUNUSED(event) ) {}; void OnActivate( wxActivateEvent &WXUNUSED(event) ) {};
void OnIdle( wxIdleEvent &event );
//private: //private:
void GtkOnSize( int x, int y, int width, int height ); void GtkOnSize( int x, int y, int width, int height );
void DoMenuUpdates(void);
void DoMenuUpdates(wxMenu* menu);
private: private:

View File

@@ -76,6 +76,7 @@ class wxListBox: public wxControl
private: private:
GtkList *m_list; GtkList *m_list;
wxList m_clientData;
public: public:

View File

@@ -29,6 +29,12 @@ class wxMenuBar;
class wxMenuItem; class wxMenuItem;
class wxMenu; class wxMenu;
//-----------------------------------------------------------------------------
// const
//-----------------------------------------------------------------------------
#define ID_SEPARATOR (-1)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxMenuBar // wxMenuBar
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -70,6 +76,14 @@ class wxMenuItem: public wxObject
GtkWidget *m_menuItem; // GtkMenuItem GtkWidget *m_menuItem; // GtkMenuItem
bool IsSeparator() const { return m_id == ID_SEPARATOR; }
bool IsEnabled() const { return m_isEnabled; }
bool IsChecked() const { return m_checked; }
int GetId() const { return m_id; }
const wxString& GetHelp() const { return m_helpStr; }
wxMenu *GetSubMenu() const { return m_subMenu; }
}; };
class wxMenu: public wxEvtHandler class wxMenu: public wxEvtHandler
@@ -86,6 +100,7 @@ class wxMenu: public wxEvtHandler
wxMenu *subMenu, const wxString &helpStr = "" ); wxMenu *subMenu, const wxString &helpStr = "" );
int FindItem( const wxString itemString ) const; int FindItem( const wxString itemString ) const;
void Break(void) {}; void Break(void) {};
void Check(int id, bool Flag);
void Enable( int id, bool enable ); void Enable( int id, bool enable );
bool Enabled( int id ) const; bool Enabled( int id ) const;
void SetLabel( int id, const wxString &label ); void SetLabel( int id, const wxString &label );

View File

@@ -65,6 +65,7 @@ class wxDialog: public wxWindow
void OnCancel( wxCommandEvent &event ); void OnCancel( wxCommandEvent &event );
void OnOk( wxCommandEvent &event ); void OnOk( wxCommandEvent &event );
void OnPaint(wxPaintEvent& event); void OnPaint(wxPaintEvent& event);
bool Destroy(void);
void OnCloseWindow(wxCloseEvent& event); void OnCloseWindow(wxCloseEvent& event);
/* /*
void OnCharHook(wxKeyEvent& event); void OnCharHook(wxKeyEvent& event);
@@ -74,11 +75,6 @@ class wxDialog: public wxWindow
virtual void EndModal(int retCode); virtual void EndModal(int retCode);
virtual bool IsModal(void) const { return ((GetWindowStyleFlag() & wxDIALOG_MODAL) == wxDIALOG_MODAL); } virtual bool IsModal(void) const { return ((GetWindowStyleFlag() & wxDIALOG_MODAL) == wxDIALOG_MODAL); }
virtual void InitDialog(void); virtual void InitDialog(void);
/*
void OnOK(wxCommandEvent& event);
void OnApply(wxCommandEvent& event);
void OnCancel(wxCommandEvent& event);
*/
private: private:

View File

@@ -69,10 +69,13 @@ class wxFrame: public wxWindow
void SetTitle( const wxString &title ); void SetTitle( const wxString &title );
wxString GetTitle(void) const; wxString GetTitle(void) const;
void OnActivate( wxActivateEvent &WXUNUSED(event) ) {}; void OnActivate( wxActivateEvent &WXUNUSED(event) ) {};
void OnIdle( wxIdleEvent &event );
//private: //private:
void GtkOnSize( int x, int y, int width, int height ); void GtkOnSize( int x, int y, int width, int height );
void DoMenuUpdates(void);
void DoMenuUpdates(wxMenu* menu);
private: private:

View File

@@ -76,6 +76,7 @@ class wxListBox: public wxControl
private: private:
GtkList *m_list; GtkList *m_list;
wxList m_clientData;
public: public:

View File

@@ -29,6 +29,12 @@ class wxMenuBar;
class wxMenuItem; class wxMenuItem;
class wxMenu; class wxMenu;
//-----------------------------------------------------------------------------
// const
//-----------------------------------------------------------------------------
#define ID_SEPARATOR (-1)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxMenuBar // wxMenuBar
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -70,6 +76,14 @@ class wxMenuItem: public wxObject
GtkWidget *m_menuItem; // GtkMenuItem GtkWidget *m_menuItem; // GtkMenuItem
bool IsSeparator() const { return m_id == ID_SEPARATOR; }
bool IsEnabled() const { return m_isEnabled; }
bool IsChecked() const { return m_checked; }
int GetId() const { return m_id; }
const wxString& GetHelp() const { return m_helpStr; }
wxMenu *GetSubMenu() const { return m_subMenu; }
}; };
class wxMenu: public wxEvtHandler class wxMenu: public wxEvtHandler
@@ -86,6 +100,7 @@ class wxMenu: public wxEvtHandler
wxMenu *subMenu, const wxString &helpStr = "" ); wxMenu *subMenu, const wxString &helpStr = "" );
int FindItem( const wxString itemString ) const; int FindItem( const wxString itemString ) const;
void Break(void) {}; void Break(void) {};
void Check(int id, bool Flag);
void Enable( int id, bool enable ); void Enable( int id, bool enable );
bool Enabled( int id ) const; bool Enabled( int id ) const;
void SetLabel( int id, const wxString &label ); void SetLabel( int id, const wxString &label );

View File

@@ -73,10 +73,13 @@ bool MyApp::OnInit(void)
// Make an image list containing small icons // Make an image list containing small icons
m_imageListNormal = new wxImageList(16, 16, TRUE); m_imageListNormal = new wxImageList(16, 16, TRUE);
#ifdef __WXMSW__
wxIcon icon1("icon1", wxBITMAP_TYPE_ICO_RESOURCE); wxIcon icon1("icon1", wxBITMAP_TYPE_ICO_RESOURCE);
m_imageListNormal->Add(icon1); m_imageListNormal->Add(icon1);
wxIcon icon2("icon2", wxBITMAP_TYPE_ICO_RESOURCE); wxIcon icon2("icon2", wxBITMAP_TYPE_ICO_RESOURCE);
m_imageListNormal->Add(icon2); m_imageListNormal->Add(icon2);
#else
#endif
// Make a menubar // Make a menubar
wxMenu *file_menu = new wxMenu; wxMenu *file_menu = new wxMenu;

View File

@@ -235,6 +235,8 @@ long wxGenericTreeItem::HitTest( const wxPoint& point, int &flags )
return m_itemId; return m_itemId;
} }
else else
{
if (!m_isCollapsed)
{ {
wxNode *node = m_children.First(); wxNode *node = m_children.First();
while (node) while (node)
@@ -245,6 +247,7 @@ long wxGenericTreeItem::HitTest( const wxPoint& point, int &flags )
node = node->Next(); node = node->Next();
}; };
}; };
};
return -1; return -1;
}; };
@@ -352,6 +355,8 @@ wxTreeCtrl::wxTreeCtrl()
m_isCreated = FALSE; m_isCreated = FALSE;
m_dc = NULL; m_dc = NULL;
m_hilightBrush = new wxBrush( wxSystemSettings::GetSystemColour(wxSYS_COLOUR_HIGHLIGHT), wxSOLID ); m_hilightBrush = new wxBrush( wxSystemSettings::GetSystemColour(wxSYS_COLOUR_HIGHLIGHT), wxSOLID );
m_imageList = NULL;
m_smallImageList = NULL;
}; };
wxTreeCtrl::wxTreeCtrl(wxWindow *parent, wxWindowID id, wxTreeCtrl::wxTreeCtrl(wxWindow *parent, wxWindowID id,
@@ -369,6 +374,8 @@ wxTreeCtrl::wxTreeCtrl(wxWindow *parent, wxWindowID id,
m_isCreated = FALSE; m_isCreated = FALSE;
m_dc = NULL; m_dc = NULL;
m_hilightBrush = new wxBrush( wxSystemSettings::GetSystemColour(wxSYS_COLOUR_HIGHLIGHT), wxSOLID ); m_hilightBrush = new wxBrush( wxSystemSettings::GetSystemColour(wxSYS_COLOUR_HIGHLIGHT), wxSOLID );
m_imageList = NULL;
m_smallImageList = NULL;
Create( parent, id, pos, size, style, name ); Create( parent, id, pos, size, style, name );
}; };
@@ -437,6 +444,8 @@ long wxTreeCtrl::InsertItem( long parent, const wxString& label, int image,
{ {
CalculatePositions(); CalculatePositions();
if (!p->HasChildren()) p->m_hasChildren = TRUE;
int ch = 0; int ch = 0;
GetClientSize( NULL, &ch ); GetClientSize( NULL, &ch );
@@ -516,6 +525,8 @@ long wxTreeCtrl::InsertItem( long parent, wxTreeItem &info, long WXUNUSED(insert
{ {
CalculatePositions(); CalculatePositions();
if (!p->HasChildren()) p->m_hasChildren = TRUE;
int ch = 0; int ch = 0;
GetClientSize( NULL, &ch ); GetClientSize( NULL, &ch );
@@ -581,6 +592,8 @@ bool wxTreeCtrl::ExpandItem( long item, int action )
node = node->Next(); node = node->Next();
}; };
CalculatePositions();
i->SendCollapse( this ); i->SendCollapse( this );
break; break;
} }
@@ -757,6 +770,26 @@ long wxTreeCtrl::HitTest( const wxPoint& point, int &flags )
return m_anchor->HitTest( point, flags ); return m_anchor->HitTest( point, flags );
}; };
wxImageList *wxTreeCtrl::GetImageList( int which ) const
{
if (which == wxIMAGE_LIST_NORMAL) return m_imageList;
return m_smallImageList;
};
void wxTreeCtrl::SetImageList( wxImageList *imageList, int which )
{
if (which == wxIMAGE_LIST_NORMAL)
{
if (m_imageList) delete m_imageList;
m_imageList = imageList;
}
else
{
if (m_smallImageList) delete m_smallImageList;
m_smallImageList = imageList;
};
};
void wxTreeCtrl::AdjustMyScrollbars() void wxTreeCtrl::AdjustMyScrollbars()
{ {
if (m_anchor) if (m_anchor)
@@ -810,13 +843,18 @@ void wxTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxPaintDC &dc, int level,
{ {
dc.SetTextForeground( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_HIGHLIGHTTEXT ) ); dc.SetTextForeground( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_HIGHLIGHTTEXT ) );
dc.SetBrush( *m_hilightBrush ); dc.SetBrush( *m_hilightBrush );
if (m_hasFocus)
dc.SetPen( *wxBLACK_PEN );
else
dc.SetPen( *wxWHITE_PEN );
long tw, th; long tw, th;
dc.GetTextExtent( item->m_text, &tw, &th ); dc.GetTextExtent( item->m_text, &tw, &th );
if (m_hasFocus)
{
dc.SetPen( *wxBLACK_PEN );
dc.DrawRectangle( item->m_x-2, item->m_y-2, tw+4, th+4 ); dc.DrawRectangle( item->m_x-2, item->m_y-2, tw+4, th+4 );
}
else
{
dc.SetPen( *wxTRANSPARENT_PEN );
dc.DrawRectangle( item->m_x-2, item->m_y-2, tw+4, th+4 );
}
dc.DrawText( item->m_text, item->m_x, item->m_y ); dc.DrawText( item->m_text, item->m_x, item->m_y );
dc.SetPen( *wxBLACK_PEN ); dc.SetPen( *wxBLACK_PEN );
@@ -825,7 +863,7 @@ void wxTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxPaintDC &dc, int level,
} }
else else
{ {
dc.SetPen( *wxWHITE_PEN ); dc.SetPen( *wxTRANSPARENT_PEN );
long tw, th; long tw, th;
dc.GetTextExtent( item->m_text, &tw, &th ); dc.GetTextExtent( item->m_text, &tw, &th );
dc.DrawRectangle( item->m_x-2, item->m_y-2, tw+4, th+4 ); dc.DrawRectangle( item->m_x-2, item->m_y-2, tw+4, th+4 );
@@ -836,18 +874,22 @@ void wxTreeCtrl::PaintLevel( wxGenericTreeItem *item, wxPaintDC &dc, int level,
if (item->NumberOfVisibleChildren() == 0) return; if (item->NumberOfVisibleChildren() == 0) return;
int semiOldY = y;
wxNode *node = item->m_children.First(); wxNode *node = item->m_children.First();
while (node) while (node)
{ {
wxGenericTreeItem *child = (wxGenericTreeItem *)node->Data(); wxGenericTreeItem *child = (wxGenericTreeItem *)node->Data();
y += m_lineHeight; y += m_lineHeight;
semiOldY = y;
PaintLevel( child, dc, level+1, y ); PaintLevel( child, dc, level+1, y );
node = node->Next(); node = node->Next();
}; };
dc.DrawLine( horizX+15, oldY+5, horizX+15, y ); dc.DrawLine( horizX+15, oldY+5, horizX+15, semiOldY );
} }
void wxTreeCtrl::OnPaint( const wxPaintEvent &WXUNUSED(event) ) void wxTreeCtrl::OnPaint( const wxPaintEvent &WXUNUSED(event) )

View File

@@ -17,6 +17,10 @@
#include "wx/app.h" #include "wx/app.h"
#include "wx/gtk/win_gtk.h" #include "wx/gtk/win_gtk.h"
//-----------------------------------------------------------------------------
extern wxList wxPendingDelete;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// delete // delete
@@ -167,6 +171,14 @@ bool wxDialog::OnClose(void)
return FALSE; return FALSE;
} }
bool wxDialog::Destroy(void)
{
if (!wxPendingDelete.Member(this))
wxPendingDelete.Append(this);
return TRUE;
}
void wxDialog::OnCloseWindow(wxCloseEvent& event) void wxDialog::OnCloseWindow(wxCloseEvent& event)
{ {
if (GetEventHandler()->OnClose() || event.GetForce()) if (GetEventHandler()->OnClose() || event.GetForce())
@@ -204,8 +216,8 @@ int wxDialog::ShowModal(void)
void wxDialog::EndModal( int retCode ) void wxDialog::EndModal( int retCode )
{ {
gtk_main_quit();
SetReturnCode( retCode ); SetReturnCode( retCode );
gtk_main_quit();
}; };
void wxDialog::InitDialog(void) void wxDialog::InitDialog(void)

View File

@@ -51,7 +51,7 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
{ {
m_needParent = FALSE; m_needParent = FALSE;
PreCreation( parent, -1, pos, wxDefaultSize, style, "filedialog" ); PreCreation( parent, -1, pos, wxDefaultSize, style | wxDIALOG_MODAL, "filedialog" );
m_message = message; m_message = message;
m_path = ""; m_path = "";
m_fileName = defaultFileName; m_fileName = defaultFileName;

View File

@@ -67,6 +67,7 @@ bool gtk_frame_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(
BEGIN_EVENT_TABLE(wxFrame, wxWindow) BEGIN_EVENT_TABLE(wxFrame, wxWindow)
EVT_CLOSE(wxFrame::OnCloseWindow) EVT_CLOSE(wxFrame::OnCloseWindow)
EVT_SIZE(wxFrame::OnSize) EVT_SIZE(wxFrame::OnSize)
EVT_IDLE(wxFrame::OnIdle)
END_EVENT_TABLE() END_EVENT_TABLE()
IMPLEMENT_DYNAMIC_CLASS(wxFrame,wxWindow) IMPLEMENT_DYNAMIC_CLASS(wxFrame,wxWindow)
@@ -360,3 +361,54 @@ wxString wxFrame::GetTitle(void) const
return (wxString&)m_title; return (wxString&)m_title;
}; };
void wxFrame::OnIdle(wxIdleEvent& WXUNUSED(event))
{
DoMenuUpdates();
}
// Query app for menu item updates (called from OnIdle)
void wxFrame::DoMenuUpdates(void)
{
wxMenuBar* bar = GetMenuBar();
if (!bar) return;
wxNode *node = bar->m_menus.First();
while (node)
{
wxMenu* menu = (wxMenu*)node->Data();
DoMenuUpdates(menu);
node = node->Next();
};
}
void wxFrame::DoMenuUpdates(wxMenu* menu)
{
wxNode* node = menu->m_items.First();
while (node)
{
wxMenuItem* item = (wxMenuItem*) node->Data();
if ( !item->IsSeparator() )
{
wxWindowID id = item->GetId();
wxUpdateUIEvent event(id);
event.SetEventObject( this );
if (GetEventHandler()->ProcessEvent(event))
{
if (event.GetSetText())
menu->SetLabel(id, event.GetText());
if (event.GetSetChecked())
menu->Check(id, event.GetChecked());
if (event.GetSetEnabled())
menu->Enable(id, event.GetEnabled());
}
if (item->GetSubMenu())
DoMenuUpdates(item->GetSubMenu());
}
node = node->Next();
}
}

View File

@@ -92,6 +92,8 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
gtk_container_add( GTK_CONTAINER(m_list), list_item ); gtk_container_add( GTK_CONTAINER(m_list), list_item );
m_clientData.Append( (wxObject*)NULL );
gtk_widget_show( list_item ); gtk_widget_show( list_item );
}; };
@@ -112,22 +114,44 @@ void wxListBox::Append( const wxString &item )
gtk_container_add( GTK_CONTAINER(m_list), list_item ); gtk_container_add( GTK_CONTAINER(m_list), list_item );
m_clientData.Append( (wxObject*)NULL );
gtk_widget_show( list_item ); gtk_widget_show( list_item );
}; };
void wxListBox::Append( const wxString &WXUNUSED(item), char *WXUNUSED(clientData) ) void wxListBox::Append( const wxString &item, char *clientData )
{ {
wxFAIL_MSG("wxListBox::Append(clientdata) not implemented"); GtkWidget *list_item;
list_item = gtk_list_item_new_with_label( item );
gtk_signal_connect( GTK_OBJECT(list_item), "select",
GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
gtk_container_add( GTK_CONTAINER(m_list), list_item );
m_clientData.Append( (wxObject*)clientData );
gtk_widget_show( list_item );
}; };
void wxListBox::Clear(void) void wxListBox::Clear(void)
{ {
gtk_list_clear_items( m_list, 0, Number() ); gtk_list_clear_items( m_list, 0, Number() );
m_clientData.Clear();
}; };
void wxListBox::Delete( int n ) void wxListBox::Delete( int n )
{ {
gtk_list_clear_items( m_list, n, n ); gtk_list_clear_items( m_list, n, n );
wxNode *node = m_clientData.Nth( n );
if (!node)
{
wxFAIL_MSG("wxListBox::Delete wrong index");
}
else
m_clientData.DeleteNode( node );
}; };
void wxListBox::Deselect( int n ) void wxListBox::Deselect( int n )
@@ -150,10 +174,10 @@ int wxListBox::FindString( const wxString &item ) const
return -1; return -1;
}; };
char *wxListBox::GetClientData( int WXUNUSED(n) ) const char *wxListBox::GetClientData( int n ) const
{ {
wxFAIL_MSG("wxListBox::GetClientData not implemented"); wxNode *node = m_clientData.Nth( n );
if (node) return ((char*)node->Data());
return NULL; return NULL;
}; };
@@ -250,8 +274,10 @@ void wxListBox::Set( int WXUNUSED(n), const wxString *WXUNUSED(choices) )
{ {
}; };
void wxListBox::SetClientData( int WXUNUSED(n), char *WXUNUSED(clientData) ) void wxListBox::SetClientData( int n, char *clientData )
{ {
wxNode *node = m_clientData.Nth( n );
if (node) node->SetData( (wxObject*)clientData );
}; };
void wxListBox::SetFirstItem( int WXUNUSED(n) ) void wxListBox::SetFirstItem( int WXUNUSED(n) )

View File

@@ -137,7 +137,7 @@ wxMenu::wxMenu( const wxString &title )
void wxMenu::AppendSeparator(void) void wxMenu::AppendSeparator(void)
{ {
wxMenuItem *mitem = new wxMenuItem(); wxMenuItem *mitem = new wxMenuItem();
mitem->m_id = -1; mitem->m_id = ID_SEPARATOR;
mitem->m_text = ""; mitem->m_text = "";
mitem->m_helpStr = ""; mitem->m_helpStr = "";
mitem->m_isCheckMenu = FALSE; mitem->m_isCheckMenu = FALSE;
@@ -219,6 +219,11 @@ int wxMenu::FindItem( const wxString itemString ) const
return -1; return -1;
}; };
void wxMenu::Check( int WXUNUSED(id), bool WXUNUSED(Flag) )
{
// I'm just too lazy
};
void wxMenu::Enable( int id, bool enable ) void wxMenu::Enable( int id, bool enable )
{ {
wxNode *node = m_items.First(); wxNode *node = m_items.First();

View File

@@ -33,6 +33,9 @@ END_EVENT_TABLE()
wxTextCtrl::wxTextCtrl(void) : streambuf() wxTextCtrl::wxTextCtrl(void) : streambuf()
{ {
if( allocate() )
setp(base(),ebuf());
m_modified = FALSE; m_modified = FALSE;
}; };
@@ -40,6 +43,9 @@ wxTextCtrl::wxTextCtrl( wxWindow *parent, wxWindowID id, const wxString &value,
const wxPoint &pos, const wxSize &size, const wxPoint &pos, const wxSize &size,
int style, const wxString &name ) : streambuf() int style, const wxString &name ) : streambuf()
{ {
if( allocate() )
setp(base(),ebuf());
m_modified = FALSE; m_modified = FALSE;
Create( parent, id, value, pos, size, style, name ); Create( parent, id, value, pos, size, style, name );
}; };
@@ -273,65 +279,6 @@ void wxTextCtrl::OnChar( wxKeyEvent &WXUNUSED(event) )
int wxTextCtrl::overflow(int c) int wxTextCtrl::overflow(int c)
{ {
// Make sure there is a holding area
if ( allocate()==EOF )
{
wxError("Streambuf allocation failed","Internal error");
return EOF;
}
// Verify that there are no characters in get area
if ( gptr() && gptr() < egptr() )
{
wxError("Who's trespassing my get area?","Internal error");
return EOF;
}
// Reset get area
setg(0,0,0);
// Make sure there is a put area
if ( ! pptr() )
{
/* This doesn't seem to be fatal so comment out error message */
// wxError("Put area not opened","Internal error");
setp( base(), base() );
}
// Determine how many characters have been inserted but no consumed
int plen = pptr() - pbase();
// Now Jerry relies on the fact that the buffer is at least 2 chars
// long, but the holding area "may be as small as 1" ???
// And we need an additional \0, so let's keep this inefficient but
// safe copy.
// If c!=EOF, it is a character that must also be comsumed
int xtra = c==EOF? 0 : 1;
// Write temporary C-string to wxTextWindow
{
char *txt = new char[plen+xtra+1];
memcpy(txt, pbase(), plen);
txt[plen] = (char)c; // append c
txt[plen+xtra] = '\0'; // append '\0' or overwrite c
// If the put area already contained \0, output will be truncated there
WriteText(txt);
delete[] txt;
}
// Reset put area
setp(pbase(), epptr());
#if defined(__WATCOMC__)
return __NOT_EOF;
#elif defined(zapeof) // HP-UX (all cfront based?)
return zapeof(c);
#else
return c!=EOF ? c : 0; // this should make everybody happy
#endif
/* OLD CODE
int len = pptr() - pbase(); int len = pptr() - pbase();
char *txt = new char[len+1]; char *txt = new char[len+1];
strncpy(txt, pbase(), len); strncpy(txt, pbase(), len);
@@ -340,22 +287,10 @@ int wxTextCtrl::overflow(int c)
setp(pbase(), epptr()); setp(pbase(), epptr());
delete[] txt; delete[] txt;
return EOF; return EOF;
*/
}; };
int wxTextCtrl::sync(void) int wxTextCtrl::sync(void)
{ {
// Verify that there are no characters in get area
if ( gptr() && gptr() < egptr() )
{
wxError("Who's trespassing my get area?","Internal error");
return EOF;
}
if ( pptr() && pptr() > pbase() ) return overflow(EOF);
return 0;
/* OLD CODE
int len = pptr() - pbase(); int len = pptr() - pbase();
char *txt = new char[len+1]; char *txt = new char[len+1];
strncpy(txt, pbase(), len); strncpy(txt, pbase(), len);
@@ -364,7 +299,6 @@ int wxTextCtrl::sync(void)
setp(pbase(), epptr()); setp(pbase(), epptr());
delete[] txt; delete[] txt;
return 0; return 0;
*/
}; };
int wxTextCtrl::underflow(void) int wxTextCtrl::underflow(void)

View File

@@ -17,6 +17,10 @@
#include "wx/app.h" #include "wx/app.h"
#include "wx/gtk/win_gtk.h" #include "wx/gtk/win_gtk.h"
//-----------------------------------------------------------------------------
extern wxList wxPendingDelete;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// delete // delete
@@ -167,6 +171,14 @@ bool wxDialog::OnClose(void)
return FALSE; return FALSE;
} }
bool wxDialog::Destroy(void)
{
if (!wxPendingDelete.Member(this))
wxPendingDelete.Append(this);
return TRUE;
}
void wxDialog::OnCloseWindow(wxCloseEvent& event) void wxDialog::OnCloseWindow(wxCloseEvent& event)
{ {
if (GetEventHandler()->OnClose() || event.GetForce()) if (GetEventHandler()->OnClose() || event.GetForce())
@@ -204,8 +216,8 @@ int wxDialog::ShowModal(void)
void wxDialog::EndModal( int retCode ) void wxDialog::EndModal( int retCode )
{ {
gtk_main_quit();
SetReturnCode( retCode ); SetReturnCode( retCode );
gtk_main_quit();
}; };
void wxDialog::InitDialog(void) void wxDialog::InitDialog(void)

View File

@@ -51,7 +51,7 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
{ {
m_needParent = FALSE; m_needParent = FALSE;
PreCreation( parent, -1, pos, wxDefaultSize, style, "filedialog" ); PreCreation( parent, -1, pos, wxDefaultSize, style | wxDIALOG_MODAL, "filedialog" );
m_message = message; m_message = message;
m_path = ""; m_path = "";
m_fileName = defaultFileName; m_fileName = defaultFileName;

View File

@@ -67,6 +67,7 @@ bool gtk_frame_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(
BEGIN_EVENT_TABLE(wxFrame, wxWindow) BEGIN_EVENT_TABLE(wxFrame, wxWindow)
EVT_CLOSE(wxFrame::OnCloseWindow) EVT_CLOSE(wxFrame::OnCloseWindow)
EVT_SIZE(wxFrame::OnSize) EVT_SIZE(wxFrame::OnSize)
EVT_IDLE(wxFrame::OnIdle)
END_EVENT_TABLE() END_EVENT_TABLE()
IMPLEMENT_DYNAMIC_CLASS(wxFrame,wxWindow) IMPLEMENT_DYNAMIC_CLASS(wxFrame,wxWindow)
@@ -360,3 +361,54 @@ wxString wxFrame::GetTitle(void) const
return (wxString&)m_title; return (wxString&)m_title;
}; };
void wxFrame::OnIdle(wxIdleEvent& WXUNUSED(event))
{
DoMenuUpdates();
}
// Query app for menu item updates (called from OnIdle)
void wxFrame::DoMenuUpdates(void)
{
wxMenuBar* bar = GetMenuBar();
if (!bar) return;
wxNode *node = bar->m_menus.First();
while (node)
{
wxMenu* menu = (wxMenu*)node->Data();
DoMenuUpdates(menu);
node = node->Next();
};
}
void wxFrame::DoMenuUpdates(wxMenu* menu)
{
wxNode* node = menu->m_items.First();
while (node)
{
wxMenuItem* item = (wxMenuItem*) node->Data();
if ( !item->IsSeparator() )
{
wxWindowID id = item->GetId();
wxUpdateUIEvent event(id);
event.SetEventObject( this );
if (GetEventHandler()->ProcessEvent(event))
{
if (event.GetSetText())
menu->SetLabel(id, event.GetText());
if (event.GetSetChecked())
menu->Check(id, event.GetChecked());
if (event.GetSetEnabled())
menu->Enable(id, event.GetEnabled());
}
if (item->GetSubMenu())
DoMenuUpdates(item->GetSubMenu());
}
node = node->Next();
}
}

View File

@@ -92,6 +92,8 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
gtk_container_add( GTK_CONTAINER(m_list), list_item ); gtk_container_add( GTK_CONTAINER(m_list), list_item );
m_clientData.Append( (wxObject*)NULL );
gtk_widget_show( list_item ); gtk_widget_show( list_item );
}; };
@@ -112,22 +114,44 @@ void wxListBox::Append( const wxString &item )
gtk_container_add( GTK_CONTAINER(m_list), list_item ); gtk_container_add( GTK_CONTAINER(m_list), list_item );
m_clientData.Append( (wxObject*)NULL );
gtk_widget_show( list_item ); gtk_widget_show( list_item );
}; };
void wxListBox::Append( const wxString &WXUNUSED(item), char *WXUNUSED(clientData) ) void wxListBox::Append( const wxString &item, char *clientData )
{ {
wxFAIL_MSG("wxListBox::Append(clientdata) not implemented"); GtkWidget *list_item;
list_item = gtk_list_item_new_with_label( item );
gtk_signal_connect( GTK_OBJECT(list_item), "select",
GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this );
gtk_container_add( GTK_CONTAINER(m_list), list_item );
m_clientData.Append( (wxObject*)clientData );
gtk_widget_show( list_item );
}; };
void wxListBox::Clear(void) void wxListBox::Clear(void)
{ {
gtk_list_clear_items( m_list, 0, Number() ); gtk_list_clear_items( m_list, 0, Number() );
m_clientData.Clear();
}; };
void wxListBox::Delete( int n ) void wxListBox::Delete( int n )
{ {
gtk_list_clear_items( m_list, n, n ); gtk_list_clear_items( m_list, n, n );
wxNode *node = m_clientData.Nth( n );
if (!node)
{
wxFAIL_MSG("wxListBox::Delete wrong index");
}
else
m_clientData.DeleteNode( node );
}; };
void wxListBox::Deselect( int n ) void wxListBox::Deselect( int n )
@@ -150,10 +174,10 @@ int wxListBox::FindString( const wxString &item ) const
return -1; return -1;
}; };
char *wxListBox::GetClientData( int WXUNUSED(n) ) const char *wxListBox::GetClientData( int n ) const
{ {
wxFAIL_MSG("wxListBox::GetClientData not implemented"); wxNode *node = m_clientData.Nth( n );
if (node) return ((char*)node->Data());
return NULL; return NULL;
}; };
@@ -250,8 +274,10 @@ void wxListBox::Set( int WXUNUSED(n), const wxString *WXUNUSED(choices) )
{ {
}; };
void wxListBox::SetClientData( int WXUNUSED(n), char *WXUNUSED(clientData) ) void wxListBox::SetClientData( int n, char *clientData )
{ {
wxNode *node = m_clientData.Nth( n );
if (node) node->SetData( (wxObject*)clientData );
}; };
void wxListBox::SetFirstItem( int WXUNUSED(n) ) void wxListBox::SetFirstItem( int WXUNUSED(n) )

View File

@@ -137,7 +137,7 @@ wxMenu::wxMenu( const wxString &title )
void wxMenu::AppendSeparator(void) void wxMenu::AppendSeparator(void)
{ {
wxMenuItem *mitem = new wxMenuItem(); wxMenuItem *mitem = new wxMenuItem();
mitem->m_id = -1; mitem->m_id = ID_SEPARATOR;
mitem->m_text = ""; mitem->m_text = "";
mitem->m_helpStr = ""; mitem->m_helpStr = "";
mitem->m_isCheckMenu = FALSE; mitem->m_isCheckMenu = FALSE;
@@ -219,6 +219,11 @@ int wxMenu::FindItem( const wxString itemString ) const
return -1; return -1;
}; };
void wxMenu::Check( int WXUNUSED(id), bool WXUNUSED(Flag) )
{
// I'm just too lazy
};
void wxMenu::Enable( int id, bool enable ) void wxMenu::Enable( int id, bool enable )
{ {
wxNode *node = m_items.First(); wxNode *node = m_items.First();

View File

@@ -33,6 +33,9 @@ END_EVENT_TABLE()
wxTextCtrl::wxTextCtrl(void) : streambuf() wxTextCtrl::wxTextCtrl(void) : streambuf()
{ {
if( allocate() )
setp(base(),ebuf());
m_modified = FALSE; m_modified = FALSE;
}; };
@@ -40,6 +43,9 @@ wxTextCtrl::wxTextCtrl( wxWindow *parent, wxWindowID id, const wxString &value,
const wxPoint &pos, const wxSize &size, const wxPoint &pos, const wxSize &size,
int style, const wxString &name ) : streambuf() int style, const wxString &name ) : streambuf()
{ {
if( allocate() )
setp(base(),ebuf());
m_modified = FALSE; m_modified = FALSE;
Create( parent, id, value, pos, size, style, name ); Create( parent, id, value, pos, size, style, name );
}; };
@@ -273,65 +279,6 @@ void wxTextCtrl::OnChar( wxKeyEvent &WXUNUSED(event) )
int wxTextCtrl::overflow(int c) int wxTextCtrl::overflow(int c)
{ {
// Make sure there is a holding area
if ( allocate()==EOF )
{
wxError("Streambuf allocation failed","Internal error");
return EOF;
}
// Verify that there are no characters in get area
if ( gptr() && gptr() < egptr() )
{
wxError("Who's trespassing my get area?","Internal error");
return EOF;
}
// Reset get area
setg(0,0,0);
// Make sure there is a put area
if ( ! pptr() )
{
/* This doesn't seem to be fatal so comment out error message */
// wxError("Put area not opened","Internal error");
setp( base(), base() );
}
// Determine how many characters have been inserted but no consumed
int plen = pptr() - pbase();
// Now Jerry relies on the fact that the buffer is at least 2 chars
// long, but the holding area "may be as small as 1" ???
// And we need an additional \0, so let's keep this inefficient but
// safe copy.
// If c!=EOF, it is a character that must also be comsumed
int xtra = c==EOF? 0 : 1;
// Write temporary C-string to wxTextWindow
{
char *txt = new char[plen+xtra+1];
memcpy(txt, pbase(), plen);
txt[plen] = (char)c; // append c
txt[plen+xtra] = '\0'; // append '\0' or overwrite c
// If the put area already contained \0, output will be truncated there
WriteText(txt);
delete[] txt;
}
// Reset put area
setp(pbase(), epptr());
#if defined(__WATCOMC__)
return __NOT_EOF;
#elif defined(zapeof) // HP-UX (all cfront based?)
return zapeof(c);
#else
return c!=EOF ? c : 0; // this should make everybody happy
#endif
/* OLD CODE
int len = pptr() - pbase(); int len = pptr() - pbase();
char *txt = new char[len+1]; char *txt = new char[len+1];
strncpy(txt, pbase(), len); strncpy(txt, pbase(), len);
@@ -340,22 +287,10 @@ int wxTextCtrl::overflow(int c)
setp(pbase(), epptr()); setp(pbase(), epptr());
delete[] txt; delete[] txt;
return EOF; return EOF;
*/
}; };
int wxTextCtrl::sync(void) int wxTextCtrl::sync(void)
{ {
// Verify that there are no characters in get area
if ( gptr() && gptr() < egptr() )
{
wxError("Who's trespassing my get area?","Internal error");
return EOF;
}
if ( pptr() && pptr() > pbase() ) return overflow(EOF);
return 0;
/* OLD CODE
int len = pptr() - pbase(); int len = pptr() - pbase();
char *txt = new char[len+1]; char *txt = new char[len+1];
strncpy(txt, pbase(), len); strncpy(txt, pbase(), len);
@@ -364,7 +299,6 @@ int wxTextCtrl::sync(void)
setp(pbase(), epptr()); setp(pbase(), epptr());
delete[] txt; delete[] txt;
return 0; return 0;
*/
}; };
int wxTextCtrl::underflow(void) int wxTextCtrl::underflow(void)