Improved wxFileDialog behaviour wrt to remembering filenames
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
This commit is contained in:
parent
93ccaed869
commit
e1811a014b
@ -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;
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
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);
|
||||
float diff = adjust->value - win->m_oldPos;
|
||||
if (fabs(diff) < 0.2) return;
|
||||
|
||||
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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
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);
|
||||
float diff = adjust->value - win->m_oldPos;
|
||||
if (fabs(diff) < 0.2) return;
|
||||
|
||||
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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user