Here it comes:

Doc updates
  Makefile doesn't strip anylonger
  Makefile adapted to /src/unix etc
  Added wxLB_ALWAYS_SB
  Added MWM window manager hints
  Fixed event handling bugs that (among others) caused
    the wxListBox misbeahiour
  Rwwrote GtkmyFixed for GTK 1.2
  Made data requests etc in wxClipboadr asynchronous
  Added underscores to menus (some)
  Tried in vain to make wxTextCtrl (and its GtkTable)
    behave correctly. The bottom text control in the
    controls samples still misbehaves upon start-up.
  did I change notebook.cpp ?


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2082 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
1999-04-09 18:01:17 +00:00
parent c84fb40aab
commit 034be8882c
40 changed files with 1338 additions and 664 deletions

View File

@@ -58,6 +58,9 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id,
long style, const wxValidator& validator, const wxString &name )
{
m_needParent = TRUE;
#if (GTK_MINOR_VERSION > 0)
m_acceptsFocus = TRUE;
#endif
PreCreation( parent, id, pos, size, style, name );

View File

@@ -15,6 +15,8 @@
#if wxUSE_CLIPBOARD
#include "wx/utils.h"
#include "glib.h"
#include "gdk/gdk.h"
#include "gtk/gtk.h"
@@ -60,30 +62,49 @@ struct _GtkSelectionData
static void
targets_selection_received( GtkWidget *WXUNUSED(widget),
GtkSelectionData *selection_data,
#if (GTK_MINOR_VERSION > 0)
guint32 WXUNUSED(time),
#endif
wxClipboard *clipboard )
{
if (!wxTheClipboard) return;
if (!wxTheClipboard)
{
clipboard->m_waiting = FALSE;
return;
}
if (selection_data->length <= 0) return;
// make sure we got the data in the correct form
if (selection_data->type != GDK_SELECTION_TYPE_ATOM) return;
if (selection_data->length <= 0)
{
clipboard->m_waiting = FALSE;
return;
}
/* make sure we got the data in the correct form */
if (selection_data->type != GDK_SELECTION_TYPE_ATOM)
{
clipboard->m_waiting = FALSE;
return;
}
// the atoms we received, holding a list of targets (= formats)
GdkAtom *atoms = (GdkAtom *)selection_data->data;
for (unsigned int i=0; i<selection_data->length/sizeof(GdkAtom); i++)
{
char *name = gdk_atom_name (atoms[i]);
if (name) printf( "Format available: %s.\n", name );
/*
char *name = gdk_atom_name (atoms[i]);
if (name) printf( "Format available: %s.\n", name );
*/
if (atoms[i] == clipboard->m_targetRequested)
{
clipboard->m_waiting = FALSE;
clipboard->m_formatSupported = TRUE;
return;
}
}
clipboard->m_waiting = FALSE;
return;
}
@@ -94,28 +115,50 @@ targets_selection_received( GtkWidget *WXUNUSED(widget),
static void
selection_received( GtkWidget *WXUNUSED(widget),
GtkSelectionData *selection_data,
#if (GTK_MINOR_VERSION > 0)
guint32 WXUNUSED(time),
#endif
wxClipboard *clipboard )
{
if (!wxTheClipboard) return;
if (!wxTheClipboard)
{
clipboard->m_waiting = FALSE;
return;
}
wxDataObject *data_object = clipboard->m_receivedData;
if (!data_object) return;
if (!data_object)
{
clipboard->m_waiting = FALSE;
return;
}
if (selection_data->length <= 0) return;
if (selection_data->length <= 0)
{
clipboard->m_waiting = FALSE;
return;
}
// make sure we got the data in the correct format
/* make sure we got the data in the correct format */
if (data_object->GetFormat().GetAtom() != selection_data->target)
{
clipboard->m_waiting = FALSE;
return;
}
if (data_object->GetFormat().GetAtom() != selection_data->target) return;
// make sure we got the data in the correct form (selection type).
// if so, copy data to target object
/* make sure we got the data in the correct form (selection type).
if so, copy data to target object */
switch (data_object->GetFormat().GetType())
{
case wxDF_TEXT:
{
if (selection_data->type != GDK_SELECTION_TYPE_STRING) return;
if (selection_data->type != GDK_SELECTION_TYPE_STRING)
{
clipboard->m_waiting = FALSE;
return;
}
wxTextDataObject *text_object = (wxTextDataObject *) data_object;
@@ -128,16 +171,22 @@ selection_received( GtkWidget *WXUNUSED(widget),
case wxDF_BITMAP:
{
if (selection_data->type != GDK_SELECTION_TYPE_BITMAP) return;
return;
if (selection_data->type != GDK_SELECTION_TYPE_BITMAP)
{
clipboard->m_waiting = FALSE;
return;
}
break;
}
case wxDF_PRIVATE:
{
if (selection_data->type != GDK_SELECTION_TYPE_STRING) return;
if (selection_data->type != GDK_SELECTION_TYPE_STRING)
{
clipboard->m_waiting = FALSE;
return;
}
wxPrivateDataObject *private_object = (wxPrivateDataObject *) data_object;
@@ -148,11 +197,13 @@ selection_received( GtkWidget *WXUNUSED(widget),
default:
{
clipboard->m_waiting = FALSE;
return;
}
}
wxTheClipboard->m_formatSupported = TRUE;
clipboard->m_waiting = FALSE;
}
//-----------------------------------------------------------------------------
@@ -285,9 +336,26 @@ wxClipboard::wxClipboard()
m_receivedData = (wxDataObject*) NULL;
/* we use m_targetsWidget to query what formats are available */
m_targetsWidget = gtk_window_new( GTK_WINDOW_POPUP );
gtk_widget_realize( m_targetsWidget );
gtk_signal_connect( GTK_OBJECT(m_targetsWidget),
"selection_received",
GTK_SIGNAL_FUNC( targets_selection_received ),
(gpointer) this );
/* we use m_clipboardWidget to get and to offer data */
m_clipboardWidget = gtk_window_new( GTK_WINDOW_POPUP );
gtk_widget_realize( m_clipboardWidget );
gtk_signal_connect( GTK_OBJECT(m_clipboardWidget),
"selection_received",
GTK_SIGNAL_FUNC( selection_received ),
(gpointer) this );
gtk_signal_connect( GTK_OBJECT(m_clipboardWidget),
"selection_clear_event",
GTK_SIGNAL_FUNC( selection_clear_clip ),
@@ -305,6 +373,7 @@ wxClipboard::~wxClipboard()
Clear();
if (m_clipboardWidget) gtk_widget_destroy( m_clipboardWidget );
if (m_targetsWidget) gtk_widget_destroy( m_targetsWidget );
}
void wxClipboard::Clear()
@@ -454,27 +523,25 @@ bool wxClipboard::IsSupported( wxDataFormat format )
wxCHECK_MSG( m_targetRequested, FALSE, "invalid clipboard format" );
/* add handler for target (= format) query */
gtk_signal_connect( GTK_OBJECT(m_clipboardWidget),
"selection_received",
GTK_SIGNAL_FUNC( targets_selection_received ),
(gpointer) this );
m_formatSupported = FALSE;
/* perform query. this will set m_formatSupported to
* TRUE if m_targetRequested is supported */
gtk_selection_convert( m_clipboardWidget,
TRUE if m_targetRequested is supported.
alsom we have to wait for the "answer" from the
clipboard owner which is an asynchronous process.
therefore we set m_waiting = TRUE here and wait
until the callback "targets_selection_received"
sets it to FALSE */
m_waiting = TRUE;
gtk_selection_convert( m_targetsWidget,
g_clipboardAtom,
g_targetsAtom,
GDK_CURRENT_TIME );
gtk_signal_disconnect_by_func( GTK_OBJECT(m_clipboardWidget),
GTK_SIGNAL_FUNC( targets_selection_received ),
(gpointer) this );
while (m_waiting) gtk_main_iteration();
if (!m_formatSupported) return FALSE;
return TRUE;
@@ -502,21 +569,23 @@ bool wxClipboard::GetData( wxDataObject *data )
m_formatSupported = FALSE;
gtk_signal_connect( GTK_OBJECT(m_clipboardWidget),
"selection_received",
GTK_SIGNAL_FUNC( selection_received ),
(gpointer) this );
/* ask for clipboard contents. this will set
m_formatSupported to TRUE if m_targetRequested
is supported.
also, we have to wait for the "answer" from the
clipboard owner which is an asynchronous process.
therefore we set m_waiting = TRUE here and wait
until the callback "targets_selection_received"
sets it to FALSE */
/* ask for clipboard contents */
m_waiting = TRUE;
gtk_selection_convert( m_clipboardWidget,
g_clipboardAtom,
m_targetRequested,
GDK_CURRENT_TIME );
gtk_signal_disconnect_by_func( GTK_OBJECT(m_clipboardWidget),
GTK_SIGNAL_FUNC( selection_received ),
(gpointer) this );
while (m_waiting) gtk_main_iteration();
/* this is a true error as we checked for the presence of such data before */

View File

@@ -13,6 +13,8 @@
#include "wx/control.h"
#include "gtk/gtkfeatures.h"
//-----------------------------------------------------------------------------
// wxControl
//-----------------------------------------------------------------------------

View File

@@ -32,7 +32,7 @@ IMPLEMENT_CLASS(wxDataFormat, wxObject)
wxDataFormat::wxDataFormat()
{
if (!g_textAtom) g_textAtom = gdk_atom_intern( "text/plain", FALSE );
if (!g_textAtom) g_textAtom = gdk_atom_intern( "STRING", FALSE );
m_type = wxDF_INVALID;
m_hasAtom = FALSE;
m_atom = (GdkAtom) 0;
@@ -40,19 +40,19 @@ wxDataFormat::wxDataFormat()
wxDataFormat::wxDataFormat( wxDataType type )
{
if (!g_textAtom) g_textAtom = gdk_atom_intern( "text/plain", FALSE );
if (!g_textAtom) g_textAtom = gdk_atom_intern( "STRING", FALSE );
SetType( type );
}
wxDataFormat::wxDataFormat( const wxString &id )
{
if (!g_textAtom) g_textAtom = gdk_atom_intern( "text/plain", FALSE );
if (!g_textAtom) g_textAtom = gdk_atom_intern( "STRING", FALSE );
SetId( id );
}
wxDataFormat::wxDataFormat( wxDataFormat &format )
{
if (!g_textAtom) g_textAtom = gdk_atom_intern( "text/plain", FALSE );
if (!g_textAtom) g_textAtom = gdk_atom_intern( "STRING", FALSE );
m_type = format.GetType();
m_id = format.GetId();
m_hasAtom = TRUE;
@@ -61,7 +61,7 @@ wxDataFormat::wxDataFormat( wxDataFormat &format )
wxDataFormat::wxDataFormat( const GdkAtom atom )
{
if (!g_textAtom) g_textAtom = gdk_atom_intern( "text/plain", FALSE );
if (!g_textAtom) g_textAtom = gdk_atom_intern( "STRING", FALSE );
m_hasAtom = TRUE;
m_atom = atom;
@@ -91,7 +91,7 @@ void wxDataFormat::SetType( wxDataType type )
if (m_type == wxDF_TEXT)
{
m_id = "text/plain";
m_id = "STRING";
}
else
if (m_type == wxDF_BITMAP)

View File

@@ -145,6 +145,27 @@ bool wxDialog::Create( wxWindow *parent,
gtk_widget_realize( m_widget );
long decor = (long) GDK_DECOR_ALL;
long func = (long) GDK_FUNC_ALL;
if ((m_windowStyle & wxCAPTION) == 0)
decor |= GDK_DECOR_TITLE;
if ((m_windowStyle & wxMINIMIZE) == 0)
func |= GDK_FUNC_MINIMIZE;
if ((m_windowStyle & wxMAXIMIZE) == 0)
func |= GDK_FUNC_MAXIMIZE;
if ((m_windowStyle & wxSYSTEM_MENU) == 0)
decor |= GDK_DECOR_MENU;
if ((m_windowStyle & wxMINIMIZE_BOX) == 0)
decor |= GDK_DECOR_MINIMIZE;
if ((m_windowStyle & wxMAXIMIZE_BOX) == 0)
decor |= GDK_DECOR_MAXIMIZE;
if ((m_windowStyle & wxRESIZE_BORDER) == 0)
func |= GDK_FUNC_RESIZE;
gdk_window_set_decorations(m_widget->window, (GdkWMDecoration)decor);
gdk_window_set_functions(m_widget->window, (GdkWMFunction)func);
gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_dialog_size_callback), (gpointer)this );

View File

@@ -171,6 +171,27 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title,
gtk_widget_realize( m_widget );
long decor = (long) GDK_DECOR_ALL;
long func = (long) GDK_FUNC_ALL;
if ((m_windowStyle & wxCAPTION) == 0)
decor |= GDK_DECOR_TITLE;
if ((m_windowStyle & wxMINIMIZE) == 0)
func |= GDK_FUNC_MINIMIZE;
if ((m_windowStyle & wxMAXIMIZE) == 0)
func |= GDK_FUNC_MAXIMIZE;
if ((m_windowStyle & wxSYSTEM_MENU) == 0)
decor |= GDK_DECOR_MENU;
if ((m_windowStyle & wxMINIMIZE_BOX) == 0)
decor |= GDK_DECOR_MINIMIZE;
if ((m_windowStyle & wxMAXIMIZE_BOX) == 0)
decor |= GDK_DECOR_MAXIMIZE;
if ((m_windowStyle & wxRESIZE_BORDER) == 0)
func |= GDK_FUNC_RESIZE;
gdk_window_set_decorations(m_widget->window, (GdkWMDecoration)decor);
gdk_window_set_functions(m_widget->window, (GdkWMFunction)func);
gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this );

View File

@@ -192,8 +192,16 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
SetValidator( validator );
m_widget = gtk_scrolled_window_new( (GtkAdjustment*) NULL, (GtkAdjustment*) NULL );
gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(m_widget),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
if (style & wxLB_ALWAYS_SB)
{
gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(m_widget),
GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS );
}
else
{
gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(m_widget),
GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
}
m_list = GTK_LIST( gtk_list_new() );
@@ -211,25 +219,6 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
gtk_container_add( GTK_CONTAINER(m_widget), GTK_WIDGET(m_list) );
#endif
#ifdef __WXDEBUG__
debug_focus_in( m_widget, "wxListBox::m_widget", name );
debug_focus_in( GTK_WIDGET(m_list), "wxListBox::m_list", name );
GtkScrolledWindow *s_window = GTK_SCROLLED_WINDOW(m_widget);
debug_focus_in( s_window->hscrollbar, "wxWindow::hsrcollbar", name );
debug_focus_in( s_window->vscrollbar, "wxWindow::vsrcollbar", name );
#ifdef NEW_GTK_SCROLL_CODE
GtkViewport *viewport = GTK_VIEWPORT( GTK_BIN(s_window)->child );
#else
GtkViewport *viewport = GTK_VIEWPORT(s_window->viewport);
#endif
debug_focus_in( GTK_WIDGET(viewport), "wxWindow::viewport", name );
#endif
gtk_widget_show( GTK_WIDGET(m_list) );
wxSize newSize = size;
@@ -252,10 +241,6 @@ bool wxListBox::Create( wxWindow *parent, wxWindowID id,
list_item = gtk_list_item_new_with_label( str );
#ifdef __WXDEBUG__
debug_focus_in( list_item, "wxListBox::list_item", name );
#endif
gtk_container_add( GTK_CONTAINER(m_list), list_item );
gtk_signal_connect( GTK_OBJECT(list_item), "select",

View File

@@ -72,19 +72,22 @@ wxMenuBar::wxMenuBar()
void wxMenuBar::Append( wxMenu *menu, const wxString &title )
{
m_menus.Append( menu );
wxString title2 = title;
int pos;
do
wxString s = "";
for ( const char *pc = title; *pc != '\0'; pc++ )
{
pos = title2.First( '&' );
if (pos != wxNOT_FOUND)
title2.Remove( pos, 1 );
} while (pos != wxNOT_FOUND);
if (*pc == '&')
{
pc++; /* skip it */
#if (GTK_MINOR_VERSION > 0)
// s << '_'; not yet
#endif
}
s << *pc;
}
menu->SetTitle(title2);
menu->m_owner = gtk_menu_item_new_with_label( WXSTRINGCAST(title2) );
menu->SetTitle(s);
menu->m_owner = gtk_menu_item_new_with_label( WXSTRINGCAST(s) );
gtk_widget_show( menu->m_owner );
gtk_menu_item_set_submenu( GTK_MENU_ITEM(menu->m_owner), menu->m_menu );
@@ -404,7 +407,13 @@ void wxMenuItem::SetName( const wxString& str )
m_text = "";
for ( const char *pc = str; *pc != '\0'; pc++ )
{
if (*pc == '&') pc++; /* skip it */
if (*pc == '&')
{
pc++; /* skip it */
#if (GTK_MINOR_VERSION > 0)
m_text << '_';
#endif
}
m_text << *pc;
}
@@ -457,7 +466,14 @@ wxMenu::wxMenu( const wxString& title, const wxFunction func )
m_title = title;
m_items.DeleteContents( TRUE );
m_invokingWindow = (wxWindow *) NULL;
#if (GTK_MINOR_VERSION > 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_callback = func;
m_eventHandler = this;
@@ -473,6 +489,11 @@ wxMenu::wxMenu( const wxString& title, const wxFunction func )
m_owner = (GtkWidget*) NULL;
}
wxMenu::~wxMenu()
{
/* how do we delete an item-factory ? */
}
void wxMenu::SetTitle( const wxString& title )
{
// TODO Waiting for something better
@@ -492,6 +513,7 @@ void wxMenu::AppendSeparator()
GtkWidget *menuItem = gtk_menu_item_new();
gtk_menu_append( GTK_MENU(m_menu), menuItem );
gtk_widget_show( menuItem );
mitem->SetMenuItem(menuItem);
m_items.Append( mitem );
}
@@ -504,25 +526,58 @@ void wxMenu::Append( int id, const wxString &item, const wxString &helpStr, bool
mitem->SetHelp(helpStr);
mitem->SetCheckable(checkable);
const char *text = mitem->GetText();
#if (GTK_MINOR_VERSION > 0)
char buf[100];
strcpy( buf, "/" );
strcat( buf, text );
GtkItemFactoryEntry entry;
entry.path = buf;
entry.accelerator = (gchar*) NULL;
entry.callback = (GtkItemFactoryCallback) gtk_menu_clicked_callback;
entry.callback_action = 0;
if (checkable)
entry.item_type = "<CheckItem>";
else
entry.item_type = "<Item>";
gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */
/* in order to get the pointer to the item we need the item text _without_ underscores */
wxString s = "<main>/";
for ( const char *pc = text; *pc != '\0'; pc++ )
{
if (*pc == '_') pc++; /* skip it */
s << *pc;
}
GtkWidget *menuItem = gtk_item_factory_get_item( m_factory, s );
#else
GtkWidget *menuItem = checkable ? gtk_check_menu_item_new_with_label(text)
: gtk_menu_item_new_with_label(text);
mitem->SetMenuItem(menuItem);
gtk_signal_connect( GTK_OBJECT(menuItem), "activate",
GTK_SIGNAL_FUNC(gtk_menu_clicked_callback),
(gpointer*)this );
(gpointer)this );
gtk_menu_append( GTK_MENU(m_menu), menuItem );
gtk_widget_show( menuItem );
#endif
gtk_signal_connect( GTK_OBJECT(menuItem), "select",
GTK_SIGNAL_FUNC(gtk_menu_hilight_callback),
(gpointer*)this );
(gpointer)this );
gtk_signal_connect( GTK_OBJECT(menuItem), "deselect",
GTK_SIGNAL_FUNC(gtk_menu_nolight_callback),
(gpointer*)this );
(gpointer)this );
mitem->SetMenuItem(menuItem);
gtk_menu_append( GTK_MENU(m_menu), menuItem );
gtk_widget_show( menuItem );
m_items.Append( mitem );
}
@@ -590,14 +645,18 @@ void wxMenu::Append( wxMenuItem *item )
int wxMenu::FindItem( const wxString itemString ) const
{
wxString s( itemString );
int pos;
do
wxString s = "";
for ( const char *pc = itemString; *pc != '\0'; pc++ )
{
pos = s.First( '&' );
if (pos != -1) s.Remove( pos, 1 );
} while (pos != -1);
if (*pc == '&')
{
pc++; /* skip it */
#if (GTK_MINOR_VERSION > 0)
s << '_';
#endif
}
s << *pc;
}
wxNode *node = m_items.First();
while (node)

View File

@@ -233,10 +233,6 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id,
m_widget = gtk_notebook_new();
#ifdef __WXDEBUG__
debug_focus_in( m_widget, "wxNotebook::m_widget", name );
#endif
gtk_notebook_set_scrollable( GTK_NOTEBOOK(m_widget), 1 );
m_idHandler = gtk_signal_connect (

View File

@@ -37,9 +37,9 @@ extern bool g_blockEventsOnDrag;
static void
gtk_text_changed_callback( GtkWidget *WXUNUSED(widget), wxTextCtrl *win )
{
win->SetModified();
if (!win->m_hasVMT) return;
win->CalculateScrollbar();
win->SetModified();
wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, win->m_windowId );
event.SetString( win->GetValue() );
@@ -48,12 +48,14 @@ gtk_text_changed_callback( GtkWidget *WXUNUSED(widget), wxTextCtrl *win )
}
//-----------------------------------------------------------------------------
// "size_allocate"
// "changed" from vertical scrollbar
//-----------------------------------------------------------------------------
static void
gtk_text_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* WXUNUSED(alloc), wxTextCtrl *win )
gtk_scrollbar_changed_callback( GtkWidget *WXUNUSED(widget), wxTextCtrl *win )
{
if (!win->m_hasVMT) return;
win->CalculateScrollbar();
}
@@ -124,19 +126,19 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value,
SetValidator( validator );
m_vScrollbarVisible = TRUE;
m_vScrollbarVisible = FALSE;
bool multi_line = (style & wxTE_MULTILINE) != 0;
if ( multi_line )
{
// a multi-line edit control: create a vertical scrollbar by default and
// horizontal if requested
/* a multi-line edit control: create a vertical scrollbar by default and
horizontal if requested */
bool bHasHScrollbar = (style & wxHSCROLL) != 0;
// create our control...
/* 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 */
m_widget = gtk_table_new(bHasHScrollbar ? 2 : 1, 2, FALSE);
GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
@@ -145,7 +147,7 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value,
(GtkAttachOptions)(GTK_FILL | GTK_EXPAND | GTK_SHRINK),
0, 0);
// put the horizontal scrollbar in the lower left hand corner
/* put the horizontal scrollbar in the lower left hand corner */
if (bHasHScrollbar)
{
GtkWidget *hscrollbar = gtk_hscrollbar_new(GTK_TEXT(m_text)->hadj);
@@ -158,22 +160,13 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value,
gtk_widget_show(hscrollbar);
}
// 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);
gtk_widget_show( m_vScrollbar );
/* we create the vertical scrollbar on demand */
m_vScrollbar = (GtkWidget*) NULL;
gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_text_size_callback), (gpointer)this );
}
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();
}
@@ -195,7 +188,7 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value,
gtk_widget_show(m_text);
}
// we want to be notified about text changes
/* we want to be notified about text changes */
gtk_signal_connect( GTK_OBJECT(m_text), "changed",
GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);
@@ -228,11 +221,17 @@ bool wxTextCtrl::Create( wxWindow *parent, wxWindowID id, const wxString &value,
if (multi_line)
gtk_text_set_editable( GTK_TEXT(m_text), 1 );
}
SetBackgroundColour( parent->GetBackgroundColour() );
SetForegroundColour( parent->GetForegroundColour() );
Show( TRUE );
SetBackgroundColour( parent->GetBackgroundColour() );
SetForegroundColour( parent->GetForegroundColour() );
if (multi_line)
{
gtk_signal_connect(GTK_OBJECT(GTK_TEXT(m_text)->vadj), "changed",
(GtkSignalFunc) gtk_scrollbar_changed_callback, (gpointer) this );
}
return TRUE;
}
@@ -247,18 +246,30 @@ 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 );
if (!m_vScrollbar)
{
/* 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);
}
gtk_widget_show( m_vScrollbar );
m_vScrollbarVisible = TRUE;
m_vScrollbarVisible = TRUE;
}
}
}

View File

@@ -8,15 +8,7 @@
/////////////////////////////////////////////////////////////////////////// */
#include "wx/gtk/win_gtk.h"
#include <gtk/gtkfeatures.h>
/*-------------------------------------------------------------------------
// conditional compilation
//------------------------------------------------------------------------- */
#if (GTK_MINOR_VERSION > 0)
#define NEW_GTK_CONSTRUCT_CODE
#endif
#include "gtk/gtksignal.h"
#ifdef __cplusplus
extern "C" {
@@ -25,7 +17,7 @@ extern "C" {
static void gtk_myfixed_class_init (GtkMyFixedClass *klass);
static void gtk_myfixed_init (GtkMyFixed *myfixed);
static void gtk_myfixed_map (GtkWidget *widget);
#ifndef NEW_GTK_CONSTRUCT_CODE
#if (GTK_MINOR_VERSION == 0)
static void gtk_myfixed_unmap (GtkWidget *widget);
#endif
static void gtk_myfixed_realize (GtkWidget *widget);
@@ -49,14 +41,20 @@ static void gtk_myfixed_foreach (GtkContainer *container,
#endif
GtkCallback callback,
gpointer callback_data);
#ifdef NEW_GTK_CONSTRUCT_CODE
#if (GTK_MINOR_VERSION > 0)
static GtkType gtk_myfixed_child_type (GtkContainer *container);
#endif
#if (GTK_MINOR_VERSION > 0)
static void gtk_myfixed_scroll_set_adjustments (GtkMyFixed *myfixed,
GtkAdjustment *hadj,
GtkAdjustment *vadj);
#endif
static GtkContainerClass *parent_class = NULL;
guint
gtk_myfixed_get_type ()
{
@@ -71,13 +69,13 @@ gtk_myfixed_get_type ()
sizeof (GtkMyFixedClass),
(GtkClassInitFunc) gtk_myfixed_class_init,
(GtkObjectInitFunc) gtk_myfixed_init,
#ifndef NEW_GTK_CONSTRUCT_CODE
(GtkArgSetFunc) NULL,
(GtkArgGetFunc) NULL,
#else
#if (GTK_MINOR_VERSION > 0)
/* reserved_1 */ NULL,
/* reserved_2 */ NULL,
(GtkClassInitFunc) NULL,
#else
(GtkArgSetFunc) NULL,
(GtkArgGetFunc) NULL,
#endif
};
@@ -98,14 +96,14 @@ gtk_myfixed_class_init (GtkMyFixedClass *klass)
widget_class = (GtkWidgetClass*) klass;
container_class = (GtkContainerClass*) klass;
#ifndef NEW_GTK_CONSTRUCT_CODE
parent_class = gtk_type_class (gtk_container_get_type ());
#else
#if (GTK_MINOR_VERSION > 0)
parent_class = gtk_type_class (GTK_TYPE_CONTAINER);
#else
parent_class = gtk_type_class (gtk_container_get_type ());
#endif
widget_class->map = gtk_myfixed_map;
#ifndef NEW_GTK_CONSTRUCT_CODE
#if (GTK_MINOR_VERSION == 0)
widget_class->unmap = gtk_myfixed_unmap;
#endif
widget_class->realize = gtk_myfixed_realize;
@@ -122,12 +120,24 @@ gtk_myfixed_class_init (GtkMyFixedClass *klass)
container_class->foreach = gtk_myfixed_foreach;
#endif
#ifdef NEW_GTK_CONSTRUCT_CODE
#if (GTK_MINOR_VERSION > 0)
container_class->child_type = gtk_myfixed_child_type;
#endif
#if (GTK_MINOR_VERSION > 0)
klass->set_scroll_adjustments = gtk_myfixed_scroll_set_adjustments;
widget_class->set_scroll_adjustments_signal =
gtk_signal_new ("set_scroll_adjustments",
GTK_RUN_LAST,
object_class->type,
GTK_SIGNAL_OFFSET (GtkMyFixedClass, set_scroll_adjustments),
gtk_marshal_NONE__POINTER_POINTER,
GTK_TYPE_NONE, 2, GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT);
#endif
}
#ifdef NEW_GTK_CONSTRUCT_CODE
#if (GTK_MINOR_VERSION > 0)
static GtkType
gtk_myfixed_child_type (GtkContainer *container)
{
@@ -140,10 +150,14 @@ gtk_myfixed_init (GtkMyFixed *myfixed)
{
GTK_WIDGET_UNSET_FLAGS (myfixed, GTK_NO_WINDOW);
#ifndef NEW_GTK_CONSTRUCT_CODE
#if (GTK_MINOR_VERSION == 0)
GTK_WIDGET_SET_FLAGS (myfixed, GTK_BASIC);
#endif
#if (GTK_MINOR_VERSION > 0)
myfixed->shadow_type = GTK_SHADOW_NONE;
#endif
myfixed->children = NULL;
}
@@ -157,8 +171,36 @@ gtk_myfixed_new ()
return GTK_WIDGET (myfixed);
}
#if (GTK_MINOR_VERSION > 0)
void gtk_myfixed_scroll_set_adjustments (GtkMyFixed *myfixed,
GtkAdjustment *hadj,
GtkAdjustment *vadj)
{
/* OK, this is embarassing, but this function has to be here */
}
void
gtk_myfixed_set_shadow_type (GtkMyFixed *myfixed,
GtkShadowType type)
{
g_return_if_fail (myfixed != NULL);
g_return_if_fail (GTK_IS_MYFIXED (myfixed));
if ((GtkShadowType) myfixed->shadow_type != type)
{
myfixed->shadow_type = type;
if (GTK_WIDGET_VISIBLE (myfixed))
{
gtk_widget_size_allocate (GTK_WIDGET (myfixed), &(GTK_WIDGET (myfixed)->allocation));
gtk_widget_queue_draw (GTK_WIDGET (myfixed));
}
}
}
#endif
void
gtk_myfixed_put (GtkMyFixed *myfixed,
gtk_myfixed_put (GtkMyFixed *myfixed,
GtkWidget *widget,
gint16 x,
gint16 y)
@@ -249,7 +291,7 @@ gtk_myfixed_map (GtkWidget *widget)
}
}
#ifndef NEW_GTK_CONSTRUCT_CODE
#if (GTK_MINOR_VERSION == 0)
static void
gtk_myfixed_unmap (GtkWidget *widget)
{
@@ -275,10 +317,26 @@ gtk_myfixed_realize (GtkWidget *widget)
GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED);
attributes.window_type = GDK_WINDOW_CHILD;
#if (GTK_MINOR_VERSION > 0)
if (myfixed->shadow_type != GTK_SHADOW_NONE)
{
attributes.x = 2;
attributes.y = 2;
}
else
{
attributes.x = 0;
attributes.y = 0;
}
attributes.width = MAX (1, (gint)widget->allocation.width - attributes.x * 2 );
attributes.height = MAX (1, (gint)widget->allocation.height - attributes.y * 2 );
#else
attributes.x = widget->allocation.x;
attributes.y = widget->allocation.y;
attributes.width = 32000;
attributes.height = 32000;
#endif
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.visual = gtk_widget_get_visual (widget);
attributes.colormap = gtk_widget_get_colormap (widget);
@@ -344,10 +402,10 @@ gtk_myfixed_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GtkMyFixed *myfixed;
gint border;
GtkMyFixedChild *child;
GtkAllocation child_allocation;
GList *children;
guint16 border_width;
GtkAllocation child_allocation;
GList *children;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_MYFIXED(widget));
@@ -355,12 +413,23 @@ gtk_myfixed_size_allocate (GtkWidget *widget,
myfixed = GTK_MYFIXED (widget);
if (myfixed->shadow_type == GTK_SHADOW_NONE)
border = 0;
else
border = 2;
widget->allocation = *allocation;
if (GTK_WIDGET_REALIZED (widget))
gdk_window_move_resize (widget->window, allocation->x, allocation->y, 32000, 32000 );
{
gdk_window_move_resize( widget->window,
allocation->x+border, allocation->y+border,
#if (GTK_MINOR_VERSION > 0)
allocation->width-border*2, allocation->height-border*2 );
#else
32000, 32000 );
#endif
}
border_width = GTK_CONTAINER (myfixed)->border_width;
children = myfixed->children;
while (children)
{
@@ -369,8 +438,8 @@ gtk_myfixed_size_allocate (GtkWidget *widget,
if (GTK_WIDGET_VISIBLE (child->widget))
{
child_allocation.x = child->x + border_width;
child_allocation.y = child->y + border_width;
child_allocation.x = child->x;
child_allocation.y = child->y;
child_allocation.width = child->widget->requisition.width;
child_allocation.height = child->widget->requisition.height;
gtk_widget_size_allocate (child->widget, &child_allocation);

View File

@@ -122,47 +122,10 @@
*/
//-------------------------------------------------------------------------
// conditional compilation
// constants
//-------------------------------------------------------------------------
#if (GTK_MINOR_VERSION > 0)
#define NEW_GTK_SCROLL_CODE
#endif
//-----------------------------------------------------------------------------
// (debug)
//-----------------------------------------------------------------------------
#ifdef __WXDEBUG__
static gint gtk_debug_focus_in_callback( GtkWidget *WXUNUSED(widget),
GdkEvent *WXUNUSED(event),
const char *name )
{
printf( "FOCUS NOW AT: " );
printf( name );
printf( "\n" );
return FALSE;
}
void debug_focus_in( GtkWidget* widget, const char* name, const char *window )
{
return;
wxString tmp = name;
tmp += " FROM ";
tmp += window;
char *s = new char[tmp.Length()+1];
strcpy( s, WXSTRINGCAST tmp );
gtk_signal_connect( GTK_OBJECT(widget), "focus_in_event",
GTK_SIGNAL_FUNC(gtk_debug_focus_in_callback), (gpointer)s );
}
#endif
#define FRAME_BORDER_WIDTH 2
//-----------------------------------------------------------------------------
// data
@@ -174,12 +137,105 @@ extern bool g_blockEventsOnScroll;
static bool g_capturing = FALSE;
static wxWindow *g_focusWindow = (wxWindow*) NULL;
// hack: we need something to pass to gtk_menu_popup, so we store the time of
// the last click here
/* hack: we need something to pass to gtk_menu_popup, so we store the time of
the last click here */
static guint32 gs_timeLastClick = 0;
//-----------------------------------------------------------------------------
// "expose_event" (of m_wxwindow, not of m_widget)
// local code (see below)
//-----------------------------------------------------------------------------
static void draw_frame( GtkWidget *widget, wxWindow *win )
{
if (!win->HasVMT()) return;
int dw = 0;
int dh = 0;
if (win->m_hasScrolling)
{
GtkScrolledWindow *scroll_window = GTK_SCROLLED_WINDOW(widget);
GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(widget)->klass );
/*
GtkWidget *hscrollbar = scroll_window->hscrollbar;
GtkWidget *vscrollbar = scroll_window->vscrollbar;
we use this instead: range.slider_width = 11 + 2*2pts edge
*/
if (scroll_window->vscrollbar_visible)
{
dw += 15; /* dw += vscrollbar->allocation.width; */
dw += scroll_class->scrollbar_spacing;
}
if (scroll_window->hscrollbar_visible)
{
dh += 15; /* dh += hscrollbar->allocation.height; */
dw += scroll_class->scrollbar_spacing;
}
}
int dx = 0;
int dy = 0;
if (GTK_WIDGET_NO_WINDOW (widget))
{
dx += widget->allocation.x;
dy += widget->allocation.y;
}
else
if (win->m_parent)
{
wxPoint pt(win->m_parent->GetClientAreaOrigin());
dx += pt.x;
dy += pt.y;
}
if (win->m_windowStyle & wxRAISED_BORDER)
{
gtk_draw_shadow( widget->style,
widget->window,
GTK_STATE_NORMAL,
GTK_SHADOW_OUT,
dx, dy,
win->m_width-dw, win->m_height-dh );
return;
}
if (win->m_windowStyle & wxSUNKEN_BORDER)
{
gtk_draw_shadow( widget->style,
widget->window,
GTK_STATE_NORMAL,
GTK_SHADOW_IN,
dx, dy,
win->m_width-dw, win->m_height-dh );
return;
}
}
//-----------------------------------------------------------------------------
// "expose_event" of m_widget
//-----------------------------------------------------------------------------
static void gtk_window_own_expose_callback( GtkWidget *widget, GdkEventExpose *gdk_event, wxWindow *win )
{
if (gdk_event->count > 0) return;
draw_frame( widget, win );
}
//-----------------------------------------------------------------------------
// "draw" of m_wxwindow
//-----------------------------------------------------------------------------
static void gtk_window_own_draw_callback( GtkWidget *widget, GdkRectangle *WXUNUSED(rect), wxWindow *win )
{
draw_frame( widget, win );
}
//-----------------------------------------------------------------------------
// "expose_event" of m_wxwindow
//-----------------------------------------------------------------------------
static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gdk_event, wxWindow *win )
@@ -208,7 +264,7 @@ static void gtk_window_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExp
}
//-----------------------------------------------------------------------------
// "draw" (of m_wxwindow, not of m_widget)
// "draw" of m_wxwindow
//-----------------------------------------------------------------------------
static void gtk_window_draw_callback( GtkWidget *WXUNUSED(widget), GdkRectangle *rect, wxWindow *win )
@@ -397,9 +453,10 @@ static gint gtk_window_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_e
if (ret)
{
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" );
return TRUE;
}
return ret;
return FALSE;
}
//-----------------------------------------------------------------------------
@@ -509,14 +566,13 @@ static gint gtk_window_key_release_callback( GtkWidget *widget, GdkEventKey *gdk
event.m_y = 0;
event.SetEventObject( win );
bool ret = win->GetEventHandler()->ProcessEvent( event );
if (ret)
if (win->GetEventHandler()->ProcessEvent( event ))
{
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_release_event" );
return TRUE;
}
return ret;
return FALSE;
}
//-----------------------------------------------------------------------------
@@ -525,11 +581,12 @@ static gint gtk_window_key_release_callback( GtkWidget *widget, GdkEventKey *gdk
static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win )
{
if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE;
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return TRUE;
if (g_blockEventsOnScroll) return TRUE;
if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE;
if (win->m_wxwindow)
{
if (GTK_WIDGET_CAN_FOCUS(win->m_wxwindow) && !GTK_WIDGET_HAS_FOCUS (win->m_wxwindow) )
@@ -546,8 +603,6 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton
}
}
if (!win->HasVMT()) return TRUE;
/*
printf( "OnButtonPress from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
@@ -660,9 +715,12 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton
gs_timeLastClick = gdk_event->time;
if (win->GetEventHandler()->ProcessEvent( event ))
{
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "button_press_event" );
return TRUE;
}
return TRUE;
return FALSE;
}
//-----------------------------------------------------------------------------
@@ -671,12 +729,11 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton
static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win )
{
if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE;
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
if (g_blockEventsOnScroll) return FALSE;
if (g_blockEventsOnDrag) return TRUE;
if (g_blockEventsOnScroll) return TRUE;
if (!win->HasVMT()) return TRUE;
if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE;
/*
printf( "OnButtonRelease from " );
@@ -766,9 +823,12 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto
event.SetEventObject( win );
if (win->GetEventHandler()->ProcessEvent( event ))
{
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "button_release_event" );
return TRUE;
}
return TRUE;
return FALSE;
}
//-----------------------------------------------------------------------------
@@ -777,6 +837,12 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto
static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_event, wxWindow *win )
{
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
if (g_blockEventsOnScroll) return FALSE;
if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE;
if (gdk_event->is_hint)
{
int x = 0;
@@ -788,13 +854,6 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion
gdk_event->state = state;
}
if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE;
if (g_blockEventsOnDrag) return TRUE;
if (g_blockEventsOnScroll) return TRUE;
if (!win->HasVMT()) return TRUE;
/*
printf( "OnMotion from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
@@ -875,9 +934,12 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion
event.SetEventObject( win );
if (win->GetEventHandler()->ProcessEvent( event ))
{
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "motion_notify_event" );
return TRUE;
}
return TRUE;
return FALSE;
}
//-----------------------------------------------------------------------------
@@ -886,7 +948,8 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion
static gint gtk_window_focus_in_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxWindow *win )
{
if (g_blockEventsOnDrag) return TRUE;
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
g_focusWindow = win;
@@ -904,7 +967,6 @@ static gint gtk_window_focus_in_callback( GtkWidget *widget, GdkEvent *WXUNUSED(
}
}
if (!win->HasVMT()) return TRUE;
/*
printf( "OnSetFocus from " );
@@ -919,9 +981,12 @@ static gint gtk_window_focus_in_callback( GtkWidget *widget, GdkEvent *WXUNUSED(
event.SetEventObject( win );
if (win->GetEventHandler()->ProcessEvent( event ))
{
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "focus_in_event" );
return TRUE;
return TRUE;
}
return FALSE;
}
//-----------------------------------------------------------------------------
@@ -930,15 +995,15 @@ static gint gtk_window_focus_in_callback( GtkWidget *widget, GdkEvent *WXUNUSED(
static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED(event), wxWindow *win )
{
if (g_blockEventsOnDrag) return TRUE;
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
if (win->m_wxwindow)
{
if (GTK_WIDGET_CAN_FOCUS(win->m_wxwindow))
GTK_WIDGET_UNSET_FLAGS (win->m_wxwindow, GTK_HAS_FOCUS);
}
if (!win->HasVMT()) return TRUE;
/*
printf( "OnKillFocus from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
@@ -950,9 +1015,12 @@ static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED
event.SetEventObject( win );
if (win->GetEventHandler()->ProcessEvent( event ))
{
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "focus_out_event" );
return TRUE;
return TRUE;
}
return FALSE;
}
//-----------------------------------------------------------------------------
@@ -961,15 +1029,14 @@ static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEvent *WXUNUSED
static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win )
{
if (g_blockEventsOnDrag) return TRUE;
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
if (widget->window != gdk_event->window) return FALSE;
if ((widget->window) && (win->m_cursor))
gdk_window_set_cursor( widget->window, win->m_cursor->GetCursor() );
if (widget->window != gdk_event->window) return TRUE;
if (!win->HasVMT()) return TRUE;
/*
printf( "OnEnter from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
@@ -1002,9 +1069,12 @@ static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_
event.m_y -= pt.y;
if (win->GetEventHandler()->ProcessEvent( event ))
{
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "enter_notify_event" );
return TRUE;
return TRUE;
}
return FALSE;
}
//-----------------------------------------------------------------------------
@@ -1013,15 +1083,14 @@ static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_
static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindow *win )
{
if (g_blockEventsOnDrag) return TRUE;
if (!win->HasVMT()) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
if (widget->window != gdk_event->window) return FALSE;
if ((widget->window) && (win->m_cursor))
gdk_window_set_cursor( widget->window, wxSTANDARD_CURSOR->GetCursor() );
if (widget->window != gdk_event->window) return TRUE;
if (!win->HasVMT()) return TRUE;
/*
printf( "OnLeave from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
@@ -1054,9 +1123,12 @@ static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_
event.m_y -= pt.y;
if (win->GetEventHandler()->ProcessEvent( event ))
{
gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "leave_notify_event" );
return TRUE;
return TRUE;
}
return FALSE;
}
//-----------------------------------------------------------------------------
@@ -1403,17 +1475,8 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id,
m_widget = gtk_scrolled_window_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL );
GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
#ifdef __WXDEBUG__
debug_focus_in( m_widget, "wxWindow::m_widget", name );
#endif
GtkScrolledWindow *s_window = GTK_SCROLLED_WINDOW(m_widget);
#ifdef __WXDEBUG__
debug_focus_in( s_window->hscrollbar, "wxWindow::hsrcollbar", name );
debug_focus_in( s_window->vscrollbar, "wxWindow::vsrcollbar", name );
#endif
GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget)->klass );
scroll_class->scrollbar_spacing = 0;
@@ -1427,21 +1490,25 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id,
m_wxwindow = gtk_myfixed_new();
#ifdef __WXDEBUG__
debug_focus_in( m_wxwindow, "wxWindow::m_wxwindow", name );
#endif
#ifdef NEW_GTK_SCROLL_CODE
gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW(m_widget), m_wxwindow );
GtkViewport *viewport = GTK_VIEWPORT( GTK_BIN(s_window)->child );
#else
gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow );
GtkViewport *viewport = GTK_VIEWPORT(s_window->viewport);
#endif
#if (GTK_MINOR_VERSION > 0)
GtkMyFixed *myfixed = GTK_MYFIXED(m_wxwindow);
#ifdef __WXDEBUG__
debug_focus_in( GTK_WIDGET(viewport), "wxWindow::viewport", name );
#endif
if (m_windowStyle & wxRAISED_BORDER)
{
gtk_myfixed_set_shadow_type( myfixed, GTK_SHADOW_OUT );
}
else if (m_windowStyle & wxSUNKEN_BORDER)
{
gtk_myfixed_set_shadow_type( myfixed, GTK_SHADOW_IN );
}
else
{
gtk_myfixed_set_shadow_type( myfixed, GTK_SHADOW_NONE );
}
#else
GtkViewport *viewport = GTK_VIEWPORT(s_window->viewport);
if (m_windowStyle & wxRAISED_BORDER)
{
@@ -1455,6 +1522,7 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id,
{
gtk_viewport_set_shadow_type( viewport, GTK_SHADOW_NONE );
}
#endif
if (m_windowStyle & wxTAB_TRAVERSAL)
{
@@ -1469,9 +1537,11 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id,
m_acceptsFocus = TRUE;
}
#if (GTK_MINOR_VERSION == 0)
// shut the viewport up
gtk_viewport_set_hadjustment( viewport, (GtkAdjustment*) gtk_adjustment_new( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) );
gtk_viewport_set_vadjustment( viewport, (GtkAdjustment*) gtk_adjustment_new( 0.0, 0.0, 0.0, 0.0, 0.0, 0.0) );
#endif
// I _really_ don't want scrollbars in the beginning
m_vAdjust->lower = 0.0;
@@ -1505,7 +1575,7 @@ bool wxWindow::Create( wxWindow *parent, wxWindowID id,
gtk_signal_connect( GTK_OBJECT(s_window->hscrollbar), "button_release_event",
(GtkSignalFunc)gtk_scrollbar_button_release_callback, (gpointer) this );
// these handers het notified when screen updates are required either when
// these handlers get notified when screen updates are required either when
// scrolling or when the window size (and therefore scrollbar configuration)
// has changed
@@ -1695,11 +1765,19 @@ void wxWindow::PostCreation()
if (m_wxwindow)
{
/* these get reported to wxWindows -> wxPaintEvent */
gtk_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event",
GTK_SIGNAL_FUNC(gtk_window_expose_callback), (gpointer)this );
gtk_signal_connect( GTK_OBJECT(m_wxwindow), "draw",
GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this );
/* these are called when the "sunken" or "raised" borders are drawn */
gtk_signal_connect( GTK_OBJECT(m_widget), "expose_event",
GTK_SIGNAL_FUNC(gtk_window_own_expose_callback), (gpointer)this );
gtk_signal_connect( GTK_OBJECT(m_widget), "draw",
GTK_SIGNAL_FUNC(gtk_window_own_draw_callback), (gpointer)this );
}
ConnectWidget( GetConnectWidget() );
@@ -1928,38 +2006,39 @@ void wxWindow::DoSetClientSize( int width, int height )
GtkScrolledWindow *scroll_window = GTK_SCROLLED_WINDOW(m_widget);
GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget)->klass );
#ifdef NEW_GTK_SCROLL_CODE
GtkWidget *viewport = GTK_BIN(scroll_window)->child;
#else
#if (GTK_MINOR_VERSION == 0)
GtkWidget *viewport = scroll_window->viewport;
#endif
GtkStyleClass *viewport_class = viewport->style->klass;
GtkWidget *hscrollbar = scroll_window->hscrollbar;
GtkWidget *vscrollbar = scroll_window->vscrollbar;
if ((m_windowStyle & wxRAISED_BORDER) ||
(m_windowStyle & wxSUNKEN_BORDER))
{
dw += 2 * viewport_class->xthickness;
dh += 2 * viewport_class->ythickness;
}
#endif
/*
GtkWidget *hscrollbar = scroll_window->hscrollbar;
GtkWidget *vscrollbar = scroll_window->vscrollbar;
we use this instead: range.slider_width = 11 + 2*2pts edge
*/
if (scroll_window->vscrollbar_visible)
{
dw += vscrollbar->allocation.width;
dw += 15; /* dw += vscrollbar->allocation.width; */
dw += scroll_class->scrollbar_spacing;
}
if (scroll_window->hscrollbar_visible)
{
dh += hscrollbar->allocation.height;
dh += 15; /* dh += hscrollbar->allocation.height; */
dw += scroll_class->scrollbar_spacing;
}
}
SetSize( width+dw, height+dh );
SetSize( width+dw, height+dh );
}
}
@@ -1993,12 +2072,8 @@ void wxWindow::GetClientSize( int *width, int *height ) const
GtkScrolledWindow *scroll_window = GTK_SCROLLED_WINDOW(m_widget);
GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT(m_widget)->klass );
#ifdef NEW_GTK_SCROLL_CODE
GtkWidget *viewport = GTK_BIN(scroll_window)->child;
#else
#if (GTK_MINOR_VERSION == 0)
GtkWidget *viewport = scroll_window->viewport;
#endif
GtkStyleClass *viewport_class = viewport->style->klass;
if ((m_windowStyle & wxRAISED_BORDER) ||
@@ -2007,18 +2082,23 @@ void wxWindow::GetClientSize( int *width, int *height ) const
dw += 2 * viewport_class->xthickness;
dh += 2 * viewport_class->ythickness;
}
#endif
/*
GtkWidget *hscrollbar = scroll_window->hscrollbar;
GtkWidget *vscrollbar = scroll_window->vscrollbar;
we use this instead: range.slider_width = 11 + 2*2pts edge
*/
if (scroll_window->vscrollbar_visible)
{
// dw += vscrollbar->allocation.width;
dw += 15; // range.slider_width = 11 + 2*2pts edge
dw += 15; /* dw += vscrollbar->allocation.width; */
dw += scroll_class->scrollbar_spacing;
}
if (scroll_window->hscrollbar_visible)
{
// dh += hscrollbar->allocation.height;
dh += 15;
dh += 15; /* dh += hscrollbar->allocation.height; */
dh += scroll_class->scrollbar_spacing;
}
}