SetInsertionPointEnd() bug corrected (was off by 1)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1485 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1999-01-26 12:56:58 +00:00
parent 1eddcfafba
commit 805dd538bb
4 changed files with 258 additions and 276 deletions

View File

@@ -4,7 +4,7 @@
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
@@ -78,7 +78,7 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
const wxPoint& pos, const wxSize& size,
int n, const wxString choices[],
long style, const wxValidator& validator,
const wxString& name )
const wxString& name )
{
m_alreadySent = FALSE;
m_needParent = TRUE;
@@ -460,17 +460,14 @@ void wxComboBox::SetInsertionPoint( long pos )
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
int tmp = (int) pos;
gtk_entry_set_position( GTK_ENTRY(entry), tmp );
gtk_entry_set_position( GTK_ENTRY(entry), (int)tmp );
}
void wxComboBox::SetInsertionPointEnd()
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
int pos = GTK_ENTRY(entry)->text_length;
SetInsertionPoint( pos-1 );
SetInsertionPoint( -1 );
}
long wxComboBox::GetInsertionPoint() const

View File

@@ -224,18 +224,18 @@ void wxTextCtrl::CalculateScrollbar()
{
if (m_vScrollbarVisible)
{
gtk_widget_hide( m_vScrollbar );
gtk_widget_hide( m_vScrollbar );
m_vScrollbarVisible = FALSE;
m_vScrollbarVisible = FALSE;
}
}
else
{
if (!m_vScrollbarVisible)
{
gtk_widget_show( m_vScrollbar );
gtk_widget_show( m_vScrollbar );
m_vScrollbarVisible = TRUE;
m_vScrollbarVisible = TRUE;
}
}
}
@@ -321,8 +321,8 @@ bool wxTextCtrl::LoadFile( const wxString &file )
return FALSE;
}
if (fread (text, sizeof (char), len, fp) != (size_t) len)
{
}
{
}
fclose (fp);
text[len] = 0;
@@ -372,13 +372,13 @@ bool wxTextCtrl::SaveFile( const wxString &file )
}
if (fwrite (text, sizeof (char), len, fp) != (size_t) len)
{
// Did not write whole file
}
{
// Did not write whole file
}
// Make sure newline terminates the file
if (text[len - 1] != '\n')
fputc ('\n', fp);
fputc ('\n', fp);
fclose (fp);
@@ -445,12 +445,12 @@ long wxTextCtrl::PositionToXY(long pos, long *x, long *y ) const
for (int i = 0; i < pos; i++ )
{
if (text[i] == '\n')
{
(*y)++;
*x=1;
}
{
(*y)++;
*x=1;
}
else
(*x)++;
(*x)++;
}
g_free( text );
return 1;
@@ -485,17 +485,17 @@ int wxTextCtrl::GetNumberOfLines() const
{
int currentLine = 0;
for (int i = 0; i < len; i++ )
{
{
if (text[i] == '\n')
currentLine++;
}
}
g_free( text );
return currentLine;
}
else
{
{
return 0;
}
}
}
else
{
@@ -518,13 +518,7 @@ void wxTextCtrl::SetInsertionPointEnd()
{
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
int pos = 0;
if (m_windowStyle & wxTE_MULTILINE)
pos = gtk_text_get_length( GTK_TEXT(m_text) );
else
pos = GTK_ENTRY(m_text)->text_length;
SetInsertionPoint((pos-1)>0 ? (pos-1):0);
SetInsertionPoint(-1);
}
void wxTextCtrl::SetEditable( bool editable )

View File

@@ -4,7 +4,7 @@
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
@@ -78,7 +78,7 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
const wxPoint& pos, const wxSize& size,
int n, const wxString choices[],
long style, const wxValidator& validator,
const wxString& name )
const wxString& name )
{
m_alreadySent = FALSE;
m_needParent = TRUE;
@@ -460,17 +460,14 @@ void wxComboBox::SetInsertionPoint( long pos )
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
int tmp = (int) pos;
gtk_entry_set_position( GTK_ENTRY(entry), tmp );
gtk_entry_set_position( GTK_ENTRY(entry), (int)tmp );
}
void wxComboBox::SetInsertionPointEnd()
{
wxCHECK_RET( m_widget != NULL, "invalid combobox" );
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
int pos = GTK_ENTRY(entry)->text_length;
SetInsertionPoint( pos-1 );
SetInsertionPoint( -1 );
}
long wxComboBox::GetInsertionPoint() const

View File

@@ -224,18 +224,18 @@ void wxTextCtrl::CalculateScrollbar()
{
if (m_vScrollbarVisible)
{
gtk_widget_hide( m_vScrollbar );
gtk_widget_hide( m_vScrollbar );
m_vScrollbarVisible = FALSE;
m_vScrollbarVisible = FALSE;
}
}
else
{
if (!m_vScrollbarVisible)
{
gtk_widget_show( m_vScrollbar );
gtk_widget_show( m_vScrollbar );
m_vScrollbarVisible = TRUE;
m_vScrollbarVisible = TRUE;
}
}
}
@@ -321,8 +321,8 @@ bool wxTextCtrl::LoadFile( const wxString &file )
return FALSE;
}
if (fread (text, sizeof (char), len, fp) != (size_t) len)
{
}
{
}
fclose (fp);
text[len] = 0;
@@ -372,13 +372,13 @@ bool wxTextCtrl::SaveFile( const wxString &file )
}
if (fwrite (text, sizeof (char), len, fp) != (size_t) len)
{
// Did not write whole file
}
{
// Did not write whole file
}
// Make sure newline terminates the file
if (text[len - 1] != '\n')
fputc ('\n', fp);
fputc ('\n', fp);
fclose (fp);
@@ -445,12 +445,12 @@ long wxTextCtrl::PositionToXY(long pos, long *x, long *y ) const
for (int i = 0; i < pos; i++ )
{
if (text[i] == '\n')
{
(*y)++;
*x=1;
}
{
(*y)++;
*x=1;
}
else
(*x)++;
(*x)++;
}
g_free( text );
return 1;
@@ -485,17 +485,17 @@ int wxTextCtrl::GetNumberOfLines() const
{
int currentLine = 0;
for (int i = 0; i < len; i++ )
{
{
if (text[i] == '\n')
currentLine++;
}
}
g_free( text );
return currentLine;
}
else
{
{
return 0;
}
}
}
else
{
@@ -518,13 +518,7 @@ void wxTextCtrl::SetInsertionPointEnd()
{
wxCHECK_RET( m_text != NULL, "invalid text ctrl" );
int pos = 0;
if (m_windowStyle & wxTE_MULTILINE)
pos = gtk_text_get_length( GTK_TEXT(m_text) );
else
pos = GTK_ENTRY(m_text)->text_length;
SetInsertionPoint((pos-1)>0 ? (pos-1):0);
SetInsertionPoint(-1);
}
void wxTextCtrl::SetEditable( bool editable )