]> git.saurik.com Git - wxWidgets.git/commitdiff
Improved wxFileDialog behaviour wrt to remembering filenames
authorRobert Roebling <robert@roebling.de>
Fri, 1 Oct 1999 15:41:15 +0000 (15:41 +0000)
committerRobert Roebling <robert@roebling.de>
Fri, 1 Oct 1999 15:41:15 +0000 (15:41 +0000)
  Ported new scrolling code from wxWindow to wxScrollBar and
    wxSlider

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3780 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/generic/filedlgg.h
src/generic/filedlgg.cpp
src/gtk/scrolbar.cpp
src/gtk/slider.cpp
src/gtk/window.cpp
src/gtk1/scrolbar.cpp
src/gtk1/slider.cpp
src/gtk1/window.cpp

index 4b06e97f87dbcc21eda977f980e4416e65a8e484..df25b6ddfa1f7e2795cf2a913dfe7b808faad8e0 100644 (file)
@@ -166,6 +166,8 @@ public:
     void OnNew( wxCommandEvent &event );
     void OnChoice( wxCommandEvent &event );
     void OnTextEnter( wxCommandEvent &event );
+    
+    void HandleAction( const wxString &fn );
 
 protected:
     wxString       m_message;
index cce6ea3eb77c8dea0de7dabaf922eb88cbcf56b5..703cf22cde968b831f0f522506ba24b866037b0c 100644 (file)
@@ -700,11 +700,9 @@ void wxFileDialog::OnChoice( wxCommandEvent &event )
     m_list->SetWild( *str );
 }
 
-void wxFileDialog::OnActivated( wxListEvent &WXUNUSED(event) )
+void wxFileDialog::OnActivated( wxListEvent &event )
 {
-    wxCommandEvent cevent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK);
-    cevent.SetEventObject( this );
-    GetEventHandler()->ProcessEvent( cevent );
+    HandleAction( event.m_item.m_text );
 }
 
 void wxFileDialog::OnTextEnter( wxCommandEvent &WXUNUSED(event) )
@@ -716,13 +714,23 @@ void wxFileDialog::OnTextEnter( wxCommandEvent &WXUNUSED(event) )
 
 void wxFileDialog::OnSelected( wxListEvent &event )
 {
-    if (FindFocus() == m_list)
-        m_text->SetValue( event.m_item.m_text );
+    if (FindFocus() != m_list) return;
+    
+    wxString filename( event.m_item.m_text );
+    if (filename == _T("..")) return;
+    
+    wxString dir;
+    m_list->GetDir( dir );
+    if (dir != _T("/")) dir += _T("/");
+    dir += filename;
+    if (wxDirExists(dir)) return;
+    
+    m_text->SetValue( filename );
 }
 
-void wxFileDialog::OnListOk( wxCommandEvent &event )
+void wxFileDialog::HandleAction( const wxString &fn )
 {
-    wxString filename( m_text->GetValue() );
+    wxString filename( fn );
     wxString dir;
     m_list->GetDir( dir );
     if (filename.IsEmpty()) return;
@@ -777,10 +785,6 @@ void wxFileDialog::OnListOk( wxCommandEvent &event )
     if (wxDirExists(filename))
     {
         m_list->GoToDir( filename );
-        if (filename == _T("/"))
-            m_text->SetValue( _T("") );
-        else
-            m_text->SetValue( _T("..") );
         m_list->GetDir( dir );
         m_static->SetLabel( dir );
         return;
@@ -808,6 +812,11 @@ void wxFileDialog::OnListOk( wxCommandEvent &event )
     }
 
     SetPath( filename );
+}
+
+void wxFileDialog::OnListOk( wxCommandEvent &event )
+{
+    HandleAction( m_text->GetValue() );
     event.Skip();
 }
 
index 890112cdbd6aa84ada47dbca2f5787261859d4e6..43997ce96d48598960e305235bcc0259070f6268 100644 (file)
@@ -40,38 +40,27 @@ extern bool   g_blockEventsOnScroll;
 // "value_changed"
 //-----------------------------------------------------------------------------
 
-static void gtk_scrollbar_callback( GtkWidget *WXUNUSED(widget), wxScrollBar *win )
+static void gtk_scrollbar_callback( GtkAdjustment *adjust, wxScrollBar *win )
 { 
     if (g_isIdle) wxapp_install_idle_handler();
 
     if (!win->m_hasVMT) return;
     if (g_blockEventsOnDrag) return;
     
-    float diff = win->m_adjust->value - win->m_oldPos;
+    float diff = adjust->value - win->m_oldPos;
     if (fabs(diff) < 0.2) return;
-    win->m_oldPos = win->m_adjust->value;
-  
-    wxEventType command = wxEVT_NULL;
-  
-    float line_step = win->m_adjust->step_increment;
-    float page_step = win->m_adjust->page_increment;
-  
-    if (win->IsScrolling())
-    {
-        command = wxEVT_SCROLL_THUMBTRACK;
-    }
-    else
-    {
-        if (fabs(win->m_adjust->value-win->m_adjust->lower) < 0.2) command = wxEVT_SCROLL_BOTTOM;
-        else if (fabs(win->m_adjust->value-win->m_adjust->upper) < 0.2) command = wxEVT_SCROLL_TOP;
-        else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLL_LINEDOWN;
-        else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLL_LINEUP;
-        else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLL_PAGEDOWN;
-        else if (fabs(diff+page_step) < 0.2) command = wxEVT_SCROLL_PAGEUP;
-        else command = wxEVT_SCROLL_THUMBTRACK;
-    }
+    
+    win->m_oldPos = adjust->value;
 
-    int value = (int)(win->m_adjust->value+0.5);
+    GtkRange *range = GTK_RANGE( win->m_widget );
+
+    wxEventType command = wxEVT_SCROLL_THUMBTRACK;
+    if      (range->scroll_type == GTK_SCROLL_STEP_BACKWARD) command = wxEVT_SCROLL_LINEUP;
+    else if (range->scroll_type == GTK_SCROLL_STEP_FORWARD)  command = wxEVT_SCROLL_LINEDOWN;
+    else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLL_PAGEUP;
+    else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD)  command = wxEVT_SCROLL_PAGEDOWN;
+    
+    int value = (int)ceil(adjust->value);
       
     int orient = win->HasFlag(wxSB_VERTICAL) ? wxVERTICAL : wxHORIZONTAL;
   
index 5d115ba3b87651642e5bc06a620f8110a31d909a..d51d94f1d4df0cb55e426db9b15e8b98dd766acf 100644 (file)
@@ -38,31 +38,27 @@ extern bool   g_blockEventsOnDrag;
 // "value_changed"
 //-----------------------------------------------------------------------------
 
-static void gtk_slider_callback( GtkWidget *WXUNUSED(widget), wxSlider *win )
+static void gtk_slider_callback( GtkAdjustment *adjust, wxSlider *win )
 { 
     if (g_isIdle) wxapp_install_idle_handler();
 
     if (!win->m_hasVMT) return;
     if (g_blockEventsOnDrag) return;
-    
-    float diff = win->m_adjust->value - win->m_oldPos;
+
+    float diff = adjust->value - win->m_oldPos;
     if (fabs(diff) < 0.2) return;
-    win->m_oldPos = win->m_adjust->value;
-  
-    wxEventType command = wxEVT_NULL;
-  
-    float line_step = win->m_adjust->step_increment;
-    float page_step = win->m_adjust->page_increment;
-  
-    if (fabs(win->m_adjust->value-win->m_adjust->lower) < 0.2) command = wxEVT_SCROLL_BOTTOM;
-    else if (fabs(win->m_adjust->value-win->m_adjust->upper) < 0.2) command = wxEVT_SCROLL_TOP;
-    else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLL_LINEDOWN;
-    else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLL_LINEUP;
-    else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLL_PAGEDOWN;
-    else if (fabs(diff+page_step) < 0.2) command = wxEVT_SCROLL_PAGEUP;
-    else command = wxEVT_SCROLL_THUMBTRACK;
-
-    int value = (int)ceil(win->m_adjust->value);
+    
+    win->m_oldPos = adjust->value;
+
+    GtkRange *range = GTK_RANGE( win->m_widget );
+
+    wxEventType command = wxEVT_SCROLL_THUMBTRACK;
+    if      (range->scroll_type == GTK_SCROLL_STEP_BACKWARD) command = wxEVT_SCROLL_LINEUP;
+    else if (range->scroll_type == GTK_SCROLL_STEP_FORWARD)  command = wxEVT_SCROLL_LINEDOWN;
+    else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLL_PAGEUP;
+    else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD)  command = wxEVT_SCROLL_PAGEDOWN;
+    
+    int value = (int)ceil(adjust->value);
       
     int orient = wxHORIZONTAL;
     if (win->GetWindowStyleFlag() & wxSB_VERTICAL == wxSB_VERTICAL) orient = wxVERTICAL;
index 2b47193e483bc3c4bdfd9fae7df4db563e19d15d..56c43282afedf5ede83ea30ea63dd3fe7bc7281e 100644 (file)
@@ -1543,9 +1543,6 @@ static void gtk_window_vscroll_callback( GtkAdjustment *adjust, wxWindow *win )
     else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLLWIN_PAGEUP;
     else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD)  command = wxEVT_SCROLLWIN_PAGEDOWN;
     
-//    if (fabs(adjust->value-adjust->lower) < 0.2) command = wxEVT_SCROLLWIN_BOTTOM;
-//    if (fabs(adjust->value-adjust->upper) < 0.2) command = wxEVT_SCROLLWIN_TOP;
-
     int value = (int)(adjust->value+0.5);
 
     wxScrollWinEvent event( command, value, wxVERTICAL );
@@ -1579,9 +1576,6 @@ static void gtk_window_hscroll_callback( GtkAdjustment *adjust, wxWindow *win )
     else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLLWIN_PAGEUP;
     else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD)  command = wxEVT_SCROLLWIN_PAGEDOWN;
     
-//    if (fabs(adjust->value-adjust->lower) < 0.2) command = wxEVT_SCROLLWIN_BOTTOM;
-//    if (fabs(adjust->value-adjust->upper) < 0.2) command = wxEVT_SCROLLWIN_TOP;
-
     int value = (int)(adjust->value+0.5);
 
     wxScrollWinEvent event( command, value, wxHORIZONTAL );
@@ -1664,13 +1658,6 @@ static gint gtk_scrollbar_button_release_callback( GtkRange *widget,
 //
 //    if (gdk_event->window != widget->slider) return FALSE;
 
-//    GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(win->m_widget);
-//
-//    if (widget == GTK_RANGE(scrolledWindow->vscrollbar))
-//        gtk_signal_emit_by_name( GTK_OBJECT(win->m_hAdjust), "value_changed" );
-//    else
-//        gtk_signal_emit_by_name( GTK_OBJECT(win->m_vAdjust), "value_changed" );
-
     win->SetScrolling( FALSE );
 
     return FALSE;
index 890112cdbd6aa84ada47dbca2f5787261859d4e6..43997ce96d48598960e305235bcc0259070f6268 100644 (file)
@@ -40,38 +40,27 @@ extern bool   g_blockEventsOnScroll;
 // "value_changed"
 //-----------------------------------------------------------------------------
 
-static void gtk_scrollbar_callback( GtkWidget *WXUNUSED(widget), wxScrollBar *win )
+static void gtk_scrollbar_callback( GtkAdjustment *adjust, wxScrollBar *win )
 { 
     if (g_isIdle) wxapp_install_idle_handler();
 
     if (!win->m_hasVMT) return;
     if (g_blockEventsOnDrag) return;
     
-    float diff = win->m_adjust->value - win->m_oldPos;
+    float diff = adjust->value - win->m_oldPos;
     if (fabs(diff) < 0.2) return;
-    win->m_oldPos = win->m_adjust->value;
-  
-    wxEventType command = wxEVT_NULL;
-  
-    float line_step = win->m_adjust->step_increment;
-    float page_step = win->m_adjust->page_increment;
-  
-    if (win->IsScrolling())
-    {
-        command = wxEVT_SCROLL_THUMBTRACK;
-    }
-    else
-    {
-        if (fabs(win->m_adjust->value-win->m_adjust->lower) < 0.2) command = wxEVT_SCROLL_BOTTOM;
-        else if (fabs(win->m_adjust->value-win->m_adjust->upper) < 0.2) command = wxEVT_SCROLL_TOP;
-        else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLL_LINEDOWN;
-        else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLL_LINEUP;
-        else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLL_PAGEDOWN;
-        else if (fabs(diff+page_step) < 0.2) command = wxEVT_SCROLL_PAGEUP;
-        else command = wxEVT_SCROLL_THUMBTRACK;
-    }
+    
+    win->m_oldPos = adjust->value;
 
-    int value = (int)(win->m_adjust->value+0.5);
+    GtkRange *range = GTK_RANGE( win->m_widget );
+
+    wxEventType command = wxEVT_SCROLL_THUMBTRACK;
+    if      (range->scroll_type == GTK_SCROLL_STEP_BACKWARD) command = wxEVT_SCROLL_LINEUP;
+    else if (range->scroll_type == GTK_SCROLL_STEP_FORWARD)  command = wxEVT_SCROLL_LINEDOWN;
+    else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLL_PAGEUP;
+    else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD)  command = wxEVT_SCROLL_PAGEDOWN;
+    
+    int value = (int)ceil(adjust->value);
       
     int orient = win->HasFlag(wxSB_VERTICAL) ? wxVERTICAL : wxHORIZONTAL;
   
index 5d115ba3b87651642e5bc06a620f8110a31d909a..d51d94f1d4df0cb55e426db9b15e8b98dd766acf 100644 (file)
@@ -38,31 +38,27 @@ extern bool   g_blockEventsOnDrag;
 // "value_changed"
 //-----------------------------------------------------------------------------
 
-static void gtk_slider_callback( GtkWidget *WXUNUSED(widget), wxSlider *win )
+static void gtk_slider_callback( GtkAdjustment *adjust, wxSlider *win )
 { 
     if (g_isIdle) wxapp_install_idle_handler();
 
     if (!win->m_hasVMT) return;
     if (g_blockEventsOnDrag) return;
-    
-    float diff = win->m_adjust->value - win->m_oldPos;
+
+    float diff = adjust->value - win->m_oldPos;
     if (fabs(diff) < 0.2) return;
-    win->m_oldPos = win->m_adjust->value;
-  
-    wxEventType command = wxEVT_NULL;
-  
-    float line_step = win->m_adjust->step_increment;
-    float page_step = win->m_adjust->page_increment;
-  
-    if (fabs(win->m_adjust->value-win->m_adjust->lower) < 0.2) command = wxEVT_SCROLL_BOTTOM;
-    else if (fabs(win->m_adjust->value-win->m_adjust->upper) < 0.2) command = wxEVT_SCROLL_TOP;
-    else if (fabs(diff-line_step) < 0.2) command = wxEVT_SCROLL_LINEDOWN;
-    else if (fabs(diff+line_step) < 0.2) command = wxEVT_SCROLL_LINEUP;
-    else if (fabs(diff-page_step) < 0.2) command = wxEVT_SCROLL_PAGEDOWN;
-    else if (fabs(diff+page_step) < 0.2) command = wxEVT_SCROLL_PAGEUP;
-    else command = wxEVT_SCROLL_THUMBTRACK;
-
-    int value = (int)ceil(win->m_adjust->value);
+    
+    win->m_oldPos = adjust->value;
+
+    GtkRange *range = GTK_RANGE( win->m_widget );
+
+    wxEventType command = wxEVT_SCROLL_THUMBTRACK;
+    if      (range->scroll_type == GTK_SCROLL_STEP_BACKWARD) command = wxEVT_SCROLL_LINEUP;
+    else if (range->scroll_type == GTK_SCROLL_STEP_FORWARD)  command = wxEVT_SCROLL_LINEDOWN;
+    else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLL_PAGEUP;
+    else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD)  command = wxEVT_SCROLL_PAGEDOWN;
+    
+    int value = (int)ceil(adjust->value);
       
     int orient = wxHORIZONTAL;
     if (win->GetWindowStyleFlag() & wxSB_VERTICAL == wxSB_VERTICAL) orient = wxVERTICAL;
index 2b47193e483bc3c4bdfd9fae7df4db563e19d15d..56c43282afedf5ede83ea30ea63dd3fe7bc7281e 100644 (file)
@@ -1543,9 +1543,6 @@ static void gtk_window_vscroll_callback( GtkAdjustment *adjust, wxWindow *win )
     else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLLWIN_PAGEUP;
     else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD)  command = wxEVT_SCROLLWIN_PAGEDOWN;
     
-//    if (fabs(adjust->value-adjust->lower) < 0.2) command = wxEVT_SCROLLWIN_BOTTOM;
-//    if (fabs(adjust->value-adjust->upper) < 0.2) command = wxEVT_SCROLLWIN_TOP;
-
     int value = (int)(adjust->value+0.5);
 
     wxScrollWinEvent event( command, value, wxVERTICAL );
@@ -1579,9 +1576,6 @@ static void gtk_window_hscroll_callback( GtkAdjustment *adjust, wxWindow *win )
     else if (range->scroll_type == GTK_SCROLL_PAGE_BACKWARD) command = wxEVT_SCROLLWIN_PAGEUP;
     else if (range->scroll_type == GTK_SCROLL_PAGE_FORWARD)  command = wxEVT_SCROLLWIN_PAGEDOWN;
     
-//    if (fabs(adjust->value-adjust->lower) < 0.2) command = wxEVT_SCROLLWIN_BOTTOM;
-//    if (fabs(adjust->value-adjust->upper) < 0.2) command = wxEVT_SCROLLWIN_TOP;
-
     int value = (int)(adjust->value+0.5);
 
     wxScrollWinEvent event( command, value, wxHORIZONTAL );
@@ -1664,13 +1658,6 @@ static gint gtk_scrollbar_button_release_callback( GtkRange *widget,
 //
 //    if (gdk_event->window != widget->slider) return FALSE;
 
-//    GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(win->m_widget);
-//
-//    if (widget == GTK_RANGE(scrolledWindow->vscrollbar))
-//        gtk_signal_emit_by_name( GTK_OBJECT(win->m_hAdjust), "value_changed" );
-//    else
-//        gtk_signal_emit_by_name( GTK_OBJECT(win->m_vAdjust), "value_changed" );
-
     win->SetScrolling( FALSE );
 
     return FALSE;