From e52f60e65236befe1a509cc3c1823607be0d2b3c Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Mon, 23 Nov 1998 12:43:57 +0000 Subject: [PATCH] Added install scripts in missing places Fixed wxFrame resize behaviour for GTK 1.1.3 Added GetMousePosition Added const char** constructors to icon and bitmap Autolayout should now work for wxDialog git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1024 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/install-sh | 250 ++++++++++++++++++++++++++++++++++ include/wx/gdicmn.h | 4 +- include/wx/gtk/bitmap.h | 1 + include/wx/gtk/dialog.h | 5 +- include/wx/gtk/icon.h | 5 +- include/wx/gtk1/bitmap.h | 1 + include/wx/gtk1/dialog.h | 5 +- include/wx/gtk1/icon.h | 5 +- include/wx/install-sh | 250 ++++++++++++++++++++++++++++++++++ samples/controls/controls.cpp | 21 ++- src/Makefile.in | 17 +-- src/common/framecmn.cpp | 7 +- src/common/resource.cpp | 2 +- src/gtk.inc | 1 - src/gtk/bitmap.cpp | 23 ++++ src/gtk/dialog.cpp | 84 +++++++++++- src/gtk/frame.cpp | 41 ++++-- src/gtk/icon.cpp | 23 ++-- src/gtk/utilsgtk.cpp | 96 +++++++------ src/gtk/win_gtk.c | 6 +- src/gtk1/bitmap.cpp | 23 ++++ src/gtk1/dialog.cpp | 84 +++++++++++- src/gtk1/frame.cpp | 41 ++++-- src/gtk1/icon.cpp | 23 ++-- src/gtk1/utilsgtk.cpp | 96 +++++++------ src/gtk1/win_gtk.c | 6 +- 26 files changed, 952 insertions(+), 168 deletions(-) create mode 100755 include/install-sh create mode 100755 include/wx/install-sh diff --git a/include/install-sh b/include/install-sh new file mode 100755 index 0000000000..ebc66913e9 --- /dev/null +++ b/include/install-sh @@ -0,0 +1,250 @@ +#! /bin/sh +# +# install - install a program, script, or datafile +# This comes from X11R5 (mit/util/scripts/install.sh). +# +# Copyright 1991 by the Massachusetts Institute of Technology +# +# Permission to use, copy, modify, distribute, and sell this software and its +# documentation for any purpose is hereby granted without fee, provided that +# the above copyright notice appear in all copies and that both that +# copyright notice and this permission notice appear in supporting +# documentation, and that the name of M.I.T. not be used in advertising or +# publicity pertaining to distribution of the software without specific, +# written prior permission. M.I.T. makes no representations about the +# suitability of this software for any purpose. It is provided "as is" +# without express or implied warranty. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. It can only install one file at a time, a restriction +# shared with many OS's install programs. + + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit="${DOITPROG-}" + + +# put in absolute paths if you don't have them in your path; or use env. vars. + +mvprog="${MVPROG-mv}" +cpprog="${CPPROG-cp}" +chmodprog="${CHMODPROG-chmod}" +chownprog="${CHOWNPROG-chown}" +chgrpprog="${CHGRPPROG-chgrp}" +stripprog="${STRIPPROG-strip}" +rmprog="${RMPROG-rm}" +mkdirprog="${MKDIRPROG-mkdir}" + +transformbasename="" +transform_arg="" +instcmd="$mvprog" +chmodcmd="$chmodprog 0755" +chowncmd="" +chgrpcmd="" +stripcmd="" +rmcmd="$rmprog -f" +mvcmd="$mvprog" +src="" +dst="" +dir_arg="" + +while [ x"$1" != x ]; do + case $1 in + -c) instcmd="$cpprog" + shift + continue;; + + -d) dir_arg=true + shift + continue;; + + -m) chmodcmd="$chmodprog $2" + shift + shift + continue;; + + -o) chowncmd="$chownprog $2" + shift + shift + continue;; + + -g) chgrpcmd="$chgrpprog $2" + shift + shift + continue;; + + -s) stripcmd="$stripprog" + shift + continue;; + + -t=*) transformarg=`echo $1 | sed 's/-t=//'` + shift + continue;; + + -b=*) transformbasename=`echo $1 | sed 's/-b=//'` + shift + continue;; + + *) if [ x"$src" = x ] + then + src=$1 + else + # this colon is to work around a 386BSD /bin/sh bug + : + dst=$1 + fi + shift + continue;; + esac +done + +if [ x"$src" = x ] +then + echo "install: no input file specified" + exit 1 +else + true +fi + +if [ x"$dir_arg" != x ]; then + dst=$src + src="" + + if [ -d $dst ]; then + instcmd=: + else + instcmd=mkdir + fi +else + +# Waiting for this to be detected by the "$instcmd $src $dsttmp" command +# might cause directories to be created, which would be especially bad +# if $src (and thus $dsttmp) contains '*'. + + if [ -f $src -o -d $src ] + then + true + else + echo "install: $src does not exist" + exit 1 + fi + + if [ x"$dst" = x ] + then + echo "install: no destination specified" + exit 1 + else + true + fi + +# If destination is a directory, append the input filename; if your system +# does not like double slashes in filenames, you may need to add some logic + + if [ -d $dst ] + then + dst="$dst"/`basename $src` + else + true + fi +fi + +## this sed command emulates the dirname command +dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` + +# Make sure that the destination directory exists. +# this part is taken from Noah Friedman's mkinstalldirs script + +# Skip lots of stat calls in the usual case. +if [ ! -d "$dstdir" ]; then +defaultIFS=' +' +IFS="${IFS-${defaultIFS}}" + +oIFS="${IFS}" +# Some sh's can't handle IFS=/ for some reason. +IFS='%' +set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` +IFS="${oIFS}" + +pathcomp='' + +while [ $# -ne 0 ] ; do + pathcomp="${pathcomp}${1}" + shift + + if [ ! -d "${pathcomp}" ] ; + then + $mkdirprog "${pathcomp}" + else + true + fi + + pathcomp="${pathcomp}/" +done +fi + +if [ x"$dir_arg" != x ] +then + $doit $instcmd $dst && + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi +else + +# If we're going to rename the final executable, determine the name now. + + if [ x"$transformarg" = x ] + then + dstfile=`basename $dst` + else + dstfile=`basename $dst $transformbasename | + sed $transformarg`$transformbasename + fi + +# don't allow the sed command to completely eliminate the filename + + if [ x"$dstfile" = x ] + then + dstfile=`basename $dst` + else + true + fi + +# Make a temp file name in the proper directory. + + dsttmp=$dstdir/#inst.$$# + +# Move or copy the file name to the temp name + + $doit $instcmd $src $dsttmp && + + trap "rm -f ${dsttmp}" 0 && + +# and set any options; do chmod last to preserve setuid bits + +# If any of these fail, we abort the whole thing. If we want to +# ignore errors from any of these, just make sure not to ignore +# errors from the above "$doit $instcmd $src $dsttmp" command. + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && + +# Now rename the file to the real destination. + + $doit $rmcmd -f $dstdir/$dstfile && + $doit $mvcmd $dsttmp $dstdir/$dstfile + +fi && + + +exit 0 diff --git a/include/wx/gdicmn.h b/include/wx/gdicmn.h index f0719dbe00..2f2570797a 100644 --- a/include/wx/gdicmn.h +++ b/include/wx/gdicmn.h @@ -331,9 +331,9 @@ extern void WXDLLEXPORT wxSetCursor(const wxCursor& cursor); // Load from a resource # define wxICON(X) wxIcon("" #X "") -#elif defined(__WXGTK__) +#elif defined(__WXGTK__) || defined(__WXMOTIF__) // Initialize from an included XPM -# define wxICON(X) wxIcon(X##_xpm) +# define wxICON(X) wxIcon( (const char**) X##_xpm ) #else // This will usually mean something on any platform diff --git a/include/wx/gtk/bitmap.h b/include/wx/gtk/bitmap.h index 8051b4da71..35d5c3008a 100644 --- a/include/wx/gtk/bitmap.h +++ b/include/wx/gtk/bitmap.h @@ -62,6 +62,7 @@ public: wxBitmap( int width, int height, int depth = -1 ); wxBitmap( const char bits[], int width, int height, int depth = 1 ); wxBitmap( const wxImage &image ); + wxBitmap( const char **bits ); wxBitmap( char **bits ); wxBitmap( const wxBitmap& bmp ); wxBitmap( const wxBitmap* bmp ); diff --git a/include/wx/gtk/dialog.h b/include/wx/gtk/dialog.h index 2e3607d09c..25cfa99c37 100644 --- a/include/wx/gtk/dialog.h +++ b/include/wx/gtk/dialog.h @@ -62,7 +62,8 @@ public: void OnApply( wxCommandEvent &event ); void OnCancel( wxCommandEvent &event ); void OnOK( wxCommandEvent &event ); - void OnPaint(wxPaintEvent& event); + void OnPaint( wxPaintEvent& event ); + void OnSize( wxSizeEvent &event ); /* void OnCharHook( wxKeyEvent& event ); */ @@ -93,6 +94,8 @@ public: // implementation + virtual void GtkOnSize( int x, int y, int width, int height ); + bool m_modalShowing; wxString m_title; wxIcon m_icon; diff --git a/include/wx/gtk/icon.h b/include/wx/gtk/icon.h index ee31769568..2b54f60c05 100644 --- a/include/wx/gtk/icon.h +++ b/include/wx/gtk/icon.h @@ -36,8 +36,9 @@ class wxIcon: public wxBitmap public: wxIcon(void); - wxIcon(const wxIcon& icon); - wxIcon(const wxIcon* icon); + wxIcon( const wxIcon& icon); + wxIcon( const wxIcon* icon); + wxIcon( const char **bits, int width=-1, int height=-1 ); wxIcon( char **bits, int width=-1, int height=-1 ); wxIcon& operator = (const wxIcon& icon); diff --git a/include/wx/gtk1/bitmap.h b/include/wx/gtk1/bitmap.h index 8051b4da71..35d5c3008a 100644 --- a/include/wx/gtk1/bitmap.h +++ b/include/wx/gtk1/bitmap.h @@ -62,6 +62,7 @@ public: wxBitmap( int width, int height, int depth = -1 ); wxBitmap( const char bits[], int width, int height, int depth = 1 ); wxBitmap( const wxImage &image ); + wxBitmap( const char **bits ); wxBitmap( char **bits ); wxBitmap( const wxBitmap& bmp ); wxBitmap( const wxBitmap* bmp ); diff --git a/include/wx/gtk1/dialog.h b/include/wx/gtk1/dialog.h index 2e3607d09c..25cfa99c37 100644 --- a/include/wx/gtk1/dialog.h +++ b/include/wx/gtk1/dialog.h @@ -62,7 +62,8 @@ public: void OnApply( wxCommandEvent &event ); void OnCancel( wxCommandEvent &event ); void OnOK( wxCommandEvent &event ); - void OnPaint(wxPaintEvent& event); + void OnPaint( wxPaintEvent& event ); + void OnSize( wxSizeEvent &event ); /* void OnCharHook( wxKeyEvent& event ); */ @@ -93,6 +94,8 @@ public: // implementation + virtual void GtkOnSize( int x, int y, int width, int height ); + bool m_modalShowing; wxString m_title; wxIcon m_icon; diff --git a/include/wx/gtk1/icon.h b/include/wx/gtk1/icon.h index ee31769568..2b54f60c05 100644 --- a/include/wx/gtk1/icon.h +++ b/include/wx/gtk1/icon.h @@ -36,8 +36,9 @@ class wxIcon: public wxBitmap public: wxIcon(void); - wxIcon(const wxIcon& icon); - wxIcon(const wxIcon* icon); + wxIcon( const wxIcon& icon); + wxIcon( const wxIcon* icon); + wxIcon( const char **bits, int width=-1, int height=-1 ); wxIcon( char **bits, int width=-1, int height=-1 ); wxIcon& operator = (const wxIcon& icon); diff --git a/include/wx/install-sh b/include/wx/install-sh new file mode 100755 index 0000000000..ebc66913e9 --- /dev/null +++ b/include/wx/install-sh @@ -0,0 +1,250 @@ +#! /bin/sh +# +# install - install a program, script, or datafile +# This comes from X11R5 (mit/util/scripts/install.sh). +# +# Copyright 1991 by the Massachusetts Institute of Technology +# +# Permission to use, copy, modify, distribute, and sell this software and its +# documentation for any purpose is hereby granted without fee, provided that +# the above copyright notice appear in all copies and that both that +# copyright notice and this permission notice appear in supporting +# documentation, and that the name of M.I.T. not be used in advertising or +# publicity pertaining to distribution of the software without specific, +# written prior permission. M.I.T. makes no representations about the +# suitability of this software for any purpose. It is provided "as is" +# without express or implied warranty. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. It can only install one file at a time, a restriction +# shared with many OS's install programs. + + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit="${DOITPROG-}" + + +# put in absolute paths if you don't have them in your path; or use env. vars. + +mvprog="${MVPROG-mv}" +cpprog="${CPPROG-cp}" +chmodprog="${CHMODPROG-chmod}" +chownprog="${CHOWNPROG-chown}" +chgrpprog="${CHGRPPROG-chgrp}" +stripprog="${STRIPPROG-strip}" +rmprog="${RMPROG-rm}" +mkdirprog="${MKDIRPROG-mkdir}" + +transformbasename="" +transform_arg="" +instcmd="$mvprog" +chmodcmd="$chmodprog 0755" +chowncmd="" +chgrpcmd="" +stripcmd="" +rmcmd="$rmprog -f" +mvcmd="$mvprog" +src="" +dst="" +dir_arg="" + +while [ x"$1" != x ]; do + case $1 in + -c) instcmd="$cpprog" + shift + continue;; + + -d) dir_arg=true + shift + continue;; + + -m) chmodcmd="$chmodprog $2" + shift + shift + continue;; + + -o) chowncmd="$chownprog $2" + shift + shift + continue;; + + -g) chgrpcmd="$chgrpprog $2" + shift + shift + continue;; + + -s) stripcmd="$stripprog" + shift + continue;; + + -t=*) transformarg=`echo $1 | sed 's/-t=//'` + shift + continue;; + + -b=*) transformbasename=`echo $1 | sed 's/-b=//'` + shift + continue;; + + *) if [ x"$src" = x ] + then + src=$1 + else + # this colon is to work around a 386BSD /bin/sh bug + : + dst=$1 + fi + shift + continue;; + esac +done + +if [ x"$src" = x ] +then + echo "install: no input file specified" + exit 1 +else + true +fi + +if [ x"$dir_arg" != x ]; then + dst=$src + src="" + + if [ -d $dst ]; then + instcmd=: + else + instcmd=mkdir + fi +else + +# Waiting for this to be detected by the "$instcmd $src $dsttmp" command +# might cause directories to be created, which would be especially bad +# if $src (and thus $dsttmp) contains '*'. + + if [ -f $src -o -d $src ] + then + true + else + echo "install: $src does not exist" + exit 1 + fi + + if [ x"$dst" = x ] + then + echo "install: no destination specified" + exit 1 + else + true + fi + +# If destination is a directory, append the input filename; if your system +# does not like double slashes in filenames, you may need to add some logic + + if [ -d $dst ] + then + dst="$dst"/`basename $src` + else + true + fi +fi + +## this sed command emulates the dirname command +dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` + +# Make sure that the destination directory exists. +# this part is taken from Noah Friedman's mkinstalldirs script + +# Skip lots of stat calls in the usual case. +if [ ! -d "$dstdir" ]; then +defaultIFS=' +' +IFS="${IFS-${defaultIFS}}" + +oIFS="${IFS}" +# Some sh's can't handle IFS=/ for some reason. +IFS='%' +set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` +IFS="${oIFS}" + +pathcomp='' + +while [ $# -ne 0 ] ; do + pathcomp="${pathcomp}${1}" + shift + + if [ ! -d "${pathcomp}" ] ; + then + $mkdirprog "${pathcomp}" + else + true + fi + + pathcomp="${pathcomp}/" +done +fi + +if [ x"$dir_arg" != x ] +then + $doit $instcmd $dst && + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi +else + +# If we're going to rename the final executable, determine the name now. + + if [ x"$transformarg" = x ] + then + dstfile=`basename $dst` + else + dstfile=`basename $dst $transformbasename | + sed $transformarg`$transformbasename + fi + +# don't allow the sed command to completely eliminate the filename + + if [ x"$dstfile" = x ] + then + dstfile=`basename $dst` + else + true + fi + +# Make a temp file name in the proper directory. + + dsttmp=$dstdir/#inst.$$# + +# Move or copy the file name to the temp name + + $doit $instcmd $src $dsttmp && + + trap "rm -f ${dsttmp}" 0 && + +# and set any options; do chmod last to preserve setuid bits + +# If any of these fail, we abort the whole thing. If we want to +# ignore errors from any of these, just make sure not to ignore +# errors from the above "$doit $instcmd $src $dsttmp" command. + + if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && + if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && + if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && + if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && + +# Now rename the file to the real destination. + + $doit $rmcmd -f $dstdir/$dstfile && + $doit $mvcmd $dsttmp $dstdir/$dstfile + +fi && + + +exit 0 diff --git a/samples/controls/controls.cpp b/samples/controls/controls.cpp index 6bd7b650e7..9af561f2fe 100644 --- a/samples/controls/controls.cpp +++ b/samples/controls/controls.cpp @@ -119,11 +119,10 @@ bool MyApp::OnInit(void) MyFrame *frame = new MyFrame((wxFrame *) NULL, (char *) "Controls wxWindows App", 50, 50, 530, 420 ); // Give it an icon -#ifdef __WXMSW__ - frame->SetIcon(wxIcon("mondrian")); -#else - frame->SetIcon(wxIcon( mondrian_xpm )); -#endif + // The wxICON() macros loads an icon from a resource under Windows + // and uses an #included XPM image under GTK+ and Motif + + frame->SetIcon( wxICON(mondrian) ); wxMenu *file_menu = new wxMenu; @@ -270,12 +269,12 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) : #else wxImageList *imagelist = new wxImageList(32, 32); - imagelist-> Add( wxBitmap( list_xpm )); - imagelist-> Add( wxBitmap( choice_xpm )); - imagelist-> Add( wxBitmap( combo_xpm )); - imagelist-> Add( wxBitmap( text_xpm )); - imagelist-> Add( wxBitmap( radio_xpm )); - imagelist-> Add( wxBitmap( gauge_xpm )); + imagelist-> Add( wxBitmap( (const char**) list_xpm )); + imagelist-> Add( wxBitmap( (const char**) choice_xpm )); + imagelist-> Add( wxBitmap( (const char**) combo_xpm )); + imagelist-> Add( wxBitmap( (const char**) text_xpm )); + imagelist-> Add( wxBitmap( (const char**) radio_xpm )); + imagelist-> Add( wxBitmap( (const char**) gauge_xpm )); #endif wxButton *button = (wxButton*)NULL; diff --git a/src/Makefile.in b/src/Makefile.in index afe872a3d2..481eda7e0e 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -101,22 +101,23 @@ install:: $(INSTALL_DATA) $$f $(includedir)/wx/protocol/$$f ; \ done @echo " Moving setup.h to library path" - @$(INSTALL) -d $(libdir)/wx/include/wx/gtk ;\ + @cd $(WXBASEDIR)/src ; \ + $(INSTALL) -d $(libdir)/wx/include/wx/gtk ;\ mv $(includedir)/wx/gtk/setup.h $(libdir)/wx/include/wx/gtk/setup.h ; @echo " Copying wx-config" - @cd $(WXBASEDIR) ; \ - $(INSTALL) -d $(bindir) ;\ + @cd $(WXBASEDIR)/src ; \ + $(INSTALL) -d $(bindir) ; \ rm -f $(bindir)/wx-config ; \ - $(INSTALL_PROGRAM) wx-config $(bindir)/wx-config + $(INSTALL_PROGRAM) $(WXBASEDIR)/wx-config $(bindir)/wx-config @echo " Copying static library" - @cd $(WXBASEDIR)/lib/$(OS) ; \ + @cd $(WXBASEDIR)/src ; \ rm -f $(libdir)/$(STATIC_LIBRARY) ; \ - $(INSTALL_DATA) $(STATIC_LIBRARY) $(libdir)/$(STATIC_LIBRARY) + $(INSTALL_DATA) $(WXBASEDIR)/lib/$(OS)/$(STATIC_LIBRARY) $(libdir)/$(STATIC_LIBRARY) @if test -f $(WXBASEDIR)/lib/$(OS)/$(SHARED_LIBRARY) ; then \ echo " Copying shared library" ; \ - cd $(WXBASEDIR)/lib/$(OS) ; \ + @cd $(WXBASEDIR)/src ; \ rm -f $(libdir)/lib$(LIB_TARGET).so* ; \ - $(INSTALL_PROGRAM) $(SHARED_LIBRARY) $(libdir)/$(SHARED_LIBRARY) ; \ + $(INSTALL_PROGRAM) $(WXBASEDIR)/lib/$(OS)/$(SHARED_LIBRARY) $(libdir)/$(SHARED_LIBRARY) ; \ $(LN_S) $(SHARED_LIBRARY) $(libdir)/lib$(LIB_TARGET).so.$(LIB_MAJOR) ; \ $(LN_S) $(SHARED_LIBRARY) $(libdir)/lib$(LIB_TARGET).so ; \ echo " " ; \ diff --git a/src/common/framecmn.cpp b/src/common/framecmn.cpp index e76404c9c9..aa326ecdf8 100644 --- a/src/common/framecmn.cpp +++ b/src/common/framecmn.cpp @@ -17,17 +17,14 @@ #include "wx/frame.h" #include "wx/menu.h" +#include "wx/menuitem.h" -// wxGTK is a special case because it doesn't use the generic wxMenuItem -// class, but it's own (already defined in wx/menu.h) one #ifndef __WXGTK__ - #include "wx/menuitem.h" -#endif //WXGTK - void wxFrame::OnIdle(wxIdleEvent& WXUNUSED(event) ) { DoMenuUpdates(); } +#endif // update all menus void wxFrame::DoMenuUpdates() diff --git a/src/common/resource.cpp b/src/common/resource.cpp index 0c2cc28936..5816feab51 100644 --- a/src/common/resource.cpp +++ b/src/common/resource.cpp @@ -2249,7 +2249,7 @@ wxIcon wxResourceCreateIcon(const wxString& resource, wxResourceTable *table) "Forgot to use wxResourceLoadIconData?"), (const char*) name); return (wxIcon *) NULL; } - return wxIcon((char **)item->GetValue1(), (int)item->GetValue2(), (int)item->GetValue3()); + return wxIcon((const char **)item->GetValue1(), (int)item->GetValue2(), (int)item->GetValue3()); #else wxLogWarning(_("No XBM facility available!")); #endif diff --git a/src/gtk.inc b/src/gtk.inc index b13843feb2..d2119a1df0 100644 --- a/src/gtk.inc +++ b/src/gtk.inc @@ -48,7 +48,6 @@ LIB_CPP_SRC=\ common/framecmn.cpp \ common/stream.cpp \ common/datstrm.cpp \ - common/wfstream.cpp \ common/mstream.cpp \ common/zstream.cpp \ common/objstrm.cpp \ diff --git a/src/gtk/bitmap.cpp b/src/gtk/bitmap.cpp index 809fcd3984..4fcbd352e0 100644 --- a/src/gtk/bitmap.cpp +++ b/src/gtk/bitmap.cpp @@ -117,6 +117,29 @@ wxBitmap::wxBitmap( int width, int height, int depth ) if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this); } +wxBitmap::wxBitmap( const char **bits ) +{ + wxCHECK_RET( bits != NULL, "invalid bitmap data" ) + + m_refData = new wxBitmapRefData(); + + GdkBitmap *mask = (GdkBitmap*) NULL; + GdkWindow *parent = (GdkWindow*) &gdk_root_parent; + + M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm_d( parent, &mask, NULL, (gchar **) bits ); + + if (mask) + { + M_BMPDATA->m_mask = new wxMask(); + M_BMPDATA->m_mask->m_bitmap = mask; + } + + gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) ); + + M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth; // ? + if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this); +} + wxBitmap::wxBitmap( char **bits ) { wxCHECK_RET( bits != NULL, "invalid bitmap data" ) diff --git a/src/gtk/dialog.cpp b/src/gtk/dialog.cpp index 5df777a91e..bde6b7e6b4 100644 --- a/src/gtk/dialog.cpp +++ b/src/gtk/dialog.cpp @@ -38,6 +38,24 @@ bool gtk_dialog_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED return TRUE; } +//----------------------------------------------------------------------------- +// "size_allocate" +//----------------------------------------------------------------------------- + +static void gtk_dialog_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxDialog *win ) +{ + if (!win->HasVMT()) return; + +/* + printf( "OnDialogResize from " ); + if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) + printf( win->GetClassInfo()->GetClassName() ); + printf( ".\n" ); +*/ + + win->GtkOnSize( alloc->x, alloc->y, alloc->width, alloc->height ); +} + //----------------------------------------------------------------------------- // wxDialog //----------------------------------------------------------------------------- @@ -46,6 +64,7 @@ BEGIN_EVENT_TABLE(wxDialog,wxPanel) EVT_BUTTON (wxID_OK, wxDialog::OnOK) EVT_BUTTON (wxID_CANCEL, wxDialog::OnCancel) EVT_BUTTON (wxID_APPLY, wxDialog::OnApply) + EVT_SIZE (wxDialog::OnSize) EVT_CLOSE (wxDialog::OnCloseWindow) END_EVENT_TABLE() @@ -85,6 +104,9 @@ bool wxDialog::Create( wxWindow *parent, gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event", GTK_SIGNAL_FUNC(gtk_dialog_delete_callback), (gpointer)this ); + gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", + GTK_SIGNAL_FUNC(gtk_dialog_size_callback), (gpointer)this ); + m_wxwindow = gtk_myfixed_new(); gtk_widget_show( m_wxwindow ); GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); @@ -194,6 +216,66 @@ void wxDialog::OnCloseWindow( wxCloseEvent& event ) } } +void wxDialog::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height ) +{ + // due to a bug in gtk, x,y are always 0 + // m_x = x; + // m_y = y; + + if ((m_height == height) && (m_width == width) && + (m_sizeSet)) return; + if (!m_wxwindow) return; + + m_width = width; + m_height = height; + + if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth; + if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight; + if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_minWidth; + if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_minHeight; + + gtk_widget_set_usize( m_widget, m_width, m_height ); + + m_sizeSet = TRUE; + + wxSizeEvent event( wxSize(m_width,m_height), GetId() ); + event.SetEventObject( this ); + GetEventHandler()->ProcessEvent( event ); +} + +void wxDialog::OnSize( wxSizeEvent &WXUNUSED(event) ) +{ + wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); + + if (GetAutoLayout()) + { + Layout(); + } + else + { + // no child: go out ! + if (!GetChildren()->First()) return; + + // do we have exactly one child? + wxWindow *child = (wxWindow *) NULL; + for(wxNode *node = GetChildren()->First(); node; node = node->Next()) + { + wxWindow *win = (wxWindow *)node->Data(); + if (!IS_KIND_OF(win,wxFrame) && !IS_KIND_OF(win,wxDialog)) + { + // it's the second one: do nothing + if (child) return; + child = win; + } + } + + // yes: set it's size to fill all the frame + int client_x, client_y; + GetClientSize( &client_x, &client_y ); + child->SetSize( 1, 1, client_x-2, client_y); + } +} + void wxDialog::SetSize( int x, int y, int width, int height, int sizeFlags ) { wxASSERT_MSG( (m_widget != NULL), "invalid window" ); @@ -254,7 +336,7 @@ void wxDialog::SetSize( int x, int y, int width, int height, int sizeFlags ) wxSizeEvent event( wxSize(m_width,m_height), GetId() ); event.SetEventObject( this ); - ProcessEvent( event ); + GetEventHandler()->ProcessEvent( event ); m_resizing = FALSE; } diff --git a/src/gtk/frame.cpp b/src/gtk/frame.cpp index 6a593bf782..edce82c9fc 100644 --- a/src/gtk/frame.cpp +++ b/src/gtk/frame.cpp @@ -42,15 +42,20 @@ extern wxList wxPendingDelete; static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxFrame *win ) { if (!win->HasVMT()) return; - + /* printf( "OnFrameResize from " ); if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) printf( win->GetClassInfo()->GetClassName() ); printf( ".\n" ); */ - - win->GtkOnSize( alloc->x, alloc->y, alloc->width, alloc->height ); + + if ((win->m_width != alloc->width) || (win->m_height != alloc->height)) + { + win->m_sizeSet = FALSE; + win->m_width = alloc->width; + win->m_height = alloc->height; + } } //----------------------------------------------------------------------------- @@ -132,6 +137,7 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title, if (style & wxSIMPLE_BORDER) win_type = GTK_WINDOW_POPUP; m_widget = gtk_window_new( win_type ); + if ((size.x != -1) && (size.y != -1)) gtk_widget_set_usize( m_widget, m_width, m_height ); if ((pos.x != -1) && (pos.y != -1)) @@ -180,9 +186,11 @@ bool wxFrame::Show( bool show ) if (show) { +/* wxSizeEvent event( wxSize(m_width,m_height), GetId() ); m_sizeSet = FALSE; - ProcessEvent( event ); + GetEventHandler()->ProcessEvent( event ); +*/ } return wxWindow::Show( show ); } @@ -279,7 +287,7 @@ void wxFrame::SetSize( int x, int y, int width, int height, int sizeFlags ) wxSizeEvent event( wxSize(m_width,m_height), GetId() ); event.SetEventObject( this ); - ProcessEvent( event ); + GetEventHandler()->ProcessEvent( event ); m_resizing = FALSE; } @@ -342,8 +350,9 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height // m_x = x; // m_y = y; - if ((m_height == height) && (m_width == width) && - (m_sizeSet)) return; + if (m_resizing) return; + m_resizing = TRUE; + if (!m_wxwindow) return; m_width = width; @@ -354,8 +363,8 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_minWidth; if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_minHeight; - gtk_widget_set_usize( m_widget, m_width, m_height ); - +// gtk_widget_set_usize( m_widget, m_width, m_height ); + // This emulates the new wxMSW behaviour if (m_frameMenuBar) @@ -390,12 +399,22 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_frameStatusBar->m_widget, 0, m_height-wxSTATUS_HEIGHT ); gtk_widget_set_usize( m_frameStatusBar->m_widget, m_width, wxSTATUS_HEIGHT ); } - + m_sizeSet = TRUE; wxSizeEvent event( wxSize(m_width,m_height), GetId() ); event.SetEventObject( this ); - ProcessEvent( event ); + GetEventHandler()->ProcessEvent( event ); + + m_resizing = FALSE; +} + +void wxFrame::OnIdle(wxIdleEvent& WXUNUSED(event) ) +{ + if (!m_sizeSet) + GtkOnSize( m_x, m_y, m_width, m_height ); + + DoMenuUpdates(); } void wxFrame::OnSize( wxSizeEvent &WXUNUSED(event) ) diff --git a/src/gtk/icon.cpp b/src/gtk/icon.cpp index 94952e31ff..37ce52b757 100644 --- a/src/gtk/icon.cpp +++ b/src/gtk/icon.cpp @@ -19,8 +19,13 @@ IMPLEMENT_DYNAMIC_CLASS(wxIcon,wxBitmap) +wxIcon::wxIcon( const char **bits, int WXUNUSED(width), int WXUNUSED(height) ) : + wxBitmap( bits ) +{ +} + wxIcon::wxIcon( char **bits, int WXUNUSED(width), int WXUNUSED(height) ) : - wxBitmap( bits ) + wxBitmap( bits ) { } @@ -28,20 +33,20 @@ wxIcon::wxIcon() : wxBitmap() { } -wxIcon::wxIcon(const wxIcon& icon) : wxBitmap() +wxIcon::wxIcon( const wxIcon& icon ) : wxBitmap() { - Ref(icon); + Ref(icon); } -wxIcon::wxIcon(const wxIcon* icon) : wxBitmap() +wxIcon::wxIcon( const wxIcon* icon ) : wxBitmap() { - if (icon) Ref(*icon); + if (icon) Ref(*icon); } -wxIcon& wxIcon::operator = (const wxIcon& icon) +wxIcon& wxIcon::operator = ( const wxIcon& icon ) { - if (*this == icon) return (*this); - Ref(icon); - return *this; + if (*this == icon) return (*this); + Ref(icon); + return *this; } diff --git a/src/gtk/utilsgtk.cpp b/src/gtk/utilsgtk.cpp index 2befc47dc3..20ad8bc2a2 100644 --- a/src/gtk/utilsgtk.cpp +++ b/src/gtk/utilsgtk.cpp @@ -30,6 +30,11 @@ #include #include +#include +#include +#include + +#include "gdk/gdkx.h" // GDK_DISPLAY #ifdef __SVR4__ #include @@ -50,42 +55,45 @@ extern "C" void wxBell(void) { - gdk_beep(); -}; + gdk_beep(); +} void wxSleep(int nSecs) { - sleep(nSecs); -}; + sleep(nSecs); +} int wxKill(long pid, int sig) { - return kill(pid, sig); -}; + return kill(pid, sig); +} void wxDisplaySize( int *width, int *height ) { - if (width) *width = gdk_screen_width(); - if (height) *height = gdk_screen_height(); + if (width) *width = gdk_screen_width(); + if (height) *height = gdk_screen_height(); } void wxGetMousePosition( int* x, int* y ) { - wxFAIL_MSG( "GetMousePosition not yet implemented" ); - if (x) *x = 0; - if (y) *y = 0; -}; + Window dumw; + int dumi; + unsigned int dumu; + + XQueryPointer( GDK_DISPLAY(),GDK_ROOT_WINDOW(), + &dumw,&dumw,x,y,&dumi,&dumi,&dumu ); +} bool wxColourDisplay(void) { - wxFAIL_MSG( "wxColourDisplay always returns TRUE" ); - return TRUE; + wxFAIL_MSG( "wxColourDisplay always returns TRUE" ); + return TRUE; } int wxDisplayDepth(void) { - wxFAIL_MSG( "wxDisplayDepth always returns 8" ); - return 8; + wxFAIL_MSG( "wxDisplayDepth always returns 8" ); + return 8; } //------------------------------------------------------------------------ @@ -94,34 +102,40 @@ int wxDisplayDepth(void) const char* wxGetHomeDir( wxString *home ) { - *home = wxGetUserHome( wxString() ); - if (home->IsNull()) *home = "/"; - return *home; -}; + *home = wxGetUserHome( wxString() ); + if (home->IsNull()) *home = "/"; + return *home; +} char *wxGetUserHome( const wxString &user ) { - struct passwd *who = (struct passwd *) NULL; + struct passwd *who = (struct passwd *) NULL; - if (user.IsNull() || (user== "")) - { + if (user.IsNull() || (user== "")) + { register char *ptr; if ((ptr = getenv("HOME")) != NULL) + { return ptr; - if ((ptr = getenv("USER")) != NULL - || (ptr = getenv("LOGNAME")) != NULL) { + } + if ((ptr = getenv("USER")) != NULL || (ptr = getenv("LOGNAME")) != NULL) + { who = getpwnam(ptr); } // We now make sure the the user exists! if (who == NULL) + { who = getpwuid(getuid()); - } - else - who = getpwnam (user); + } + } + else + { + who = getpwnam (user); + } - return who ? who->pw_dir : (char*)NULL; -}; + return who ? who->pw_dir : (char*)NULL; +} //------------------------------------------------------------------------ // id routines @@ -147,15 +161,15 @@ bool wxGetHostName(char *buf, int sz) // strncpy(buf, (h=gethostbyname(name))!=NULL ? h->h_name : name, sz-1); if((unsigned)sz > strlen(name)+strlen(domain)+1) { - strcpy(buf, name); - if(strcmp(domain,"(none)") == 0) // standalone machine - { - strcat(buf,"."); - strcat(buf,domain); - } + strcpy(buf, name); + if(strcmp(domain,"(none)") == 0) // standalone machine + { + strcat(buf,"."); + strcat(buf,domain); + } } else - return FALSE; + return FALSE; return TRUE; #endif } @@ -223,10 +237,10 @@ void wxFatalError( const wxString &msg, const wxString &title ) bool wxDirExists( const wxString& dir ) { - char buf[500]; - strcpy( buf, WXSTRINGCAST(dir) ); - struct stat sbuf; - return ((stat(buf, &sbuf) != -1) && S_ISDIR(sbuf.st_mode) ? TRUE : FALSE); + char buf[500]; + strcpy( buf, WXSTRINGCAST(dir) ); + struct stat sbuf; + return ((stat(buf, &sbuf) != -1) && S_ISDIR(sbuf.st_mode) ? TRUE : FALSE); }; //------------------------------------------------------------------------ diff --git a/src/gtk/win_gtk.c b/src/gtk/win_gtk.c index 53e308a1c9..dc58604aa9 100644 --- a/src/gtk/win_gtk.c +++ b/src/gtk/win_gtk.c @@ -103,10 +103,6 @@ gtk_myfixed_init (GtkMyFixed *myfixed) { GTK_WIDGET_UNSET_FLAGS (myfixed, GTK_NO_WINDOW); GTK_WIDGET_SET_FLAGS (myfixed, GTK_BASIC); - -#if (GTK_MINOR_VERSION == 1) - gtk_container_set_resize_mode( GTK_CONTAINER(myfixed), GTK_RESIZE_PARENT ); -#endif myfixed->children = NULL; } @@ -173,7 +169,7 @@ gtk_myfixed_move (GtkMyFixed *myfixed, if (child->widget == widget) { - if ((child->x == x) && (child->y == y)) return; +/* if ((child->x == x) && (child->y == y)) return; */ child->x = x; child->y = y; diff --git a/src/gtk1/bitmap.cpp b/src/gtk1/bitmap.cpp index 809fcd3984..4fcbd352e0 100644 --- a/src/gtk1/bitmap.cpp +++ b/src/gtk1/bitmap.cpp @@ -117,6 +117,29 @@ wxBitmap::wxBitmap( int width, int height, int depth ) if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this); } +wxBitmap::wxBitmap( const char **bits ) +{ + wxCHECK_RET( bits != NULL, "invalid bitmap data" ) + + m_refData = new wxBitmapRefData(); + + GdkBitmap *mask = (GdkBitmap*) NULL; + GdkWindow *parent = (GdkWindow*) &gdk_root_parent; + + M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm_d( parent, &mask, NULL, (gchar **) bits ); + + if (mask) + { + M_BMPDATA->m_mask = new wxMask(); + M_BMPDATA->m_mask->m_bitmap = mask; + } + + gdk_window_get_size( M_BMPDATA->m_pixmap, &(M_BMPDATA->m_width), &(M_BMPDATA->m_height) ); + + M_BMPDATA->m_bpp = gdk_window_get_visual( parent )->depth; // ? + if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this); +} + wxBitmap::wxBitmap( char **bits ) { wxCHECK_RET( bits != NULL, "invalid bitmap data" ) diff --git a/src/gtk1/dialog.cpp b/src/gtk1/dialog.cpp index 5df777a91e..bde6b7e6b4 100644 --- a/src/gtk1/dialog.cpp +++ b/src/gtk1/dialog.cpp @@ -38,6 +38,24 @@ bool gtk_dialog_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED return TRUE; } +//----------------------------------------------------------------------------- +// "size_allocate" +//----------------------------------------------------------------------------- + +static void gtk_dialog_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxDialog *win ) +{ + if (!win->HasVMT()) return; + +/* + printf( "OnDialogResize from " ); + if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) + printf( win->GetClassInfo()->GetClassName() ); + printf( ".\n" ); +*/ + + win->GtkOnSize( alloc->x, alloc->y, alloc->width, alloc->height ); +} + //----------------------------------------------------------------------------- // wxDialog //----------------------------------------------------------------------------- @@ -46,6 +64,7 @@ BEGIN_EVENT_TABLE(wxDialog,wxPanel) EVT_BUTTON (wxID_OK, wxDialog::OnOK) EVT_BUTTON (wxID_CANCEL, wxDialog::OnCancel) EVT_BUTTON (wxID_APPLY, wxDialog::OnApply) + EVT_SIZE (wxDialog::OnSize) EVT_CLOSE (wxDialog::OnCloseWindow) END_EVENT_TABLE() @@ -85,6 +104,9 @@ bool wxDialog::Create( wxWindow *parent, gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event", GTK_SIGNAL_FUNC(gtk_dialog_delete_callback), (gpointer)this ); + gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", + GTK_SIGNAL_FUNC(gtk_dialog_size_callback), (gpointer)this ); + m_wxwindow = gtk_myfixed_new(); gtk_widget_show( m_wxwindow ); GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); @@ -194,6 +216,66 @@ void wxDialog::OnCloseWindow( wxCloseEvent& event ) } } +void wxDialog::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height ) +{ + // due to a bug in gtk, x,y are always 0 + // m_x = x; + // m_y = y; + + if ((m_height == height) && (m_width == width) && + (m_sizeSet)) return; + if (!m_wxwindow) return; + + m_width = width; + m_height = height; + + if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth; + if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight; + if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_minWidth; + if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_minHeight; + + gtk_widget_set_usize( m_widget, m_width, m_height ); + + m_sizeSet = TRUE; + + wxSizeEvent event( wxSize(m_width,m_height), GetId() ); + event.SetEventObject( this ); + GetEventHandler()->ProcessEvent( event ); +} + +void wxDialog::OnSize( wxSizeEvent &WXUNUSED(event) ) +{ + wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); + + if (GetAutoLayout()) + { + Layout(); + } + else + { + // no child: go out ! + if (!GetChildren()->First()) return; + + // do we have exactly one child? + wxWindow *child = (wxWindow *) NULL; + for(wxNode *node = GetChildren()->First(); node; node = node->Next()) + { + wxWindow *win = (wxWindow *)node->Data(); + if (!IS_KIND_OF(win,wxFrame) && !IS_KIND_OF(win,wxDialog)) + { + // it's the second one: do nothing + if (child) return; + child = win; + } + } + + // yes: set it's size to fill all the frame + int client_x, client_y; + GetClientSize( &client_x, &client_y ); + child->SetSize( 1, 1, client_x-2, client_y); + } +} + void wxDialog::SetSize( int x, int y, int width, int height, int sizeFlags ) { wxASSERT_MSG( (m_widget != NULL), "invalid window" ); @@ -254,7 +336,7 @@ void wxDialog::SetSize( int x, int y, int width, int height, int sizeFlags ) wxSizeEvent event( wxSize(m_width,m_height), GetId() ); event.SetEventObject( this ); - ProcessEvent( event ); + GetEventHandler()->ProcessEvent( event ); m_resizing = FALSE; } diff --git a/src/gtk1/frame.cpp b/src/gtk1/frame.cpp index 6a593bf782..edce82c9fc 100644 --- a/src/gtk1/frame.cpp +++ b/src/gtk1/frame.cpp @@ -42,15 +42,20 @@ extern wxList wxPendingDelete; static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxFrame *win ) { if (!win->HasVMT()) return; - + /* printf( "OnFrameResize from " ); if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) printf( win->GetClassInfo()->GetClassName() ); printf( ".\n" ); */ - - win->GtkOnSize( alloc->x, alloc->y, alloc->width, alloc->height ); + + if ((win->m_width != alloc->width) || (win->m_height != alloc->height)) + { + win->m_sizeSet = FALSE; + win->m_width = alloc->width; + win->m_height = alloc->height; + } } //----------------------------------------------------------------------------- @@ -132,6 +137,7 @@ bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title, if (style & wxSIMPLE_BORDER) win_type = GTK_WINDOW_POPUP; m_widget = gtk_window_new( win_type ); + if ((size.x != -1) && (size.y != -1)) gtk_widget_set_usize( m_widget, m_width, m_height ); if ((pos.x != -1) && (pos.y != -1)) @@ -180,9 +186,11 @@ bool wxFrame::Show( bool show ) if (show) { +/* wxSizeEvent event( wxSize(m_width,m_height), GetId() ); m_sizeSet = FALSE; - ProcessEvent( event ); + GetEventHandler()->ProcessEvent( event ); +*/ } return wxWindow::Show( show ); } @@ -279,7 +287,7 @@ void wxFrame::SetSize( int x, int y, int width, int height, int sizeFlags ) wxSizeEvent event( wxSize(m_width,m_height), GetId() ); event.SetEventObject( this ); - ProcessEvent( event ); + GetEventHandler()->ProcessEvent( event ); m_resizing = FALSE; } @@ -342,8 +350,9 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height // m_x = x; // m_y = y; - if ((m_height == height) && (m_width == width) && - (m_sizeSet)) return; + if (m_resizing) return; + m_resizing = TRUE; + if (!m_wxwindow) return; m_width = width; @@ -354,8 +363,8 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_minWidth; if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_minHeight; - gtk_widget_set_usize( m_widget, m_width, m_height ); - +// gtk_widget_set_usize( m_widget, m_width, m_height ); + // This emulates the new wxMSW behaviour if (m_frameMenuBar) @@ -390,12 +399,22 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_frameStatusBar->m_widget, 0, m_height-wxSTATUS_HEIGHT ); gtk_widget_set_usize( m_frameStatusBar->m_widget, m_width, wxSTATUS_HEIGHT ); } - + m_sizeSet = TRUE; wxSizeEvent event( wxSize(m_width,m_height), GetId() ); event.SetEventObject( this ); - ProcessEvent( event ); + GetEventHandler()->ProcessEvent( event ); + + m_resizing = FALSE; +} + +void wxFrame::OnIdle(wxIdleEvent& WXUNUSED(event) ) +{ + if (!m_sizeSet) + GtkOnSize( m_x, m_y, m_width, m_height ); + + DoMenuUpdates(); } void wxFrame::OnSize( wxSizeEvent &WXUNUSED(event) ) diff --git a/src/gtk1/icon.cpp b/src/gtk1/icon.cpp index 94952e31ff..37ce52b757 100644 --- a/src/gtk1/icon.cpp +++ b/src/gtk1/icon.cpp @@ -19,8 +19,13 @@ IMPLEMENT_DYNAMIC_CLASS(wxIcon,wxBitmap) +wxIcon::wxIcon( const char **bits, int WXUNUSED(width), int WXUNUSED(height) ) : + wxBitmap( bits ) +{ +} + wxIcon::wxIcon( char **bits, int WXUNUSED(width), int WXUNUSED(height) ) : - wxBitmap( bits ) + wxBitmap( bits ) { } @@ -28,20 +33,20 @@ wxIcon::wxIcon() : wxBitmap() { } -wxIcon::wxIcon(const wxIcon& icon) : wxBitmap() +wxIcon::wxIcon( const wxIcon& icon ) : wxBitmap() { - Ref(icon); + Ref(icon); } -wxIcon::wxIcon(const wxIcon* icon) : wxBitmap() +wxIcon::wxIcon( const wxIcon* icon ) : wxBitmap() { - if (icon) Ref(*icon); + if (icon) Ref(*icon); } -wxIcon& wxIcon::operator = (const wxIcon& icon) +wxIcon& wxIcon::operator = ( const wxIcon& icon ) { - if (*this == icon) return (*this); - Ref(icon); - return *this; + if (*this == icon) return (*this); + Ref(icon); + return *this; } diff --git a/src/gtk1/utilsgtk.cpp b/src/gtk1/utilsgtk.cpp index 2befc47dc3..20ad8bc2a2 100644 --- a/src/gtk1/utilsgtk.cpp +++ b/src/gtk1/utilsgtk.cpp @@ -30,6 +30,11 @@ #include #include +#include +#include +#include + +#include "gdk/gdkx.h" // GDK_DISPLAY #ifdef __SVR4__ #include @@ -50,42 +55,45 @@ extern "C" void wxBell(void) { - gdk_beep(); -}; + gdk_beep(); +} void wxSleep(int nSecs) { - sleep(nSecs); -}; + sleep(nSecs); +} int wxKill(long pid, int sig) { - return kill(pid, sig); -}; + return kill(pid, sig); +} void wxDisplaySize( int *width, int *height ) { - if (width) *width = gdk_screen_width(); - if (height) *height = gdk_screen_height(); + if (width) *width = gdk_screen_width(); + if (height) *height = gdk_screen_height(); } void wxGetMousePosition( int* x, int* y ) { - wxFAIL_MSG( "GetMousePosition not yet implemented" ); - if (x) *x = 0; - if (y) *y = 0; -}; + Window dumw; + int dumi; + unsigned int dumu; + + XQueryPointer( GDK_DISPLAY(),GDK_ROOT_WINDOW(), + &dumw,&dumw,x,y,&dumi,&dumi,&dumu ); +} bool wxColourDisplay(void) { - wxFAIL_MSG( "wxColourDisplay always returns TRUE" ); - return TRUE; + wxFAIL_MSG( "wxColourDisplay always returns TRUE" ); + return TRUE; } int wxDisplayDepth(void) { - wxFAIL_MSG( "wxDisplayDepth always returns 8" ); - return 8; + wxFAIL_MSG( "wxDisplayDepth always returns 8" ); + return 8; } //------------------------------------------------------------------------ @@ -94,34 +102,40 @@ int wxDisplayDepth(void) const char* wxGetHomeDir( wxString *home ) { - *home = wxGetUserHome( wxString() ); - if (home->IsNull()) *home = "/"; - return *home; -}; + *home = wxGetUserHome( wxString() ); + if (home->IsNull()) *home = "/"; + return *home; +} char *wxGetUserHome( const wxString &user ) { - struct passwd *who = (struct passwd *) NULL; + struct passwd *who = (struct passwd *) NULL; - if (user.IsNull() || (user== "")) - { + if (user.IsNull() || (user== "")) + { register char *ptr; if ((ptr = getenv("HOME")) != NULL) + { return ptr; - if ((ptr = getenv("USER")) != NULL - || (ptr = getenv("LOGNAME")) != NULL) { + } + if ((ptr = getenv("USER")) != NULL || (ptr = getenv("LOGNAME")) != NULL) + { who = getpwnam(ptr); } // We now make sure the the user exists! if (who == NULL) + { who = getpwuid(getuid()); - } - else - who = getpwnam (user); + } + } + else + { + who = getpwnam (user); + } - return who ? who->pw_dir : (char*)NULL; -}; + return who ? who->pw_dir : (char*)NULL; +} //------------------------------------------------------------------------ // id routines @@ -147,15 +161,15 @@ bool wxGetHostName(char *buf, int sz) // strncpy(buf, (h=gethostbyname(name))!=NULL ? h->h_name : name, sz-1); if((unsigned)sz > strlen(name)+strlen(domain)+1) { - strcpy(buf, name); - if(strcmp(domain,"(none)") == 0) // standalone machine - { - strcat(buf,"."); - strcat(buf,domain); - } + strcpy(buf, name); + if(strcmp(domain,"(none)") == 0) // standalone machine + { + strcat(buf,"."); + strcat(buf,domain); + } } else - return FALSE; + return FALSE; return TRUE; #endif } @@ -223,10 +237,10 @@ void wxFatalError( const wxString &msg, const wxString &title ) bool wxDirExists( const wxString& dir ) { - char buf[500]; - strcpy( buf, WXSTRINGCAST(dir) ); - struct stat sbuf; - return ((stat(buf, &sbuf) != -1) && S_ISDIR(sbuf.st_mode) ? TRUE : FALSE); + char buf[500]; + strcpy( buf, WXSTRINGCAST(dir) ); + struct stat sbuf; + return ((stat(buf, &sbuf) != -1) && S_ISDIR(sbuf.st_mode) ? TRUE : FALSE); }; //------------------------------------------------------------------------ diff --git a/src/gtk1/win_gtk.c b/src/gtk1/win_gtk.c index 53e308a1c9..dc58604aa9 100644 --- a/src/gtk1/win_gtk.c +++ b/src/gtk1/win_gtk.c @@ -103,10 +103,6 @@ gtk_myfixed_init (GtkMyFixed *myfixed) { GTK_WIDGET_UNSET_FLAGS (myfixed, GTK_NO_WINDOW); GTK_WIDGET_SET_FLAGS (myfixed, GTK_BASIC); - -#if (GTK_MINOR_VERSION == 1) - gtk_container_set_resize_mode( GTK_CONTAINER(myfixed), GTK_RESIZE_PARENT ); -#endif myfixed->children = NULL; } @@ -173,7 +169,7 @@ gtk_myfixed_move (GtkMyFixed *myfixed, if (child->widget == widget) { - if ((child->x == x) && (child->y == y)) return; +/* if ((child->x == x) && (child->y == y)) return; */ child->x = x; child->y = y; -- 2.45.2