From 66bd6b93005b803910caca469110495ce549599f Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Sun, 2 Aug 1998 20:38:05 +0000 Subject: [PATCH] Fixed Fontdialog Fixed frame positions/centering Fixed inserting mdi windows Changed control callbacks git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@410 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/generic/fontdlgg.h | 1 + samples/dialogs/dialogs.cpp | 2 +- samples/dnd/dnd.cpp | 38 +++++++++++++++------------------- samples/forty/playerdg.cpp | 2 +- src/common/gdicmn.cpp | 7 ++++--- src/generic/fontdlgg.cpp | 12 +++++++---- src/gtk/bmpbuttn.cpp | 11 +++++++++- src/gtk/button.cpp | 11 +++++++++- src/gtk/checkbox.cpp | 11 +++++++++- src/gtk/choice.cpp | 11 +++++++++- src/gtk/combobox.cpp | 9 +++++--- src/gtk/filedlg.cpp | 4 ++++ src/gtk/listbox.cpp | 15 +++++++++++--- src/gtk/radiobox.cpp | 11 +++++++++- src/gtk/scrolbar.cpp | 16 +++++++------- src/gtk/slider.cpp | 16 +++++++------- src/gtk/window.cpp | 39 +++++++++++++++++++++-------------- src/gtk1/bmpbuttn.cpp | 11 +++++++++- src/gtk1/button.cpp | 11 +++++++++- src/gtk1/checkbox.cpp | 11 +++++++++- src/gtk1/choice.cpp | 11 +++++++++- src/gtk1/combobox.cpp | 9 +++++--- src/gtk1/filedlg.cpp | 4 ++++ src/gtk1/listbox.cpp | 15 +++++++++++--- src/gtk1/radiobox.cpp | 11 +++++++++- src/gtk1/scrolbar.cpp | 16 +++++++------- src/gtk1/slider.cpp | 16 +++++++------- src/gtk1/window.cpp | 39 +++++++++++++++++++++-------------- 28 files changed, 254 insertions(+), 116 deletions(-) diff --git a/include/wx/generic/fontdlgg.h b/include/wx/generic/fontdlgg.h index 8afda5b745..bd997e45e3 100644 --- a/include/wx/generic/fontdlgg.h +++ b/include/wx/generic/fontdlgg.h @@ -54,6 +54,7 @@ class WXDLLEXPORT wxGenericFontDialog: public wxDialog wxChoice *colourChoice; wxCheckBox *underLineCheckBox; wxChoice *pointSizeChoice; + bool m_useEvents; // static bool fontDialogCancelled; public: diff --git a/samples/dialogs/dialogs.cpp b/samples/dialogs/dialogs.cpp index 0d8fd9a363..7a501ba5ef 100644 --- a/samples/dialogs/dialogs.cpp +++ b/samples/dialogs/dialogs.cpp @@ -50,7 +50,7 @@ IMPLEMENT_WXWIN_MAIN bool MyApp::OnInit(void) { m_canvasTextColour = wxColour("BLACK"); - m_canvasFont = *wxSWISS_FONT; + m_canvasFont = *wxNORMAL_FONT; // Create the main frame window MyFrame *frame = new MyFrame(NULL, "wxWindows dialogs example", wxPoint(50, 50), wxSize(400, 300)); diff --git a/samples/dnd/dnd.cpp b/samples/dnd/dnd.cpp index 53f2c43f12..68e299b830 100644 --- a/samples/dnd/dnd.cpp +++ b/samples/dnd/dnd.cpp @@ -258,27 +258,23 @@ void DnDFrame::OnAbout(wxCommandEvent& /* event */) void DnDFrame::OnHelp(wxCommandEvent& /* event */) { wxMessageDialog dialog(this, -"This small program demonstrates drag & drop support in wxWindows. " -"The program window consists of 3 parts: the bottom pane is for " -"debug messages, so that you can see what's going on inside. " -"The top part is split into 2 listboxes, the left one accepts " -"files and the right one accepts text." -"\n\n" -"To test wxDropTarget: open wordpad (write.exe), select some text in " -"it and drag it to the right listbox (you'll notice the usual visual " -"feedback, i.e. the cursor will change). Also, try dragging some " -"files (you can select several at once) from Windows Explorer (or " -"File Manager) to the left pane. Hold down Ctrl/Shift keys when " -"you drop text (doesn't work with files) and see what changes. " -"\n\n" -"To test wxDropSource: just press any mouse button on the empty zone of " -"the window and drag it to wordpad or any other droptarget accepting " -"text (and of course you can just drag it to the right pane). Due to " -"a lot of trace messages, the cursor might take some time to change, " -"don't release the mouse button until it does. You can change the " -"string being dragged in in \"File|Test drag...\" dialog." -"\n\n" -"Please send all questions/bug reports/suggestions &c to " +"This small program demonstrates drag & drop support in wxWindows. The program window\n" +"consists of 3 parts: the bottom pane is for debug messages, so that you can see what's\n" +"going on inside. The top part is split into 2 listboxes, the left one accepts files\n" +"and the right one accepts text." +"\n" +"To test wxDropTarget: open wordpad (write.exe), select some text in it and drag it to\n" +"the right listbox (you'll notice the usual visual feedback, i.e. the cursor will change).\n" +"Also, try dragging some files (you can select several at once) from Windows Explorer (or \n" +"File Manager) to the left pane. Hold down Ctrl/Shift keys when you drop text (doesn't \n" +"work with files) and see what changes." +"\n" +"To test wxDropSource: just press any mouse button on the empty zone of the window and drag\n" +"it to wordpad or any other droptarget accepting text (and of course you can just drag it\n" +"to the right pane). Due to a lot of trace messages, the cursor might take some time to \n" +"change, don't release the mouse button until it does. You can change the string being\n" +"dragged in in \"File|Test drag...\" dialog.\n" +"Please send all questions/bug reports/suggestions &c to \n" "Vadim Zeitlin ", "wxDnD Help"); diff --git a/samples/forty/playerdg.cpp b/samples/forty/playerdg.cpp index d2949f4219..93852d3e8f 100644 --- a/samples/forty/playerdg.cpp +++ b/samples/forty/playerdg.cpp @@ -44,7 +44,7 @@ PlayerSelectionDialog::PlayerSelectionDialog( ScoreFile* file ) : wxDialog(parent, -1, "Player Selection", - wxDefaultPosition, wxSize(250, 200), + wxDefaultPosition, wxSize(320, 200), wxDIALOG_MODAL | wxDEFAULT_DIALOG_STYLE), m_scoreFile(file) { diff --git a/src/common/gdicmn.cpp b/src/common/gdicmn.cpp index a30a772c7a..913b36b7b9 100644 --- a/src/common/gdicmn.cpp +++ b/src/common/gdicmn.cpp @@ -146,7 +146,7 @@ void wxColourDatabase::Initialize () cdef cc; static cdef table[]={ -#ifdef __WXMSW__ +// #ifdef __WXMSW__ {"AQUAMARINE",112, 219, 147}, {"BLACK",0, 0, 0}, {"BLUE", 0, 0, 255}, @@ -218,7 +218,7 @@ void wxColourDatabase::Initialize () {"WHITE", 255, 255, 255}, {"YELLOW", 255, 255, 0}, {"YELLOW GREEN", 153, 204, 50}, -#endif +// #endif #if defined(__WXGTK__) || defined(__X__) {"MEDIUM GOLDENROD", 234, 234, 173}, @@ -303,10 +303,11 @@ wxString wxColourDatabase::FindName (const wxColour& colour) const unsigned char red = colour.Red (); unsigned char green = colour.Green (); unsigned char blue = colour.Blue (); - + for (wxNode * node = First (); node; node = node->Next ()) { wxColour *col = (wxColour *) node->Data (); + if (col->Red () == red && col->Green () == green && col->Blue () == blue) { char *found = node->key.string; diff --git a/src/generic/fontdlgg.cpp b/src/generic/fontdlgg.cpp index 5d0ea78fbd..f12689c768 100644 --- a/src/generic/fontdlgg.cpp +++ b/src/generic/fontdlgg.cpp @@ -116,12 +116,14 @@ static wxString wxColourDialogNames[NUM_COLS]={"ORANGE", wxGenericFontDialog::wxGenericFontDialog(void) { + m_useEvents = FALSE; dialogParent = NULL; } wxGenericFontDialog::wxGenericFontDialog(wxWindow *parent, wxFontData *data): wxDialog(parent, -1, "Font", wxPoint(0, 0), wxSize(600, 600), wxDEFAULT_DIALOG_STYLE|wxDIALOG_MODAL) { + m_useEvents = FALSE; Create(parent, data); } @@ -243,15 +245,14 @@ void wxGenericFontDialog::CreateWidgets(void) wxButton *okButton = new wxButton(this, wxID_OK, "OK", wxPoint(5, by)); (void) new wxButton(this, wxID_OK, "Cancel", wxPoint(50, by)); - familyChoice->SetStringSelection(wxFontFamilyIntToString(dialogFont.GetFamily())); + familyChoice->SetStringSelection( wxFontFamilyIntToString(dialogFont.GetFamily()) ); styleChoice->SetStringSelection(wxFontStyleIntToString(dialogFont.GetStyle())); weightChoice->SetStringSelection(wxFontWeightIntToString(dialogFont.GetWeight())); wxString name(wxTheColourDatabase->FindName(fontData.fontColour)); colourChoice->SetStringSelection(name); underLineCheckBox->SetValue(dialogFont.GetUnderlined()); - - pointSizeChoice->SetSelection(dialogFont.GetPointSize()); + pointSizeChoice->SetSelection(dialogFont.GetPointSize()-1); okButton->SetDefault(); @@ -260,6 +261,8 @@ void wxGenericFontDialog::CreateWidgets(void) Centre(wxBOTH); wxEndBusyCursor(); + + m_useEvents = TRUE; } void wxGenericFontDialog::InitializeFont(void) @@ -278,7 +281,6 @@ void wxGenericFontDialog::InitializeFont(void) fontUnderline = fontData.initialFont.GetUnderlined(); } dialogFont = wxFont(fontSize, fontFamily, fontStyle, fontWeight, (fontUnderline != 0)); - } void wxGenericFontDialog::PaintFontBackground(wxDC& dc) @@ -313,6 +315,8 @@ void wxGenericFontDialog::PaintFont(wxDC& dc) void wxGenericFontDialog::OnChangeFont(wxCommandEvent& WXUNUSED(event)) { + if (!m_useEvents) return; + int fontFamily = wxFontFamilyStringToInt(WXSTRINGCAST familyChoice->GetStringSelection()); int fontWeight = wxFontWeightStringToInt(WXSTRINGCAST weightChoice->GetStringSelection()); int fontStyle = wxFontStyleStringToInt(WXSTRINGCAST styleChoice->GetStringSelection()); diff --git a/src/gtk/bmpbuttn.cpp b/src/gtk/bmpbuttn.cpp index f1a0aa1a46..4e33f54278 100644 --- a/src/gtk/bmpbuttn.cpp +++ b/src/gtk/bmpbuttn.cpp @@ -20,14 +20,23 @@ class wxBitmapButton; +//----------------------------------------------------------------------------- +// data +//----------------------------------------------------------------------------- + +extern bool g_blockEventsOnDrag; + //----------------------------------------------------------------------------- // wxBitmapButton //----------------------------------------------------------------------------- IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton,wxControl) -void gtk_bmpbutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxBitmapButton *button ) +static void gtk_bmpbutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxBitmapButton *button ) { + if (!button->HasVMT()) return; + if (g_blockEventsOnDrag) return; + wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, button->GetId()); event.SetEventObject(button); button->GetEventHandler()->ProcessEvent(event); diff --git a/src/gtk/button.cpp b/src/gtk/button.cpp index 52c4e2d4b9..9e64e2579e 100644 --- a/src/gtk/button.cpp +++ b/src/gtk/button.cpp @@ -20,14 +20,23 @@ class wxButton; +//----------------------------------------------------------------------------- +// data +//----------------------------------------------------------------------------- + +extern bool g_blockEventsOnDrag; + //----------------------------------------------------------------------------- // wxButton //----------------------------------------------------------------------------- IMPLEMENT_DYNAMIC_CLASS(wxButton,wxControl) -void gtk_button_clicked_callback( GtkWidget *WXUNUSED(widget), wxButton *button ) +static void gtk_button_clicked_callback( GtkWidget *WXUNUSED(widget), wxButton *button ) { + if (!button->HasVMT()) return; + if (g_blockEventsOnDrag) return; + wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, button->GetId()); event.SetEventObject(button); button->GetEventHandler()->ProcessEvent(event); diff --git a/src/gtk/checkbox.cpp b/src/gtk/checkbox.cpp index b4c8a447ff..42c8b4167a 100644 --- a/src/gtk/checkbox.cpp +++ b/src/gtk/checkbox.cpp @@ -15,12 +15,21 @@ #include "wx/checkbox.h" +//----------------------------------------------------------------------------- +// data +//----------------------------------------------------------------------------- + +extern bool g_blockEventsOnDrag; + //----------------------------------------------------------------------------- // wxCheckBox //----------------------------------------------------------------------------- -void gtk_checkbox_clicked_callback( GtkWidget *WXUNUSED(widget), wxCheckBox *cb ) +static void gtk_checkbox_clicked_callback( GtkWidget *WXUNUSED(widget), wxCheckBox *cb ) { + if (!cb->HasVMT()) return; + if (g_blockEventsOnDrag) return; + wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, cb->GetId()); event.SetInt( cb->GetValue() ); event.SetEventObject(cb); diff --git a/src/gtk/choice.cpp b/src/gtk/choice.cpp index 180bbb17d3..ef374c13ad 100644 --- a/src/gtk/choice.cpp +++ b/src/gtk/choice.cpp @@ -15,12 +15,21 @@ #include "wx/choice.h" +//----------------------------------------------------------------------------- +// data +//----------------------------------------------------------------------------- + +extern bool g_blockEventsOnDrag; + //----------------------------------------------------------------------------- // wxChoice //----------------------------------------------------------------------------- -void gtk_choice_clicked_callback( GtkWidget *WXUNUSED(widget), wxChoice *choice ) +static void gtk_choice_clicked_callback( GtkWidget *WXUNUSED(widget), wxChoice *choice ) { + if (!choice->HasVMT()) return; + if (g_blockEventsOnDrag) return; + wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, choice->GetId() ); event.SetInt( choice->GetSelection() ); wxString tmp( choice->GetStringSelection() ); diff --git a/src/gtk/combobox.cpp b/src/gtk/combobox.cpp index 2e892f7e3a..1ac91ffdd4 100644 --- a/src/gtk/combobox.cpp +++ b/src/gtk/combobox.cpp @@ -29,6 +29,9 @@ extern bool g_blockEventsOnDrag; static void gtk_combo_clicked_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo ) { + if (!combo->HasVMT()) return; + if (g_blockEventsOnDrag) return; + if (combo->m_alreadySent) { combo->m_alreadySent = FALSE; @@ -90,14 +93,14 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value, GtkWidget *list_item; list_item = gtk_list_item_new_with_label( choices[i] ); - gtk_signal_connect( GTK_OBJECT(list_item), "select", - GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this ); - gtk_container_add( GTK_CONTAINER(list), list_item ); m_clientData.Append( (wxObject*)NULL ); gtk_widget_show( list_item ); + + gtk_signal_connect( GTK_OBJECT(list_item), "select", + GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this ); }; PostCreation(); diff --git a/src/gtk/filedlg.cpp b/src/gtk/filedlg.cpp index bc003c8185..b4d0ed1592 100644 --- a/src/gtk/filedlg.cpp +++ b/src/gtk/filedlg.cpp @@ -65,6 +65,10 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message, m_widget = gtk_file_selection_new( "File selection" ); + int x = (gdk_screen_width () - 400) / 2; + int y = (gdk_screen_height () - 400) / 2; + gtk_widget_set_uposition( m_widget, x, y ); + GtkFileSelection *sel = GTK_FILE_SELECTION(m_widget); m_path.Append(m_dir); diff --git a/src/gtk/listbox.cpp b/src/gtk/listbox.cpp index 359adda8d0..e4f05dc807 100644 --- a/src/gtk/listbox.cpp +++ b/src/gtk/listbox.cpp @@ -16,12 +16,21 @@ #include "wx/dynarray.h" #include "wx/listbox.h" +//----------------------------------------------------------------------------- +// data +//----------------------------------------------------------------------------- + +extern bool g_blockEventsOnDrag; + //----------------------------------------------------------------------------- // wxListBox //----------------------------------------------------------------------------- -void gtk_listitem_select_callback( GtkWidget *widget, wxListBox *listbox ) +static void gtk_listitem_select_callback( GtkWidget *widget, wxListBox *listbox ) { + if (!listbox->HasVMT()) return; + if (g_blockEventsOnDrag) return; + wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, listbox->GetId() ); event.SetInt( listbox->GetIndex( widget ) ); @@ -84,11 +93,11 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id, GtkWidget *list_item; list_item = gtk_list_item_new_with_label( choices[i] ); + gtk_container_add( GTK_CONTAINER(m_list), list_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*)NULL ); gtk_widget_show( list_item ); diff --git a/src/gtk/radiobox.cpp b/src/gtk/radiobox.cpp index f4efa3d603..9ff546a945 100644 --- a/src/gtk/radiobox.cpp +++ b/src/gtk/radiobox.cpp @@ -18,12 +18,21 @@ #include "wx/frame.h" #include "wx/gtk/win_gtk.h" +//----------------------------------------------------------------------------- +// data +//----------------------------------------------------------------------------- + +extern bool g_blockEventsOnDrag; + //----------------------------------------------------------------------------- // wxRadioBox //----------------------------------------------------------------------------- -void gtk_radiobutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxRadioBox *rb ) +static void gtk_radiobutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxRadioBox *rb ) { + if (!rb->HasVMT()) return; + if (g_blockEventsOnDrag) return; + if (rb->m_alreadySent) { rb->m_alreadySent = FALSE; diff --git a/src/gtk/scrolbar.cpp b/src/gtk/scrolbar.cpp index ac11b17d44..37396d9605 100644 --- a/src/gtk/scrolbar.cpp +++ b/src/gtk/scrolbar.cpp @@ -16,20 +16,20 @@ #include "wx/scrolbar.h" #include "wx/utils.h" +//----------------------------------------------------------------------------- +// data +//----------------------------------------------------------------------------- + +extern bool g_blockEventsOnDrag; + //----------------------------------------------------------------------------- // wxScrollBar //----------------------------------------------------------------------------- -void gtk_scrollbar_callback( GtkWidget *WXUNUSED(widget), wxScrollBar *win ) +static void gtk_scrollbar_callback( GtkWidget *WXUNUSED(widget), wxScrollBar *win ) { -/* - printf( "OnScroll from " ); - if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) - printf( win->GetClassInfo()->GetClassName() ); - printf( ".\n" ); -*/ - if (!win->HasVMT()) return; + if (g_blockEventsOnDrag) return; float diff = win->m_adjust->value - win->m_oldPos; if (fabs(diff) < 0.2) return; diff --git a/src/gtk/slider.cpp b/src/gtk/slider.cpp index d83eb9d7e3..fd8d17b8d6 100644 --- a/src/gtk/slider.cpp +++ b/src/gtk/slider.cpp @@ -16,20 +16,20 @@ #include "wx/slider.h" #include "wx/utils.h" +//----------------------------------------------------------------------------- +// data +//----------------------------------------------------------------------------- + +extern bool g_blockEventsOnDrag; + //----------------------------------------------------------------------------- // wxSlider //----------------------------------------------------------------------------- -void gtk_slider_callback( GtkWidget *WXUNUSED(widget), wxSlider *win ) +static void gtk_slider_callback( GtkWidget *WXUNUSED(widget), wxSlider *win ) { -/* - printf( "OnScroll from " ); - if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) - printf( win->GetClassInfo()->GetClassName() ); - printf( ".\n" ); -*/ - if (!win->HasVMT()) return; + if (g_blockEventsOnDrag) return; float diff = win->m_adjust->value - win->m_oldPos; if (fabs(diff) < 0.2) return; diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index c064c71faa..8cb3065191 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -256,7 +256,12 @@ gint gtk_window_key_press_callback( GtkWidget *WXUNUSED(widget), GdkEventKey *gd event.m_x = 0; event.m_y = 0; event.SetEventObject( win ); - return win->ProcessEvent( event ); + + bool ret = win->ProcessEvent( event ); +/* + if (ret) printf( "found.\n") ; +*/ + return ret; }; //----------------------------------------------------------------------------- @@ -627,6 +632,8 @@ void gtk_window_hscroll_change_callback( GtkWidget *WXUNUSED(widget), wxWindow * void gtk_window_drop_callback( GtkWidget *widget, GdkEvent *event, wxWindow *win ) { + if (!win->HasVMT()) return; + if (win->GetDropTarget()) { int x = 0; @@ -662,8 +669,8 @@ bool gtk_window_destroy_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSE bool gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win ) { if (widget->window != gdk_event->window) return TRUE; - - if (g_blockEventsOnDrag) return FALSE; + if (g_blockEventsOnDrag) return TRUE; + if (!win->HasVMT()) return TRUE; if (widget->window) gdk_window_set_cursor( widget->window, win->m_cursor->GetCursor() ); @@ -679,8 +686,8 @@ bool gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, bool gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win ) { if (widget->window != gdk_event->window) return TRUE; - - if (g_blockEventsOnDrag) return FALSE; + if (!win->HasVMT()) return TRUE; + if (g_blockEventsOnDrag) return TRUE; if (widget->window) gdk_window_set_cursor( widget->window, wxSTANDARD_CURSOR->GetCursor() ); @@ -804,6 +811,8 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id, m_wxwindow = gtk_myfixed_new(); + if (m_wxwindow) GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS ); + if (m_windowStyle & wxTAB_TRAVERSAL == wxTAB_TRAVERSAL) GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); else @@ -1059,18 +1068,16 @@ void wxWindow::ImplementSetSize(void) void wxWindow::ImplementSetPosition(void) { + if (IS_KIND_OF(this,wxFrame) || IS_KIND_OF(this,wxDialog)) + { + if ((m_x != -1) || (m_y != -1)) + gtk_widget_set_uposition( m_widget, m_x, m_y ); + return; + } + if (!m_parent) { - if (IsKindOf(CLASSINFO(wxFrame)) || - IsKindOf(CLASSINFO(wxDialog))) - { - if ((m_x != -1) || (m_y != -1)) - gtk_widget_set_uposition( m_widget, m_x, m_y ); - } - else - { - printf( "wxWindow::SetSize error.\n" ); - } + printf( "wxWindow::SetSize error.\n" ); return; } @@ -1325,7 +1332,7 @@ void wxWindow::ScreenToClient( int *x, int *y ) void wxWindow::Centre( int direction ) { - if (this->IsKindOf(CLASSINFO(wxDialog)) || this->IsKindOf(CLASSINFO(wxFrame))) + if (IS_KIND_OF(this,wxDialog) || IS_KIND_OF(this,wxFrame)) { if (direction & wxHORIZONTAL == wxHORIZONTAL) m_x = (gdk_screen_width () - m_width) / 2; if (direction & wxVERTICAL == wxVERTICAL) m_y = (gdk_screen_height () - m_height) / 2; diff --git a/src/gtk1/bmpbuttn.cpp b/src/gtk1/bmpbuttn.cpp index f1a0aa1a46..4e33f54278 100644 --- a/src/gtk1/bmpbuttn.cpp +++ b/src/gtk1/bmpbuttn.cpp @@ -20,14 +20,23 @@ class wxBitmapButton; +//----------------------------------------------------------------------------- +// data +//----------------------------------------------------------------------------- + +extern bool g_blockEventsOnDrag; + //----------------------------------------------------------------------------- // wxBitmapButton //----------------------------------------------------------------------------- IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton,wxControl) -void gtk_bmpbutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxBitmapButton *button ) +static void gtk_bmpbutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxBitmapButton *button ) { + if (!button->HasVMT()) return; + if (g_blockEventsOnDrag) return; + wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, button->GetId()); event.SetEventObject(button); button->GetEventHandler()->ProcessEvent(event); diff --git a/src/gtk1/button.cpp b/src/gtk1/button.cpp index 52c4e2d4b9..9e64e2579e 100644 --- a/src/gtk1/button.cpp +++ b/src/gtk1/button.cpp @@ -20,14 +20,23 @@ class wxButton; +//----------------------------------------------------------------------------- +// data +//----------------------------------------------------------------------------- + +extern bool g_blockEventsOnDrag; + //----------------------------------------------------------------------------- // wxButton //----------------------------------------------------------------------------- IMPLEMENT_DYNAMIC_CLASS(wxButton,wxControl) -void gtk_button_clicked_callback( GtkWidget *WXUNUSED(widget), wxButton *button ) +static void gtk_button_clicked_callback( GtkWidget *WXUNUSED(widget), wxButton *button ) { + if (!button->HasVMT()) return; + if (g_blockEventsOnDrag) return; + wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, button->GetId()); event.SetEventObject(button); button->GetEventHandler()->ProcessEvent(event); diff --git a/src/gtk1/checkbox.cpp b/src/gtk1/checkbox.cpp index b4c8a447ff..42c8b4167a 100644 --- a/src/gtk1/checkbox.cpp +++ b/src/gtk1/checkbox.cpp @@ -15,12 +15,21 @@ #include "wx/checkbox.h" +//----------------------------------------------------------------------------- +// data +//----------------------------------------------------------------------------- + +extern bool g_blockEventsOnDrag; + //----------------------------------------------------------------------------- // wxCheckBox //----------------------------------------------------------------------------- -void gtk_checkbox_clicked_callback( GtkWidget *WXUNUSED(widget), wxCheckBox *cb ) +static void gtk_checkbox_clicked_callback( GtkWidget *WXUNUSED(widget), wxCheckBox *cb ) { + if (!cb->HasVMT()) return; + if (g_blockEventsOnDrag) return; + wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, cb->GetId()); event.SetInt( cb->GetValue() ); event.SetEventObject(cb); diff --git a/src/gtk1/choice.cpp b/src/gtk1/choice.cpp index 180bbb17d3..ef374c13ad 100644 --- a/src/gtk1/choice.cpp +++ b/src/gtk1/choice.cpp @@ -15,12 +15,21 @@ #include "wx/choice.h" +//----------------------------------------------------------------------------- +// data +//----------------------------------------------------------------------------- + +extern bool g_blockEventsOnDrag; + //----------------------------------------------------------------------------- // wxChoice //----------------------------------------------------------------------------- -void gtk_choice_clicked_callback( GtkWidget *WXUNUSED(widget), wxChoice *choice ) +static void gtk_choice_clicked_callback( GtkWidget *WXUNUSED(widget), wxChoice *choice ) { + if (!choice->HasVMT()) return; + if (g_blockEventsOnDrag) return; + wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, choice->GetId() ); event.SetInt( choice->GetSelection() ); wxString tmp( choice->GetStringSelection() ); diff --git a/src/gtk1/combobox.cpp b/src/gtk1/combobox.cpp index 2e892f7e3a..1ac91ffdd4 100644 --- a/src/gtk1/combobox.cpp +++ b/src/gtk1/combobox.cpp @@ -29,6 +29,9 @@ extern bool g_blockEventsOnDrag; static void gtk_combo_clicked_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo ) { + if (!combo->HasVMT()) return; + if (g_blockEventsOnDrag) return; + if (combo->m_alreadySent) { combo->m_alreadySent = FALSE; @@ -90,14 +93,14 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id, const wxString& value, GtkWidget *list_item; list_item = gtk_list_item_new_with_label( choices[i] ); - gtk_signal_connect( GTK_OBJECT(list_item), "select", - GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this ); - gtk_container_add( GTK_CONTAINER(list), list_item ); m_clientData.Append( (wxObject*)NULL ); gtk_widget_show( list_item ); + + gtk_signal_connect( GTK_OBJECT(list_item), "select", + GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this ); }; PostCreation(); diff --git a/src/gtk1/filedlg.cpp b/src/gtk1/filedlg.cpp index bc003c8185..b4d0ed1592 100644 --- a/src/gtk1/filedlg.cpp +++ b/src/gtk1/filedlg.cpp @@ -65,6 +65,10 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message, m_widget = gtk_file_selection_new( "File selection" ); + int x = (gdk_screen_width () - 400) / 2; + int y = (gdk_screen_height () - 400) / 2; + gtk_widget_set_uposition( m_widget, x, y ); + GtkFileSelection *sel = GTK_FILE_SELECTION(m_widget); m_path.Append(m_dir); diff --git a/src/gtk1/listbox.cpp b/src/gtk1/listbox.cpp index 359adda8d0..e4f05dc807 100644 --- a/src/gtk1/listbox.cpp +++ b/src/gtk1/listbox.cpp @@ -16,12 +16,21 @@ #include "wx/dynarray.h" #include "wx/listbox.h" +//----------------------------------------------------------------------------- +// data +//----------------------------------------------------------------------------- + +extern bool g_blockEventsOnDrag; + //----------------------------------------------------------------------------- // wxListBox //----------------------------------------------------------------------------- -void gtk_listitem_select_callback( GtkWidget *widget, wxListBox *listbox ) +static void gtk_listitem_select_callback( GtkWidget *widget, wxListBox *listbox ) { + if (!listbox->HasVMT()) return; + if (g_blockEventsOnDrag) return; + wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, listbox->GetId() ); event.SetInt( listbox->GetIndex( widget ) ); @@ -84,11 +93,11 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id, GtkWidget *list_item; list_item = gtk_list_item_new_with_label( choices[i] ); + gtk_container_add( GTK_CONTAINER(m_list), list_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*)NULL ); gtk_widget_show( list_item ); diff --git a/src/gtk1/radiobox.cpp b/src/gtk1/radiobox.cpp index f4efa3d603..9ff546a945 100644 --- a/src/gtk1/radiobox.cpp +++ b/src/gtk1/radiobox.cpp @@ -18,12 +18,21 @@ #include "wx/frame.h" #include "wx/gtk/win_gtk.h" +//----------------------------------------------------------------------------- +// data +//----------------------------------------------------------------------------- + +extern bool g_blockEventsOnDrag; + //----------------------------------------------------------------------------- // wxRadioBox //----------------------------------------------------------------------------- -void gtk_radiobutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxRadioBox *rb ) +static void gtk_radiobutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxRadioBox *rb ) { + if (!rb->HasVMT()) return; + if (g_blockEventsOnDrag) return; + if (rb->m_alreadySent) { rb->m_alreadySent = FALSE; diff --git a/src/gtk1/scrolbar.cpp b/src/gtk1/scrolbar.cpp index ac11b17d44..37396d9605 100644 --- a/src/gtk1/scrolbar.cpp +++ b/src/gtk1/scrolbar.cpp @@ -16,20 +16,20 @@ #include "wx/scrolbar.h" #include "wx/utils.h" +//----------------------------------------------------------------------------- +// data +//----------------------------------------------------------------------------- + +extern bool g_blockEventsOnDrag; + //----------------------------------------------------------------------------- // wxScrollBar //----------------------------------------------------------------------------- -void gtk_scrollbar_callback( GtkWidget *WXUNUSED(widget), wxScrollBar *win ) +static void gtk_scrollbar_callback( GtkWidget *WXUNUSED(widget), wxScrollBar *win ) { -/* - printf( "OnScroll from " ); - if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) - printf( win->GetClassInfo()->GetClassName() ); - printf( ".\n" ); -*/ - if (!win->HasVMT()) return; + if (g_blockEventsOnDrag) return; float diff = win->m_adjust->value - win->m_oldPos; if (fabs(diff) < 0.2) return; diff --git a/src/gtk1/slider.cpp b/src/gtk1/slider.cpp index d83eb9d7e3..fd8d17b8d6 100644 --- a/src/gtk1/slider.cpp +++ b/src/gtk1/slider.cpp @@ -16,20 +16,20 @@ #include "wx/slider.h" #include "wx/utils.h" +//----------------------------------------------------------------------------- +// data +//----------------------------------------------------------------------------- + +extern bool g_blockEventsOnDrag; + //----------------------------------------------------------------------------- // wxSlider //----------------------------------------------------------------------------- -void gtk_slider_callback( GtkWidget *WXUNUSED(widget), wxSlider *win ) +static void gtk_slider_callback( GtkWidget *WXUNUSED(widget), wxSlider *win ) { -/* - printf( "OnScroll from " ); - if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) - printf( win->GetClassInfo()->GetClassName() ); - printf( ".\n" ); -*/ - if (!win->HasVMT()) return; + if (g_blockEventsOnDrag) return; float diff = win->m_adjust->value - win->m_oldPos; if (fabs(diff) < 0.2) return; diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index c064c71faa..8cb3065191 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -256,7 +256,12 @@ gint gtk_window_key_press_callback( GtkWidget *WXUNUSED(widget), GdkEventKey *gd event.m_x = 0; event.m_y = 0; event.SetEventObject( win ); - return win->ProcessEvent( event ); + + bool ret = win->ProcessEvent( event ); +/* + if (ret) printf( "found.\n") ; +*/ + return ret; }; //----------------------------------------------------------------------------- @@ -627,6 +632,8 @@ void gtk_window_hscroll_change_callback( GtkWidget *WXUNUSED(widget), wxWindow * void gtk_window_drop_callback( GtkWidget *widget, GdkEvent *event, wxWindow *win ) { + if (!win->HasVMT()) return; + if (win->GetDropTarget()) { int x = 0; @@ -662,8 +669,8 @@ bool gtk_window_destroy_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSE bool gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win ) { if (widget->window != gdk_event->window) return TRUE; - - if (g_blockEventsOnDrag) return FALSE; + if (g_blockEventsOnDrag) return TRUE; + if (!win->HasVMT()) return TRUE; if (widget->window) gdk_window_set_cursor( widget->window, win->m_cursor->GetCursor() ); @@ -679,8 +686,8 @@ bool gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, bool gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win ) { if (widget->window != gdk_event->window) return TRUE; - - if (g_blockEventsOnDrag) return FALSE; + if (!win->HasVMT()) return TRUE; + if (g_blockEventsOnDrag) return TRUE; if (widget->window) gdk_window_set_cursor( widget->window, wxSTANDARD_CURSOR->GetCursor() ); @@ -804,6 +811,8 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id, m_wxwindow = gtk_myfixed_new(); + if (m_wxwindow) GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS ); + if (m_windowStyle & wxTAB_TRAVERSAL == wxTAB_TRAVERSAL) GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); else @@ -1059,18 +1068,16 @@ void wxWindow::ImplementSetSize(void) void wxWindow::ImplementSetPosition(void) { + if (IS_KIND_OF(this,wxFrame) || IS_KIND_OF(this,wxDialog)) + { + if ((m_x != -1) || (m_y != -1)) + gtk_widget_set_uposition( m_widget, m_x, m_y ); + return; + } + if (!m_parent) { - if (IsKindOf(CLASSINFO(wxFrame)) || - IsKindOf(CLASSINFO(wxDialog))) - { - if ((m_x != -1) || (m_y != -1)) - gtk_widget_set_uposition( m_widget, m_x, m_y ); - } - else - { - printf( "wxWindow::SetSize error.\n" ); - } + printf( "wxWindow::SetSize error.\n" ); return; } @@ -1325,7 +1332,7 @@ void wxWindow::ScreenToClient( int *x, int *y ) void wxWindow::Centre( int direction ) { - if (this->IsKindOf(CLASSINFO(wxDialog)) || this->IsKindOf(CLASSINFO(wxFrame))) + if (IS_KIND_OF(this,wxDialog) || IS_KIND_OF(this,wxFrame)) { if (direction & wxHORIZONTAL == wxHORIZONTAL) m_x = (gdk_screen_width () - m_width) / 2; if (direction & wxVERTICAL == wxVERTICAL) m_y = (gdk_screen_height () - m_height) / 2; -- 2.45.2