Added wxWakeUpIdle() to wxGTK,
Changed wxFindFile to detect hidden files (but not "." and ".." as before), Added "show hidden files" to file dialog, Added controls to wxToolBar, doc view now uses pretty file dialogs as per MSW. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4553 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -310,6 +310,11 @@ extern void WXDLLEXPORT wxExit();
|
||||
// Yield to other apps/messages
|
||||
extern bool WXDLLEXPORT wxYield();
|
||||
|
||||
#ifdef __WXGTK__
|
||||
// Yield to other apps/messages
|
||||
extern void WXDLLEXPORT wxWakeUpIdle();
|
||||
#endif
|
||||
|
||||
// Post a message to the given eventhandler which will be processed during the
|
||||
// next event loop iteration
|
||||
inline void WXDLLEXPORT wxPostEvent(wxEvtHandler *dest, wxEvent& event)
|
||||
|
@@ -166,6 +166,7 @@ public:
|
||||
void OnNew( wxCommandEvent &event );
|
||||
void OnChoice( wxCommandEvent &event );
|
||||
void OnTextEnter( wxCommandEvent &event );
|
||||
void OnCheck( wxCommandEvent &event );
|
||||
|
||||
void HandleAction( const wxString &fn );
|
||||
|
||||
|
@@ -49,11 +49,11 @@ extern const wxChar *wxToolBarNameStr;
|
||||
class wxToolBar: public wxControl
|
||||
{
|
||||
public:
|
||||
wxToolBar(void);
|
||||
wxToolBar();
|
||||
wxToolBar( wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
||||
long style = 0, const wxString& name = wxToolBarNameStr );
|
||||
~wxToolBar(void);
|
||||
~wxToolBar();
|
||||
|
||||
bool Create( wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
||||
@@ -76,10 +76,16 @@ public:
|
||||
const wxBitmap& pushedBitmap = wxNullBitmap, bool toggle = FALSE,
|
||||
wxCoord xPos = -1, wxCoord yPos = -1, wxObject *clientData = (wxObject *)NULL,
|
||||
const wxString& helpString1 = "", const wxString& helpString2 = "");
|
||||
virtual void AddSeparator(void);
|
||||
virtual void ClearTools(void);
|
||||
|
||||
virtual bool Realize(void);
|
||||
// Add arbitrary control
|
||||
virtual bool AddControl(wxControl *control);
|
||||
|
||||
// Add space
|
||||
virtual void AddSeparator();
|
||||
|
||||
virtual void ClearTools();
|
||||
|
||||
virtual bool Realize();
|
||||
|
||||
virtual void EnableTool(int toolIndex, bool enable);
|
||||
virtual void ToggleTool(int toolIndex, bool toggle); // toggle is TRUE if toggled on
|
||||
|
@@ -49,11 +49,11 @@ extern const wxChar *wxToolBarNameStr;
|
||||
class wxToolBar: public wxControl
|
||||
{
|
||||
public:
|
||||
wxToolBar(void);
|
||||
wxToolBar();
|
||||
wxToolBar( wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
||||
long style = 0, const wxString& name = wxToolBarNameStr );
|
||||
~wxToolBar(void);
|
||||
~wxToolBar();
|
||||
|
||||
bool Create( wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
|
||||
@@ -76,10 +76,16 @@ public:
|
||||
const wxBitmap& pushedBitmap = wxNullBitmap, bool toggle = FALSE,
|
||||
wxCoord xPos = -1, wxCoord yPos = -1, wxObject *clientData = (wxObject *)NULL,
|
||||
const wxString& helpString1 = "", const wxString& helpString2 = "");
|
||||
virtual void AddSeparator(void);
|
||||
virtual void ClearTools(void);
|
||||
|
||||
virtual bool Realize(void);
|
||||
// Add arbitrary control
|
||||
virtual bool AddControl(wxControl *control);
|
||||
|
||||
// Add space
|
||||
virtual void AddSeparator();
|
||||
|
||||
virtual void ClearTools();
|
||||
|
||||
virtual bool Realize();
|
||||
|
||||
virtual void EnableTool(int toolIndex, bool enable);
|
||||
virtual void ToggleTool(int toolIndex, bool toggle); // toggle is TRUE if toggled on
|
||||
|
@@ -224,6 +224,8 @@ bool MyApp::InitToolbar(wxToolBar* toolBar, bool smallicons)
|
||||
combo->Append("toolbar");
|
||||
toolBar->AddControl(combo);
|
||||
|
||||
toolBar->AddSeparator();
|
||||
|
||||
if ( !smallicons )
|
||||
{
|
||||
currentX += width + 5;
|
||||
@@ -238,11 +240,6 @@ bool MyApp::InitToolbar(wxToolBar* toolBar, bool smallicons)
|
||||
currentX += width + 5;
|
||||
toolBar->AddSeparator();
|
||||
toolBar->AddTool(wxID_HELP, *(toolBarBitmaps[7]), wxNullBitmap, TRUE, currentX, -1, (wxObject *) NULL, "Help button");
|
||||
|
||||
toolBar->ToggleTool( wxID_SAVE, TRUE );
|
||||
toolBar->ToggleTool( wxID_COPY, TRUE );
|
||||
toolBar->ToggleTool( wxID_COPY, FALSE );
|
||||
toolBar->EnableTool( wxID_PRINT, FALSE );
|
||||
}
|
||||
|
||||
toolBar->Realize();
|
||||
@@ -303,7 +300,7 @@ MyFrame::MyFrame(wxFrame* parent,
|
||||
wxTB_FLAT | wxTB_DOCKABLE,
|
||||
ID_TOOLBAR);
|
||||
|
||||
tbar->SetMargins( 2, 2 );
|
||||
tbar->SetMargins( 4, 4 );
|
||||
|
||||
wxGetApp().InitToolbar(tbar);
|
||||
}
|
||||
|
@@ -1191,7 +1191,7 @@ wxDocTemplate *wxDocManager::FindTemplateForPath(const wxString& path)
|
||||
// template extension.
|
||||
|
||||
wxDocTemplate *wxDocManager::SelectDocumentPath(wxDocTemplate **templates,
|
||||
#ifdef __WXMSW__
|
||||
#if defined(__WXMSW__) || defined(__WXGTK__)
|
||||
int noTemplates,
|
||||
#else
|
||||
int WXUNUSED(noTemplates),
|
||||
@@ -1200,8 +1200,8 @@ wxDocTemplate *wxDocManager::SelectDocumentPath(wxDocTemplate **templates,
|
||||
long WXUNUSED(flags),
|
||||
bool WXUNUSED(save))
|
||||
{
|
||||
// We can only have multiple filters in Windows
|
||||
#ifdef __WXMSW__
|
||||
// We can only have multiple filters in Windows and GTK
|
||||
#if defined(__WXMSW__) || defined(__WXGTK__)
|
||||
wxString descrBuf;
|
||||
|
||||
int i;
|
||||
|
@@ -611,10 +611,7 @@ void wxEvtHandler::AddPendingEvent(wxEvent& event)
|
||||
|
||||
// TODO: Wake up idle handler for the other platforms.
|
||||
#ifdef __WXGTK__
|
||||
extern bool g_isIdle;
|
||||
extern void wxapp_install_idle_handler();
|
||||
if ( g_isIdle )
|
||||
wxapp_install_idle_handler();
|
||||
wxWakeUpIdle();
|
||||
#elif wxUSE_GUI // this works for wxMSW, but may be for others too?
|
||||
// might also send a dummy message to the top level window, this would
|
||||
// probably be cleaner?
|
||||
|
@@ -1304,7 +1304,9 @@ wxString wxFindNextFile()
|
||||
nextDir != NULL;
|
||||
nextDir = readdir(gs_dirStream) )
|
||||
{
|
||||
if (wxMatchWild(name, nextDir->d_name))
|
||||
if (wxMatchWild(name, nextDir->d_name, FALSE) && // RR: added FALSE to find hidden files
|
||||
strcmp(nextDir->d_name, ".") &&
|
||||
strcmp(nextDir->d_name, "..") )
|
||||
{
|
||||
result.Empty();
|
||||
if ( !path.IsEmpty() )
|
||||
|
@@ -543,6 +543,7 @@ void wxFileCtrl::OnListEndLabelEdit( wxListEvent &event )
|
||||
#define ID_TEXT wxID_FILEDLGG + 9
|
||||
#define ID_LIST_CTRL wxID_FILEDLGG + 10
|
||||
#define ID_ACTIVATED wxID_FILEDLGG + 11
|
||||
#define ID_CHECK wxID_FILEDLGG + 12
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxFileDialog,wxDialog)
|
||||
|
||||
@@ -557,6 +558,7 @@ BEGIN_EVENT_TABLE(wxFileDialog,wxDialog)
|
||||
EVT_LIST_ITEM_ACTIVATED(ID_LIST_CTRL, wxFileDialog::OnActivated)
|
||||
EVT_CHOICE(ID_CHOICE,wxFileDialog::OnChoice)
|
||||
EVT_TEXT_ENTER(ID_TEXT,wxFileDialog::OnTextEnter)
|
||||
EVT_CHECKBOX(ID_CHECK,wxFileDialog::OnCheck)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
wxFileDialog::wxFileDialog(wxWindow *parent,
|
||||
@@ -668,6 +670,9 @@ wxFileDialog::wxFileDialog(wxWindow *parent,
|
||||
wxBoxSizer *choicesizer = new wxBoxSizer( wxHORIZONTAL );
|
||||
m_choice = new wxChoice( this, ID_CHOICE );
|
||||
choicesizer->Add( m_choice, 1, wxCENTER|wxALL, 10 );
|
||||
m_check = new wxCheckBox( this, ID_CHECK, _("Show hidden files") );
|
||||
m_check->SetValue( FALSE );
|
||||
choicesizer->Add( m_check, 0, wxCENTER|wxALL, 10 );
|
||||
choicesizer->Add( new wxButton( this, wxID_CANCEL, _("Cancel") ), 0, wxCENTER | wxALL, 10 );
|
||||
mainsizer->Add( choicesizer, 0, wxEXPAND );
|
||||
|
||||
@@ -706,6 +711,11 @@ void wxFileDialog::OnChoice( wxCommandEvent &event )
|
||||
m_list->SetWild( *str );
|
||||
}
|
||||
|
||||
void wxFileDialog::OnCheck( wxCommandEvent &event )
|
||||
{
|
||||
m_list->ShowHidden( event.GetInt() );
|
||||
}
|
||||
|
||||
void wxFileDialog::OnActivated( wxListEvent &event )
|
||||
{
|
||||
HandleAction( event.m_item.m_text );
|
||||
|
@@ -124,8 +124,13 @@ unsigned char g_palette[64*3] =
|
||||
|
||||
extern void wxFlushResources();
|
||||
|
||||
/* forward declaration */
|
||||
gint wxapp_idle_callback( gpointer WXUNUSED(data) );
|
||||
void wxapp_install_idle_handler();
|
||||
static gint wxapp_wakeup_timerout_callback( gpointer WXUNUSED(data) );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// global functions
|
||||
// wxExit
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void wxExit()
|
||||
@@ -133,8 +138,9 @@ void wxExit()
|
||||
gtk_main_quit();
|
||||
}
|
||||
|
||||
/* forward declaration */
|
||||
gint wxapp_idle_callback( gpointer WXUNUSED(data) );
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxYield
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool wxYield()
|
||||
{
|
||||
@@ -165,6 +171,20 @@ bool wxYield()
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxWakeUpIdle
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void wxWakeUpIdle()
|
||||
{
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// local functions
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
gint wxapp_idle_callback( gpointer WXUNUSED(data) )
|
||||
{
|
||||
if (!wxTheApp) return TRUE;
|
||||
@@ -213,9 +233,6 @@ void wxapp_install_idle_handler()
|
||||
|
||||
#if wxUSE_THREADS
|
||||
|
||||
/* forward declaration */
|
||||
static gint wxapp_wakeup_timerout_callback( gpointer WXUNUSED(data) );
|
||||
|
||||
void wxapp_install_thread_wakeup()
|
||||
{
|
||||
if (wxTheApp->m_wakeUpTimerTag) return;
|
||||
|
@@ -43,7 +43,8 @@ extern bool g_blockEventsOnDrag;
|
||||
|
||||
static void gtk_bmpbutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxBitmapButton *button )
|
||||
{
|
||||
if (g_isIdle) wxapp_install_idle_handler();
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
|
||||
if (!button->m_hasVMT) return;
|
||||
if (g_blockEventsOnDrag) return;
|
||||
|
@@ -122,6 +122,15 @@ static gint gtk_toolbar_enter_callback( GtkWidget *WXUNUSED(widget),
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// InsertChild callback for wxToolBar
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static void wxInsertChildInToolBar( wxToolBar* WXUNUSED(parent), wxWindow* WXUNUSED(child) )
|
||||
{
|
||||
/* we don't do anything here but pray */
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxToolBar
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -155,6 +164,7 @@ bool wxToolBar::Create( wxWindow *parent, wxWindowID id,
|
||||
{
|
||||
m_needParent = TRUE;
|
||||
m_blockNextEvent = FALSE;
|
||||
m_insertCallback = (wxInsertChildFunction)wxInsertChildInToolBar;
|
||||
|
||||
if (!PreCreation( parent, pos, size ) ||
|
||||
!CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
|
||||
@@ -304,7 +314,7 @@ wxToolBarTool *wxToolBar::AddTool( int toolIndex, const wxBitmap& bitmap,
|
||||
|
||||
GtkWidget *item = gtk_toolbar_append_element
|
||||
(
|
||||
GTK_TOOLBAR(m_toolbar),
|
||||
m_toolbar,
|
||||
ctype,
|
||||
(GtkWidget *)NULL,
|
||||
(const char *)NULL,
|
||||
@@ -332,6 +342,29 @@ wxToolBarTool *wxToolBar::AddTool( int toolIndex, const wxBitmap& bitmap,
|
||||
return tool;
|
||||
}
|
||||
|
||||
bool wxToolBar::AddControl(wxControl *control)
|
||||
{
|
||||
wxCHECK_MSG( control, FALSE, wxT("toolbar: can't insert NULL control") );
|
||||
|
||||
wxCHECK_MSG( control->GetParent() == this, FALSE,
|
||||
wxT("control must have toolbar as parent") );
|
||||
|
||||
m_hasToolAlready = TRUE;
|
||||
|
||||
wxToolBarTool *tool = new wxToolBarTool(control);
|
||||
|
||||
gtk_toolbar_append_widget( m_toolbar, control->m_widget, (const char *) NULL, (const char *) NULL );
|
||||
|
||||
GtkRequisition req;
|
||||
(* GTK_WIDGET_CLASS( GTK_OBJECT(m_widget)->klass )->size_request ) (m_widget, &req );
|
||||
m_width = req.width;
|
||||
m_height = req.height;
|
||||
|
||||
m_tools.Append( tool );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxToolBar::AddSeparator()
|
||||
{
|
||||
gtk_toolbar_append_space( m_toolbar );
|
||||
@@ -635,12 +668,12 @@ void wxToolBar::OnInternalIdle()
|
||||
while (node)
|
||||
{
|
||||
wxToolBarTool *tool = (wxToolBarTool*)node->Data();
|
||||
if (!tool->m_item->window)
|
||||
break;
|
||||
node = node->Next();
|
||||
|
||||
if (!tool->m_item || !tool->m_item->window)
|
||||
continue;
|
||||
else
|
||||
gdk_window_set_cursor( tool->m_item->window, cursor.GetCursor() );
|
||||
|
||||
node = node->Next();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -124,8 +124,13 @@ unsigned char g_palette[64*3] =
|
||||
|
||||
extern void wxFlushResources();
|
||||
|
||||
/* forward declaration */
|
||||
gint wxapp_idle_callback( gpointer WXUNUSED(data) );
|
||||
void wxapp_install_idle_handler();
|
||||
static gint wxapp_wakeup_timerout_callback( gpointer WXUNUSED(data) );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// global functions
|
||||
// wxExit
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void wxExit()
|
||||
@@ -133,8 +138,9 @@ void wxExit()
|
||||
gtk_main_quit();
|
||||
}
|
||||
|
||||
/* forward declaration */
|
||||
gint wxapp_idle_callback( gpointer WXUNUSED(data) );
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxYield
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
bool wxYield()
|
||||
{
|
||||
@@ -165,6 +171,20 @@ bool wxYield()
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxWakeUpIdle
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void wxWakeUpIdle()
|
||||
{
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// local functions
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
gint wxapp_idle_callback( gpointer WXUNUSED(data) )
|
||||
{
|
||||
if (!wxTheApp) return TRUE;
|
||||
@@ -213,9 +233,6 @@ void wxapp_install_idle_handler()
|
||||
|
||||
#if wxUSE_THREADS
|
||||
|
||||
/* forward declaration */
|
||||
static gint wxapp_wakeup_timerout_callback( gpointer WXUNUSED(data) );
|
||||
|
||||
void wxapp_install_thread_wakeup()
|
||||
{
|
||||
if (wxTheApp->m_wakeUpTimerTag) return;
|
||||
|
@@ -43,7 +43,8 @@ extern bool g_blockEventsOnDrag;
|
||||
|
||||
static void gtk_bmpbutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxBitmapButton *button )
|
||||
{
|
||||
if (g_isIdle) wxapp_install_idle_handler();
|
||||
if (g_isIdle)
|
||||
wxapp_install_idle_handler();
|
||||
|
||||
if (!button->m_hasVMT) return;
|
||||
if (g_blockEventsOnDrag) return;
|
||||
|
@@ -122,6 +122,15 @@ static gint gtk_toolbar_enter_callback( GtkWidget *WXUNUSED(widget),
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// InsertChild callback for wxToolBar
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
static void wxInsertChildInToolBar( wxToolBar* WXUNUSED(parent), wxWindow* WXUNUSED(child) )
|
||||
{
|
||||
/* we don't do anything here but pray */
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxToolBar
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -155,6 +164,7 @@ bool wxToolBar::Create( wxWindow *parent, wxWindowID id,
|
||||
{
|
||||
m_needParent = TRUE;
|
||||
m_blockNextEvent = FALSE;
|
||||
m_insertCallback = (wxInsertChildFunction)wxInsertChildInToolBar;
|
||||
|
||||
if (!PreCreation( parent, pos, size ) ||
|
||||
!CreateBase( parent, id, pos, size, style, wxDefaultValidator, name ))
|
||||
@@ -304,7 +314,7 @@ wxToolBarTool *wxToolBar::AddTool( int toolIndex, const wxBitmap& bitmap,
|
||||
|
||||
GtkWidget *item = gtk_toolbar_append_element
|
||||
(
|
||||
GTK_TOOLBAR(m_toolbar),
|
||||
m_toolbar,
|
||||
ctype,
|
||||
(GtkWidget *)NULL,
|
||||
(const char *)NULL,
|
||||
@@ -332,6 +342,29 @@ wxToolBarTool *wxToolBar::AddTool( int toolIndex, const wxBitmap& bitmap,
|
||||
return tool;
|
||||
}
|
||||
|
||||
bool wxToolBar::AddControl(wxControl *control)
|
||||
{
|
||||
wxCHECK_MSG( control, FALSE, wxT("toolbar: can't insert NULL control") );
|
||||
|
||||
wxCHECK_MSG( control->GetParent() == this, FALSE,
|
||||
wxT("control must have toolbar as parent") );
|
||||
|
||||
m_hasToolAlready = TRUE;
|
||||
|
||||
wxToolBarTool *tool = new wxToolBarTool(control);
|
||||
|
||||
gtk_toolbar_append_widget( m_toolbar, control->m_widget, (const char *) NULL, (const char *) NULL );
|
||||
|
||||
GtkRequisition req;
|
||||
(* GTK_WIDGET_CLASS( GTK_OBJECT(m_widget)->klass )->size_request ) (m_widget, &req );
|
||||
m_width = req.width;
|
||||
m_height = req.height;
|
||||
|
||||
m_tools.Append( tool );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxToolBar::AddSeparator()
|
||||
{
|
||||
gtk_toolbar_append_space( m_toolbar );
|
||||
@@ -635,12 +668,12 @@ void wxToolBar::OnInternalIdle()
|
||||
while (node)
|
||||
{
|
||||
wxToolBarTool *tool = (wxToolBarTool*)node->Data();
|
||||
if (!tool->m_item->window)
|
||||
break;
|
||||
node = node->Next();
|
||||
|
||||
if (!tool->m_item || !tool->m_item->window)
|
||||
continue;
|
||||
else
|
||||
gdk_window_set_cursor( tool->m_item->window, cursor.GetCursor() );
|
||||
|
||||
node = node->Next();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user