Added wxCommandEvent::IsSeection for listbox,

Applied patch for wxListBox::Set when sorting
  Added new value rounding code (corrected for
    negative values) to scrollbar and slider
  Added ...TEXT_CHANGED event to wxSpinCtrl


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8928 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2000-12-16 10:02:47 +00:00
parent 186837b05e
commit 0a07a7d852
11 changed files with 157 additions and 39 deletions

View File

@@ -415,6 +415,7 @@ bool wxWindowDC::DoGetPixel( wxCoord x1, wxCoord y1, wxColour *col ) const
memdc.SelectObject(bitmap);
memdc.Blit(0, 0, 1, 1, (wxDC*) this, x1, y1);
memdc.SelectObject(wxNullBitmap);
wxImage image(bitmap);
col->Set(image.GetRed(0, 0), image.GetGreen(0, 0), image.GetBlue(0, 0));
return TRUE;

View File

@@ -251,14 +251,19 @@ gtk_listbox_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxLis
// "select" and "deselect"
//-----------------------------------------------------------------------------
static void gtk_listitem_select_callback( GtkWidget *WXUNUSED(widget), wxListBox *listbox );
static void gtk_listitem_select_cb( GtkWidget *widget, wxListBox *listbox, bool is_selection );
static void gtk_listitem_select_callback( GtkWidget *widget, wxListBox *listbox )
{
gtk_listitem_select_cb( widget, listbox, TRUE );
}
static void gtk_listitem_deselect_callback( GtkWidget *widget, wxListBox *listbox )
{
gtk_listitem_select_callback( widget, listbox );
gtk_listitem_select_cb( widget, listbox, FALSE );
}
static void gtk_listitem_select_callback( GtkWidget *WXUNUSED(widget), wxListBox *listbox )
static void gtk_listitem_select_cb( GtkWidget *WXUNUSED(widget), wxListBox *listbox, bool is_selection )
{
if (g_isIdle) wxapp_install_idle_handler();
@@ -267,6 +272,7 @@ static void gtk_listitem_select_callback( GtkWidget *WXUNUSED(widget), wxListBox
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, listbox->GetId() );
event.SetEventObject( listbox );
event.SetExtraLong( (long) is_selection );
wxArrayInt aSelections;
int n, count = listbox->GetSelections(aSelections);
@@ -430,7 +436,29 @@ void wxListBox::DoInsertItems(const wxArrayString& items, int pos)
wxCHECK_RET( pos <= length, wxT("invalid index in wxListBox::InsertItems") );
size_t nItems = items.GetCount();
int index;
if (m_strings)
{
for (size_t n = 0; n < nItems; n++)
{
index = m_strings->Add( items[n] );
if (index != GetCount())
{
GtkAddItem( items[n], index );
wxNode *node = m_clientList.Nth( index );
m_clientList.Insert( node, (wxObject*) NULL );
}
else
{
GtkAddItem( items[n] );
m_clientList.Append( (wxObject*) NULL );
}
}
}
else
{
if (pos == length)
{
for ( size_t n = 0; n < nItems; n++ )
@@ -450,6 +478,7 @@ void wxListBox::DoInsertItems(const wxArrayString& items, int pos)
m_clientList.Insert( node, (wxObject *)NULL );
}
}
}
wxASSERT_MSG( m_clientList.GetCount() == (size_t)GetCount(),
wxT("bug in client data management") );

View File

@@ -63,7 +63,8 @@ static void gtk_scrollbar_callback( GtkAdjustment *adjust, wxScrollBar *win )
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);
double dvalue = adjust->value;
int value = (int)(dvalue >= 0 ? dvalue - 0.5 : dvalue + 0.5);
int orient = win->HasFlag(wxSB_VERTICAL) ? wxVERTICAL : wxHORIZONTAL;
@@ -129,7 +130,7 @@ static gint gtk_scrollbar_button_release_callback( GtkRange *WXUNUSED(widget),
IMPLEMENT_DYNAMIC_CLASS(wxScrollBar,wxControl)
wxScrollBar::~wxScrollBar(void)
wxScrollBar::~wxScrollBar()
{
}
@@ -182,9 +183,10 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id,
return TRUE;
}
int wxScrollBar::GetThumbPosition(void) const
int wxScrollBar::GetThumbPosition() const
{
return (int)(m_adjust->value+0.5);
double val = m_adjust->value;
return (int)(val >= 0 ? val - 0.5 : val + 0.5);
}
int wxScrollBar::GetThumbSize() const
@@ -252,7 +254,7 @@ void wxScrollBar::SetScrollbar( int position, int thumbSize, int range, int page
}
/* Backward compatibility */
int wxScrollBar::GetValue(void) const
int wxScrollBar::GetValue() const
{
return GetThumbPosition();
}

View File

@@ -61,7 +61,8 @@ static void gtk_slider_callback( GtkAdjustment *adjust, wxSlider *win )
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);
double dvalue = adjust->value;
int value = (int)(dvalue >= 0 ? dvalue - 0.5 : dvalue + 0.5);
int orient = wxHORIZONTAL;
if ( (win->GetWindowStyleFlag() & wxSB_VERTICAL) == wxSB_VERTICAL)

View File

@@ -55,6 +55,24 @@ static void gtk_spinctrl_callback( GtkWidget *WXUNUSED(widget), wxSpinCtrl *win
win->GetEventHandler()->ProcessEvent( event );
}
//-----------------------------------------------------------------------------
// "changed"
//-----------------------------------------------------------------------------
static void
gtk_spinctrl_text_changed_callback( GtkWidget *WXUNUSED(widget), wxSpinCtrl *win )
{
if (!win->m_hasVMT) return;
if (g_isIdle)
wxapp_install_idle_handler();
wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, win->GetId() );
event.SetEventObject( win );
event.SetInt( win->GetValue() );
win->GetEventHandler()->ProcessEvent( event );
}
//-----------------------------------------------------------------------------
// wxSpinCtrl
//-----------------------------------------------------------------------------
@@ -125,6 +143,9 @@ void wxSpinCtrl::GtkDisableEvents()
GTK_SIGNAL_FUNC(gtk_spinctrl_callback),
(gpointer) this );
gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget),
GTK_SIGNAL_FUNC(gtk_spinctrl_text_changed_callback),
(gpointer) this );
}
void wxSpinCtrl::GtkEnableEvents()
@@ -133,6 +154,11 @@ void wxSpinCtrl::GtkEnableEvents()
"value_changed",
GTK_SIGNAL_FUNC(gtk_spinctrl_callback),
(gpointer) this );
gtk_signal_connect( GTK_OBJECT(m_widget),
"changed",
GTK_SIGNAL_FUNC(gtk_spinctrl_text_changed_callback),
(gpointer)this);
}
int wxSpinCtrl::GetMin() const

View File

@@ -415,6 +415,7 @@ bool wxWindowDC::DoGetPixel( wxCoord x1, wxCoord y1, wxColour *col ) const
memdc.SelectObject(bitmap);
memdc.Blit(0, 0, 1, 1, (wxDC*) this, x1, y1);
memdc.SelectObject(wxNullBitmap);
wxImage image(bitmap);
col->Set(image.GetRed(0, 0), image.GetGreen(0, 0), image.GetBlue(0, 0));
return TRUE;

View File

@@ -251,14 +251,19 @@ gtk_listbox_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxLis
// "select" and "deselect"
//-----------------------------------------------------------------------------
static void gtk_listitem_select_callback( GtkWidget *WXUNUSED(widget), wxListBox *listbox );
static void gtk_listitem_select_cb( GtkWidget *widget, wxListBox *listbox, bool is_selection );
static void gtk_listitem_select_callback( GtkWidget *widget, wxListBox *listbox )
{
gtk_listitem_select_cb( widget, listbox, TRUE );
}
static void gtk_listitem_deselect_callback( GtkWidget *widget, wxListBox *listbox )
{
gtk_listitem_select_callback( widget, listbox );
gtk_listitem_select_cb( widget, listbox, FALSE );
}
static void gtk_listitem_select_callback( GtkWidget *WXUNUSED(widget), wxListBox *listbox )
static void gtk_listitem_select_cb( GtkWidget *WXUNUSED(widget), wxListBox *listbox, bool is_selection )
{
if (g_isIdle) wxapp_install_idle_handler();
@@ -267,6 +272,7 @@ static void gtk_listitem_select_callback( GtkWidget *WXUNUSED(widget), wxListBox
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, listbox->GetId() );
event.SetEventObject( listbox );
event.SetExtraLong( (long) is_selection );
wxArrayInt aSelections;
int n, count = listbox->GetSelections(aSelections);
@@ -430,7 +436,29 @@ void wxListBox::DoInsertItems(const wxArrayString& items, int pos)
wxCHECK_RET( pos <= length, wxT("invalid index in wxListBox::InsertItems") );
size_t nItems = items.GetCount();
int index;
if (m_strings)
{
for (size_t n = 0; n < nItems; n++)
{
index = m_strings->Add( items[n] );
if (index != GetCount())
{
GtkAddItem( items[n], index );
wxNode *node = m_clientList.Nth( index );
m_clientList.Insert( node, (wxObject*) NULL );
}
else
{
GtkAddItem( items[n] );
m_clientList.Append( (wxObject*) NULL );
}
}
}
else
{
if (pos == length)
{
for ( size_t n = 0; n < nItems; n++ )
@@ -450,6 +478,7 @@ void wxListBox::DoInsertItems(const wxArrayString& items, int pos)
m_clientList.Insert( node, (wxObject *)NULL );
}
}
}
wxASSERT_MSG( m_clientList.GetCount() == (size_t)GetCount(),
wxT("bug in client data management") );

View File

@@ -63,7 +63,8 @@ static void gtk_scrollbar_callback( GtkAdjustment *adjust, wxScrollBar *win )
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);
double dvalue = adjust->value;
int value = (int)(dvalue >= 0 ? dvalue - 0.5 : dvalue + 0.5);
int orient = win->HasFlag(wxSB_VERTICAL) ? wxVERTICAL : wxHORIZONTAL;
@@ -129,7 +130,7 @@ static gint gtk_scrollbar_button_release_callback( GtkRange *WXUNUSED(widget),
IMPLEMENT_DYNAMIC_CLASS(wxScrollBar,wxControl)
wxScrollBar::~wxScrollBar(void)
wxScrollBar::~wxScrollBar()
{
}
@@ -182,9 +183,10 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id,
return TRUE;
}
int wxScrollBar::GetThumbPosition(void) const
int wxScrollBar::GetThumbPosition() const
{
return (int)(m_adjust->value+0.5);
double val = m_adjust->value;
return (int)(val >= 0 ? val - 0.5 : val + 0.5);
}
int wxScrollBar::GetThumbSize() const
@@ -252,7 +254,7 @@ void wxScrollBar::SetScrollbar( int position, int thumbSize, int range, int page
}
/* Backward compatibility */
int wxScrollBar::GetValue(void) const
int wxScrollBar::GetValue() const
{
return GetThumbPosition();
}

View File

@@ -61,7 +61,8 @@ static void gtk_slider_callback( GtkAdjustment *adjust, wxSlider *win )
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);
double dvalue = adjust->value;
int value = (int)(dvalue >= 0 ? dvalue - 0.5 : dvalue + 0.5);
int orient = wxHORIZONTAL;
if ( (win->GetWindowStyleFlag() & wxSB_VERTICAL) == wxSB_VERTICAL)

View File

@@ -55,6 +55,24 @@ static void gtk_spinctrl_callback( GtkWidget *WXUNUSED(widget), wxSpinCtrl *win
win->GetEventHandler()->ProcessEvent( event );
}
//-----------------------------------------------------------------------------
// "changed"
//-----------------------------------------------------------------------------
static void
gtk_spinctrl_text_changed_callback( GtkWidget *WXUNUSED(widget), wxSpinCtrl *win )
{
if (!win->m_hasVMT) return;
if (g_isIdle)
wxapp_install_idle_handler();
wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, win->GetId() );
event.SetEventObject( win );
event.SetInt( win->GetValue() );
win->GetEventHandler()->ProcessEvent( event );
}
//-----------------------------------------------------------------------------
// wxSpinCtrl
//-----------------------------------------------------------------------------
@@ -125,6 +143,9 @@ void wxSpinCtrl::GtkDisableEvents()
GTK_SIGNAL_FUNC(gtk_spinctrl_callback),
(gpointer) this );
gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget),
GTK_SIGNAL_FUNC(gtk_spinctrl_text_changed_callback),
(gpointer) this );
}
void wxSpinCtrl::GtkEnableEvents()
@@ -133,6 +154,11 @@ void wxSpinCtrl::GtkEnableEvents()
"value_changed",
GTK_SIGNAL_FUNC(gtk_spinctrl_callback),
(gpointer) this );
gtk_signal_connect( GTK_OBJECT(m_widget),
"changed",
GTK_SIGNAL_FUNC(gtk_spinctrl_text_changed_callback),
(gpointer)this);
}
int wxSpinCtrl::GetMin() const