From: Robert Roebling Date: Thu, 26 Nov 1998 07:11:24 +0000 (+0000) Subject: Fixes for wxlist X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/a802c3a1f665a21fde886de6234d877e49aaccf6 Fixes for wxlist improvements for DnD :-) moer dialog and frame fine tuning git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1058 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/docs/gtk/install.txt b/docs/gtk/install.txt index 1038da9bdd..3bec5f9ebd 100644 --- a/docs/gtk/install.txt +++ b/docs/gtk/install.txt @@ -1,8 +1,8 @@ * The most simple case ----------------------- -If you compile wxWindows on Unix for the first time and don't like -to read install instructions just do (in the base dir): +If you compile wxWindows on Unix for the first time and don't +like to read install instructions just do (in the base dir): ./configure --without-threads make @@ -11,33 +11,42 @@ and drink 10 coffees. Then you may log in as root and type make install -You can leave out the --without-threads option if you have a NEW -Linux distribution based on glibc (e.g. RedHat 5.1 or Debian 2.0) -or any other Unix that comes with Posix threads or SGI threads. +You can leave out the --without-threads option if you have +a NEW Linux distribution based on glibc (e.g. RedHat 5.1 or +Debian 2.0) or any other Unix that comes with Posix threads +or SGI threads. -Now create your super-application myfoo.app and compile anywhere with +Now create your super-application myfoo.app and compile anywhere +with g++ myfoo.cpp `wx-config --libs` `wx-config --cflags` -o myfoo * General ----------------------- -The Unix variants of wxWindows use GNU configure. If you have problems -with your make use GNU make instead. +The Unix variants of wxWindows use GNU configure. If you have +problems with your make use GNU make instead. -Read my homepage at +If you have general problems with installation, read my +homepage at http://wesley.informatik.uni-freiburg.de/~wxxt -for newest information. +for newest information. If you still don't have any success, +please send a bug report to one of our mailing lists (see +my homepage) INCLUDING A DESCRIPTION OF YOUR SYSTEM AND +YOUR PROBLEM, SUCH AS YOUR VERSION OF GTK, WXGTK, WHAT +DISTRIBUTION YOU USE AND WHAT ERROR WAS REPORTED. I know +this has no effect, but I tried... * GUI libraries ----------------------- wxWindows/GTK requires the GTK+ library to be installed on your system. It has to be a stable version, preferebly version 1.0.6. When using -a version previous to 1.0.6 you'll get crashes here and there. This -is certain to happen with colors in native widgets. +a version previous to 1.0.6 you'll get crashes here and there. Although +wxWindows/GTK now compiles with GTK+ 1.1.3, it does not set work +properly. Wait for a stable version GTK 1.2. You can get the newest version of the GTK+ from the GTK homepage at diff --git a/docs/gtk/readme.txt b/docs/gtk/readme.txt index 9699f25225..ac4bf93b6d 100644 --- a/docs/gtk/readme.txt +++ b/docs/gtk/readme.txt @@ -1,9 +1,9 @@ Welcome to wxWindows/Gtk, -you have downloaded version 1.96 of the GTK+ port of C++ library +you have downloaded version 1.97 of the GTK+ port of C++ library wxWindows. Information on how to install can be found in the -file install.txt, but if you cannot wait, this should work on +file INSTALL.txt, but if you cannot wait, this should work on all systems configure --without-threads @@ -11,8 +11,16 @@ make su (PASSWORD) make install +When you run into problems, please read the INSTALL.txt and +follow those instructions. If you still don't have any success, +please send a bug report to one of our mailing lists (see +my homepage) INCLUDING A DESCRIPTION OF YOUR SYSTEM AND +YOUR PROBLEM, SUCH AS YOUR VERSION OF GTK, WXGTK, WHAT +DISTRIBUTION YOU USE AND WHAT ERROR WAS REPORTED. I know +this has no effect, but I tried... + wxWindows/Gtk is still in development and you can have a look -at the todo.txt to see what's missing before an official beta +at the TODO.txt to see what's missing before an official beta and - more important - before we can aim at binary compatibility. More information is available from my homepage at diff --git a/docs/gtk/todo.txt b/docs/gtk/todo.txt index c3fea8c07e..b7899507e7 100644 --- a/docs/gtk/todo.txt +++ b/docs/gtk/todo.txt @@ -10,14 +10,14 @@ wxClipboard Fix printing of bitmaps -> No idea. +-------------------- Low priority --------------------- + OwnerDraw for wxListCtrl and others - -> That is a big one. + -> Postponed. DnD -> Must be rewritten for GTK+ 1.1.3 --------------------- Low priority --------------------- - wxDebugContext <-> wxLogXXX functions -> Remove either diff --git a/include/wx/list.h b/include/wx/list.h index dc52fc248c..795b5f579b 100644 --- a/include/wx/list.h +++ b/include/wx/list.h @@ -222,13 +222,13 @@ protected: // get the list item's data void *operator[](size_t index) const - { wxNodeBase *node = Item(index); return node ? node->GetData() : NULL; } + { wxNodeBase *node = Item(index); return node ? node->GetData() : (wxNodeBase*)NULL; } // operations // append to end of list wxNodeBase *Append(void *object); // insert a new item at the beginning of the list - wxNodeBase *Insert(void *object) { return Insert(NULL, object); } + wxNodeBase *Insert(void *object) { return Insert( (wxNodeBase*)NULL, object); } // insert before given node or at front of list if prev == NULL wxNodeBase *Insert(wxNodeBase *prev, void *object); @@ -350,7 +350,7 @@ private: nodetype *Append(T *object) \ { return (nodetype *)wxListBase::Append(object); } \ nodetype *Insert(T *object) \ - { return (nodetype *)Insert(NULL, object); } \ + { return (nodetype *)Insert((nodetype*)NULL, object); } \ nodetype *Insert(nodetype *prev, T *object) \ { return (nodetype *)wxListBase::Insert(prev, object); } \ \ diff --git a/samples/dnd/dnd.cpp b/samples/dnd/dnd.cpp index 03d8ce9388..15ac819ee3 100644 --- a/samples/dnd/dnd.cpp +++ b/samples/dnd/dnd.cpp @@ -182,7 +182,6 @@ DnDFrame::DnDFrame(wxFrame *frame, char *title, int x, int y, int w, int h) m_ctrlFile = new wxListBox(this, -1, pos, size, 1, &strFile, wxLB_HSCROLL); m_ctrlText = new wxListBox(this, -1, pos, size, 1, &strText, wxLB_HSCROLL); -/* m_ctrlLog = new wxTextCtrl(this, -1, "", pos, size, wxTE_MULTILINE | wxTE_READONLY | wxSUNKEN_BORDER| wxHSCROLL); @@ -190,10 +189,6 @@ DnDFrame::DnDFrame(wxFrame *frame, char *title, int x, int y, int w, int h) // redirect log messages to the text window (don't forget to delete it!) m_pLog = new wxLogTextCtrl(m_ctrlLog); m_pLogPrev = wxLog::SetActiveTarget(m_pLog); -*/ - - wxStaticText *m_testLabel = new wxStaticText( this, -1, "Hallo", pos, size ); - m_testLabel->SetDropTarget( new wxTextDropTarget() ); // associate drop targets with 2 text controls m_ctrlFile->SetDropTarget(new DnDFile(m_ctrlFile)); @@ -217,7 +212,6 @@ DnDFrame::DnDFrame(wxFrame *frame, char *title, int x, int y, int w, int h) c->height.PercentOf(this, wxHeight, 40); m_ctrlText->SetConstraints(c); -/* // Lower text control c = new wxLayoutConstraints; c->left.SameAs (this, wxLeft); @@ -225,17 +219,7 @@ DnDFrame::DnDFrame(wxFrame *frame, char *title, int x, int y, int w, int h) c->height.PercentOf(this, wxHeight, 40); c->top.SameAs(m_ctrlText, wxBottom); m_ctrlLog->SetConstraints(c); -*/ - // Lower label control - c = new wxLayoutConstraints; - c->left.SameAs (this, wxLeft); - c->right.SameAs (this, wxRight); - c->height.PercentOf(this, wxHeight, 40); - c->top.SameAs(m_ctrlText, wxBottom); - m_testLabel->SetConstraints(c); - - SetAutoLayout(TRUE); } diff --git a/src/gtk.inc b/src/gtk.inc index 6b2a8b08e0..5d349c4141 100644 --- a/src/gtk.inc +++ b/src/gtk.inc @@ -4,7 +4,7 @@ NONE = # define library name LIB_TARGET=wx_gtk LIB_MAJOR=1 -LIB_MINOR=96 +LIB_MINOR=97 # define library sources diff --git a/src/gtk/dcclient.cpp b/src/gtk/dcclient.cpp index 290d654ddf..854f5d07f5 100644 --- a/src/gtk/dcclient.cpp +++ b/src/gtk/dcclient.cpp @@ -829,6 +829,7 @@ void wxPaintDC::SetBackground( const wxBrush &brush ) m_backgroundBrush.GetColour().CalcPixel( m_cmap ); gdk_gc_set_background( m_brushGC, m_backgroundBrush.GetColour().GetColor() ); + gdk_gc_set_background( m_penGC, m_backgroundBrush.GetColour().GetColor() ); gdk_gc_set_background( m_bgGC, m_backgroundBrush.GetColour().GetColor() ); gdk_gc_set_foreground( m_bgGC, m_backgroundBrush.GetColour().GetColor() ); @@ -949,8 +950,13 @@ void wxPaintDC::SetUpDC(void) m_brushGC = gdk_gc_new( m_window ); m_textGC = gdk_gc_new( m_window ); m_bgGC = gdk_gc_new( m_window ); - SetTextForeground( m_textForegroundColour ); - SetTextBackground( m_textBackgroundColour ); + + wxColour tmp_col( m_textForegroundColour ); + m_textForegroundColour = wxNullColour; + SetTextForeground( tmp_col ); + tmp_col = m_textBackgroundColour; + m_textBackgroundColour = wxNullColour; + SetTextBackground( tmp_col ); wxPen tmp_pen( m_pen ); m_pen = wxNullPen; @@ -968,8 +974,6 @@ void wxPaintDC::SetUpDC(void) m_backgroundBrush = wxNullBrush; SetBackground( tmp_brush ); - gdk_gc_set_background( m_penGC, wxWHITE->GetColor() ); - if (!hatch_bitmap) { hatch_bitmap = hatches; diff --git a/src/gtk/dialog.cpp b/src/gtk/dialog.cpp index bde6b7e6b4..0e26ee1808 100644 --- a/src/gtk/dialog.cpp +++ b/src/gtk/dialog.cpp @@ -74,7 +74,6 @@ wxDialog::wxDialog() { m_title = ""; m_modalShowing = FALSE; - wxTopLevelWindows.Insert( this ); } wxDialog::wxDialog( wxWindow *parent, @@ -83,7 +82,6 @@ wxDialog::wxDialog( wxWindow *parent, long style, const wxString &name ) { m_modalShowing = FALSE; - wxTopLevelWindows.Insert( this ); Create( parent, id, title, pos, size, style, name ); } @@ -92,6 +90,8 @@ bool wxDialog::Create( wxWindow *parent, const wxPoint &pos, const wxSize &size, long style, const wxString &name ) { + wxTopLevelWindows.Append( this ); + m_needParent = FALSE; PreCreation( parent, id, pos, size, style, name ); diff --git a/src/gtk/dnd.cpp b/src/gtk/dnd.cpp index 388df88d25..2b894ea995 100644 --- a/src/gtk/dnd.cpp +++ b/src/gtk/dnd.cpp @@ -366,8 +366,99 @@ void wxDropSource::UnregisterWindow(void) #else // NEW_CODE - - +GtkWidget *shape_create_icon (char **data, + gint x, + gint y, + gint px, + gint py, + gint window_type); + +/* XPM */ +static char * gv_xpm[] = { +"40 34 3 1", +" s None c None", +". c black", +"X c white", +" ", +" ", +" ...... ", +" ..XXXXXX.. ", +" .XXXXXXXXXX. ", +" .XXXXXXXXXXXX. ", +" .XXXXXXXXXXXX. ", +" .XXXXXXXXXXXXXX. ", +" .XXX..XXXX..XXX. ", +" ....XX....XX....XX. ", +" .XXX.XXX..XXXX..XXX.... ", +" .XXXXXXXXXXXXXXXXXXX.XXX. ", +" .XXXXXXXXXXXXXXXXXXXXXXXX. ", +" .XXXXXXXXXXXXXXXXXXXXXXXX. ", +" ..XXXXXXXXXXXXXXXXXXXXXX. ", +" .XXXXXXXXXXXXXXXXXX... ", +" ..XXXXXXXXXXXXXXXX. ", +" .XXXXXXXXXXXXXXXX. ", +" .XXXXXXXXXXXXXXXX. ", +" .XXXXXXXXXXXXXXXXX. ", +" .XXXXXXXXXXXXXXXXX. ", +" .XXXXXXXXXXXXXXXXXX. ", +" .XXXXXXXXXXXXXXXXXXX. ", +" .XXXXXXXXXXXXXXXXXXXXX. ", +" .XXXXXXXXXXXXXX.XXXXXXX. ", +" .XXXXXXX.XXXXXXX.XXXXXXX. ", +" .XXXXXXXX.XXXXXXX.XXXXXXX. ", +" .XXXXXXX...XXXXX...XXXXX. ", +" .XXXXXXX. ..... ..... ", +" ..XXXX.. ", +" .... ", +" ", +" ", +" "}; + +/* XPM */ +static char * page_xpm[] = { +/* width height ncolors chars_per_pixel */ +"32 32 5 1", +/* colors */ +" s None c None", +". c black", +"X c wheat", +"o c tan", +"O c #6699FF", +/* pixels */ +" ................... ", +" .XXXXXXXXXXXXXXXXX.. ", +" .XXXXXXXXXXXXXXXXX.o. ", +" .XXXXXXXXXXXXXXXXX.oo. ", +" .XXXXXXXXXXXXXXXXX.ooo. ", +" .XXXXXXXXXXXXXXXXX.oooo. ", +" .XXXXXXXXXXXXXXXXX....... ", +" .XXXXXOOOOOOOOOOXXXooooo. ", +" .XXXXXXXXXXXXXXXXXXooooo. ", +" .XXXXXOOOOOOOOOOXXXXXXXX. ", +" .XXXXXXXXXXXXXXXXXXXXXXX. ", +" .XXXXXXXOOOOOOOOOXXXXXXX. ", +" .XXXXXXXXXXXXXXXXXXXXXXX. ", +" .XXXXXXOOOOOOOOOOXXXXXXX. ", +" .XXXXXXXXXXXXXXXXXXXXXXX. ", +" .XXXXXOOOOOOOOOOXXXXXXXX. ", +" .XXXXXXXXXXXXXXXXXXXXXXX. ", +" .XXXXXXXOOOOOOOOOXXXXXXX. ", +" .XXXXXXXXXXXXXXXXXXXXXXX. ", +" .XXXXXXOOOOOOOOOOXXXXXXX. ", +" .XXXXXXXXXXXXXXXXXXXXXXX. ", +" .XXXXXOOOOOOOOOOXXXXXXXX. ", +" .XXXXXXXXXXXXXXXXXXXXXXX. ", +" .XXXXXXOOOOOOOOOOXXXXXXX. ", +" .XXXXXXXXXXXXXXXXXXXXXXX. ", +" .XXXXXOOOOOOOXXXXXXXXXXX. ", +" .XXXXXXXXXXXXXXXXXXXXXXX. ", +" .XXXXXXXXXXXXXXXXXXXXXXX. ", +" .XXXXXXXXXXXXXXXXXXXXXXX. ", +" .XXXXXXXXXXXXXXXXXXXXXXX. ", +" .XXXXXXXXXXXXXXXXXXXXXXX. ", +" ......................... "}; + + //----------------------------------------------------------------------------- // "drop_data_available_event" //----------------------------------------------------------------------------- @@ -382,7 +473,7 @@ static void gtk_target_callback( GtkWidget *widget, int y = 0; gdk_window_get_pointer( widget->window, &x, &y, (GdkModifierType *) NULL ); - printf( "Drop data is of type %s.\n", event->data_type ); +// printf( "Drop data is of type %s.\n", event->data_type ); target->OnDrop( x, y, (const void*)event->data, (size_t)event->data_numbytes ); } @@ -536,8 +627,6 @@ wxDataFormat wxFileDropTarget::GetFormat(size_t WXUNUSED(n)) const void gtk_drag_callback( GtkWidget *widget, GdkEvent *event, wxDropSource *source ) { - printf( "Data requested for dropping.\n" ); - wxDataObject *data = source->m_data; size_t size = data->GetDataSize(); @@ -603,6 +692,43 @@ wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) ) if (!m_data) return (wxDragResult) wxDragNone; if (m_data->GetDataSize() == 0) return (wxDragResult) wxDragNone; + static GtkWidget *drag_icon = NULL; + static GtkWidget *drop_icon = NULL; + + GdkPoint hotspot_1 = {0,-5 }; + + if (!drag_icon) + { + drag_icon = shape_create_icon ( gv_xpm, + 440, 140, 0,0, GTK_WINDOW_POPUP); + + gtk_signal_connect (GTK_OBJECT (drag_icon), "destroy", + GTK_SIGNAL_FUNC(gtk_widget_destroyed), + &drag_icon); + + gtk_widget_hide (drag_icon); + } + + GdkPoint hotspot_2 = {-5,-5}; + + if (!drop_icon) + { + drop_icon = shape_create_icon ( page_xpm, + 440, 140, 0,0, GTK_WINDOW_POPUP); + + gtk_signal_connect (GTK_OBJECT (drop_icon), "destroy", + GTK_SIGNAL_FUNC(gtk_widget_destroyed), + &drop_icon); + + gtk_widget_hide (drop_icon); + } + + gdk_dnd_set_drag_shape(drag_icon->window, + &hotspot_1, + drop_icon->window, + &hotspot_2); + + GdkWindowPrivate *wp = (GdkWindowPrivate*) m_widget->window; RegisterWindow(); @@ -695,6 +821,129 @@ void wxDropSource::UnregisterWindow(void) gtk_signal_disconnect_by_data( GTK_OBJECT(m_widget), (gpointer)this ); } + +/* + * Shaped Windows + */ +static GdkWindow *root_win = NULL; + +typedef struct _cursoroffset {gint x,y;} CursorOffset; + +static void +shape_pressed (GtkWidget *widget, GdkEventButton *event) +{ + CursorOffset *p; + + /* ignore double and triple click */ + if (event->type != GDK_BUTTON_PRESS) + return; + + p = gtk_object_get_user_data (GTK_OBJECT(widget)); + p->x = (int) event->x; + p->y = (int) event->y; + + gtk_grab_add (widget); + gdk_pointer_grab (widget->window, TRUE, + GDK_BUTTON_RELEASE_MASK | + GDK_BUTTON_MOTION_MASK | + GDK_POINTER_MOTION_HINT_MASK, + NULL, NULL, 0); +} + + +static void +shape_released (GtkWidget *widget) +{ + gtk_grab_remove (widget); + gdk_pointer_ungrab (0); +} + +static void +shape_motion (GtkWidget *widget, + GdkEventMotion *event) +{ + gint xp, yp; + CursorOffset * p; + GdkModifierType mask; + + p = gtk_object_get_user_data (GTK_OBJECT (widget)); + + /* + * Can't use event->x / event->y here + * because I need absolute coordinates. + */ + gdk_window_get_pointer (root_win, &xp, &yp, &mask); + gtk_widget_set_uposition (widget, xp - p->x, yp - p->y); +} + +GtkWidget * +shape_create_icon (char **data, + gint x, + gint y, + gint px, + gint py, + gint window_type) +{ + GtkWidget *window; + GtkWidget *pixmap; + GtkWidget *fixed; + CursorOffset* icon_pos; + GdkGC* gc; + GdkBitmap *gdk_pixmap_mask; + GdkPixmap *gdk_pixmap; + GtkStyle *style; + + style = gtk_widget_get_default_style (); + gc = style->black_gc; + + /* + * GDK_WINDOW_TOPLEVEL works also, giving you a title border + */ + window = gtk_window_new (window_type); + + fixed = gtk_fixed_new (); + gtk_widget_set_usize (fixed, 100,100); + gtk_container_add (GTK_CONTAINER (window), fixed); + gtk_widget_show (fixed); + + gtk_widget_set_events (window, + gtk_widget_get_events (window) | + GDK_BUTTON_MOTION_MASK | + GDK_POINTER_MOTION_HINT_MASK | + GDK_BUTTON_PRESS_MASK); + + gtk_widget_realize (window); + + gdk_pixmap = gdk_pixmap_create_from_xpm_d (window->window, &gdk_pixmap_mask, + &style->bg[GTK_STATE_NORMAL], + (gchar**) data ); + + pixmap = gtk_pixmap_new (gdk_pixmap, gdk_pixmap_mask); + gtk_fixed_put (GTK_FIXED (fixed), pixmap, px,py); + gtk_widget_show (pixmap); + + gtk_widget_shape_combine_mask (window, gdk_pixmap_mask, px,py); + + + gtk_signal_connect (GTK_OBJECT (window), "button_press_event", + GTK_SIGNAL_FUNC (shape_pressed),NULL); + gtk_signal_connect (GTK_OBJECT (window), "button_release_event", + GTK_SIGNAL_FUNC (shape_released),NULL); + gtk_signal_connect (GTK_OBJECT (window), "motion_notify_event", + GTK_SIGNAL_FUNC (shape_motion),NULL); + + icon_pos = g_new (CursorOffset, 1); + gtk_object_set_user_data(GTK_OBJECT(window), icon_pos); + + gtk_widget_set_uposition (window, x, y); + gtk_widget_show (window); + + return window; +} + + + + #endif // NEW_GTK_DND_CODE diff --git a/src/gtk/frame.cpp b/src/gtk/frame.cpp index 0533692316..bfbbda8e30 100644 --- a/src/gtk/frame.cpp +++ b/src/gtk/frame.cpp @@ -108,7 +108,6 @@ wxFrame::wxFrame() m_frameStatusBar = (wxStatusBar *) NULL; m_frameToolBar = (wxToolBar *) NULL; m_sizeSet = FALSE; - wxTopLevelWindows.Insert( this ); } wxFrame::wxFrame( wxWindow *parent, wxWindowID id, const wxString &title, @@ -120,13 +119,14 @@ wxFrame::wxFrame( wxWindow *parent, wxWindowID id, const wxString &title, m_frameToolBar = (wxToolBar *) NULL; m_sizeSet = FALSE; Create( parent, id, title, pos, size, style, name ); - wxTopLevelWindows.Insert( this ); } bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &pos, const wxSize &size, long style, const wxString &name ) { + wxTopLevelWindows.Append( this ); + m_needParent = FALSE; PreCreation( parent, id, pos, size, style, name ); diff --git a/src/gtk1/dcclient.cpp b/src/gtk1/dcclient.cpp index 290d654ddf..854f5d07f5 100644 --- a/src/gtk1/dcclient.cpp +++ b/src/gtk1/dcclient.cpp @@ -829,6 +829,7 @@ void wxPaintDC::SetBackground( const wxBrush &brush ) m_backgroundBrush.GetColour().CalcPixel( m_cmap ); gdk_gc_set_background( m_brushGC, m_backgroundBrush.GetColour().GetColor() ); + gdk_gc_set_background( m_penGC, m_backgroundBrush.GetColour().GetColor() ); gdk_gc_set_background( m_bgGC, m_backgroundBrush.GetColour().GetColor() ); gdk_gc_set_foreground( m_bgGC, m_backgroundBrush.GetColour().GetColor() ); @@ -949,8 +950,13 @@ void wxPaintDC::SetUpDC(void) m_brushGC = gdk_gc_new( m_window ); m_textGC = gdk_gc_new( m_window ); m_bgGC = gdk_gc_new( m_window ); - SetTextForeground( m_textForegroundColour ); - SetTextBackground( m_textBackgroundColour ); + + wxColour tmp_col( m_textForegroundColour ); + m_textForegroundColour = wxNullColour; + SetTextForeground( tmp_col ); + tmp_col = m_textBackgroundColour; + m_textBackgroundColour = wxNullColour; + SetTextBackground( tmp_col ); wxPen tmp_pen( m_pen ); m_pen = wxNullPen; @@ -968,8 +974,6 @@ void wxPaintDC::SetUpDC(void) m_backgroundBrush = wxNullBrush; SetBackground( tmp_brush ); - gdk_gc_set_background( m_penGC, wxWHITE->GetColor() ); - if (!hatch_bitmap) { hatch_bitmap = hatches; diff --git a/src/gtk1/dialog.cpp b/src/gtk1/dialog.cpp index bde6b7e6b4..0e26ee1808 100644 --- a/src/gtk1/dialog.cpp +++ b/src/gtk1/dialog.cpp @@ -74,7 +74,6 @@ wxDialog::wxDialog() { m_title = ""; m_modalShowing = FALSE; - wxTopLevelWindows.Insert( this ); } wxDialog::wxDialog( wxWindow *parent, @@ -83,7 +82,6 @@ wxDialog::wxDialog( wxWindow *parent, long style, const wxString &name ) { m_modalShowing = FALSE; - wxTopLevelWindows.Insert( this ); Create( parent, id, title, pos, size, style, name ); } @@ -92,6 +90,8 @@ bool wxDialog::Create( wxWindow *parent, const wxPoint &pos, const wxSize &size, long style, const wxString &name ) { + wxTopLevelWindows.Append( this ); + m_needParent = FALSE; PreCreation( parent, id, pos, size, style, name ); diff --git a/src/gtk1/dnd.cpp b/src/gtk1/dnd.cpp index 388df88d25..2b894ea995 100644 --- a/src/gtk1/dnd.cpp +++ b/src/gtk1/dnd.cpp @@ -366,8 +366,99 @@ void wxDropSource::UnregisterWindow(void) #else // NEW_CODE - - +GtkWidget *shape_create_icon (char **data, + gint x, + gint y, + gint px, + gint py, + gint window_type); + +/* XPM */ +static char * gv_xpm[] = { +"40 34 3 1", +" s None c None", +". c black", +"X c white", +" ", +" ", +" ...... ", +" ..XXXXXX.. ", +" .XXXXXXXXXX. ", +" .XXXXXXXXXXXX. ", +" .XXXXXXXXXXXX. ", +" .XXXXXXXXXXXXXX. ", +" .XXX..XXXX..XXX. ", +" ....XX....XX....XX. ", +" .XXX.XXX..XXXX..XXX.... ", +" .XXXXXXXXXXXXXXXXXXX.XXX. ", +" .XXXXXXXXXXXXXXXXXXXXXXXX. ", +" .XXXXXXXXXXXXXXXXXXXXXXXX. ", +" ..XXXXXXXXXXXXXXXXXXXXXX. ", +" .XXXXXXXXXXXXXXXXXX... ", +" ..XXXXXXXXXXXXXXXX. ", +" .XXXXXXXXXXXXXXXX. ", +" .XXXXXXXXXXXXXXXX. ", +" .XXXXXXXXXXXXXXXXX. ", +" .XXXXXXXXXXXXXXXXX. ", +" .XXXXXXXXXXXXXXXXXX. ", +" .XXXXXXXXXXXXXXXXXXX. ", +" .XXXXXXXXXXXXXXXXXXXXX. ", +" .XXXXXXXXXXXXXX.XXXXXXX. ", +" .XXXXXXX.XXXXXXX.XXXXXXX. ", +" .XXXXXXXX.XXXXXXX.XXXXXXX. ", +" .XXXXXXX...XXXXX...XXXXX. ", +" .XXXXXXX. ..... ..... ", +" ..XXXX.. ", +" .... ", +" ", +" ", +" "}; + +/* XPM */ +static char * page_xpm[] = { +/* width height ncolors chars_per_pixel */ +"32 32 5 1", +/* colors */ +" s None c None", +". c black", +"X c wheat", +"o c tan", +"O c #6699FF", +/* pixels */ +" ................... ", +" .XXXXXXXXXXXXXXXXX.. ", +" .XXXXXXXXXXXXXXXXX.o. ", +" .XXXXXXXXXXXXXXXXX.oo. ", +" .XXXXXXXXXXXXXXXXX.ooo. ", +" .XXXXXXXXXXXXXXXXX.oooo. ", +" .XXXXXXXXXXXXXXXXX....... ", +" .XXXXXOOOOOOOOOOXXXooooo. ", +" .XXXXXXXXXXXXXXXXXXooooo. ", +" .XXXXXOOOOOOOOOOXXXXXXXX. ", +" .XXXXXXXXXXXXXXXXXXXXXXX. ", +" .XXXXXXXOOOOOOOOOXXXXXXX. ", +" .XXXXXXXXXXXXXXXXXXXXXXX. ", +" .XXXXXXOOOOOOOOOOXXXXXXX. ", +" .XXXXXXXXXXXXXXXXXXXXXXX. ", +" .XXXXXOOOOOOOOOOXXXXXXXX. ", +" .XXXXXXXXXXXXXXXXXXXXXXX. ", +" .XXXXXXXOOOOOOOOOXXXXXXX. ", +" .XXXXXXXXXXXXXXXXXXXXXXX. ", +" .XXXXXXOOOOOOOOOOXXXXXXX. ", +" .XXXXXXXXXXXXXXXXXXXXXXX. ", +" .XXXXXOOOOOOOOOOXXXXXXXX. ", +" .XXXXXXXXXXXXXXXXXXXXXXX. ", +" .XXXXXXOOOOOOOOOOXXXXXXX. ", +" .XXXXXXXXXXXXXXXXXXXXXXX. ", +" .XXXXXOOOOOOOXXXXXXXXXXX. ", +" .XXXXXXXXXXXXXXXXXXXXXXX. ", +" .XXXXXXXXXXXXXXXXXXXXXXX. ", +" .XXXXXXXXXXXXXXXXXXXXXXX. ", +" .XXXXXXXXXXXXXXXXXXXXXXX. ", +" .XXXXXXXXXXXXXXXXXXXXXXX. ", +" ......................... "}; + + //----------------------------------------------------------------------------- // "drop_data_available_event" //----------------------------------------------------------------------------- @@ -382,7 +473,7 @@ static void gtk_target_callback( GtkWidget *widget, int y = 0; gdk_window_get_pointer( widget->window, &x, &y, (GdkModifierType *) NULL ); - printf( "Drop data is of type %s.\n", event->data_type ); +// printf( "Drop data is of type %s.\n", event->data_type ); target->OnDrop( x, y, (const void*)event->data, (size_t)event->data_numbytes ); } @@ -536,8 +627,6 @@ wxDataFormat wxFileDropTarget::GetFormat(size_t WXUNUSED(n)) const void gtk_drag_callback( GtkWidget *widget, GdkEvent *event, wxDropSource *source ) { - printf( "Data requested for dropping.\n" ); - wxDataObject *data = source->m_data; size_t size = data->GetDataSize(); @@ -603,6 +692,43 @@ wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) ) if (!m_data) return (wxDragResult) wxDragNone; if (m_data->GetDataSize() == 0) return (wxDragResult) wxDragNone; + static GtkWidget *drag_icon = NULL; + static GtkWidget *drop_icon = NULL; + + GdkPoint hotspot_1 = {0,-5 }; + + if (!drag_icon) + { + drag_icon = shape_create_icon ( gv_xpm, + 440, 140, 0,0, GTK_WINDOW_POPUP); + + gtk_signal_connect (GTK_OBJECT (drag_icon), "destroy", + GTK_SIGNAL_FUNC(gtk_widget_destroyed), + &drag_icon); + + gtk_widget_hide (drag_icon); + } + + GdkPoint hotspot_2 = {-5,-5}; + + if (!drop_icon) + { + drop_icon = shape_create_icon ( page_xpm, + 440, 140, 0,0, GTK_WINDOW_POPUP); + + gtk_signal_connect (GTK_OBJECT (drop_icon), "destroy", + GTK_SIGNAL_FUNC(gtk_widget_destroyed), + &drop_icon); + + gtk_widget_hide (drop_icon); + } + + gdk_dnd_set_drag_shape(drag_icon->window, + &hotspot_1, + drop_icon->window, + &hotspot_2); + + GdkWindowPrivate *wp = (GdkWindowPrivate*) m_widget->window; RegisterWindow(); @@ -695,6 +821,129 @@ void wxDropSource::UnregisterWindow(void) gtk_signal_disconnect_by_data( GTK_OBJECT(m_widget), (gpointer)this ); } + +/* + * Shaped Windows + */ +static GdkWindow *root_win = NULL; + +typedef struct _cursoroffset {gint x,y;} CursorOffset; + +static void +shape_pressed (GtkWidget *widget, GdkEventButton *event) +{ + CursorOffset *p; + + /* ignore double and triple click */ + if (event->type != GDK_BUTTON_PRESS) + return; + + p = gtk_object_get_user_data (GTK_OBJECT(widget)); + p->x = (int) event->x; + p->y = (int) event->y; + + gtk_grab_add (widget); + gdk_pointer_grab (widget->window, TRUE, + GDK_BUTTON_RELEASE_MASK | + GDK_BUTTON_MOTION_MASK | + GDK_POINTER_MOTION_HINT_MASK, + NULL, NULL, 0); +} + + +static void +shape_released (GtkWidget *widget) +{ + gtk_grab_remove (widget); + gdk_pointer_ungrab (0); +} + +static void +shape_motion (GtkWidget *widget, + GdkEventMotion *event) +{ + gint xp, yp; + CursorOffset * p; + GdkModifierType mask; + + p = gtk_object_get_user_data (GTK_OBJECT (widget)); + + /* + * Can't use event->x / event->y here + * because I need absolute coordinates. + */ + gdk_window_get_pointer (root_win, &xp, &yp, &mask); + gtk_widget_set_uposition (widget, xp - p->x, yp - p->y); +} + +GtkWidget * +shape_create_icon (char **data, + gint x, + gint y, + gint px, + gint py, + gint window_type) +{ + GtkWidget *window; + GtkWidget *pixmap; + GtkWidget *fixed; + CursorOffset* icon_pos; + GdkGC* gc; + GdkBitmap *gdk_pixmap_mask; + GdkPixmap *gdk_pixmap; + GtkStyle *style; + + style = gtk_widget_get_default_style (); + gc = style->black_gc; + + /* + * GDK_WINDOW_TOPLEVEL works also, giving you a title border + */ + window = gtk_window_new (window_type); + + fixed = gtk_fixed_new (); + gtk_widget_set_usize (fixed, 100,100); + gtk_container_add (GTK_CONTAINER (window), fixed); + gtk_widget_show (fixed); + + gtk_widget_set_events (window, + gtk_widget_get_events (window) | + GDK_BUTTON_MOTION_MASK | + GDK_POINTER_MOTION_HINT_MASK | + GDK_BUTTON_PRESS_MASK); + + gtk_widget_realize (window); + + gdk_pixmap = gdk_pixmap_create_from_xpm_d (window->window, &gdk_pixmap_mask, + &style->bg[GTK_STATE_NORMAL], + (gchar**) data ); + + pixmap = gtk_pixmap_new (gdk_pixmap, gdk_pixmap_mask); + gtk_fixed_put (GTK_FIXED (fixed), pixmap, px,py); + gtk_widget_show (pixmap); + + gtk_widget_shape_combine_mask (window, gdk_pixmap_mask, px,py); + + + gtk_signal_connect (GTK_OBJECT (window), "button_press_event", + GTK_SIGNAL_FUNC (shape_pressed),NULL); + gtk_signal_connect (GTK_OBJECT (window), "button_release_event", + GTK_SIGNAL_FUNC (shape_released),NULL); + gtk_signal_connect (GTK_OBJECT (window), "motion_notify_event", + GTK_SIGNAL_FUNC (shape_motion),NULL); + + icon_pos = g_new (CursorOffset, 1); + gtk_object_set_user_data(GTK_OBJECT(window), icon_pos); + + gtk_widget_set_uposition (window, x, y); + gtk_widget_show (window); + + return window; +} + + + + #endif // NEW_GTK_DND_CODE diff --git a/src/gtk1/frame.cpp b/src/gtk1/frame.cpp index 0533692316..bfbbda8e30 100644 --- a/src/gtk1/frame.cpp +++ b/src/gtk1/frame.cpp @@ -108,7 +108,6 @@ wxFrame::wxFrame() m_frameStatusBar = (wxStatusBar *) NULL; m_frameToolBar = (wxToolBar *) NULL; m_sizeSet = FALSE; - wxTopLevelWindows.Insert( this ); } wxFrame::wxFrame( wxWindow *parent, wxWindowID id, const wxString &title, @@ -120,13 +119,14 @@ wxFrame::wxFrame( wxWindow *parent, wxWindowID id, const wxString &title, m_frameToolBar = (wxToolBar *) NULL; m_sizeSet = FALSE; Create( parent, id, title, pos, size, style, name ); - wxTopLevelWindows.Insert( this ); } bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &pos, const wxSize &size, long style, const wxString &name ) { + wxTopLevelWindows.Append( this ); + m_needParent = FALSE; PreCreation( parent, id, pos, size, style, name ); diff --git a/wx-config.in b/wx-config.in index 44b607839e..3c9515c273 100755 --- a/wx-config.in +++ b/wx-config.in @@ -36,7 +36,7 @@ while test $# -gt 0; do echo $exec_prefix ;; --version) - echo 1.94 + echo 1.97 ;; --cflags) if test @includedir@ != /usr/include ; then