event.SetEventObject(win);
win->GetEventHandler()->ProcessEvent(event);
-
+
if (event.MoreRequested())
needMore = TRUE;
SetLabel( label );
-#if (GTK_MINOR_VERSION > 0)
if (style & wxNO_BORDER)
gtk_button_set_relief( GTK_BUTTON(m_widget), GTK_RELIEF_NONE );
-#endif
gtk_signal_connect( GTK_OBJECT(m_widget), "clicked",
GTK_SIGNAL_FUNC(gtk_button_clicked_callback), (gpointer*)this );
wxControl::SetLabel( label );
- gtk_label_set( GTK_LABEL( BUTTON_CHILD(m_widget) ), GetLabel().mbc_str() );
+ gtk_label_set( GTK_LABEL( BUTTON_CHILD(m_widget) ), wxGTK_CONV( GetLabel() ) );
}
bool wxButton::Enable( bool enable )
// left of it
m_widgetCheckbox = gtk_check_button_new();
- m_widgetLabel = gtk_label_new(m_label.mbc_str());
+ m_widgetLabel = gtk_label_new( wxGTK_CONV( m_label ) );
gtk_misc_set_alignment(GTK_MISC(m_widgetLabel), 0.0, 0.5);
m_widget = gtk_hbox_new(FALSE, 0);
}
else
{
- m_widgetCheckbox = gtk_check_button_new_with_label( m_label.mbc_str() );
+ m_widgetCheckbox = gtk_check_button_new_with_label( wxGTK_CONV( m_label ) );
m_widgetLabel = BUTTON_CHILD( m_widgetCheckbox );
m_widget = m_widgetCheckbox;
}
wxControl::SetLabel( label );
- gtk_label_set( GTK_LABEL(m_widgetLabel), GetLabel().mbc_str() );
+ gtk_label_set( GTK_LABEL(m_widgetLabel), wxGTK_CONV( GetLabel() ) );
}
bool wxCheckBox::Enable( bool enable )
#if wxUSE_CHECKLISTBOX
#include "wx/checklst.h"
+#include "wx/gtk/private.h"
#include <gdk/gdk.h>
#include <gtk/gtk.h>
GtkBin *bin = GTK_BIN( child->data );
GtkLabel *label = GTK_LABEL( bin->child );
- wxString str = wxString(label->label,*wxConvCurrent);
+ wxString str( wxGTK_CONV_BACK( label->label ) );
return str.GetChar(1) == wxCHECKLBOX_CHECKED;
}
GtkBin *bin = GTK_BIN( child->data );
GtkLabel *label = GTK_LABEL( bin->child );
- wxString str = wxString(label->label,*wxConvCurrent);
+ wxString str( wxGTK_CONV_BACK( label->label ) );
if (check == (str.GetChar(1) == wxCHECKLBOX_CHECKED))
return;
str.SetChar( 1, check ? wxCHECKLBOX_CHECKED : wxCHECKLBOX_UNCHECKED );
- gtk_label_set( label, str.mbc_str() );
+ gtk_label_set( label, wxGTK_CONV( str ) );
return;
}
label = GTK_LABEL( BUTTON_CHILD(m_widget) );
wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") );
-
- if (string == wxString(label->label,*wxConvCurrent))
+
+ wxString tmp( wxGTK_CONV_BACK( label->label ) );
+ if (string == tmp)
return count;
child = child->next;
wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") );
- return wxString(label->label,*wxConvCurrent);
+ return wxString( wxGTK_CONV_BACK(label->label) );
}
child = child->next;
count++;
size_t wxChoice::GtkAppendHelper(GtkWidget *menu, const wxString& item)
{
- GtkWidget *menu_item = gtk_menu_item_new_with_label( item.mbc_str() );
+ GtkWidget *menu_item = gtk_menu_item_new_with_label( wxGTK_CONV( item ) );
size_t index;
if ( m_strings )
size_t count = GetCount();
for ( size_t n = 0; n < count; n++ )
{
- width = (wxCoord)gdk_string_width(font, GetString(n).mbc_str());
+ // FIXME GTK 2.0
+ width = (wxCoord)gdk_string_width(font, wxGTK_CONV( GetString(n) ) );
if ( width > ret.x )
ret.x = width;
}
if ( ret.x < 80 )
ret.x = 80;
- ret.y = 16 + gdk_char_height(GET_STYLE_FONT( m_widget->style ), 'H');
+ ret.y = 16 + gdk_char_height(GET_STYLE_FONT( m_widget->style ), 'H' );
return ret;
}
{
const wchar_t *wstr = (const wchar_t *)d;
size_t len = wxConvCurrent->WC2MB(NULL, wstr, 0);
- char *str = malloc(len + 1);
+ char *str = (char*) malloc(len + 1);
wxConvCurrent->WC2MB(str, wstr, len);
str[len] = '\0';
inserting the first item */
m_alreadySent = TRUE;
- GtkWidget *list_item = gtk_list_item_new_with_label( choices[i].mbc_str() );
+ GtkWidget *list_item = gtk_list_item_new_with_label( wxGTK_CONV( choices[i] ) );
m_clientDataList.Append( (wxObject*)NULL );
m_clientObjectList.Append( (wxObject*)NULL );
GtkWidget *list = GTK_COMBO(m_widget)->list;
- GtkWidget *list_item = gtk_list_item_new_with_label( item.mbc_str() );
+ GtkWidget *list_item = gtk_list_item_new_with_label( wxGTK_CONV( item ) );
gtk_container_add( GTK_CONTAINER(list), list_item );
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
wxString tmp = wxT("");
if (!value.IsNull()) tmp = value;
- gtk_entry_set_text( GTK_ENTRY(entry), tmp.mbc_str() );
+ gtk_entry_set_text( GTK_ENTRY(entry), wxGTK_CONV( tmp ) );
}
void wxComboBox::Copy()
{
wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") );
// FIXME: not quite sure how to do this method right in multibyte mode
+ // FIXME GTK 2.0
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
gtk_editable_delete_text( GTK_EDITABLE(entry), (gint)from, (gint)to );
size_t count = Number();
for ( size_t n = 0; n < count; n++ )
{
- width = (wxCoord)gdk_string_width(font, GetString(n).mbc_str());
+ width = (wxCoord)gdk_string_width(font, wxGTK_CONV( GetString(n) ) );
if ( width > ret.x )
ret.x = width;
}
{
// the test below catches all of BOLD, EXTRABOLD, DEMIBOLD, ULTRABOLD
// and BLACK
- if ( ((w[0u] == _T('B') && (!strcmp(w.c_str() + 1, _T("OLD")) ||
- !strcmp(w.c_str() + 1, _T("LACK"))))) ||
- strstr(w.c_str() + 1, _T("BOLD")) )
+ if ( ((w[0u] == _T('B') && (!wxStrcmp(w.c_str() + 1, wxT("OLD")) ||
+ !wxStrcmp(w.c_str() + 1, wxT("LACK"))))) ||
+ wxStrstr(w.c_str() + 1, _T("BOLD")) )
{
m_weight = wxFONTWEIGHT_BOLD;
}
// "clicked" for OK-button
//-----------------------------------------------------------------------------
-#ifdef __WXGTK12__
static
void gtk_fontdialog_ok_callback( GtkWidget *WXUNUSED(widget), wxFontDialog *dialog )
{
event.SetEventObject( dialog );
dialog->GetEventHandler()->ProcessEvent( event );
}
-#endif // GTK+ 1.2 and later only
//-----------------------------------------------------------------------------
// "clicked" for Cancel-button
}
wxString m_message( _("Choose font") );
- m_widget = gtk_font_selection_dialog_new( m_message.mbc_str() );
+ m_widget = gtk_font_selection_dialog_new( wxGTK_CONV( m_message ) );
int x = (gdk_screen_width () - 400) / 2;
int y = (gdk_screen_height () - 400) / 2;
gtk_signal_connect( GTK_OBJECT(sel->ok_button), "clicked",
GTK_SIGNAL_FUNC(gtk_fontdialog_ok_callback), (gpointer*)this );
+#ifndef __WXGTK20__
// strange way to internationalize
- gtk_label_set( GTK_LABEL( BUTTON_CHILD(sel->ok_button) ), wxConvCurrent->cWX2MB(_("OK")) );
+ gtk_label_set( GTK_LABEL( BUTTON_CHILD(sel->ok_button) ), _("OK") );
+#endif
gtk_signal_connect( GTK_OBJECT(sel->cancel_button), "clicked",
GTK_SIGNAL_FUNC(gtk_fontdialog_cancel_callback), (gpointer*)this );
+#ifndef __WXGTK20__
// strange way to internationalize
- gtk_label_set( GTK_LABEL( BUTTON_CHILD(sel->cancel_button) ), wxConvCurrent->cWX2MB(_("Cancel")) );
+ gtk_label_set( GTK_LABEL( BUTTON_CHILD(sel->cancel_button) ), _("Cancel") );
+#endif
gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event",
GTK_SIGNAL_FUNC(gtk_fontdialog_delete_callback), (gpointer)this );
{
wxString dev_name;
// Assume it's the same device name on all Linux systems ...
- dev_name.Printf("/dev/js%d", (joystick == wxJOYSTICK1) ? 0 : 1);
+ dev_name.Printf( wxT("/dev/js%d"), (joystick == wxJOYSTICK1) ? 0 : 1); // FIXME Unicode?
- m_joystick = open(dev_name, O_RDWR);
+ m_joystick = open(dev_name.fn_str(), O_RDWR);
m_lastposition = wxPoint(-1, -1);
for (int i=0;i<15;i++)
m_axe[i] = 0;
int fd, j;
for (j=0;j<2;j++) {
- dev_name.Printf("/dev/js%d", j);
- fd = open(dev_name, O_RDONLY);
+ dev_name.Printf(wxT("/dev/js%d"), j);
+ fd = open(dev_name.fn_str(), O_RDONLY);
if (fd == -1)
return j;
close(fd);
#include "wx/intl.h"
#include "wx/checklst.h"
#include "wx/settings.h"
+#include "wx/gtk/private.h"
#if wxUSE_TOOLTIPS
#include "wx/tooltip.h"
}
#endif // wxUSE_CHECKLISTBOX
- list_item = gtk_list_item_new_with_label( label.mbc_str() );
+ list_item = gtk_list_item_new_with_label( wxGTK_CONV( label ) );
GList *gitem_list = g_list_alloc ();
gitem_list->data = list_item;
#endif // wxUSE_CHECKLISTBOX
str += string;
- gtk_label_set( label, str.mbc_str() );
+ gtk_label_set( label, wxGTK_CONV( str ) );
}
else
{
GtkBin *bin = GTK_BIN( child->data );
GtkLabel *label = GTK_LABEL( bin->child );
- wxString str = wxString(GET_REAL_LABEL(label->label),*wxConvCurrent);
+ wxString str = wxGTK_CONV_BACK( GET_REAL_LABEL(label->label) );
return str;
}
GtkBin *bin = GTK_BIN( child->data );
GtkLabel *label = GTK_LABEL( bin->child );
- wxString str = wxString(GET_REAL_LABEL(label->label),*wxConvCurrent);
+ wxString str = wxGTK_CONV_BACK( GET_REAL_LABEL(label->label) );
if (str == item)
return count;
#include "wx/dialog.h"
#include "wx/menu.h"
#include "wx/intl.h"
+#include "wx/gtk/private.h"
#include <glib.h>
#include <gdk/gdk.h>
wxMDIParentFrame* parent = (wxMDIParentFrame*) GetParent();
GtkNotebook* notebook = GTK_NOTEBOOK(parent->m_widget);
- gtk_notebook_set_tab_label_text(notebook, m_widget, title.mbc_str());
+ gtk_notebook_set_tab_label_text(notebook, m_widget, wxGTK_CONV( title ) );
}
//-----------------------------------------------------------------------------
{
menu->SetInvokingWindow( (wxWindow*) NULL );
-#if GTK_CHECK_VERSION(1, 2, 0)
wxWindow *top_frame = win;
while (top_frame->GetParent() && !(top_frame->IsTopLevel()))
top_frame = top_frame->GetParent();
- /* support for native hot keys */
+ /* support for native hot keys */
gtk_accel_group_detach( menu->m_accel, ACCEL_OBJ_CAST(top_frame->m_widget) );
-#endif
wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst();
while (node)
/* GTK 1.2.0 doesn't have gtk_item_factory_get_item(), but GTK 1.2.1 has. */
#if GTK_CHECK_VERSION(1, 2, 1)
- /* local buffer in multibyte form */
wxString buf;
buf << wxT('/') << str.c_str();
- char *cbuf = new char[buf.Length()+1];
- strcpy(cbuf, buf.mbc_str());
+ /* local buffer in multibyte form */
+ char cbuf[400];
+ strcpy(cbuf, wxGTK_CONV(buf) );
GtkItemFactoryEntry entry;
entry.path = (gchar *)cbuf; // const_cast
pc++;
tmp << *pc;
}
- menu->m_owner = gtk_item_factory_get_item( m_factory, tmp.mb_str() );
+ menu->m_owner = gtk_item_factory_get_item( m_factory, wxGTK_CONV( tmp ) );
gtk_menu_item_set_submenu( GTK_MENU_ITEM(menu->m_owner), menu->m_menu );
- delete [] cbuf;
#else
- menu->m_owner = gtk_menu_item_new_with_label( str.mb_str() );
+ menu->m_owner = gtk_menu_item_new_with_label( wxGTK_CONV( str ) );
gtk_widget_show( menu->m_owner );
gtk_menu_item_set_submenu( GTK_MENU_ITEM(menu->m_owner), menu->m_menu );
if ( !wxMenuBarBase::Insert(pos, menu, title) )
return FALSE;
-#if __WXGTK12__
// GTK+ doesn't have a function to insert a menu using GtkItemFactory (as
// of version 1.2.6), so we first append the item and then change its
// index
menu_shell->children = g_list_insert(menu_shell->children, data, pos);
return TRUE;
-#else // GTK < 1.2
- // this should be easy to do with GTK 1.0 - can use standard functions for
- // this and don't need any hacks like above, but as I don't have GTK 1.0
- // any more I can't do it
- wxFAIL_MSG( wxT("TODO") );
-
- return FALSE;
-#endif // GTK 1.2/1.0
}
wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title)
wxString label;
wxString text( menu->GetTitle() );
-#if GTK_CHECK_VERSION(1, 2, 0)
for ( const wxChar *pc = text.c_str(); *pc; pc++ )
{
if ( *pc == wxT('_') || *pc == wxT('&') )
label += *pc;
}
-#else // GTK+ 1.0
- label = text;
-#endif // GTK+ 1.2/1.0
return label;
}
GtkLabel *label = GTK_LABEL( GTK_BIN(menu->m_owner)->child );
/* set new text */
- gtk_label_set( label, str.mb_str());
+ gtk_label_set( label, wxGTK_CONV( str ) );
/* reparse key accel */
- (void)gtk_label_parse_uline (GTK_LABEL(label), str.mb_str() );
+ (void)gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV( str ) );
gtk_accel_label_refetch( GTK_ACCEL_LABEL(label) );
}
label = GTK_LABEL( GTK_BIN(m_menuItem)->child );
/* set new text */
- gtk_label_set( label, m_text.mb_str());
+ gtk_label_set( label, wxGTK_CONV( m_text ) );
/* reparse key accel */
- (void)gtk_label_parse_uline (GTK_LABEL(label), m_text.mb_str() );
+ (void)gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV( m_text ) );
gtk_accel_label_refetch( GTK_ACCEL_LABEL(label) );
}
}
m_text << *pc;
}
- /* only GTK 1.2 knows about hot keys */
m_hotKey = wxT("");
-#if GTK_CHECK_VERSION(1, 2, 0)
if(*pc == wxT('\t'))
{
pc++;
m_hotKey = pc;
}
-#endif // GTK+ 1.2.0+
}
#if wxUSE_ACCEL
void wxMenu::Init()
{
-#if GTK_CHECK_VERSION(1, 2, 0)
m_accel = gtk_accel_group_new();
m_factory = gtk_item_factory_new( GTK_TYPE_MENU, "<main>", m_accel );
m_menu = gtk_item_factory_get_widget( m_factory, "<main>" );
-#else
- m_menu = gtk_menu_new(); // Do not show!
-#endif
m_owner = (GtkWidget*) NULL;
-#if GTK_CHECK_VERSION(1, 2, 0)
/* Tearoffs are entries, just like separators. So if we want this
menu to be a tear-off one, we just append a tearoff entry
immediately. */
gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */
//GtkWidget *menuItem = gtk_item_factory_get_widget( m_factory, "<main>/tearoff" );
}
-#endif // GTK+ 1.2.0+
// append the title as the very first entry if we have it
if ( !!m_title )
bool appended = FALSE;
#endif
-#if GTK_CHECK_VERSION(1, 2, 0)
// does this item terminate the current radio group?
bool endOfRadioGroup = TRUE;
-#endif // GTK+ >= 1.2
if ( mitem->IsSeparator() )
{
-#if GTK_CHECK_VERSION(1, 2, 0)
GtkItemFactoryEntry entry;
entry.path = (char *)"/sep";
entry.callback = (GtkItemFactoryCallback) NULL;
// we might have a separator inside a radio group
endOfRadioGroup = FALSE;
-#else // GTK+ 1.0
- menuItem = gtk_menu_item_new();
-#endif // GTK 1.2/1.0
}
else if ( mitem->IsSubMenu() )
{
-#if GTK_CHECK_VERSION(1, 2, 0)
/* text has "_" instead of "&" after mitem->SetText() */
wxString text( mitem->GetText() );
/* local buffer in multibyte form */
char buf[200];
strcpy( buf, "/" );
- strcat( buf, text.mb_str() );
+ strcat( buf, wxGTK_CONV( text ) );
GtkItemFactoryEntry entry;
entry.path = buf;
gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */
wxString path( mitem->GetFactoryPath() );
- menuItem = gtk_item_factory_get_item( m_factory, path.mb_str() );
-#else // GTK+ 1.0
- menuItem = gtk_menu_item_new_with_label(mitem->GetText().mbc_str());
-#endif // GTK 1.2/1.0
+ menuItem = gtk_item_factory_get_item( m_factory, wxGTK_CONV( path ) );
gtk_menu_item_set_submenu( GTK_MENU_ITEM(menuItem), mitem->GetSubMenu()->m_menu );
const wxBitmap *bitmap = &mitem->GetBitmap();
menuItem = gtk_pixmap_menu_item_new ();
- GtkWidget *label = gtk_accel_label_new (text.mb_str());
+ GtkWidget *label = gtk_accel_label_new ( wxGTK_CONV( text ) );
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_container_add (GTK_CONTAINER (menuItem), label);
- guint accel_key = gtk_label_parse_uline (GTK_LABEL(label), text.mb_str() );
+ guint accel_key = gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV( text ) );
gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (label), menuItem);
if (accel_key != GDK_VoidSymbol)
{
#endif // USE_MENU_BITMAPS
else // a normal item
{
-#if GTK_CHECK_VERSION(1, 2, 0)
/* text has "_" instead of "&" after mitem->SetText() */
wxString text( mitem->GetText() );
/* local buffer in multibyte form */
char buf[200];
strcpy( buf, "/" );
- strncat( buf, text.mb_str(), WXSIZEOF(buf) - 2 );
+ strncat( buf, wxGTK_CONV(text), WXSIZEOF(buf) - 2 );
buf[WXSIZEOF(buf) - 1] = '\0';
GtkItemFactoryEntry entry;
entry.callback_action = 0;
wxString pathRadio;
+ char buf2[200];
const char *item_type;
switch ( mitem->GetKind() )
{
else // continue the radio group
{
pathRadio = m_pathLastRadio;
- pathRadio.Replace("_", "");
- pathRadio.Prepend("<main>/");
- item_type = pathRadio;
+ pathRadio.Replace(wxT("_"), wxT(""));
+ pathRadio.Prepend(wxT("<main>/"));
+ strncat( buf2, wxGTK_CONV(pathRadio), WXSIZEOF(buf2) - 2 );
+ buf2[WXSIZEOF(buf2) - 1] = '\0';
+ item_type = buf2;
}
// continue the existing radio group, if any
// due to an apparent bug in GTK+, we have to use a static buffer here -
// otherwise GTK+ 1.2.2 manages to override the memory we pass to it
// somehow! (VZ)
- static char s_accel[50]; // must be big enougg
+ static char s_accel[50]; // must be big enough
wxString tmp( GetHotKey(*mitem) );
- strncpy(s_accel, tmp.mb_str(), WXSIZEOF(s_accel));
+ strncpy(s_accel, wxGTK_CONV( tmp ), WXSIZEOF(s_accel));
entry.accelerator = s_accel;
#else // !wxUSE_ACCEL
entry.accelerator = (char*) NULL;
gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */
wxString path( mitem->GetFactoryPath() );
- menuItem = gtk_item_factory_get_widget( m_factory, path.mb_str() );
-#else // GTK+ 1.0
- menuItem = checkable ? gtk_check_menu_item_new_with_label( mitem->GetText().mb_str() )
- : gtk_menu_item_new_with_label( mitem->GetText().mb_str() );
-
- gtk_signal_connect( GTK_OBJECT(menuItem), "activate",
- GTK_SIGNAL_FUNC(gtk_menu_clicked_callback),
- (gpointer)this );
-#endif // GTK+ 1.2/1.0
+ menuItem = gtk_item_factory_get_widget( m_factory, wxGTK_CONV( path ) );
}
if ( !mitem->IsSeparator() )
(gpointer)this );
}
-#if !GTK_CHECK_VERSION(1, 2, 0)
- if (!appended)
- {
- gtk_menu_append( GTK_MENU(m_menu), menuItem );
- gtk_widget_show( menuItem );
- }
-#endif // GTK+ 1.0
-
mitem->SetMenuItem(menuItem);
-#if GTK_CHECK_VERSION(1, 2, 0)
if ( endOfRadioGroup )
{
m_pathLastRadio.clear();
}
-#endif // GTK+ >= 1.2
return TRUE;
}
#include "gtk/gtk.h"
#include "wx/gtk/win_gtk.h"
+#include "wx/gtk/private.h"
#include <gdk/gdk.h>
#include <gdk/gdkprivate.h>
gdk_draw_string( pizza->bin_window, font, gc,
6,
3+font->ascent,
- win->m_title.mb_str() );
+ wxGTK_CONV( win->m_title ) );
gdk_gc_unref( gc );
}
gdk_draw_string( pizza->bin_window, font, gc,
6,
3+font->ascent,
- win->m_title.mb_str() );
+ wxGTK_CONV( win->m_title ) );
gdk_gc_unref( gc );
}
nb_page->m_text = text;
- gtk_label_set( nb_page->m_label, nb_page->m_text.mbc_str() );
+ gtk_label_set( nb_page->m_label, wxGTK_CONV( nb_page->m_text ) );
return TRUE;
}
page->m_text = text;
if (page->m_text.IsEmpty()) page->m_text = wxT("");
- page->m_label = GTK_LABEL( gtk_label_new(page->m_text.mbc_str()) );
+ page->m_label = GTK_LABEL( gtk_label_new( wxGTK_CONV( page->m_text ) ) );
gtk_box_pack_end( GTK_BOX(page->m_box), GTK_WIDGET(page->m_label), FALSE, FALSE, 3 );
/* show the label */
return FALSE;
}
- m_widget = gtk_frame_new( title.mbc_str() );
+ m_widget = gtk_frame_new( wxGTK_CONV( title ) );
// majorDim may be 0 if all trailing parameters were omitted, so don't
// assert here but just use the correct value for it
label += *pc;
}
- m_radio = GTK_RADIO_BUTTON( gtk_radio_button_new_with_label( radio_button_group, label.mbc_str() ) );
+ m_radio = GTK_RADIO_BUTTON( gtk_radio_button_new_with_label( radio_button_group, wxGTK_CONV( label ) ) );
gtk_signal_connect( GTK_OBJECT(m_radio), "key_press_event",
GTK_SIGNAL_FUNC(gtk_radiobox_keypress_callback), (gpointer)this );
wxControl::SetLabel( label );
- gtk_frame_set_label( GTK_FRAME(m_widget), wxControl::GetLabel().mbc_str() );
+ gtk_frame_set_label( GTK_FRAME(m_widget), wxGTK_CONV( wxControl::GetLabel() ) );
}
void wxRadioBox::SetString( int item, const wxString& label )
GtkLabel *g_label = GTK_LABEL( BUTTON_CHILD(node->Data()) );
- gtk_label_set( g_label, label.mbc_str() );
+ gtk_label_set( g_label, wxGTK_CONV( label ) );
}
bool wxRadioBox::Enable( bool enable )
}
}
- m_widget = gtk_radio_button_new_with_label( m_radioButtonGroup, label.mbc_str() );
+ m_widget = gtk_radio_button_new_with_label( m_radioButtonGroup, wxGTK_CONV( label ) );
SetLabel(label);
wxControl::SetLabel( label );
GtkLabel *g_label = GTK_LABEL( BUTTON_CHILD(m_widget) );
- gtk_label_set( g_label, GetLabel().mbc_str() );
+ gtk_label_set( g_label, wxGTK_CONV( GetLabel() ) );
}
void wxRadioButton::SetValue( bool val )
{
// invalid number - set text as is (wxMSW compatible)
GtkDisableEvents();
- gtk_entry_set_text( GTK_ENTRY(m_widget), value.mbc_str() );
+ gtk_entry_set_text( GTK_ENTRY(m_widget), wxGTK_CONV( value ) );
GtkEnableEvents();
}
}
#if wxUSE_STATBOX
#include "wx/statbox.h"
+#include "wx/gtk/private.h"
#include "gdk/gdk.h"
#include "gtk/gtk.h"
wxControl::SetLabel(label);
- m_widget = gtk_frame_new(m_label.empty() ? (char *)NULL : m_label.mbc_str());
+ m_widget = gtk_frame_new(m_label.empty() ? (char *)NULL : (const char*) wxGTK_CONV( m_label ) );
m_parent->DoAddChild( this );
wxControl::SetLabel( label );
gtk_frame_set_label( GTK_FRAME( m_widget ),
- m_label.empty() ? (char *)NULL : m_label.mbc_str() );
+ m_label.empty() ? (char *)NULL : (const char*) wxGTK_CONV( m_label ) );
}
void wxStaticBox::ApplyWidgetStyle()
#if wxUSE_STATTEXT
#include "wx/stattext.h"
+#include "wx/gtk/private.h"
#include "gdk/gdk.h"
#include "gtk/gtk.h"
widget,
tool->GetLabel().empty()
? NULL
- : tool->GetLabel().mbc_str(),
+ : (const char*) wxGTK_CONV( tool->GetLabel() ),
tool->GetShortHelp().empty()
? NULL
- : tool->GetShortHelp().mbc_str(),
+ : (const char*) wxGTK_CONV( tool->GetShortHelp() ),
"", // tooltip_private_text (?)
tool->m_pixmap,
(GtkSignalFunc)gtk_toolbar_callback,
void wxToolBar::DoEnableTool(wxToolBarToolBase *toolBase, bool enable)
{
-#if (GTK_MINOR_VERSION > 0)
wxToolBarTool *tool = (wxToolBarTool *)toolBase;
- /* we don't disable the tools for GTK 1.0 as the bitmaps don't get
- greyed anyway and this also disables tooltips */
if (tool->m_item)
+ {
gtk_widget_set_sensitive( tool->m_item, enable );
-#endif
+ }
}
void wxToolBar::DoToggleTool( wxToolBarToolBase *toolBase, bool toggle )
{
(void)tool->SetShortHelp(helpString);
gtk_tooltips_set_tip(m_toolbar->tooltips, tool->m_item,
- helpString.mbc_str(), "");
+ wxGTK_CONV( helpString ), "");
}
}
#include "wx/log.h"
#include "wx/settings.h"
#include "wx/panel.h"
+#include "wx/strconv.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <ctype.h>
#include <math.h> // for fabs
-// TODO: reimplement wxTextCtrl using GtkTextView
-#ifdef __WXGTK20__
- #define GTK_ENABLE_BROKEN // need this to get GtkText at all
-#endif // __WXGTK20__
-
#include "wx/gtk/private.h"
#include <gdk/gdkkeysyms.h>
const char *txt,
size_t len)
{
+#ifndef __WXGTK__
GdkFont *font = attr.HasFont() ? attr.GetFont().GetInternalFont()
: NULL;
: NULL;
gtk_text_insert( GTK_TEXT(text), font, colFg, colBg, txt, len );
+#endif
}
// ----------------------------------------------------------------------------
if (g_isIdle)
wxapp_install_idle_handler();
-
+
win->SetModified();
win->UpdateFontIfNeeded();
-
+
wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, win->GetId() );
event.SetEventObject( win );
event.SetString( win->GetValue() );
// "changed" from vertical scrollbar
//-----------------------------------------------------------------------------
+#ifndef __WXGTK20__
static void
gtk_scrollbar_changed_callback( GtkWidget *WXUNUSED(widget), wxTextCtrl *win )
{
win->CalculateScrollbar();
}
+#endif
// ----------------------------------------------------------------------------
// redraw callback for multiline text
m_vScrollbarVisible = FALSE;
bool multi_line = (style & wxTE_MULTILINE) != 0;
+
+#ifdef __WXGTK20__
+ GtkTextBuffer *buffer = NULL;
+#endif
+
if (multi_line)
{
-#ifdef __WXGTK13__
- /* a multi-line edit control: create a vertical scrollbar by default and
- horizontal if requested */
- bool bHasHScrollbar = (style & wxHSCROLL) != 0;
-#else
- bool bHasHScrollbar = FALSE;
-#endif
+#ifdef __WXGTK20__
+ // Create view
+ m_text = gtk_text_view_new();
+
+ buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_text) );
+
+ // create scrolled window
+ m_widget = gtk_scrolled_window_new( NULL, NULL );
+ gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( m_widget ),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
+
+ // Insert view into scrolled window
+ gtk_container_add( GTK_CONTAINER(m_widget), m_text );
+
+ // Global settings which can be overridden by tags, I guess.
+ if (HasFlag( wxHSCROLL ))
+ gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW( m_text ), GTK_WRAP_NONE );
+ else
+ gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW( m_text ), GTK_WRAP_WORD );
- /* create our control ... */
+ if (!HasFlag(wxNO_BORDER))
+ gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW(m_widget), GTK_SHADOW_IN );
+#else
+ // create our control ...
m_text = gtk_text_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL );
- /* ... and put into the upper left hand corner of the table */
+ // ... and put into the upper left hand corner of the table
+ bool bHasHScrollbar = FALSE;
m_widget = gtk_table_new(bHasHScrollbar ? 2 : 1, 2, FALSE);
GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
gtk_table_attach( GTK_TABLE(m_widget), m_text, 0, 1, 0, 1,
(GtkAttachOptions)(GTK_FILL | GTK_EXPAND | GTK_SHRINK),
0, 0);
- /* always wrap words */
+ // always wrap words
gtk_text_set_word_wrap( GTK_TEXT(m_text), TRUE );
-#ifdef __WXGTK13__
- /* put the horizontal scrollbar in the lower left hand corner */
- if (bHasHScrollbar)
- {
- GtkWidget *hscrollbar = gtk_hscrollbar_new(GTK_TEXT(m_text)->hadj);
- GTK_WIDGET_UNSET_FLAGS( hscrollbar, GTK_CAN_FOCUS );
- gtk_table_attach(GTK_TABLE(m_widget), hscrollbar, 0, 1, 1, 2,
- (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK),
- GTK_FILL,
- 0, 0);
- gtk_widget_show(hscrollbar);
-
- /* don't wrap lines, otherwise we wouldn't need the scrollbar */
- gtk_text_set_line_wrap( GTK_TEXT(m_text), FALSE );
- }
-#endif
-
- /* finally, put the vertical scrollbar in the upper right corner */
+ // finally, put the vertical scrollbar in the upper right corner
m_vScrollbar = gtk_vscrollbar_new( GTK_TEXT(m_text)->vadj );
GTK_WIDGET_UNSET_FLAGS( m_vScrollbar, GTK_CAN_FOCUS );
gtk_table_attach(GTK_TABLE(m_widget), m_vScrollbar, 1, 2, 0, 1,
GTK_FILL,
(GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK),
0, 0);
+#endif
}
else
{
- /* a single-line text control: no need for scrollbars */
+ // a single-line text control: no need for scrollbars
m_widget =
m_text = gtk_entry_new();
}
if (multi_line)
gtk_widget_show(m_text);
+#ifndef __WXGTK20__
if (multi_line)
{
gtk_signal_connect(GTK_OBJECT(GTK_TEXT(m_text)->vadj), "changed",
(GtkSignalFunc) gtk_scrollbar_changed_callback, (gpointer) this );
-#ifndef __WXGTK20__
// only initialize gs_gtk_text_draw once, starting from the next the
// klass::draw will already be wxgtk_text_draw
if ( !gs_gtk_text_draw )
draw = wxgtk_text_draw;
}
-#endif // GTK+ 1.x
}
+#endif // GTK+ 1.x
if (!value.IsEmpty())
{
- gint tmp = 0;
+#ifdef __WXGTK20__
+ SetValue( value );
+#else
#if !GTK_CHECK_VERSION(1, 2, 0)
// if we don't realize it, GTK 1.0.6 dies with a SIGSEGV in
gtk_widget_realize(m_text);
#endif // GTK 1.0
+ gint tmp = 0;
#if wxUSE_UNICODE
wxWX2MBbuf val = value.mbc_str();
gtk_editable_insert_text( GTK_EDITABLE(m_text), val, strlen(val), &tmp );
-#else // !Unicode
+#else
gtk_editable_insert_text( GTK_EDITABLE(m_text), value, value.Length(), &tmp );
-#endif // Unicode/!Unicode
+#endif
if (multi_line)
{
- /* bring editable's cursor uptodate. bug in GTK. */
+ // Bring editable's cursor uptodate. Bug in GTK.
SET_EDITABLE_POS(m_text, gtk_text_get_point( GTK_TEXT(m_text) ));
}
+
+#endif
}
if (style & wxTE_PASSWORD)
{
if (!multi_line)
gtk_entry_set_editable( GTK_ENTRY(m_text), FALSE );
+#ifdef __WXGTK20__
+ else
+ gtk_text_view_set_editable( GTK_TEXT_VIEW( m_text), FALSE);
+ }
+#else
}
else
{
if (multi_line)
gtk_text_set_editable( GTK_TEXT(m_text), 1 );
}
+#endif
- /* we want to be notified about text changes */
+ // We want to be notified about text changes.
+#ifdef __WXGTK20__
+ if (multi_line)
+ {
+ g_signal_connect( G_OBJECT(buffer), "changed",
+ GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);
+ }
+ else
+#endif
+ {
gtk_signal_connect( GTK_OBJECT(m_text), "changed",
- GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);
+ GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);
+ }
- /* we don't set a valid background colour, because the window
- manager should use a default one */
+ // we don't set a valid background colour, because the window
+ // manager should use a default one
m_backgroundColour = wxColour();
wxColour colFg = parent->GetForegroundColour();
m_cursor = wxCursor( wxCURSOR_IBEAM );
+#ifndef __WXGTK20__
wxTextAttr attrDef( colFg, m_backgroundColour, parent->GetFont() );
SetDefaultStyle( attrDef );
+#endif
Show( TRUE );
void wxTextCtrl::CalculateScrollbar()
{
+#ifndef __WXGTK20__
if ((m_windowStyle & wxTE_MULTILINE) == 0) return;
GtkAdjustment *adj = GTK_TEXT(m_text)->vadj;
m_vScrollbarVisible = TRUE;
}
}
+#endif
}
wxString wxTextCtrl::GetValue() const
wxString tmp;
if (m_windowStyle & wxTE_MULTILINE)
{
+#ifdef __WXGTK20__
+ GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_text) );
+
+ GtkTextIter start;
+ gtk_text_buffer_get_start_iter( text_buffer, &start );
+ GtkTextIter end;
+ gtk_text_buffer_get_end_iter( text_buffer, &end );
+ gchar *text = gtk_text_buffer_get_text( text_buffer, &start, &end, TRUE );
+
+#if wxUSE_UNICODE
+ wxWCharBuffer buffer( wxConvUTF8.cMB2WX( text ) );
+#else
+ wxCharBuffer buffer( wxConvLocal.cWC2WX( wxConvUTF8.cMB2WC( text ) ) );
+#endif
+ tmp = buffer;
+
+ g_free( text );
+#else
gint len = gtk_text_get_length( GTK_TEXT(m_text) );
char *text = gtk_editable_get_chars( GTK_EDITABLE(m_text), 0, len );
- tmp = wxString(text,*wxConvCurrent);
+ tmp = text;
g_free( text );
+#endif
}
else
{
- tmp = wxString(gtk_entry_get_text( GTK_ENTRY(m_text) ),*wxConvCurrent);
+ tmp = wxGTK_CONV_BACK( gtk_entry_get_text( GTK_ENTRY(m_text) ) );
}
+
return tmp;
}
if (m_windowStyle & wxTE_MULTILINE)
{
+#ifdef __WXGTK20__
+
+#if wxUSE_UNICODE
+ wxCharBuffer buffer( wxConvUTF8.cWX2MB( value) );
+#else
+ wxCharBuffer buffer( wxConvUTF8.cWC2MB( wxConvLocal.cWX2WC( value ) ) );
+#endif
+ GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_text) );
+ gtk_text_buffer_set_text( text_buffer, buffer, strlen(buffer) );
+
+#else
gint len = gtk_text_get_length( GTK_TEXT(m_text) );
gtk_editable_delete_text( GTK_EDITABLE(m_text), 0, len );
len = 0;
-#if wxUSE_UNICODE
- wxWX2MBbuf tmpbuf = value.mbc_str();
- gtk_editable_insert_text( GTK_EDITABLE(m_text), tmpbuf, strlen(tmpbuf), &len );
-#else
gtk_editable_insert_text( GTK_EDITABLE(m_text), value.mbc_str(), value.Length(), &len );
#endif
}
else
{
- gtk_entry_set_text( GTK_ENTRY(m_text), value.mbc_str() );
+ gtk_entry_set_text( GTK_ENTRY(m_text), wxGTK_CONV( value ) );
}
// GRG, Jun/2000: Changed this after a lot of discussion in
// the lists. wxWindows 2.2 will have a set of flags to
// customize this behaviour.
SetInsertionPoint(0);
-
+
m_modified = FALSE;
}
if ( text.empty() )
return;
-#if wxUSE_UNICODE
- wxWX2MBbuf buf = text.mbc_str();
- const char *txt = buf;
- size_t txtlen = strlen(buf);
-#else
- const char *txt = text;
- size_t txtlen = text.length();
-#endif
-
if ( m_windowStyle & wxTE_MULTILINE )
{
+#ifdef __WXGTK20__
+
+#if wxUSE_UNICODE
+ wxCharBuffer buffer( wxConvUTF8.cWX2MB( text ) );
+#else
+ wxCharBuffer buffer( wxConvUTF8.cWC2MB( wxConvLocal.cWX2WC( text ) ) );
+#endif
+ GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_text) );
+ gtk_text_buffer_insert_at_cursor( text_buffer, buffer, strlen(buffer) );
+
+#else
// After cursor movements, gtk_text_get_point() is wrong by one.
gtk_text_set_point( GTK_TEXT(m_text), GET_EDITABLE_POS(m_text) );
// always use m_defaultStyle, even if it is empty as otherwise
// resetting the style and appending some more text wouldn't work: if
// we don't specify the style explicitly, the old style would be used
- wxGtkTextInsert(m_text, m_defaultStyle, txt, txtlen);
+ wxGtkTextInsert(m_text, m_defaultStyle, text.c_str(), text.Len());
// Bring editable's cursor back uptodate.
SET_EDITABLE_POS(m_text, gtk_text_get_point( GTK_TEXT(m_text) ));
+#endif
}
else // single line
{
// This moves the cursor pos to behind the inserted text.
gint len = GET_EDITABLE_POS(m_text);
- gtk_editable_insert_text( GTK_EDITABLE(m_text), txt, txtlen, &len );
+
+#ifdef __WXGTK20__
+
+#if wxUSE_UNICODE
+ wxCharBuffer buffer( wxConvUTF8.cWX2MB( text ) );
+#else
+ wxCharBuffer buffer( wxConvUTF8.cWC2MB( wxConvLocal.cWX2WC( text ) ) );
+#endif
+ gtk_editable_insert_text( GTK_EDITABLE(m_text), buffer, strlen(buffer), &len );
+
+#else
+ gtk_editable_insert_text( GTK_EDITABLE(m_text), text.c_str(), text.Len(), &len );
+#endif
// Bring editable's cursor uptodate.
len += text.Len();
{
if (m_windowStyle & wxTE_MULTILINE)
{
+#ifndef __WXGTK20__
gint len = gtk_text_get_length( GTK_TEXT(m_text) );
char *text = gtk_editable_get_chars( GTK_EDITABLE(m_text), 0, len );
return buf;
}
else
+#endif
{
return wxEmptyString;
}
{
if (m_windowStyle & wxTE_MULTILINE)
{
+#ifdef __WXGTK20__
+ GtkTextBuffer *buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_text) );
+
+ return gtk_text_buffer_get_line_count( buffer );
+#else
gint len = gtk_text_get_length( GTK_TEXT(m_text) );
char *text = gtk_editable_get_chars( GTK_EDITABLE(m_text), 0, len );
{
return 0;
}
+#endif
}
else
{
if (m_windowStyle & wxTE_MULTILINE)
{
- /* seems to be broken in GTK 1.0.X:
- gtk_text_set_point( GTK_TEXT(m_text), (int)pos ); */
-
+#ifdef __WXGTK20__
+ GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_text) );
+ GtkTextIter iter;
+ gtk_text_buffer_get_iter_at_offset( text_buffer, &iter, pos );
+ gtk_text_buffer_place_cursor( text_buffer, &iter );
+#else
gtk_signal_disconnect_by_func( GTK_OBJECT(m_text),
GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);
/* we fake a set_point by inserting and deleting. as the user
- isn't supposed to get to know about thos non-sense, we
+ isn't supposed to get to know about this non-sense, we
disconnect so that no events are sent to the user program. */
gint tmp = (gint)pos;
gtk_signal_connect( GTK_OBJECT(m_text), "changed",
GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);
- /* bring editable's cursor uptodate. another bug in GTK. */
-
+ // bring editable's cursor uptodate. Bug in GTK.
SET_EDITABLE_POS(m_text, gtk_text_get_point( GTK_TEXT(m_text) ));
+#endif
}
else
{
gtk_entry_set_position( GTK_ENTRY(m_text), (int)pos );
- /* bring editable's cursor uptodate. bug in GTK. */
-
+ // Bring editable's cursor uptodate. Bug in GTK.
SET_EDITABLE_POS(m_text, (guint32)pos);
}
}
wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
if (m_windowStyle & wxTE_MULTILINE)
+ {
+#ifdef __WXGTK20__
+ GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_text) );
+ GtkTextIter end;
+ gtk_text_buffer_get_end_iter( text_buffer, &end );
+ gtk_text_buffer_place_cursor( text_buffer, &end );
+#else
SetInsertionPoint(gtk_text_get_length(GTK_TEXT(m_text)));
+#endif
+ }
else
+ {
gtk_entry_set_position( GTK_ENTRY(m_text), -1 );
+ }
}
void wxTextCtrl::SetEditable( bool editable )
wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
if (m_windowStyle & wxTE_MULTILINE)
+ {
+#ifdef __WXGTK20__
+ gtk_text_view_set_editable( GTK_TEXT_VIEW(m_text), editable );
+#else
gtk_text_set_editable( GTK_TEXT(m_text), editable );
+#endif
+ }
else
+ {
gtk_entry_set_editable( GTK_ENTRY(m_text), editable );
+ }
}
bool wxTextCtrl::Enable( bool enable )
if (m_windowStyle & wxTE_MULTILINE)
{
+#ifdef __WXGTK20__
+ SetEditable( enable );
+#else
gtk_text_set_editable( GTK_TEXT(m_text), enable );
OnParentEnable(enable);
+#endif
}
else
{
{
wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
+#ifndef __WXGTK20__
if ( (m_windowStyle & wxTE_MULTILINE) &&
!GTK_TEXT(m_text)->line_start_cache )
{
wxLogDebug(_T("Can't call SetSelection() before realizing the control"));
return;
}
+#endif
- gtk_editable_select_region( GTK_EDITABLE(m_text), (gint)from, (gint)to );
+ if (m_windowStyle & wxTE_MULTILINE)
+ {
+#ifdef __WXGTK20__
+ // ????
+#else
+ gtk_editable_select_region( GTK_EDITABLE(m_text), (gint)from, (gint)to );
+#endif
+ }
+ else
+ {
+ gtk_editable_select_region( GTK_EDITABLE(m_text), (gint)from, (gint)to );
+ }
}
void wxTextCtrl::ShowPosition( long pos )
{
+#ifndef __WXGTK20__
if (m_windowStyle & wxTE_MULTILINE)
{
GtkAdjustment *vp = GTK_TEXT(m_text)->vadj;
float p = (posLine/totalLines)*(vp->upper - vp->lower) + vp->lower;
gtk_adjustment_set_value(GTK_TEXT(m_text)->vadj, p);
}
+#endif
}
long wxTextCtrl::GetInsertionPoint() const
{
wxCHECK_MSG( m_text != NULL, 0, wxT("invalid text ctrl") );
+#ifdef __WXGTK20__
+ if (m_windowStyle & wxTE_MULTILINE)
+ {
+ GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_text) );
+
+ // There is no direct accessor for the cursor, but
+ // internally, the cursor is the "mark" called
+ // "insert" in the text view's btree structure.
+
+ GtkTextMark *mark = gtk_text_buffer_get_insert( text_buffer );
+ GtkTextIter cursor;
+ gtk_text_buffer_get_iter_at_mark( text_buffer, &cursor, mark );
+
+ return gtk_text_iter_get_offset( &cursor );
+ }
+ else
+#endif
+ {
return (long) GET_EDITABLE_POS(m_text);
+ }
}
long wxTextCtrl::GetLastPosition() const
wxCHECK_MSG( m_text != NULL, 0, wxT("invalid text ctrl") );
int pos = 0;
+
if (m_windowStyle & wxTE_MULTILINE)
+ {
+#ifdef __WXGTK20__
+ GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_text) );
+ GtkTextIter end;
+ gtk_text_buffer_get_end_iter( text_buffer, &end );
+
+ pos = gtk_text_iter_get_offset( &end );
+#else
pos = gtk_text_get_length( GTK_TEXT(m_text) );
+#endif
+ }
else
+ {
pos = GTK_ENTRY(m_text)->text_length;
+ }
return (long)pos;
}
{
wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
+#ifndef __WXGTK20__
gtk_editable_delete_text( GTK_EDITABLE(m_text), (gint)from, (gint)to );
+#endif
}
void wxTextCtrl::Replace( long from, long to, const wxString &value )
{
wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
+#ifndef __WXGTK20__
gtk_editable_delete_text( GTK_EDITABLE(m_text), (gint)from, (gint)to );
if (!value.IsEmpty())
gtk_editable_insert_text( GTK_EDITABLE(m_text), value, value.Length(), &pos );
#endif
}
+#endif
}
void wxTextCtrl::Cut()
{
wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
+#ifndef __WXGTK20__
gtk_editable_cut_clipboard( GTK_EDITABLE(m_text) DUMMY_CLIPBOARD_ARG );
+#endif
}
void wxTextCtrl::Copy()
{
wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
+#ifndef __WXGTK20__
gtk_editable_copy_clipboard( GTK_EDITABLE(m_text) DUMMY_CLIPBOARD_ARG );
+#endif
}
void wxTextCtrl::Paste()
{
wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
+#ifndef __WXGTK20__
gtk_editable_paste_clipboard( GTK_EDITABLE(m_text) DUMMY_CLIPBOARD_ARG );
+#endif
}
// Undo/redo
bool wxTextCtrl::IsOwnGtkWindow( GdkWindow *window )
{
if (m_windowStyle & wxTE_MULTILINE)
+ {
+#ifdef __WXGTK20__
+ return window == gtk_text_view_get_window( GTK_TEXT_VIEW( m_text ), GTK_TEXT_WINDOW_TEXT ); // pure guesswork
+#else
return (window == GTK_TEXT(m_text)->text_area);
+#endif
+ }
else
+ {
return (window == GTK_ENTRY(m_text)->text_area);
+ }
}
// the font will change for subsequent text insertiongs
if (m_windowStyle & wxTE_MULTILINE)
{
+#ifndef __WXGTK__
GdkWindow *window = GTK_TEXT(m_text)->text_area;
if (!window)
return FALSE;
m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) );
gdk_window_set_background( window, m_backgroundColour.GetColor() );
gdk_window_clear( window );
+#endif
}
// change active background color too
with styling (FIXME) */
if ( m_windowStyle & wxTE_MULTILINE )
{
+#ifndef __WXGTK20__
if ( style.IsDefault() )
{
// nothing to do
/* does not seem to help under GTK+ 1.2 !!!
gtk_editable_set_position( GTK_EDITABLE(m_text), old_pos ); */
SetInsertionPoint( old_pos );
+#endif
return TRUE;
}
else // singe line
if (cursor.Ok())
{
+#ifndef __WXGTK20__
GdkWindow *window = (GdkWindow*) NULL;
if (HasFlag(wxTE_MULTILINE))
window = GTK_TEXT(m_text)->text_area;
window = m_widget->window;
if ((window) && !(GTK_WIDGET_NO_WINDOW(m_widget)))
gdk_window_set_cursor( window, cursor.GetCursor() );
+#endif
}
if (g_delayedFocus == this)
void wxTextCtrl::Freeze()
{
+#ifndef __WXGTK20__
if ( HasFlag(wxTE_MULTILINE) )
{
gtk_text_freeze(GTK_TEXT(m_text));
}
+#endif
}
void wxTextCtrl::Thaw()
{
+#ifndef __WXGTK20__
if ( HasFlag(wxTE_MULTILINE) )
{
GTK_TEXT(m_text)->vadj->value = 0.0;
gtk_text_thaw(GTK_TEXT(m_text));
}
+#endif
}
// ----------------------------------------------------------------------------
GtkAdjustment *wxTextCtrl::GetVAdj() const
{
+#ifdef __WXGTK20__
+ return NULL;
+#else
return HasFlag(wxTE_MULTILINE) ? GTK_TEXT(m_text)->vadj : NULL;
+#endif
}
bool wxTextCtrl::DoScroll(GtkAdjustment *adj, int diff)
{
+#ifndef __WXGTK20__
float value = adj->value + diff;
if ( value < 0 )
gtk_signal_emit_by_name(GTK_OBJECT(adj), "value_changed");
+#endif
return TRUE;
}
bool wxTextCtrl::ScrollLines(int lines)
{
+#ifdef __WXGTK20__
+ return FALSE;
+#else
GtkAdjustment *adj = GetVAdj();
if ( !adj )
return FALSE;
static const int KEY_SCROLL_PIXELS = 10;
return DoScroll(adj, lines*KEY_SCROLL_PIXELS);
+#endif
}
bool wxTextCtrl::ScrollPages(int pages)
{
+#ifdef __WXGTK20__
+ return FALSE;
+#else
GtkAdjustment *adj = GetVAdj();
if ( !adj )
return FALSE;
return DoScroll(adj, (int)ceil(pages*adj->page_increment));
+#endif
}
wxControl::SetLabel(label);
// Create the gtk widget.
- m_widget = gtk_toggle_button_new_with_label(m_label.mbc_str());
+ m_widget = gtk_toggle_button_new_with_label( wxGTK_CONV( m_label ) );
gtk_signal_connect(GTK_OBJECT(m_widget), "clicked",
GTK_SIGNAL_FUNC(gtk_togglebutton_clicked_callback),
wxControl::SetLabel(label);
- gtk_label_set(GTK_LABEL(BUTTON_CHILD(m_widget)), GetLabel().mbc_str());
+ gtk_label_set(GTK_LABEL(BUTTON_CHILD(m_widget)), wxGTK_CONV( GetLabel() ) );
}
bool wxToggleButton::Enable(bool enable /*=TRUE*/)
#include "wx/control.h"
#include "wx/app.h"
#include "wx/dcclient.h"
+#include "wx/gtk/private.h"
#include <glib.h>
#include <gdk/gdk.h>
}
if (!name.IsEmpty())
- gtk_window_set_wmclass( GTK_WINDOW(m_widget), name.mb_str(), name.mb_str() );
+ gtk_window_set_wmclass( GTK_WINDOW(m_widget), wxGTK_CONV( name ), wxGTK_CONV( name ) );
- gtk_window_set_title( GTK_WINDOW(m_widget), title.mbc_str() );
+ gtk_window_set_title( GTK_WINDOW(m_widget), wxGTK_CONV( title ) );
GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event",
static void wx_win_hints_set_layer(GtkWidget *window, int layer)
{
- XEvent xev;
- GdkWindowPrivate *priv;
- gint prev_error;
+#ifndef __WXGTK20__
+ XEvent xev;
+ GdkWindowPrivate *priv;
+ gint prev_error;
- prev_error = gdk_error_warnings;
- gdk_error_warnings = 0;
- priv = (GdkWindowPrivate*)(GTK_WIDGET(window)->window);
+ prev_error = gdk_error_warnings;
+ gdk_error_warnings = 0;
+ priv = (GdkWindowPrivate*)(GTK_WIDGET(window)->window);
- if (GTK_WIDGET_MAPPED(window))
- {
- xev.type = ClientMessage;
- xev.xclient.type = ClientMessage;
- xev.xclient.window = priv->xwindow;
- xev.xclient.message_type = gs_XA_WIN_LAYER;
- xev.xclient.format = 32;
- xev.xclient.data.l[0] = (long)layer;
- xev.xclient.data.l[1] = gdk_time_get();
+ if (GTK_WIDGET_MAPPED(window))
+ {
+ xev.type = ClientMessage;
+ xev.xclient.type = ClientMessage;
+ xev.xclient.window = priv->xwindow;
+ xev.xclient.message_type = gs_XA_WIN_LAYER;
+ xev.xclient.format = 32;
+ xev.xclient.data.l[0] = (long)layer;
+ xev.xclient.data.l[1] = gdk_time_get();
- XSendEvent(GDK_DISPLAY(), GDK_ROOT_WINDOW(), False,
- SubstructureNotifyMask, (XEvent*) &xev);
+ XSendEvent(GDK_DISPLAY(), GDK_ROOT_WINDOW(), False,
+ SubstructureNotifyMask, (XEvent*) &xev);
}
- else
+ else
{
- long data[1];
+ long data[1];
- data[0] = layer;
- XChangeProperty(GDK_DISPLAY(), priv->xwindow, gs_XA_WIN_LAYER,
- XA_CARDINAL, 32, PropModeReplace, (unsigned char *)data,
- 1);
+ data[0] = layer;
+ XChangeProperty(GDK_DISPLAY(), priv->xwindow, gs_XA_WIN_LAYER,
+ XA_CARDINAL, 32, PropModeReplace, (unsigned char *)data, 1);
}
- gdk_error_warnings = prev_error;
+ gdk_error_warnings = prev_error;
+#endif
}
bool wxTopLevelWindowGTK::ShowFullScreen(bool show, long style )
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
m_title = title;
- gtk_window_set_title( GTK_WINDOW(m_widget), title.mbc_str() );
+ gtk_window_set_title( GTK_WINDOW(m_widget), wxGTK_CONV( title ) );
}
void wxTopLevelWindowGTK::DoSetIcon( const wxIcon &icon )
#endif
#include <math.h>
+#include <ctype.h>
#include "wx/gtk/private.h"
#include <gdk/gdkprivate.h>
wxCHECK_RET( fontToUse.Ok(), wxT("invalid font") );
GdkFont *font = fontToUse.GetInternalFont( 1.0 );
- if (x) (*x) = gdk_string_width( font, string.mbc_str() );
+ if (x) (*x) = gdk_string_width( font, wxGTK_CONV( string ) );
if (y) (*y) = font->ascent + font->descent;
if (descent) (*descent) = font->descent;
if (externalLeading) (*externalLeading) = 0; // ??
// Clip to paint region in wxClientDC
m_clipPaintRegion = TRUE;
-
+
+#ifndef __WXGTK20__
if (GetThemeEnabled())
{
// find ancestor from which to steal background
}
}
else
- // if (!m_clearRegion.IsEmpty()) // always send an erase event
+#endif
+#ifdef __WXGTK20__
+ if (!m_clearRegion.IsEmpty()) // Always send an erase event under GTK 1.2
+#endif
{
wxWindowDC dc( (wxWindow*)this );
if (m_clearRegion.IsEmpty())
if (!GetEventHandler()->ProcessEvent(erase_event))
{
+#ifndef __WXGTK20__
if (!g_eraseGC)
{
g_eraseGC = gdk_gc_new( pizza->bin_window );
upd.GetX(), upd.GetY(), upd.GetWidth(), upd.GetHeight() );
upd ++;
}
+#endif
}
m_clearRegion.Clear();
}
event.SetEventObject(win);
win->GetEventHandler()->ProcessEvent(event);
-
+
if (event.MoreRequested())
needMore = TRUE;
SetLabel( label );
-#if (GTK_MINOR_VERSION > 0)
if (style & wxNO_BORDER)
gtk_button_set_relief( GTK_BUTTON(m_widget), GTK_RELIEF_NONE );
-#endif
gtk_signal_connect( GTK_OBJECT(m_widget), "clicked",
GTK_SIGNAL_FUNC(gtk_button_clicked_callback), (gpointer*)this );
wxControl::SetLabel( label );
- gtk_label_set( GTK_LABEL( BUTTON_CHILD(m_widget) ), GetLabel().mbc_str() );
+ gtk_label_set( GTK_LABEL( BUTTON_CHILD(m_widget) ), wxGTK_CONV( GetLabel() ) );
}
bool wxButton::Enable( bool enable )
// left of it
m_widgetCheckbox = gtk_check_button_new();
- m_widgetLabel = gtk_label_new(m_label.mbc_str());
+ m_widgetLabel = gtk_label_new( wxGTK_CONV( m_label ) );
gtk_misc_set_alignment(GTK_MISC(m_widgetLabel), 0.0, 0.5);
m_widget = gtk_hbox_new(FALSE, 0);
}
else
{
- m_widgetCheckbox = gtk_check_button_new_with_label( m_label.mbc_str() );
+ m_widgetCheckbox = gtk_check_button_new_with_label( wxGTK_CONV( m_label ) );
m_widgetLabel = BUTTON_CHILD( m_widgetCheckbox );
m_widget = m_widgetCheckbox;
}
wxControl::SetLabel( label );
- gtk_label_set( GTK_LABEL(m_widgetLabel), GetLabel().mbc_str() );
+ gtk_label_set( GTK_LABEL(m_widgetLabel), wxGTK_CONV( GetLabel() ) );
}
bool wxCheckBox::Enable( bool enable )
#if wxUSE_CHECKLISTBOX
#include "wx/checklst.h"
+#include "wx/gtk/private.h"
#include <gdk/gdk.h>
#include <gtk/gtk.h>
GtkBin *bin = GTK_BIN( child->data );
GtkLabel *label = GTK_LABEL( bin->child );
- wxString str = wxString(label->label,*wxConvCurrent);
+ wxString str( wxGTK_CONV_BACK( label->label ) );
return str.GetChar(1) == wxCHECKLBOX_CHECKED;
}
GtkBin *bin = GTK_BIN( child->data );
GtkLabel *label = GTK_LABEL( bin->child );
- wxString str = wxString(label->label,*wxConvCurrent);
+ wxString str( wxGTK_CONV_BACK( label->label ) );
if (check == (str.GetChar(1) == wxCHECKLBOX_CHECKED))
return;
str.SetChar( 1, check ? wxCHECKLBOX_CHECKED : wxCHECKLBOX_UNCHECKED );
- gtk_label_set( label, str.mbc_str() );
+ gtk_label_set( label, wxGTK_CONV( str ) );
return;
}
label = GTK_LABEL( BUTTON_CHILD(m_widget) );
wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") );
-
- if (string == wxString(label->label,*wxConvCurrent))
+
+ wxString tmp( wxGTK_CONV_BACK( label->label ) );
+ if (string == tmp)
return count;
child = child->next;
wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") );
- return wxString(label->label,*wxConvCurrent);
+ return wxString( wxGTK_CONV_BACK(label->label) );
}
child = child->next;
count++;
size_t wxChoice::GtkAppendHelper(GtkWidget *menu, const wxString& item)
{
- GtkWidget *menu_item = gtk_menu_item_new_with_label( item.mbc_str() );
+ GtkWidget *menu_item = gtk_menu_item_new_with_label( wxGTK_CONV( item ) );
size_t index;
if ( m_strings )
size_t count = GetCount();
for ( size_t n = 0; n < count; n++ )
{
- width = (wxCoord)gdk_string_width(font, GetString(n).mbc_str());
+ // FIXME GTK 2.0
+ width = (wxCoord)gdk_string_width(font, wxGTK_CONV( GetString(n) ) );
if ( width > ret.x )
ret.x = width;
}
if ( ret.x < 80 )
ret.x = 80;
- ret.y = 16 + gdk_char_height(GET_STYLE_FONT( m_widget->style ), 'H');
+ ret.y = 16 + gdk_char_height(GET_STYLE_FONT( m_widget->style ), 'H' );
return ret;
}
{
const wchar_t *wstr = (const wchar_t *)d;
size_t len = wxConvCurrent->WC2MB(NULL, wstr, 0);
- char *str = malloc(len + 1);
+ char *str = (char*) malloc(len + 1);
wxConvCurrent->WC2MB(str, wstr, len);
str[len] = '\0';
inserting the first item */
m_alreadySent = TRUE;
- GtkWidget *list_item = gtk_list_item_new_with_label( choices[i].mbc_str() );
+ GtkWidget *list_item = gtk_list_item_new_with_label( wxGTK_CONV( choices[i] ) );
m_clientDataList.Append( (wxObject*)NULL );
m_clientObjectList.Append( (wxObject*)NULL );
GtkWidget *list = GTK_COMBO(m_widget)->list;
- GtkWidget *list_item = gtk_list_item_new_with_label( item.mbc_str() );
+ GtkWidget *list_item = gtk_list_item_new_with_label( wxGTK_CONV( item ) );
gtk_container_add( GTK_CONTAINER(list), list_item );
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
wxString tmp = wxT("");
if (!value.IsNull()) tmp = value;
- gtk_entry_set_text( GTK_ENTRY(entry), tmp.mbc_str() );
+ gtk_entry_set_text( GTK_ENTRY(entry), wxGTK_CONV( tmp ) );
}
void wxComboBox::Copy()
{
wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") );
// FIXME: not quite sure how to do this method right in multibyte mode
+ // FIXME GTK 2.0
GtkWidget *entry = GTK_COMBO(m_widget)->entry;
gtk_editable_delete_text( GTK_EDITABLE(entry), (gint)from, (gint)to );
size_t count = Number();
for ( size_t n = 0; n < count; n++ )
{
- width = (wxCoord)gdk_string_width(font, GetString(n).mbc_str());
+ width = (wxCoord)gdk_string_width(font, wxGTK_CONV( GetString(n) ) );
if ( width > ret.x )
ret.x = width;
}
{
// the test below catches all of BOLD, EXTRABOLD, DEMIBOLD, ULTRABOLD
// and BLACK
- if ( ((w[0u] == _T('B') && (!strcmp(w.c_str() + 1, _T("OLD")) ||
- !strcmp(w.c_str() + 1, _T("LACK"))))) ||
- strstr(w.c_str() + 1, _T("BOLD")) )
+ if ( ((w[0u] == _T('B') && (!wxStrcmp(w.c_str() + 1, wxT("OLD")) ||
+ !wxStrcmp(w.c_str() + 1, wxT("LACK"))))) ||
+ wxStrstr(w.c_str() + 1, _T("BOLD")) )
{
m_weight = wxFONTWEIGHT_BOLD;
}
// "clicked" for OK-button
//-----------------------------------------------------------------------------
-#ifdef __WXGTK12__
static
void gtk_fontdialog_ok_callback( GtkWidget *WXUNUSED(widget), wxFontDialog *dialog )
{
event.SetEventObject( dialog );
dialog->GetEventHandler()->ProcessEvent( event );
}
-#endif // GTK+ 1.2 and later only
//-----------------------------------------------------------------------------
// "clicked" for Cancel-button
}
wxString m_message( _("Choose font") );
- m_widget = gtk_font_selection_dialog_new( m_message.mbc_str() );
+ m_widget = gtk_font_selection_dialog_new( wxGTK_CONV( m_message ) );
int x = (gdk_screen_width () - 400) / 2;
int y = (gdk_screen_height () - 400) / 2;
gtk_signal_connect( GTK_OBJECT(sel->ok_button), "clicked",
GTK_SIGNAL_FUNC(gtk_fontdialog_ok_callback), (gpointer*)this );
+#ifndef __WXGTK20__
// strange way to internationalize
- gtk_label_set( GTK_LABEL( BUTTON_CHILD(sel->ok_button) ), wxConvCurrent->cWX2MB(_("OK")) );
+ gtk_label_set( GTK_LABEL( BUTTON_CHILD(sel->ok_button) ), _("OK") );
+#endif
gtk_signal_connect( GTK_OBJECT(sel->cancel_button), "clicked",
GTK_SIGNAL_FUNC(gtk_fontdialog_cancel_callback), (gpointer*)this );
+#ifndef __WXGTK20__
// strange way to internationalize
- gtk_label_set( GTK_LABEL( BUTTON_CHILD(sel->cancel_button) ), wxConvCurrent->cWX2MB(_("Cancel")) );
+ gtk_label_set( GTK_LABEL( BUTTON_CHILD(sel->cancel_button) ), _("Cancel") );
+#endif
gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event",
GTK_SIGNAL_FUNC(gtk_fontdialog_delete_callback), (gpointer)this );
{
wxString dev_name;
// Assume it's the same device name on all Linux systems ...
- dev_name.Printf("/dev/js%d", (joystick == wxJOYSTICK1) ? 0 : 1);
+ dev_name.Printf( wxT("/dev/js%d"), (joystick == wxJOYSTICK1) ? 0 : 1); // FIXME Unicode?
- m_joystick = open(dev_name, O_RDWR);
+ m_joystick = open(dev_name.fn_str(), O_RDWR);
m_lastposition = wxPoint(-1, -1);
for (int i=0;i<15;i++)
m_axe[i] = 0;
int fd, j;
for (j=0;j<2;j++) {
- dev_name.Printf("/dev/js%d", j);
- fd = open(dev_name, O_RDONLY);
+ dev_name.Printf(wxT("/dev/js%d"), j);
+ fd = open(dev_name.fn_str(), O_RDONLY);
if (fd == -1)
return j;
close(fd);
#include "wx/intl.h"
#include "wx/checklst.h"
#include "wx/settings.h"
+#include "wx/gtk/private.h"
#if wxUSE_TOOLTIPS
#include "wx/tooltip.h"
}
#endif // wxUSE_CHECKLISTBOX
- list_item = gtk_list_item_new_with_label( label.mbc_str() );
+ list_item = gtk_list_item_new_with_label( wxGTK_CONV( label ) );
GList *gitem_list = g_list_alloc ();
gitem_list->data = list_item;
#endif // wxUSE_CHECKLISTBOX
str += string;
- gtk_label_set( label, str.mbc_str() );
+ gtk_label_set( label, wxGTK_CONV( str ) );
}
else
{
GtkBin *bin = GTK_BIN( child->data );
GtkLabel *label = GTK_LABEL( bin->child );
- wxString str = wxString(GET_REAL_LABEL(label->label),*wxConvCurrent);
+ wxString str = wxGTK_CONV_BACK( GET_REAL_LABEL(label->label) );
return str;
}
GtkBin *bin = GTK_BIN( child->data );
GtkLabel *label = GTK_LABEL( bin->child );
- wxString str = wxString(GET_REAL_LABEL(label->label),*wxConvCurrent);
+ wxString str = wxGTK_CONV_BACK( GET_REAL_LABEL(label->label) );
if (str == item)
return count;
#include "wx/dialog.h"
#include "wx/menu.h"
#include "wx/intl.h"
+#include "wx/gtk/private.h"
#include <glib.h>
#include <gdk/gdk.h>
wxMDIParentFrame* parent = (wxMDIParentFrame*) GetParent();
GtkNotebook* notebook = GTK_NOTEBOOK(parent->m_widget);
- gtk_notebook_set_tab_label_text(notebook, m_widget, title.mbc_str());
+ gtk_notebook_set_tab_label_text(notebook, m_widget, wxGTK_CONV( title ) );
}
//-----------------------------------------------------------------------------
{
menu->SetInvokingWindow( (wxWindow*) NULL );
-#if GTK_CHECK_VERSION(1, 2, 0)
wxWindow *top_frame = win;
while (top_frame->GetParent() && !(top_frame->IsTopLevel()))
top_frame = top_frame->GetParent();
- /* support for native hot keys */
+ /* support for native hot keys */
gtk_accel_group_detach( menu->m_accel, ACCEL_OBJ_CAST(top_frame->m_widget) );
-#endif
wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst();
while (node)
/* GTK 1.2.0 doesn't have gtk_item_factory_get_item(), but GTK 1.2.1 has. */
#if GTK_CHECK_VERSION(1, 2, 1)
- /* local buffer in multibyte form */
wxString buf;
buf << wxT('/') << str.c_str();
- char *cbuf = new char[buf.Length()+1];
- strcpy(cbuf, buf.mbc_str());
+ /* local buffer in multibyte form */
+ char cbuf[400];
+ strcpy(cbuf, wxGTK_CONV(buf) );
GtkItemFactoryEntry entry;
entry.path = (gchar *)cbuf; // const_cast
pc++;
tmp << *pc;
}
- menu->m_owner = gtk_item_factory_get_item( m_factory, tmp.mb_str() );
+ menu->m_owner = gtk_item_factory_get_item( m_factory, wxGTK_CONV( tmp ) );
gtk_menu_item_set_submenu( GTK_MENU_ITEM(menu->m_owner), menu->m_menu );
- delete [] cbuf;
#else
- menu->m_owner = gtk_menu_item_new_with_label( str.mb_str() );
+ menu->m_owner = gtk_menu_item_new_with_label( wxGTK_CONV( str ) );
gtk_widget_show( menu->m_owner );
gtk_menu_item_set_submenu( GTK_MENU_ITEM(menu->m_owner), menu->m_menu );
if ( !wxMenuBarBase::Insert(pos, menu, title) )
return FALSE;
-#if __WXGTK12__
// GTK+ doesn't have a function to insert a menu using GtkItemFactory (as
// of version 1.2.6), so we first append the item and then change its
// index
menu_shell->children = g_list_insert(menu_shell->children, data, pos);
return TRUE;
-#else // GTK < 1.2
- // this should be easy to do with GTK 1.0 - can use standard functions for
- // this and don't need any hacks like above, but as I don't have GTK 1.0
- // any more I can't do it
- wxFAIL_MSG( wxT("TODO") );
-
- return FALSE;
-#endif // GTK 1.2/1.0
}
wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title)
wxString label;
wxString text( menu->GetTitle() );
-#if GTK_CHECK_VERSION(1, 2, 0)
for ( const wxChar *pc = text.c_str(); *pc; pc++ )
{
if ( *pc == wxT('_') || *pc == wxT('&') )
label += *pc;
}
-#else // GTK+ 1.0
- label = text;
-#endif // GTK+ 1.2/1.0
return label;
}
GtkLabel *label = GTK_LABEL( GTK_BIN(menu->m_owner)->child );
/* set new text */
- gtk_label_set( label, str.mb_str());
+ gtk_label_set( label, wxGTK_CONV( str ) );
/* reparse key accel */
- (void)gtk_label_parse_uline (GTK_LABEL(label), str.mb_str() );
+ (void)gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV( str ) );
gtk_accel_label_refetch( GTK_ACCEL_LABEL(label) );
}
label = GTK_LABEL( GTK_BIN(m_menuItem)->child );
/* set new text */
- gtk_label_set( label, m_text.mb_str());
+ gtk_label_set( label, wxGTK_CONV( m_text ) );
/* reparse key accel */
- (void)gtk_label_parse_uline (GTK_LABEL(label), m_text.mb_str() );
+ (void)gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV( m_text ) );
gtk_accel_label_refetch( GTK_ACCEL_LABEL(label) );
}
}
m_text << *pc;
}
- /* only GTK 1.2 knows about hot keys */
m_hotKey = wxT("");
-#if GTK_CHECK_VERSION(1, 2, 0)
if(*pc == wxT('\t'))
{
pc++;
m_hotKey = pc;
}
-#endif // GTK+ 1.2.0+
}
#if wxUSE_ACCEL
void wxMenu::Init()
{
-#if GTK_CHECK_VERSION(1, 2, 0)
m_accel = gtk_accel_group_new();
m_factory = gtk_item_factory_new( GTK_TYPE_MENU, "<main>", m_accel );
m_menu = gtk_item_factory_get_widget( m_factory, "<main>" );
-#else
- m_menu = gtk_menu_new(); // Do not show!
-#endif
m_owner = (GtkWidget*) NULL;
-#if GTK_CHECK_VERSION(1, 2, 0)
/* Tearoffs are entries, just like separators. So if we want this
menu to be a tear-off one, we just append a tearoff entry
immediately. */
gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */
//GtkWidget *menuItem = gtk_item_factory_get_widget( m_factory, "<main>/tearoff" );
}
-#endif // GTK+ 1.2.0+
// append the title as the very first entry if we have it
if ( !!m_title )
bool appended = FALSE;
#endif
-#if GTK_CHECK_VERSION(1, 2, 0)
// does this item terminate the current radio group?
bool endOfRadioGroup = TRUE;
-#endif // GTK+ >= 1.2
if ( mitem->IsSeparator() )
{
-#if GTK_CHECK_VERSION(1, 2, 0)
GtkItemFactoryEntry entry;
entry.path = (char *)"/sep";
entry.callback = (GtkItemFactoryCallback) NULL;
// we might have a separator inside a radio group
endOfRadioGroup = FALSE;
-#else // GTK+ 1.0
- menuItem = gtk_menu_item_new();
-#endif // GTK 1.2/1.0
}
else if ( mitem->IsSubMenu() )
{
-#if GTK_CHECK_VERSION(1, 2, 0)
/* text has "_" instead of "&" after mitem->SetText() */
wxString text( mitem->GetText() );
/* local buffer in multibyte form */
char buf[200];
strcpy( buf, "/" );
- strcat( buf, text.mb_str() );
+ strcat( buf, wxGTK_CONV( text ) );
GtkItemFactoryEntry entry;
entry.path = buf;
gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */
wxString path( mitem->GetFactoryPath() );
- menuItem = gtk_item_factory_get_item( m_factory, path.mb_str() );
-#else // GTK+ 1.0
- menuItem = gtk_menu_item_new_with_label(mitem->GetText().mbc_str());
-#endif // GTK 1.2/1.0
+ menuItem = gtk_item_factory_get_item( m_factory, wxGTK_CONV( path ) );
gtk_menu_item_set_submenu( GTK_MENU_ITEM(menuItem), mitem->GetSubMenu()->m_menu );
const wxBitmap *bitmap = &mitem->GetBitmap();
menuItem = gtk_pixmap_menu_item_new ();
- GtkWidget *label = gtk_accel_label_new (text.mb_str());
+ GtkWidget *label = gtk_accel_label_new ( wxGTK_CONV( text ) );
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
gtk_container_add (GTK_CONTAINER (menuItem), label);
- guint accel_key = gtk_label_parse_uline (GTK_LABEL(label), text.mb_str() );
+ guint accel_key = gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV( text ) );
gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (label), menuItem);
if (accel_key != GDK_VoidSymbol)
{
#endif // USE_MENU_BITMAPS
else // a normal item
{
-#if GTK_CHECK_VERSION(1, 2, 0)
/* text has "_" instead of "&" after mitem->SetText() */
wxString text( mitem->GetText() );
/* local buffer in multibyte form */
char buf[200];
strcpy( buf, "/" );
- strncat( buf, text.mb_str(), WXSIZEOF(buf) - 2 );
+ strncat( buf, wxGTK_CONV(text), WXSIZEOF(buf) - 2 );
buf[WXSIZEOF(buf) - 1] = '\0';
GtkItemFactoryEntry entry;
entry.callback_action = 0;
wxString pathRadio;
+ char buf2[200];
const char *item_type;
switch ( mitem->GetKind() )
{
else // continue the radio group
{
pathRadio = m_pathLastRadio;
- pathRadio.Replace("_", "");
- pathRadio.Prepend("<main>/");
- item_type = pathRadio;
+ pathRadio.Replace(wxT("_"), wxT(""));
+ pathRadio.Prepend(wxT("<main>/"));
+ strncat( buf2, wxGTK_CONV(pathRadio), WXSIZEOF(buf2) - 2 );
+ buf2[WXSIZEOF(buf2) - 1] = '\0';
+ item_type = buf2;
}
// continue the existing radio group, if any
// due to an apparent bug in GTK+, we have to use a static buffer here -
// otherwise GTK+ 1.2.2 manages to override the memory we pass to it
// somehow! (VZ)
- static char s_accel[50]; // must be big enougg
+ static char s_accel[50]; // must be big enough
wxString tmp( GetHotKey(*mitem) );
- strncpy(s_accel, tmp.mb_str(), WXSIZEOF(s_accel));
+ strncpy(s_accel, wxGTK_CONV( tmp ), WXSIZEOF(s_accel));
entry.accelerator = s_accel;
#else // !wxUSE_ACCEL
entry.accelerator = (char*) NULL;
gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */
wxString path( mitem->GetFactoryPath() );
- menuItem = gtk_item_factory_get_widget( m_factory, path.mb_str() );
-#else // GTK+ 1.0
- menuItem = checkable ? gtk_check_menu_item_new_with_label( mitem->GetText().mb_str() )
- : gtk_menu_item_new_with_label( mitem->GetText().mb_str() );
-
- gtk_signal_connect( GTK_OBJECT(menuItem), "activate",
- GTK_SIGNAL_FUNC(gtk_menu_clicked_callback),
- (gpointer)this );
-#endif // GTK+ 1.2/1.0
+ menuItem = gtk_item_factory_get_widget( m_factory, wxGTK_CONV( path ) );
}
if ( !mitem->IsSeparator() )
(gpointer)this );
}
-#if !GTK_CHECK_VERSION(1, 2, 0)
- if (!appended)
- {
- gtk_menu_append( GTK_MENU(m_menu), menuItem );
- gtk_widget_show( menuItem );
- }
-#endif // GTK+ 1.0
-
mitem->SetMenuItem(menuItem);
-#if GTK_CHECK_VERSION(1, 2, 0)
if ( endOfRadioGroup )
{
m_pathLastRadio.clear();
}
-#endif // GTK+ >= 1.2
return TRUE;
}
#include "gtk/gtk.h"
#include "wx/gtk/win_gtk.h"
+#include "wx/gtk/private.h"
#include <gdk/gdk.h>
#include <gdk/gdkprivate.h>
gdk_draw_string( pizza->bin_window, font, gc,
6,
3+font->ascent,
- win->m_title.mb_str() );
+ wxGTK_CONV( win->m_title ) );
gdk_gc_unref( gc );
}
gdk_draw_string( pizza->bin_window, font, gc,
6,
3+font->ascent,
- win->m_title.mb_str() );
+ wxGTK_CONV( win->m_title ) );
gdk_gc_unref( gc );
}
nb_page->m_text = text;
- gtk_label_set( nb_page->m_label, nb_page->m_text.mbc_str() );
+ gtk_label_set( nb_page->m_label, wxGTK_CONV( nb_page->m_text ) );
return TRUE;
}
page->m_text = text;
if (page->m_text.IsEmpty()) page->m_text = wxT("");
- page->m_label = GTK_LABEL( gtk_label_new(page->m_text.mbc_str()) );
+ page->m_label = GTK_LABEL( gtk_label_new( wxGTK_CONV( page->m_text ) ) );
gtk_box_pack_end( GTK_BOX(page->m_box), GTK_WIDGET(page->m_label), FALSE, FALSE, 3 );
/* show the label */
return FALSE;
}
- m_widget = gtk_frame_new( title.mbc_str() );
+ m_widget = gtk_frame_new( wxGTK_CONV( title ) );
// majorDim may be 0 if all trailing parameters were omitted, so don't
// assert here but just use the correct value for it
label += *pc;
}
- m_radio = GTK_RADIO_BUTTON( gtk_radio_button_new_with_label( radio_button_group, label.mbc_str() ) );
+ m_radio = GTK_RADIO_BUTTON( gtk_radio_button_new_with_label( radio_button_group, wxGTK_CONV( label ) ) );
gtk_signal_connect( GTK_OBJECT(m_radio), "key_press_event",
GTK_SIGNAL_FUNC(gtk_radiobox_keypress_callback), (gpointer)this );
wxControl::SetLabel( label );
- gtk_frame_set_label( GTK_FRAME(m_widget), wxControl::GetLabel().mbc_str() );
+ gtk_frame_set_label( GTK_FRAME(m_widget), wxGTK_CONV( wxControl::GetLabel() ) );
}
void wxRadioBox::SetString( int item, const wxString& label )
GtkLabel *g_label = GTK_LABEL( BUTTON_CHILD(node->Data()) );
- gtk_label_set( g_label, label.mbc_str() );
+ gtk_label_set( g_label, wxGTK_CONV( label ) );
}
bool wxRadioBox::Enable( bool enable )
}
}
- m_widget = gtk_radio_button_new_with_label( m_radioButtonGroup, label.mbc_str() );
+ m_widget = gtk_radio_button_new_with_label( m_radioButtonGroup, wxGTK_CONV( label ) );
SetLabel(label);
wxControl::SetLabel( label );
GtkLabel *g_label = GTK_LABEL( BUTTON_CHILD(m_widget) );
- gtk_label_set( g_label, GetLabel().mbc_str() );
+ gtk_label_set( g_label, wxGTK_CONV( GetLabel() ) );
}
void wxRadioButton::SetValue( bool val )
{
// invalid number - set text as is (wxMSW compatible)
GtkDisableEvents();
- gtk_entry_set_text( GTK_ENTRY(m_widget), value.mbc_str() );
+ gtk_entry_set_text( GTK_ENTRY(m_widget), wxGTK_CONV( value ) );
GtkEnableEvents();
}
}
#if wxUSE_STATBOX
#include "wx/statbox.h"
+#include "wx/gtk/private.h"
#include "gdk/gdk.h"
#include "gtk/gtk.h"
wxControl::SetLabel(label);
- m_widget = gtk_frame_new(m_label.empty() ? (char *)NULL : m_label.mbc_str());
+ m_widget = gtk_frame_new(m_label.empty() ? (char *)NULL : (const char*) wxGTK_CONV( m_label ) );
m_parent->DoAddChild( this );
wxControl::SetLabel( label );
gtk_frame_set_label( GTK_FRAME( m_widget ),
- m_label.empty() ? (char *)NULL : m_label.mbc_str() );
+ m_label.empty() ? (char *)NULL : (const char*) wxGTK_CONV( m_label ) );
}
void wxStaticBox::ApplyWidgetStyle()
#if wxUSE_STATTEXT
#include "wx/stattext.h"
+#include "wx/gtk/private.h"
#include "gdk/gdk.h"
#include "gtk/gtk.h"
widget,
tool->GetLabel().empty()
? NULL
- : tool->GetLabel().mbc_str(),
+ : (const char*) wxGTK_CONV( tool->GetLabel() ),
tool->GetShortHelp().empty()
? NULL
- : tool->GetShortHelp().mbc_str(),
+ : (const char*) wxGTK_CONV( tool->GetShortHelp() ),
"", // tooltip_private_text (?)
tool->m_pixmap,
(GtkSignalFunc)gtk_toolbar_callback,
void wxToolBar::DoEnableTool(wxToolBarToolBase *toolBase, bool enable)
{
-#if (GTK_MINOR_VERSION > 0)
wxToolBarTool *tool = (wxToolBarTool *)toolBase;
- /* we don't disable the tools for GTK 1.0 as the bitmaps don't get
- greyed anyway and this also disables tooltips */
if (tool->m_item)
+ {
gtk_widget_set_sensitive( tool->m_item, enable );
-#endif
+ }
}
void wxToolBar::DoToggleTool( wxToolBarToolBase *toolBase, bool toggle )
{
(void)tool->SetShortHelp(helpString);
gtk_tooltips_set_tip(m_toolbar->tooltips, tool->m_item,
- helpString.mbc_str(), "");
+ wxGTK_CONV( helpString ), "");
}
}
#include "wx/log.h"
#include "wx/settings.h"
#include "wx/panel.h"
+#include "wx/strconv.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <ctype.h>
#include <math.h> // for fabs
-// TODO: reimplement wxTextCtrl using GtkTextView
-#ifdef __WXGTK20__
- #define GTK_ENABLE_BROKEN // need this to get GtkText at all
-#endif // __WXGTK20__
-
#include "wx/gtk/private.h"
#include <gdk/gdkkeysyms.h>
const char *txt,
size_t len)
{
+#ifndef __WXGTK__
GdkFont *font = attr.HasFont() ? attr.GetFont().GetInternalFont()
: NULL;
: NULL;
gtk_text_insert( GTK_TEXT(text), font, colFg, colBg, txt, len );
+#endif
}
// ----------------------------------------------------------------------------
if (g_isIdle)
wxapp_install_idle_handler();
-
+
win->SetModified();
win->UpdateFontIfNeeded();
-
+
wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, win->GetId() );
event.SetEventObject( win );
event.SetString( win->GetValue() );
// "changed" from vertical scrollbar
//-----------------------------------------------------------------------------
+#ifndef __WXGTK20__
static void
gtk_scrollbar_changed_callback( GtkWidget *WXUNUSED(widget), wxTextCtrl *win )
{
win->CalculateScrollbar();
}
+#endif
// ----------------------------------------------------------------------------
// redraw callback for multiline text
m_vScrollbarVisible = FALSE;
bool multi_line = (style & wxTE_MULTILINE) != 0;
+
+#ifdef __WXGTK20__
+ GtkTextBuffer *buffer = NULL;
+#endif
+
if (multi_line)
{
-#ifdef __WXGTK13__
- /* a multi-line edit control: create a vertical scrollbar by default and
- horizontal if requested */
- bool bHasHScrollbar = (style & wxHSCROLL) != 0;
-#else
- bool bHasHScrollbar = FALSE;
-#endif
+#ifdef __WXGTK20__
+ // Create view
+ m_text = gtk_text_view_new();
+
+ buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_text) );
+
+ // create scrolled window
+ m_widget = gtk_scrolled_window_new( NULL, NULL );
+ gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( m_widget ),
+ GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
+
+ // Insert view into scrolled window
+ gtk_container_add( GTK_CONTAINER(m_widget), m_text );
+
+ // Global settings which can be overridden by tags, I guess.
+ if (HasFlag( wxHSCROLL ))
+ gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW( m_text ), GTK_WRAP_NONE );
+ else
+ gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW( m_text ), GTK_WRAP_WORD );
- /* create our control ... */
+ if (!HasFlag(wxNO_BORDER))
+ gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW(m_widget), GTK_SHADOW_IN );
+#else
+ // create our control ...
m_text = gtk_text_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL );
- /* ... and put into the upper left hand corner of the table */
+ // ... and put into the upper left hand corner of the table
+ bool bHasHScrollbar = FALSE;
m_widget = gtk_table_new(bHasHScrollbar ? 2 : 1, 2, FALSE);
GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
gtk_table_attach( GTK_TABLE(m_widget), m_text, 0, 1, 0, 1,
(GtkAttachOptions)(GTK_FILL | GTK_EXPAND | GTK_SHRINK),
0, 0);
- /* always wrap words */
+ // always wrap words
gtk_text_set_word_wrap( GTK_TEXT(m_text), TRUE );
-#ifdef __WXGTK13__
- /* put the horizontal scrollbar in the lower left hand corner */
- if (bHasHScrollbar)
- {
- GtkWidget *hscrollbar = gtk_hscrollbar_new(GTK_TEXT(m_text)->hadj);
- GTK_WIDGET_UNSET_FLAGS( hscrollbar, GTK_CAN_FOCUS );
- gtk_table_attach(GTK_TABLE(m_widget), hscrollbar, 0, 1, 1, 2,
- (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK),
- GTK_FILL,
- 0, 0);
- gtk_widget_show(hscrollbar);
-
- /* don't wrap lines, otherwise we wouldn't need the scrollbar */
- gtk_text_set_line_wrap( GTK_TEXT(m_text), FALSE );
- }
-#endif
-
- /* finally, put the vertical scrollbar in the upper right corner */
+ // finally, put the vertical scrollbar in the upper right corner
m_vScrollbar = gtk_vscrollbar_new( GTK_TEXT(m_text)->vadj );
GTK_WIDGET_UNSET_FLAGS( m_vScrollbar, GTK_CAN_FOCUS );
gtk_table_attach(GTK_TABLE(m_widget), m_vScrollbar, 1, 2, 0, 1,
GTK_FILL,
(GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK),
0, 0);
+#endif
}
else
{
- /* a single-line text control: no need for scrollbars */
+ // a single-line text control: no need for scrollbars
m_widget =
m_text = gtk_entry_new();
}
if (multi_line)
gtk_widget_show(m_text);
+#ifndef __WXGTK20__
if (multi_line)
{
gtk_signal_connect(GTK_OBJECT(GTK_TEXT(m_text)->vadj), "changed",
(GtkSignalFunc) gtk_scrollbar_changed_callback, (gpointer) this );
-#ifndef __WXGTK20__
// only initialize gs_gtk_text_draw once, starting from the next the
// klass::draw will already be wxgtk_text_draw
if ( !gs_gtk_text_draw )
draw = wxgtk_text_draw;
}
-#endif // GTK+ 1.x
}
+#endif // GTK+ 1.x
if (!value.IsEmpty())
{
- gint tmp = 0;
+#ifdef __WXGTK20__
+ SetValue( value );
+#else
#if !GTK_CHECK_VERSION(1, 2, 0)
// if we don't realize it, GTK 1.0.6 dies with a SIGSEGV in
gtk_widget_realize(m_text);
#endif // GTK 1.0
+ gint tmp = 0;
#if wxUSE_UNICODE
wxWX2MBbuf val = value.mbc_str();
gtk_editable_insert_text( GTK_EDITABLE(m_text), val, strlen(val), &tmp );
-#else // !Unicode
+#else
gtk_editable_insert_text( GTK_EDITABLE(m_text), value, value.Length(), &tmp );
-#endif // Unicode/!Unicode
+#endif
if (multi_line)
{
- /* bring editable's cursor uptodate. bug in GTK. */
+ // Bring editable's cursor uptodate. Bug in GTK.
SET_EDITABLE_POS(m_text, gtk_text_get_point( GTK_TEXT(m_text) ));
}
+
+#endif
}
if (style & wxTE_PASSWORD)
{
if (!multi_line)
gtk_entry_set_editable( GTK_ENTRY(m_text), FALSE );
+#ifdef __WXGTK20__
+ else
+ gtk_text_view_set_editable( GTK_TEXT_VIEW( m_text), FALSE);
+ }
+#else
}
else
{
if (multi_line)
gtk_text_set_editable( GTK_TEXT(m_text), 1 );
}
+#endif
- /* we want to be notified about text changes */
+ // We want to be notified about text changes.
+#ifdef __WXGTK20__
+ if (multi_line)
+ {
+ g_signal_connect( G_OBJECT(buffer), "changed",
+ GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);
+ }
+ else
+#endif
+ {
gtk_signal_connect( GTK_OBJECT(m_text), "changed",
- GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);
+ GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);
+ }
- /* we don't set a valid background colour, because the window
- manager should use a default one */
+ // we don't set a valid background colour, because the window
+ // manager should use a default one
m_backgroundColour = wxColour();
wxColour colFg = parent->GetForegroundColour();
m_cursor = wxCursor( wxCURSOR_IBEAM );
+#ifndef __WXGTK20__
wxTextAttr attrDef( colFg, m_backgroundColour, parent->GetFont() );
SetDefaultStyle( attrDef );
+#endif
Show( TRUE );
void wxTextCtrl::CalculateScrollbar()
{
+#ifndef __WXGTK20__
if ((m_windowStyle & wxTE_MULTILINE) == 0) return;
GtkAdjustment *adj = GTK_TEXT(m_text)->vadj;
m_vScrollbarVisible = TRUE;
}
}
+#endif
}
wxString wxTextCtrl::GetValue() const
wxString tmp;
if (m_windowStyle & wxTE_MULTILINE)
{
+#ifdef __WXGTK20__
+ GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_text) );
+
+ GtkTextIter start;
+ gtk_text_buffer_get_start_iter( text_buffer, &start );
+ GtkTextIter end;
+ gtk_text_buffer_get_end_iter( text_buffer, &end );
+ gchar *text = gtk_text_buffer_get_text( text_buffer, &start, &end, TRUE );
+
+#if wxUSE_UNICODE
+ wxWCharBuffer buffer( wxConvUTF8.cMB2WX( text ) );
+#else
+ wxCharBuffer buffer( wxConvLocal.cWC2WX( wxConvUTF8.cMB2WC( text ) ) );
+#endif
+ tmp = buffer;
+
+ g_free( text );
+#else
gint len = gtk_text_get_length( GTK_TEXT(m_text) );
char *text = gtk_editable_get_chars( GTK_EDITABLE(m_text), 0, len );
- tmp = wxString(text,*wxConvCurrent);
+ tmp = text;
g_free( text );
+#endif
}
else
{
- tmp = wxString(gtk_entry_get_text( GTK_ENTRY(m_text) ),*wxConvCurrent);
+ tmp = wxGTK_CONV_BACK( gtk_entry_get_text( GTK_ENTRY(m_text) ) );
}
+
return tmp;
}
if (m_windowStyle & wxTE_MULTILINE)
{
+#ifdef __WXGTK20__
+
+#if wxUSE_UNICODE
+ wxCharBuffer buffer( wxConvUTF8.cWX2MB( value) );
+#else
+ wxCharBuffer buffer( wxConvUTF8.cWC2MB( wxConvLocal.cWX2WC( value ) ) );
+#endif
+ GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_text) );
+ gtk_text_buffer_set_text( text_buffer, buffer, strlen(buffer) );
+
+#else
gint len = gtk_text_get_length( GTK_TEXT(m_text) );
gtk_editable_delete_text( GTK_EDITABLE(m_text), 0, len );
len = 0;
-#if wxUSE_UNICODE
- wxWX2MBbuf tmpbuf = value.mbc_str();
- gtk_editable_insert_text( GTK_EDITABLE(m_text), tmpbuf, strlen(tmpbuf), &len );
-#else
gtk_editable_insert_text( GTK_EDITABLE(m_text), value.mbc_str(), value.Length(), &len );
#endif
}
else
{
- gtk_entry_set_text( GTK_ENTRY(m_text), value.mbc_str() );
+ gtk_entry_set_text( GTK_ENTRY(m_text), wxGTK_CONV( value ) );
}
// GRG, Jun/2000: Changed this after a lot of discussion in
// the lists. wxWindows 2.2 will have a set of flags to
// customize this behaviour.
SetInsertionPoint(0);
-
+
m_modified = FALSE;
}
if ( text.empty() )
return;
-#if wxUSE_UNICODE
- wxWX2MBbuf buf = text.mbc_str();
- const char *txt = buf;
- size_t txtlen = strlen(buf);
-#else
- const char *txt = text;
- size_t txtlen = text.length();
-#endif
-
if ( m_windowStyle & wxTE_MULTILINE )
{
+#ifdef __WXGTK20__
+
+#if wxUSE_UNICODE
+ wxCharBuffer buffer( wxConvUTF8.cWX2MB( text ) );
+#else
+ wxCharBuffer buffer( wxConvUTF8.cWC2MB( wxConvLocal.cWX2WC( text ) ) );
+#endif
+ GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_text) );
+ gtk_text_buffer_insert_at_cursor( text_buffer, buffer, strlen(buffer) );
+
+#else
// After cursor movements, gtk_text_get_point() is wrong by one.
gtk_text_set_point( GTK_TEXT(m_text), GET_EDITABLE_POS(m_text) );
// always use m_defaultStyle, even if it is empty as otherwise
// resetting the style and appending some more text wouldn't work: if
// we don't specify the style explicitly, the old style would be used
- wxGtkTextInsert(m_text, m_defaultStyle, txt, txtlen);
+ wxGtkTextInsert(m_text, m_defaultStyle, text.c_str(), text.Len());
// Bring editable's cursor back uptodate.
SET_EDITABLE_POS(m_text, gtk_text_get_point( GTK_TEXT(m_text) ));
+#endif
}
else // single line
{
// This moves the cursor pos to behind the inserted text.
gint len = GET_EDITABLE_POS(m_text);
- gtk_editable_insert_text( GTK_EDITABLE(m_text), txt, txtlen, &len );
+
+#ifdef __WXGTK20__
+
+#if wxUSE_UNICODE
+ wxCharBuffer buffer( wxConvUTF8.cWX2MB( text ) );
+#else
+ wxCharBuffer buffer( wxConvUTF8.cWC2MB( wxConvLocal.cWX2WC( text ) ) );
+#endif
+ gtk_editable_insert_text( GTK_EDITABLE(m_text), buffer, strlen(buffer), &len );
+
+#else
+ gtk_editable_insert_text( GTK_EDITABLE(m_text), text.c_str(), text.Len(), &len );
+#endif
// Bring editable's cursor uptodate.
len += text.Len();
{
if (m_windowStyle & wxTE_MULTILINE)
{
+#ifndef __WXGTK20__
gint len = gtk_text_get_length( GTK_TEXT(m_text) );
char *text = gtk_editable_get_chars( GTK_EDITABLE(m_text), 0, len );
return buf;
}
else
+#endif
{
return wxEmptyString;
}
{
if (m_windowStyle & wxTE_MULTILINE)
{
+#ifdef __WXGTK20__
+ GtkTextBuffer *buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_text) );
+
+ return gtk_text_buffer_get_line_count( buffer );
+#else
gint len = gtk_text_get_length( GTK_TEXT(m_text) );
char *text = gtk_editable_get_chars( GTK_EDITABLE(m_text), 0, len );
{
return 0;
}
+#endif
}
else
{
if (m_windowStyle & wxTE_MULTILINE)
{
- /* seems to be broken in GTK 1.0.X:
- gtk_text_set_point( GTK_TEXT(m_text), (int)pos ); */
-
+#ifdef __WXGTK20__
+ GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_text) );
+ GtkTextIter iter;
+ gtk_text_buffer_get_iter_at_offset( text_buffer, &iter, pos );
+ gtk_text_buffer_place_cursor( text_buffer, &iter );
+#else
gtk_signal_disconnect_by_func( GTK_OBJECT(m_text),
GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);
/* we fake a set_point by inserting and deleting. as the user
- isn't supposed to get to know about thos non-sense, we
+ isn't supposed to get to know about this non-sense, we
disconnect so that no events are sent to the user program. */
gint tmp = (gint)pos;
gtk_signal_connect( GTK_OBJECT(m_text), "changed",
GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);
- /* bring editable's cursor uptodate. another bug in GTK. */
-
+ // bring editable's cursor uptodate. Bug in GTK.
SET_EDITABLE_POS(m_text, gtk_text_get_point( GTK_TEXT(m_text) ));
+#endif
}
else
{
gtk_entry_set_position( GTK_ENTRY(m_text), (int)pos );
- /* bring editable's cursor uptodate. bug in GTK. */
-
+ // Bring editable's cursor uptodate. Bug in GTK.
SET_EDITABLE_POS(m_text, (guint32)pos);
}
}
wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
if (m_windowStyle & wxTE_MULTILINE)
+ {
+#ifdef __WXGTK20__
+ GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_text) );
+ GtkTextIter end;
+ gtk_text_buffer_get_end_iter( text_buffer, &end );
+ gtk_text_buffer_place_cursor( text_buffer, &end );
+#else
SetInsertionPoint(gtk_text_get_length(GTK_TEXT(m_text)));
+#endif
+ }
else
+ {
gtk_entry_set_position( GTK_ENTRY(m_text), -1 );
+ }
}
void wxTextCtrl::SetEditable( bool editable )
wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
if (m_windowStyle & wxTE_MULTILINE)
+ {
+#ifdef __WXGTK20__
+ gtk_text_view_set_editable( GTK_TEXT_VIEW(m_text), editable );
+#else
gtk_text_set_editable( GTK_TEXT(m_text), editable );
+#endif
+ }
else
+ {
gtk_entry_set_editable( GTK_ENTRY(m_text), editable );
+ }
}
bool wxTextCtrl::Enable( bool enable )
if (m_windowStyle & wxTE_MULTILINE)
{
+#ifdef __WXGTK20__
+ SetEditable( enable );
+#else
gtk_text_set_editable( GTK_TEXT(m_text), enable );
OnParentEnable(enable);
+#endif
}
else
{
{
wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
+#ifndef __WXGTK20__
if ( (m_windowStyle & wxTE_MULTILINE) &&
!GTK_TEXT(m_text)->line_start_cache )
{
wxLogDebug(_T("Can't call SetSelection() before realizing the control"));
return;
}
+#endif
- gtk_editable_select_region( GTK_EDITABLE(m_text), (gint)from, (gint)to );
+ if (m_windowStyle & wxTE_MULTILINE)
+ {
+#ifdef __WXGTK20__
+ // ????
+#else
+ gtk_editable_select_region( GTK_EDITABLE(m_text), (gint)from, (gint)to );
+#endif
+ }
+ else
+ {
+ gtk_editable_select_region( GTK_EDITABLE(m_text), (gint)from, (gint)to );
+ }
}
void wxTextCtrl::ShowPosition( long pos )
{
+#ifndef __WXGTK20__
if (m_windowStyle & wxTE_MULTILINE)
{
GtkAdjustment *vp = GTK_TEXT(m_text)->vadj;
float p = (posLine/totalLines)*(vp->upper - vp->lower) + vp->lower;
gtk_adjustment_set_value(GTK_TEXT(m_text)->vadj, p);
}
+#endif
}
long wxTextCtrl::GetInsertionPoint() const
{
wxCHECK_MSG( m_text != NULL, 0, wxT("invalid text ctrl") );
+#ifdef __WXGTK20__
+ if (m_windowStyle & wxTE_MULTILINE)
+ {
+ GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_text) );
+
+ // There is no direct accessor for the cursor, but
+ // internally, the cursor is the "mark" called
+ // "insert" in the text view's btree structure.
+
+ GtkTextMark *mark = gtk_text_buffer_get_insert( text_buffer );
+ GtkTextIter cursor;
+ gtk_text_buffer_get_iter_at_mark( text_buffer, &cursor, mark );
+
+ return gtk_text_iter_get_offset( &cursor );
+ }
+ else
+#endif
+ {
return (long) GET_EDITABLE_POS(m_text);
+ }
}
long wxTextCtrl::GetLastPosition() const
wxCHECK_MSG( m_text != NULL, 0, wxT("invalid text ctrl") );
int pos = 0;
+
if (m_windowStyle & wxTE_MULTILINE)
+ {
+#ifdef __WXGTK20__
+ GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_text) );
+ GtkTextIter end;
+ gtk_text_buffer_get_end_iter( text_buffer, &end );
+
+ pos = gtk_text_iter_get_offset( &end );
+#else
pos = gtk_text_get_length( GTK_TEXT(m_text) );
+#endif
+ }
else
+ {
pos = GTK_ENTRY(m_text)->text_length;
+ }
return (long)pos;
}
{
wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
+#ifndef __WXGTK20__
gtk_editable_delete_text( GTK_EDITABLE(m_text), (gint)from, (gint)to );
+#endif
}
void wxTextCtrl::Replace( long from, long to, const wxString &value )
{
wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
+#ifndef __WXGTK20__
gtk_editable_delete_text( GTK_EDITABLE(m_text), (gint)from, (gint)to );
if (!value.IsEmpty())
gtk_editable_insert_text( GTK_EDITABLE(m_text), value, value.Length(), &pos );
#endif
}
+#endif
}
void wxTextCtrl::Cut()
{
wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
+#ifndef __WXGTK20__
gtk_editable_cut_clipboard( GTK_EDITABLE(m_text) DUMMY_CLIPBOARD_ARG );
+#endif
}
void wxTextCtrl::Copy()
{
wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
+#ifndef __WXGTK20__
gtk_editable_copy_clipboard( GTK_EDITABLE(m_text) DUMMY_CLIPBOARD_ARG );
+#endif
}
void wxTextCtrl::Paste()
{
wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") );
+#ifndef __WXGTK20__
gtk_editable_paste_clipboard( GTK_EDITABLE(m_text) DUMMY_CLIPBOARD_ARG );
+#endif
}
// Undo/redo
bool wxTextCtrl::IsOwnGtkWindow( GdkWindow *window )
{
if (m_windowStyle & wxTE_MULTILINE)
+ {
+#ifdef __WXGTK20__
+ return window == gtk_text_view_get_window( GTK_TEXT_VIEW( m_text ), GTK_TEXT_WINDOW_TEXT ); // pure guesswork
+#else
return (window == GTK_TEXT(m_text)->text_area);
+#endif
+ }
else
+ {
return (window == GTK_ENTRY(m_text)->text_area);
+ }
}
// the font will change for subsequent text insertiongs
if (m_windowStyle & wxTE_MULTILINE)
{
+#ifndef __WXGTK__
GdkWindow *window = GTK_TEXT(m_text)->text_area;
if (!window)
return FALSE;
m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) );
gdk_window_set_background( window, m_backgroundColour.GetColor() );
gdk_window_clear( window );
+#endif
}
// change active background color too
with styling (FIXME) */
if ( m_windowStyle & wxTE_MULTILINE )
{
+#ifndef __WXGTK20__
if ( style.IsDefault() )
{
// nothing to do
/* does not seem to help under GTK+ 1.2 !!!
gtk_editable_set_position( GTK_EDITABLE(m_text), old_pos ); */
SetInsertionPoint( old_pos );
+#endif
return TRUE;
}
else // singe line
if (cursor.Ok())
{
+#ifndef __WXGTK20__
GdkWindow *window = (GdkWindow*) NULL;
if (HasFlag(wxTE_MULTILINE))
window = GTK_TEXT(m_text)->text_area;
window = m_widget->window;
if ((window) && !(GTK_WIDGET_NO_WINDOW(m_widget)))
gdk_window_set_cursor( window, cursor.GetCursor() );
+#endif
}
if (g_delayedFocus == this)
void wxTextCtrl::Freeze()
{
+#ifndef __WXGTK20__
if ( HasFlag(wxTE_MULTILINE) )
{
gtk_text_freeze(GTK_TEXT(m_text));
}
+#endif
}
void wxTextCtrl::Thaw()
{
+#ifndef __WXGTK20__
if ( HasFlag(wxTE_MULTILINE) )
{
GTK_TEXT(m_text)->vadj->value = 0.0;
gtk_text_thaw(GTK_TEXT(m_text));
}
+#endif
}
// ----------------------------------------------------------------------------
GtkAdjustment *wxTextCtrl::GetVAdj() const
{
+#ifdef __WXGTK20__
+ return NULL;
+#else
return HasFlag(wxTE_MULTILINE) ? GTK_TEXT(m_text)->vadj : NULL;
+#endif
}
bool wxTextCtrl::DoScroll(GtkAdjustment *adj, int diff)
{
+#ifndef __WXGTK20__
float value = adj->value + diff;
if ( value < 0 )
gtk_signal_emit_by_name(GTK_OBJECT(adj), "value_changed");
+#endif
return TRUE;
}
bool wxTextCtrl::ScrollLines(int lines)
{
+#ifdef __WXGTK20__
+ return FALSE;
+#else
GtkAdjustment *adj = GetVAdj();
if ( !adj )
return FALSE;
static const int KEY_SCROLL_PIXELS = 10;
return DoScroll(adj, lines*KEY_SCROLL_PIXELS);
+#endif
}
bool wxTextCtrl::ScrollPages(int pages)
{
+#ifdef __WXGTK20__
+ return FALSE;
+#else
GtkAdjustment *adj = GetVAdj();
if ( !adj )
return FALSE;
return DoScroll(adj, (int)ceil(pages*adj->page_increment));
+#endif
}
wxControl::SetLabel(label);
// Create the gtk widget.
- m_widget = gtk_toggle_button_new_with_label(m_label.mbc_str());
+ m_widget = gtk_toggle_button_new_with_label( wxGTK_CONV( m_label ) );
gtk_signal_connect(GTK_OBJECT(m_widget), "clicked",
GTK_SIGNAL_FUNC(gtk_togglebutton_clicked_callback),
wxControl::SetLabel(label);
- gtk_label_set(GTK_LABEL(BUTTON_CHILD(m_widget)), GetLabel().mbc_str());
+ gtk_label_set(GTK_LABEL(BUTTON_CHILD(m_widget)), wxGTK_CONV( GetLabel() ) );
}
bool wxToggleButton::Enable(bool enable /*=TRUE*/)
#include "wx/control.h"
#include "wx/app.h"
#include "wx/dcclient.h"
+#include "wx/gtk/private.h"
#include <glib.h>
#include <gdk/gdk.h>
}
if (!name.IsEmpty())
- gtk_window_set_wmclass( GTK_WINDOW(m_widget), name.mb_str(), name.mb_str() );
+ gtk_window_set_wmclass( GTK_WINDOW(m_widget), wxGTK_CONV( name ), wxGTK_CONV( name ) );
- gtk_window_set_title( GTK_WINDOW(m_widget), title.mbc_str() );
+ gtk_window_set_title( GTK_WINDOW(m_widget), wxGTK_CONV( title ) );
GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event",
static void wx_win_hints_set_layer(GtkWidget *window, int layer)
{
- XEvent xev;
- GdkWindowPrivate *priv;
- gint prev_error;
+#ifndef __WXGTK20__
+ XEvent xev;
+ GdkWindowPrivate *priv;
+ gint prev_error;
- prev_error = gdk_error_warnings;
- gdk_error_warnings = 0;
- priv = (GdkWindowPrivate*)(GTK_WIDGET(window)->window);
+ prev_error = gdk_error_warnings;
+ gdk_error_warnings = 0;
+ priv = (GdkWindowPrivate*)(GTK_WIDGET(window)->window);
- if (GTK_WIDGET_MAPPED(window))
- {
- xev.type = ClientMessage;
- xev.xclient.type = ClientMessage;
- xev.xclient.window = priv->xwindow;
- xev.xclient.message_type = gs_XA_WIN_LAYER;
- xev.xclient.format = 32;
- xev.xclient.data.l[0] = (long)layer;
- xev.xclient.data.l[1] = gdk_time_get();
+ if (GTK_WIDGET_MAPPED(window))
+ {
+ xev.type = ClientMessage;
+ xev.xclient.type = ClientMessage;
+ xev.xclient.window = priv->xwindow;
+ xev.xclient.message_type = gs_XA_WIN_LAYER;
+ xev.xclient.format = 32;
+ xev.xclient.data.l[0] = (long)layer;
+ xev.xclient.data.l[1] = gdk_time_get();
- XSendEvent(GDK_DISPLAY(), GDK_ROOT_WINDOW(), False,
- SubstructureNotifyMask, (XEvent*) &xev);
+ XSendEvent(GDK_DISPLAY(), GDK_ROOT_WINDOW(), False,
+ SubstructureNotifyMask, (XEvent*) &xev);
}
- else
+ else
{
- long data[1];
+ long data[1];
- data[0] = layer;
- XChangeProperty(GDK_DISPLAY(), priv->xwindow, gs_XA_WIN_LAYER,
- XA_CARDINAL, 32, PropModeReplace, (unsigned char *)data,
- 1);
+ data[0] = layer;
+ XChangeProperty(GDK_DISPLAY(), priv->xwindow, gs_XA_WIN_LAYER,
+ XA_CARDINAL, 32, PropModeReplace, (unsigned char *)data, 1);
}
- gdk_error_warnings = prev_error;
+ gdk_error_warnings = prev_error;
+#endif
}
bool wxTopLevelWindowGTK::ShowFullScreen(bool show, long style )
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
m_title = title;
- gtk_window_set_title( GTK_WINDOW(m_widget), title.mbc_str() );
+ gtk_window_set_title( GTK_WINDOW(m_widget), wxGTK_CONV( title ) );
}
void wxTopLevelWindowGTK::DoSetIcon( const wxIcon &icon )
#endif
#include <math.h>
+#include <ctype.h>
#include "wx/gtk/private.h"
#include <gdk/gdkprivate.h>
wxCHECK_RET( fontToUse.Ok(), wxT("invalid font") );
GdkFont *font = fontToUse.GetInternalFont( 1.0 );
- if (x) (*x) = gdk_string_width( font, string.mbc_str() );
+ if (x) (*x) = gdk_string_width( font, wxGTK_CONV( string ) );
if (y) (*y) = font->ascent + font->descent;
if (descent) (*descent) = font->descent;
if (externalLeading) (*externalLeading) = 0; // ??
// Clip to paint region in wxClientDC
m_clipPaintRegion = TRUE;
-
+
+#ifndef __WXGTK20__
if (GetThemeEnabled())
{
// find ancestor from which to steal background
}
}
else
- // if (!m_clearRegion.IsEmpty()) // always send an erase event
+#endif
+#ifdef __WXGTK20__
+ if (!m_clearRegion.IsEmpty()) // Always send an erase event under GTK 1.2
+#endif
{
wxWindowDC dc( (wxWindow*)this );
if (m_clearRegion.IsEmpty())
if (!GetEventHandler()->ProcessEvent(erase_event))
{
+#ifndef __WXGTK20__
if (!g_eraseGC)
{
g_eraseGC = gdk_gc_new( pizza->bin_window );
upd.GetX(), upd.GetY(), upd.GetWidth(), upd.GetHeight() );
upd ++;
}
+#endif
}
m_clearRegion.Clear();
}