void OnNew( wxCommandEvent &event );
void OnChoice( wxCommandEvent &event );
void OnTextEnter( wxCommandEvent &event );
+
+ void HandleAction( const wxString &fn );
protected:
wxString m_message;
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) )
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;
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;
}
SetPath( filename );
+}
+
+void wxFileDialog::OnListOk( wxCommandEvent &event )
+{
+ HandleAction( m_text->GetValue() );
event.Skip();
}
// "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;
// "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;
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 );
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 );
//
// 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;
// "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;
// "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;
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 );
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 );
//
// 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;