controls sample tests a bit more
combox doesn't send start-up event spinbutton looks correct now slider had vertic/horiz flags mixed up threads use gdk_enter_gui() dnd works a bit more often git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2304 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
b9a535f540
commit
19da43267e
@ -697,9 +697,12 @@ void MyPanel::OnPageChanged( wxNotebookEvent &event )
|
||||
|
||||
void MyPanel::OnListBox( wxCommandEvent &event )
|
||||
{
|
||||
m_text->AppendText( "ListBox selection string is: " );
|
||||
m_text->AppendText( "ListBox event selection string is: " );
|
||||
m_text->AppendText( event.GetString() );
|
||||
m_text->AppendText( "\n" );
|
||||
m_text->AppendText( "ListBox control selection string is: " );
|
||||
m_text->AppendText( m_listbox->GetStringSelection() );
|
||||
m_text->AppendText( "\n" );
|
||||
}
|
||||
|
||||
void MyPanel::OnListBoxDoubleClick( wxCommandEvent &event )
|
||||
@ -763,9 +766,12 @@ void MyPanel::OnListBoxButtons( wxCommandEvent &event )
|
||||
|
||||
void MyPanel::OnChoice( wxCommandEvent &event )
|
||||
{
|
||||
m_text->AppendText( "Choice selection string is: " );
|
||||
m_text->AppendText( "Choice event selection string is: " );
|
||||
m_text->AppendText( event.GetString() );
|
||||
m_text->AppendText( "\n" );
|
||||
m_text->AppendText( "Choice control selection string is: " );
|
||||
m_text->AppendText( m_choice->GetStringSelection() );
|
||||
m_text->AppendText( "\n" );
|
||||
}
|
||||
|
||||
void MyPanel::OnChoiceButtons( wxCommandEvent &event )
|
||||
@ -813,9 +819,12 @@ void MyPanel::OnChoiceButtons( wxCommandEvent &event )
|
||||
|
||||
void MyPanel::OnCombo( wxCommandEvent &event )
|
||||
{
|
||||
m_text->AppendText( "ComboBox selection string is: " );
|
||||
m_text->AppendText( "ComboBox event selection string is: " );
|
||||
m_text->AppendText( event.GetString() );
|
||||
m_text->AppendText( "\n" );
|
||||
m_text->AppendText( "ComboBox control selection string is: " );
|
||||
m_text->AppendText( m_combo->GetStringSelection() );
|
||||
m_text->AppendText( "\n" );
|
||||
}
|
||||
|
||||
void MyPanel::OnComboButtons( wxCommandEvent &event )
|
||||
|
@ -117,6 +117,10 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
/* don't send first event, which GTK sends aways when
|
||||
inserting the first item */
|
||||
m_alreadySent = TRUE;
|
||||
|
||||
GtkWidget *list_item = gtk_list_item_new_with_label( choices[i].mbc_str() );
|
||||
|
||||
m_clientDataList.Append( (wxObject*)NULL );
|
||||
@ -124,10 +128,10 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
|
||||
|
||||
gtk_container_add( GTK_CONTAINER(list), list_item );
|
||||
|
||||
gtk_widget_show( list_item );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(list_item), "select",
|
||||
GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this );
|
||||
GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this );
|
||||
|
||||
gtk_widget_show( list_item );
|
||||
}
|
||||
|
||||
m_parent->AddChild( this );
|
||||
|
@ -613,7 +613,7 @@ source_drag_data_get (GtkWidget *WXUNUSED(widget),
|
||||
|
||||
gtk_selection_data_set( selection_data,
|
||||
selection_data->target,
|
||||
8, /* 8-bit */
|
||||
8, // 8-bit
|
||||
buffer,
|
||||
data_size );
|
||||
|
||||
@ -776,8 +776,11 @@ wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
|
||||
|
||||
m_waiting = TRUE;
|
||||
|
||||
GdkAtom atom = gdk_atom_intern( "STRING", FALSE );
|
||||
// wxPrintf( _T("atom id: %d.\n"), (int)atom );
|
||||
|
||||
GtkTargetList *target_list = gtk_target_list_new( (GtkTargetEntry*) NULL, 0 );
|
||||
gtk_target_list_add( target_list, gdk_atom_intern( "STRING", FALSE ), 0, 0 );
|
||||
gtk_target_list_add( target_list, atom, 0, 0 );
|
||||
|
||||
GdkEventMotion event;
|
||||
event.window = m_widget->window;
|
||||
@ -788,6 +791,7 @@ wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
|
||||
event.x = x;
|
||||
event.y = y;
|
||||
event.state = state;
|
||||
event.time = GDK_CURRENT_TIME;
|
||||
|
||||
/* GTK wants to know which button was pressed which caused the dragging */
|
||||
int button_number = 0;
|
||||
@ -816,7 +820,7 @@ wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
|
||||
0,
|
||||
0 );
|
||||
|
||||
while (m_waiting) wxYield();
|
||||
while (m_waiting) gtk_main_iteration();;
|
||||
}
|
||||
|
||||
g_blockEventsOnDrag = FALSE;
|
||||
|
@ -102,15 +102,15 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
|
||||
m_oldPos = 0.0;
|
||||
|
||||
if (style & wxSL_VERTICAL)
|
||||
m_widget = gtk_hscale_new( (GtkAdjustment *) NULL );
|
||||
else
|
||||
m_widget = gtk_vscale_new( (GtkAdjustment *) NULL );
|
||||
else
|
||||
m_widget = gtk_hscale_new( (GtkAdjustment *) NULL );
|
||||
|
||||
if (style & wxSL_LABELS)
|
||||
gtk_scale_set_draw_value( GTK_SCALE( m_widget ), TRUE );
|
||||
else
|
||||
gtk_scale_set_draw_value( GTK_SCALE( m_widget ), FALSE );
|
||||
|
||||
|
||||
m_adjust = gtk_range_get_adjustment( GTK_RANGE(m_widget) );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(m_adjust),
|
||||
|
@ -90,7 +90,7 @@ bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, c
|
||||
m_needParent = TRUE;
|
||||
|
||||
wxSize new_size = size;
|
||||
new_size.x = 16;
|
||||
new_size.x = 15;
|
||||
if (new_size.y == -1)
|
||||
new_size.y = 30;
|
||||
|
||||
@ -185,7 +185,7 @@ void wxSpinButton::OnSize( wxSizeEvent &WXUNUSED(event) )
|
||||
{
|
||||
wxCHECK_RET( (m_widget != NULL), _T("invalid spin button") );
|
||||
|
||||
m_width = 16;
|
||||
m_width = 15;
|
||||
gtk_widget_set_usize( m_widget, m_width, m_height );
|
||||
}
|
||||
|
||||
|
@ -195,7 +195,7 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value,
|
||||
|
||||
if (multi_line)
|
||||
{
|
||||
gtk_widget_realize(m_text);
|
||||
// gtk_widget_realize(m_text);
|
||||
gtk_widget_show(m_text);
|
||||
}
|
||||
|
||||
|
@ -2051,7 +2051,17 @@ void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags )
|
||||
gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x, m_y );
|
||||
|
||||
if ((old_width != m_width) || (old_height != m_height))
|
||||
gtk_widget_set_usize( m_widget, m_width, m_height );
|
||||
{
|
||||
/*
|
||||
GtkAllocation alloc;
|
||||
alloc.x = m_x;
|
||||
alloc.y = m_y;
|
||||
alloc.width = m_width;
|
||||
alloc.height = m_height;
|
||||
gtk_widget_size_allocate( m_widget, &alloc );
|
||||
*/
|
||||
gtk_widget_set_usize( m_widget, m_width, m_height );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -117,6 +117,10 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
/* don't send first event, which GTK sends aways when
|
||||
inserting the first item */
|
||||
m_alreadySent = TRUE;
|
||||
|
||||
GtkWidget *list_item = gtk_list_item_new_with_label( choices[i].mbc_str() );
|
||||
|
||||
m_clientDataList.Append( (wxObject*)NULL );
|
||||
@ -124,10 +128,10 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
|
||||
|
||||
gtk_container_add( GTK_CONTAINER(list), list_item );
|
||||
|
||||
gtk_widget_show( list_item );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(list_item), "select",
|
||||
GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this );
|
||||
GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this );
|
||||
|
||||
gtk_widget_show( list_item );
|
||||
}
|
||||
|
||||
m_parent->AddChild( this );
|
||||
|
@ -613,7 +613,7 @@ source_drag_data_get (GtkWidget *WXUNUSED(widget),
|
||||
|
||||
gtk_selection_data_set( selection_data,
|
||||
selection_data->target,
|
||||
8, /* 8-bit */
|
||||
8, // 8-bit
|
||||
buffer,
|
||||
data_size );
|
||||
|
||||
@ -776,8 +776,11 @@ wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
|
||||
|
||||
m_waiting = TRUE;
|
||||
|
||||
GdkAtom atom = gdk_atom_intern( "STRING", FALSE );
|
||||
// wxPrintf( _T("atom id: %d.\n"), (int)atom );
|
||||
|
||||
GtkTargetList *target_list = gtk_target_list_new( (GtkTargetEntry*) NULL, 0 );
|
||||
gtk_target_list_add( target_list, gdk_atom_intern( "STRING", FALSE ), 0, 0 );
|
||||
gtk_target_list_add( target_list, atom, 0, 0 );
|
||||
|
||||
GdkEventMotion event;
|
||||
event.window = m_widget->window;
|
||||
@ -788,6 +791,7 @@ wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
|
||||
event.x = x;
|
||||
event.y = y;
|
||||
event.state = state;
|
||||
event.time = GDK_CURRENT_TIME;
|
||||
|
||||
/* GTK wants to know which button was pressed which caused the dragging */
|
||||
int button_number = 0;
|
||||
@ -816,7 +820,7 @@ wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
|
||||
0,
|
||||
0 );
|
||||
|
||||
while (m_waiting) wxYield();
|
||||
while (m_waiting) gtk_main_iteration();;
|
||||
}
|
||||
|
||||
g_blockEventsOnDrag = FALSE;
|
||||
|
@ -102,15 +102,15 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
|
||||
m_oldPos = 0.0;
|
||||
|
||||
if (style & wxSL_VERTICAL)
|
||||
m_widget = gtk_hscale_new( (GtkAdjustment *) NULL );
|
||||
else
|
||||
m_widget = gtk_vscale_new( (GtkAdjustment *) NULL );
|
||||
else
|
||||
m_widget = gtk_hscale_new( (GtkAdjustment *) NULL );
|
||||
|
||||
if (style & wxSL_LABELS)
|
||||
gtk_scale_set_draw_value( GTK_SCALE( m_widget ), TRUE );
|
||||
else
|
||||
gtk_scale_set_draw_value( GTK_SCALE( m_widget ), FALSE );
|
||||
|
||||
|
||||
m_adjust = gtk_range_get_adjustment( GTK_RANGE(m_widget) );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(m_adjust),
|
||||
|
@ -90,7 +90,7 @@ bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, c
|
||||
m_needParent = TRUE;
|
||||
|
||||
wxSize new_size = size;
|
||||
new_size.x = 16;
|
||||
new_size.x = 15;
|
||||
if (new_size.y == -1)
|
||||
new_size.y = 30;
|
||||
|
||||
@ -185,7 +185,7 @@ void wxSpinButton::OnSize( wxSizeEvent &WXUNUSED(event) )
|
||||
{
|
||||
wxCHECK_RET( (m_widget != NULL), _T("invalid spin button") );
|
||||
|
||||
m_width = 16;
|
||||
m_width = 15;
|
||||
gtk_widget_set_usize( m_widget, m_width, m_height );
|
||||
}
|
||||
|
||||
|
@ -195,7 +195,7 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value,
|
||||
|
||||
if (multi_line)
|
||||
{
|
||||
gtk_widget_realize(m_text);
|
||||
// gtk_widget_realize(m_text);
|
||||
gtk_widget_show(m_text);
|
||||
}
|
||||
|
||||
|
@ -2051,7 +2051,17 @@ void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags )
|
||||
gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x, m_y );
|
||||
|
||||
if ((old_width != m_width) || (old_height != m_height))
|
||||
gtk_widget_set_usize( m_widget, m_width, m_height );
|
||||
{
|
||||
/*
|
||||
GtkAllocation alloc;
|
||||
alloc.x = m_x;
|
||||
alloc.y = m_y;
|
||||
alloc.width = m_width;
|
||||
alloc.height = m_height;
|
||||
gtk_widget_size_allocate( m_widget, &alloc );
|
||||
*/
|
||||
gtk_widget_set_usize( m_widget, m_width, m_height );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,10 @@
|
||||
#include <sched.h>
|
||||
#endif
|
||||
|
||||
#ifdef __WXGTK12__
|
||||
#include "gtk/gtk.h"
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// constants
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -81,8 +85,10 @@ static pthread_t gs_tidMain;
|
||||
// the key for the pointer to the associated wxThread object
|
||||
static pthread_key_t gs_keySelf;
|
||||
|
||||
#ifndef __WXGTK12__
|
||||
// this mutex must be acquired before any call to a GUI function
|
||||
static wxMutex *gs_mutexGui;
|
||||
#endif
|
||||
|
||||
// ============================================================================
|
||||
// implementation
|
||||
@ -765,12 +771,15 @@ bool wxThreadModule::OnInit()
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#ifndef __WXGTK12__
|
||||
gs_mutexGui = new wxMutex();
|
||||
|
||||
//wxThreadGuiInit();
|
||||
#endif
|
||||
|
||||
gs_tidMain = pthread_self();
|
||||
|
||||
#ifndef __WXGTK12__
|
||||
gs_mutexGui->Lock();
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -789,12 +798,12 @@ void wxThreadModule::OnExit()
|
||||
gs_allThreads[n]->Delete();
|
||||
}
|
||||
|
||||
#ifndef __WXGTK12__
|
||||
// destroy GUI mutex
|
||||
gs_mutexGui->Unlock();
|
||||
|
||||
//wxThreadGuiExit();
|
||||
|
||||
delete gs_mutexGui;
|
||||
#endif
|
||||
|
||||
// and free TLD slot
|
||||
(void)pthread_key_delete(gs_keySelf);
|
||||
@ -806,12 +815,20 @@ void wxThreadModule::OnExit()
|
||||
|
||||
void wxMutexGuiEnter()
|
||||
{
|
||||
#ifdef __WXGTK12__
|
||||
gdk_threads_enter();
|
||||
#else
|
||||
gs_mutexGui->Lock();
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxMutexGuiLeave()
|
||||
{
|
||||
#ifdef __WXGTK12__
|
||||
gdk_threads_leave();
|
||||
#else
|
||||
gs_mutexGui->Unlock();
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user