diff --git a/include/wx/gtk1/.cvsignore b/include/wx/gtk1/.cvsignore deleted file mode 100644 index 6d050a0ed7..0000000000 --- a/include/wx/gtk1/.cvsignore +++ /dev/null @@ -1,2 +0,0 @@ -setup.h -Makefile.in diff --git a/include/wx/gtk1/accel.h b/include/wx/gtk1/accel.h deleted file mode 100644 index 035a0fd38c..0000000000 --- a/include/wx/gtk1/accel.h +++ /dev/null @@ -1,15 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/gtk/accel.h -// Purpose: wxAcceleratorTable redirection file -// Author: Julian Smart -// Modified by: -// Created: -// Copyright: (c) Julian Smart -// RCS-ID: $Id$ -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// VZ: keeping the old file just in case we're going to have a native GTK+ -// wxAcceleratorTable implementation one day, but for now use the generic -// version -#include "wx/generic/accel.h" diff --git a/include/wx/gtk1/app.h b/include/wx/gtk1/app.h deleted file mode 100644 index 69137912be..0000000000 --- a/include/wx/gtk1/app.h +++ /dev/null @@ -1,94 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/gtk/app.h -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling, Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef __GTKAPPH__ -#define __GTKAPPH__ - -#include "wx/frame.h" -#include "wx/icon.h" - -//----------------------------------------------------------------------------- -// classes -//----------------------------------------------------------------------------- - -class wxApp; -class wxLog; - -//----------------------------------------------------------------------------- -// wxApp -//----------------------------------------------------------------------------- - -class wxApp: public wxAppBase -{ -public: - wxApp(); - virtual ~wxApp(); - - /* override for altering the way wxGTK intializes the GUI - * (palette/visual/colorcube). under wxMSW, OnInitGui() does nothing by - * default. when overriding this method, the code in it is likely to be - * platform dependent, otherwise use OnInit(). */ - virtual bool OnInitGui(); - - // override base class (pure) virtuals - virtual int MainLoop(); - virtual void ExitMainLoop(); - virtual bool Initialized(); - virtual bool Pending(); - virtual void Dispatch(); - virtual bool Yield(bool onlyIfNeeded = FALSE); - virtual bool ProcessIdle(); - - // implementation only from now on - void OnIdle( wxIdleEvent &event ); - bool SendIdleEvents(); - bool SendIdleEvents( wxWindow* win ); - - static bool Initialize(); - static bool InitialzeVisual(); - static void CleanUp(); - - void DeletePendingObjects(); - -#ifdef __WXDEBUG__ - virtual void OnAssert(const wxChar *file, int line, const wxChar *cond, const wxChar *msg); - - bool IsInAssert() const { return m_isInAssert; } -#endif // __WXDEBUG__ - - bool m_initialized; - - gint m_idleTag; -#if wxUSE_THREADS - gint m_wakeUpTimerTag; -#endif - unsigned char *m_colorCube; - - // Used by the the wxGLApp and wxGLCanvas class for GL-based X visual - // selection; this is actually an XVisualInfo* - void *m_glVisualInfo; - // This returns the current visual: either that used by wxRootWindow - // or the XVisualInfo* for SGI. - GdkVisual *GetGdkVisual(); - -private: - // true if we're inside an assert modal dialog -#ifdef __WXDEBUG__ - bool m_isInAssert; -#endif // __WXDEBUG__ - - bool CallInternalIdle( wxWindow* win ); - - DECLARE_DYNAMIC_CLASS(wxApp) - DECLARE_EVENT_TABLE() -}; - -int WXDLLEXPORT wxEntry( int argc, char *argv[] ); - -#endif // __GTKAPPH__ diff --git a/include/wx/gtk1/bitmap.h b/include/wx/gtk1/bitmap.h deleted file mode 100644 index 96be82f635..0000000000 --- a/include/wx/gtk1/bitmap.h +++ /dev/null @@ -1,121 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: bitmap.h -// Purpose: -// Author: Robert Roebling -// RCS-ID: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - - -#ifndef __GTKBITMAPH__ -#define __GTKBITMAPH__ - -#include "wx/defs.h" -#include "wx/object.h" -#include "wx/string.h" -#include "wx/palette.h" -#include "wx/gdiobj.h" - -//----------------------------------------------------------------------------- -// classes -//----------------------------------------------------------------------------- - -class wxMask; -class wxBitmap; -class wxImage; - -//----------------------------------------------------------------------------- -// wxMask -//----------------------------------------------------------------------------- - -class wxMask: public wxObject -{ -public: - wxMask(); - wxMask( const wxBitmap& bitmap, const wxColour& colour ); - wxMask( const wxBitmap& bitmap, int paletteIndex ); - wxMask( const wxBitmap& bitmap ); - ~wxMask(); - - bool Create( const wxBitmap& bitmap, const wxColour& colour ); - bool Create( const wxBitmap& bitmap, int paletteIndex ); - bool Create( const wxBitmap& bitmap ); - - // implementation - GdkBitmap *m_bitmap; - - GdkBitmap *GetBitmap() const; - -private: - DECLARE_DYNAMIC_CLASS(wxMask) -}; - -//----------------------------------------------------------------------------- -// wxBitmap -//----------------------------------------------------------------------------- - -class wxBitmap: public wxGDIObject -{ -public: - wxBitmap(); - wxBitmap( int width, int height, int depth = -1 ); - wxBitmap( const char bits[], int width, int height, int depth = 1 ); - wxBitmap( const char **bits ) { (void)CreateFromXpm(bits); } - wxBitmap( char **bits ) { (void)CreateFromXpm((const char **)bits); } - wxBitmap( const wxBitmap& bmp ); - wxBitmap( const wxString &filename, int type = wxBITMAP_TYPE_XPM ); - wxBitmap( const wxImage& image, int depth = -1 ) { (void)CreateFromImage(image, depth); } - ~wxBitmap(); - wxBitmap& operator = ( const wxBitmap& bmp ); - bool operator == ( const wxBitmap& bmp ) const; - bool operator != ( const wxBitmap& bmp ) const; - bool Ok() const; - - bool Create(int width, int height, int depth = -1); - - int GetHeight() const; - int GetWidth() const; - int GetDepth() const; - - wxImage ConvertToImage() const; - - // copies the contents and mask of the given (colour) icon to the bitmap - virtual bool CopyFromIcon(const wxIcon& icon); - - wxMask *GetMask() const; - void SetMask( wxMask *mask ); - - wxBitmap GetSubBitmap( const wxRect& rect ) const; - - bool SaveFile( const wxString &name, int type, wxPalette *palette = (wxPalette *) NULL ); - bool LoadFile( const wxString &name, int type = wxBITMAP_TYPE_XPM ); - - wxPalette *GetPalette() const; - wxPalette *GetColourMap() const - { return GetPalette(); }; - - // implementation - // -------------- - - void SetHeight( int height ); - void SetWidth( int width ); - void SetDepth( int depth ); - void SetPixmap( GdkPixmap *pixmap ); - void SetBitmap( GdkBitmap *bitmap ); - - GdkPixmap *GetPixmap() const; - GdkBitmap *GetBitmap() const; - - // Basically, this corresponds to Win32 StretchBlt() - wxBitmap Rescale( int clipx, int clipy, int clipwidth, int clipheight, int width, int height ); - -protected: - bool CreateFromXpm(const char **bits); - bool CreateFromImage(const wxImage& image, int depth); - -private: - DECLARE_DYNAMIC_CLASS(wxBitmap) -}; - -#endif // __GTKBITMAPH__ diff --git a/include/wx/gtk1/bmpbuttn.h b/include/wx/gtk1/bmpbuttn.h deleted file mode 100644 index 2e84f96c20..0000000000 --- a/include/wx/gtk1/bmpbuttn.h +++ /dev/null @@ -1,74 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/gtk/bmpbutton.h -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - - -#ifndef __BMPBUTTONH__ -#define __BMPBUTTONH__ - -// ---------------------------------------------------------------------------- -// wxBitmapButton -// ---------------------------------------------------------------------------- - -class wxBitmapButton: public wxBitmapButtonBase -{ -public: - wxBitmapButton() { Init(); } - - wxBitmapButton(wxWindow *parent, - wxWindowID id, - const wxBitmap& bitmap, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxBU_AUTODRAW, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxButtonNameStr) - { - Init(); - - Create(parent, id, bitmap, pos, size, style, validator, name); - } - - bool Create(wxWindow *parent, - wxWindowID id, - const wxBitmap& bitmap, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxBU_AUTODRAW, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxButtonNameStr); - - void SetLabel( const wxString &label ); - wxString GetLabel() const; - virtual void SetLabel( const wxBitmap& bitmap ) { SetBitmapLabel(bitmap); } - - virtual void SetDefault(); - virtual bool Enable(bool enable = TRUE); - - // implementation - // -------------- - - void HasFocus(); - void NotFocus(); - void StartSelect(); - void EndSelect(); - void ApplyWidgetStyle(); - - bool m_hasFocus:1; - bool m_isSelected:1; - -protected: - virtual void OnSetBitmap(); - - void Init(); - -private: - DECLARE_DYNAMIC_CLASS(wxBitmapButton) -}; - -#endif // __BMPBUTTONH__ diff --git a/include/wx/gtk1/brush.h b/include/wx/gtk1/brush.h deleted file mode 100644 index adda6ba5a5..0000000000 --- a/include/wx/gtk1/brush.h +++ /dev/null @@ -1,66 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: brush.h -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - - -#ifndef __GTKBRUSHH__ -#define __GTKBRUSHH__ - -#include "wx/defs.h" -#include "wx/object.h" -#include "wx/string.h" -#include "wx/gdiobj.h" -#include "wx/bitmap.h" - -//----------------------------------------------------------------------------- -// classes -//----------------------------------------------------------------------------- - -class wxBrush; - -//----------------------------------------------------------------------------- -// wxBrush -//----------------------------------------------------------------------------- - -class wxBrush: public wxGDIObject -{ -public: - wxBrush() { } - - wxBrush( const wxColour &colour, int style ); - wxBrush( const wxBitmap &stippleBitmap ); - ~wxBrush(); - - wxBrush( const wxBrush &brush ) - : wxGDIObject() - { Ref(brush); } - wxBrush& operator = ( const wxBrush& brush ) { Ref(brush); return *this; } - - bool Ok() const { return m_refData != NULL; } - - bool operator == ( const wxBrush& brush ) const; - bool operator != (const wxBrush& brush) const { return !(*this == brush); } - - int GetStyle() const; - wxColour &GetColour() const; - wxBitmap *GetStipple() const; - - void SetColour( const wxColour& col ); - void SetColour( unsigned char r, unsigned char g, unsigned char b ); - void SetStyle( int style ); - void SetStipple( const wxBitmap& stipple ); - -private: - // ref counting code - virtual wxObjectRefData *CreateRefData() const; - virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const; - - DECLARE_DYNAMIC_CLASS(wxBrush) -}; - -#endif // __GTKBRUSHH__ diff --git a/include/wx/gtk1/button.h b/include/wx/gtk1/button.h deleted file mode 100644 index 434c2f9b83..0000000000 --- a/include/wx/gtk1/button.h +++ /dev/null @@ -1,73 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/gtk/button.h -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef __GTKBUTTONH__ -#define __GTKBUTTONH__ - -#include "wx/defs.h" -#include "wx/object.h" -#include "wx/list.h" -#include "wx/control.h" - -//----------------------------------------------------------------------------- -// classes -//----------------------------------------------------------------------------- - -class wxButton; - -//----------------------------------------------------------------------------- -// global data -//----------------------------------------------------------------------------- - -extern const wxChar *wxButtonNameStr; - -//----------------------------------------------------------------------------- -// wxButton -//----------------------------------------------------------------------------- - -class wxButton: public wxControl -{ -public: - wxButton(); - wxButton(wxWindow *parent, wxWindowID id, const wxString& label, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxButtonNameStr) - { - Create(parent, id, label, pos, size, style, validator, name); - } - virtual ~wxButton(); - - bool Create(wxWindow *parent, wxWindowID id, const wxString& label, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxButtonNameStr); - - virtual void SetDefault(); - virtual void SetLabel( const wxString &label ); - virtual bool Enable( bool enable = TRUE ); - - static wxSize GetDefaultSize(); - - // implementation - // -------------- - - void ApplyWidgetStyle(); - bool IsOwnGtkWindow( GdkWindow *window ); - -protected: - virtual wxSize DoGetBestSize() const; - -private: - DECLARE_DYNAMIC_CLASS(wxButton) -}; - -#endif // __GTKBUTTONH__ diff --git a/include/wx/gtk1/checkbox.h b/include/wx/gtk1/checkbox.h deleted file mode 100644 index 0f217841a5..0000000000 --- a/include/wx/gtk1/checkbox.h +++ /dev/null @@ -1,63 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/gtk/checkbox.h -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef __GTKCHECKBOXH__ -#define __GTKCHECKBOXH__ - -// ---------------------------------------------------------------------------- -// wxCheckBox -// ---------------------------------------------------------------------------- - -class wxCheckBox : public wxCheckBoxBase -{ -public: - wxCheckBox(); - wxCheckBox( wxWindow *parent, wxWindowID id, const wxString& label, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxCheckBoxNameStr) - { - Create(parent, id, label, pos, size, style, validator, name); - } - bool Create(wxWindow *parent, - wxWindowID id, - const wxString& label, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxCheckBoxNameStr ); - - void SetValue( bool state ); - bool GetValue() const; - - virtual void SetLabel( const wxString& label ); - virtual bool Enable( bool enable = TRUE ); - - // implementation - // -------------- - - void ApplyWidgetStyle(); - bool IsOwnGtkWindow( GdkWindow *window ); - void OnInternalIdle(); - - GtkWidget *m_widgetCheckbox; - GtkWidget *m_widgetLabel; - - bool m_blockEvent; - -protected: - virtual wxSize DoGetBestSize() const; - -private: - DECLARE_DYNAMIC_CLASS(wxCheckBox) -}; - -#endif // __GTKCHECKBOXH__ diff --git a/include/wx/gtk1/checklst.h b/include/wx/gtk1/checklst.h deleted file mode 100644 index 541c994db5..0000000000 --- a/include/wx/gtk1/checklst.h +++ /dev/null @@ -1,53 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: checklst.h -// Purpose: wxCheckListBox class -// Author: Robert Roebling -// Modified by: -// RCS-ID: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef __GTKCHECKLISTH__ -#define __GTKCHECKLISTH__ - -// ---------------------------------------------------------------------------- -// macros -// ---------------------------------------------------------------------------- - -// there is no "right" choice of the checkbox indicators, so allow the user to -// define them himself if he wants -#ifndef wxCHECKLBOX_CHECKED - #define wxCHECKLBOX_CHECKED _T('x') - #define wxCHECKLBOX_UNCHECKED _T(' ') - - #define wxCHECKLBOX_STRING _T("[ ] ") -#endif - -//----------------------------------------------------------------------------- -// wxCheckListBox -// ---------------------------------------------------------------------------- - -class wxCheckListBox : public wxListBox -{ -public: - wxCheckListBox(); - wxCheckListBox(wxWindow *parent, wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - int nStrings = 0, - const wxString *choices = (const wxString *)NULL, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxListBoxNameStr); - - bool IsChecked( int index ) const; - void Check( int index, bool check = TRUE ); - - int GetItemHeight() const; - -private: - DECLARE_DYNAMIC_CLASS(wxCheckListBox) -}; - -#endif //__GTKCHECKLISTH__ diff --git a/include/wx/gtk1/choice.h b/include/wx/gtk1/choice.h deleted file mode 100644 index 7bce3f2bfd..0000000000 --- a/include/wx/gtk1/choice.h +++ /dev/null @@ -1,80 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: choice.h -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef __GTKCHOICEH__ -#define __GTKCHOICEH__ - -//----------------------------------------------------------------------------- -// wxChoice -//----------------------------------------------------------------------------- - -class wxChoice : public wxChoiceBase -{ -public: - wxChoice(); - wxChoice( wxWindow *parent, wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - int n = 0, const wxString choices[] = (const wxString *) NULL, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxChoiceNameStr ) - { - m_strings = (wxSortedArrayString *)NULL; - - Create(parent, id, pos, size, n, choices, style, validator, name); - } - ~wxChoice(); - bool Create( wxWindow *parent, wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - int n = 0, const wxString choices[] = (wxString *) NULL, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxChoiceNameStr ); - - // implement base class pure virtuals - void Delete(int n); - void Clear(); - - int GetSelection() const; - void SetSelection( int n ); - - virtual int GetCount() const; - int FindString( const wxString& string ) const; - wxString GetString( int n ) const; - void SetString( int n, const wxString& string ); - -protected: - wxList m_clientList; // contains the client data for the items - - void ApplyWidgetStyle(); - virtual int DoAppend(const wxString& item); - - virtual void DoSetItemClientData( int n, void* clientData ); - virtual void* DoGetItemClientData( int n ) const; - virtual void DoSetItemClientObject( int n, wxClientData* clientData ); - virtual wxClientData* DoGetItemClientObject( int n ) const; - - virtual wxSize DoGetBestSize() const; - - virtual bool IsOwnGtkWindow( GdkWindow *window ); -private: - // common part of Create() and DoAppend() - size_t GtkAppendHelper(GtkWidget *menu, const wxString& item); - - // this array is only used for controls with wxCB_SORT style, so only - // allocate it if it's needed (hence using pointer) - wxSortedArrayString *m_strings; - - DECLARE_DYNAMIC_CLASS(wxChoice) -}; - - -#endif // __GTKCHOICEH__ diff --git a/include/wx/gtk1/clipbrd.h b/include/wx/gtk1/clipbrd.h deleted file mode 100644 index 7f7c2d45ea..0000000000 --- a/include/wx/gtk1/clipbrd.h +++ /dev/null @@ -1,84 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: clipboard.h -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - - -#ifndef __GTKCLIPBOARDH__ -#define __GTKCLIPBOARDH__ - -#if wxUSE_CLIPBOARD - -#include "wx/object.h" -#include "wx/list.h" -#include "wx/dataobj.h" -#include "wx/control.h" -#include "wx/module.h" - -// ---------------------------------------------------------------------------- -// wxClipboard -// ---------------------------------------------------------------------------- - -class wxClipboard : public wxClipboardBase -{ -public: - wxClipboard(); - ~wxClipboard(); - - // open the clipboard before SetData() and GetData() - virtual bool Open(); - - // close the clipboard after SetData() and GetData() - virtual void Close(); - - // query whether the clipboard is opened - virtual bool IsOpened() const; - - // set the clipboard data. all other formats will be deleted. - virtual bool SetData( wxDataObject *data ); - - // add to the clipboard data. - virtual bool AddData( wxDataObject *data ); - - // ask if data in correct format is available - virtual bool IsSupported( const wxDataFormat& format ); - - // fill data with data on the clipboard (if available) - virtual bool GetData( wxDataObject& data ); - - // clears wxTheClipboard and the system's clipboard if possible - virtual void Clear(); - - // If primary == TRUE, use primary selection in all further ops, - // primary == FALSE resets it. - virtual void UsePrimarySelection(bool primary = TRUE) - { m_usePrimary = primary; } - - // implementation from now on - bool m_open; - bool m_ownsClipboard; - bool m_ownsPrimarySelection; - wxDataObject *m_data; - - GtkWidget *m_clipboardWidget; /* for getting and offering data */ - GtkWidget *m_targetsWidget; /* for getting list of supported formats */ - bool m_waiting; /* querying data or formats is asynchronous */ - - bool m_formatSupported; - GdkAtom m_targetRequested; - bool m_usePrimary; - wxDataObject *m_receivedData; - -private: - DECLARE_DYNAMIC_CLASS(wxClipboard) -}; - -#endif - // wxUSE_CLIPBOARD - -#endif - // __GTKCLIPBOARDH__ diff --git a/include/wx/gtk1/colour.h b/include/wx/gtk1/colour.h deleted file mode 100644 index ae8ee926b8..0000000000 --- a/include/wx/gtk1/colour.h +++ /dev/null @@ -1,96 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: colour.h -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - - -#ifndef __GTKCOLOURH__ -#define __GTKCOLOURH__ - -#include "wx/defs.h" -#include "wx/object.h" -#include "wx/string.h" -#include "wx/gdiobj.h" -#include "wx/palette.h" - -//----------------------------------------------------------------------------- -// classes -//----------------------------------------------------------------------------- - -class wxDC; -class wxPaintDC; -class wxBitmap; -class wxWindow; - -class wxColour; - -//----------------------------------------------------------------------------- -// wxColour -//----------------------------------------------------------------------------- - -class wxColour: public wxGDIObject -{ -public: - wxColour() { } - - // Construct from RGB - wxColour( unsigned char red, unsigned char green, unsigned char blue ); - wxColour( unsigned long colRGB ) { Set(colRGB); } - - // Implicit conversion from the colour name - wxColour( const wxString &colourName ) { InitFromName(colourName); } - wxColour( const char *colourName ) { InitFromName( wxString::FromAscii(colourName) ); } -#if wxUSE_UNICODE - wxColour( const wxChar *colourName ) { InitFromName( wxString(colourName) ); } -#endif - - - wxColour( const wxColour& col ) - : wxGDIObject() - { Ref(col); } - wxColour& operator = ( const wxColour& col ) { Ref(col); return *this; } - - ~wxColour(); - - bool Ok() const { return m_refData != NULL; } - - bool operator == ( const wxColour& col ) const; - bool operator != ( const wxColour& col ) const { return !(*this == col); } - - void Set( unsigned char red, unsigned char green, unsigned char blue ); - void Set( unsigned long colRGB ) - { - // We don't need to know sizeof(long) here because we assume that the three - // least significant bytes contain the R, G and B values - Set((unsigned char)colRGB, - (unsigned char)(colRGB >> 8), - (unsigned char)(colRGB >> 16)); - } - - unsigned char Red() const; - unsigned char Green() const; - unsigned char Blue() const; - - - // Implementation part - void CalcPixel( GdkColormap *cmap ); - int GetPixel() const; - GdkColor *GetColor() const; - -protected: - // ref counting code - virtual wxObjectRefData *CreateRefData() const; - virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const; - - // Helper functions - void InitFromName(const wxString& colourName); - -private: - DECLARE_DYNAMIC_CLASS(wxColour) -}; - -#endif // __GTKCOLOURH__ diff --git a/include/wx/gtk1/combobox.h b/include/wx/gtk1/combobox.h deleted file mode 100644 index 084c22bf14..0000000000 --- a/include/wx/gtk1/combobox.h +++ /dev/null @@ -1,136 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: combobox.h -// Purpose: -// Author: Robert Roebling -// Created: 01/02/97 -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - - -#ifndef __GTKCOMBOBOXH__ -#define __GTKCOMBOBOXH__ - -#include "wx/defs.h" - -#if wxUSE_COMBOBOX - -#include "wx/object.h" -#include "wx/control.h" - -//----------------------------------------------------------------------------- -// classes -//----------------------------------------------------------------------------- - -class wxComboBox; - -//----------------------------------------------------------------------------- -// global data -//----------------------------------------------------------------------------- - -extern const wxChar* wxComboBoxNameStr; -extern const wxChar* wxEmptyString; - -//----------------------------------------------------------------------------- -// wxComboBox -//----------------------------------------------------------------------------- - -class wxComboBox : public wxControl -{ -public: - inline wxComboBox() {} - inline wxComboBox(wxWindow *parent, wxWindowID id, - const wxString& value = wxEmptyString, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - int n = 0, const wxString choices[] = (const wxString *) NULL, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxComboBoxNameStr) - { - Create(parent, id, value, pos, size, n, choices, style, validator, name); - } - ~wxComboBox(); - bool Create(wxWindow *parent, wxWindowID id, - const wxString& value = wxEmptyString, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - int n = 0, const wxString choices[] = (const wxString *) NULL, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxComboBoxNameStr); - - void Append( const wxString &item ); - void Append( const wxString &item, void* clientData ); - void Append( const wxString &item, wxClientData* clientData ); - - void SetClientData( int n, void* clientData ); - void* GetClientData( int n ); - void SetClientObject( int n, wxClientData* clientData ); - wxClientData* GetClientObject( int n ); - - void SetClientObject( wxClientData *data ) { wxControl::SetClientObject( data ); } - wxClientData *GetClientObject() const { return wxControl::GetClientObject(); } - void SetClientData( void *data ) { wxControl::SetClientData( data ); } - void *GetClientData() const { return wxControl::GetClientData(); } - - void Clear(); - void Delete( int n ); - - int FindString( const wxString &item ); - int GetSelection() const; - wxString GetString( int n ) const; - wxString GetStringSelection() const; - int GetCount() const { return Number(); } - int Number() const; - void SetSelection( int n ); - void SetStringSelection( const wxString &string ); - - wxString GetValue() const; - void SetValue(const wxString& value); - - void Copy(); - void Cut(); - void Paste(); - void SetInsertionPoint( long pos ); - void SetInsertionPointEnd(); - long GetInsertionPoint() const; - long GetLastPosition() const; - void Replace( long from, long to, const wxString& value ); - void Remove( long from, long to ); - void SetSelection( long from, long to ); - void SetEditable( bool editable ); - - // implementation - - virtual void SetFocus(); - - void OnSize( wxSizeEvent &event ); - void OnChar( wxKeyEvent &event ); - - bool m_alreadySent; - wxList m_clientDataList; - wxList m_clientObjectList; - int m_prevSelection; - - void DisableEvents(); - void EnableEvents(); - void AppendCommon( const wxString &item ); - GtkWidget* GetConnectWidget(); - bool IsOwnGtkWindow( GdkWindow *window ); - void ApplyWidgetStyle(); - -protected: - virtual wxSize DoGetBestSize() const; - -private: - DECLARE_DYNAMIC_CLASS(wxComboBox) - DECLARE_EVENT_TABLE() -}; - -#endif - -#endif - - // __GTKCOMBOBOXH__ diff --git a/include/wx/gtk1/control.h b/include/wx/gtk1/control.h deleted file mode 100644 index c67f5733df..0000000000 --- a/include/wx/gtk1/control.h +++ /dev/null @@ -1,65 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: control.h -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling, Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef __GTKCONTROLH__ -#define __GTKCONTROLH__ - -#include "wx/defs.h" -#include "wx/object.h" -#include "wx/list.h" -#include "wx/window.h" - -//----------------------------------------------------------------------------- -// classes -//----------------------------------------------------------------------------- - -class wxControl; - -//----------------------------------------------------------------------------- -// wxControl -//----------------------------------------------------------------------------- - -class wxControl : public wxControlBase -{ -public: - wxControl(); - wxControl(wxWindow *parent, wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxControlNameStr) - { - Create(parent, id, pos, size, style, validator, name); - } - - bool Create(wxWindow *parent, wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxControlNameStr); - - // this function will filter out '&' characters and will put the accelerator - // char (the one immediately after '&') into m_chAccel (TODO not yet) - virtual void SetLabel( const wxString &label ); - virtual wxString GetLabel() const; - -protected: - virtual wxSize DoGetBestSize() const; -#ifdef __WXGTK20__ - wxString PrepareLabelMnemonics( const wxString &label ) const; -#endif - - wxString m_label; - char m_chAccel; // enabled to avoid breaking binary compatibility later on - -private: - DECLARE_DYNAMIC_CLASS(wxControl) -}; - -#endif // __GTKCONTROLH__ diff --git a/include/wx/gtk1/cursor.h b/include/wx/gtk1/cursor.h deleted file mode 100644 index f85b5614e7..0000000000 --- a/include/wx/gtk1/cursor.h +++ /dev/null @@ -1,53 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: cursor.h -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - - -#ifndef __GTKCURSORH__ -#define __GTKCURSORH__ - -#include "wx/defs.h" -#include "wx/object.h" -#include "wx/gdicmn.h" - -#if wxUSE_IMAGE -#include "wx/image.h" -#endif - -//----------------------------------------------------------------------------- -// wxCursor -//----------------------------------------------------------------------------- - -class wxCursor: public wxObject -{ -public: - - wxCursor(); - wxCursor( int cursorId ); - wxCursor( const wxCursor &cursor ); -#if wxUSE_IMAGE - wxCursor( const wxImage & image ); -#endif - wxCursor( const char bits[], int width, int height, - int hotSpotX=-1, int hotSpotY=-1, - const char maskBits[]=0, wxColour *fg=0, wxColour *bg=0 ); - ~wxCursor(); - wxCursor& operator = ( const wxCursor& cursor ); - bool operator == ( const wxCursor& cursor ) const; - bool operator != ( const wxCursor& cursor ) const; - bool Ok() const; - - // implementation - - GdkCursor *GetCursor() const; - -private: - DECLARE_DYNAMIC_CLASS(wxCursor) -}; - -#endif // __GTKCURSORH__ diff --git a/include/wx/gtk1/dataform.h b/include/wx/gtk1/dataform.h deleted file mode 100644 index 00b2c9f0c0..0000000000 --- a/include/wx/gtk1/dataform.h +++ /dev/null @@ -1,66 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: gtk/dataform.h -// Purpose: declaration of the wxDataFormat class -// Author: Vadim Zeitlin -// Modified by: -// Created: 19.10.99 (extracted from gtk/dataobj.h) -// RCS-ID: $Id$ -// Copyright: (c) 1998 Vadim Zeitlin -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GTK_DATAFORM_H -#define _WX_GTK_DATAFORM_H - -class wxDataFormat -{ -public: - // the clipboard formats under GDK are GdkAtoms - typedef GdkAtom NativeFormat; - - wxDataFormat(); - wxDataFormat( wxDataFormatId type ); - wxDataFormat( const wxString &id ); - wxDataFormat( const wxChar *id ); - wxDataFormat( NativeFormat format ); - - wxDataFormat& operator=(const wxDataFormat& format) - { m_type = format.m_type; m_format = format.m_format; return *this; } - wxDataFormat& operator=(NativeFormat format) - { SetId(format); return *this; } - - // comparison (must have both versions) - bool operator==(NativeFormat format) const - { return m_format == (NativeFormat)format; } - bool operator!=(NativeFormat format) const - { return m_format != (NativeFormat)format; } - bool operator==(wxDataFormatId format) const - { return m_type == (wxDataFormatId)format; } - bool operator!=(wxDataFormatId format) const - { return m_type != (wxDataFormatId)format; } - - // explicit and implicit conversions to NativeFormat which is one of - // standard data types (implicit conversion is useful for preserving the - // compatibility with old code) - NativeFormat GetFormatId() const { return m_format; } - operator NativeFormat() const { return m_format; } - - void SetId( NativeFormat format ); - - // string ids are used for custom types - this SetId() must be used for - // application-specific formats - wxString GetId() const; - void SetId( const wxChar *id ); - - // implementation - wxDataFormatId GetType() const; - void SetType( wxDataFormatId type ); - -private: - wxDataFormatId m_type; - NativeFormat m_format; - - void PrepareFormats(); -}; - -#endif // _WX_GTK_DATAFORM_H diff --git a/include/wx/gtk1/dataobj.h b/include/wx/gtk1/dataobj.h deleted file mode 100644 index 3713d8f92a..0000000000 --- a/include/wx/gtk1/dataobj.h +++ /dev/null @@ -1,27 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: gtk/dataobj.h -// Purpose: declaration of the wxDataObject -// Author: Robert Roebling -// RCS-ID: $Id$ -// Copyright: (c) 1998, 1999 Vadim Zeitlin, Robert Roebling -// Licence: wxWindows license -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GTK_DATAOBJ_H_ -#define _WX_GTK_DATAOBJ_H_ - -// ---------------------------------------------------------------------------- -// wxDataObject is the same as wxDataObjectBase under wxGTK -// ---------------------------------------------------------------------------- - -class wxDataObject : public wxDataObjectBase -{ -public: - wxDataObject(); - virtual ~wxDataObject(); - - virtual bool IsSupportedFormat( const wxDataFormat& format, Direction dir = Get ) const; -}; - -#endif // _WX_GTK_DATAOBJ_H_ - diff --git a/include/wx/gtk1/dataobj2.h b/include/wx/gtk1/dataobj2.h deleted file mode 100644 index 93e7c88022..0000000000 --- a/include/wx/gtk1/dataobj2.h +++ /dev/null @@ -1,85 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: gtk/dataobj2.h -// Purpose: declaration of standard wxDataObjectSimple-derived classes -// Author: Robert Roebling -// Created: 19.10.99 (extracted from gtk/dataobj.h) -// RCS-ID: $Id$ -// Copyright: (c) 1998, 1999 Vadim Zeitlin, Robert Roebling -// Licence: wxWindows license -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GTK_DATAOBJ2_H_ -#define _WX_GTK_DATAOBJ2_H_ - -// ---------------------------------------------------------------------------- -// wxBitmapDataObject is a specialization of wxDataObject for bitmaps -// ---------------------------------------------------------------------------- - -class wxBitmapDataObject : public wxBitmapDataObjectBase -{ -public: - // ctors - wxBitmapDataObject(); - wxBitmapDataObject(const wxBitmap& bitmap); - - // destr - ~wxBitmapDataObject(); - - // override base class virtual to update PNG data too - virtual void SetBitmap(const wxBitmap& bitmap); - - // implement base class pure virtuals - // ---------------------------------- - - virtual size_t GetDataSize() const { return m_pngSize; } - virtual bool GetDataHere(void *buf) const; - virtual bool SetData(size_t len, const void *buf); - -protected: - void Init() { m_pngData = (void *)NULL; m_pngSize = 0; } - void Clear() { free(m_pngData); } - void ClearAll() { Clear(); Init(); } - - size_t m_pngSize; - void *m_pngData; - - void DoConvertToPng(); - -private: - // virtual function hiding supression - size_t GetDataSize(const wxDataFormat& format) const - { return(wxDataObjectSimple::GetDataSize(format)); } - bool GetDataHere(const wxDataFormat& format, void* pBuf) const - { return(wxDataObjectSimple::GetDataHere(format, pBuf)); } - bool SetData(const wxDataFormat& format, size_t nLen, const void* pBuf) - { return(wxDataObjectSimple::SetData(format, nLen, pBuf)); } -}; - -// ---------------------------------------------------------------------------- -// wxFileDataObject is a specialization of wxDataObject for file names -// ---------------------------------------------------------------------------- - -class wxFileDataObject : public wxFileDataObjectBase -{ -public: - // implement base class pure virtuals - // ---------------------------------- - - void AddFile( const wxString &filename ); - - virtual size_t GetDataSize() const; - virtual bool GetDataHere(void *buf) const; - virtual bool SetData(size_t len, const void *buf); - -private: - // virtual function hiding supression - size_t GetDataSize(const wxDataFormat& format) const - { return(wxDataObjectSimple::GetDataSize(format)); } - bool GetDataHere(const wxDataFormat& format, void* pBuf) const - { return(wxDataObjectSimple::GetDataHere(format, pBuf)); } - bool SetData(const wxDataFormat& format, size_t nLen, const void* pBuf) - { return(wxDataObjectSimple::SetData(format, nLen, pBuf)); } -}; - -#endif // _WX_GTK_DATAOBJ2_H_ - diff --git a/include/wx/gtk1/dc.h b/include/wx/gtk1/dc.h deleted file mode 100644 index 42eb3b46e3..0000000000 --- a/include/wx/gtk1/dc.h +++ /dev/null @@ -1,158 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: dc.h -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - - -#ifndef __GTKDCH__ -#define __GTKDCH__ - -//----------------------------------------------------------------------------- -// classes -//----------------------------------------------------------------------------- - -class wxDC; - -//----------------------------------------------------------------------------- -// constants -//----------------------------------------------------------------------------- - -#define MM_TEXT 0 -#define MM_ISOTROPIC 1 -#define MM_ANISOTROPIC 2 -#define MM_LOMETRIC 3 -#define MM_HIMETRIC 4 -#define MM_TWIPS 5 -#define MM_POINTS 6 -#define MM_METRIC 7 - -//----------------------------------------------------------------------------- -// wxDC -//----------------------------------------------------------------------------- - -class wxDC : public wxDCBase -{ -public: - wxDC(); - ~wxDC() { } - - void SetColourMap( const wxPalette& palette ) { SetPalette(palette); }; - - // the first two must be overridden and called - virtual void DestroyClippingRegion(); - - // Resolution in pixels per logical inch - virtual wxSize GetPPI() const; - - virtual bool StartDoc( const wxString& WXUNUSED(message) ) { return TRUE; } - virtual void EndDoc() { } - virtual void StartPage() { } - virtual void EndPage() { } - - virtual void SetMapMode( int mode ); - virtual void SetUserScale( double x, double y ); - virtual void SetLogicalScale( double x, double y ); - virtual void SetLogicalOrigin( wxCoord x, wxCoord y ); - virtual void SetDeviceOrigin( wxCoord x, wxCoord y ); - - virtual void SetAxisOrientation( bool xLeftRight, bool yBottomUp ); - - // implementation - // -------------- - - virtual void ComputeScaleAndOrigin(); - - wxCoord XDEV2LOG(wxCoord x) const - { - wxCoord new_x = x - m_deviceOriginX; - if (new_x > 0) - return (wxCoord)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX; - else - return (wxCoord)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX; - } - wxCoord XDEV2LOGREL(wxCoord x) const - { - if (x > 0) - return (wxCoord)((double)(x) / m_scaleX + 0.5); - else - return (wxCoord)((double)(x) / m_scaleX - 0.5); - } - wxCoord YDEV2LOG(wxCoord y) const - { - wxCoord new_y = y - m_deviceOriginY; - if (new_y > 0) - return (wxCoord)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY; - else - return (wxCoord)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY; - } - wxCoord YDEV2LOGREL(wxCoord y) const - { - if (y > 0) - return (wxCoord)((double)(y) / m_scaleY + 0.5); - else - return (wxCoord)((double)(y) / m_scaleY - 0.5); - } - wxCoord XLOG2DEV(wxCoord x) const - { - wxCoord new_x = x - m_logicalOriginX; - if (new_x > 0) - return (wxCoord)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX; - else - return (wxCoord)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX; - } - wxCoord XLOG2DEVREL(wxCoord x) const - { - if (x > 0) - return (wxCoord)((double)(x) * m_scaleX + 0.5); - else - return (wxCoord)((double)(x) * m_scaleX - 0.5); - } - wxCoord YLOG2DEV(wxCoord y) const - { - wxCoord new_y = y - m_logicalOriginY; - if (new_y > 0) - return (wxCoord)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY; - else - return (wxCoord)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY; - } - wxCoord YLOG2DEVREL(wxCoord y) const - { - if (y > 0) - return (wxCoord)((double)(y) * m_scaleY + 0.5); - else - return (wxCoord)((double)(y) * m_scaleY - 0.5); - } - -protected: - // base class pure virtuals implemented here - virtual void DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height); - virtual void DoGetSizeMM(int* width, int* height) const; - -public: - // GTK-specific member variables - - // not sure what for, but what is a mm on a screen you don't know the size - // of? - double m_mm_to_pix_x, - m_mm_to_pix_y; - - bool m_needComputeScaleX, - m_needComputeScaleY; // not yet used - - -private: - DECLARE_ABSTRACT_CLASS(wxDC) -}; - -// this must be defined when wxDC::Blit() honours the DC origian and needed to -// allow wxUniv code in univ/winuniv.cpp to work with versions of wxGTK -// 2.3.[23] -#ifndef wxHAS_WORKING_GTK_DC_BLIT - #define wxHAS_WORKING_GTK_DC_BLIT -#endif - -#endif // __GTKDCH__ diff --git a/include/wx/gtk1/dcclient.h b/include/wx/gtk1/dcclient.h deleted file mode 100644 index abe77dc227..0000000000 --- a/include/wx/gtk1/dcclient.h +++ /dev/null @@ -1,165 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: dcclient.h -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef __GTKDCCLIENTH__ -#define __GTKDCCLIENTH__ - -#include "wx/dc.h" -#include "wx/window.h" - -//----------------------------------------------------------------------------- -// classes -//----------------------------------------------------------------------------- - -class wxWindowDC; -class wxPaintDC; -class wxClientDC; - -//----------------------------------------------------------------------------- -// wxWindowDC -//----------------------------------------------------------------------------- - -class wxWindowDC : public wxDC -{ -public: - wxWindowDC(); - wxWindowDC( wxWindow *win ); - - virtual ~wxWindowDC(); - - virtual bool CanDrawBitmap() const { return TRUE; } - virtual bool CanGetTextExtent() const { return TRUE; } - -protected: - virtual void DoGetSize(int *width, int *height) const; - virtual bool DoFloodFill( wxCoord x, wxCoord y, const wxColour& col, int style=wxFLOOD_SURFACE ); - virtual bool DoGetPixel( wxCoord x1, wxCoord y1, wxColour *col ) const; - - virtual void DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 ); - virtual void DoCrossHair( wxCoord x, wxCoord y ); - virtual void DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, - wxCoord xc, wxCoord yc ); - virtual void DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, wxCoord height, - double sa, double ea ); - virtual void DoDrawPoint( wxCoord x, wxCoord y ); - - virtual void DoDrawLines(int n, wxPoint points[], - wxCoord xoffset, wxCoord yoffset); - virtual void DoDrawPolygon(int n, wxPoint points[], - wxCoord xoffset, wxCoord yoffset, - int fillStyle = wxODDEVEN_RULE); - - virtual void DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord height ); - virtual void DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius = 20.0 ); - virtual void DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord height ); - - virtual void DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y ); - virtual void DoDrawBitmap( const wxBitmap &bitmap, wxCoord x, wxCoord y, - bool useMask = FALSE ); - - virtual bool DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, - wxDC *source, wxCoord xsrc, wxCoord ysrc, - int logical_func = wxCOPY, bool useMask = FALSE, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1 ); - - virtual void DoDrawText( const wxString &text, wxCoord x, wxCoord y ); - virtual void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, - double angle); - virtual void DoGetTextExtent( const wxString &string, - wxCoord *width, wxCoord *height, - wxCoord *descent = (wxCoord *) NULL, - wxCoord *externalLeading = (wxCoord *) NULL, - wxFont *theFont = (wxFont *) NULL) const; - -public: - virtual wxCoord GetCharWidth() const; - virtual wxCoord GetCharHeight() const; - - virtual void Clear(); - - virtual void SetFont( const wxFont &font ); - virtual void SetPen( const wxPen &pen ); - virtual void SetBrush( const wxBrush &brush ); - virtual void SetBackground( const wxBrush &brush ); - virtual void SetLogicalFunction( int function ); - virtual void SetTextForeground( const wxColour &col ); - virtual void SetTextBackground( const wxColour &col ); - virtual void SetBackgroundMode( int mode ); - virtual void SetPalette( const wxPalette& palette ); - - virtual void DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height ); - virtual void DestroyClippingRegion(); - virtual void DoSetClippingRegionAsRegion( const wxRegion ®ion ); - - // Resolution in pixels per logical inch - virtual wxSize GetPPI() const; - virtual int GetDepth() const; - - // implementation - // -------------- - - GdkWindow *m_window; - GdkGC *m_penGC; - GdkGC *m_brushGC; - GdkGC *m_textGC; - GdkGC *m_bgGC; - GdkColormap *m_cmap; - bool m_isMemDC; - bool m_isScreenDC; - wxWindow *m_owner; - wxRegion m_currentClippingRegion; - wxRegion m_paintClippingRegion; - - // PangoContext stuff for GTK 2.0 -#ifdef __WXGTK20__ - PangoContext *m_context; - PangoFontDescription *m_fontdesc; -#endif - - void SetUpDC(); - void Destroy(); - void ComputeScaleAndOrigin(); - - GdkWindow *GetWindow() { return m_window; } - -private: - DECLARE_DYNAMIC_CLASS(wxWindowDC) -}; - -//----------------------------------------------------------------------------- -// wxClientDC -//----------------------------------------------------------------------------- - -class wxClientDC : public wxWindowDC -{ -public: - wxClientDC() { } - wxClientDC( wxWindow *win ); - -protected: - virtual void DoGetSize(int *width, int *height) const; - -private: - DECLARE_DYNAMIC_CLASS(wxClientDC) -}; - -//----------------------------------------------------------------------------- -// wxPaintDC -//----------------------------------------------------------------------------- - -class wxPaintDC : public wxClientDC -{ -public: - wxPaintDC() { } - wxPaintDC( wxWindow *win ); - -private: - DECLARE_DYNAMIC_CLASS(wxPaintDC) -}; - -#endif // __GTKDCCLIENTH__ diff --git a/include/wx/gtk1/dcmemory.h b/include/wx/gtk1/dcmemory.h deleted file mode 100644 index 6244c611ad..0000000000 --- a/include/wx/gtk1/dcmemory.h +++ /dev/null @@ -1,54 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: dcmemory.h -// Purpose: -// Author: Robert Roebling -// RCS-ID: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - - -#ifndef __GTKDCMEMORYH__ -#define __GTKDCMEMORYH__ - -#include "wx/defs.h" -#include "wx/dcclient.h" - -//----------------------------------------------------------------------------- -// classes -//----------------------------------------------------------------------------- - -class wxMemoryDC; - -//----------------------------------------------------------------------------- -// wxMemoryDC -//----------------------------------------------------------------------------- - -class wxMemoryDC : public wxWindowDC -{ -public: - wxMemoryDC(); - wxMemoryDC( wxDC *dc ); // Create compatible DC - ~wxMemoryDC(); - virtual void SelectObject( const wxBitmap& bitmap ); - void DoGetSize( int *width, int *height ) const; - - // these get reimplemented for mono-bitmaps to behave - // more like their Win32 couterparts. They now interpret - // wxWHITE, wxWHITE_BRUSH and wxWHITE_PEN as drawing 0 - // and everything else as drawing 1. - virtual void SetPen( const wxPen &pen ); - virtual void SetBrush( const wxBrush &brush ); - virtual void SetTextForeground( const wxColour &col ); - virtual void SetTextBackground( const wxColour &col ); - - // implementation - wxBitmap m_selected; - -private: - DECLARE_DYNAMIC_CLASS(wxMemoryDC) -}; - -#endif - // __GTKDCMEMORYH__ - diff --git a/include/wx/gtk1/dcscreen.h b/include/wx/gtk1/dcscreen.h deleted file mode 100644 index b1cc81a7e6..0000000000 --- a/include/wx/gtk1/dcscreen.h +++ /dev/null @@ -1,51 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: dcscreen.h -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef __GTKDCSCREENH__ -#define __GTKDCSCREENH__ - -#include "wx/dcclient.h" - -//----------------------------------------------------------------------------- -// classes -//----------------------------------------------------------------------------- - -class wxScreenDC; - -//----------------------------------------------------------------------------- -// wxScreenDC -//----------------------------------------------------------------------------- - -class wxScreenDC : public wxPaintDC -{ -public: - wxScreenDC(); - virtual ~wxScreenDC(); - - static bool StartDrawingOnTop( wxWindow *window ); - static bool StartDrawingOnTop( wxRect *rect = (wxRect *) NULL ); - static bool EndDrawingOnTop(); - - // implementation - - static GdkWindow *sm_overlayWindow; - static int sm_overlayWindowX; - static int sm_overlayWindowY; - -protected: - virtual void DoGetSize(int *width, int *height) const; - -private: - DECLARE_DYNAMIC_CLASS(wxScreenDC) -}; - -#endif - - // __GTKDCSCREENH__ - diff --git a/include/wx/gtk1/dialog.h b/include/wx/gtk1/dialog.h deleted file mode 100644 index 71fca73494..0000000000 --- a/include/wx/gtk1/dialog.h +++ /dev/null @@ -1,79 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: dialog.h -// Purpose: -// Author: Robert Roebling -// Created: -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef __GTKDIALOGH__ -#define __GTKDIALOGH__ - -#include "wx/defs.h" - -//----------------------------------------------------------------------------- -// classes -//----------------------------------------------------------------------------- - -class wxDialog; - -//----------------------------------------------------------------------------- -// global data -//----------------------------------------------------------------------------- - -extern const wxChar *wxDialogNameStr; - -//----------------------------------------------------------------------------- -// wxDialog -//----------------------------------------------------------------------------- - -class wxDialog: public wxDialogBase -{ -public: - wxDialog() { Init(); } - wxDialog( wxWindow *parent, wxWindowID id, - const wxString &title, - const wxPoint &pos = wxDefaultPosition, - const wxSize &size = wxDefaultSize, - long style = wxDEFAULT_DIALOG_STYLE, - const wxString &name = wxDialogNameStr ); - bool Create( wxWindow *parent, wxWindowID id, - const wxString &title, - const wxPoint &pos = wxDefaultPosition, - const wxSize &size = wxDefaultSize, - long style = wxDEFAULT_DIALOG_STYLE, - const wxString &name = wxDialogNameStr ); - ~wxDialog() {} - - void OnApply( wxCommandEvent &event ); - void OnCancel( wxCommandEvent &event ); - void OnOK( wxCommandEvent &event ); - void OnPaint( wxPaintEvent& event ); - void OnCloseWindow( wxCloseEvent& event ); - /* - void OnCharHook( wxKeyEvent& event ); - */ - - virtual bool Show( bool show = TRUE ); - virtual int ShowModal(); - virtual void EndModal( int retCode ); - virtual bool IsModal() const; - void SetModal( bool modal ); - - // implementation - // -------------- - - bool m_modalShowing; - -protected: - // common part of all ctors - void Init(); - -private: - DECLARE_EVENT_TABLE() - DECLARE_DYNAMIC_CLASS(wxDialog) -}; - -#endif // __GTKDIALOGH__ diff --git a/include/wx/gtk1/dnd.h b/include/wx/gtk1/dnd.h deleted file mode 100644 index 115ac75415..0000000000 --- a/include/wx/gtk1/dnd.h +++ /dev/null @@ -1,131 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: dnd.h -// Purpose: declaration of the wxDropTarget class -// Author: Robert Roebling -// RCS-ID: $Id$ -// Copyright: (c) 1998 Vadim Zeitlin, Robert Roebling -// Licence: wxWindows license -/////////////////////////////////////////////////////////////////////////////// - - -#ifndef __GTKDNDH__ -#define __GTKDNDH__ - -#if wxUSE_DRAG_AND_DROP - -#include "wx/object.h" -#include "wx/string.h" -#include "wx/dataobj.h" -#include "wx/cursor.h" -#include "wx/icon.h" -#include "wx/gdicmn.h" - -//------------------------------------------------------------------------- -// classes -//------------------------------------------------------------------------- - -class wxWindow; - -class wxDropTarget; -class wxTextDropTarget; -class wxFileDropTarget; - -class wxDropSource; - -// ---------------------------------------------------------------------------- -// macros -// ---------------------------------------------------------------------------- - -// this macro may be used instead for wxDropSource ctor arguments: it will use -// the icon 'name' from an XPM file under GTK, but will expand to something -// else under MSW. If you don't use it, you will have to use #ifdef in the -// application code. -#define wxDROP_ICON(name) wxICON(name) - -//------------------------------------------------------------------------- -// wxDropTarget -//------------------------------------------------------------------------- - -class wxDropTarget: public wxDropTargetBase -{ -public: - wxDropTarget(wxDataObject *dataObject = (wxDataObject*) NULL ); - - virtual wxDragResult OnDragOver(wxCoord x, wxCoord y, wxDragResult def); - virtual bool OnDrop(wxCoord x, wxCoord y); - virtual wxDragResult OnData(wxCoord x, wxCoord y, wxDragResult def); - virtual bool GetData(); - - // implementation - - GdkAtom GetMatchingPair(); - - void RegisterWidget( GtkWidget *widget ); - void UnregisterWidget( GtkWidget *widget ); - - GdkDragContext *m_dragContext; - GtkWidget *m_dragWidget; - GtkSelectionData *m_dragData; - guint m_dragTime; - bool m_firstMotion; // gdk has no "gdk_drag_enter" event - - void SetDragContext( GdkDragContext *dc ) { m_dragContext = dc; } - void SetDragWidget( GtkWidget *w ) { m_dragWidget = w; } - void SetDragData( GtkSelectionData *sd ) { m_dragData = sd; } - void SetDragTime( guint time ) { m_dragTime = time; } -}; - -//------------------------------------------------------------------------- -// wxDropSource -//------------------------------------------------------------------------- - -class wxDropSource: public wxDropSourceBase -{ -public: - // constructor. set data later with SetData() - wxDropSource( wxWindow *win = (wxWindow *)NULL, - const wxIcon © = wxNullIcon, - const wxIcon &move = wxNullIcon, - const wxIcon &none = wxNullIcon); - - // constructor for setting one data object - wxDropSource( wxDataObject& data, - wxWindow *win, - const wxIcon © = wxNullIcon, - const wxIcon &move = wxNullIcon, - const wxIcon &none = wxNullIcon); - - virtual ~wxDropSource(); - - // start drag action - virtual wxDragResult DoDragDrop(int flags = wxDrag_CopyOnly); - - // GTK implementation - void RegisterWindow(); - void UnregisterWindow(); - - void PrepareIcon( int action, GdkDragContext *context ); - - GtkWidget *m_widget; - GtkWidget *m_iconWindow; - GdkDragContext *m_dragContext; - wxWindow *m_window; - - wxDragResult m_retValue; - wxIcon m_iconCopy, - m_iconMove, - m_iconNone; - - bool m_waiting; - -private: - // common part of both ctors - void SetIcons(const wxIcon& copy, - const wxIcon& move, - const wxIcon& none); -}; - -#endif // wxUSE_DRAG_AND_DROP - -#endif //__GTKDNDH__ - diff --git a/include/wx/gtk1/filedlg.h b/include/wx/gtk1/filedlg.h deleted file mode 100644 index f367f3ffd4..0000000000 --- a/include/wx/gtk1/filedlg.h +++ /dev/null @@ -1,109 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: filedlg.h -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - - -#ifndef __GTKFILEDLGH__ -#define __GTKFILEDLGH__ - -#include "wx/dialog.h" - -//------------------------------------------------------------------------- -// File selector -//------------------------------------------------------------------------- - -extern const wxChar *wxFileSelectorPromptStr; -extern const wxChar *wxFileSelectorDefaultWildcardStr; - -class wxFileDialog: public wxDialog -{ -public: - wxFileDialog() { } - - wxFileDialog(wxWindow *parent, - const wxString& message = wxFileSelectorPromptStr, - const wxString& defaultDir = "", - const wxString& defaultFile = "", - const wxString& wildCard = wxFileSelectorDefaultWildcardStr, - long style = 0, - const wxPoint& pos = wxDefaultPosition); - - void SetMessage(const wxString& message) { m_message = message; } - void SetPath(const wxString& path); - void SetDirectory(const wxString& dir) { m_dir = dir; } - void SetFilename(const wxString& name) { m_fileName = name; } - void SetWildcard(const wxString& wildCard) { m_wildCard = wildCard; } - void SetStyle(long style) { m_dialogStyle = style; } - void SetFilterIndex(int filterIndex) { m_filterIndex = filterIndex; } - - wxString GetMessage() const { return m_message; } - wxString GetPath() const { return m_path; } - wxString GetDirectory() const { return m_dir; } - wxString GetFilename() const { return m_fileName; } - wxString GetWildcard() const { return m_wildCard; } - long GetStyle() const { return m_dialogStyle; } - int GetFilterIndex() const { return m_filterIndex ; } - -protected: - wxString m_message; - long m_dialogStyle; - wxWindow * m_parent; - wxString m_dir; - wxString m_path; // Full path - wxString m_fileName; - wxString m_wildCard; - int m_filterIndex; - -private: - DECLARE_DYNAMIC_CLASS(wxFileDialog) -}; - -#define wxOPEN 1 -#define wxSAVE 2 -#define wxOVERWRITE_PROMPT 4 -#define wxHIDE_READONLY 8 -#define wxFILE_MUST_EXIST 16 - -// File selector - backward compatibility -WXDLLEXPORT wxString -wxFileSelector(const wxChar *message = wxFileSelectorPromptStr, - const wxChar *default_path = NULL, - const wxChar *default_filename = NULL, - const wxChar *default_extension = NULL, - const wxChar *wildcard = wxFileSelectorDefaultWildcardStr, - int flags = 0, - wxWindow *parent = NULL, - int x = -1, int y = -1); - -// An extended version of wxFileSelector -WXDLLEXPORT wxString -wxFileSelectorEx(const wxChar *message = wxFileSelectorPromptStr, - const wxChar *default_path = NULL, - const wxChar *default_filename = NULL, - int *indexDefaultExtension = NULL, - const wxChar *wildcard = wxFileSelectorDefaultWildcardStr, - int flags = 0, - wxWindow *parent = NULL, - int x = -1, int y = -1); - -// Ask for filename to load -WXDLLEXPORT wxString -wxLoadFileSelector(const wxChar *what, - const wxChar *extension, - const wxChar *default_name = (const wxChar *)NULL, - wxWindow *parent = (wxWindow *) NULL); - -// Ask for filename to save -WXDLLEXPORT wxString -wxSaveFileSelector(const wxChar *what, - const wxChar *extension, - const wxChar *default_name = (const wxChar *) NULL, - wxWindow *parent = (wxWindow *) NULL); - -#endif - // __GTKFILEDLGH__ diff --git a/include/wx/gtk1/font.h b/include/wx/gtk1/font.h deleted file mode 100644 index a7ace917c4..0000000000 --- a/include/wx/gtk1/font.h +++ /dev/null @@ -1,113 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: font.h -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef __GTKFONTH__ -#define __GTKFONTH__ - -#include "wx/hash.h" - -// ---------------------------------------------------------------------------- -// classes -// ---------------------------------------------------------------------------- - -class wxDC; -class wxPaintDC; -class wxWindow; - -class wxFont; - -// ---------------------------------------------------------------------------- -// wxFont -// ---------------------------------------------------------------------------- - -class wxFont : public wxFontBase -{ -public: - // ctors and such - wxFont() { Init(); } - wxFont(const wxFont& font) : wxFontBase() { Init(); Ref(font); } - - // wxGTK-specific - wxFont(const wxString& fontname) - { - Init(); - - Create(fontname); - } - - wxFont(const wxNativeFontInfo& info); - - wxFont(int size, - int family, - int style, - int weight, - bool underlined = FALSE, - const wxString& face = wxEmptyString, - wxFontEncoding encoding = wxFONTENCODING_DEFAULT) - { - Init(); - - (void)Create(size, family, style, weight, underlined, face, encoding); - } - - bool Create(int size, - int family, - int style, - int weight, - bool underlined = FALSE, - const wxString& face = wxEmptyString, - wxFontEncoding encoding = wxFONTENCODING_DEFAULT); - - // wxGTK-specific - bool Create(const wxString& fontname); - - ~wxFont(); - - // assignment - wxFont& operator=(const wxFont& font); - - // implement base class pure virtuals - virtual int GetPointSize() const; - virtual int GetFamily() const; - virtual int GetStyle() const; - virtual int GetWeight() const; - virtual wxString GetFaceName() const; - virtual bool GetUnderlined() const; - virtual wxFontEncoding GetEncoding() const; - virtual wxNativeFontInfo *GetNativeFontInfo() const; - virtual bool IsFixedWidth() const; - - virtual void SetPointSize( int pointSize ); - virtual void SetFamily( int family ); - virtual void SetStyle( int style ); - virtual void SetWeight( int weight ); - virtual void SetFaceName( const wxString& faceName ); - virtual void SetUnderlined( bool underlined ); - virtual void SetEncoding(wxFontEncoding encoding); - virtual void SetNativeFontInfo( const wxNativeFontInfo& info ); - - virtual void SetNoAntiAliasing( bool no = TRUE ); - virtual bool GetNoAntiAliasing(); - - // implementation from now on - void Unshare(); - - GdkFont* GetInternalFont(float scale = 1.0) const; - - // no data :-) - -protected: - // common part of all ctors - void Init(); - -private: - DECLARE_DYNAMIC_CLASS(wxFont) -}; - -#endif // __GTKFONTH__ diff --git a/include/wx/gtk1/fontdlg.h b/include/wx/gtk1/fontdlg.h deleted file mode 100644 index 9c7468d293..0000000000 --- a/include/wx/gtk1/fontdlg.h +++ /dev/null @@ -1,44 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: fontdlgg.h -// Purpose: wxFontDialog -// Author: Robert Roebling -// Created: -// RCS-ID: $Id$ -// Copyright: (c) Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef __GTK_FONTDLGH__ -#define __GTK_FONTDLGH__ - -//----------------------------------------------------------------------------- -// wxFontDialog -//----------------------------------------------------------------------------- - -class wxFontDialog : public wxFontDialogBase -{ -public: - wxFontDialog() : wxFontDialogBase() { /* must be Create()d later */ } - wxFontDialog(wxWindow *parent) - : wxFontDialogBase(parent) { Create(parent); } - wxFontDialog(wxWindow *parent, const wxFontData& data) - : wxFontDialogBase(parent, data) { Create(parent, data); } - - virtual ~wxFontDialog(); - - // implementation only - void SetChosenFont(const char *name); - - // deprecated interface, don't use - wxFontDialog(wxWindow *parent, const wxFontData *data) - : wxFontDialogBase(parent, data) { Create(parent, data); } - -protected: - // create the GTK dialog - virtual bool DoCreate(wxWindow *parent); - -private: - DECLARE_DYNAMIC_CLASS(wxFontDialog) -}; - -#endif diff --git a/include/wx/gtk1/frame.h b/include/wx/gtk1/frame.h deleted file mode 100644 index ea2de6acc2..0000000000 --- a/include/wx/gtk1/frame.h +++ /dev/null @@ -1,108 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/gtk/frame.h -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling, Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - - -#ifndef __GTKFRAMEH__ -#define __GTKFRAMEH__ - -//----------------------------------------------------------------------------- -// classes -//----------------------------------------------------------------------------- - -class wxMDIChildFrame; -class wxMDIClientWindow; -class wxMenu; -class wxMenuBar; -class wxToolBar; -class wxStatusBar; - -//----------------------------------------------------------------------------- -// wxFrame -//----------------------------------------------------------------------------- - -class wxFrame : public wxFrameBase -{ -public: - // construction - wxFrame() { Init(); } - wxFrame(wxWindow *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE, - const wxString& name = wxFrameNameStr) - { - Init(); - - Create(parent, id, title, pos, size, style, name); - } - - bool Create(wxWindow *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE, - const wxString& name = wxFrameNameStr); - - virtual ~wxFrame(); - -#if wxUSE_STATUSBAR - virtual void PositionStatusBar(); - - virtual wxStatusBar* CreateStatusBar(int number = 1, - long style = wxST_SIZEGRIP, - wxWindowID id = 0, - const wxString& name = wxStatusLineNameStr); -#endif // wxUSE_STATUSBAR - -#if wxUSE_TOOLBAR - virtual wxToolBar* CreateToolBar(long style = wxNO_BORDER | wxTB_HORIZONTAL | wxTB_FLAT, - wxWindowID id = -1, - const wxString& name = wxToolBarNameStr); - void SetToolBar(wxToolBar *toolbar); -#endif // wxUSE_TOOLBAR - - wxPoint GetClientAreaOrigin() const { return wxPoint(0, 0); } - - // implementation from now on - // -------------------------- - - // GTK callbacks - virtual void GtkOnSize( int x, int y, int width, int height ); - virtual void OnInternalIdle(); - - bool m_menuBarDetached; - int m_menuBarHeight; - bool m_toolBarDetached; - -protected: - // common part of all ctors - void Init(); - - // override wxWindow methods to take into account tool/menu/statusbars - virtual void DoSetClientSize(int width, int height); - virtual void DoGetClientSize( int *width, int *height ) const; - -#if wxUSE_MENUS_NATIVE - - virtual void DetachMenuBar(); - virtual void AttachMenuBar(wxMenuBar *menubar); - -public: - // Menu size is dynamic now, call this whenever it might change. - void UpdateMenuBarSize(); - -#endif // wxUSE_MENUS_NATIVE - - DECLARE_DYNAMIC_CLASS(wxFrame) -}; - -#endif // __GTKFRAMEH__ diff --git a/include/wx/gtk1/gauge.h b/include/wx/gtk1/gauge.h deleted file mode 100644 index 3bf4aba836..0000000000 --- a/include/wx/gtk1/gauge.h +++ /dev/null @@ -1,101 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: gauge.h -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - - -#ifndef __GTKGAUGEH__ -#define __GTKGAUGEH__ - -#include "wx/defs.h" - -#if wxUSE_GAUGE - -#include "wx/object.h" -#include "wx/list.h" -#include "wx/control.h" - -//----------------------------------------------------------------------------- -// classes -//----------------------------------------------------------------------------- - -class wxGauge; - -//----------------------------------------------------------------------------- -// global data -//----------------------------------------------------------------------------- - -extern const wxChar* wxGaugeNameStr; - -//----------------------------------------------------------------------------- -// wxGaugeBox -//----------------------------------------------------------------------------- - -class wxGauge: public wxControl -{ -public: - wxGauge() { Init(); } - - wxGauge( wxWindow *parent, - wxWindowID id, - int range, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxGA_HORIZONTAL, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxGaugeNameStr ) - { - Init(); - - Create(parent, id, range, pos, size, style, validator, name); - } - - bool Create( wxWindow *parent, - wxWindowID id, int range, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxGA_HORIZONTAL, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxGaugeNameStr ); - - void SetShadowWidth( int WXUNUSED(w) ) { } - void SetBezelFace( int WXUNUSED(w) ) { } - void SetRange( int r ); - void SetValue( int pos ); - int GetShadowWidth() const { return 0; }; - int GetBezelFace() const { return 0; }; - int GetRange() const; - int GetValue() const; - - // implementation - // ------------- - - void ApplyWidgetStyle(); - - // the max and current gauge values - int m_rangeMax, - m_gaugePos; - - // obsolete functions, don't use -#ifdef WXWIN_COMPATIBILITY_2_2 - bool GetProgressBar() const { return TRUE; } -#endif // WXWIN_COMPATIBILITY_2_2 - -protected: - // common part of all ctors - void Init() { m_rangeMax = m_gaugePos = 0; } - - // set the gauge value to the value of m_gaugePos - void DoSetGauge(); - -private: - DECLARE_DYNAMIC_CLASS(wxGauge) -}; - -#endif - -#endif // __GTKGAUGEH__ diff --git a/include/wx/gtk1/gdiobj.h b/include/wx/gtk1/gdiobj.h deleted file mode 100644 index f6c64a5fda..0000000000 --- a/include/wx/gtk1/gdiobj.h +++ /dev/null @@ -1,35 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: gdiobj.h -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling, Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - - -#ifndef __GDIOBJH__ -#define __GDIOBJH__ - -#include "wx/object.h" - -class wxGDIObject : public wxObject -{ -public: - inline wxGDIObject() { m_visible = FALSE; }; - inline ~wxGDIObject() {} - - virtual bool GetVisible() { return m_visible; } - virtual void SetVisible( bool visible ) { m_visible = visible; } - - bool IsNull() const { return (m_refData == 0); } - -protected: - bool m_visible; /* can a pointer to this object be safely taken? - * - only if created within FindOrCreate... */ -private: - DECLARE_DYNAMIC_CLASS(wxGDIObject) -}; - -#endif - // __GDIOBJH__ diff --git a/include/wx/gtk1/glcanvas.h b/include/wx/gtk1/glcanvas.h deleted file mode 100644 index 953a406739..0000000000 --- a/include/wx/gtk1/glcanvas.h +++ /dev/null @@ -1,176 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: glcanvas.h -// Purpose: wxGLCanvas, for using OpenGL/Mesa with wxWindows and GTK -// Author: Robert Roebling -// Modified by: -// Created: 17/8/98 -// RCS-ID: $Id$ -// Copyright: (c) Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GLCANVAS_H_ -#define _WX_GLCANVAS_H_ - -#include "wx/scrolwin.h" -#include "wx/app.h" - -extern "C" { -#include -#include -#include -} - -//--------------------------------------------------------------------------- -// Constants for attriblist -//--------------------------------------------------------------------------- - -enum -{ - WX_GL_RGBA=1, /* use true color palette */ - WX_GL_BUFFER_SIZE, /* bits for buffer if not WX_GL_RGBA */ - WX_GL_LEVEL, /* 0 for main buffer, >0 for overlay, <0 for underlay */ - WX_GL_DOUBLEBUFFER, /* use doublebuffer */ - WX_GL_STEREO, /* use stereoscopic display */ - WX_GL_AUX_BUFFERS, /* number of auxiliary buffers */ - WX_GL_MIN_RED, /* use red buffer with most bits (> MIN_RED bits) */ - WX_GL_MIN_GREEN, /* use green buffer with most bits (> MIN_GREEN bits) */ - WX_GL_MIN_BLUE, /* use blue buffer with most bits (> MIN_BLUE bits) */ - WX_GL_MIN_ALPHA, /* use blue buffer with most bits (> MIN_ALPHA bits) */ - WX_GL_DEPTH_SIZE, /* bits for Z-buffer (0,16,32) */ - WX_GL_STENCIL_SIZE, /* bits for stencil buffer */ - WX_GL_MIN_ACCUM_RED, /* use red accum buffer with most bits (> MIN_ACCUM_RED bits) */ - WX_GL_MIN_ACCUM_GREEN, /* use green buffer with most bits (> MIN_ACCUM_GREEN bits) */ - WX_GL_MIN_ACCUM_BLUE, /* use blue buffer with most bits (> MIN_ACCUM_BLUE bits) */ - WX_GL_MIN_ACCUM_ALPHA /* use blue buffer with most bits (> MIN_ACCUM_ALPHA bits) */ -}; - -//--------------------------------------------------------------------------- -// classes -//--------------------------------------------------------------------------- - -class WXDLLEXPORT wxGLContext; -class WXDLLEXPORT wxGLCanvas; - -//--------------------------------------------------------------------------- -// wxGLContext -//--------------------------------------------------------------------------- - - -class WXDLLEXPORT wxGLContext: public wxObject -{ -public: - wxGLContext( bool isRGB, wxWindow *win, const wxPalette& palette = wxNullPalette ); - wxGLContext( - bool WXUNUSED(isRGB), wxWindow *win, - const wxPalette& WXUNUSED(palette), - const wxGLContext *other /* for sharing display lists */ - ); - ~wxGLContext(); - - void SetCurrent(); - void SetColour(const wxChar *colour); - void SwapBuffers(); - - void SetupPixelFormat(); - void SetupPalette(const wxPalette& palette); - wxPalette CreateDefaultPalette(); - - inline wxPalette* GetPalette() const { return (wxPalette*) & m_palette; } - inline wxWindow* GetWindow() const { return m_window; } - inline GtkWidget* GetWidget() const { return m_widget; } - inline GLXContext GetContext() const { return m_glContext; } - -public: - GLXContext m_glContext; - - GtkWidget *m_widget; - wxPalette m_palette; - wxWindow* m_window; - -private: - DECLARE_CLASS(wxGLContext) -}; - -//--------------------------------------------------------------------------- -// wxGLCanvas -//--------------------------------------------------------------------------- - -class WXDLLEXPORT wxGLCanvas: public wxWindow -{ -public: - inline wxGLCanvas() { - m_glContext = (wxGLContext*) NULL; - m_sharedContext = (wxGLContext*) NULL; - m_glWidget = (GtkWidget*) NULL; - m_vi = (void*) NULL; - m_exposed = FALSE; - } - wxGLCanvas( wxWindow *parent, wxWindowID id = -1, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, const wxString& name = wxGLCanvasName, - int *attribList = (int*) NULL, - const wxPalette& palette = wxNullPalette ); - wxGLCanvas( wxWindow *parent, const wxGLContext *shared = (wxGLContext *)NULL, - wxWindowID id = -1, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, const wxString& name = wxGLCanvasName, - int *attribList = (int*) NULL, - const wxPalette& palette = wxNullPalette ); - wxGLCanvas( wxWindow *parent, const wxGLCanvas *shared = (wxGLCanvas *)NULL, - wxWindowID id = -1, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, const wxString& name = wxGLCanvasName, - int *attribList = (int*) NULL, - const wxPalette& palette = wxNullPalette ); - - bool Create( wxWindow *parent, - const wxGLContext *shared = (wxGLContext*)NULL, - const wxGLCanvas *shared_context_of = (wxGLCanvas*)NULL, - wxWindowID id = -1, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxGLCanvasName, - int *attribList = (int*) NULL, - const wxPalette& palette = wxNullPalette ); - - ~wxGLCanvas(); - - void SetCurrent(); - void SetColour(const wxChar *colour); - void SwapBuffers(); - - void OnSize(wxSizeEvent& event); - - void OnInternalIdle(); - - inline wxGLContext* GetContext() const { return m_glContext; } - - // implementation - - wxGLContext *m_glContext, - *m_sharedContext; - wxGLCanvas *m_sharedContextOf; - void *m_vi; // actually an XVisualInfo* - bool m_canFreeVi; - GtkWidget *m_glWidget; - bool m_exposed; - - // returns an XVisualInfo* based on desired GL attributes; - // returns NULL if an appropriate visual is not found. The - // caller is reponsible for using XFree() to deallocate - // the returned structure. - static void* ChooseGLVisual(int *attribList); - -private: - DECLARE_EVENT_TABLE() - DECLARE_CLASS(wxGLCanvas) -}; - -#endif - // _WX_GLCANVAS_H_ - diff --git a/include/wx/gtk1/icon.h b/include/wx/gtk1/icon.h deleted file mode 100644 index aa7a75c536..0000000000 --- a/include/wx/gtk1/icon.h +++ /dev/null @@ -1,58 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: icon.h -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - - -#ifndef __GTKICONH__ -#define __GTKICONH__ - -#include "wx/defs.h" -#include "wx/object.h" -#include "wx/bitmap.h" - -//----------------------------------------------------------------------------- -// classes -//----------------------------------------------------------------------------- - -class wxIcon; - -//----------------------------------------------------------------------------- -// wxIcon -//----------------------------------------------------------------------------- - -class wxIcon: public wxBitmap -{ -public: - wxIcon(); - wxIcon( const wxIcon& icon); - wxIcon( const char **bits, int width=-1, int height=-1 ); - - // For compatibility with wxMSW where desired size is sometimes required to - // distinguish between multiple icons in a resource. - wxIcon( const wxString& filename, int type = wxBITMAP_TYPE_XPM, - int WXUNUSED(desiredWidth)=-1, int WXUNUSED(desiredHeight)=-1 ) : - wxBitmap(filename, type) - { - } - wxIcon( char **bits, int width=-1, int height=-1 ); - - wxIcon& operator=(const wxIcon& icon); - bool operator==(const wxIcon& icon) const { return m_refData == icon.m_refData; } - bool operator!=(const wxIcon& icon) const { return !(*this == icon); } - - // create from bitmap (which should have a mask unless it's monochrome): - // there shouldn't be any implicit bitmap -> icon conversion (i.e. no - // ctors, assignment operators...), but it's ok to have such function - void CopyFromBitmap(const wxBitmap& bmp); - -private: - DECLARE_DYNAMIC_CLASS(wxIcon) -}; - - -#endif // __GTKICONH__ diff --git a/include/wx/gtk1/joystick.h b/include/wx/gtk1/joystick.h deleted file mode 100644 index 684b6595a7..0000000000 --- a/include/wx/gtk1/joystick.h +++ /dev/null @@ -1,98 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: joystick.h -// Purpose: wxJoystick class -// Author: Guilhem Lavaux -// Modified by: -// Created: 01/02/97 -// RCS-ID: $Id$ -// Copyright: (c) Guilhem Lavaux -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef __JOYSTICKH__ -#define __JOYSTICKH__ - -#include "wx/event.h" -#include "wx/thread.h" - -class WXDLLEXPORT wxJoystick: public wxObject, public wxThread -{ - DECLARE_DYNAMIC_CLASS(wxJoystick) - public: - /* - * Public interface - */ - - wxJoystick(int joystick = wxJOYSTICK1); - - // Attributes - //////////////////////////////////////////////////////////////////////////// - - wxPoint GetPosition(void) const; - int GetZPosition(void) const; - int GetButtonState(void) const; - int GetPOVPosition(void) const; - int GetPOVCTSPosition(void) const; - int GetRudderPosition(void) const; - int GetUPosition(void) const; - int GetVPosition(void) const; - int GetMovementThreshold(void) const; - void SetMovementThreshold(int threshold) ; - - // Capabilities - //////////////////////////////////////////////////////////////////////////// - - bool IsOk(void) const; // Checks that the joystick is functioning - int GetNumberJoysticks(void) const ; - int GetManufacturerId(void) const ; - int GetProductId(void) const ; - wxString GetProductName(void) const ; - int GetXMin(void) const; - int GetYMin(void) const; - int GetZMin(void) const; - int GetXMax(void) const; - int GetYMax(void) const; - int GetZMax(void) const; - int GetNumberButtons(void) const; - int GetNumberAxes(void) const; - int GetMaxButtons(void) const; - int GetMaxAxes(void) const; - int GetPollingMin(void) const; - int GetPollingMax(void) const; - int GetRudderMin(void) const; - int GetRudderMax(void) const; - int GetUMin(void) const; - int GetUMax(void) const; - int GetVMin(void) const; - int GetVMax(void) const; - - bool HasRudder(void) const; - bool HasZ(void) const; - bool HasU(void) const; - bool HasV(void) const; - bool HasPOV(void) const; - bool HasPOV4Dir(void) const; - bool HasPOVCTS(void) const; - - // Operations - //////////////////////////////////////////////////////////////////////////// - - // pollingFreq = 0 means that movement events are sent when above the threshold. - // If pollingFreq > 0, events are received every this many milliseconds. - bool SetCapture(wxWindow* win, int pollingFreq = 0); - bool ReleaseCapture(void); - -protected: - int m_joystick; - wxPoint m_lastposition; - int m_axe[15]; - int m_buttons; - wxWindow *m_catchwin; - int m_polling; - - void *Entry(void); -}; - -#endif - // __JOYSTICKH__ - diff --git a/include/wx/gtk1/listbox.h b/include/wx/gtk1/listbox.h deleted file mode 100644 index 6ea273090c..0000000000 --- a/include/wx/gtk1/listbox.h +++ /dev/null @@ -1,112 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: listbox.h -// Purpose: wxListBox class declaration -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - - -#ifndef __GTKLISTBOXH__ -#define __GTKLISTBOXH__ - -#include "wx/list.h" - -//----------------------------------------------------------------------------- -// wxListBox -//----------------------------------------------------------------------------- - -class wxListBox : public wxListBoxBase -{ -public: - // ctors and such - wxListBox(); - wxListBox( wxWindow *parent, wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - int n = 0, const wxString choices[] = (const wxString *) NULL, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxListBoxNameStr ) - { -#if wxUSE_CHECKLISTBOX - m_hasCheckBoxes = FALSE; -#endif // wxUSE_CHECKLISTBOX - Create(parent, id, pos, size, n, choices, style, validator, name); - } - virtual ~wxListBox(); - - bool Create(wxWindow *parent, wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - int n = 0, const wxString choices[] = (const wxString *) NULL, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxListBoxNameStr); - - // implement base class pure virtuals - virtual void Clear(); - virtual void Delete(int n); - - virtual int GetCount() const; - virtual wxString GetString(int n) const; - virtual void SetString(int n, const wxString& s); - virtual int FindString(const wxString& s) const; - - virtual bool IsSelected(int n) const; - virtual void SetSelection(int n, bool select = TRUE); - virtual int GetSelection() const; - virtual int GetSelections(wxArrayInt& aSelections) const; - - virtual int DoAppend(const wxString& item); - virtual void DoInsertItems(const wxArrayString& items, int pos); - virtual void DoSetItems(const wxArrayString& items, void **clientData); - - virtual void DoSetFirstItem(int n); - - virtual void DoSetItemClientData(int n, void* clientData); - virtual void* DoGetItemClientData(int n) const; - virtual void DoSetItemClientObject(int n, wxClientData* clientData); - virtual wxClientData* DoGetItemClientObject(int n) const; - - // implementation from now on - - void GtkAddItem( const wxString &item, int pos=-1 ); - int GtkGetIndex( GtkWidget *item ) const; - GtkWidget *GetConnectWidget(); - bool IsOwnGtkWindow( GdkWindow *window ); - void ApplyWidgetStyle(); - void OnInternalIdle(); - -#if wxUSE_TOOLTIPS - void ApplyToolTip( GtkTooltips *tips, const wxChar *tip ); -#endif // wxUSE_TOOLTIPS - - GtkList *m_list; - wxList m_clientList; - -#if wxUSE_CHECKLISTBOX - bool m_hasCheckBoxes; -#endif // wxUSE_CHECKLISTBOX - - int m_prevSelection; - bool m_blockEvent; - - virtual void FixUpMouseEvent(GtkWidget *widget, wxCoord& x, wxCoord& y); - -protected: - virtual wxSize DoGetBestSize() const; - - // return the string label for the given item - wxString GetRealLabel(struct _GList *item) const; - -private: - // this array is only used for controls with wxCB_SORT style, so only - // allocate it if it's needed (hence using pointer) - wxSortedArrayString *m_strings; - - DECLARE_DYNAMIC_CLASS(wxListBox) -}; - -#endif // __GTKLISTBOXH__ diff --git a/include/wx/gtk1/mdi.h b/include/wx/gtk1/mdi.h deleted file mode 100644 index dd5ad42f44..0000000000 --- a/include/wx/gtk1/mdi.h +++ /dev/null @@ -1,216 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: gtk/mdi.h -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - - -#ifndef __MDIH__ -#define __MDIH__ - -#include "wx/defs.h" -#include "wx/object.h" -#include "wx/list.h" -#include "wx/control.h" -#include "wx/panel.h" -#include "wx/frame.h" -#include "wx/toolbar.h" - -#if wxUSE_MDI_ARCHITECTURE - -//----------------------------------------------------------------------------- -// classes -//----------------------------------------------------------------------------- - -class wxMDIParentFrame; -class wxMDIClientWindow; -class wxMDIChildFrame; - -//----------------------------------------------------------------------------- -// global data -//----------------------------------------------------------------------------- - -extern const wxChar* wxFrameNameStr; -extern const wxChar* wxStatusLineNameStr; - -//----------------------------------------------------------------------------- -// wxMDIParentFrame -//----------------------------------------------------------------------------- - -class wxMDIParentFrame: public wxFrame -{ -public: - wxMDIParentFrame() { Init(); } - wxMDIParentFrame(wxWindow *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL, - const wxString& name = wxFrameNameStr) - { - Init(); - - (void)Create(parent, id, title, pos, size, style, name); - } - - ~wxMDIParentFrame(); - bool Create( wxWindow *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL, - const wxString& name = wxFrameNameStr ); - - wxMDIChildFrame *GetActiveChild() const; - - wxMDIClientWindow *GetClientWindow() const; - virtual wxMDIClientWindow *OnCreateClient(); - - virtual void Cascade() {} - virtual void Tile() {} - virtual void ArrangeIcons() {} - virtual void ActivateNext(); - virtual void ActivatePrevious(); - - // implementation - - wxMDIClientWindow *m_clientWindow; - bool m_justInserted; - - virtual void GtkOnSize( int x, int y, int width, int height ); - virtual void OnInternalIdle(); - -protected: - void Init(); - - virtual void DoGetClientSize(int *width, int *height) const; - -private: - friend class wxMDIChildFrame; - - DECLARE_DYNAMIC_CLASS(wxMDIParentFrame) -}; - -//----------------------------------------------------------------------------- -// wxMDIChildFrame -//----------------------------------------------------------------------------- - -class wxMDIChildFrame: public wxFrame -{ -public: - wxMDIChildFrame(); - wxMDIChildFrame( wxMDIParentFrame *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE, - const wxString& name = wxFrameNameStr ); - - virtual ~wxMDIChildFrame(); - bool Create( wxMDIParentFrame *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE, - const wxString& name = wxFrameNameStr ); - - virtual void SetMenuBar( wxMenuBar *menu_bar ); - virtual wxMenuBar *GetMenuBar() const; - - virtual void AddChild( wxWindowBase *child ); - - virtual void Activate(); - -#if wxUSE_STATUSBAR - // no status bars - virtual wxStatusBar* CreateStatusBar( int WXUNUSED(number) = 1, - long WXUNUSED(style) = 1, - wxWindowID WXUNUSED(id) = 1, - const wxString& WXUNUSED(name) = wxEmptyString) - { return (wxStatusBar*)NULL; } - - virtual wxStatusBar *GetStatusBar() const { return (wxStatusBar*)NULL; } - virtual void SetStatusText( const wxString &WXUNUSED(text), int WXUNUSED(number)=0 ) {} - virtual void SetStatusWidths( int WXUNUSED(n), const int WXUNUSED(widths_field)[] ) {} -#endif - - // no size hints - virtual void SetSizeHints( int WXUNUSED(minW), - int WXUNUSED(minH), - int WXUNUSED(maxW) = -1, - int WXUNUSED(maxH) = -1, - int WXUNUSED(incW) = -1, - int WXUNUSED(incH) = -1) {} - -#if wxUSE_TOOLBAR - // no toolbar bars - virtual wxToolBar* CreateToolBar( long WXUNUSED(style), - wxWindowID WXUNUSED(id), - const wxString& WXUNUSED(name) ) - { return (wxToolBar*)NULL; } - virtual wxToolBar *GetToolBar() const { return (wxToolBar*)NULL; } -#endif - - // no icon - void SetIcon( const wxIcon &icon ) { m_icons = wxIconBundle( icon ); } - void SetIcons( const wxIconBundle &icons ) { m_icons = icons; } - - // no title - void SetTitle( const wxString &title ); - wxString GetTitle() const { return m_title; } - - // no maximize etc - virtual void Maximize( bool WXUNUSED(maximize) ) {} - virtual void Restore() {} - - virtual bool IsTopLevel() const { return FALSE; } - - void OnActivate( wxActivateEvent& event ); - void OnMenuHighlight( wxMenuEvent& event ); - - // implementation - - wxMenuBar *m_menuBar; - GtkNotebookPage *m_page; - bool m_justInserted; - -protected: - // override wxFrame methods to not do anything - virtual void DoSetSize(int x, int y, - int width, int height, - int sizeFlags = wxSIZE_AUTO); - virtual void DoSetClientSize(int width, int height); - virtual void DoGetClientSize( int *width, int *height ) const; - -private: - DECLARE_EVENT_TABLE() - DECLARE_DYNAMIC_CLASS(wxMDIChildFrame) -}; - -//----------------------------------------------------------------------------- -// wxMDIClientWindow -//----------------------------------------------------------------------------- - -class wxMDIClientWindow: public wxWindow -{ -public: - wxMDIClientWindow(); - wxMDIClientWindow( wxMDIParentFrame *parent, long style = 0 ); - ~wxMDIClientWindow(); - virtual bool CreateClient( wxMDIParentFrame *parent, long style = wxVSCROLL | wxHSCROLL ); - -private: - DECLARE_DYNAMIC_CLASS(wxMDIClientWindow) -}; - -#endif // if USE_MDI... - -#endif // __MDIH__ - diff --git a/include/wx/gtk1/menu.h b/include/wx/gtk1/menu.h deleted file mode 100644 index ae7303336d..0000000000 --- a/include/wx/gtk1/menu.h +++ /dev/null @@ -1,113 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/gtk/menu.h -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling, Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef __GTKMENUH__ -#define __GTKMENUH__ - -//----------------------------------------------------------------------------- -// wxMenuBar -//----------------------------------------------------------------------------- - -class wxMenuBar : public wxMenuBarBase -{ -public: - // ctors - wxMenuBar(); - wxMenuBar(long style); - wxMenuBar(int n, wxMenu *menus[], const wxString titles[]); - virtual ~wxMenuBar(); - - // implement base class (pure) virtuals - virtual bool Append( wxMenu *menu, const wxString &title ); - virtual bool Insert(size_t pos, wxMenu *menu, const wxString& title); - virtual wxMenu *Replace(size_t pos, wxMenu *menu, const wxString& title); - virtual wxMenu *Remove(size_t pos); - - virtual int FindMenuItem(const wxString& menuString, - const wxString& itemString) const; - virtual wxMenuItem* FindItem( int id, wxMenu **menu = NULL ) const; - - virtual void EnableTop( size_t pos, bool flag ); - virtual void SetLabelTop( size_t pos, const wxString& label ); - virtual wxString GetLabelTop( size_t pos ) const; - - // implementation only from now on - void SetInvokingWindow( wxWindow *win ); - void UnsetInvokingWindow( wxWindow *win ); - - // common part of Append and Insert - bool GtkAppend(wxMenu *menu, const wxString& title); - - GtkAccelGroup *m_accel; - GtkItemFactory *m_factory; - GtkWidget *m_menubar; - long m_style; - wxWindow *m_invokingWindow; - -private: - DECLARE_DYNAMIC_CLASS(wxMenuBar) -}; - -//----------------------------------------------------------------------------- -// wxMenu -//----------------------------------------------------------------------------- - -class wxMenu : public wxMenuBase -{ -public: - // ctors & dtor - wxMenu(const wxString& title, long style = 0) - : wxMenuBase(title, style) { Init(); } - - wxMenu(long style = 0) : wxMenuBase(style) { Init(); } - - virtual ~wxMenu(); - - // implement base class virtuals - virtual bool DoAppend(wxMenuItem *item); - virtual bool DoInsert(size_t pos, wxMenuItem *item); - virtual wxMenuItem *DoRemove(wxMenuItem *item); - - // TODO: virtual void SetTitle(const wxString& title); - - // compatibility only -#if wxUSE_MENU_CALLBACK - wxMenu(const wxString& title, const wxFunction func) - : wxMenuBase(title) - { - Init(); - - Callback(func); - } -#endif // WXWIN_COMPATIBILITY_2 - - // implementation - int FindMenuIdByMenuItem( GtkWidget *menuItem ) const; - - // implementation GTK only - GtkWidget *m_menu; // GtkMenu - GtkWidget *m_owner; - GtkAccelGroup *m_accel; - GtkItemFactory *m_factory; - -private: - // common code for all constructors: - void Init(); - - // common part of Append and Insert - bool GtkAppend(wxMenuItem *item); - - // if the last menu item was a radio one, this field contains its path, - // otherwise it is empty - wxString m_pathLastRadio; - - DECLARE_DYNAMIC_CLASS(wxMenu) -}; - -#endif // __GTKMENUH__ diff --git a/include/wx/gtk1/menuitem.h b/include/wx/gtk1/menuitem.h deleted file mode 100644 index 29a8c7ae7e..0000000000 --- a/include/wx/gtk1/menuitem.h +++ /dev/null @@ -1,78 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: menuitem.h -// Purpose: wxMenuItem class -// Author: Robert Roebling -// RCS-ID: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows license -/////////////////////////////////////////////////////////////////////////////// - -#ifndef __GTKMENUITEMH__ -#define __GTKMENUITEMH__ - -#include "wx/bitmap.h" - -//----------------------------------------------------------------------------- -// wxMenuItem -//----------------------------------------------------------------------------- - -class wxMenuItem : public wxMenuItemBase -{ -public: - wxMenuItem(wxMenu *parentMenu = (wxMenu *)NULL, - int id = wxID_SEPARATOR, - const wxString& text = wxEmptyString, - const wxString& help = wxEmptyString, - wxItemKind kind = wxITEM_NORMAL, - wxMenu *subMenu = (wxMenu *)NULL); - ~wxMenuItem(); - - // implement base class virtuals - virtual void SetText( const wxString& str ); - virtual void Enable( bool enable = TRUE ); - virtual void Check( bool check = TRUE ); - virtual bool IsChecked() const; - virtual void SetBitmap(const wxBitmap& bitmap) { m_bitmap = bitmap; } - virtual const wxBitmap& GetBitmap() const { return m_bitmap; } - -#if wxUSE_ACCEL - virtual wxAcceleratorEntry *GetAccel() const; -#endif // wxUSE_ACCEL - - // implementation - void SetMenuItem(GtkWidget *menuItem) { m_menuItem = menuItem; } - GtkWidget *GetMenuItem() const { return m_menuItem; } - GtkWidget *GetLabelWidget() const { return m_labelWidget; } - void SetLabelWidget(GtkWidget *labelWidget) { m_labelWidget = labelWidget; } - wxString GetFactoryPath() const; - - wxString GetHotKey() const { return m_hotKey; } - - // compatibility only, don't use in new code - wxMenuItem(wxMenu *parentMenu, - int id, - const wxString& text, - const wxString& help, - bool isCheckable, - wxMenu *subMenu = (wxMenu *)NULL); - -private: - // common part of all ctors - void Init(const wxString& text); - - // DoSetText() transforms the accel mnemonics in our label from MSW/wxWin - // style to GTK+ and is called from ctor and SetText() - void DoSetText(const wxString& text); - - wxString m_hotKey; - wxBitmap m_bitmap; // Bitmap for menuitem, if any - - GtkWidget *m_menuItem; // GtkMenuItem - GtkWidget* m_labelWidget; // Label widget - - DECLARE_DYNAMIC_CLASS(wxMenuItem) -}; - - -#endif - //__GTKMENUITEMH__ diff --git a/include/wx/gtk1/minifram.h b/include/wx/gtk1/minifram.h deleted file mode 100644 index 80dd5170f2..0000000000 --- a/include/wx/gtk1/minifram.h +++ /dev/null @@ -1,65 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: minifram.h -// Purpose: wxMiniFrame class -// Author: Robert Roebling -// RCS-ID: $Id$ -// Copyright: (c) Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef __GTKMINIFRAMEH__ -#define __GTKMINIFRAMEH__ - -#include "wx/defs.h" - -#if wxUSE_MINIFRAME - -#include "wx/object.h" -#include "wx/frame.h" - -//----------------------------------------------------------------------------- -// classes -//----------------------------------------------------------------------------- - -class wxMiniFrame; - -//----------------------------------------------------------------------------- -// wxMiniFrame -//----------------------------------------------------------------------------- - -class wxMiniFrame: public wxFrame -{ - DECLARE_DYNAMIC_CLASS(wxMiniFrame) - -public: - wxMiniFrame() {} - wxMiniFrame(wxWindow *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE | wxTINY_CAPTION_HORIZ, - const wxString& name = wxFrameNameStr) - { - Create(parent, id, title, pos, size, style, name); - } - - bool Create(wxWindow *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE | wxTINY_CAPTION_HORIZ, - const wxString& name = wxFrameNameStr); - - // implementation - - bool m_isDragging; - int m_oldX,m_oldY; - int m_diffX,m_diffY; -}; - -#endif - -#endif - // __GTKMINIFRAMEH__ diff --git a/include/wx/gtk1/notebook.h b/include/wx/gtk1/notebook.h deleted file mode 100644 index 8e360d378c..0000000000 --- a/include/wx/gtk1/notebook.h +++ /dev/null @@ -1,137 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: notebook.h -// Purpose: wxNotebook class -// Author: Robert Roebling -// Modified by: -// RCS-ID: $Id$ -// Copyright: (c) Julian Smart and Robert Roebling -// Licence: wxWindows license -///////////////////////////////////////////////////////////////////////////// - -#ifndef __GTKNOTEBOOKH__ -#define __GTKNOTEBOOKH__ - -//----------------------------------------------------------------------------- -// internal class -//----------------------------------------------------------------------------- - -class wxGtkNotebookPage; - -#include "wx/list.h" -WX_DECLARE_LIST(wxGtkNotebookPage, wxGtkNotebookPagesList); - -//----------------------------------------------------------------------------- -// wxNotebook -//----------------------------------------------------------------------------- - -class wxNotebook : public wxNotebookBase -{ -public: - // default for dynamic class - wxNotebook(); - // the same arguments as for wxControl - wxNotebook(wxWindow *parent, - wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxT("notebook")); - // Create() function - bool Create(wxWindow *parent, - wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxT("notebook")); - // dtor - virtual ~wxNotebook(); - - // accessors - // --------- - - // set the currently selected page, return the index of the previously - // selected one (or -1 on error) - // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events - int SetSelection(int nPage); - // get the currently selected page - int GetSelection() const; - - // set/get the title of a page - bool SetPageText(int nPage, const wxString& strText); - wxString GetPageText(int nPage) const; - - // sets/returns item's image index in the current image list - int GetPageImage(int nPage) const; - bool SetPageImage(int nPage, int nImage); - - // control the appearance of the notebook pages - // set the size (the same for all pages) - void SetPageSize(const wxSize& size); - // set the padding between tabs (in pixels) - void SetPadding(const wxSize& padding); - // sets the size of the tabs (assumes all tabs are the same size) - void SetTabSize(const wxSize& sz); - - // operations - // ---------- - // remove one page from the notebook - bool DeletePage(int nPage); - // remove all pages - bool DeleteAllPages(); - - // adds a new page to the notebook (it will be deleted ny the notebook, - // don't delete it yourself). If bSelect, this page becomes active. - // the same as AddPage(), but adds it at the specified position - bool InsertPage( int position, - wxNotebookPage *win, - const wxString& strText, - bool bSelect = FALSE, - int imageId = -1 ); - - // handler for tab navigation - // -------------------------- - void OnNavigationKey(wxNavigationKeyEvent& event); - - // implementation - // -------------- - -#if wxUSE_CONSTRAINTS - void SetConstraintSizes(bool recurse); - bool DoPhase(int phase); -#endif - - void ApplyWidgetStyle(); - - // report if window belongs to notebook - bool IsOwnGtkWindow( GdkWindow *window ); - - // common part of all ctors - void Init(); - - // helper function - wxGtkNotebookPage* GetNotebookPage(int page) const; - - // the additional page data (the pages themselves are in m_pages array) - wxGtkNotebookPagesList m_pagesData; - - // for reasons explained in gtk/notebook.cpp we store the current - // selection internally instead of querying the notebook for it - int m_selection; - - // flag set to TRUE while we're inside "switch_page" callback - bool m_inSwitchPage; - -protected: - // remove one page from the notebook but do not destroy it - virtual wxNotebookPage *DoRemovePage(int nPage); - -private: - // the padding set by SetPadding() - int m_padding; - - DECLARE_DYNAMIC_CLASS(wxNotebook) - DECLARE_EVENT_TABLE() -}; - -#endif - // __GTKNOTEBOOKH__ diff --git a/include/wx/gtk1/pen.h b/include/wx/gtk1/pen.h deleted file mode 100644 index 9600ba7e45..0000000000 --- a/include/wx/gtk1/pen.h +++ /dev/null @@ -1,79 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: pen.h -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - - -#ifndef __GTKPENH__ -#define __GTKPENH__ - -#include "wx/defs.h" -#include "wx/object.h" -#include "wx/string.h" -#include "wx/gdiobj.h" -#include "wx/gdicmn.h" - -//----------------------------------------------------------------------------- -// classes -//----------------------------------------------------------------------------- - -class wxPen; - -#if defined(__WXGTK127__) || defined(__WXGTK20__) -typedef gint8 wxGTKDash; -#else -typedef gchar wxGTKDash; -#endif - -//----------------------------------------------------------------------------- -// wxPen -//----------------------------------------------------------------------------- - -class wxPen: public wxGDIObject -{ -public: - wxPen() { } - - wxPen( const wxColour &colour, int width, int style ); - ~wxPen(); - - wxPen( const wxPen& pen ) - : wxGDIObject() - { Ref(pen); } - wxPen& operator = ( const wxPen& pen ) { Ref(pen); return *this; } - - bool Ok() const { return m_refData != NULL; } - - bool operator == ( const wxPen& pen ) const; - bool operator != (const wxPen& pen) const { return !(*this == pen); } - - void SetColour( const wxColour &colour ); - void SetColour( int red, int green, int blue ); - void SetCap( int capStyle ); - void SetJoin( int joinStyle ); - void SetStyle( int style ); - void SetWidth( int width ); - void SetDashes( int number_of_dashes, const wxDash *dash ); - - wxColour &GetColour() const; - int GetCap() const; - int GetJoin() const; - int GetStyle() const; - int GetWidth() const; - int GetDashes(wxDash **ptr) const; - int GetDashCount() const; - wxDash* GetDash() const; - -private: - // ref counting code - virtual wxObjectRefData *CreateRefData() const; - virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const; - - DECLARE_DYNAMIC_CLASS(wxPen) -}; - -#endif // __GTKPENH__ diff --git a/include/wx/gtk1/popupwin.h b/include/wx/gtk1/popupwin.h deleted file mode 100644 index ed6a615957..0000000000 --- a/include/wx/gtk1/popupwin.h +++ /dev/null @@ -1,54 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: popupwin.h -// Purpose: -// Author: Robert Roebling -// Created: -// Id: $Id$ -// Copyright: (c) 2001 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef __GTKPOPUPWINH__ -#define __GTKPOPUPWINH__ - -#include "wx/defs.h" -#include "wx/panel.h" -#include "wx/icon.h" - -//----------------------------------------------------------------------------- -// wxPopUpWindow -//----------------------------------------------------------------------------- - -class wxPopupWindow: public wxPopupWindowBase -{ -public: - wxPopupWindow() { } - virtual ~wxPopupWindow(); - - wxPopupWindow(wxWindow *parent, int flags = wxBORDER_NONE) - { (void)Create(parent, flags); } - bool Create(wxWindow *parent, int flags = wxBORDER_NONE); - - virtual bool Show( bool show = TRUE ); - - // implementation - // -------------- - - virtual void DoMoveWindow(int x, int y, int width, int height); - - virtual void OnInternalIdle(); - - -protected: - void GtkOnSize( int x, int y, int width, int height ); - - virtual void DoSetSize(int x, int y, - int width, int height, - int sizeFlags = wxSIZE_AUTO); - -private: - DECLARE_EVENT_TABLE() - DECLARE_DYNAMIC_CLASS(wxPopupWindow) -}; - -#endif // __GTKPOPUPWINDOWH__ diff --git a/include/wx/gtk1/private.h b/include/wx/gtk1/private.h deleted file mode 100644 index 877dd4b561..0000000000 --- a/include/wx/gtk1/private.h +++ /dev/null @@ -1,149 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: wx/gtk/private.h -// Purpose: wxGTK private macros, functions &c -// Author: Vadim Zeitlin -// Modified by: -// Created: 12.03.02 -// RCS-ID: $Id$ -// Copyright: (c) 2002 Vadim Zeitlin -// Licence: wxWindows license -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GTK_PRIVATE_H_ -#define _WX_GTK_PRIVATE_H_ - -#include -#include - -#include "wx/event.h" - -// fail all version tests if the GTK+ version is so ancient that it doesn't -// even have GTK_CHECK_VERSION -#ifndef GTK_CHECK_VERSION - #define GTK_CHECK_VERSION(a, b, c) 0 -#endif - -#ifdef __WXGTK20__ -#if wxUSE_UNICODE - #define wxGTK_CONV(s) wxConvUTF8.cWX2MB(s) - #define wxGTK_CONV_BACK(s) wxConvUTF8.cMB2WX(s) -#else - #define wxGTK_CONV(s) wxConvUTF8.cWC2MB( wxConvLocal.cWX2WC(s) ) - #define wxGTK_CONV_BACK(s) wxConvLocal.cWC2WX( (wxConvUTF8.cMB2WC( s ) ) ) -#endif -#else - #define wxGTK_CONV(s) s.c_str() - #define wxGTK_CONV_BACK(s) s -#endif - - -// GTK+ 2.0 compatibility define is broken when used from C++ as it -// casts enum to int implicitly -#ifdef __WXGTK20__ - #undef gtk_signal_disconnect_by_func - #define gtk_signal_disconnect_by_func(object,func,data) \ - gtk_signal_compat_matched((object), (func), (data), \ - (GSignalMatchType)(G_SIGNAL_MATCH_FUNC | \ - G_SIGNAL_MATCH_DATA), 0) -#endif - -// child is not a member of GTK_BUTTON() any more in GTK+ 2.0 -#ifdef __WXGTK20__ - #define BUTTON_CHILD(w) GTK_BIN((w))->child -#else - #define BUTTON_CHILD(w) GTK_BUTTON((w))->child -#endif - -// event_window has disappeared from GtkToggleButton in GTK+ 2.0 -#ifdef __WXGTK20__ - #define TOGGLE_BUTTON_EVENT_WIN(w) GTK_BUTTON((w))->event_window -#else - #define TOGGLE_BUTTON_EVENT_WIN(w) GTK_TOGGLE_BUTTON((w))->event_window -#endif - -// get the font from a style -// -// TODO: GdkFont has been replaced by PangoFontDescription in GTK+ 2.0 -// and we really should use it instead of GdkFont (see also dclient.cpp) -#ifdef __WXGTK20__ - #define GET_STYLE_FONT(style) gtk_style_get_font(style) - #define SET_STYLE_FONT(style, font) gtk_style_set_font(style, font) -#else - #define GET_STYLE_FONT(style) ((style)->font) - #define SET_STYLE_FONT(style, fnt) \ - gdk_font_unref( style->font ); \ - style->font = gdk_font_ref( fnt ) -#endif - -// gtk_editable_{copy|cut|paste}_clipboard() had an extra argument under -// previous GTK+ versions but no more -#if defined(__WXGTK20__) || (GTK_MINOR_VERSION > 0) - #define DUMMY_CLIPBOARD_ARG -#else - #define DUMMY_CLIPBOARD_ARG ,0 -#endif - -// _GtkEditable is now private -#ifdef __WXGTK20__ - #define GET_EDITABLE_POS(w) gtk_editable_get_position(GTK_EDITABLE(w)) - #define SET_EDITABLE_POS(w, pos) \ - gtk_editable_set_position(GTK_EDITABLE(w), (pos)) -#else - #define GET_EDITABLE_POS(w) GTK_EDITABLE((w))->current_pos - #define SET_EDITABLE_POS(w, pos) \ - GTK_EDITABLE((w))->current_pos = (pos) -#endif - -// this GtkNotebook struct field has been renamed -#ifdef __WXGTK20__ - #define NOTEBOOK_PANEL(nb) GTK_NOTEBOOK(nb)->event_window -#else - #define NOTEBOOK_PANEL(nb) GTK_NOTEBOOK(nb)->panel -#endif - -#ifdef __WXGTK20__ - #define SCROLLBAR_CBACK_ARG - #define GET_SCROLL_TYPE(w) GTK_SCROLL_JUMP -#else - #define SCROLLBAR_CBACK_ARG - #define GET_SCROLL_TYPE(w) GTK_RANGE((w))->scroll_type -#endif - -// translate a GTK+ scroll type to a wxEventType -inline wxEventType GtkScrollTypeToWx(guint scrollType) -{ - wxEventType command; - switch ( scrollType ) - { - case GTK_SCROLL_STEP_BACKWARD: - command = wxEVT_SCROLL_LINEUP; - break; - - case GTK_SCROLL_STEP_FORWARD: - command = wxEVT_SCROLL_LINEDOWN; - break; - - case GTK_SCROLL_PAGE_BACKWARD: - command = wxEVT_SCROLL_PAGEUP; - break; - - case GTK_SCROLL_PAGE_FORWARD: - command = wxEVT_SCROLL_PAGEDOWN; - break; - - default: - command = wxEVT_SCROLL_THUMBTRACK; - } - - return command; -} - -inline wxEventType GtkScrollWinTypeToWx(guint scrollType) -{ - // GtkScrollTypeToWx() returns SCROLL_XXX, not SCROLLWIN_XXX as we need - return GtkScrollTypeToWx(scrollType) + - wxEVT_SCROLLWIN_TOP - wxEVT_SCROLL_TOP; -} - -#endif // _WX_GTK_PRIVATE_H_ - diff --git a/include/wx/gtk1/radiobox.h b/include/wx/gtk1/radiobox.h deleted file mode 100644 index 6c81e98a39..0000000000 --- a/include/wx/gtk1/radiobox.h +++ /dev/null @@ -1,114 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/gtk/radiobox.h -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - - -#ifndef __GTKRADIOBOXH__ -#define __GTKRADIOBOXH__ - -#include "wx/bitmap.h" - -//----------------------------------------------------------------------------- -// wxRadioBox -//----------------------------------------------------------------------------- - -class wxRadioBox: public wxControl -{ -public: - wxRadioBox() { Init(); } - wxRadioBox(wxWindow *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - int n = 0, - const wxString choices[] = (const wxString *) NULL, - int majorDim = 1, - long style = wxRA_HORIZONTAL, - const wxValidator& val = wxDefaultValidator, - const wxString& name = wxRadioBoxNameStr) - { - Init(); - - Create( parent, id, title, pos, size, n, choices, majorDim, style, val, name ); - } - - virtual ~wxRadioBox(); - bool Create(wxWindow *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - int n = 0, - const wxString choices[] = (const wxString *) NULL, - int majorDim = 0, - long style = wxRA_HORIZONTAL, - const wxValidator& val = wxDefaultValidator, - const wxString& name = wxRadioBoxNameStr); - - int FindString( const wxString& s) const; - void SetSelection( int n ); - int GetSelection() const; - - wxString GetString( int n ) const; - void SetString( int n, const wxString& label ); - - void Show( int item, bool show ); - void Enable( int item, bool enable ); - - virtual wxString GetStringSelection() const; - virtual bool SetStringSelection( const wxString& s ); - - int GetCount() const; - int GetNumberOfRowsOrCols() const; - void SetNumberOfRowsOrCols( int n ); - - // for compatibility only, don't use these methods in new code! -#if WXWIN_COMPATIBILITY_2_2 - int Number() const { return GetCount(); } - wxString GetLabel(int n) const { return GetString(n); } - void SetLabel( int item, const wxString& label ) - { SetString(item, label); } -#endif // WXWIN_COMPATIBILITY_2_2 - - // we have to override those to avoid virtual function name hiding - virtual wxString GetLabel() const { return wxControl::GetLabel(); } - virtual void SetLabel( const wxString& label ); - virtual bool Show( bool show = TRUE ); - virtual bool Enable( bool enable = TRUE ); - - // implementation - // -------------- - - void SetFocus(); - void GtkDisableEvents(); - void GtkEnableEvents(); - bool IsOwnGtkWindow( GdkWindow *window ); - void ApplyWidgetStyle(); -#if wxUSE_TOOLTIPS - void ApplyToolTip( GtkTooltips *tips, const wxChar *tip ); -#endif // wxUSE_TOOLTIPS - wxSize LayoutItems(); - - virtual void DoSetSize( int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO ); - virtual void OnInternalIdle(); - - bool m_hasFocus, - m_lostFocus; - int m_majorDim; - wxList m_boxes; - -protected: - // common part of all ctors - void Init(); - -private: - DECLARE_DYNAMIC_CLASS(wxRadioBox) -}; - -#endif // __GTKRADIOBOXH__ diff --git a/include/wx/gtk1/radiobut.h b/include/wx/gtk1/radiobut.h deleted file mode 100644 index bdeabaf9f9..0000000000 --- a/include/wx/gtk1/radiobut.h +++ /dev/null @@ -1,66 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/gtk/radiobut.h -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - - -#ifndef __GTKRADIOBUTTONH__ -#define __GTKRADIOBUTTONH__ - -//----------------------------------------------------------------------------- -// wxRadioButton -//----------------------------------------------------------------------------- - -class wxRadioButton: public wxControl -{ -public: - wxRadioButton() { } - wxRadioButton( wxWindow *parent, - wxWindowID id, - const wxString& label, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxRadioButtonNameStr ) - { - Create( parent, id, label, pos, size, style, validator, name ); - } - - bool Create( wxWindow *parent, - wxWindowID id, - const wxString& label, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxRadioButtonNameStr ); - - virtual void SetLabel(const wxString& label); - virtual void SetValue(bool val); - virtual bool GetValue() const; - virtual bool Enable( bool enable = TRUE ); - - // implementation - - virtual bool IsRadioButton() const { return TRUE; } - - GSList *m_radioButtonGroup; - void ApplyWidgetStyle(); - bool IsOwnGtkWindow( GdkWindow *window ); - void OnInternalIdle(); - - bool m_blockEvent; - -protected: - virtual wxSize DoGetBestSize() const; - -private: - DECLARE_DYNAMIC_CLASS(wxRadioButton) -}; - -#endif // __GTKRADIOBUTTONH__ diff --git a/include/wx/gtk1/region.h b/include/wx/gtk1/region.h deleted file mode 100644 index 458e1547e2..0000000000 --- a/include/wx/gtk1/region.h +++ /dev/null @@ -1,190 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/gtk/region.h -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GTK_REGION_H_ -#define _WX_GTK_REGION_H_ - -#include "wx/list.h" -#include "wx/gdiobj.h" -#include "wx/gdicmn.h" - -//----------------------------------------------------------------------------- -// classes -//----------------------------------------------------------------------------- - -class wxRegion; - -//----------------------------------------------------------------------------- -// constants -//----------------------------------------------------------------------------- - -enum wxRegionContain -{ - wxOutRegion = 0, - wxPartRegion = 1, - wxInRegion = 2 -}; - -// So far, for internal use only -enum wxRegionOp -{ - wxRGN_AND, // Creates the intersection of the two combined regions. - wxRGN_COPY, // Creates a copy of the region identified by hrgnSrc1. - wxRGN_DIFF, // Combines the parts of hrgnSrc1 that are not part of hrgnSrc2. - wxRGN_OR, // Creates the union of two combined regions. - wxRGN_XOR // Creates the union of two combined regions except for any overlapping areas. -}; - -// ---------------------------------------------------------------------------- -// wxRegion -// ---------------------------------------------------------------------------- - -class wxRegion : public wxGDIObject -{ -public: - wxRegion() { } - - wxRegion( wxCoord x, wxCoord y, wxCoord w, wxCoord h ) - { - InitRect(x, y, w, h); - } - - wxRegion( const wxPoint& topLeft, const wxPoint& bottomRight ) - { - InitRect(topLeft.x, topLeft.y, - bottomRight.x - topLeft.x, bottomRight.y - topLeft.y); - } - - wxRegion( const wxRect& rect ) - { - InitRect(rect.x, rect.y, rect.width, rect.height); - } - - wxRegion( size_t n, const wxPoint *points, int fillStyle = wxODDEVEN_RULE ); - - wxRegion( const wxBitmap& bmp, - const wxColour& transColour = wxNullColour, - int tolerance = 0) - { - Union(bmp, transColour, tolerance); - } - - ~wxRegion(); - - wxRegion( const wxRegion& region ) - : wxGDIObject() - { Ref(region); } - wxRegion& operator = ( const wxRegion& region ) { Ref(region); return *this; } - - bool Ok() const { return m_refData != NULL; } - - bool operator == ( const wxRegion& region ); - bool operator != ( const wxRegion& region ) { return !(*this == region); } - - void Clear(); - - bool Offset( wxCoord x, wxCoord y ); - - bool Union( wxCoord x, wxCoord y, wxCoord width, wxCoord height ); - bool Union( const wxRect& rect ); - bool Union( const wxRegion& region ); - - bool Intersect( wxCoord x, wxCoord y, wxCoord width, wxCoord height ); - bool Intersect( const wxRect& rect ); - bool Intersect( const wxRegion& region ); - - bool Subtract( wxCoord x, wxCoord y, wxCoord width, wxCoord height ); - bool Subtract( const wxRect& rect ); - bool Subtract( const wxRegion& region ); - - bool Xor( wxCoord x, wxCoord y, wxCoord width, wxCoord height ); - bool Xor( const wxRect& rect ); - bool Xor( const wxRegion& region ); - - void GetBox( wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h ) const; - wxRect GetBox() const ; - - bool Empty() const; - bool IsEmpty() const { return Empty(); } - - wxRegionContain Contains( wxCoord x, wxCoord y ) const; - wxRegionContain Contains( wxCoord x, wxCoord y, wxCoord w, wxCoord h ) const; - wxRegionContain Contains(const wxPoint& pt) const; - wxRegionContain Contains(const wxRect& rect) const; - - // Convert the region to a B&W bitmap with the white pixels being inside - // the region. - wxBitmap ConvertToBitmap() const; - - // Use the non-transparent pixels of a wxBitmap for the region to combine - // with this region. If the bitmap has a mask then it will be used, - // otherwise the colour to be treated as transparent may be specified, - // along with an optional tolerance value. - bool Union(const wxBitmap& bmp, - const wxColour& transColour = wxNullColour, - int tolerance = 0); - - -public: - // Init with GdkRegion, set ref count to 2 so that - // the C++ class will not destroy the region! - wxRegion( GdkRegion *region ); - - GdkRegion *GetRegion() const; - -protected: - // ref counting code - virtual wxObjectRefData *CreateRefData() const; - virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const; - - // common part of ctors for a rectangle region - void InitRect(wxCoord x, wxCoord y, wxCoord w, wxCoord h); - -private: - DECLARE_DYNAMIC_CLASS(wxRegion); -}; - -// ---------------------------------------------------------------------------- -// wxRegionIterator: decomposes a region into rectangles -// ---------------------------------------------------------------------------- - -class wxRegionIterator: public wxObject -{ -public: - wxRegionIterator(); - wxRegionIterator(const wxRegion& region); - - void Reset() { m_current = 0u; } - void Reset(const wxRegion& region); - - bool HaveRects() const; - operator bool () const { return HaveRects(); } - - wxRegionIterator& operator ++ (); - wxRegionIterator operator ++ (int); - - wxCoord GetX() const; - wxCoord GetY() const; - wxCoord GetW() const; - wxCoord GetWidth() const { return GetW(); } - wxCoord GetH() const; - wxCoord GetHeight() const { return GetH(); } - wxRect GetRect() const; - -private: - size_t m_current; - wxRegion m_region; - -private: - DECLARE_DYNAMIC_CLASS(wxRegionIterator); -}; - - -#endif - // _WX_GTK_REGION_H_ diff --git a/include/wx/gtk1/scrolbar.h b/include/wx/gtk1/scrolbar.h deleted file mode 100644 index 24e1a6bf76..0000000000 --- a/include/wx/gtk1/scrolbar.h +++ /dev/null @@ -1,81 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: scrolbar.h -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - - -#ifndef __GTKSCROLLBARH__ -#define __GTKSCROLLBARH__ - -#include "wx/defs.h" - -//----------------------------------------------------------------------------- -// classes -//----------------------------------------------------------------------------- - -class wxScrollBar; - -//----------------------------------------------------------------------------- -// wxScrollBar -//----------------------------------------------------------------------------- - -class wxScrollBar: public wxScrollBarBase -{ -public: - wxScrollBar() - { m_adjust = (GtkAdjustment *) NULL; m_oldPos = 0.0; } - inline wxScrollBar( wxWindow *parent, wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxSB_HORIZONTAL, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxScrollBarNameStr ) - { - Create( parent, id, pos, size, style, validator, name ); - } - bool Create( wxWindow *parent, wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxSB_HORIZONTAL, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxScrollBarNameStr ); - ~wxScrollBar(); - int GetThumbPosition() const; - int GetThumbSize() const; - int GetPageSize() const; - int GetRange() const; - virtual void SetThumbPosition( int viewStart ); - virtual void SetScrollbar( int position, int thumbSize, int range, int pageSize, - bool refresh = TRUE ); - - // Backward compatibility - // ---------------------- - - int GetValue(void) const; - void SetValue( int viewStart ); - void GetValues( int *viewStart, int *viewLength, int *objectLength, int *pageLength) const; - int GetViewLength() const; - int GetObjectLength() const; - void SetPageSize( int pageLength ); - void SetObjectLength( int objectLength ); - void SetViewLength( int viewLength ); - - // implementation - // -------------- - - bool IsOwnGtkWindow( GdkWindow *window ); - void ApplyWidgetStyle(); - - GtkAdjustment *m_adjust; - float m_oldPos; - -private: - DECLARE_DYNAMIC_CLASS(wxScrollBar) -}; - -#endif - // __GTKSCROLLBARH__ diff --git a/include/wx/gtk1/scrolwin.h b/include/wx/gtk1/scrolwin.h deleted file mode 100644 index 42cc9346af..0000000000 --- a/include/wx/gtk1/scrolwin.h +++ /dev/null @@ -1,188 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/gtk/scrolwin.h -// Purpose: wxScrolledWindow class -// Author: Robert Roebling -// Modified by: -// Created: 01/02/97 -// RCS-ID: $Id$ -// Copyright: (c) Robert Roebling -// Licence: wxWindows license -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GTK_SCROLLWIN_H_ -#define _WX_GTK_SCROLLWIN_H_ - -// ---------------------------------------------------------------------------- -// headers and constants -// ---------------------------------------------------------------------------- - -#include "wx/window.h" -#include "wx/panel.h" - -WXDLLEXPORT_DATA(extern const wxChar*) wxPanelNameStr; - -// default scrolled window style -#ifndef wxScrolledWindowStyle -#define wxScrolledWindowStyle (wxHSCROLL | wxVSCROLL) -#endif - -// ---------------------------------------------------------------------------- -// wxScrolledWindow -// ---------------------------------------------------------------------------- - -class WXDLLEXPORT wxScrolledWindow : public wxPanel -{ -public: - wxScrolledWindow() - { Init(); } - - wxScrolledWindow(wxWindow *parent, - wxWindowID id = -1, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxScrolledWindowStyle, - const wxString& name = wxPanelNameStr) - { Create(parent, id, pos, size, style, name); } - - void Init(); - - bool Create(wxWindow *parent, - wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxScrolledWindowStyle, - const wxString& name = wxPanelNameStr); - - // Normally the wxScrolledWindow will scroll itself, but in - // some rare occasions you might want it to scroll another - // window (e.g. a child of it in order to scroll only a portion - // the area between the scrollbars (spreadsheet: only cell area - // will move). - virtual void SetTargetWindow( wxWindow *target, bool pushEventHandler = FALSE ); - virtual wxWindow *GetTargetWindow(); - - // Set the scrolled area of the window. - virtual void DoSetVirtualSize( int x, int y ); - - // Set the x, y scrolling increments. - void SetScrollRate( int xstep, int ystep ); - - // Number of pixels per user unit (0 or -1 for no scrollbar) - // Length of virtual canvas in user units - // Length of page in user units - // Default action is to set the virtual size and alter scrollbars - // accordingly. - virtual void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY, - int noUnitsX, int noUnitsY, - int xPos = 0, int yPos = 0, - bool noRefresh = FALSE ); - - // Physically scroll the window - virtual void Scroll(int x_pos, int y_pos); - - int GetScrollPageSize(int orient) const; - void SetScrollPageSize(int orient, int pageSize); - - virtual void GetScrollPixelsPerUnit(int *x_unit, int *y_unit) const; - - // Enable/disable Windows scrolling in either direction. - // If TRUE, wxWindows scrolls the canvas and only a bit of - // the canvas is invalidated; no Clear() is necessary. - // If FALSE, the whole canvas is invalidated and a Clear() is - // necessary. Disable for when the scroll increment is used - // to actually scroll a non-constant distance - virtual void EnableScrolling(bool x_scrolling, bool y_scrolling); - - // Get the view start - virtual void GetViewStart(int *x, int *y) const; - - // translate between scrolled and unscrolled coordinates - void CalcScrolledPosition(int x, int y, int *xx, int *yy) const - { DoCalcScrolledPosition(x, y, xx, yy); } - wxPoint CalcScrolledPosition(const wxPoint& pt) const - { - wxPoint p2; - DoCalcScrolledPosition(pt.x, pt.y, &p2.x, &p2.y); - return p2; - } - - void CalcUnscrolledPosition(int x, int y, int *xx, int *yy) const - { DoCalcUnscrolledPosition(x, y, xx, yy); } - wxPoint CalcUnscrolledPosition(const wxPoint& pt) const - { - wxPoint p2; - DoCalcUnscrolledPosition(pt.x, pt.y, &p2.x, &p2.y); - return p2; - } - - virtual void DoCalcScrolledPosition(int x, int y, int *xx, int *yy) const; - virtual void DoCalcUnscrolledPosition(int x, int y, int *xx, int *yy) const; - - // Override this function to draw the graphic (or just process EVT_PAINT) - virtual void OnDraw(wxDC& WXUNUSED(dc)) {} - - // Override this function if you don't want to have wxScrolledWindow - // automatically change the origin according to the scroll position. - virtual void PrepareDC(wxDC& dc); - - // lay out the window and its children - virtual bool Layout(); - - // Adjust the scrollbars - virtual void AdjustScrollbars(); - - // Set the scale factor, used in PrepareDC - void SetScale(double xs, double ys) { m_scaleX = xs; m_scaleY = ys; } - double GetScaleX() const { return m_scaleX; } - double GetScaleY() const { return m_scaleY; } - - // implementation from now on - void OnScroll(wxScrollWinEvent& event); - void OnSize(wxSizeEvent& event); - void OnPaint(wxPaintEvent& event); - void OnChar(wxKeyEvent& event); - - void GtkVScroll( float value, unsigned int scroll_type ); - void GtkHScroll( float value, unsigned int scroll_type ); - void GtkVConnectEvent(); - void GtkHConnectEvent(); - void GtkVDisconnectEvent(); - void GtkHDisconnectEvent(); - - // Calculate scroll increment - virtual int CalcScrollInc(wxScrollWinEvent& event); - - // Overridden from wxWindows due callback being static - virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE ); - -#if WXWIN_COMPATIBILITY_2_2 - // Compatibility - void ViewStart(int *x, int *y) const { GetViewStart( x, y ); } -#endif // WXWIN_COMPATIBILITY_2_2 - -protected: - wxWindow *m_targetWindow; - int m_xScrollPixelsPerLine; - int m_yScrollPixelsPerLine; - bool m_xScrollingEnabled; - bool m_yScrollingEnabled; - - // FIXME: these next four members are duplicated in the GtkAdjustment - // members of wxWindow. Can they be safely removed from here? - - int m_xScrollPosition; - int m_yScrollPosition; - int m_xScrollLinesPerPage; - int m_yScrollLinesPerPage; - - double m_scaleY,m_scaleX; - -private: - DECLARE_EVENT_TABLE() - DECLARE_ABSTRACT_CLASS(wxScrolledWindow) -}; - -#endif - // _WX_GTK_SCROLLWIN_H_ - -// vi:sts=4:sw=4:et diff --git a/include/wx/gtk1/slider.h b/include/wx/gtk1/slider.h deleted file mode 100644 index 00f046ba3d..0000000000 --- a/include/wx/gtk1/slider.h +++ /dev/null @@ -1,72 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/gtk/slider.h -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef __GTKSLIDERH__ -#define __GTKSLIDERH__ - -// ---------------------------------------------------------------------------- -// wxSlider -// ---------------------------------------------------------------------------- - -class wxSlider : public wxSliderBase -{ -public: - wxSlider() { } - wxSlider(wxWindow *parent, - wxWindowID id, - int value, int minValue, int maxValue, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxSL_HORIZONTAL, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxSliderNameStr) - { - Create( parent, id, value, minValue, maxValue, - pos, size, style, validator, name ); - } - - bool Create(wxWindow *parent, - wxWindowID id, - int value, int minValue, int maxValue, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxSL_HORIZONTAL, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxSliderNameStr); - - // implement the base class pure virtuals - virtual int GetValue() const; - virtual void SetValue(int value); - - virtual void SetRange(int minValue, int maxValue); - virtual int GetMin() const; - virtual int GetMax() const; - - virtual void SetLineSize(int lineSize); - virtual void SetPageSize(int pageSize); - virtual int GetLineSize() const; - virtual int GetPageSize() const; - - virtual void SetThumbLength(int lenPixels); - virtual int GetThumbLength() const; - - // implementation - bool IsOwnGtkWindow( GdkWindow *window ); - void ApplyWidgetStyle(); - void GtkDisableEvents(); - void GtkEnableEvents(); - - GtkAdjustment *m_adjust; - float m_oldPos; - -private: - DECLARE_DYNAMIC_CLASS(wxSlider) -}; - -#endif // __GTKSLIDERH__ diff --git a/include/wx/gtk1/spinbutt.h b/include/wx/gtk1/spinbutt.h deleted file mode 100644 index e4e955d71f..0000000000 --- a/include/wx/gtk1/spinbutt.h +++ /dev/null @@ -1,63 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/gtk/spinbutt.h -// Purpose: wxSpinButton class -// Author: Robert Roebling -// Modified by: -// RCS-ID: $Id$ -// Copyright: (c) Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GTK_SPINBUTT_H_ -#define _WX_GTK_SPINBUTT_H_ - -//----------------------------------------------------------------------------- -// wxSpinButton -//----------------------------------------------------------------------------- - -class wxSpinButton : public wxSpinButtonBase -{ -public: - wxSpinButton() { } - wxSpinButton(wxWindow *parent, - wxWindowID id = -1, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxSP_VERTICAL, - const wxString& name = wxSPIN_BUTTON_NAME) - { - Create(parent, id, pos, size, style, name); - } - - bool Create(wxWindow *parent, - wxWindowID id = -1, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxSP_VERTICAL, - const wxString& name = wxSPIN_BUTTON_NAME); - - virtual int GetValue() const; - virtual void SetValue( int value ); - virtual void SetRange( int minVal, int maxVal ); - virtual int GetMin() const; - virtual int GetMax() const; - - // implementation - void OnSize( wxSizeEvent &event ); - - bool IsOwnGtkWindow( GdkWindow *window ); - void ApplyWidgetStyle(); - - GtkAdjustment *m_adjust; - float m_oldPos; - -protected: - virtual wxSize DoGetBestSize() const; - -private: - DECLARE_EVENT_TABLE() - DECLARE_DYNAMIC_CLASS(wxSpinButton) -}; - -#endif - // _WX_GTK_SPINBUTT_H_ diff --git a/include/wx/gtk1/spinctrl.h b/include/wx/gtk1/spinctrl.h deleted file mode 100644 index 138497f44f..0000000000 --- a/include/wx/gtk1/spinctrl.h +++ /dev/null @@ -1,80 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: spinctrl.h -// Purpose: wxSpinCtrl class -// Author: Robert Roebling -// Modified by: -// RCS-ID: $Id$ -// Copyright: (c) Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef __GTKSPINCTRLH__ -#define __GTKSPINCTRLH__ - -#include "wx/defs.h" - -#if wxUSE_SPINCTRL - -#include "wx/control.h" - -//----------------------------------------------------------------------------- -// wxSpinCtrl -//----------------------------------------------------------------------------- - -class wxSpinCtrl : public wxControl -{ -public: - wxSpinCtrl() {} - wxSpinCtrl(wxWindow *parent, - wxWindowID id = -1, - const wxString& value = wxEmptyString, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxSP_ARROW_KEYS, - int min = 0, int max = 100, int initial = 0, - const wxString& name = _T("wxSpinCtrl")) - { - Create(parent, id, value, pos, size, style, min, max, initial, name); - } - - bool Create(wxWindow *parent, - wxWindowID id = -1, - const wxString& value = wxEmptyString, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxSP_ARROW_KEYS, - int min = 0, int max = 100, int initial = 0, - const wxString& name = _T("wxSpinCtrl")); - - void SetValue(const wxString& text); - - virtual int GetValue() const; - virtual void SetValue( int value ); - virtual void SetRange( int minVal, int maxVal ); - virtual int GetMin() const; - virtual int GetMax() const; - - // implementation - void OnChar( wxKeyEvent &event ); - - bool IsOwnGtkWindow( GdkWindow *window ); - void ApplyWidgetStyle(); - void GtkDisableEvents(); - void GtkEnableEvents(); - - GtkAdjustment *m_adjust; - float m_oldPos; - -protected: - virtual wxSize DoGetBestSize() const; - -private: - DECLARE_DYNAMIC_CLASS(wxSpinCtrl) - DECLARE_EVENT_TABLE() -}; - -#endif - // wxUSE_SPINCTRL - -#endif - // __GTKSPINCTRLH__ diff --git a/include/wx/gtk1/statbmp.h b/include/wx/gtk1/statbmp.h deleted file mode 100644 index 0941233ca2..0000000000 --- a/include/wx/gtk1/statbmp.h +++ /dev/null @@ -1,60 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/gtk/statbmp.h -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - - -#ifndef __GTKSTATICBITMAPH__ -#define __GTKSTATICBITMAPH__ - -#include "wx/icon.h" - -//----------------------------------------------------------------------------- -// wxStaticBitmap -//----------------------------------------------------------------------------- - -class wxStaticBitmap : public wxStaticBitmapBase -{ -public: - wxStaticBitmap(); - wxStaticBitmap( wxWindow *parent, - wxWindowID id, - const wxBitmap& label, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxStaticBitmapNameStr ); - bool Create( wxWindow *parent, - wxWindowID id, - const wxBitmap& label, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxStaticBitmapNameStr); - - virtual void SetIcon(const wxIcon& icon) { SetBitmap( icon ); } - virtual void SetBitmap( const wxBitmap& bitmap ); - virtual wxBitmap GetBitmap() const { return m_bitmap; } - - // for compatibility with wxMSW - wxIcon GetIcon() const - { - // don't use wxDynamicCast, icons and bitmaps are really the same thing - // in wxGTK - return (const wxIcon &)m_bitmap; - } - -private: - // creates the new pixmap widget - void CreatePixmapWidget(); - - wxBitmap m_bitmap; - - DECLARE_DYNAMIC_CLASS(wxStaticBitmap) -}; - -#endif // __GTKSTATICBITMAPH__ diff --git a/include/wx/gtk1/statbox.h b/include/wx/gtk1/statbox.h deleted file mode 100644 index d6640d9741..0000000000 --- a/include/wx/gtk1/statbox.h +++ /dev/null @@ -1,49 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/gtk/stabox.h -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - - -#ifndef __GTKSTATICBOXH__ -#define __GTKSTATICBOXH__ - -//----------------------------------------------------------------------------- -// wxStaticBox -//----------------------------------------------------------------------------- - -class wxStaticBox : public wxStaticBoxBase -{ -public: - wxStaticBox(); - wxStaticBox( wxWindow *parent, - wxWindowID id, - const wxString &label, - const wxPoint &pos = wxDefaultPosition, - const wxSize &size = wxDefaultSize, - long style = 0, - const wxString &name = wxStaticBoxNameStr ); - bool Create( wxWindow *parent, - wxWindowID id, - const wxString &label, - const wxPoint &pos = wxDefaultPosition, - const wxSize &size = wxDefaultSize, - long style = 0, - const wxString &name = wxStaticBoxNameStr ); - - virtual void SetLabel( const wxString &label ); - - // implementation - - virtual void ApplyWidgetStyle(); - - virtual bool IsTransparentForMouse() const { return TRUE; } - -private: - DECLARE_DYNAMIC_CLASS(wxStaticBox) -}; - -#endif // __GTKSTATICBOXH__ diff --git a/include/wx/gtk1/statline.h b/include/wx/gtk1/statline.h deleted file mode 100644 index 374ceb0669..0000000000 --- a/include/wx/gtk1/statline.h +++ /dev/null @@ -1,50 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: statline.h -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - - -#ifndef __GTKSTATICLINEH__ -#define __GTKSTATICLINEH__ - -#include "wx/defs.h" - -#if wxUSE_STATLINE - -#include "wx/object.h" -#include "wx/list.h" -#include "wx/control.h" - -//----------------------------------------------------------------------------- -// classes -//----------------------------------------------------------------------------- - -class wxStaticLine; - -//----------------------------------------------------------------------------- -// wxStaticLine -//----------------------------------------------------------------------------- - -class wxStaticLine : public wxStaticLineBase -{ - DECLARE_DYNAMIC_CLASS(wxStaticLine) - -public: - wxStaticLine(); - wxStaticLine( wxWindow *parent, wxWindowID id, - const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, - long style = wxLI_HORIZONTAL, const wxString &name = wxStaticTextNameStr ); - bool Create( wxWindow *parent, wxWindowID id, - const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize, - long style = wxLI_HORIZONTAL, const wxString &name = wxStaticTextNameStr ); -}; - -#endif - // wxUSE_STATLINE - -#endif - // __GTKSTATICLINEH__ diff --git a/include/wx/gtk1/stattext.h b/include/wx/gtk1/stattext.h deleted file mode 100644 index 5b9c4640c2..0000000000 --- a/include/wx/gtk1/stattext.h +++ /dev/null @@ -1,69 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: stattext.h -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - - -#ifndef __GTKSTATICTEXTH__ -#define __GTKSTATICTEXTH__ - -#include "wx/defs.h" -#include "wx/object.h" -#include "wx/list.h" -#include "wx/control.h" - -//----------------------------------------------------------------------------- -// classes -//----------------------------------------------------------------------------- - -class wxStaticText; - -//----------------------------------------------------------------------------- -// global data -//----------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// wxStaticText -//----------------------------------------------------------------------------- - -class wxStaticText : public wxControl -{ -public: - wxStaticText(); - wxStaticText(wxWindow *parent, - wxWindowID id, - const wxString &label, - const wxPoint &pos = wxDefaultPosition, - const wxSize &size = wxDefaultSize, - long style = 0, - const wxString &name = wxStaticTextNameStr ); - - bool Create(wxWindow *parent, - wxWindowID id, - const wxString &label, - const wxPoint &pos = wxDefaultPosition, - const wxSize &size = wxDefaultSize, - long style = 0, - const wxString &name = wxStaticTextNameStr ); - - wxString GetLabel() const; - void SetLabel( const wxString &label ); - - bool SetFont( const wxFont &font ); - - // implementation - // -------------- - - void ApplyWidgetStyle(); - -protected: - virtual wxSize DoGetBestSize() const; - - DECLARE_DYNAMIC_CLASS(wxStaticText) -}; - -#endif // __GTKSTATICTEXTH__ diff --git a/include/wx/gtk1/tbargtk.h b/include/wx/gtk1/tbargtk.h deleted file mode 100644 index 092d6af1fe..0000000000 --- a/include/wx/gtk1/tbargtk.h +++ /dev/null @@ -1,99 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: tbargtk.h -// Purpose: GTK toolbar -// Author: Robert Roebling -// RCS-ID: $Id$ -// Copyright: (c) Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GTK_TBARGTK_H_ -#define _WX_GTK_TBARGTK_H_ - -#if wxUSE_TOOLBAR - -// ---------------------------------------------------------------------------- -// wxToolBar -// ---------------------------------------------------------------------------- - -class wxToolBar : public wxToolBarBase -{ -public: - // construction/destruction - wxToolBar() { Init(); } - wxToolBar( wxWindow *parent, - wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxToolBarNameStr ) - { - Init(); - - Create(parent, id, pos, size, style, name); - } - - bool Create( wxWindow *parent, - wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxToolBarNameStr ); - - virtual ~wxToolBar(); - - // override base class virtuals - virtual void SetMargins(int x, int y); - virtual void SetToolSeparation(int separation); - - virtual wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y) const; - - virtual void SetToolShortHelp(int id, const wxString& helpString); - - virtual void SetWindowStyleFlag( long style ); - - // implementation from now on - // -------------------------- - - GtkToolbar *m_toolbar; - - GdkColor *m_fg; - GdkColor *m_bg; - - bool m_blockEvent; - - void OnInternalIdle(); - -protected: - // common part of all ctors - void Init(); - - // set the GTK toolbar style and orientation - void GtkSetStyle(); - - // implement base class pure virtuals - virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool); - virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool); - - virtual void DoEnableTool(wxToolBarToolBase *tool, bool enable); - virtual void DoToggleTool(wxToolBarToolBase *tool, bool toggle); - virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle); - - virtual wxToolBarToolBase *CreateTool(int id, - const wxString& label, - const wxBitmap& bitmap1, - const wxBitmap& bitmap2, - wxItemKind kind, - wxObject *clientData, - const wxString& shortHelpString, - const wxString& longHelpString); - virtual wxToolBarToolBase *CreateTool(wxControl *control); - -private: - DECLARE_DYNAMIC_CLASS(wxToolBar) -}; - -#endif // wxUSE_TOOLBAR - -#endif - // _WX_GTK_TBARGTK_H_ diff --git a/include/wx/gtk1/textctrl.h b/include/wx/gtk1/textctrl.h deleted file mode 100644 index 69d2400032..0000000000 --- a/include/wx/gtk1/textctrl.h +++ /dev/null @@ -1,190 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/gtk/textctrl.h -// Purpose: -// Author: Robert Roebling -// Created: 01/02/97 -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef __GTKTEXTCTRLH__ -#define __GTKTEXTCTRLH__ - -//----------------------------------------------------------------------------- -// wxTextCtrl -//----------------------------------------------------------------------------- - -class wxTextCtrl: public wxTextCtrlBase -{ -public: - wxTextCtrl() { Init(); } - wxTextCtrl(wxWindow *parent, - wxWindowID id, - const wxString &value = wxEmptyString, - const wxPoint &pos = wxDefaultPosition, - const wxSize &size = wxDefaultSize, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString &name = wxTextCtrlNameStr); - - bool Create(wxWindow *parent, - wxWindowID id, - const wxString &value = wxEmptyString, - const wxPoint &pos = wxDefaultPosition, - const wxSize &size = wxDefaultSize, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString &name = wxTextCtrlNameStr); - - // implement base class pure virtuals - // ---------------------------------- - - virtual wxString GetValue() const; - virtual void SetValue(const wxString& value); - - virtual int GetLineLength(long lineNo) const; - virtual wxString GetLineText(long lineNo) const; - virtual int GetNumberOfLines() const; - - virtual bool IsModified() const; - virtual bool IsEditable() const; - - // If the return values from and to are the same, there is no selection. - virtual void GetSelection(long* from, long* to) const; - - // operations - // ---------- - - // editing - virtual void Clear(); - virtual void Replace(long from, long to, const wxString& value); - virtual void Remove(long from, long to); - - // clears the dirty flag - virtual void DiscardEdits(); - - virtual void SetMaxLength(unsigned long len); - - // writing text inserts it at the current position, appending always - // inserts it at the end - virtual void WriteText(const wxString& text); - virtual void AppendText(const wxString& text); - - // apply text attribute to the range of text (only works with richedit - // controls) - virtual bool SetStyle(long start, long end, const wxTextAttr& style); - - // translate between the position (which is just an index in the text ctrl - // considering all its contents as a single strings) and (x, y) coordinates - // which represent column and line. - virtual long XYToPosition(long x, long y) const; - virtual bool PositionToXY(long pos, long *x, long *y) const; - - virtual void ShowPosition(long pos); - - // Clipboard operations - virtual void Copy(); - virtual void Cut(); - virtual void Paste(); - - // Undo/redo - virtual void Undo(); - virtual void Redo(); - - virtual bool CanUndo() const; - virtual bool CanRedo() const; - - // Insertion point - virtual void SetInsertionPoint(long pos); - virtual void SetInsertionPointEnd(); - virtual long GetInsertionPoint() const; - virtual long GetLastPosition() const; - - virtual void SetSelection(long from, long to); - virtual void SetEditable(bool editable); - - virtual bool Enable( bool enable = TRUE ); - - // Implementation from now on - void OnDropFiles( wxDropFilesEvent &event ); - void OnChar( wxKeyEvent &event ); - - void OnCut(wxCommandEvent& event); - void OnCopy(wxCommandEvent& event); - void OnPaste(wxCommandEvent& event); - void OnUndo(wxCommandEvent& event); - void OnRedo(wxCommandEvent& event); - - void OnUpdateCut(wxUpdateUIEvent& event); - void OnUpdateCopy(wxUpdateUIEvent& event); - void OnUpdatePaste(wxUpdateUIEvent& event); - void OnUpdateUndo(wxUpdateUIEvent& event); - void OnUpdateRedo(wxUpdateUIEvent& event); - - bool SetFont(const wxFont& font); - bool SetForegroundColour(const wxColour& colour); - bool SetBackgroundColour(const wxColour& colour); - - GtkWidget* GetConnectWidget(); - bool IsOwnGtkWindow( GdkWindow *window ); - void ApplyWidgetStyle(); - void CalculateScrollbar(); - void OnInternalIdle(); - void UpdateFontIfNeeded(); - - void SetModified() { m_modified = TRUE; } - - // GTK+ textctrl is so dumb that you need to freeze/thaw it manually to - // avoid horrible flicker/scrolling back and forth - virtual void Freeze(); - virtual void Thaw(); - - // textctrl specific scrolling - virtual bool ScrollLines(int lines); - virtual bool ScrollPages(int pages); - - // implementation only from now on - - // wxGTK-specific: called recursively by Enable, - // to give widgets an oppprtunity to correct their colours after they - // have been changed by Enable - virtual void OnParentEnable( bool enable ) ; - - // tell the control to ignore next text changed signal - void IgnoreNextTextUpdate(); - - // should we ignore the changed signal? always resets the flag - bool IgnoreTextUpdate(); - -protected: - virtual wxSize DoGetBestSize() const; - - // common part of all ctors - void Init(); - - // get the vertical adjustment, if any, NULL otherwise - GtkAdjustment *GetVAdj() const; - - // scroll the control by the given number of pixels, return true if the - // scroll position changed - bool DoScroll(GtkAdjustment *adj, int diff); - -private: - // change the font for everything in this control - void ChangeFontGlobally(); - - GtkWidget *m_text; - GtkWidget *m_vScrollbar; - - bool m_modified:1; - bool m_vScrollbarVisible:1; - bool m_updateFont:1; - bool m_ignoreNextUpdate:1; - - DECLARE_EVENT_TABLE() - DECLARE_DYNAMIC_CLASS(wxTextCtrl); -}; - -#endif // __GTKTEXTCTRLH__ - diff --git a/include/wx/gtk1/tglbtn.h b/include/wx/gtk1/tglbtn.h deleted file mode 100644 index 46403fd35b..0000000000 --- a/include/wx/gtk1/tglbtn.h +++ /dev/null @@ -1,81 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/gtk/tglbtn.h -// Purpose: Declaration of the wxToggleButton class, which implements a -// toggle button under wxGTK. -// Author: John Norris, minor changes by Axel Schlueter -// Modified by: -// Created: 08.02.01 -// RCS-ID: $Id$ -// Copyright: (c) 2000 Johnny C. Norris II -// License: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_GTK_TOGGLEBUTTON_H_ -#define _WX_GTK_TOGGLEBUTTON_H_ - -//----------------------------------------------------------------------------- -// classes -//----------------------------------------------------------------------------- - -class wxToggleButton; - -//----------------------------------------------------------------------------- -// global data -//----------------------------------------------------------------------------- - -extern const wxChar *wxCheckBoxNameStr; - -//----------------------------------------------------------------------------- -// wxToggleButton -//----------------------------------------------------------------------------- - -class wxToggleButton: public wxControl -{ -public: - // construction/destruction - wxToggleButton() {} - wxToggleButton(wxWindow *parent, - wxWindowID id, - const wxString& label, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxCheckBoxNameStr) - { - Create(parent, id, label, pos, size, style, validator, name); - } - - // Create the control - bool Create(wxWindow *parent, - wxWindowID id, - const wxString& label, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, long style = 0, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = wxCheckBoxNameStr); - - // Get/set the value - void SetValue(bool state); - bool GetValue() const; - - // Set the label - void SetLabel(const wxString& label); - bool Enable(bool enable = TRUE); - - - // implementation - bool m_blockEvent; - - void ApplyWidgetStyle(); - bool IsOwnGtkWindow(GdkWindow *window); - - virtual void OnInternalIdle(); - virtual wxSize DoGetBestSize() const; - -private: - DECLARE_DYNAMIC_CLASS(wxToggleButton) -}; - -#endif // _WX_GTK_TOGGLEBUTTON_H_ - diff --git a/include/wx/gtk1/timer.h b/include/wx/gtk1/timer.h deleted file mode 100644 index 94a1036fa1..0000000000 --- a/include/wx/gtk1/timer.h +++ /dev/null @@ -1,40 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/gtk/timer.h -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - - -#ifndef __GTKTIMERH__ -#define __GTKTIMERH__ - -//----------------------------------------------------------------------------- -// wxTimer -//----------------------------------------------------------------------------- - -class wxTimer : public wxTimerBase -{ -public: - wxTimer() { Init(); } - wxTimer(wxEvtHandler *owner, int id = -1) : wxTimerBase(owner, id) - { Init(); } - ~wxTimer(); - - virtual bool Start( int millisecs = -1, bool oneShot = FALSE ); - virtual void Stop(); - - virtual bool IsRunning() const { return m_tag != -1; } - -protected: - void Init(); - - int m_tag; - -private: - DECLARE_ABSTRACT_CLASS(wxTimer) -}; - -#endif // __GTKTIMERH__ diff --git a/include/wx/gtk1/tooltip.h b/include/wx/gtk1/tooltip.h deleted file mode 100644 index e4cb8d03b1..0000000000 --- a/include/wx/gtk1/tooltip.h +++ /dev/null @@ -1,54 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: tooltip.h -// Purpose: wxToolTip class -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef __GTKTOOLTIPH__ -#define __GTKTOOLTIPH__ - -#include "wx/defs.h" -#include "wx/string.h" -#include "wx/object.h" - -//----------------------------------------------------------------------------- -// forward declarations -//----------------------------------------------------------------------------- - -class wxToolTip; -class wxWindow; - -//----------------------------------------------------------------------------- -// wxToolTip -//----------------------------------------------------------------------------- - -class wxToolTip : public wxObject -{ -public: - // globally change the tooltip parameters - static void Enable( bool flag ); - static void SetDelay( long msecs ); - - wxToolTip( const wxString &tip ); - - // get/set the tooltip text - void SetTip( const wxString &tip ); - wxString GetTip() const { return m_text; } - - wxWindow *GetWindow() const { return m_window; } - bool IsOk() const { return m_window != NULL; } - - // implementation - void Apply( wxWindow *win ); - -private: - wxString m_text; - wxWindow *m_window; - - DECLARE_ABSTRACT_CLASS(wxToolTip) -}; - -#endif // __GTKTOOLTIPH__ diff --git a/include/wx/gtk1/toplevel.h b/include/wx/gtk1/toplevel.h deleted file mode 100644 index 8002b3abf7..0000000000 --- a/include/wx/gtk1/toplevel.h +++ /dev/null @@ -1,122 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/gtk/toplevel.h -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling, Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - - -#ifndef __GTKTOPLEVELH__ -#define __GTKTOPLEVELH__ - -//----------------------------------------------------------------------------- -// wxTopLevelWindowGTK -//----------------------------------------------------------------------------- - -class wxTopLevelWindowGTK : public wxTopLevelWindowBase -{ -public: - // construction - wxTopLevelWindowGTK() { Init(); } - wxTopLevelWindowGTK(wxWindow *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE, - const wxString& name = wxFrameNameStr) - { - Init(); - - Create(parent, id, title, pos, size, style, name); - } - - bool Create(wxWindow *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxDEFAULT_FRAME_STYLE, - const wxString& name = wxFrameNameStr); - - virtual ~wxTopLevelWindowGTK(); - - // implement base class pure virtuals - virtual void Maximize(bool maximize = TRUE); - virtual bool IsMaximized() const; - virtual void Iconize(bool iconize = TRUE); - virtual bool IsIconized() const; - virtual void SetIcon(const wxIcon& icon); - virtual void SetIcons(const wxIconBundle& icons); - virtual void Restore(); - - virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL); - virtual bool IsFullScreen() const { return m_fsIsShowing; }; - - /*virtual*/ bool SetShape(const wxRegion& region); - - virtual bool Show(bool show = TRUE); - - virtual void SetTitle( const wxString &title ); - virtual wxString GetTitle() const { return m_title; } - - // Experimental, to allow help windows to be - // viewable from within modal dialogs - virtual void AddGrab(); - virtual void RemoveGrab(); - virtual bool IsGrabbed() const { return m_grabbed; } - - // implementation from now on - // -------------------------- - - // move the window to the specified location and resize it: this is called - // from both DoSetSize() and DoSetClientSize() - virtual void DoMoveWindow(int x, int y, int width, int height); - - // set the icon for this window - void DoSetIcon( const wxIcon& icon ); - - // GTK callbacks - virtual void GtkOnSize( int x, int y, int width, int height ); - virtual void OnInternalIdle(); - - // do *not* call this to iconize the frame, this is a private function! - void SetIconizeState(bool iconic); - - wxString m_title; - int m_miniEdge, - m_miniTitle; - GtkWidget *m_mainWidget; - bool m_insertInClientArea; /* not from within OnCreateXXX */ - - bool m_fsIsShowing; /* full screen */ - long m_fsSaveGdkFunc, m_fsSaveGdkDecor; - long m_fsSaveFlag; - wxRect m_fsSaveFrame; - - // m_windowStyle translated to GDK's terms - long m_gdkFunc, - m_gdkDecor; - -protected: - // common part of all ctors - void Init(); - - // override wxWindow methods to take into account tool/menu/statusbars - virtual void DoSetSize(int x, int y, - int width, int height, - int sizeFlags = wxSIZE_AUTO); - - virtual void DoSetClientSize(int width, int height); - virtual void DoGetClientSize( int *width, int *height ) const; - - // is the frame currently iconized? - bool m_isIconized; - // is the frame currently grabbed explicitly - // by the application? - bool m_grabbed; -}; - -#endif // __GTKTOPLEVELH__ diff --git a/include/wx/gtk1/treectrl.h b/include/wx/gtk1/treectrl.h deleted file mode 100644 index 950c33e9e0..0000000000 --- a/include/wx/gtk1/treectrl.h +++ /dev/null @@ -1,406 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: treectrl.h -// Purpose: wxTreeCtrl class -// Author: Denis Pershin -// Modified by: -// Created: 08/08/98 -// RCS-ID: $Id$ -// Copyright: (c) Denis Pershin -// Licence: wxWindows license -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_TREECTRL_H_ -#define _WX_TREECTRL_H_ - -#include "wx/textctrl.h" -#include "wx/imaglist.h" - -#include - -// the type for "untyped" data -typedef long wxDataType; - -// fwd decl -class wxImageList; -struct wxTreeViewItem; - -// a callback function used for sorting tree items, it should return -1 if the -// first item precedes the second, +1 if the second precedes the first or 0 if -// they're equivalent -class wxTreeItemData; -typedef int (*wxTreeItemCmpFunc)(wxTreeItemData *item1, wxTreeItemData *item2); - -// ---------------------------------------------------------------------------- -// constants -// ---------------------------------------------------------------------------- - -// values for the `flags' parameter of wxTreeCtrl::HitTest() which determine -// where exactly the specified point is situated: - // above the client area. -static const int wxTREE_HITTEST_ABOVE = 0x0001; - // below the client area. -static const int wxTREE_HITTEST_BELOW = 0x0002; - // in the client area but below the last item. -static const int wxTREE_HITTEST_NOWHERE = 0x0004; - // on the button associated with an item. -static const int wxTREE_HITTEST_ONITEMBUTTON = 0x0010; - // on the bitmap associated with an item. -static const int wxTREE_HITTEST_ONITEMICON = 0x0020; - // in the indentation associated with an item. -static const int wxTREE_HITTEST_ONITEMINDENT = 0x0040; - // on the label (string) associated with an item. -static const int wxTREE_HITTEST_ONITEMLABEL = 0x0080; - // in the area to the right of an item. -static const int wxTREE_HITTEST_ONITEMRIGHT = 0x0100; - // on the state icon for a tree view item that is in a user-defined state. -static const int wxTREE_HITTEST_ONITEMSTATEICON = 0x0200; - // to the right of the client area. -static const int wxTREE_HITTEST_TOLEFT = 0x0400; - // to the left of the client area. -static const int wxTREE_HITTEST_TORIGHT = 0x0800; - // anywhere on the item -static const int wxTREE_HITTEST_ONITEM = wxTREE_HITTEST_ONITEMICON | - wxTREE_HITTEST_ONITEMLABEL | - wxTREE_HITTEST_ONITEMSTATEICON; - -// NB: all the following flags are for compatbility only and will be removed in -// next versions - -// flags for deprecated `Expand(int action)' -enum -{ - wxTREE_EXPAND_EXPAND, - wxTREE_EXPAND_COLLAPSE, - wxTREE_EXPAND_COLLAPSE_RESET, - wxTREE_EXPAND_TOGGLE -}; - -// flags for deprecated InsertItem() variant -#define wxTREE_INSERT_FIRST 0xFFFF0001 -#define wxTREE_INSERT_LAST 0xFFFF0002 - -// ---------------------------------------------------------------------------- -// wxTreeItemId identifies an element of the tree. In this implementation, it's -// just a trivial wrapper around GTK GtkTreeItem *. It's opaque for the -// application. -// ---------------------------------------------------------------------------- -class WXDLLEXPORT wxTreeItemId { -public: - // ctors - wxTreeItemId() { m_itemId = NULL; } - - // default copy ctor/assignment operator are ok for us - - // accessors - // is this a valid tree item? - bool IsOk() const { return m_itemId != NULL; } - - // conversion to/from either real (system-dependent) tree item id or - // to "long" which used to be the type for tree item ids in previous - // versions of wxWindows - - // for wxTreeCtrl usage only - wxTreeItemId(GtkTreeItem *itemId) { m_itemId = itemId; } - operator GtkTreeItem *() const { return m_itemId; } - void operator =(GtkTreeItem *item) { m_itemId = item; } - -protected: - GtkTreeItem *m_itemId; -}; - -// ---------------------------------------------------------------------------- -// wxTreeItemData is some (arbitrary) user class associated with some item. The -// main advantage of having this class (compared to old untyped interface) is -// that wxTreeItemData's are destroyed automatically by the tree and, as this -// class has virtual dtor, it means that the memory will be automatically -// freed. OTOH, we don't just use wxObject instead of wxTreeItemData because -// the size of this class is critical: in any real application, each tree leaf -// will have wxTreeItemData associated with it and number of leaves may be -// quite big. -// -// Because the objects of this class are deleted by the tree, they should -// always be allocated on the heap! -// ---------------------------------------------------------------------------- -class WXDLLEXPORT wxTreeItemData : private wxTreeItemId { -public: - // default ctor/copy ctor/assignment operator are ok - - // dtor is virtual and all the items are deleted by the tree control when - // it's deleted, so you normally don't have to care about freeing memory - // allocated in your wxTreeItemData-derived class - virtual ~wxTreeItemData() { } - - // accessors: set/get the item associated with this node - void SetId(const wxTreeItemId& id) { m_itemId = id; } - const wxTreeItemId& GetId() const { return (wxTreeItemId&) m_itemId; } -}; - -class WXDLLEXPORT wxTreeCtrl: public wxControl { -public: - // creation - // -------- - wxTreeCtrl() { Init(); } - - wxTreeCtrl(wxWindow *parent, wxWindowID id = -1, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = "wxTreeCtrl") { - Create(parent, id, pos, size, style, validator, name); - } - - virtual ~wxTreeCtrl(); - - bool Create(wxWindow *parent, wxWindowID id = -1, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT, - const wxValidator& validator = wxDefaultValidator, - const wxString& name = "wxTreeCtrl"); - - // accessors - // --------- - - // get the total number of items in the control - size_t GetCount() const; - - // indent is the number of pixels the children are indented relative to - // the parents position. SetIndent() also redraws the control - // immediately. - unsigned int GetIndent() const; - void SetIndent(unsigned int indent); - - // image list: these functions allow to associate an image list with - // the control and retrieve it. Note that the control does _not_ delete - // the associated image list when it's deleted in order to allow image - // lists to be shared between different controls. - // - // The normal image list is for the icons which correspond to the - // normal tree item state (whether it is selected or not). - // Additionally, the application might choose to show a state icon - // which corresponds to an app-defined item state (for example, - // checked/unchecked) which are taken from the state image list. - wxImageList *GetImageList() const; - wxImageList *GetStateImageList() const; - - void SetImageList(wxImageList *imageList); - void SetStateImageList(wxImageList *imageList); - - // Functions to work with tree ctrl items. Unfortunately, they can _not_ be - // member functions of wxTreeItem because they must know the tree the item - // belongs to for Windows implementation and storing the pointer to - // wxTreeCtrl in each wxTreeItem is just too much waste. - - // accessors - // --------- - - // retrieve items label - wxString GetItemText(const wxTreeItemId& item) const; - // get the normal item image - int GetItemImage(const wxTreeItemId& item) const; - // get the selected item image - int GetItemSelectedImage(const wxTreeItemId& item) const; - // get the data associated with the item - wxTreeItemData *GetItemData(const wxTreeItemId& item) const; - - // modifiers - // --------- - - // set items label - void SetItemText(const wxTreeItemId& item, const wxString& text); - // set the normal item image - void SetItemImage(const wxTreeItemId& item, int image); - // set the selected item image - void SetItemSelectedImage(const wxTreeItemId& item, int image); - // associate some data with the item - void SetItemData(const wxTreeItemId& item, wxTreeItemData *data); - - // item status inquiries - // --------------------- - - // is the item visible (it might be outside the view or not expanded)? - bool IsVisible(const wxTreeItemId& item) const; - // does the item has any children? - bool ItemHasChildren(const wxTreeItemId& item) const; - // is the item expanded (only makes sense if HasChildren())? - bool IsExpanded(const wxTreeItemId& item) const; - // is this item currently selected (the same as has focus)? - bool IsSelected(const wxTreeItemId& item) const; - - // number of children - // ------------------ - - // if 'recursively' is FALSE, only immediate children count, otherwise - // the returned number is the number of all items in this branch - size_t GetChildrenCount(const wxTreeItemId& item, bool recursively = TRUE); - - // navigation - // ---------- - - // wxTreeItemId.IsOk() will return FALSE if there is no such item - - // get the root tree item - wxTreeItemId GetRootItem() const; - - // get the item currently selected (may return NULL if no selection) - wxTreeItemId GetSelection() const; - - // get the parent of this item (may return NULL if root) - wxTreeItemId GetItemParent(const wxTreeItemId& item) const; - - // for this enumeration function you must pass in a "cookie" parameter - // which is opaque for the application but is necessary for the library - // to make these functions reentrant (i.e. allow more than one - // enumeration on one and the same object simultaneously). Of course, - // the "cookie" passed to GetFirstChild() and GetNextChild() should be - // the same! - - // get the first child of this item - wxTreeItemId GetFirstChild(const wxTreeItemId& item, long& cookie) const; - // get the next child (after GetFirstChild or GetNextChild) - wxTreeItemId GetNextChild(const wxTreeItemId& item, long& cookie) const; - // get the last child of this item - this method doesn't use cookies - wxTreeItemId GetLastChild(const wxTreeItemId& item) const; - - // get the next sibling of this item - wxTreeItemId GetNextSibling(const wxTreeItemId& item) const; - // get the previous sibling - wxTreeItemId GetPrevSibling(const wxTreeItemId& item) const; - - // get first visible item - wxTreeItemId GetFirstVisibleItem() const; - // get the next visible item: item must be visible itself! - // see IsVisible() and wxTreeCtrl::GetFirstVisibleItem() - wxTreeItemId GetNextVisible(const wxTreeItemId& item) const; - // get the previous visible item: item must be visible itself! - wxTreeItemId GetPrevVisible(const wxTreeItemId& item) const; - - // operations - // ---------- - - // add the root node to the tree - wxTreeItemId AddRoot(const wxString& text, - int image = -1, int selectedImage = -1, - wxTreeItemData *data = NULL); - - // insert a new item in as the first child of the parent - wxTreeItemId PrependItem(const wxTreeItemId& parent, - const wxString& text, - int image = -1, int selectedImage = -1, - wxTreeItemData *data = NULL); - - // insert a new item after a given one - wxTreeItemId InsertItem(const wxTreeItemId& parent, - const wxTreeItemId& idPrevious, - const wxString& text, - int image = -1, int selectedImage = -1, - wxTreeItemData *data = NULL); - - // insert a new item in as the last child of the parent - wxTreeItemId AppendItem(const wxTreeItemId& parent, - const wxString& text, - int image = -1, int selectedImage = -1, - wxTreeItemData *data = NULL); - - // delete this item and associated data if any - void Delete(const wxTreeItemId& item); - // delete all items from the tree - void DeleteAllItems(); - - // expand this item - void Expand(const wxTreeItemId& item); - // collapse the item without removing its children - void Collapse(const wxTreeItemId& item); - // collapse the item and remove all children - void CollapseAndReset(const wxTreeItemId& item); - // toggles the current state - void Toggle(const wxTreeItemId& item); - - // remove the selection from currently selected item (if any) - void Unselect(); - // select this item - void SelectItem(const wxTreeItemId& item); - // make sure this item is visible (expanding the parent item and/or - // scrolling to this item if necessary) - void EnsureVisible(const wxTreeItemId& item); - // scroll to this item (but don't expand its parent) - void ScrollTo(const wxTreeItemId& item); - - // start editing the item label: this (temporarily) replaces the item - // with a one line edit control. The item will be selected if it hadn't - // been before. textCtrlClass parameter allows you to create an edit - // control of arbitrary user-defined class deriving from wxTextCtrl. - wxTextCtrl* EditLabel(const wxTreeItemId& item, - wxClassInfo* textCtrlClass = CLASSINFO(wxTextCtrl)); - // returns the same pointer as StartEdit() if the item is being edited, - // NULL otherwise (it's assumed that no more than one item may be - // edited simultaneously) - wxTextCtrl* GetEditControl() const; - // end editing and accept or discard the changes to item label - void EndEditLabel(const wxTreeItemId& item, bool discardChanges = FALSE); - - // sort the children of this item using the specified callback function - // (it should return -1, 0 or +1 as usual), if it's not specified - // alphabetical comparaison is performed. - // - // NB: this function is not reentrant! - void SortChildren(const wxTreeItemId& item, - wxTreeItemCmpFunc *cmpFunction = NULL); - - // deprecated - // ---------- - - // these methods are deprecated and will be removed in future versions of - // wxWindows, they're here for compatibility only, don't use them in new - // code (the comments indicate why these methods are now useless and how to - // replace them) - - // use Expand, Collapse, CollapseAndReset or Toggle - void ExpandItem(const wxTreeItemId& item, int action); - - // use AddRoot, PrependItem or AppendItem - wxTreeItemId InsertItem(const wxTreeItemId& parent, - const wxString& text, - int image = -1, int selImage = -1, - long insertAfter = wxTREE_INSERT_LAST); - - // use Set/GetImageList and Set/GetStateImageList - wxImageList *GetImageList(int) const - { return GetImageList(); } - void SetImageList(wxImageList *imageList, int) - { SetImageList(imageList); } - - void SendExpanding(const wxTreeItemId& item); - void SendExpanded(const wxTreeItemId& item); - void SendCollapsing(const wxTreeItemId& item); - void SendCollapsed(const wxTreeItemId& item); - void SendSelChanging(const wxTreeItemId& item); - void SendSelChanged(const wxTreeItemId& item); -protected: - wxTreeItemId m_editItem; - GtkTree *m_tree; - GtkTreeItem *m_anchor; - wxTextCtrl* m_textCtrl; - wxImageList* m_imageListNormal; - wxImageList* m_imageListState; - - long m_curitemId; - - void SendMessage(wxEventType command, const wxTreeItemId& item); -// GtkTreeItem *findGtkTreeItem(wxTreeCtrlId &id) const; - - // the common part of all ctors - void Init(); - // insert a new item in as the last child of the parent - wxTreeItemId p_InsertItem(GtkTreeItem *p, - const wxString& text, - int image, int selectedImage, - wxTreeItemData *data); - - - DECLARE_DYNAMIC_CLASS(wxTreeCtrl) -}; - -#endif - // _WX_TREECTRL_H_ diff --git a/include/wx/gtk1/wave.h b/include/wx/gtk1/wave.h deleted file mode 100644 index 6bb08c14ca..0000000000 --- a/include/wx/gtk1/wave.h +++ /dev/null @@ -1,59 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wave.h -// Purpose: wxWave class -// Author: Julian Smart -// Modified by: -// Created: 25/10/98 -// RCS-ID: $Id$ -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifndef _WX_WAVE_H_ -#define _WX_WAVE_H_ - -#if wxUSE_WAVE - -#include "wx/object.h" - -#ifndef AUDIODEV -#define AUDIODEV "/dev/dsp" // Default path for audio device -#endif - -class wxWave : public wxObject -{ -public: - wxWave(); - wxWave(const wxString& fileName, bool isResource = FALSE); - wxWave(int size, const wxByte* data); - ~wxWave(); - -public: - // Create from resource or file - bool Create(const wxString& fileName, bool isResource = FALSE); - // Create from data - bool Create(int size, const wxByte* data); - - bool IsOk() const { return (m_waveData ? TRUE : FALSE); }; - bool Play(bool async = TRUE, bool looped = FALSE); - -protected: - bool Free(); - -private: - wxByte* m_waveData; - int m_waveLength; - bool m_isResource; - - - int OpenDSP(void); - bool InitDSP(int dev, int iDataBits, int iChannel,unsigned long ulSamplingRate); - int m_DSPblkSize; // Size of the DSP buffer - char *m_data; - int m_sizeData; -}; - -#endif - -#endif - diff --git a/include/wx/gtk1/win_gtk.h b/include/wx/gtk1/win_gtk.h deleted file mode 100644 index 6bd073219b..0000000000 --- a/include/wx/gtk1/win_gtk.h +++ /dev/null @@ -1,135 +0,0 @@ -/* /////////////////////////////////////////////////////////////////////////// -// Name: win_gtk.h -// Purpose: wxWindows's GTK base widget = GtkPizza -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////// */ - - -#ifndef __GTK_PIZZA_H__ -#define __GTK_PIZZA_H__ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#include -#include -#include -#include -#ifndef __WXGTK20__ -#include -#endif - -#define GTK_PIZZA(obj) GTK_CHECK_CAST (obj, gtk_pizza_get_type (), GtkPizza) -#define GTK_PIZZA_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gtk_pizza_get_type (), GtkPizzaClass) -#define GTK_IS_PIZZA(obj) GTK_CHECK_TYPE (obj, gtk_pizza_get_type ()) - -/* Shadow types */ -typedef enum -{ - GTK_MYSHADOW_NONE, - GTK_MYSHADOW_THIN, - GTK_MYSHADOW_IN, - GTK_MYSHADOW_OUT -} GtkMyShadowType; - -typedef struct _GtkPizzaChild GtkPizzaChild; -typedef struct _GtkPizza GtkPizza; -typedef struct _GtkPizzaClass GtkPizzaClass; - -struct _GtkPizzaChild -{ - GtkWidget *widget; - gint x; - gint y; - gint width; - gint height; -}; - -struct _GtkPizza -{ - GtkContainer container; - GList *children; - GtkMyShadowType shadow_type; - - guint width; - guint height; - - guint xoffset; - guint yoffset; - - GdkWindow *bin_window; - - GdkVisibilityState visibility; - gulong configure_serial; - gint scroll_x; - gint scroll_y; - - gboolean clear_on_draw; - gboolean use_filter; - gboolean external_expose; -}; - -struct _GtkPizzaClass -{ - GtkContainerClass parent_class; - - void (*set_scroll_adjustments) (GtkPizza *pizza, - GtkAdjustment *hadjustment, - GtkAdjustment *vadjustment); -}; - -guint gtk_pizza_get_type (void); -GtkWidget* gtk_pizza_new (void); - -void gtk_pizza_set_shadow_type (GtkPizza *pizza, - GtkMyShadowType type); - -void gtk_pizza_set_clear (GtkPizza *pizza, - gboolean clear); - -void gtk_pizza_set_filter (GtkPizza *pizza, - gboolean use); - -void gtk_pizza_set_external (GtkPizza *pizza, - gboolean expose); - -void gtk_pizza_scroll (GtkPizza *pizza, - gint dx, - gint dy); - -gint gtk_pizza_child_resized (GtkPizza *pizza, - GtkWidget *widget); - -void gtk_pizza_put (GtkPizza *pizza, - GtkWidget *widget, - gint x, - gint y, - gint width, - gint height); - -void gtk_pizza_move (GtkPizza *pizza, - GtkWidget *widget, - gint x, - gint y ); - -void gtk_pizza_resize (GtkPizza *pizza, - GtkWidget *widget, - gint width, - gint height ); - -void gtk_pizza_set_size (GtkPizza *pizza, - GtkWidget *widget, - gint x, - gint y, - gint width, - gint height); -#ifdef __cplusplus -} -#endif /* __cplusplus */ - - -#endif /* __GTK_PIZZA_H__ */ diff --git a/include/wx/gtk1/window.h b/include/wx/gtk1/window.h deleted file mode 100644 index 2b0f5890c4..0000000000 --- a/include/wx/gtk1/window.h +++ /dev/null @@ -1,288 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/gtk/window.h -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - - -#ifndef __GTKWINDOWH__ -#define __GTKWINDOWH__ - -//----------------------------------------------------------------------------- -// callback definition for inserting a window (internal) -//----------------------------------------------------------------------------- - -class wxWindowGTK; -typedef void (*wxInsertChildFunction)( wxWindowGTK*, wxWindowGTK* ); - -//----------------------------------------------------------------------------- -// wxWindowGTK -//----------------------------------------------------------------------------- - -class wxWindowGTK : public wxWindowBase -{ -public: - // creating the window - // ------------------- - wxWindowGTK(); - wxWindowGTK(wxWindow *parent, - wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxPanelNameStr); - bool Create(wxWindow *parent, - wxWindowID id, - const wxPoint& pos = wxDefaultPosition, - const wxSize& size = wxDefaultSize, - long style = 0, - const wxString& name = wxPanelNameStr); - virtual ~wxWindowGTK(); - - // implement base class (pure) virtual methods - // ------------------------------------------- - - virtual bool Destroy(); - - virtual void Raise(); - virtual void Lower(); - - virtual bool Show( bool show = TRUE ); - virtual bool Enable( bool enable = TRUE ); - - virtual bool IsRetained() const; - - virtual void SetFocus(); - virtual bool AcceptsFocus() const; - - virtual bool Reparent( wxWindowBase *newParent ); - - virtual void WarpPointer(int x, int y); - - virtual void Refresh( bool eraseBackground = TRUE, - const wxRect *rect = (const wxRect *) NULL ); - virtual void Update(); - virtual void Clear(); - - virtual bool SetBackgroundColour( const wxColour &colour ); - virtual bool SetForegroundColour( const wxColour &colour ); - virtual bool SetCursor( const wxCursor &cursor ); - virtual bool SetFont( const wxFont &font ); - - virtual int GetCharHeight() const; - virtual int GetCharWidth() const; - virtual void GetTextExtent(const wxString& string, - int *x, int *y, - int *descent = (int *) NULL, - int *externalLeading = (int *) NULL, - const wxFont *theFont = (const wxFont *) NULL) - const; - -#if wxUSE_MENUS_NATIVE - virtual bool DoPopupMenu( wxMenu *menu, int x, int y ); -#endif // wxUSE_MENUS_NATIVE - - virtual void SetScrollbar( int orient, int pos, int thumbVisible, - int range, bool refresh = TRUE ); - virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE ); - virtual int GetScrollPos( int orient ) const; - virtual int GetScrollThumb( int orient ) const; - virtual int GetScrollRange( int orient ) const; - virtual void ScrollWindow( int dx, int dy, - const wxRect* rect = (wxRect *) NULL ); - -#if wxUSE_DRAG_AND_DROP - virtual void SetDropTarget( wxDropTarget *dropTarget ); -#endif // wxUSE_DRAG_AND_DROP - - // implementation - // -------------- - - virtual WXWidget GetHandle() const { return m_widget; } - - // I don't want users to override what's done in idle so everything that - // has to be done in idle time in order for wxGTK to work is done in - // OnInternalIdle - virtual void OnInternalIdle(); - - // Internal represention of Update() - void GtkUpdate(); - - // For delayed background - void GtkSetBackgroundColour( const wxColour &colour ); - void GtkSetForegroundColour( const wxColour &colour ); - - // For compatibility across platforms (not in event table) - void OnIdle(wxIdleEvent& WXUNUSED(event)) {} - - // wxGTK-specific: called recursively by Enable, - // to give widgets an oppprtunity to correct their colours after they - // have been changed by Enable - virtual void OnParentEnable( bool WXUNUSED(enable) ) {} - - // Used by all window classes in the widget creation process. - bool PreCreation( wxWindowGTK *parent, const wxPoint &pos, const wxSize &size ); - void PostCreation(); - - // Internal addition of child windows. differs from class - // to class not by using virtual functions but by using - // the m_insertCallback. - void DoAddChild(wxWindowGTK *child); - - // This methods sends wxPaintEvents to the window. It reads the - // update region, breaks it up into rects and sends an event - // for each rect. It is also responsible for background erase - // events and NC paint events. It is called from "draw" and - // "expose" handlers as well as from ::Update() - void GtkSendPaintEvents(); - - // The methods below are required because many native widgets - // are composed of several subwidgets and setting a style for - // the widget means setting it for all subwidgets as well. - // also, it is nor clear, which native widget is the top - // widget where (most of) the input goes. even tooltips have - // to be applied to all subwidgets. - virtual GtkWidget* GetConnectWidget(); - virtual bool IsOwnGtkWindow( GdkWindow *window ); - void ConnectWidget( GtkWidget *widget ); - - // Creates a new widget style if none is there - // and sets m_widgetStyle to this value. - GtkStyle *GetWidgetStyle(); - -#ifdef __WXGTK20__ - // Returns the default context which usually is anti-aliased - PangoContext *GtkGetPangoDefaultContext(); - - // Returns the X11 context which renders on the X11 client - // side (which can be remote) and which usually is not - // anti-aliased and is thus faster - // MR: Deprecated and returning GtkGetPangoDefaultContext to avoid libpangox dependancy - PangoContext *GtkGetPangoX11Context(); - PangoContext *m_x11Context; -#endif - - // Called by SetFont() and SetXXXColour etc - void SetWidgetStyle(); - - // Overridden in many GTK widgets who have to handle subwidgets - virtual void ApplyWidgetStyle(); - -#if wxUSE_TOOLTIPS - virtual void ApplyToolTip( GtkTooltips *tips, const wxChar *tip ); -#endif // wxUSE_TOOLTIPS - - // Called from GTK signales handlers. it indicates that - // the layouting functions have to be called later on - // (i.e. in idle time, implemented in OnInternalIdle() ). - void GtkUpdateSize() { m_sizeSet = FALSE; } - - // fix up the mouse event coords, used by wxListBox only so far - virtual void FixUpMouseEvent(GtkWidget * WXUNUSED(widget), - wxCoord& WXUNUSED(x), - wxCoord& WXUNUSED(y)) { } - - // is this window transparent for the mouse events (as wxStaticBox is)? - virtual bool IsTransparentForMouse() const { return FALSE; } - - // is this a radiobutton (used by radiobutton code itself only)? - virtual bool IsRadioButton() const { return FALSE; } - - // position and size of the window - int m_x, m_y; - int m_width, m_height; - int m_oldClientWidth,m_oldClientHeight; - - // see the docs in src/gtk/window.cpp - GtkWidget *m_widget; // mostly the widget seen by the rest of GTK - GtkWidget *m_wxwindow; // mostly the client area as per wxWindows - - // this widget will be queried for GTK's focus events - GtkWidget *m_focusWidget; - -#ifdef __WXGTK20__ - GtkIMMulticontext *m_imContext; -#else -#if HAVE_XIM - // XIM support for wxWindows - GdkIC *m_ic; - GdkICAttr *m_icattr; -#endif -#endif - -#ifndef __WXGTK20__ - // The area to be cleared (and not just refreshed) - // We cannot make this distinction under GTK 2.0. - wxRegion m_clearRegion; -#endif - - // scrolling stuff - GtkAdjustment *m_hAdjust,*m_vAdjust; - float m_oldHorizontalPos; - float m_oldVerticalPos; - - // extra (wxGTK-specific) flags - bool m_needParent:1; // ! wxFrame, wxDialog, wxNotebookPage ? - bool m_noExpose:1; // wxGLCanvas has its own redrawing - bool m_nativeSizeEvent:1; // wxGLCanvas sends wxSizeEvent upon "alloc_size" - bool m_hasScrolling:1; - bool m_hasVMT:1; - bool m_sizeSet:1; - bool m_resizing:1; - bool m_acceptsFocus:1; // true if not static - bool m_hasFocus:1; // true if == FindFocus() - bool m_isScrolling:1; // dragging scrollbar thumb? - bool m_clipPaintRegion:1; // TRUE after ScrollWindow() - bool m_queuedFullRedraw:1; // TRUE after DoMoveWindow - - // These are true if the style were set before the widget was realized - // (typcally in the constructor) but the actual GTK style must not be set - // before the widget has been "realized" - bool m_delayedForegroundColour:1; - bool m_delayedBackgroundColour:1; - - // Contains GTK's widgets internal information about non-default widget - // font and colours. we create one for each widget that gets any - // non-default attribute set via SetFont() or SetForegroundColour() / - // SetBackgroundColour(). - GtkStyle *m_widgetStyle; - - // C++ has no virtual methods in the constrcutor of any class but we need - // different methods of inserting a child window into a wxFrame, - // wxMDIFrame, wxNotebook etc. this is the callback that will get used. - wxInsertChildFunction m_insertCallback; - - // implement the base class pure virtuals - virtual void DoClientToScreen( int *x, int *y ) const; - virtual void DoScreenToClient( int *x, int *y ) const; - virtual void DoGetPosition( int *x, int *y ) const; - virtual void DoGetSize( int *width, int *height ) const; - virtual void DoGetClientSize( int *width, int *height ) const; - virtual void DoSetSize(int x, int y, - int width, int height, - int sizeFlags = wxSIZE_AUTO); - virtual void DoSetClientSize(int width, int height); - virtual void DoMoveWindow(int x, int y, int width, int height); - - virtual void DoCaptureMouse(); - virtual void DoReleaseMouse(); - -#if wxUSE_TOOLTIPS - virtual void DoSetToolTip( wxToolTip *tip ); -#endif // wxUSE_TOOLTIPS - -protected: - // common part of all ctors (not virtual because called from ctor) - void Init(); - -private: - DECLARE_DYNAMIC_CLASS(wxWindowGTK) - DECLARE_NO_COPY_CLASS(wxWindowGTK) -}; - -extern wxWindow *wxFindFocusedChild(wxWindowGTK *win); - -#endif // __GTKWINDOWH__ diff --git a/src/gtk1/.cvsignore b/src/gtk1/.cvsignore deleted file mode 100644 index 05bd4624c9..0000000000 --- a/src/gtk1/.cvsignore +++ /dev/null @@ -1,3 +0,0 @@ -Makefile.in -*.lo -*.la diff --git a/src/gtk1/app.cpp b/src/gtk1/app.cpp deleted file mode 100644 index 74febcb63d..0000000000 --- a/src/gtk1/app.cpp +++ /dev/null @@ -1,963 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: app.cpp -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling, Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifdef __VMS -#include -#endif - -#include "wx/app.h" -#include "wx/gdicmn.h" -#include "wx/utils.h" -#include "wx/intl.h" -#include "wx/log.h" -#include "wx/memory.h" -#include "wx/font.h" -#include "wx/settings.h" -#include "wx/dialog.h" -#include "wx/msgdlg.h" -#include "wx/file.h" -#include "wx/filename.h" - -#if wxUSE_WX_RESOURCES - #include "wx/resource.h" -#endif - -#include "wx/module.h" -#include "wx/image.h" - -#ifdef __WXUNIVERSAL__ - #include "wx/univ/theme.h" - #include "wx/univ/renderer.h" -#endif - -#if wxUSE_THREADS - #include "wx/thread.h" -#endif - -#include - -#ifdef HAVE_POLL - #if defined(__VMS) - #include - #else - // bug in the OpenBSD headers: at least in 3.1 there is no extern "C" - // in neither poll.h nor sys/poll.h which results in link errors later - #ifdef __OPENBSD__ - extern "C" - { - #endif - - #include - - #ifdef __OPENBSD__ - }; - #endif - #endif // platform -#else // !HAVE_POLL - // we implement poll() ourselves using select() which is supposed exist in - // all modern Unices - #include - #include - #include -#endif // HAVE_POLL/!HAVE_POLL - -#include "wx/gtk/win_gtk.h" - -#include - - -//----------------------------------------------------------------------------- -// global data -//----------------------------------------------------------------------------- - -wxApp *wxTheApp = (wxApp *) NULL; -wxAppInitializerFunction wxAppBase::m_appInitFn = (wxAppInitializerFunction) NULL; - -bool g_mainThreadLocked = FALSE; -gint g_pendingTag = 0; - -static GtkWidget *gs_RootWindow = (GtkWidget*) NULL; - -//----------------------------------------------------------------------------- -// idle system -//----------------------------------------------------------------------------- - -extern bool g_isIdle; - -void wxapp_install_idle_handler(); - -//----------------------------------------------------------------------------- -// wxExit -//----------------------------------------------------------------------------- - -void wxExit() -{ - gtk_main_quit(); -} - -//----------------------------------------------------------------------------- -// wxYield -//----------------------------------------------------------------------------- - -// not static because used by textctrl.cpp -// -// MT-FIXME -bool wxIsInsideYield = FALSE; - -bool wxApp::Yield(bool onlyIfNeeded) -{ - if ( wxIsInsideYield ) - { - if ( !onlyIfNeeded ) - { - wxFAIL_MSG( wxT("wxYield called recursively" ) ); - } - - return FALSE; - } - -#if wxUSE_THREADS - if ( !wxThread::IsMain() ) - { - // can't call gtk_main_iteration() from other threads like this - return TRUE; - } -#endif // wxUSE_THREADS - - wxIsInsideYield = TRUE; - - if (!g_isIdle) - { - // We need to remove idle callbacks or the loop will - // never finish. - gtk_idle_remove( m_idleTag ); - m_idleTag = 0; - g_isIdle = TRUE; - } - - // disable log flushing from here because a call to wxYield() shouldn't - // normally result in message boxes popping up &c - wxLog::Suspend(); - - while (gtk_events_pending()) - gtk_main_iteration(); - - // It's necessary to call ProcessIdle() to update the frames sizes which - // might have been changed (it also will update other things set from - // OnUpdateUI() which is a nice (and desired) side effect). But we - // call ProcessIdle() only once since this is not meant for longish - // background jobs (controlled by wxIdleEvent::RequestMore() and the - // return value of Processidle(). - ProcessIdle(); - - // let the logs be flashed again - wxLog::Resume(); - - wxIsInsideYield = FALSE; - - return TRUE; -} - -//----------------------------------------------------------------------------- -// wxWakeUpIdle -//----------------------------------------------------------------------------- - -static bool gs_WakeUpIdle = false; - -void wxWakeUpIdle() -{ -#if wxUSE_THREADS - if (!wxThread::IsMain()) - wxMutexGuiEnter(); -#endif - - if (g_isIdle) { - gs_WakeUpIdle = true; - wxapp_install_idle_handler(); - gs_WakeUpIdle = false; - } - -#if wxUSE_THREADS - if (!wxThread::IsMain()) - wxMutexGuiLeave(); -#endif -} - -//----------------------------------------------------------------------------- -// local functions -//----------------------------------------------------------------------------- - -// the callback functions must be extern "C" to comply with GTK+ declarations -extern "C" -{ - -static gint wxapp_pending_callback( gpointer WXUNUSED(data) ) -{ - if (!wxTheApp) return TRUE; - - // When getting called from GDK's time-out handler - // we are no longer within GDK's grab on the GUI - // thread so we must lock it here ourselves. - gdk_threads_enter(); - - // Sent idle event to all who request them. - wxTheApp->ProcessPendingEvents(); - - g_pendingTag = 0; - - // Flush the logged messages if any. -#if wxUSE_LOG - wxLog::FlushActive(); -#endif // wxUSE_LOG - - // Release lock again - gdk_threads_leave(); - - // Return FALSE to indicate that no more idle events are - // to be sent (single shot instead of continuous stream) - return FALSE; -} - -static gint wxapp_idle_callback( gpointer WXUNUSED(data) ) -{ - if (!wxTheApp) - return TRUE; - -#ifdef __WXDEBUG__ - // don't generate the idle events while the assert modal dialog is shown, - // this completely confuses the apps which don't expect to be reentered - // from some safely-looking functions - if ( wxTheApp->IsInAssert() ) - { - // But repaint the assertion message if necessary - if (wxTopLevelWindows.GetCount() > 0) - { - wxWindow* win = (wxWindow*) wxTopLevelWindows.Last()->Data(); - if (win->IsKindOf(CLASSINFO(wxGenericMessageDialog))) - win->OnInternalIdle(); - } - return TRUE; - } -#endif // __WXDEBUG__ - - // When getting called from GDK's time-out handler - // we are no longer within GDK's grab on the GUI - // thread so we must lock it here ourselves. - gdk_threads_enter(); - - // Indicate that we are now in idle mode and event handlers - // will have to reinstall the idle handler again. - g_isIdle = TRUE; - wxTheApp->m_idleTag = 0; - - // Send idle event to all who request them as long as - // no events have popped up in the event queue. - while (wxTheApp->ProcessIdle() && (gtk_events_pending() == 0)) - ; - - // Release lock again - gdk_threads_leave(); - - // Return FALSE to indicate that no more idle events are - // to be sent (single shot instead of continuous stream). - return FALSE; -} - -#if wxUSE_THREADS - -#ifdef HAVE_POLL - #define wxPoll poll - #define wxPollFd pollfd -#else // !HAVE_POLL - -typedef GPollFD wxPollFd; - -int wxPoll(wxPollFd *ufds, unsigned int nfds, int timeout) -{ - // convert timeout from ms to struct timeval (s/us) - timeval tv_timeout; - tv_timeout.tv_sec = timeout/1000; - tv_timeout.tv_usec = (timeout%1000)*1000; - - // remember the highest fd used here - int fdMax = -1; - - // and fill the sets for select() - fd_set readfds; - fd_set writefds; - fd_set exceptfds; - FD_ZERO(&readfds); - FD_ZERO(&writefds); - FD_ZERO(&exceptfds); - - unsigned int i; - for ( i = 0; i < nfds; i++ ) - { - wxASSERT_MSG( ufds[i].fd < FD_SETSIZE, _T("fd out of range") ); - - if ( ufds[i].events & G_IO_IN ) - FD_SET(ufds[i].fd, &readfds); - - if ( ufds[i].events & G_IO_PRI ) - FD_SET(ufds[i].fd, &exceptfds); - - if ( ufds[i].events & G_IO_OUT ) - FD_SET(ufds[i].fd, &writefds); - - if ( ufds[i].fd > fdMax ) - fdMax = ufds[i].fd; - } - - fdMax++; - int res = select(fdMax, &readfds, &writefds, &exceptfds, &tv_timeout); - - // translate the results back - for ( i = 0; i < nfds; i++ ) - { - ufds[i].revents = 0; - - if ( FD_ISSET(ufds[i].fd, &readfds ) ) - ufds[i].revents |= G_IO_IN; - - if ( FD_ISSET(ufds[i].fd, &exceptfds ) ) - ufds[i].revents |= G_IO_PRI; - - if ( FD_ISSET(ufds[i].fd, &writefds ) ) - ufds[i].revents |= G_IO_OUT; - } - - return res; -} - -#endif // HAVE_POLL/!HAVE_POLL - -static gint wxapp_poll_func( GPollFD *ufds, guint nfds, gint timeout ) -{ - gdk_threads_enter(); - - wxMutexGuiLeave(); - g_mainThreadLocked = TRUE; - - // we rely on the fact that glib GPollFD struct is really just pollfd but - // I wonder how wise is this in the long term (VZ) - gint res = wxPoll( (wxPollFd *) ufds, nfds, timeout ); - - wxMutexGuiEnter(); - g_mainThreadLocked = FALSE; - - gdk_threads_leave(); - - return res; -} - -#endif // wxUSE_THREADS - -} // extern "C" - -void wxapp_install_idle_handler() -{ - // GD: this assert is raised when using the thread sample (which works) - // so the test is probably not so easy. Can widget callbacks be - // triggered from child threads and, if so, for which widgets? - // wxASSERT_MSG( wxThread::IsMain() || gs_WakeUpIdle, wxT("attempt to install idle handler from widget callback in child thread (should be exclusively from wxWakeUpIdle)") ); - - wxASSERT_MSG( wxTheApp->m_idleTag == 0, wxT("attempt to install idle handler twice") ); - - g_isIdle = FALSE; - - if (g_pendingTag == 0) - g_pendingTag = gtk_idle_add_priority( 900, wxapp_pending_callback, (gpointer) NULL ); - - // This routine gets called by all event handlers - // indicating that the idle is over. It may also - // get called from other thread for sending events - // to the main thread (and processing these in - // idle time). Very low priority. - wxTheApp->m_idleTag = gtk_idle_add_priority( 1000, wxapp_idle_callback, (gpointer) NULL ); -} - -//----------------------------------------------------------------------------- -// Access to the root window global -//----------------------------------------------------------------------------- - -GtkWidget* wxGetRootWindow() -{ - if (gs_RootWindow == NULL) - { - gs_RootWindow = gtk_window_new( GTK_WINDOW_TOPLEVEL ); - gtk_widget_realize( gs_RootWindow ); - } - return gs_RootWindow; -} - -//----------------------------------------------------------------------------- -// wxApp -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxApp,wxEvtHandler) - -BEGIN_EVENT_TABLE(wxApp, wxEvtHandler) - EVT_IDLE(wxApp::OnIdle) -END_EVENT_TABLE() - -wxApp::wxApp() -{ - m_initialized = FALSE; -#ifdef __WXDEBUG__ - m_isInAssert = FALSE; -#endif // __WXDEBUG__ - - m_idleTag = 0; - wxapp_install_idle_handler(); - -#if wxUSE_THREADS - g_main_set_poll_func( wxapp_poll_func ); -#endif - - m_colorCube = (unsigned char*) NULL; - - // this is NULL for a "regular" wxApp, but is set (and freed) by a wxGLApp - m_glVisualInfo = (void *) NULL; -} - -wxApp::~wxApp() -{ - if (m_idleTag) gtk_idle_remove( m_idleTag ); - - if (m_colorCube) free(m_colorCube); -} - -bool wxApp::OnInitGui() -{ - if ( !wxAppBase::OnInitGui() ) - return FALSE; - - GdkVisual *visual = gdk_visual_get_system(); - - // if this is a wxGLApp (derived from wxApp), and we've already - // chosen a specific visual, then derive the GdkVisual from that - if (m_glVisualInfo != NULL) - { -#ifdef __WXGTK20__ - // seems gtk_widget_set_default_visual no longer exists? - GdkVisual* vis = gtk_widget_get_default_visual(); -#else - GdkVisual* vis = gdkx_visual_get( - ((XVisualInfo *) m_glVisualInfo) ->visualid ); - gtk_widget_set_default_visual( vis ); -#endif - - GdkColormap *colormap = gdk_colormap_new( vis, FALSE ); - gtk_widget_set_default_colormap( colormap ); - - visual = vis; - } - - // On some machines, the default visual is just 256 colours, so - // we make sure we get the best. This can sometimes be wasteful. - - else - if ((gdk_visual_get_best() != gdk_visual_get_system()) && (m_useBestVisual)) - { -#ifdef __WXGTK20__ - /* seems gtk_widget_set_default_visual no longer exists? */ - GdkVisual* vis = gtk_widget_get_default_visual(); -#else - GdkVisual* vis = gdk_visual_get_best(); - gtk_widget_set_default_visual( vis ); -#endif - - GdkColormap *colormap = gdk_colormap_new( vis, FALSE ); - gtk_widget_set_default_colormap( colormap ); - - visual = vis; - } - - // Nothing to do for 15, 16, 24, 32 bit displays - if (visual->depth > 8) return TRUE; - - // initialize color cube for 8-bit color reduction dithering - - GdkColormap *cmap = gtk_widget_get_default_colormap(); - - m_colorCube = (unsigned char*)malloc(32 * 32 * 32); - - for (int r = 0; r < 32; r++) - { - for (int g = 0; g < 32; g++) - { - for (int b = 0; b < 32; b++) - { - int rr = (r << 3) | (r >> 2); - int gg = (g << 3) | (g >> 2); - int bb = (b << 3) | (b >> 2); - - int index = -1; - - GdkColor *colors = cmap->colors; - if (colors) - { - int max = 3 * 65536; - - for (int i = 0; i < cmap->size; i++) - { - int rdiff = ((rr << 8) - colors[i].red); - int gdiff = ((gg << 8) - colors[i].green); - int bdiff = ((bb << 8) - colors[i].blue); - int sum = ABS (rdiff) + ABS (gdiff) + ABS (bdiff); - if (sum < max) - { - index = i; max = sum; - } - } - } - else - { - // assume 8-bit true or static colors. this really exists - GdkVisual* vis = gdk_colormap_get_visual( cmap ); - index = (r >> (5 - vis->red_prec)) << vis->red_shift; - index |= (g >> (5 - vis->green_prec)) << vis->green_shift; - index |= (b >> (5 - vis->blue_prec)) << vis->blue_shift; - } - m_colorCube[ (r*1024) + (g*32) + b ] = index; - } - } - } - - return TRUE; -} - -GdkVisual *wxApp::GetGdkVisual() -{ - GdkVisual *visual = NULL; - - if (m_glVisualInfo) - visual = gdkx_visual_get( ((XVisualInfo *) m_glVisualInfo)->visualid ); - else - visual = gdk_window_get_visual( wxGetRootWindow()->window ); - - wxASSERT( visual ); - - return visual; -} - -bool wxApp::ProcessIdle() -{ - wxWindowList::Node* node = wxTopLevelWindows.GetFirst(); - node = wxTopLevelWindows.GetFirst(); - while (node) - { - wxWindow* win = node->GetData(); - CallInternalIdle( win ); - - node = node->GetNext(); - } - - wxIdleEvent event; - event.SetEventObject( this ); - ProcessEvent( event ); - - return event.MoreRequested(); -} - -void wxApp::OnIdle( wxIdleEvent &event ) -{ - static bool s_inOnIdle = FALSE; - - // Avoid recursion (via ProcessEvent default case) - if (s_inOnIdle) - return; - - s_inOnIdle = TRUE; - - // Resend in the main thread events which have been prepared in other - // threads - ProcessPendingEvents(); - - // 'Garbage' collection of windows deleted with Close() - DeletePendingObjects(); - - // Send OnIdle events to all windows - bool needMore = SendIdleEvents(); - - if (needMore) - event.RequestMore(TRUE); - - s_inOnIdle = FALSE; -} - -bool wxApp::SendIdleEvents() -{ - bool needMore = FALSE; - - wxWindowList::Node* node = wxTopLevelWindows.GetFirst(); - while (node) - { - wxWindow* win = node->GetData(); - if (SendIdleEvents(win)) - needMore = TRUE; - - node = node->GetNext(); - } - - return needMore; -} - -bool wxApp::CallInternalIdle( wxWindow* win ) -{ - win->OnInternalIdle(); - - wxNode* node = win->GetChildren().First(); - while (node) - { - wxWindow* win = (wxWindow*) node->Data(); - CallInternalIdle( win ); - - node = node->Next(); - } - - return TRUE; -} - -bool wxApp::SendIdleEvents( wxWindow* win ) -{ - bool needMore = FALSE; - - wxIdleEvent event; - event.SetEventObject(win); - - win->GetEventHandler()->ProcessEvent(event); - - if (event.MoreRequested()) - needMore = TRUE; - - wxNode* node = win->GetChildren().First(); - while (node) - { - wxWindow* win = (wxWindow*) node->Data(); - if (SendIdleEvents(win)) - needMore = TRUE; - - node = node->Next(); - } - - return needMore; -} - -int wxApp::MainLoop() -{ - gtk_main(); - return 0; -} - -void wxApp::ExitMainLoop() -{ - if (gtk_main_level() > 0) - gtk_main_quit(); -} - -bool wxApp::Initialized() -{ - return m_initialized; -} - -bool wxApp::Pending() -{ - return (gtk_events_pending() > 0); -} - -void wxApp::Dispatch() -{ - gtk_main_iteration(); -} - -void wxApp::DeletePendingObjects() -{ - wxNode *node = wxPendingDelete.First(); - while (node) - { - wxObject *obj = (wxObject *)node->Data(); - - delete obj; - - if (wxPendingDelete.Find(obj)) - delete node; - - node = wxPendingDelete.First(); - } -} - -bool wxApp::Initialize() -{ - wxClassInfo::InitializeClasses(); - - // GL: I'm annoyed ... I don't know where to put this and I don't want to - // create a module for that as it's part of the core. -#if wxUSE_THREADS - wxPendingEvents = new wxList(); - wxPendingEventsLocker = new wxCriticalSection(); -#endif - - wxTheColourDatabase = new wxColourDatabase( wxKEY_STRING ); - wxTheColourDatabase->Initialize(); - - wxInitializeStockLists(); - wxInitializeStockObjects(); - -#if wxUSE_WX_RESOURCES - wxInitializeResourceSystem(); -#endif - - wxModule::RegisterModules(); - if (!wxModule::InitializeModules()) - return FALSE; - -#if wxUSE_INTL - wxFont::SetDefaultEncoding(wxLocale::GetSystemEncoding()); -#endif - - return TRUE; -} - -void wxApp::CleanUp() -{ - wxModule::CleanUpModules(); - -#if wxUSE_WX_RESOURCES - wxCleanUpResourceSystem(); -#endif - - delete wxTheColourDatabase; - wxTheColourDatabase = (wxColourDatabase*) NULL; - - wxDeleteStockObjects(); - - wxDeleteStockLists(); - - delete wxTheApp; - wxTheApp = (wxApp*) NULL; - - wxClassInfo::CleanUpClasses(); - -#if wxUSE_THREADS - delete wxPendingEvents; - delete wxPendingEventsLocker; -#endif - - // check for memory leaks -#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT - if (wxDebugContext::CountObjectsLeft(TRUE) > 0) - { - wxLogDebug(wxT("There were memory leaks.\n")); - wxDebugContext::Dump(); - wxDebugContext::PrintStatistics(); - } -#endif // Debug - -#if wxUSE_LOG - // do this as the very last thing because everything else can log messages - wxLog::DontCreateOnDemand(); - - wxLog *oldLog = wxLog::SetActiveTarget( (wxLog*) NULL ); - if (oldLog) - delete oldLog; -#endif // wxUSE_LOG -} - -//----------------------------------------------------------------------------- -// wxEntry -//----------------------------------------------------------------------------- - -// NB: argc and argv may be changed here, pass by reference! -int wxEntryStart( int& argc, char *argv[] ) -{ -#if wxUSE_THREADS - // GTK 1.2 up to version 1.2.3 has broken threads - if ((gtk_major_version == 1) && - (gtk_minor_version == 2) && - (gtk_micro_version < 4)) - { - printf( "wxWindows warning: GUI threading disabled due to outdated GTK version\n" ); - } - else - { - if (!g_thread_supported()) - g_thread_init(NULL); - } -#endif - - gtk_set_locale(); - - // We should have the wxUSE_WCHAR_T test on the _outside_ -#if wxUSE_WCHAR_T -#if defined(__WXGTK20__) - // gtk+ 2.0 supports Unicode through UTF-8 strings - wxConvCurrent = &wxConvUTF8; -#else - if (!wxOKlibc()) wxConvCurrent = &wxConvLocal; -#endif -#else - if (!wxOKlibc()) wxConvCurrent = (wxMBConv*) NULL; -#endif - - gtk_init( &argc, &argv ); - - /* we can not enter threads before gtk_init is done */ - gdk_threads_enter(); - - wxSetDetectableAutoRepeat( TRUE ); - - if (!wxApp::Initialize()) - { - gdk_threads_leave(); - return -1; - } - - return 0; -} - - -int wxEntryInitGui() -{ - int retValue = 0; - - if ( !wxTheApp->OnInitGui() ) - retValue = -1; - - wxGetRootWindow(); - - return retValue; -} - - -void wxEntryCleanup() -{ -#if wxUSE_LOG - // flush the logged messages if any - wxLog *log = wxLog::GetActiveTarget(); - if (log != NULL && log->HasPendingMessages()) - log->Flush(); - - // continuing to use user defined log target is unsafe from now on because - // some resources may be already unavailable, so replace it by something - // more safe - wxLog *oldlog = wxLog::SetActiveTarget(new wxLogStderr); - if ( oldlog ) - delete oldlog; -#endif // wxUSE_LOG - - wxApp::CleanUp(); - - gdk_threads_leave(); -} - - -int wxEntry( int argc, char *argv[] ) -{ -#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT - // This seems to be necessary since there are 'rogue' - // objects present at this point (perhaps global objects?) - // Setting a checkpoint will ignore them as far as the - // memory checking facility is concerned. - // Of course you may argue that memory allocated in globals should be - // checked, but this is a reasonable compromise. - wxDebugContext::SetCheckpoint(); -#endif - int err = wxEntryStart(argc, argv); - if (err) - return err; - - if (!wxTheApp) - { - wxCHECK_MSG( wxApp::GetInitializerFunction(), -1, - wxT("wxWindows error: No initializer - use IMPLEMENT_APP macro.\n") ); - - wxAppInitializerFunction app_ini = wxApp::GetInitializerFunction(); - - wxObject *test_app = app_ini(); - - wxTheApp = (wxApp*) test_app; - } - - wxCHECK_MSG( wxTheApp, -1, wxT("wxWindows error: no application object") ); - - wxTheApp->argc = argc; -#if wxUSE_UNICODE - wxTheApp->argv = new wxChar*[argc+1]; - int mb_argc = 0; - while (mb_argc < argc) - { - wxTheApp->argv[mb_argc] = wxStrdup(wxConvLibc.cMB2WX(argv[mb_argc])); - mb_argc++; - } - wxTheApp->argv[mb_argc] = (wxChar *)NULL; -#else - wxTheApp->argv = argv; -#endif - - if (wxTheApp->argc > 0) - { - wxFileName fname( wxTheApp->argv[0] ); - wxTheApp->SetAppName( fname.GetName() ); - } - - int retValue; - retValue = wxEntryInitGui(); - - // Here frames insert themselves automatically into wxTopLevelWindows by - // getting created in OnInit(). - if ( retValue == 0 ) - { - if ( !wxTheApp->OnInit() ) - retValue = -1; - } - - if ( retValue == 0 ) - { - // Delete pending toplevel windows - wxTheApp->DeletePendingObjects(); - - // When is the app not initialized ? - wxTheApp->m_initialized = TRUE; - - if (wxTheApp->Initialized()) - { - wxTheApp->OnRun(); - - wxWindow *topWindow = wxTheApp->GetTopWindow(); - - // Delete all pending windows if any - wxTheApp->DeletePendingObjects(); - - // Reset top window - if (topWindow) - wxTheApp->SetTopWindow( (wxWindow*) NULL ); - - retValue = wxTheApp->OnExit(); - } - } - - wxEntryCleanup(); - - return retValue; -} - -#ifdef __WXDEBUG__ - -void wxApp::OnAssert(const wxChar *file, int line, const wxChar* cond, const wxChar *msg) -{ - m_isInAssert = TRUE; - - wxAppBase::OnAssert(file, line, cond, msg); - - m_isInAssert = FALSE; -} - -#endif // __WXDEBUG__ - diff --git a/src/gtk1/bdiag.xbm b/src/gtk1/bdiag.xbm deleted file mode 100644 index 9ff0a1822f..0000000000 --- a/src/gtk1/bdiag.xbm +++ /dev/null @@ -1,6 +0,0 @@ -#define bdiag_width 16 -#define bdiag_height 16 -static char bdiag_bits[] = { - 0x80, 0x80, 0x40, 0x40, 0x20, 0x20, 0x10, 0x10, 0x08, 0x08, 0x04, 0x04, - 0x02, 0x02, 0x01, 0x01, 0x80, 0x80, 0x40, 0x40, 0x20, 0x20, 0x10, 0x10, - 0x08, 0x08, 0x04, 0x04, 0x02, 0x02, 0x01, 0x01}; diff --git a/src/gtk1/bitmap.cpp b/src/gtk1/bitmap.cpp deleted file mode 100644 index e73920e51b..0000000000 --- a/src/gtk1/bitmap.cpp +++ /dev/null @@ -1,1278 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: bitmap.cpp -// Purpose: -// Author: Robert Roebling -// RCS-ID: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/defs.h" - -#include "wx/palette.h" -#include "wx/bitmap.h" -#include "wx/icon.h" -#include "wx/filefn.h" -#include "wx/image.h" -#include "wx/dcmemory.h" -#include "wx/app.h" - -#ifdef __WXGTK20__ - // need this to get gdk_image_new_bitmap() - #define GDK_ENABLE_BROKEN -#endif - -#include -#include -#include - -#ifdef __WXGTK20__ - #include -#else // GTK+ 1.2 - #include -#endif // GTK+ 2.0/1.2 - -#include - -//----------------------------------------------------------------------------- -// 1-bit blitting implemented in dcclient.cpp -//----------------------------------------------------------------------------- - -extern void gdk_wx_draw_bitmap (GdkDrawable *drawable, - GdkGC *gc, - GdkDrawable *src, - gint xsrc, - gint ysrc, - gint xdest, - gint ydest, - gint width, - gint height); - -//----------------------------------------------------------------------------- -// data -//----------------------------------------------------------------------------- - -extern GtkWidget *wxGetRootWindow(); - -//----------------------------------------------------------------------------- -// wxMask -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxMask,wxObject) - -wxMask::wxMask() -{ - m_bitmap = (GdkBitmap *) NULL; -} - -wxMask::wxMask( const wxBitmap& bitmap, const wxColour& colour ) -{ - m_bitmap = (GdkBitmap *) NULL; - Create( bitmap, colour ); -} - -wxMask::wxMask( const wxBitmap& bitmap, int paletteIndex ) -{ - m_bitmap = (GdkBitmap *) NULL; - Create( bitmap, paletteIndex ); -} - -wxMask::wxMask( const wxBitmap& bitmap ) -{ - m_bitmap = (GdkBitmap *) NULL; - Create( bitmap ); -} - -wxMask::~wxMask() -{ - if (m_bitmap) - gdk_bitmap_unref( m_bitmap ); -} - -bool wxMask::Create( const wxBitmap& bitmap, - const wxColour& colour ) -{ - if (m_bitmap) - { - gdk_bitmap_unref( m_bitmap ); - m_bitmap = (GdkBitmap*) NULL; - } - - wxImage image = bitmap.ConvertToImage(); - if (!image.Ok()) return FALSE; - - m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, image.GetWidth(), image.GetHeight(), 1 ); - GdkGC *gc = gdk_gc_new( m_bitmap ); - - GdkColor color; - color.red = 65000; - color.green = 65000; - color.blue = 65000; - color.pixel = 1; - gdk_gc_set_foreground( gc, &color ); - gdk_gc_set_fill( gc, GDK_SOLID ); - gdk_draw_rectangle( m_bitmap, gc, TRUE, 0, 0, image.GetWidth(), image.GetHeight() ); - - unsigned char *data = image.GetData(); - int index = 0; - - unsigned char red = colour.Red(); - unsigned char green = colour.Green(); - unsigned char blue = colour.Blue(); - - GdkVisual *visual = wxTheApp->GetGdkVisual(); - - int bpp = visual->depth; - if ((bpp == 16) && (visual->red_mask != 0xf800)) - bpp = 15; - if (bpp == 15) - { - red = red & 0xf8; - green = green & 0xf8; - blue = blue & 0xf8; - } - else if (bpp == 16) - { - red = red & 0xf8; - green = green & 0xfc; - blue = blue & 0xf8; - } - else if (bpp == 12) - { - red = red & 0xf0; - green = green & 0xf0; - blue = blue & 0xf0; - } - - color.red = 0; - color.green = 0; - color.blue = 0; - color.pixel = 0; - gdk_gc_set_foreground( gc, &color ); - - for (int j = 0; j < image.GetHeight(); j++) - { - int start_x = -1; - int i; - for (i = 0; i < image.GetWidth(); i++) - { - if ((data[index] == red) && - (data[index+1] == green) && - (data[index+2] == blue)) - { - if (start_x == -1) - start_x = i; - } - else - { - if (start_x != -1) - { - gdk_draw_line( m_bitmap, gc, start_x, j, i-1, j ); - start_x = -1; - } - } - index += 3; - } - if (start_x != -1) - gdk_draw_line( m_bitmap, gc, start_x, j, i, j ); - } - - gdk_gc_unref( gc ); - - return TRUE; -} - -bool wxMask::Create( const wxBitmap& bitmap, int paletteIndex ) -{ - unsigned char r,g,b; - wxPalette *pal = bitmap.GetPalette(); - - wxCHECK_MSG( pal, FALSE, wxT("Cannot create mask from bitmap without palette") ); - - pal->GetRGB(paletteIndex, &r, &g, &b); - - return Create(bitmap, wxColour(r, g, b)); -} - -bool wxMask::Create( const wxBitmap& bitmap ) -{ - if (m_bitmap) - { - gdk_bitmap_unref( m_bitmap ); - m_bitmap = (GdkBitmap*) NULL; - } - - if (!bitmap.Ok()) return FALSE; - - wxCHECK_MSG( bitmap.GetBitmap(), FALSE, wxT("Cannot create mask from colour bitmap") ); - - m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, bitmap.GetWidth(), bitmap.GetHeight(), 1 ); - - if (!m_bitmap) return FALSE; - - GdkGC *gc = gdk_gc_new( m_bitmap ); - - gdk_wx_draw_bitmap( m_bitmap, gc, bitmap.GetBitmap(), 0, 0, 0, 0, bitmap.GetWidth(), bitmap.GetHeight() ); - - gdk_gc_unref( gc ); - - return TRUE; -} - -GdkBitmap *wxMask::GetBitmap() const -{ - return m_bitmap; -} - -//----------------------------------------------------------------------------- -// wxBitmap -//----------------------------------------------------------------------------- - -class wxBitmapRefData: public wxObjectRefData -{ -public: - wxBitmapRefData(); - ~wxBitmapRefData(); - - GdkPixmap *m_pixmap; - GdkBitmap *m_bitmap; - wxMask *m_mask; - int m_width; - int m_height; - int m_bpp; - wxPalette *m_palette; -}; - -wxBitmapRefData::wxBitmapRefData() -{ - m_pixmap = (GdkPixmap *) NULL; - m_bitmap = (GdkBitmap *) NULL; - m_mask = (wxMask *) NULL; - m_width = 0; - m_height = 0; - m_bpp = 0; - m_palette = (wxPalette *) NULL; -} - -wxBitmapRefData::~wxBitmapRefData() -{ - if (m_pixmap) gdk_pixmap_unref( m_pixmap ); - if (m_bitmap) gdk_bitmap_unref( m_bitmap ); - if (m_mask) delete m_mask; - if (m_palette) delete m_palette; -} - -//----------------------------------------------------------------------------- - -#define M_BMPDATA ((wxBitmapRefData *)m_refData) - -IMPLEMENT_DYNAMIC_CLASS(wxBitmap,wxGDIObject) - -wxBitmap::wxBitmap() -{ -} - -wxBitmap::wxBitmap( int width, int height, int depth ) -{ - Create( width, height, depth ); -} - -bool wxBitmap::Create( int width, int height, int depth ) -{ - UnRef(); - - wxCHECK_MSG( (width > 0) && (height > 0), FALSE, wxT("invalid bitmap size") ) - - GdkVisual *visual = wxTheApp->GetGdkVisual(); - - if (depth == -1) depth = visual->depth; - - wxCHECK_MSG( (depth == visual->depth) || - (depth == 1), FALSE, wxT("invalid bitmap depth") ) - - m_refData = new wxBitmapRefData(); - M_BMPDATA->m_mask = (wxMask *) NULL; - M_BMPDATA->m_width = width; - M_BMPDATA->m_height = height; - if (depth == 1) - { - M_BMPDATA->m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, width, height, 1 ); - M_BMPDATA->m_bpp = 1; - } - else - { - M_BMPDATA->m_pixmap = gdk_pixmap_new( wxGetRootWindow()->window, width, height, depth ); - M_BMPDATA->m_bpp = visual->depth; - } - - return Ok(); -} - -bool wxBitmap::CreateFromXpm( const char **bits ) -{ - UnRef(); - - wxCHECK_MSG( bits != NULL, FALSE, wxT("invalid bitmap data") ) - - GdkVisual *visual = wxTheApp->GetGdkVisual(); - - m_refData = new wxBitmapRefData(); - - GdkBitmap *mask = (GdkBitmap*) NULL; - - M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm_d( wxGetRootWindow()->window, &mask, NULL, (gchar **) bits ); - - if (!M_BMPDATA->m_pixmap) - { - UnRef(); - - wxFAIL_MSG( wxT("couldn't create pixmap") ); - - return FALSE; - } - - 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 = visual->depth; // Can we get a different depth from create_from_xpm_d() ? - - return TRUE; -} - -bool wxBitmap::CreateFromImage( const wxImage& image, int depth ) -{ - UnRef(); - - wxCHECK_MSG( image.Ok(), FALSE, wxT("invalid image") ) - wxCHECK_MSG( depth == -1 || depth == 1, FALSE, wxT("invalid bitmap depth") ) - - m_refData = new wxBitmapRefData(); - - // ------ - // conversion to mono bitmap: - // ------ - if (depth == 1) - { - int width = image.GetWidth(); - int height = image.GetHeight(); - - SetHeight( height ); - SetWidth( width ); - - SetBitmap( gdk_pixmap_new( wxGetRootWindow()->window, width, height, 1 ) ); - - SetDepth( 1 ); - - GdkVisual *visual = wxTheApp->GetGdkVisual(); - - // Create picture image - - unsigned char *data_data = (unsigned char*)malloc( ((width >> 3)+8) * height ); - - GdkImage *data_image = - gdk_image_new_bitmap( visual, data_data, width, height ); - - // Create mask image - - GdkImage *mask_image = (GdkImage*) NULL; - - if (image.HasMask()) - { - unsigned char *mask_data = (unsigned char*)malloc( ((width >> 3)+8) * height ); - - mask_image = gdk_image_new_bitmap( visual, mask_data, width, height ); - - wxMask *mask = new wxMask(); - mask->m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, width, height, 1 ); - - SetMask( mask ); - } - - int r_mask = image.GetMaskRed(); - int g_mask = image.GetMaskGreen(); - int b_mask = image.GetMaskBlue(); - - unsigned char* data = image.GetData(); - - int index = 0; - for (int y = 0; y < height; y++) - { - for (int x = 0; x < width; x++) - { - int r = data[index]; - index++; - int g = data[index]; - index++; - int b = data[index]; - index++; - - if (image.HasMask()) - { - if ((r == r_mask) && (b == b_mask) && (g == g_mask)) - gdk_image_put_pixel( mask_image, x, y, 1 ); - else - gdk_image_put_pixel( mask_image, x, y, 0 ); - } - - if ((r == 255) && (b == 255) && (g == 255)) - gdk_image_put_pixel( data_image, x, y, 1 ); - else - gdk_image_put_pixel( data_image, x, y, 0 ); - - } // for - } // for - - // Blit picture - - GdkGC *data_gc = gdk_gc_new( GetBitmap() ); - - gdk_draw_image( GetBitmap(), data_gc, data_image, 0, 0, 0, 0, width, height ); - - gdk_image_destroy( data_image ); - gdk_gc_unref( data_gc ); - - // Blit mask - - if (image.HasMask()) - { - GdkGC *mask_gc = gdk_gc_new( GetMask()->GetBitmap() ); - - gdk_draw_image( GetMask()->GetBitmap(), mask_gc, mask_image, 0, 0, 0, 0, width, height ); - - gdk_image_destroy( mask_image ); - gdk_gc_unref( mask_gc ); - } - } - - // ------ - // conversion to colour bitmap: - // ------ - else - { - int width = image.GetWidth(); - int height = image.GetHeight(); - - SetHeight( height ); - SetWidth( width ); - - SetPixmap( gdk_pixmap_new( wxGetRootWindow()->window, width, height, -1 ) ); - - GdkVisual *visual = wxTheApp->GetGdkVisual(); - - int bpp = visual->depth; - - SetDepth( bpp ); - - if ((bpp == 16) && (visual->red_mask != 0xf800)) - bpp = 15; - else if (bpp < 8) - bpp = 8; - - // We handle 8-bit bitmaps ourselves using the colour cube, 12-bit - // visuals are not supported by GDK so we do these ourselves, too. - // 15-bit and 16-bit should actually work and 24-bit certainly does. -#ifdef __sgi - if (!image.HasMask() && (bpp > 16)) -#else - if (!image.HasMask() && (bpp > 12)) -#endif - { - static bool s_hasInitialized = FALSE; - - if (!s_hasInitialized) - { - gdk_rgb_init(); - s_hasInitialized = TRUE; - } - - GdkGC *gc = gdk_gc_new( GetPixmap() ); - - gdk_draw_rgb_image( GetPixmap(), - gc, - 0, 0, - width, height, - GDK_RGB_DITHER_NONE, - image.GetData(), - width*3 ); - - gdk_gc_unref( gc ); - return TRUE; - } - - // Create picture image - - GdkImage *data_image = - gdk_image_new( GDK_IMAGE_FASTEST, visual, width, height ); - - // Create mask image - - GdkImage *mask_image = (GdkImage*) NULL; - - if (image.HasMask()) - { - unsigned char *mask_data = (unsigned char*)malloc( ((width >> 3)+8) * height ); - - mask_image = gdk_image_new_bitmap( visual, mask_data, width, height ); - - wxMask *mask = new wxMask(); - mask->m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, width, height, 1 ); - - SetMask( mask ); - } - - // Render - - enum byte_order { RGB, RBG, BRG, BGR, GRB, GBR }; - byte_order b_o = RGB; - - if (bpp > 8) - { - if ((visual->red_mask > visual->green_mask) && (visual->green_mask > visual->blue_mask)) b_o = RGB; - else if ((visual->red_mask > visual->blue_mask) && (visual->blue_mask > visual->green_mask)) b_o = RBG; - else if ((visual->blue_mask > visual->red_mask) && (visual->red_mask > visual->green_mask)) b_o = BRG; - else if ((visual->blue_mask > visual->green_mask) && (visual->green_mask > visual->red_mask)) b_o = BGR; - else if ((visual->green_mask > visual->red_mask) && (visual->red_mask > visual->blue_mask)) b_o = GRB; - else if ((visual->green_mask > visual->blue_mask) && (visual->blue_mask > visual->red_mask)) b_o = GBR; - } - - int r_mask = image.GetMaskRed(); - int g_mask = image.GetMaskGreen(); - int b_mask = image.GetMaskBlue(); - - unsigned char* data = image.GetData(); - - int index = 0; - for (int y = 0; y < height; y++) - { - for (int x = 0; x < width; x++) - { - int r = data[index]; - index++; - int g = data[index]; - index++; - int b = data[index]; - index++; - - if (image.HasMask()) - { - if ((r == r_mask) && (b == b_mask) && (g == g_mask)) - gdk_image_put_pixel( mask_image, x, y, 1 ); - else - gdk_image_put_pixel( mask_image, x, y, 0 ); - } - - switch (bpp) - { - case 8: - { - int pixel = -1; - if (wxTheApp->m_colorCube) - { - pixel = wxTheApp->m_colorCube[ ((r & 0xf8) << 7) + ((g & 0xf8) << 2) + ((b & 0xf8) >> 3) ]; - } - else - { - GdkColormap *cmap = gtk_widget_get_default_colormap(); - GdkColor *colors = cmap->colors; - int max = 3 * (65536); - - for (int i = 0; i < cmap->size; i++) - { - int rdiff = (r << 8) - colors[i].red; - int gdiff = (g << 8) - colors[i].green; - int bdiff = (b << 8) - colors[i].blue; - int sum = ABS (rdiff) + ABS (gdiff) + ABS (bdiff); - if (sum < max) { pixel = i; max = sum; } - } - } - - gdk_image_put_pixel( data_image, x, y, pixel ); - - break; - } - case 12: // SGI only - { - guint32 pixel = 0; - switch (b_o) - { - case RGB: pixel = ((r & 0xf0) << 4) | (g & 0xf0) | ((b & 0xf0) >> 4); break; - case RBG: pixel = ((r & 0xf0) << 4) | (b & 0xf0) | ((g & 0xf0) >> 4); break; - case GRB: pixel = ((g & 0xf0) << 4) | (r & 0xf0) | ((b & 0xf0) >> 4); break; - case GBR: pixel = ((g & 0xf0) << 4) | (b & 0xf0) | ((r & 0xf0) >> 4); break; - case BRG: pixel = ((b & 0xf0) << 4) | (r & 0xf0) | ((g & 0xf0) >> 4); break; - case BGR: pixel = ((b & 0xf0) << 4) | (g & 0xf0) | ((r & 0xf0) >> 4); break; - } - gdk_image_put_pixel( data_image, x, y, pixel ); - break; - } - case 15: - { - guint32 pixel = 0; - switch (b_o) - { - case RGB: pixel = ((r & 0xf8) << 7) | ((g & 0xf8) << 2) | ((b & 0xf8) >> 3); break; - case RBG: pixel = ((r & 0xf8) << 7) | ((b & 0xf8) << 2) | ((g & 0xf8) >> 3); break; - case GRB: pixel = ((g & 0xf8) << 7) | ((r & 0xf8) << 2) | ((b & 0xf8) >> 3); break; - case GBR: pixel = ((g & 0xf8) << 7) | ((b & 0xf8) << 2) | ((r & 0xf8) >> 3); break; - case BRG: pixel = ((b & 0xf8) << 7) | ((r & 0xf8) << 2) | ((g & 0xf8) >> 3); break; - case BGR: pixel = ((b & 0xf8) << 7) | ((g & 0xf8) << 2) | ((r & 0xf8) >> 3); break; - } - gdk_image_put_pixel( data_image, x, y, pixel ); - break; - } - case 16: - { - // I actually don't know if for 16-bit displays, it is alway the green - // component or the second component which has 6 bits. - guint32 pixel = 0; - switch (b_o) - { - case RGB: pixel = ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | ((b & 0xf8) >> 3); break; - case RBG: pixel = ((r & 0xf8) << 8) | ((b & 0xfc) << 3) | ((g & 0xf8) >> 3); break; - case GRB: pixel = ((g & 0xf8) << 8) | ((r & 0xfc) << 3) | ((b & 0xf8) >> 3); break; - case GBR: pixel = ((g & 0xf8) << 8) | ((b & 0xfc) << 3) | ((r & 0xf8) >> 3); break; - case BRG: pixel = ((b & 0xf8) << 8) | ((r & 0xfc) << 3) | ((g & 0xf8) >> 3); break; - case BGR: pixel = ((b & 0xf8) << 8) | ((g & 0xfc) << 3) | ((r & 0xf8) >> 3); break; - } - gdk_image_put_pixel( data_image, x, y, pixel ); - break; - } - case 32: - case 24: - { - guint32 pixel = 0; - switch (b_o) - { - case RGB: pixel = (r << 16) | (g << 8) | b; break; - case RBG: pixel = (r << 16) | (b << 8) | g; break; - case BRG: pixel = (b << 16) | (r << 8) | g; break; - case BGR: pixel = (b << 16) | (g << 8) | r; break; - case GRB: pixel = (g << 16) | (r << 8) | b; break; - case GBR: pixel = (g << 16) | (b << 8) | r; break; - } - gdk_image_put_pixel( data_image, x, y, pixel ); - } - default: break; - } - } // for - } // for - - // Blit picture - - GdkGC *data_gc = gdk_gc_new( GetPixmap() ); - - gdk_draw_image( GetPixmap(), data_gc, data_image, 0, 0, 0, 0, width, height ); - - gdk_image_destroy( data_image ); - gdk_gc_unref( data_gc ); - - // Blit mask - - if (image.HasMask()) - { - GdkGC *mask_gc = gdk_gc_new( GetMask()->GetBitmap() ); - - gdk_draw_image( GetMask()->GetBitmap(), mask_gc, mask_image, 0, 0, 0, 0, width, height ); - - gdk_image_destroy( mask_image ); - gdk_gc_unref( mask_gc ); - } - } - - return TRUE; -} - -wxImage wxBitmap::ConvertToImage() const -{ - // the colour used as transparent one in wxImage and the one it is replaced - // with when it really occurs in the bitmap - static const int MASK_RED = 1; - static const int MASK_GREEN = 2; - static const int MASK_BLUE = 3; - static const int MASK_BLUE_REPLACEMENT = 2; - - wxImage image; - - wxCHECK_MSG( Ok(), wxNullImage, wxT("invalid bitmap") ); - - GdkImage *gdk_image = (GdkImage*) NULL; - if (GetPixmap()) - { - gdk_image = gdk_image_get( GetPixmap(), - 0, 0, - GetWidth(), GetHeight() ); - } - else if (GetBitmap()) - { - gdk_image = gdk_image_get( GetBitmap(), - 0, 0, - GetWidth(), GetHeight() ); - } - else - { - wxFAIL_MSG( wxT("Ill-formed bitmap") ); - } - - wxCHECK_MSG( gdk_image, wxNullImage, wxT("couldn't create image") ); - - image.Create( GetWidth(), GetHeight() ); - char unsigned *data = image.GetData(); - - if (!data) - { - gdk_image_destroy( gdk_image ); - wxFAIL_MSG( wxT("couldn't create image") ); - return wxNullImage; - } - - GdkImage *gdk_image_mask = (GdkImage*) NULL; - if (GetMask()) - { - gdk_image_mask = gdk_image_get( GetMask()->GetBitmap(), - 0, 0, - GetWidth(), GetHeight() ); - - image.SetMaskColour( MASK_RED, MASK_GREEN, MASK_BLUE ); - } - - int bpp = -1; - int red_shift_right = 0; - int green_shift_right = 0; - int blue_shift_right = 0; - int red_shift_left = 0; - int green_shift_left = 0; - int blue_shift_left = 0; - bool use_shift = FALSE; - - if (GetPixmap()) - { - GdkVisual *visual = gdk_window_get_visual( GetPixmap() ); - if (visual == NULL) - visual = wxTheApp->GetGdkVisual(); - - bpp = visual->depth; - if (bpp == 16) - bpp = visual->red_prec + visual->green_prec + visual->blue_prec; - red_shift_right = visual->red_shift; - red_shift_left = 8-visual->red_prec; - green_shift_right = visual->green_shift; - green_shift_left = 8-visual->green_prec; - blue_shift_right = visual->blue_shift; - blue_shift_left = 8-visual->blue_prec; - - use_shift = (visual->type == GDK_VISUAL_TRUE_COLOR) || (visual->type == GDK_VISUAL_DIRECT_COLOR); - } - if (GetBitmap()) - { - bpp = 1; - } - - - GdkColormap *cmap = gtk_widget_get_default_colormap(); - - long pos = 0; - for (int j = 0; j < GetHeight(); j++) - { - for (int i = 0; i < GetWidth(); i++) - { - wxUint32 pixel = gdk_image_get_pixel( gdk_image, i, j ); - if (bpp == 1) - { - if (pixel == 0) - { - data[pos] = 0; - data[pos+1] = 0; - data[pos+2] = 0; - } - else - { - data[pos] = 255; - data[pos+1] = 255; - data[pos+2] = 255; - } - } - else if (use_shift) - { - data[pos] = (pixel >> red_shift_right) << red_shift_left; - data[pos+1] = (pixel >> green_shift_right) << green_shift_left; - data[pos+2] = (pixel >> blue_shift_right) << blue_shift_left; - } - else if (cmap->colors) - { - data[pos] = cmap->colors[pixel].red >> 8; - data[pos+1] = cmap->colors[pixel].green >> 8; - data[pos+2] = cmap->colors[pixel].blue >> 8; - } - else - { - wxFAIL_MSG( wxT("Image conversion failed. Unknown visual type.") ); - } - - if (gdk_image_mask) - { - int mask_pixel = gdk_image_get_pixel( gdk_image_mask, i, j ); - if (mask_pixel == 0) - { - data[pos] = MASK_RED; - data[pos+1] = MASK_GREEN; - data[pos+2] = MASK_BLUE; - } - else if ( data[pos] == MASK_RED && - data[pos+1] == MASK_GREEN && - data[pos+2] == MASK_BLUE ) - { - data[pos+2] = MASK_BLUE_REPLACEMENT; - } - } - - pos += 3; - } - } - - gdk_image_destroy( gdk_image ); - if (gdk_image_mask) gdk_image_destroy( gdk_image_mask ); - - return image; -} - -wxBitmap::wxBitmap( const wxBitmap& bmp ) - : wxGDIObject() -{ - Ref( bmp ); -} - -wxBitmap::wxBitmap( const wxString &filename, int type ) -{ - LoadFile( filename, type ); -} - -wxBitmap::wxBitmap( const char bits[], int width, int height, int WXUNUSED(depth)) -{ - m_refData = new wxBitmapRefData(); - - M_BMPDATA->m_mask = (wxMask *) NULL; - M_BMPDATA->m_bitmap = - gdk_bitmap_create_from_data( wxGetRootWindow()->window, (gchar *) bits, width, height ); - M_BMPDATA->m_width = width; - M_BMPDATA->m_height = height; - M_BMPDATA->m_bpp = 1; - - if (!M_BMPDATA->m_bitmap) - { - UnRef(); - - wxFAIL_MSG( wxT("couldn't create bitmap") ); - } -} - -wxBitmap::~wxBitmap() -{ -} - -wxBitmap& wxBitmap::operator = ( const wxBitmap& bmp ) -{ - if ( m_refData != bmp.m_refData ) - Ref( bmp ); - - return *this; -} - -bool wxBitmap::operator == ( const wxBitmap& bmp ) const -{ - return m_refData == bmp.m_refData; -} - -bool wxBitmap::operator != ( const wxBitmap& bmp ) const -{ - return m_refData != bmp.m_refData; -} - -bool wxBitmap::Ok() const -{ - return (m_refData != NULL); -} - -int wxBitmap::GetHeight() const -{ - wxCHECK_MSG( Ok(), -1, wxT("invalid bitmap") ); - - return M_BMPDATA->m_height; -} - -int wxBitmap::GetWidth() const -{ - wxCHECK_MSG( Ok(), -1, wxT("invalid bitmap") ); - - return M_BMPDATA->m_width; -} - -int wxBitmap::GetDepth() const -{ - wxCHECK_MSG( Ok(), -1, wxT("invalid bitmap") ); - - return M_BMPDATA->m_bpp; -} - -wxMask *wxBitmap::GetMask() const -{ - wxCHECK_MSG( Ok(), (wxMask *) NULL, wxT("invalid bitmap") ); - - return M_BMPDATA->m_mask; -} - -void wxBitmap::SetMask( wxMask *mask ) -{ - wxCHECK_RET( Ok(), wxT("invalid bitmap") ); - - if (M_BMPDATA->m_mask) delete M_BMPDATA->m_mask; - - M_BMPDATA->m_mask = mask; -} - -bool wxBitmap::CopyFromIcon(const wxIcon& icon) -{ - *this = icon; - return TRUE; -} - -wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect) const -{ - wxCHECK_MSG( Ok() && - (rect.x >= 0) && (rect.y >= 0) && - (rect.x+rect.width <= M_BMPDATA->m_width) && (rect.y+rect.height <= M_BMPDATA->m_height), - wxNullBitmap, wxT("invalid bitmap or bitmap region") ); - - wxBitmap ret( rect.width, rect.height, M_BMPDATA->m_bpp ); - wxASSERT_MSG( ret.Ok(), wxT("GetSubBitmap error") ); - - if (ret.GetPixmap()) - { - GdkGC *gc = gdk_gc_new( ret.GetPixmap() ); - gdk_draw_pixmap( ret.GetPixmap(), gc, GetPixmap(), rect.x, rect.y, 0, 0, rect.width, rect.height ); - gdk_gc_destroy( gc ); - } - else - { - GdkGC *gc = gdk_gc_new( ret.GetBitmap() ); - GdkColor col; - col.pixel = 0xFFFFFF; - gdk_gc_set_foreground( gc, &col ); - col.pixel = 0; - gdk_gc_set_background( gc, &col ); - gdk_wx_draw_bitmap( ret.GetBitmap(), gc, GetBitmap(), rect.x, rect.y, 0, 0, rect.width, rect.height ); - gdk_gc_destroy( gc ); - } - - if (GetMask()) - { - wxMask *mask = new wxMask; - mask->m_bitmap = gdk_pixmap_new( wxGetRootWindow()->window, rect.width, rect.height, 1 ); - - GdkGC *gc = gdk_gc_new( mask->m_bitmap ); - GdkColor col; - col.pixel = 0xFFFFFF; - gdk_gc_set_foreground( gc, &col ); - col.pixel = 0; - gdk_gc_set_background( gc, &col ); - gdk_wx_draw_bitmap( mask->m_bitmap, gc, M_BMPDATA->m_mask->m_bitmap, rect.x, rect.y, 0, 0, rect.width, rect.height ); - gdk_gc_destroy( gc ); - - ret.SetMask( mask ); - } - - return ret; -} - -wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight, int newx, int newy ) -{ - wxCHECK_MSG( Ok(), wxNullBitmap, wxT("invalid bitmap") ); - - if (newy==M_BMPDATA->m_width && newy==M_BMPDATA->m_height) - return *this; - - GdkImage *img = (GdkImage*) NULL; - if (GetPixmap()) - img = gdk_image_get( GetPixmap(), 0, 0, GetWidth(), GetHeight() ); - else if (GetBitmap()) - img = gdk_image_get( GetBitmap(), 0, 0, GetWidth(), GetHeight() ); - else - wxFAIL_MSG( wxT("Ill-formed bitmap") ); - - wxCHECK_MSG( img, wxNullBitmap, wxT("couldn't create image") ); - - wxBitmap bmp; - int bpp = -1; - - int width = wxMax(newx, 1); - int height = wxMax(newy, 1); - width = wxMin(width, clipwidth); - height = wxMin(height, clipheight); - - GdkGC *gc = NULL; - GdkPixmap *dstpix = NULL; - if (GetPixmap()) - { - GdkVisual *visual = gdk_window_get_visual( GetPixmap() ); - if (visual == NULL) - visual = wxTheApp->GetGdkVisual(); - - bpp = visual->depth; - bmp = wxBitmap(width,height,bpp); - dstpix = bmp.GetPixmap(); - gc = gdk_gc_new( dstpix ); - } - - char *dst = NULL; - long dstbyteperline = 0; - - if (GetBitmap()) - { - bpp = 1; - dstbyteperline = width/8*M_BMPDATA->m_bpp; - if (width*M_BMPDATA->m_bpp % 8 != 0) - dstbyteperline++; - dst = (char*) malloc(dstbyteperline*height); - } - - // be careful to use the right scaling factor - float scx = (float)M_BMPDATA->m_width/(float)newx; - float scy = (float)M_BMPDATA->m_height/(float)newy; - // prepare accel-tables - int *tablex = (int *)calloc(width,sizeof(int)); - int *tabley = (int *)calloc(height,sizeof(int)); - - // accel table filled with clipped values - for (int x = 0; x < width; x++) - tablex[x] = (int) (scx * (x+clipx)); - for (int y = 0; y < height; y++) - tabley[y] = (int) (scy * (y+clipy)); - - // Main rescaling routine starts here - for (int h = 0; h < height; h++) - { - char outbyte = 0; - int old_x = -1; - guint32 old_pixval = 0; - - for (int w = 0; w < width; w++) - { - guint32 pixval; - int x = tablex[w]; - if (x == old_x) - pixval = old_pixval; - else - { - pixval = gdk_image_get_pixel( img, x, tabley[h] ); - old_pixval = pixval; - old_x = x; - } - - if (bpp == 1) - { - if (!pixval) - { - char bit=1; - char shift = bit << w % 8; - outbyte |= shift; - } - - if ((w+1)%8==0) - { - dst[h*dstbyteperline+w/8] = outbyte; - outbyte = 0; - } - } - else - { - GdkColor col; - col.pixel = pixval; - gdk_gc_set_foreground( gc, &col ); - gdk_draw_point( dstpix, gc, w, h); - } - } - - // do not forget the last byte - if ((bpp == 1) && (width % 8 != 0)) - dst[h*dstbyteperline+width/8] = outbyte; - } - - gdk_image_destroy( img ); - if (gc) gdk_gc_unref( gc ); - - if (bpp == 1) - { - bmp = wxBitmap( (const char *)dst, width, height, 1 ); - free( dst ); - } - - if (GetMask()) - { - dstbyteperline = width/8; - if (width % 8 != 0) - dstbyteperline++; - dst = (char*) malloc(dstbyteperline*height); - img = gdk_image_get( GetMask()->GetBitmap(), 0, 0, GetWidth(), GetHeight() ); - - for (int h = 0; h < height; h++) - { - char outbyte = 0; - int old_x = -1; - guint32 old_pixval = 0; - - for (int w = 0; w < width; w++) - { - guint32 pixval; - int x = tablex[w]; - if (x == old_x) - pixval = old_pixval; - else - { - pixval = gdk_image_get_pixel( img, x, tabley[h] ); - old_pixval = pixval; - old_x = x; - } - - if (pixval) - { - char bit=1; - char shift = bit << w % 8; - outbyte |= shift; - } - - if ((w+1)%8 == 0) - { - dst[h*dstbyteperline+w/8] = outbyte; - outbyte = 0; - } - } - - // do not forget the last byte - if (width % 8 != 0) - dst[h*dstbyteperline+width/8] = outbyte; - } - wxMask* mask = new wxMask; - mask->m_bitmap = gdk_bitmap_create_from_data( wxGetRootWindow()->window, (gchar *) dst, width, height ); - bmp.SetMask(mask); - - free( dst ); - gdk_image_destroy( img ); - } - - free( tablex ); - free( tabley ); - - return bmp; -} - - -bool wxBitmap::SaveFile( const wxString &name, int type, wxPalette *WXUNUSED(palette) ) -{ - wxCHECK_MSG( Ok(), FALSE, wxT("invalid bitmap") ); - - // Try to save the bitmap via wxImage handlers: - { - wxImage image = ConvertToImage(); - if (image.Ok()) return image.SaveFile( name, type ); - } - - return FALSE; -} - -bool wxBitmap::LoadFile( const wxString &name, int type ) -{ - UnRef(); - - if (!wxFileExists(name)) return FALSE; - - GdkVisual *visual = wxTheApp->GetGdkVisual(); - - if (type == wxBITMAP_TYPE_XPM) - { - m_refData = new wxBitmapRefData(); - - GdkBitmap *mask = (GdkBitmap*) NULL; - - M_BMPDATA->m_pixmap = gdk_pixmap_create_from_xpm( wxGetRootWindow()->window, &mask, NULL, name.fn_str() ); - - 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 = visual->depth; - } - else // try if wxImage can load it - { - wxImage image; - if (!image.LoadFile( name, type )) return FALSE; - if (image.Ok()) - *this = wxBitmap(image); - else return FALSE; - } - - return TRUE; -} - -wxPalette *wxBitmap::GetPalette() const -{ - if (!Ok()) return (wxPalette *) NULL; - - return M_BMPDATA->m_palette; -} - -void wxBitmap::SetHeight( int height ) -{ - if (!m_refData) m_refData = new wxBitmapRefData(); - - M_BMPDATA->m_height = height; -} - -void wxBitmap::SetWidth( int width ) -{ - if (!m_refData) m_refData = new wxBitmapRefData(); - - M_BMPDATA->m_width = width; -} - -void wxBitmap::SetDepth( int depth ) -{ - if (!m_refData) m_refData = new wxBitmapRefData(); - - M_BMPDATA->m_bpp = depth; -} - -void wxBitmap::SetPixmap( GdkPixmap *pixmap ) -{ - if (!m_refData) m_refData = new wxBitmapRefData(); - - M_BMPDATA->m_pixmap = pixmap; -} - -void wxBitmap::SetBitmap( GdkPixmap *bitmap ) -{ - if (!m_refData) m_refData = new wxBitmapRefData(); - - M_BMPDATA->m_bitmap = bitmap; -} - -GdkPixmap *wxBitmap::GetPixmap() const -{ - wxCHECK_MSG( Ok(), (GdkPixmap *) NULL, wxT("invalid bitmap") ); - - return M_BMPDATA->m_pixmap; -} - -GdkBitmap *wxBitmap::GetBitmap() const -{ - wxCHECK_MSG( Ok(), (GdkBitmap *) NULL, wxT("invalid bitmap") ); - - return M_BMPDATA->m_bitmap; -} diff --git a/src/gtk1/bmpbuttn.cpp b/src/gtk1/bmpbuttn.cpp deleted file mode 100644 index 1eba0896c9..0000000000 --- a/src/gtk1/bmpbuttn.cpp +++ /dev/null @@ -1,292 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: gtk/bmpbuttn.cpp -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/defs.h" - -#if wxUSE_BMPBUTTON - -#include "wx/bmpbuttn.h" - -#include "wx/gtk/private.h" - -//----------------------------------------------------------------------------- -// classes -//----------------------------------------------------------------------------- - -class wxBitmapButton; - -//----------------------------------------------------------------------------- -// idle system -//----------------------------------------------------------------------------- - -extern void wxapp_install_idle_handler(); -extern bool g_isIdle; - -//----------------------------------------------------------------------------- -// data -//----------------------------------------------------------------------------- - -extern bool g_blockEventsOnDrag; - -//----------------------------------------------------------------------------- -// "clicked" -//----------------------------------------------------------------------------- - -static void gtk_bmpbutton_clicked_callback( GtkWidget *WXUNUSED(widget), wxBitmapButton *button ) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - - if (!button->m_hasVMT) return; - if (g_blockEventsOnDrag) return; - - wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, button->GetId()); - event.SetEventObject(button); - button->GetEventHandler()->ProcessEvent(event); -} - -//----------------------------------------------------------------------------- -// "enter" -//----------------------------------------------------------------------------- - -static void gtk_bmpbutton_enter_callback( GtkWidget *WXUNUSED(widget), wxBitmapButton *button ) -{ - if (!button->m_hasVMT) return; - if (g_blockEventsOnDrag) return; - - button->HasFocus(); -} - -//----------------------------------------------------------------------------- -// "leave" -//----------------------------------------------------------------------------- - -static void gtk_bmpbutton_leave_callback( GtkWidget *WXUNUSED(widget), wxBitmapButton *button ) -{ - if (!button->m_hasVMT) return; - if (g_blockEventsOnDrag) return; - - button->NotFocus(); -} - -//----------------------------------------------------------------------------- -// "pressed" -//----------------------------------------------------------------------------- - -static void gtk_bmpbutton_press_callback( GtkWidget *WXUNUSED(widget), wxBitmapButton *button ) -{ - if (!button->m_hasVMT) return; - if (g_blockEventsOnDrag) return; - - button->StartSelect(); -} - -//----------------------------------------------------------------------------- -// "released" -//----------------------------------------------------------------------------- - -static void gtk_bmpbutton_release_callback( GtkWidget *WXUNUSED(widget), wxBitmapButton *button ) -{ - if (!button->m_hasVMT) return; - if (g_blockEventsOnDrag) return; - - button->EndSelect(); -} - -//----------------------------------------------------------------------------- -// wxBitmapButton -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton,wxButton) - -void wxBitmapButton::Init() -{ - m_hasFocus = - m_isSelected = FALSE; -} - -bool wxBitmapButton::Create( wxWindow *parent, - wxWindowID id, - const wxBitmap& bitmap, - const wxPoint& pos, - const wxSize& size, - long style, - const wxValidator& validator, - const wxString &name ) -{ - m_needParent = TRUE; - m_acceptsFocus = TRUE; - - if (!PreCreation( parent, pos, size ) || - !CreateBase( parent, id, pos, size, style, validator, name )) - { - wxFAIL_MSG( wxT("wxBitmapButton creation failed") ); - return FALSE; - } - - m_bmpNormal = - m_bmpDisabled = - m_bmpFocus = - m_bmpSelected = bitmap; - - m_widget = gtk_button_new(); - -#if (GTK_MINOR_VERSION > 0) - if (style & wxNO_BORDER) - gtk_button_set_relief( GTK_BUTTON(m_widget), GTK_RELIEF_NONE ); -#endif - - if (m_bmpNormal.Ok()) - { - wxSize newSize = size; - int border = (style & wxNO_BORDER) ? 4 : 10; - if (newSize.x == -1) - newSize.x = m_bmpNormal.GetWidth()+border; - if (newSize.y == -1) - newSize.y = m_bmpNormal.GetHeight()+border; - SetSize( newSize.x, newSize.y ); - OnSetBitmap(); - } - - gtk_signal_connect( GTK_OBJECT(m_widget), "clicked", - GTK_SIGNAL_FUNC(gtk_bmpbutton_clicked_callback), (gpointer*)this ); - - gtk_signal_connect( GTK_OBJECT(m_widget), "enter", - GTK_SIGNAL_FUNC(gtk_bmpbutton_enter_callback), (gpointer*)this ); - gtk_signal_connect( GTK_OBJECT(m_widget), "leave", - GTK_SIGNAL_FUNC(gtk_bmpbutton_leave_callback), (gpointer*)this ); - gtk_signal_connect( GTK_OBJECT(m_widget), "pressed", - GTK_SIGNAL_FUNC(gtk_bmpbutton_press_callback), (gpointer*)this ); - gtk_signal_connect( GTK_OBJECT(m_widget), "released", - GTK_SIGNAL_FUNC(gtk_bmpbutton_release_callback), (gpointer*)this ); - - m_parent->DoAddChild( this ); - - PostCreation(); - - SetBackgroundColour( parent->GetBackgroundColour() ); - - Show( TRUE ); - - return TRUE; -} - -void wxBitmapButton::SetDefault() -{ - GTK_WIDGET_SET_FLAGS( m_widget, GTK_CAN_DEFAULT ); - gtk_widget_grab_default( m_widget ); - - SetSize( m_x, m_y, m_width, m_height ); -} - -void wxBitmapButton::SetLabel( const wxString &label ) -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid button") ); - - wxControl::SetLabel( label ); -} - -wxString wxBitmapButton::GetLabel() const -{ - wxCHECK_MSG( m_widget != NULL, wxT(""), wxT("invalid button") ); - - return wxControl::GetLabel(); -} - -void wxBitmapButton::ApplyWidgetStyle() -{ - if ( !BUTTON_CHILD(m_widget) ) - return; - - wxButton::ApplyWidgetStyle(); -} - -void wxBitmapButton::OnSetBitmap() -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid bitmap button") ); - - wxBitmap the_one; - if (!m_isEnabled) - the_one = m_bmpDisabled; - else if (m_isSelected) - the_one = m_bmpSelected; - else if (m_hasFocus) - the_one = m_bmpFocus; - else - { - if (m_isSelected) - { - the_one = m_bmpSelected; - } - else - { - if (m_hasFocus) - the_one = m_bmpFocus; - else - the_one = m_bmpNormal; - } - } - - if (!the_one.Ok()) the_one = m_bmpNormal; - if (!the_one.Ok()) return; - - GdkBitmap *mask = (GdkBitmap *) NULL; - if (the_one.GetMask()) mask = the_one.GetMask()->GetBitmap(); - - GtkWidget *child = BUTTON_CHILD(m_widget); - if (child == NULL) - { - // initial bitmap - GtkWidget *pixmap = gtk_pixmap_new(the_one.GetPixmap(), mask); - gtk_widget_show(pixmap); - gtk_container_add(GTK_CONTAINER(m_widget), pixmap); - } - else - { // subsequent bitmaps - GtkPixmap *g_pixmap = GTK_PIXMAP(child); - gtk_pixmap_set(g_pixmap, the_one.GetPixmap(), mask); - } -} - -bool wxBitmapButton::Enable( bool enable ) -{ - if ( !wxWindow::Enable(enable) ) - return FALSE; - - OnSetBitmap(); - - return TRUE; -} - -void wxBitmapButton::HasFocus() -{ - m_hasFocus = TRUE; - OnSetBitmap(); -} - -void wxBitmapButton::NotFocus() -{ - m_hasFocus = FALSE; - OnSetBitmap(); -} - -void wxBitmapButton::StartSelect() -{ - m_isSelected = TRUE; - OnSetBitmap(); -} - -void wxBitmapButton::EndSelect() -{ - m_isSelected = FALSE; - OnSetBitmap(); -} - -#endif // wxUSE_BMPBUTTON - diff --git a/src/gtk1/brush.cpp b/src/gtk1/brush.cpp deleted file mode 100644 index 847ce9e120..0000000000 --- a/src/gtk1/brush.cpp +++ /dev/null @@ -1,164 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/gtk/brush.cpp -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/brush.h" - -#include - -//----------------------------------------------------------------------------- -// wxBrush -//----------------------------------------------------------------------------- - -class wxBrushRefData: public wxObjectRefData -{ -public: - wxBrushRefData() - { - m_style = 0; - } - - wxBrushRefData( const wxBrushRefData& data ) - : wxObjectRefData() - { - m_style = data.m_style; - m_stipple = data.m_stipple; - m_colour = data.m_colour; - } - - bool operator == (const wxBrushRefData& data) const - { - return (m_style == data.m_style && - m_stipple == data.m_stipple && - m_colour == data.m_colour); - } - - int m_style; - wxColour m_colour; - wxBitmap m_stipple; -}; - -//----------------------------------------------------------------------------- - -#define M_BRUSHDATA ((wxBrushRefData *)m_refData) - -IMPLEMENT_DYNAMIC_CLASS(wxBrush,wxGDIObject) - -wxBrush::wxBrush( const wxColour &colour, int style ) -{ - m_refData = new wxBrushRefData(); - M_BRUSHDATA->m_style = style; - M_BRUSHDATA->m_colour = colour; -} - -wxBrush::wxBrush( const wxBitmap &stippleBitmap ) -{ - m_refData = new wxBrushRefData(); - M_BRUSHDATA->m_colour = *wxBLACK; - - M_BRUSHDATA->m_stipple = stippleBitmap; - - if (M_BRUSHDATA->m_stipple.GetMask()) - M_BRUSHDATA->m_style = wxSTIPPLE_MASK_OPAQUE; - else - M_BRUSHDATA->m_style = wxSTIPPLE; -} - -wxBrush::~wxBrush() -{ - // m_refData unrefed in ~wxObject -} - -wxObjectRefData *wxBrush::CreateRefData() const -{ - return new wxBrushRefData; -} - -wxObjectRefData *wxBrush::CloneRefData(const wxObjectRefData *data) const -{ - return new wxBrushRefData(*(wxBrushRefData *)data); -} - -bool wxBrush::operator == ( const wxBrush& brush ) const -{ - if (m_refData == brush.m_refData) return TRUE; - - if (!m_refData || !brush.m_refData) return FALSE; - - return ( *(wxBrushRefData*)m_refData == *(wxBrushRefData*)brush.m_refData ); -} - -int wxBrush::GetStyle() const -{ - if (m_refData == NULL) - { - wxFAIL_MSG( wxT("invalid brush") ); - return 0; - } - - return M_BRUSHDATA->m_style; -} - -wxColour &wxBrush::GetColour() const -{ - if (m_refData == NULL) - { - wxFAIL_MSG( wxT("invalid brush") ); - return wxNullColour; - } - - return M_BRUSHDATA->m_colour; -} - -wxBitmap *wxBrush::GetStipple() const -{ - if (m_refData == NULL) - { - wxFAIL_MSG( wxT("invalid brush") ); - return &wxNullBitmap; - } - - return &M_BRUSHDATA->m_stipple; -} - -void wxBrush::SetColour( const wxColour& col ) -{ - AllocExclusive(); - - M_BRUSHDATA->m_colour = col; -} - -void wxBrush::SetColour( unsigned char r, unsigned char g, unsigned char b ) -{ - AllocExclusive(); - - M_BRUSHDATA->m_colour.Set( r, g, b ); -} - -void wxBrush::SetStyle( int style ) -{ - AllocExclusive(); - - M_BRUSHDATA->m_style = style; -} - -void wxBrush::SetStipple( const wxBitmap& stipple ) -{ - AllocExclusive(); - - M_BRUSHDATA->m_stipple = stipple; - if (M_BRUSHDATA->m_stipple.GetMask()) - { - M_BRUSHDATA->m_style = wxSTIPPLE_MASK_OPAQUE; - } - else - { - M_BRUSHDATA->m_style = wxSTIPPLE; - } -} - diff --git a/src/gtk1/button.cpp b/src/gtk1/button.cpp deleted file mode 100644 index bb05502fef..0000000000 --- a/src/gtk1/button.cpp +++ /dev/null @@ -1,221 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: button.cpp -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/defs.h" - -#if wxUSE_BUTTON - -#include "wx/button.h" - -#include "wx/gtk/private.h" - -//----------------------------------------------------------------------------- -// classes -//----------------------------------------------------------------------------- - -class wxButton; - -//----------------------------------------------------------------------------- -// idle system -//----------------------------------------------------------------------------- - -extern void wxapp_install_idle_handler(); -extern bool g_isIdle; - -//----------------------------------------------------------------------------- -// data -//----------------------------------------------------------------------------- - -extern bool g_blockEventsOnDrag; - -//----------------------------------------------------------------------------- -// "clicked" -//----------------------------------------------------------------------------- - -static void gtk_button_clicked_callback( GtkWidget *WXUNUSED(widget), wxButton *button ) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - - if (!button->m_hasVMT) return; - if (g_blockEventsOnDrag) return; - - wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, button->GetId()); - event.SetEventObject(button); - button->GetEventHandler()->ProcessEvent(event); -} - -//----------------------------------------------------------------------------- -// wxButton -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxButton,wxControl) - -wxButton::wxButton() -{ -} - -wxButton::~wxButton() -{ -} - -bool wxButton::Create( wxWindow *parent, wxWindowID id, const wxString &label, - const wxPoint &pos, const wxSize &size, - long style, const wxValidator& validator, const wxString &name ) -{ - m_needParent = TRUE; - m_acceptsFocus = TRUE; - - if (!PreCreation( parent, pos, size ) || - !CreateBase( parent, id, pos, size, style, validator, name )) - { - wxFAIL_MSG( wxT("wxButton creation failed") ); - return FALSE; - } - -/* - wxString label2( label ); - for (size_t i = 0; i < label2.Len(); i++) - { - if (label2.GetChar(i) == wxT('&')) - label2.SetChar(i,wxT('_')); - } - - GtkWidget *accel_label = gtk_accel_label_new( label2.mb_str() ); - gtk_widget_show( accel_label ); - - m_widget = gtk_button_new(); - gtk_container_add( GTK_CONTAINER(m_widget), accel_label ); - - gtk_accel_label_set_accel_widget( GTK_ACCEL_LABEL(accel_label), m_widget ); - - guint accel_key = gtk_label_parse_uline (GTK_LABEL(accel_label), label2.mb_str() ); - gtk_accel_label_refetch( GTK_ACCEL_LABEL(accel_label) ); - - wxControl::SetLabel( label ); -*/ - - m_widget = gtk_button_new_with_label(""); - - float x_alignment = 0.5; - if (HasFlag(wxBU_LEFT)) - x_alignment = 0.0; - else if (HasFlag(wxBU_RIGHT)) - x_alignment = 1.0; - - float y_alignment = 0.5; - if (HasFlag(wxBU_TOP)) - y_alignment = 0.0; - else if (HasFlag(wxBU_BOTTOM)) - y_alignment = 1.0; - - gtk_misc_set_alignment (GTK_MISC (BUTTON_CHILD (m_widget)), - x_alignment, y_alignment); - - SetLabel( label ); - - if (style & wxNO_BORDER) - gtk_button_set_relief( GTK_BUTTON(m_widget), GTK_RELIEF_NONE ); - - gtk_signal_connect( GTK_OBJECT(m_widget), "clicked", - GTK_SIGNAL_FUNC(gtk_button_clicked_callback), (gpointer*)this ); - - m_parent->DoAddChild( this ); - - PostCreation(); - - SetFont( parent->GetFont() ); - - wxSize best_size( DoGetBestSize() ); - wxSize new_size( size ); - if (new_size.x == -1) - new_size.x = best_size.x; - if (new_size.y == -1) - new_size.y = best_size.y; - if ((new_size.x != size.x) || (new_size.y != size.y)) - SetSize( new_size.x, new_size.y ); - - SetSize( new_size ); - - SetBackgroundColour( parent->GetBackgroundColour() ); - SetForegroundColour( parent->GetForegroundColour() ); - - Show( TRUE ); - - return TRUE; -} - -void wxButton::SetDefault() -{ - GTK_WIDGET_SET_FLAGS( m_widget, GTK_CAN_DEFAULT ); - gtk_widget_grab_default( m_widget ); - - SetSize( m_x, m_y, m_width, m_height ); -} - -/* static */ -wxSize wxButton::GetDefaultSize() -{ - return wxSize(80,26); -} - -void wxButton::SetLabel( const wxString &label ) -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid button") ); - - wxControl::SetLabel( label ); - -#ifdef __WXGTK20__ - wxString label2 = PrepareLabelMnemonics( label ); - gtk_label_set_text_with_mnemonic( GTK_LABEL( BUTTON_CHILD(m_widget) ), wxGTK_CONV( label2 ) ); -#else - gtk_label_set( GTK_LABEL( BUTTON_CHILD(m_widget) ), wxGTK_CONV( GetLabel() ) ); -#endif -} - -bool wxButton::Enable( bool enable ) -{ - if ( !wxControl::Enable( enable ) ) - return FALSE; - - gtk_widget_set_sensitive( BUTTON_CHILD(m_widget), enable ); - - return TRUE; -} - -bool wxButton::IsOwnGtkWindow( GdkWindow *window ) -{ -#ifdef __WXGTK20__ - return GTK_BUTTON(m_widget)->event_window; -#else - return (window == m_widget->window); -#endif -} - -void wxButton::ApplyWidgetStyle() -{ - SetWidgetStyle(); - gtk_widget_set_style( m_widget, m_widgetStyle ); - gtk_widget_set_style( BUTTON_CHILD(m_widget), m_widgetStyle ); -} - -wxSize wxButton::DoGetBestSize() const -{ - wxSize ret( wxControl::DoGetBestSize() ); - - if (!HasFlag(wxBU_EXACTFIT)) - { - if (ret.x < 80) ret.x = 80; - } - - return ret; -} - -#endif // wxUSE_BUTTON - diff --git a/src/gtk1/cdiag.xbm b/src/gtk1/cdiag.xbm deleted file mode 100644 index 15dc7ba86d..0000000000 --- a/src/gtk1/cdiag.xbm +++ /dev/null @@ -1,6 +0,0 @@ -#define cdiag_width 16 -#define cdiag_height 16 -static char cdiag_bits[] = { - 0x81, 0x81, 0x42, 0x42, 0x24, 0x24, 0x18, 0x18, 0x18, 0x18, 0x24, 0x24, - 0x42, 0x42, 0x81, 0x81, 0x81, 0x81, 0x42, 0x42, 0x24, 0x24, 0x18, 0x18, - 0x18, 0x18, 0x24, 0x24, 0x42, 0x42, 0x81, 0x81}; diff --git a/src/gtk1/checkbox.cpp b/src/gtk1/checkbox.cpp deleted file mode 100644 index 7dbb87c840..0000000000 --- a/src/gtk1/checkbox.cpp +++ /dev/null @@ -1,226 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: checkbox.cpp -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/defs.h" - -#if wxUSE_CHECKBOX - -#include "wx/checkbox.h" - -#include "wx/gtk/private.h" - -//----------------------------------------------------------------------------- -// idle system -//----------------------------------------------------------------------------- - -extern void wxapp_install_idle_handler(); -extern bool g_isIdle; - -//----------------------------------------------------------------------------- -// data -//----------------------------------------------------------------------------- - -extern bool g_blockEventsOnDrag; -extern wxCursor g_globalCursor; -extern wxWindowGTK *g_delayedFocus; - -//----------------------------------------------------------------------------- -// "clicked" -//----------------------------------------------------------------------------- - -static void gtk_checkbox_clicked_callback( GtkWidget *WXUNUSED(widget), wxCheckBox *cb ) -{ - if (g_isIdle) wxapp_install_idle_handler(); - - if (!cb->m_hasVMT) return; - - if (g_blockEventsOnDrag) return; - - if (cb->m_blockEvent) return; - - wxCommandEvent event(wxEVT_COMMAND_CHECKBOX_CLICKED, cb->GetId()); - event.SetInt( cb->GetValue() ); - event.SetEventObject(cb); - cb->GetEventHandler()->ProcessEvent(event); -} - -//----------------------------------------------------------------------------- -// wxCheckBox -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxCheckBox,wxControl) - -wxCheckBox::wxCheckBox() -{ -} - -bool wxCheckBox::Create(wxWindow *parent, - wxWindowID id, - const wxString &label, - const wxPoint &pos, - const wxSize &size, - long style, - const wxValidator& validator, - const wxString &name ) -{ - m_needParent = TRUE; - m_acceptsFocus = TRUE; - m_blockEvent = FALSE; - - if (!PreCreation( parent, pos, size ) || - !CreateBase( parent, id, pos, size, style, validator, name )) - { - wxFAIL_MSG( wxT("wxCheckBox creation failed") ); - return FALSE; - } - - if ( style & wxALIGN_RIGHT ) - { - // VZ: as I don't know a way to create a right aligned checkbox with - // GTK we will create a checkbox without label and a label at the - // left of it - m_widgetCheckbox = gtk_check_button_new(); - - m_widgetLabel = gtk_label_new(""); - gtk_misc_set_alignment(GTK_MISC(m_widgetLabel), 0.0, 0.5); - - m_widget = gtk_hbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX(m_widget), m_widgetLabel, FALSE, FALSE, 3); - gtk_box_pack_start(GTK_BOX(m_widget), m_widgetCheckbox, FALSE, FALSE, 3); - - gtk_widget_show( m_widgetLabel ); - gtk_widget_show( m_widgetCheckbox ); - } - else - { - m_widgetCheckbox = gtk_check_button_new_with_label(""); - m_widgetLabel = BUTTON_CHILD( m_widgetCheckbox ); - m_widget = m_widgetCheckbox; - } - SetLabel( label ); - - gtk_signal_connect( GTK_OBJECT(m_widgetCheckbox), - "clicked", - GTK_SIGNAL_FUNC(gtk_checkbox_clicked_callback), - (gpointer *)this ); - - m_parent->DoAddChild( this ); - - PostCreation(); - - SetFont( parent->GetFont() ); - - wxSize size_best( DoGetBestSize() ); - wxSize new_size( size ); - if (new_size.x == -1) - new_size.x = size_best.x; - if (new_size.y == -1) - new_size.y = size_best.y; - if ((new_size.x != size.x) || (new_size.y != size.y)) - SetSize( new_size.x, new_size.y ); - - SetBackgroundColour( parent->GetBackgroundColour() ); - SetForegroundColour( parent->GetForegroundColour() ); - - Show( TRUE ); - - return TRUE; -} - -void wxCheckBox::SetValue( bool state ) -{ - wxCHECK_RET( m_widgetCheckbox != NULL, wxT("invalid checkbox") ); - - if (state == GetValue()) - return; - - m_blockEvent = TRUE; - - gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_widgetCheckbox), state ); - - m_blockEvent = FALSE; -} - -bool wxCheckBox::GetValue() const -{ - wxCHECK_MSG( m_widgetCheckbox != NULL, FALSE, wxT("invalid checkbox") ); - - return GTK_TOGGLE_BUTTON(m_widgetCheckbox)->active; -} - -void wxCheckBox::SetLabel( const wxString& label ) -{ - wxCHECK_RET( m_widgetLabel != NULL, wxT("invalid checkbox") ); - - wxControl::SetLabel( label ); - -#ifdef __WXGTK20__ - wxString label2 = PrepareLabelMnemonics( label ); - gtk_label_set_text_with_mnemonic( GTK_LABEL(m_widgetLabel), wxGTK_CONV( label2 ) ); -#else - gtk_label_set( GTK_LABEL(m_widgetLabel), wxGTK_CONV( GetLabel() ) ); -#endif -} - -bool wxCheckBox::Enable( bool enable ) -{ - if ( !wxControl::Enable( enable ) ) - return FALSE; - - gtk_widget_set_sensitive( m_widgetLabel, enable ); - - return TRUE; -} - -void wxCheckBox::ApplyWidgetStyle() -{ - SetWidgetStyle(); - gtk_widget_set_style( m_widgetCheckbox, m_widgetStyle ); - gtk_widget_set_style( m_widgetLabel, m_widgetStyle ); -} - -bool wxCheckBox::IsOwnGtkWindow( GdkWindow *window ) -{ - return window == TOGGLE_BUTTON_EVENT_WIN(m_widget); -} - -void wxCheckBox::OnInternalIdle() -{ - wxCursor cursor = m_cursor; - if (g_globalCursor.Ok()) cursor = g_globalCursor; - - GdkWindow *event_window = TOGGLE_BUTTON_EVENT_WIN(m_widgetCheckbox); - if ( event_window && cursor.Ok() ) - { - /* I now set the cursor the anew in every OnInternalIdle call - as setting the cursor in a parent window also effects the - windows above so that checking for the current cursor is - not possible. */ - - gdk_window_set_cursor( event_window, cursor.GetCursor() ); - } - - if (g_delayedFocus == this) - { - if (GTK_WIDGET_REALIZED(m_widget)) - { - gtk_widget_grab_focus( m_widget ); - g_delayedFocus = NULL; - } - } - - UpdateWindowUI(); -} - -wxSize wxCheckBox::DoGetBestSize() const -{ - return wxControl::DoGetBestSize(); -} - -#endif diff --git a/src/gtk1/checklst.cpp b/src/gtk1/checklst.cpp deleted file mode 100644 index 0dbd245235..0000000000 --- a/src/gtk1/checklst.cpp +++ /dev/null @@ -1,94 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: checklst.cpp -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/defs.h" - -#if wxUSE_CHECKLISTBOX - -#include "wx/checklst.h" -#include "wx/gtk/private.h" - -#include -#include - -//----------------------------------------------------------------------------- -// wxCheckListBox -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox,wxListBox) - -wxCheckListBox::wxCheckListBox() : wxListBox() -{ - m_hasCheckBoxes = TRUE; -} - -wxCheckListBox::wxCheckListBox(wxWindow *parent, wxWindowID id, - const wxPoint& pos, - const wxSize& size, - int nStrings, - const wxString *choices, - long style, - const wxValidator& validator, - const wxString& name ) -{ - m_hasCheckBoxes = TRUE; - wxListBox::Create( parent, id, pos, size, nStrings, choices, style, validator, name ); -} - -bool wxCheckListBox::IsChecked( int index ) const -{ - wxCHECK_MSG( m_list != NULL, FALSE, wxT("invalid checklistbox") ); - - GList *child = g_list_nth( m_list->children, index ); - if (child) - { - GtkBin *bin = GTK_BIN( child->data ); - GtkLabel *label = GTK_LABEL( bin->child ); - - wxString str( wxGTK_CONV_BACK( label->label ) ); - - return str.GetChar(1) == wxCHECKLBOX_CHECKED; - } - - wxFAIL_MSG(wxT("wrong checklistbox index")); - return FALSE; -} - -void wxCheckListBox::Check( int index, bool check ) -{ - wxCHECK_RET( m_list != NULL, wxT("invalid checklistbox") ); - - GList *child = g_list_nth( m_list->children, index ); - if (child) - { - GtkBin *bin = GTK_BIN( child->data ); - GtkLabel *label = GTK_LABEL( bin->child ); - - wxString str( wxGTK_CONV_BACK( label->label ) ); - - if (check == (str.GetChar(1) == wxCHECKLBOX_CHECKED)) - return; - - str.SetChar( 1, check ? wxCHECKLBOX_CHECKED : wxCHECKLBOX_UNCHECKED ); - - gtk_label_set( label, wxGTK_CONV( str ) ); - - return; - } - - wxFAIL_MSG(wxT("wrong checklistbox index")); -} - -int wxCheckListBox::GetItemHeight() const -{ - // FIXME - return 22; -} - -#endif diff --git a/src/gtk1/choice.cpp b/src/gtk1/choice.cpp deleted file mode 100644 index 004dfcc784..0000000000 --- a/src/gtk1/choice.cpp +++ /dev/null @@ -1,510 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: choice.cpp -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/defs.h" - -#if wxUSE_CHOICE - -#include "wx/choice.h" - -#include "wx/gtk/private.h" - -//----------------------------------------------------------------------------- -// idle system -//----------------------------------------------------------------------------- - -extern void wxapp_install_idle_handler(); -extern bool g_isIdle; - -//----------------------------------------------------------------------------- -// data -//----------------------------------------------------------------------------- - -extern bool g_blockEventsOnDrag; - -//----------------------------------------------------------------------------- -// "activate" -//----------------------------------------------------------------------------- - -static void gtk_choice_clicked_callback( GtkWidget *WXUNUSED(widget), wxChoice *choice ) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - - if (!choice->m_hasVMT) return; - - if (g_blockEventsOnDrag) return; - - wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, choice->GetId() ); - int n = choice->GetSelection(); - - event.SetInt( n ); - event.SetString( choice->GetStringSelection() ); - event.SetEventObject(choice); - - if ( choice->HasClientObjectData() ) - event.SetClientObject( choice->GetClientObject(n) ); - else if ( choice->HasClientUntypedData() ) - event.SetClientData( choice->GetClientData(n) ); - - choice->GetEventHandler()->ProcessEvent(event); -} - -//----------------------------------------------------------------------------- -// wxChoice -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxChoice,wxControl) - -wxChoice::wxChoice() -{ - m_strings = (wxSortedArrayString *)NULL; -} - -bool wxChoice::Create( wxWindow *parent, wxWindowID id, - const wxPoint &pos, const wxSize &size, - int n, const wxString choices[], - long style, const wxValidator& validator, const wxString &name ) -{ - m_needParent = TRUE; -#if (GTK_MINOR_VERSION > 0) - m_acceptsFocus = TRUE; -#endif - - if (!PreCreation( parent, pos, size ) || - !CreateBase( parent, id, pos, size, style, validator, name )) - { - wxFAIL_MSG( wxT("wxChoice creation failed") ); - return FALSE; - } - - m_widget = gtk_option_menu_new(); - - if ( style & wxCB_SORT ) - { - // if our m_strings != NULL, DoAppend() will check for it and insert - // items in the correct order - m_strings = new wxSortedArrayString; - } - - GtkWidget *menu = gtk_menu_new(); - - for (int i = 0; i < n; i++) - { - GtkAppendHelper(menu, choices[i]); - } - - gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu ); - - m_parent->DoAddChild( this ); - - PostCreation(); - - SetFont( parent->GetFont() ); - - SetBestSize(size); - - SetBackgroundColour( parent->GetBackgroundColour() ); - SetForegroundColour( parent->GetForegroundColour() ); - - Show( TRUE ); - - return TRUE; -} - -wxChoice::~wxChoice() -{ - Clear(); - - delete m_strings; -} - -int wxChoice::DoAppend( const wxString &item ) -{ - wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid choice control") ); - - GtkWidget *menu = gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ); - - return GtkAppendHelper(menu, item); -} - -void wxChoice::DoSetItemClientData( int n, void* clientData ) -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid choice control") ); - - wxNode *node = m_clientList.Nth( n ); - wxCHECK_RET( node, wxT("invalid index in wxChoice::DoSetItemClientData") ); - - node->SetData( (wxObject*) clientData ); -} - -void* wxChoice::DoGetItemClientData( int n ) const -{ - wxCHECK_MSG( m_widget != NULL, NULL, wxT("invalid choice control") ); - - wxNode *node = m_clientList.Nth( n ); - wxCHECK_MSG( node, NULL, wxT("invalid index in wxChoice::DoGetItemClientData") ); - - return node->Data(); -} - -void wxChoice::DoSetItemClientObject( int n, wxClientData* clientData ) -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid choice control") ); - - wxNode *node = m_clientList.Nth( n ); - wxCHECK_RET( node, wxT("invalid index in wxChoice::DoSetItemClientObject") ); - - // wxItemContainer already deletes data for us - - node->SetData( (wxObject*) clientData ); -} - -wxClientData* wxChoice::DoGetItemClientObject( int n ) const -{ - wxCHECK_MSG( m_widget != NULL, (wxClientData*) NULL, wxT("invalid choice control") ); - - wxNode *node = m_clientList.Nth( n ); - wxCHECK_MSG( node, (wxClientData *)NULL, - wxT("invalid index in wxChoice::DoGetItemClientObject") ); - - return (wxClientData*) node->Data(); -} - -void wxChoice::Clear() -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid choice") ); - - gtk_option_menu_remove_menu( GTK_OPTION_MENU(m_widget) ); - GtkWidget *menu = gtk_menu_new(); - gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu ); - - if ( HasClientObjectData() ) - { - // destroy the data (due to Robert's idea of using wxList - // and not wxList we can't just say - // m_clientList.DeleteContents(TRUE) - this would crash! - wxNode *node = m_clientList.First(); - while ( node ) - { - delete (wxClientData *)node->Data(); - node = node->Next(); - } - } - m_clientList.Clear(); - - if ( m_strings ) - m_strings->Clear(); -} - -void wxChoice::Delete( int n ) -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid choice") ); - - // VZ: apparently GTK+ doesn't have a built-in function to do it (not even - // in 2.0), hence this dump implementation - still better than nothing - int i, - count = GetCount(); - - wxCHECK_RET( n >= 0 && n < count, _T("invalid index in wxChoice::Delete") ); - - wxArrayString items; - items.Alloc(count); - for ( i = 0; i < count; i++ ) - { - if ( i != n ) - items.Add(GetString(i)); - } - - Clear(); - - for ( i = 0; i < count - 1; i++ ) - { - Append(items[i]); - } -} - -int wxChoice::FindString( const wxString &string ) const -{ - wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid choice") ); - - // If you read this code once and you think you understand - // it, then you are very wrong. Robert Roebling. - - GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) ); - int count = 0; - GList *child = menu_shell->children; - while (child) - { - GtkBin *bin = GTK_BIN( child->data ); - GtkLabel *label = (GtkLabel *) NULL; - if (bin->child) - label = GTK_LABEL(bin->child); - if (!label) - label = GTK_LABEL( BUTTON_CHILD(m_widget) ); - - wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") ); - -#ifdef __WXGTK20__ - wxString tmp( wxGTK_CONV_BACK( gtk_label_get_text( label) ) ); -#else - wxString tmp( label->label ); -#endif - if (string == tmp) - return count; - - child = child->next; - count++; - } - - return -1; -} - -int wxChoice::GetSelection() const -{ - wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid choice") ); - -#ifdef __WXGTK20__ - - return gtk_option_menu_get_history( GTK_OPTION_MENU(m_widget) ); - -#else - GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) ); - int count = 0; - - GList *child = menu_shell->children; - while (child) - { - GtkBin *bin = GTK_BIN( child->data ); - if (!bin->child) return count; - child = child->next; - count++; - } - - return -1; -#endif -} - -void wxChoice::SetString( int n, const wxString& str ) -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid choice") ); - - GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) ); - int count = 0; - GList *child = menu_shell->children; - while (child) - { - GtkBin *bin = GTK_BIN( child->data ); - if (count == n) - { - GtkLabel *label = (GtkLabel *) NULL; - if (bin->child) - label = GTK_LABEL(bin->child); - if (!label) - label = GTK_LABEL( BUTTON_CHILD(m_widget) ); - - wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") ); - - gtk_label_set_text( label, wxGTK_CONV( str ) ); - - return; - } - child = child->next; - count++; - } -} - -wxString wxChoice::GetString( int n ) const -{ - wxCHECK_MSG( m_widget != NULL, wxT(""), wxT("invalid choice") ); - - GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) ); - int count = 0; - GList *child = menu_shell->children; - while (child) - { - GtkBin *bin = GTK_BIN( child->data ); - if (count == n) - { - GtkLabel *label = (GtkLabel *) NULL; - if (bin->child) - label = GTK_LABEL(bin->child); - if (!label) - label = GTK_LABEL( BUTTON_CHILD(m_widget) ); - - wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") ); - -#ifdef __WXGTK20__ - return wxString( wxGTK_CONV_BACK( gtk_label_get_text( label) ) ); -#else - return wxString( label->label ); -#endif - } - child = child->next; - count++; - } - - wxFAIL_MSG( wxT("wxChoice: invalid index in GetString()") ); - - return wxT(""); -} - -int wxChoice::GetCount() const -{ - wxCHECK_MSG( m_widget != NULL, 0, wxT("invalid choice") ); - - GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) ); - int count = 0; - GList *child = menu_shell->children; - while (child) - { - count++; - child = child->next; - } - return count; -} - -void wxChoice::SetSelection( int n ) -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid choice") ); - - int tmp = n; - gtk_option_menu_set_history( GTK_OPTION_MENU(m_widget), (gint)tmp ); -} - -void wxChoice::ApplyWidgetStyle() -{ - SetWidgetStyle(); - - GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) ); - - gtk_widget_set_style( m_widget, m_widgetStyle ); - gtk_widget_set_style( GTK_WIDGET( menu_shell ), m_widgetStyle ); - - GList *child = menu_shell->children; - while (child) - { - gtk_widget_set_style( GTK_WIDGET( child->data ), m_widgetStyle ); - - GtkBin *bin = GTK_BIN( child->data ); - GtkWidget *label = (GtkWidget *) NULL; - if (bin->child) - label = bin->child; - if (!label) - label = BUTTON_CHILD(m_widget); - - gtk_widget_set_style( label, m_widgetStyle ); - - child = child->next; - } -} - -size_t wxChoice::GtkAppendHelper(GtkWidget *menu, const wxString& item) -{ - GtkWidget *menu_item = gtk_menu_item_new_with_label( wxGTK_CONV( item ) ); - - size_t index; - if ( m_strings ) - { - // sorted control, need to insert at the correct index - index = m_strings->Add(item); - - gtk_menu_insert( GTK_MENU(menu), menu_item, index ); - - if ( index ) - { - m_clientList.Insert( m_clientList.Item(index - 1), - (wxObject*) NULL ); - } - else - { - m_clientList.Insert( (wxObject*) NULL ); - } - } - else - { - // normal control, just append - gtk_menu_append( GTK_MENU(menu), menu_item ); - - m_clientList.Append( (wxObject*) NULL ); - - // don't call wxChoice::GetCount() from here because it doesn't work - // if we're called from ctor (and GtkMenuShell is still NULL) - index = m_clientList.GetCount() - 1; - } - - if (GTK_WIDGET_REALIZED(m_widget)) - { - gtk_widget_realize( menu_item ); - gtk_widget_realize( GTK_BIN(menu_item)->child ); - - if (m_widgetStyle) ApplyWidgetStyle(); - } - - gtk_signal_connect( GTK_OBJECT( menu_item ), "activate", - GTK_SIGNAL_FUNC(gtk_choice_clicked_callback), (gpointer*)this ); - - gtk_widget_show( menu_item ); - - // return the index of the item in the control - return index; -} - -wxSize wxChoice::DoGetBestSize() const -{ - wxSize ret( wxControl::DoGetBestSize() ); - - // we know better our horizontal extent: it depends on the longest string - // we have - ret.x = 0; - if ( m_widget ) - { - int width; - size_t count = GetCount(); - for ( size_t n = 0; n < count; n++ ) - { - GetTextExtent( GetString(n), &width, NULL, NULL, NULL, &m_font ); - if ( width > ret.x ) - ret.x = width; - } - - // add extra for the choice "=" button - - // VZ: I don't know how to get the right value, it seems to be in - // GtkOptionMenuProps struct from gtkoptionmenu.c but we can't get - // to it - maybe we can use gtk_option_menu_size_request() for this - // somehow? - // - // This default value works only for the default GTK+ theme (i.e. - // no theme at all) (FIXME) - static const int widthChoiceIndicator = 35; - ret.x += widthChoiceIndicator; - } - - // but not less than the minimal width - if ( ret.x < 80 ) - ret.x = 80; - - ret.y = 16 + GetCharHeight(); - - return ret; -} - -bool wxChoice::IsOwnGtkWindow( GdkWindow *window ) -{ -#ifdef __WXGTK20__ - return GTK_BUTTON(m_widget)->event_window; -#else - return (window == m_widget->window); -#endif -} - - -#endif // wxUSE_CHOICE - diff --git a/src/gtk1/clipbrd.cpp b/src/gtk1/clipbrd.cpp deleted file mode 100644 index 9574119808..0000000000 --- a/src/gtk1/clipbrd.cpp +++ /dev/null @@ -1,595 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: gtk/clipbrd.cpp -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/clipbrd.h" - -#if wxUSE_CLIPBOARD - -#include "wx/dataobj.h" -#include "wx/utils.h" -#include "wx/log.h" - -#include -#include -#include - -//----------------------------------------------------------------------------- -// thread system -//----------------------------------------------------------------------------- - -#if wxUSE_THREADS -#endif - -//----------------------------------------------------------------------------- -// data -//----------------------------------------------------------------------------- - -GdkAtom g_clipboardAtom = 0; -GdkAtom g_targetsAtom = 0; - -// the trace mask we use with wxLogTrace() - call -// wxLog::AddTraceMask(TRACE_CLIPBOARD) to enable the trace messages from here -// (there will be a *lot* of them!) -static const wxChar *TRACE_CLIPBOARD = _T("clipboard"); - -//----------------------------------------------------------------------------- -// reminder -//----------------------------------------------------------------------------- - -/* The contents of a selection are returned in a GtkSelectionData - structure. selection/target identify the request. - type specifies the type of the return; if length < 0, and - the data should be ignored. This structure has object semantics - - no fields should be modified directly, they should not be created - directly, and pointers to them should not be stored beyond the duration of - a callback. (If the last is changed, we'll need to add reference - counting) - -struct _GtkSelectionData -{ - GdkAtom selection; - GdkAtom target; - GdkAtom type; - gint format; - guchar *data; - gint length; -}; - -*/ - -//----------------------------------------------------------------------------- -// "selection_received" for targets -//----------------------------------------------------------------------------- - -static void -targets_selection_received( GtkWidget *WXUNUSED(widget), - GtkSelectionData *selection_data, - guint32 WXUNUSED(time), - wxClipboard *clipboard ) -{ - if ( wxTheClipboard && selection_data->length > 0 ) - { - // make sure we got the data in the correct form - GdkAtom type = selection_data->type; - if ( type != GDK_SELECTION_TYPE_ATOM ) - { - if ( strcmp(gdk_atom_name(type), "TARGETS") ) - { - wxLogTrace( TRACE_CLIPBOARD, - _T("got unsupported clipboard target") ); - - clipboard->m_waiting = FALSE; - return; - } - } - -#ifdef __WXDEBUG__ - wxDataFormat clip( selection_data->selection ); - wxLogTrace( TRACE_CLIPBOARD, - wxT("selection received for targets, clipboard %s"), - clip.GetId().c_str() ); -#endif // __WXDEBUG__ - - // the atoms we received, holding a list of targets (= formats) - GdkAtom *atoms = (GdkAtom *)selection_data->data; - - for (unsigned int i=0; ilength/sizeof(GdkAtom); i++) - { - wxDataFormat format( atoms[i] ); - - wxLogTrace( TRACE_CLIPBOARD, - wxT("selection received for targets, format %s"), - format.GetId().c_str() ); - -// printf( "format %s requested %s\n", -// gdk_atom_name( atoms[i] ), -// gdk_atom_name( clipboard->m_targetRequested ) ); - - if (format == clipboard->m_targetRequested) - { - clipboard->m_waiting = FALSE; - clipboard->m_formatSupported = TRUE; - return; - } - } - } - - clipboard->m_waiting = FALSE; -} - -//----------------------------------------------------------------------------- -// "selection_received" for the actual data -//----------------------------------------------------------------------------- - -static void -selection_received( GtkWidget *WXUNUSED(widget), - GtkSelectionData *selection_data, - guint32 WXUNUSED(time), - wxClipboard *clipboard ) -{ - if (!wxTheClipboard) - { - clipboard->m_waiting = FALSE; - return; - } - - wxDataObject *data_object = clipboard->m_receivedData; - - if (!data_object) - { - clipboard->m_waiting = FALSE; - return; - } - - if (selection_data->length <= 0) - { - clipboard->m_waiting = FALSE; - return; - } - - wxDataFormat format( selection_data->target ); - - // make sure we got the data in the correct format - if (!data_object->IsSupportedFormat( format ) ) - { - clipboard->m_waiting = FALSE; - return; - } - - /* make sure we got the data in the correct form (selection type). - if so, copy data to target object */ - if (selection_data->type != GDK_SELECTION_TYPE_STRING) - { - clipboard->m_waiting = FALSE; - return; - } - - data_object->SetData( format, (size_t) selection_data->length, (const char*) selection_data->data ); - - wxTheClipboard->m_formatSupported = TRUE; - clipboard->m_waiting = FALSE; -} - -//----------------------------------------------------------------------------- -// "selection_clear" -//----------------------------------------------------------------------------- - -static gint -selection_clear_clip( GtkWidget *WXUNUSED(widget), GdkEventSelection *event ) -{ - if (!wxTheClipboard) return TRUE; - - if (event->selection == GDK_SELECTION_PRIMARY) - { - wxTheClipboard->m_ownsPrimarySelection = FALSE; - } - else - if (event->selection == g_clipboardAtom) - { - wxTheClipboard->m_ownsClipboard = FALSE; - } - else - { - wxTheClipboard->m_waiting = FALSE; - return FALSE; - } - - if ((!wxTheClipboard->m_ownsPrimarySelection) && - (!wxTheClipboard->m_ownsClipboard)) - { - /* the clipboard is no longer in our hands. we can the delete clipboard data. */ - if (wxTheClipboard->m_data) - { - wxLogTrace(TRACE_CLIPBOARD, wxT("wxClipboard will get cleared" )); - - delete wxTheClipboard->m_data; - wxTheClipboard->m_data = (wxDataObject*) NULL; - } - } - - wxTheClipboard->m_waiting = FALSE; - return TRUE; -} - -//----------------------------------------------------------------------------- -// selection handler for supplying data -//----------------------------------------------------------------------------- - -static void -selection_handler( GtkWidget *WXUNUSED(widget), - GtkSelectionData *selection_data, - guint WXUNUSED(info), - guint WXUNUSED(time), - gpointer WXUNUSED(data) ) -{ - if (!wxTheClipboard) return; - - if (!wxTheClipboard->m_data) return; - - wxDataObject *data = wxTheClipboard->m_data; - - wxDataFormat format( selection_data->target ); - - if (!data->IsSupportedFormat( format )) return; - - int size = data->GetDataSize( format ); - - if (size == 0) return; - - void *d = malloc(size); - - // Text data will be in UTF8 in Unicode mode. - data->GetDataHere( selection_data->target, d ); - - gtk_selection_data_set( - selection_data, - GDK_SELECTION_TYPE_STRING, - 8*sizeof(gchar), - (unsigned char*) d, - size ); - - free(d); -} - -//----------------------------------------------------------------------------- -// wxClipboard -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxClipboard,wxObject) - -wxClipboard::wxClipboard() -{ - m_open = FALSE; - - m_ownsClipboard = FALSE; - m_ownsPrimarySelection = FALSE; - - m_data = (wxDataObject*) NULL; - 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 ), - (gpointer) NULL ); - - if (!g_clipboardAtom) g_clipboardAtom = gdk_atom_intern( "CLIPBOARD", FALSE ); - if (!g_targetsAtom) g_targetsAtom = gdk_atom_intern ("TARGETS", FALSE); - - m_formatSupported = FALSE; - m_targetRequested = 0; - - m_usePrimary = FALSE; -} - -wxClipboard::~wxClipboard() -{ - Clear(); - - if (m_clipboardWidget) gtk_widget_destroy( m_clipboardWidget ); - if (m_targetsWidget) gtk_widget_destroy( m_targetsWidget ); -} - -void wxClipboard::Clear() -{ - if (m_data) - { -#if wxUSE_THREADS - /* disable GUI threads */ -#endif - - // As we have data we also own the clipboard. Once we no longer own - // it, clear_selection is called which will set m_data to zero - if (gdk_selection_owner_get( g_clipboardAtom ) == m_clipboardWidget->window) - { - m_waiting = TRUE; - - gtk_selection_owner_set( (GtkWidget*) NULL, g_clipboardAtom, - (guint32) GDK_CURRENT_TIME ); - - while (m_waiting) gtk_main_iteration(); - } - - if (gdk_selection_owner_get( GDK_SELECTION_PRIMARY ) == m_clipboardWidget->window) - { - m_waiting = TRUE; - - gtk_selection_owner_set( (GtkWidget*) NULL, GDK_SELECTION_PRIMARY, - (guint32) GDK_CURRENT_TIME ); - - while (m_waiting) gtk_main_iteration(); - } - - if (m_data) - { - delete m_data; - m_data = (wxDataObject*) NULL; - } - -#if wxUSE_THREADS - /* re-enable GUI threads */ -#endif - } - - m_targetRequested = 0; - m_formatSupported = FALSE; -} - -bool wxClipboard::Open() -{ - wxCHECK_MSG( !m_open, FALSE, wxT("clipboard already open") ); - - m_open = TRUE; - - return TRUE; -} - -bool wxClipboard::SetData( wxDataObject *data ) -{ - wxCHECK_MSG( m_open, FALSE, wxT("clipboard not open") ); - - wxCHECK_MSG( data, FALSE, wxT("data is invalid") ); - - Clear(); - - return AddData( data ); -} - -bool wxClipboard::AddData( wxDataObject *data ) -{ - wxCHECK_MSG( m_open, FALSE, wxT("clipboard not open") ); - - wxCHECK_MSG( data, FALSE, wxT("data is invalid") ); - - // we can only store one wxDataObject - Clear(); - - m_data = data; - - // get formats from wxDataObjects - wxDataFormat *array = new wxDataFormat[ m_data->GetFormatCount() ]; - m_data->GetAllFormats( array ); - - // primary selection or clipboard - GdkAtom clipboard = m_usePrimary ? (GdkAtom)GDK_SELECTION_PRIMARY - : g_clipboardAtom; - - - for (size_t i = 0; i < m_data->GetFormatCount(); i++) - { - wxLogTrace( TRACE_CLIPBOARD, - wxT("wxClipboard now supports atom %s"), - array[i].GetId().c_str() ); - -// printf( "added %s\n", -// gdk_atom_name( array[i].GetFormatId() ) ); - - gtk_selection_add_target( GTK_WIDGET(m_clipboardWidget), - clipboard, - array[i], - 0 ); /* what is info ? */ - } - - delete[] array; - - gtk_signal_connect( GTK_OBJECT(m_clipboardWidget), - "selection_get", - GTK_SIGNAL_FUNC(selection_handler), - (gpointer) NULL ); - -#if wxUSE_THREADS - /* disable GUI threads */ -#endif - - /* Tell the world we offer clipboard data */ - bool res = (gtk_selection_owner_set( m_clipboardWidget, - clipboard, - (guint32) GDK_CURRENT_TIME )); - - if (m_usePrimary) - m_ownsPrimarySelection = res; - else - m_ownsClipboard = res; - -#if wxUSE_THREADS - /* re-enable GUI threads */ -#endif - - return res; -} - -void wxClipboard::Close() -{ - wxCHECK_RET( m_open, wxT("clipboard not open") ); - - m_open = FALSE; -} - -bool wxClipboard::IsOpened() const -{ - return m_open; -} - -bool wxClipboard::IsSupported( const wxDataFormat& format ) -{ - /* reentrance problems */ - if (m_waiting) return FALSE; - - /* store requested format to be asked for by callbacks */ - m_targetRequested = format; - -#if 0 - wxLogTrace( TRACE_CLIPBOARD, - wxT("wxClipboard:IsSupported: requested format: %s"), - format.GetId().c_str() ); -#endif - - wxCHECK_MSG( m_targetRequested, FALSE, wxT("invalid clipboard format") ); - - m_formatSupported = FALSE; - - /* perform query. 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 */ - - m_waiting = TRUE; - - gtk_selection_convert( m_targetsWidget, - m_usePrimary ? (GdkAtom)GDK_SELECTION_PRIMARY - : g_clipboardAtom, - g_targetsAtom, - (guint32) GDK_CURRENT_TIME ); - - while (m_waiting) gtk_main_iteration(); - - if (!m_formatSupported) return FALSE; - - return TRUE; -} - -bool wxClipboard::GetData( wxDataObject& data ) -{ - wxCHECK_MSG( m_open, FALSE, wxT("clipboard not open") ); - - /* get formats from wxDataObjects */ - wxDataFormat *array = new wxDataFormat[ data.GetFormatCount() ]; - data.GetAllFormats( array ); - - for (size_t i = 0; i < data.GetFormatCount(); i++) - { - wxDataFormat format( array[i] ); - - wxLogTrace( TRACE_CLIPBOARD, - wxT("wxClipboard::GetData: requested format: %s"), - format.GetId().c_str() ); - - /* is data supported by clipboard ? */ - - /* store requested format to be asked for by callbacks */ - m_targetRequested = format; - - wxCHECK_MSG( m_targetRequested, FALSE, wxT("invalid clipboard format") ); - - m_formatSupported = FALSE; - - /* perform query. 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 */ - - m_waiting = TRUE; - - gtk_selection_convert( m_targetsWidget, - m_usePrimary ? (GdkAtom)GDK_SELECTION_PRIMARY - : g_clipboardAtom, - g_targetsAtom, - (guint32) GDK_CURRENT_TIME ); - - while (m_waiting) gtk_main_iteration(); - - if (!m_formatSupported) continue; - - /* store pointer to data object to be filled up by callbacks */ - m_receivedData = &data; - - /* store requested format to be asked for by callbacks */ - m_targetRequested = format; - - wxCHECK_MSG( m_targetRequested, FALSE, wxT("invalid clipboard format") ); - - /* start query */ - m_formatSupported = FALSE; - - /* 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 */ - - m_waiting = TRUE; - - wxLogTrace( TRACE_CLIPBOARD, - wxT("wxClipboard::GetData: format found, start convert") ); - - gtk_selection_convert( m_clipboardWidget, - m_usePrimary ? (GdkAtom)GDK_SELECTION_PRIMARY - : g_clipboardAtom, - m_targetRequested, - (guint32) GDK_CURRENT_TIME ); - - while (m_waiting) gtk_main_iteration(); - - /* this is a true error as we checked for the presence of such data before */ - wxCHECK_MSG( m_formatSupported, FALSE, wxT("error retrieving data from clipboard") ); - - /* return success */ - delete[] array; - return TRUE; - } - - wxLogTrace( TRACE_CLIPBOARD, - wxT("wxClipboard::GetData: format not found") ); - - /* return failure */ - delete[] array; - return FALSE; -} - -#endif - // wxUSE_CLIPBOARD - diff --git a/src/gtk1/colour.cpp b/src/gtk1/colour.cpp deleted file mode 100644 index f38ff726cd..0000000000 --- a/src/gtk1/colour.cpp +++ /dev/null @@ -1,267 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: colour.cpp -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/gdicmn.h" -#include "wx/gtk/private.h" - -#include -#include -#include - -//----------------------------------------------------------------------------- -// wxColour -//----------------------------------------------------------------------------- - -class wxColourRefData: public wxObjectRefData -{ -public: - wxColourRefData() - { - m_color.red = 0; - m_color.green = 0; - m_color.blue = 0; - m_color.pixel = 0; - m_colormap = (GdkColormap *) NULL; - m_hasPixel = FALSE; - } - - wxColourRefData(const wxColourRefData& data) - : wxObjectRefData() - { - m_color = data.m_color; - m_colormap = data.m_colormap; - m_hasPixel = data.m_hasPixel; - } - - ~wxColourRefData() - { - FreeColour(); - } - - bool operator == (const wxColourRefData& data) const - { - return (m_colormap == data.m_colormap && - m_hasPixel == data.m_hasPixel && - m_color.red == data.m_color.red && - m_color.green == data.m_color.green && - m_color.blue == data.m_color.blue && - m_color.pixel == data.m_color.pixel); - } - - void FreeColour(); - void AllocColour( GdkColormap* cmap ); - - GdkColor m_color; - GdkColormap *m_colormap; - bool m_hasPixel; - - friend class wxColour; - - // reference counter for systems with <= 8-Bit display - static gushort colMapAllocCounter[ 256 ]; -}; - -gushort wxColourRefData::colMapAllocCounter[ 256 ] = -{ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; - -void wxColourRefData::FreeColour() -{ - if (m_colormap) - { -#ifdef __WXGTK20__ - if ((m_colormap->visual->type == GDK_VISUAL_GRAYSCALE) || - (m_colormap->visual->type == GDK_VISUAL_PSEUDO_COLOR)) -#else - GdkColormapPrivate *private_colormap = (GdkColormapPrivate*) m_colormap; - if ((private_colormap->visual->type == GDK_VISUAL_GRAYSCALE) || - (private_colormap->visual->type == GDK_VISUAL_PSEUDO_COLOR)) -#endif - { - int idx = m_color.pixel; - colMapAllocCounter[ idx ] = colMapAllocCounter[ idx ] - 1; - - if (colMapAllocCounter[ idx ] == 0) - gdk_colormap_free_colors( m_colormap, &m_color, 1 ); - } - } -} - -void wxColourRefData::AllocColour( GdkColormap *cmap ) -{ - if (m_hasPixel && (m_colormap == cmap)) - return; - - FreeColour(); - -#ifdef __WXGTK20__ - if ( (cmap->visual->type == GDK_VISUAL_GRAYSCALE) || - (cmap->visual->type == GDK_VISUAL_PSEUDO_COLOR) ) -#else - GdkColormapPrivate *private_colormap = (GdkColormapPrivate*) cmap; - if ((private_colormap->visual->type == GDK_VISUAL_GRAYSCALE) || - (private_colormap->visual->type == GDK_VISUAL_PSEUDO_COLOR)) -#endif - { - m_hasPixel = gdk_colormap_alloc_color( cmap, &m_color, FALSE, TRUE ); - int idx = m_color.pixel; - colMapAllocCounter[ idx ] = colMapAllocCounter[ idx ] + 1; - } - else - { - m_hasPixel = gdk_color_alloc( cmap, &m_color ); - } - m_colormap = cmap; -} - -//----------------------------------------------------------------------------- - -#define M_COLDATA ((wxColourRefData *)m_refData) - -#define SHIFT (8*(sizeof(short int)-sizeof(char))) - -IMPLEMENT_DYNAMIC_CLASS(wxColour,wxGDIObject) - -wxColour::wxColour( unsigned char red, unsigned char green, unsigned char blue ) -{ - m_refData = new wxColourRefData(); - M_COLDATA->m_color.red = ((unsigned short)red) << SHIFT; - M_COLDATA->m_color.green = ((unsigned short)green) << SHIFT; - M_COLDATA->m_color.blue = ((unsigned short)blue) << SHIFT; - M_COLDATA->m_color.pixel = 0; -} - -void wxColour::InitFromName( const wxString &colourName ) -{ - wxNode *node = (wxNode *) NULL; - if ( (wxTheColourDatabase) && (node = wxTheColourDatabase->Find(colourName)) ) - { - wxColour *col = (wxColour*)node->Data(); - UnRef(); - if (col) Ref( *col ); - } - else - { - m_refData = new wxColourRefData(); - - if (!gdk_color_parse( wxGTK_CONV( colourName ), &M_COLDATA->m_color )) - { - // VZ: asserts are good in general but this one is triggered by - // calling wxColourDatabase::FindColour() with an - // unrecognized colour name and this can't be avoided from the - // user code, so don't give it here - // - // a better solution would be to changed code in FindColour() - - //wxFAIL_MSG( wxT("wxColour: couldn't find colour") ); - - delete m_refData; - m_refData = (wxObjectRefData *) NULL; - } - } -} - -wxColour::~wxColour() -{ -} - -bool wxColour::operator == ( const wxColour& col ) const -{ - if (m_refData == col.m_refData) return TRUE; - - if (!m_refData || !col.m_refData) return FALSE; - - GdkColor *own = &(((wxColourRefData*)m_refData)->m_color); - GdkColor *other = &(((wxColourRefData*)col.m_refData)->m_color); - if (own->red != other->red) return FALSE; - if (own->blue != other->blue) return FALSE; - if (own->green != other->green) return FALSE; - - return TRUE; -} - -wxObjectRefData *wxColour::CreateRefData() const -{ - return new wxColourRefData; -} - -wxObjectRefData *wxColour::CloneRefData(const wxObjectRefData *data) const -{ - return new wxColourRefData(*(wxColourRefData *)data); -} - -void wxColour::Set( unsigned char red, unsigned char green, unsigned char blue ) -{ - AllocExclusive(); - - M_COLDATA->m_color.red = ((unsigned short)red) << SHIFT; - M_COLDATA->m_color.green = ((unsigned short)green) << SHIFT; - M_COLDATA->m_color.blue = ((unsigned short)blue) << SHIFT; - M_COLDATA->m_color.pixel = 0; - - M_COLDATA->m_colormap = (GdkColormap*) NULL; - M_COLDATA->m_hasPixel = FALSE; -} - -unsigned char wxColour::Red() const -{ - wxCHECK_MSG( Ok(), 0, wxT("invalid colour") ); - - return (unsigned char)(M_COLDATA->m_color.red >> SHIFT); -} - -unsigned char wxColour::Green() const -{ - wxCHECK_MSG( Ok(), 0, wxT("invalid colour") ); - - return (unsigned char)(M_COLDATA->m_color.green >> SHIFT); -} - -unsigned char wxColour::Blue() const -{ - wxCHECK_MSG( Ok(), 0, wxT("invalid colour") ); - - return (unsigned char)(M_COLDATA->m_color.blue >> SHIFT); -} - -void wxColour::CalcPixel( GdkColormap *cmap ) -{ - if (!Ok()) return; - - M_COLDATA->AllocColour( cmap ); -} - -int wxColour::GetPixel() const -{ - wxCHECK_MSG( Ok(), 0, wxT("invalid colour") ); - - return M_COLDATA->m_color.pixel; -} - -GdkColor *wxColour::GetColor() const -{ - wxCHECK_MSG( Ok(), (GdkColor *) NULL, wxT("invalid colour") ); - - return &M_COLDATA->m_color; -} - - diff --git a/src/gtk1/combobox.cpp b/src/gtk1/combobox.cpp deleted file mode 100644 index f84751e63f..0000000000 --- a/src/gtk1/combobox.cpp +++ /dev/null @@ -1,742 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: combobox.cpp -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/combobox.h" - -#if wxUSE_COMBOBOX - -#include "wx/settings.h" -#include "wx/intl.h" - -#include "wx/textctrl.h" // for wxEVT_COMMAND_TEXT_UPDATED - -#include "wx/gtk/private.h" - -//----------------------------------------------------------------------------- -// idle system -//----------------------------------------------------------------------------- - -extern void wxapp_install_idle_handler(); -extern bool g_isIdle; - -//----------------------------------------------------------------------------- -// data -//----------------------------------------------------------------------------- - -extern bool g_blockEventsOnDrag; - -//----------------------------------------------------------------------------- -// "select-child" - click/cursor get select-child, changed, select-child -//----------------------------------------------------------------------------- - -static void -gtk_combo_select_child_callback( GtkList *WXUNUSED(list), GtkWidget *WXUNUSED(widget), wxComboBox *combo ) -{ - if (g_isIdle) wxapp_install_idle_handler(); - - if (!combo->m_hasVMT) return; - - if (g_blockEventsOnDrag) return; - - int curSelection = combo->GetSelection(); - - if (combo->m_prevSelection != curSelection) - { - GtkWidget *list = GTK_COMBO(combo->m_widget)->list; - gtk_list_unselect_item( GTK_LIST(list), combo->m_prevSelection ); - } - combo->m_prevSelection = curSelection; - - wxCommandEvent event( wxEVT_COMMAND_COMBOBOX_SELECTED, combo->GetId() ); - event.SetInt( curSelection ); - event.SetString( combo->GetStringSelection() ); - event.SetEventObject( combo ); - - combo->GetEventHandler()->ProcessEvent( event ); -} - -//----------------------------------------------------------------------------- -// "changed" - typing and list item matches get changed, select-child -// if it doesn't match an item then just get a single changed -//----------------------------------------------------------------------------- - -static void -gtk_text_changed_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo ) -{ - if (g_isIdle) wxapp_install_idle_handler(); - - if (!combo->m_hasVMT) return; - - wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, combo->GetId() ); - event.SetString( combo->GetValue() ); - event.SetEventObject( combo ); - combo->GetEventHandler()->ProcessEvent( event ); -} - -static void -gtk_dummy_callback(GtkEntry *WXUNUSED(entry), GtkCombo *WXUNUSED(combo)) -{ -} - - -//----------------------------------------------------------------------------- -// wxComboBox -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxComboBox,wxControl) - -BEGIN_EVENT_TABLE(wxComboBox, wxControl) - EVT_SIZE(wxComboBox::OnSize) - EVT_CHAR(wxComboBox::OnChar) -END_EVENT_TABLE() - -bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, - const wxPoint& pos, const wxSize& size, - int n, const wxString choices[], - long style, const wxValidator& validator, - const wxString& name ) -{ - m_alreadySent = FALSE; - m_needParent = TRUE; - m_acceptsFocus = TRUE; - m_prevSelection = 0; - - if (!PreCreation( parent, pos, size ) || - !CreateBase( parent, id, pos, size, style, validator, name )) - { - wxFAIL_MSG( wxT("wxComboBox creation failed") ); - return FALSE; - } - - m_widget = gtk_combo_new(); - GtkCombo *combo = GTK_COMBO(m_widget); - - // Disable GTK's broken events ... - gtk_signal_disconnect( GTK_OBJECT(combo->entry), combo->entry_change_id ); - // ... and add surogate handler. - combo->entry_change_id = gtk_signal_connect (GTK_OBJECT (combo->entry), "changed", - (GtkSignalFunc) gtk_dummy_callback, combo); - - // make it more useable - gtk_combo_set_use_arrows_always( GTK_COMBO(m_widget), TRUE ); - - // and case-sensitive - gtk_combo_set_case_sensitive( GTK_COMBO(m_widget), TRUE ); - - GtkWidget *list = GTK_COMBO(m_widget)->list; - -#ifndef __WXGTK20__ - // gtk_list_set_selection_mode( GTK_LIST(list), GTK_SELECTION_MULTIPLE ); -#endif - - for (int i = 0; i < n; i++) - { - GtkWidget *list_item = gtk_list_item_new_with_label( wxGTK_CONV( choices[i] ) ); - - m_clientDataList.Append( (wxObject*)NULL ); - m_clientObjectList.Append( (wxObject*)NULL ); - - gtk_container_add( GTK_CONTAINER(list), list_item ); - - gtk_widget_show( list_item ); - } - - m_parent->DoAddChild( this ); - - m_focusWidget = combo->entry; - - PostCreation(); - - ConnectWidget( combo->button ); - - // MSW's combo box shows the value and the selection is -1 - gtk_entry_set_text( GTK_ENTRY(combo->entry), wxGTK_CONV(value) ); - gtk_list_unselect_all( GTK_LIST(combo->list) ); - - if (style & wxCB_READONLY) - gtk_entry_set_editable( GTK_ENTRY( combo->entry ), FALSE ); - - gtk_signal_connect( GTK_OBJECT(combo->entry), "changed", - GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this ); - - gtk_signal_connect( GTK_OBJECT(combo->list), "select-child", - GTK_SIGNAL_FUNC(gtk_combo_select_child_callback), (gpointer)this ); - - wxSize size_best( DoGetBestSize() ); - wxSize new_size( size ); - if (new_size.x == -1) - new_size.x = size_best.x; - if (new_size.y == -1) - new_size.y = size_best.y; - if (new_size.y > size_best.y) - new_size.y = size_best.y; - if ((new_size.x != size.x) || (new_size.y != size.y)) - { - SetSize( new_size.x, new_size.y ); - - // This is required for tool bar support - gtk_widget_set_usize( m_widget, new_size.x, new_size.y ); - } - - SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) ); - SetForegroundColour( parent->GetForegroundColour() ); - - Show( TRUE ); - - return TRUE; -} - -wxComboBox::~wxComboBox() -{ - wxNode *node = m_clientObjectList.First(); - while (node) - { - wxClientData *cd = (wxClientData*)node->Data(); - if (cd) delete cd; - node = node->Next(); - } - m_clientObjectList.Clear(); - - m_clientDataList.Clear(); -} - -void wxComboBox::SetFocus() -{ - if ( m_hasFocus ) - { - // don't do anything if we already have focus - return; - } - - gtk_widget_grab_focus( m_focusWidget ); -} - -void wxComboBox::AppendCommon( const wxString &item ) -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); - - DisableEvents(); - - GtkWidget *list = GTK_COMBO(m_widget)->list; - - GtkWidget *list_item = gtk_list_item_new_with_label( wxGTK_CONV( item ) ); - - gtk_container_add( GTK_CONTAINER(list), list_item ); - - if (GTK_WIDGET_REALIZED(m_widget)) - { - gtk_widget_realize( list_item ); - gtk_widget_realize( GTK_BIN(list_item)->child ); - - if (m_widgetStyle) ApplyWidgetStyle(); - } - - gtk_widget_show( list_item ); - - EnableEvents(); -} - -void wxComboBox::Append( const wxString &item ) -{ - m_clientDataList.Append( (wxObject*) NULL ); - m_clientObjectList.Append( (wxObject*) NULL ); - - AppendCommon( item ); -} - -void wxComboBox::Append( const wxString &item, void *clientData ) -{ - m_clientDataList.Append( (wxObject*) clientData ); - m_clientObjectList.Append( (wxObject*)NULL ); - - AppendCommon( item ); -} - -void wxComboBox::Append( const wxString &item, wxClientData *clientData ) -{ - m_clientDataList.Append( (wxObject*) NULL ); - m_clientObjectList.Append( (wxObject*) clientData ); - - AppendCommon( item ); -} - -void wxComboBox::SetClientData( int n, void* clientData ) -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); - - wxNode *node = m_clientDataList.Nth( n ); - if (!node) return; - - node->SetData( (wxObject*) clientData ); -} - -void* wxComboBox::GetClientData( int n ) -{ - wxCHECK_MSG( m_widget != NULL, NULL, wxT("invalid combobox") ); - - wxNode *node = m_clientDataList.Nth( n ); - if (!node) return NULL; - - return node->Data(); -} - -void wxComboBox::SetClientObject( int n, wxClientData* clientData ) -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); - - wxNode *node = m_clientObjectList.Nth( n ); - if (!node) return; - - wxClientData *cd = (wxClientData*) node->Data(); - if (cd) delete cd; - - node->SetData( (wxObject*) clientData ); -} - -wxClientData* wxComboBox::GetClientObject( int n ) -{ - wxCHECK_MSG( m_widget != NULL, (wxClientData*)NULL, wxT("invalid combobox") ); - - wxNode *node = m_clientObjectList.Nth( n ); - if (!node) return (wxClientData*) NULL; - - return (wxClientData*) node->Data(); -} - -void wxComboBox::Clear() -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); - - DisableEvents(); - - GtkWidget *list = GTK_COMBO(m_widget)->list; - gtk_list_clear_items( GTK_LIST(list), 0, Number() ); - - wxNode *node = m_clientObjectList.First(); - while (node) - { - wxClientData *cd = (wxClientData*)node->Data(); - if (cd) delete cd; - node = node->Next(); - } - m_clientObjectList.Clear(); - - m_clientDataList.Clear(); - - EnableEvents(); -} - -void wxComboBox::Delete( int n ) -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); - - GtkList *listbox = GTK_LIST( GTK_COMBO(m_widget)->list ); - - GList *child = g_list_nth( listbox->children, n ); - - if (!child) - { - wxFAIL_MSG(wxT("wrong index")); - return; - } - - DisableEvents(); - - GList *list = g_list_append( (GList*) NULL, child->data ); - gtk_list_remove_items( listbox, list ); - g_list_free( list ); - - wxNode *node = m_clientObjectList.Nth( n ); - if (node) - { - wxClientData *cd = (wxClientData*)node->Data(); - if (cd) delete cd; - m_clientObjectList.DeleteNode( node ); - } - - node = m_clientDataList.Nth( n ); - if (node) - m_clientDataList.DeleteNode( node ); - - EnableEvents(); -} - -int wxComboBox::FindString( const wxString &item ) -{ - wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid combobox") ); - - GtkWidget *list = GTK_COMBO(m_widget)->list; - - GList *child = GTK_LIST(list)->children; - int count = 0; - while (child) - { - GtkBin *bin = GTK_BIN( child->data ); - GtkLabel *label = GTK_LABEL( bin->child ); -#ifdef __WXGTK20__ - wxString str( wxGTK_CONV_BACK( gtk_label_get_text(label) ) ); -#else - wxString str( label->label ); -#endif - if (item == str) - return count; - - count++; - child = child->next; - } - - return wxNOT_FOUND; -} - -int wxComboBox::GetSelection() const -{ - wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid combobox") ); - - GtkWidget *list = GTK_COMBO(m_widget)->list; - - GList *selection = GTK_LIST(list)->selection; - if (selection) - { - GList *child = GTK_LIST(list)->children; - int count = 0; - while (child) - { - if (child->data == selection->data) return count; - count++; - child = child->next; - } - } - - return -1; -} - -wxString wxComboBox::GetString( int n ) const -{ - wxCHECK_MSG( m_widget != NULL, wxT(""), wxT("invalid combobox") ); - - GtkWidget *list = GTK_COMBO(m_widget)->list; - - wxString str; - GList *child = g_list_nth( GTK_LIST(list)->children, n ); - if (child) - { - GtkBin *bin = GTK_BIN( child->data ); - GtkLabel *label = GTK_LABEL( bin->child ); -#ifdef __WXGTK20__ - str = wxGTK_CONV_BACK( gtk_label_get_text(label) ); -#else - str = wxString( label->label ); -#endif - } - else - { - wxFAIL_MSG( wxT("wxComboBox: wrong index") ); - } - - return str; -} - -wxString wxComboBox::GetStringSelection() const -{ - wxCHECK_MSG( m_widget != NULL, wxT(""), wxT("invalid combobox") ); - - GtkWidget *list = GTK_COMBO(m_widget)->list; - - GList *selection = GTK_LIST(list)->selection; - if (selection) - { - GtkBin *bin = GTK_BIN( selection->data ); - GtkLabel *label = GTK_LABEL( bin->child ); -#ifdef __WXGTK20__ - wxString tmp( wxGTK_CONV_BACK( gtk_label_get_text(label) ) ); -#else - wxString tmp( label->label ); -#endif - return tmp; - } - - wxFAIL_MSG( wxT("wxComboBox: no selection") ); - - return wxT(""); -} - -int wxComboBox::Number() const -{ - wxCHECK_MSG( m_widget != NULL, 0, wxT("invalid combobox") ); - - GtkWidget *list = GTK_COMBO(m_widget)->list; - - GList *child = GTK_LIST(list)->children; - int count = 0; - while (child) { count++; child = child->next; } - return count; -} - -void wxComboBox::SetSelection( int n ) -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); - - DisableEvents(); - - GtkWidget *list = GTK_COMBO(m_widget)->list; - gtk_list_unselect_item( GTK_LIST(list), m_prevSelection ); - gtk_list_select_item( GTK_LIST(list), n ); - m_prevSelection = n; - - EnableEvents(); -} - -void wxComboBox::SetStringSelection( const wxString &string ) -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); - - int res = FindString( string ); - if (res == -1) return; - SetSelection( res ); -} - -wxString wxComboBox::GetValue() const -{ - GtkEntry *entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry ); - wxString tmp( wxGTK_CONV_BACK( gtk_entry_get_text( entry ) ) ); - -#if 0 - for (int i = 0; i < wxStrlen(tmp.c_str()) +1; i++) - { - wxChar c = tmp[i]; - printf( "%d ", (int) (c) ); - } - printf( "\n" ); -#endif - - return tmp; -} - -void wxComboBox::SetValue( const wxString& value ) -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); - - GtkWidget *entry = GTK_COMBO(m_widget)->entry; - wxString tmp = wxT(""); - if (!value.IsNull()) tmp = value; - gtk_entry_set_text( GTK_ENTRY(entry), wxGTK_CONV( tmp ) ); -} - -void wxComboBox::Copy() -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); - - GtkWidget *entry = GTK_COMBO(m_widget)->entry; - gtk_editable_copy_clipboard( GTK_EDITABLE(entry) DUMMY_CLIPBOARD_ARG ); -} - -void wxComboBox::Cut() -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); - - GtkWidget *entry = GTK_COMBO(m_widget)->entry; - gtk_editable_cut_clipboard( GTK_EDITABLE(entry) DUMMY_CLIPBOARD_ARG ); -} - -void wxComboBox::Paste() -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); - - GtkWidget *entry = GTK_COMBO(m_widget)->entry; - gtk_editable_paste_clipboard( GTK_EDITABLE(entry) DUMMY_CLIPBOARD_ARG); -} - -void wxComboBox::SetInsertionPoint( long pos ) -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); - - GtkWidget *entry = GTK_COMBO(m_widget)->entry; - gtk_entry_set_position( GTK_ENTRY(entry), (int)pos ); -} - -void wxComboBox::SetInsertionPointEnd() -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); - - SetInsertionPoint( -1 ); -} - -long wxComboBox::GetInsertionPoint() const -{ - return (long) GET_EDITABLE_POS( GTK_COMBO(m_widget)->entry ); -} - -long wxComboBox::GetLastPosition() const -{ - GtkWidget *entry = GTK_COMBO(m_widget)->entry; - int pos = GTK_ENTRY(entry)->text_length; - return (long) pos-1; -} - -void wxComboBox::Replace( long from, long to, const wxString& value ) -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); - - GtkWidget *entry = GTK_COMBO(m_widget)->entry; - gtk_editable_delete_text( GTK_EDITABLE(entry), (gint)from, (gint)to ); - if (value.IsNull()) return; - gint pos = (gint)to; - -#if wxUSE_UNICODE - wxCharBuffer buffer = wxConvUTF8.cWX2MB( value ); - gtk_editable_insert_text( GTK_EDITABLE(entry), (const char*) buffer, strlen( (const char*) buffer ), &pos ); -#else - gtk_editable_insert_text( GTK_EDITABLE(entry), value.c_str(), value.Length(), &pos ); -#endif -} - -void wxComboBox::Remove(long from, long to) -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid combobox") ); - - GtkWidget *entry = GTK_COMBO(m_widget)->entry; - gtk_editable_delete_text( GTK_EDITABLE(entry), (gint)from, (gint)to ); -} - -void wxComboBox::SetSelection( long from, long to ) -{ - GtkWidget *entry = GTK_COMBO(m_widget)->entry; - gtk_editable_select_region( GTK_EDITABLE(entry), (gint)from, (gint)to ); -} - -void wxComboBox::SetEditable( bool editable ) -{ - GtkWidget *entry = GTK_COMBO(m_widget)->entry; - gtk_entry_set_editable( GTK_ENTRY(entry), editable ); -} - -void wxComboBox::OnChar( wxKeyEvent &event ) -{ - if ( event.KeyCode() == WXK_RETURN ) - { - // GTK automatically selects an item if its in the list - wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, GetId()); - event.SetString( GetValue() ); - event.SetInt( GetSelection() ); - event.SetEventObject( this ); - - if (!GetEventHandler()->ProcessEvent( event )) - { - // This will invoke the dialog default action, such - // as the clicking the default button. - - wxWindow *top_frame = m_parent; - while (top_frame->GetParent() && !(top_frame->IsTopLevel())) - top_frame = top_frame->GetParent(); - - if (top_frame && GTK_IS_WINDOW(top_frame->m_widget)) - { - GtkWindow *window = GTK_WINDOW(top_frame->m_widget); - - if (window->default_widget) - gtk_widget_activate (window->default_widget); - } - } - - // Catch GTK event so that GTK doesn't open the drop - // down list upon RETURN. - return; - } - - event.Skip(); -} - -void wxComboBox::DisableEvents() -{ - gtk_signal_disconnect_by_func( GTK_OBJECT(GTK_COMBO(m_widget)->list), - GTK_SIGNAL_FUNC(gtk_combo_select_child_callback), (gpointer)this ); - gtk_signal_disconnect_by_func( GTK_OBJECT(GTK_COMBO(m_widget)->entry), - GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this ); -} - -void wxComboBox::EnableEvents() -{ - gtk_signal_connect( GTK_OBJECT(GTK_COMBO(m_widget)->list), "select-child", - GTK_SIGNAL_FUNC(gtk_combo_select_child_callback), (gpointer)this ); - gtk_signal_connect( GTK_OBJECT(GTK_COMBO(m_widget)->entry), "changed", - GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this ); -} - -void wxComboBox::OnSize( wxSizeEvent &event ) -{ - event.Skip(); - -#if 0 - int w = 21; - gtk_widget_set_usize( GTK_COMBO(m_widget)->entry, m_width-w-1, m_height ); - - gtk_widget_set_uposition( GTK_COMBO(m_widget)->button, m_x+m_width-w, m_y ); - gtk_widget_set_usize( GTK_COMBO(m_widget)->button, w, m_height ); -#endif // 0 -} - -void wxComboBox::ApplyWidgetStyle() -{ - SetWidgetStyle(); - -// gtk_widget_set_style( GTK_COMBO(m_widget)->button, m_widgetStyle ); - gtk_widget_set_style( GTK_COMBO(m_widget)->entry, m_widgetStyle ); - gtk_widget_set_style( GTK_COMBO(m_widget)->list, m_widgetStyle ); - - GtkList *list = GTK_LIST( GTK_COMBO(m_widget)->list ); - GList *child = list->children; - while (child) - { - gtk_widget_set_style( GTK_WIDGET(child->data), m_widgetStyle ); - - GtkBin *bin = GTK_BIN(child->data); - gtk_widget_set_style( bin->child, m_widgetStyle ); - - child = child->next; - } -} - -GtkWidget* wxComboBox::GetConnectWidget() -{ - return GTK_COMBO(m_widget)->entry; -} - -bool wxComboBox::IsOwnGtkWindow( GdkWindow *window ) -{ - return ( (window == GTK_ENTRY( GTK_COMBO(m_widget)->entry )->text_area) || - (window == GTK_COMBO(m_widget)->button->window ) ); -} - -wxSize wxComboBox::DoGetBestSize() const -{ - wxSize ret( wxControl::DoGetBestSize() ); - - // we know better our horizontal extent: it depends on the longest string - // in the combobox - ret.x = 0; - if ( m_widget ) - { - int width; - size_t count = GetCount(); - for ( size_t n = 0; n < count; n++ ) - { - GetTextExtent( GetString(n), &width, NULL, NULL, NULL, &m_font ); - if ( width > ret.x ) - ret.x = width; - } - } - - // empty combobox should have some reasonable default size too - if ( ret.x < 100 ) - ret.x = 100; - return ret; -} - -#endif - diff --git a/src/gtk1/control.cpp b/src/gtk1/control.cpp deleted file mode 100644 index b68f5745b9..0000000000 --- a/src/gtk1/control.cpp +++ /dev/null @@ -1,127 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: control.cpp -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling, Julian Smart and Vadim Zeitlin -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/defs.h" - -#if wxUSE_CONTROLS - -#include "wx/control.h" - -#include - -//----------------------------------------------------------------------------- -// wxControl -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxControl, wxWindow) - -wxControl::wxControl() -{ - m_needParent = TRUE; -} - -bool wxControl::Create( wxWindow *parent, - wxWindowID id, - const wxPoint &pos, - const wxSize &size, - long style, - const wxValidator& validator, - const wxString &name ) -{ - bool ret = wxWindow::Create(parent, id, pos, size, style, name); - -#if wxUSE_VALIDATORS - SetValidator(validator); -#endif - - return ret; -} - -void wxControl::SetLabel( const wxString &label ) -{ - m_label.Empty(); - for ( const wxChar *pc = label; *pc != wxT('\0'); pc++ ) - { - if ( *pc == wxT('&') ) - { - pc++; // skip it -#if 0 // it would be unused anyhow for now - kbd interface not done yet - if ( *pc != wxT('&') ) m_chAccel = *pc; -#endif - } - m_label << *pc; - } -} - -wxString wxControl::GetLabel() const -{ - return m_label; -} - - -wxSize wxControl::DoGetBestSize() const -{ - // Do not return any arbitrary default value... - wxASSERT_MSG( m_widget, wxT("DoGetBestSize called before creation") ); - - GtkRequisition req; - req.width = 2; - req.height = 2; - (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(m_widget) )->size_request ) - (m_widget, &req ); - - return wxSize(req.width, req.height); -} - -#ifdef __WXGTK20__ -wxString wxControl::PrepareLabelMnemonics( const wxString &label ) const -{ - //Format mnemonics properly for GTK2. This can be called from GTK1.x, but - //it's not very useful because mnemonics don't exist prior to GTK2. - wxString label2; - for (size_t i = 0; i < label.Len(); i++) - { - if (label.GetChar(i) == wxT('&')) - { - //Mnemonic escape sequence "&&" is a literal "&" in the output. - if (label.GetChar(i + 1) == wxT('&')) - { - label2 << wxT('&'); - i++; - } - //Handle special case of "&_" (i.e. "_" is the mnemonic). - //FIXME - Is it possible to use "_" as a GTK mnemonic? Just use a - //dash for now. - else if (label.GetChar(i + 1) == wxT('_')) - { - label2 << wxT("_-"); - i++; - } - //Replace WX mnemonic indicator "&" with GTK indicator "_". - else - { - label2 << wxT('_'); - } - } - else if (label.GetChar(i) == wxT('_')) - { - //Escape any underlines in the string so GTK doesn't use them. - label2 << wxT("__"); - } - else - { - label2 << label.GetChar(i); - } - } - return label2; -} -#endif - -#endif // wxUSE_CONTROLS - diff --git a/src/gtk1/cross.xbm b/src/gtk1/cross.xbm deleted file mode 100644 index b07cbe7fcd..0000000000 --- a/src/gtk1/cross.xbm +++ /dev/null @@ -1,6 +0,0 @@ -#define cross_width 15 -#define cross_height 15 -static char cross_bits[] = { - 0x84, 0x10, 0x84, 0x10, 0xff, 0x7f, 0x84, 0x10, 0x84, 0x10, 0x84, 0x10, - 0x84, 0x10, 0xff, 0x7f, 0x84, 0x10, 0x84, 0x10, 0x84, 0x10, 0x84, 0x10, - 0xff, 0x7f, 0x84, 0x10, 0x84, 0x10}; diff --git a/src/gtk1/cursor.cpp b/src/gtk1/cursor.cpp deleted file mode 100644 index 483ffc9b7f..0000000000 --- a/src/gtk1/cursor.cpp +++ /dev/null @@ -1,395 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: cursor.cpp -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/cursor.h" -#include "wx/utils.h" -#include "wx/app.h" - -#include -#include - -//----------------------------------------------------------------------------- -// idle system -//----------------------------------------------------------------------------- - -extern void wxapp_install_idle_handler(); -extern bool g_isIdle; - -//----------------------------------------------------------------------------- -// wxCursor -//----------------------------------------------------------------------------- - -class wxCursorRefData: public wxObjectRefData -{ - public: - - wxCursorRefData(); - ~wxCursorRefData(); - - GdkCursor *m_cursor; -}; - -wxCursorRefData::wxCursorRefData() -{ - m_cursor = (GdkCursor *) NULL; -} - -wxCursorRefData::~wxCursorRefData() -{ - if (m_cursor) gdk_cursor_destroy( m_cursor ); -} - -//----------------------------------------------------------------------------- - -#define M_CURSORDATA ((wxCursorRefData *)m_refData) - -IMPLEMENT_DYNAMIC_CLASS(wxCursor,wxObject) - -wxCursor::wxCursor() -{ - -} - -wxCursor::wxCursor( int cursorId ) -{ - m_refData = new wxCursorRefData(); - - GdkCursorType gdk_cur = GDK_LEFT_PTR; - switch (cursorId) - { - case wxCURSOR_ARROW: // fall through to default - case wxCURSOR_DEFAULT: gdk_cur = GDK_LEFT_PTR; break; - case wxCURSOR_RIGHT_ARROW: gdk_cur = GDK_RIGHT_PTR; break; - case wxCURSOR_HAND: gdk_cur = GDK_HAND1; break; - case wxCURSOR_CROSS: gdk_cur = GDK_CROSSHAIR; break; - case wxCURSOR_SIZEWE: gdk_cur = GDK_SB_H_DOUBLE_ARROW; break; - case wxCURSOR_SIZENS: gdk_cur = GDK_SB_V_DOUBLE_ARROW; break; - case wxCURSOR_ARROWWAIT: - case wxCURSOR_WAIT: - case wxCURSOR_WATCH: gdk_cur = GDK_WATCH; break; - case wxCURSOR_SIZING: gdk_cur = GDK_SIZING; break; - case wxCURSOR_SPRAYCAN: gdk_cur = GDK_SPRAYCAN; break; - case wxCURSOR_IBEAM: gdk_cur = GDK_XTERM; break; - case wxCURSOR_PENCIL: gdk_cur = GDK_PENCIL; break; - case wxCURSOR_NO_ENTRY: gdk_cur = GDK_PIRATE; break; - case wxCURSOR_SIZENWSE: - case wxCURSOR_SIZENESW: gdk_cur = GDK_FLEUR; break; - case wxCURSOR_QUESTION_ARROW: gdk_cur = GDK_QUESTION_ARROW; break; - case wxCURSOR_PAINT_BRUSH: gdk_cur = GDK_SPRAYCAN; break; - case wxCURSOR_MAGNIFIER: gdk_cur = GDK_PLUS; break; - case wxCURSOR_CHAR: gdk_cur = GDK_XTERM; break; - case wxCURSOR_LEFT_BUTTON: gdk_cur = GDK_LEFTBUTTON; break; - case wxCURSOR_MIDDLE_BUTTON: gdk_cur = GDK_MIDDLEBUTTON; break; - case wxCURSOR_RIGHT_BUTTON: gdk_cur = GDK_RIGHTBUTTON; break; - case wxCURSOR_BULLSEYE: gdk_cur = GDK_TARGET; break; - - case wxCURSOR_POINT_LEFT: gdk_cur = GDK_SB_LEFT_ARROW; break; - case wxCURSOR_POINT_RIGHT: gdk_cur = GDK_SB_RIGHT_ARROW; break; -/* - case wxCURSOR_DOUBLE_ARROW: gdk_cur = GDK_DOUBLE_ARROW; break; - case wxCURSOR_CROSS_REVERSE: gdk_cur = GDK_CROSS_REVERSE; break; - case wxCURSOR_BASED_ARROW_UP: gdk_cur = GDK_BASED_ARROW_UP; break; - case wxCURSOR_BASED_ARROW_DOWN: gdk_cur = GDK_BASED_ARROW_DOWN; break; -*/ - default: - wxFAIL_MSG(wxT("unsupported cursor type")); - // will use the standard one - break; - } - - M_CURSORDATA->m_cursor = gdk_cursor_new( gdk_cur ); -} - -extern GtkWidget *wxGetRootWindow(); - -wxCursor::wxCursor(const char bits[], int width, int height, - int hotSpotX, int hotSpotY, - const char maskBits[], wxColour *fg, wxColour *bg) -{ - if (!maskBits) - maskBits = bits; - if (!fg) - fg = wxBLACK; - if (!bg) - bg = wxWHITE; - if (hotSpotX < 0 || hotSpotX >= width) - hotSpotX = 0; - if (hotSpotY < 0 || hotSpotY >= height) - hotSpotY = 0; - - GdkBitmap *data = gdk_bitmap_create_from_data( wxGetRootWindow()->window, (gchar *) bits, width, height ); - GdkBitmap *mask = gdk_bitmap_create_from_data( wxGetRootWindow()->window, (gchar *) maskBits, width, height); - - m_refData = new wxCursorRefData; - M_CURSORDATA->m_cursor = gdk_cursor_new_from_pixmap( - data, mask, fg->GetColor(), bg->GetColor(), - hotSpotX, hotSpotY ); - - gdk_bitmap_unref( data ); - gdk_bitmap_unref( mask ); -} - - -wxCursor::wxCursor( const wxCursor &cursor ) - : wxObject() -{ - Ref( cursor ); -} - -#if wxUSE_IMAGE - -wxCursor::wxCursor( const wxImage & image ) -{ - unsigned char * rgbBits = image.GetData(); - int w = image.GetWidth() ; - int h = image.GetHeight(); - bool bHasMask = image.HasMask(); - int imagebitcount = (w*h)/8; - - unsigned char * bits = new unsigned char [imagebitcount]; - unsigned char * maskBits = new unsigned char [imagebitcount]; - - int i, j, i8; unsigned char c, cMask; - for (i=0; i mid grey - if (c>127) - bits[i] = bits[i] | cMask; - cMask = cMask * 2; - } - } - - unsigned long keyMaskColor; - if (bHasMask) - { - unsigned char - r = image.GetMaskRed(), - g = image.GetMaskGreen(), - b = image.GetMaskBlue(); - - for (i=0; isecond.value; - key = entry->first; - if ( !bHasMask || (key != keyMaskColor) ) - { - if (value > nMost) - { - nMost = value; - colMostFreq = key; - } - else if (value > nNext) - { - nNext = value; - colNextMostFreq = key; - } - } - } - - wxColour fg = wxColour ( (unsigned char)(colMostFreq >> 16), - (unsigned char)(colMostFreq >> 8), - (unsigned char)(colMostFreq) ); - - wxColour bg = wxColour ( (unsigned char)(colNextMostFreq >> 16), - (unsigned char)(colNextMostFreq >> 8), - (unsigned char)(colNextMostFreq) ); - - int fg_intensity = fg.Red() + fg.Green() + fg.Blue(); - int bg_intensity = bg.Red() + bg.Green() + bg.Blue(); - - if (bg_intensity > fg_intensity) - { - //swap fg and bg - wxColour tmp = fg; - fg = bg; - bg = tmp; - } - - int hotSpotX; - int hotSpotY; - - if (image.HasOption(wxCUR_HOTSPOT_X)) - hotSpotX = image.GetOptionInt(wxCUR_HOTSPOT_X); - else - hotSpotX = 0; - - if (image.HasOption(wxCUR_HOTSPOT_Y)) - hotSpotY = image.GetOptionInt(wxCUR_HOTSPOT_Y); - else - hotSpotY = 0; - - if (hotSpotX < 0 || hotSpotX >= w) - hotSpotX = 0; - if (hotSpotY < 0 || hotSpotY >= h) - hotSpotY = 0; - - GdkBitmap *data = gdk_bitmap_create_from_data(wxGetRootWindow()->window, - (gchar *) bits, w, h); - GdkBitmap *mask = gdk_bitmap_create_from_data(wxGetRootWindow()->window, - (gchar *) maskBits, w, h); - - m_refData = new wxCursorRefData; - M_CURSORDATA->m_cursor = gdk_cursor_new_from_pixmap - ( - data, - mask, - fg.GetColor(), bg.GetColor(), - hotSpotX, hotSpotY - ); - - gdk_bitmap_unref( data ); - gdk_bitmap_unref( mask ); - delete [] bits; - delete [] maskBits; -} - -#endif // wxUSE_IMAGE - -wxCursor::~wxCursor() -{ -} - -wxCursor& wxCursor::operator = ( const wxCursor& cursor ) -{ - if (*this == cursor) - return (*this); - - Ref( cursor ); - - return *this; -} - -bool wxCursor::operator == ( const wxCursor& cursor ) const -{ - return m_refData == cursor.m_refData; -} - -bool wxCursor::operator != ( const wxCursor& cursor ) const -{ - return m_refData != cursor.m_refData; -} - -bool wxCursor::Ok() const -{ - return (m_refData != NULL); -} - -GdkCursor *wxCursor::GetCursor() const -{ - return M_CURSORDATA->m_cursor; -} - -//----------------------------------------------------------------------------- -// busy cursor routines -//----------------------------------------------------------------------------- - -extern wxCursor g_globalCursor; - -static wxCursor gs_savedCursor; -static int gs_busyCount = 0; - -const wxCursor &wxBusyCursor::GetStoredCursor() -{ - return gs_savedCursor; -} - -const wxCursor wxBusyCursor::GetBusyCursor() -{ - return wxCursor(wxCURSOR_WATCH); -} - -void wxEndBusyCursor() -{ - if (--gs_busyCount > 0) - return; - - wxSetCursor( gs_savedCursor ); - gs_savedCursor = wxNullCursor; - - if (wxTheApp) - wxTheApp->SendIdleEvents(); -} - -void wxBeginBusyCursor( wxCursor *WXUNUSED(cursor) ) -{ - if (gs_busyCount++ > 0) - return; - - wxASSERT_MSG( !gs_savedCursor.Ok(), - wxT("forgot to call wxEndBusyCursor, will leak memory") ); - - gs_savedCursor = g_globalCursor; - - wxSetCursor( wxCursor(wxCURSOR_WATCH) ); - - if (wxTheApp) - wxTheApp->ProcessIdle(); - - gdk_flush(); -} - -bool wxIsBusy() -{ - return gs_busyCount > 0; -} - -void wxSetCursor( const wxCursor& cursor ) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - - g_globalCursor = cursor; -} diff --git a/src/gtk1/data.cpp b/src/gtk1/data.cpp deleted file mode 100644 index 1ad7aec611..0000000000 --- a/src/gtk1/data.cpp +++ /dev/null @@ -1,166 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: data.cpp -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/defs.h" -#include "wx/object.h" -#include "wx/window.h" -#include "wx/dc.h" - -#if wxUSE_ACCEL -#include "wx/accel.h" -#endif - -#include "wx/dcps.h" -#include "wx/icon.h" - -#define _MAXPATHLEN 500 - -/* Windows List */ -wxWindowList wxTopLevelWindows; - -/* List of windows pending deletion */ -wxList wxPendingDelete; - -/* Current cursor, in order to hang on to - * cursor handle when setting the cursor globally */ -wxCursor g_globalCursor; - -/* Don't allow event propagation during drag */ -bool g_blockEventsOnDrag = FALSE; - -/* Don't allow mouse event propagation during scroll */ -bool g_blockEventsOnScroll = FALSE; - -/* Don't allow window closing if there are open dialogs */ -int g_openDialogs = 0; - -/* TRUE when the message queue is empty. this gets set to - FALSE by all event callbacks before anything else is done */ -bool g_isIdle = FALSE; - -/* Message Strings for Internationalization */ -char **wx_msg_str = (char**)NULL; - -/* For printing several pages */ -int wxPageNumber; - -// Now in prntbase.cpp -// wxPrintPaperDatabase* wxThePrintPaperDatabase = (wxPrintPaperDatabase *) NULL; - -/* GDI Object Lists */ -wxBrushList *wxTheBrushList = (wxBrushList *) NULL; -wxPenList *wxThePenList = (wxPenList *) NULL; -wxFontList *wxTheFontList = (wxFontList *) NULL; -wxColourDatabase *wxTheColourDatabase = (wxColourDatabase *) NULL; -wxBitmapList *wxTheBitmapList = (wxBitmapList *) NULL; - -/* X only font names */ -/* -wxFontNameDirectory *wxTheFontNameDirectory; -*/ - -/* Stock objects */ -wxFont *wxNORMAL_FONT; -wxFont *wxSMALL_FONT; -wxFont *wxITALIC_FONT; -wxFont *wxSWISS_FONT; - -wxPen *wxRED_PEN; -wxPen *wxCYAN_PEN; -wxPen *wxGREEN_PEN; -wxPen *wxBLACK_PEN; -wxPen *wxWHITE_PEN; -wxPen *wxTRANSPARENT_PEN; -wxPen *wxBLACK_DASHED_PEN; -wxPen *wxGREY_PEN; -wxPen *wxMEDIUM_GREY_PEN; -wxPen *wxLIGHT_GREY_PEN; - -wxBrush *wxBLUE_BRUSH; -wxBrush *wxGREEN_BRUSH; -wxBrush *wxWHITE_BRUSH; -wxBrush *wxBLACK_BRUSH; -wxBrush *wxTRANSPARENT_BRUSH; -wxBrush *wxCYAN_BRUSH; -wxBrush *wxRED_BRUSH; -wxBrush *wxGREY_BRUSH; -wxBrush *wxMEDIUM_GREY_BRUSH; -wxBrush *wxLIGHT_GREY_BRUSH; - -wxColour *wxBLACK; -wxColour *wxWHITE; -wxColour *wxGREY; -wxColour *wxRED; -wxColour *wxBLUE; -wxColour *wxGREEN; -wxColour *wxCYAN; -wxColour *wxLIGHT_GREY; - -wxCursor *wxSTANDARD_CURSOR = (wxCursor *) NULL; -wxCursor *wxHOURGLASS_CURSOR = (wxCursor *) NULL; -wxCursor *wxCROSS_CURSOR = (wxCursor *) NULL; - -/* 'Null' objects */ -#if wxUSE_ACCEL - wxAcceleratorTable wxNullAcceleratorTable; -#endif // wxUSE_ACCEL - -wxBitmap wxNullBitmap; -wxIcon wxNullIcon; -wxCursor wxNullCursor; -wxPen wxNullPen; -wxBrush wxNullBrush; -wxFont wxNullFont; -wxColour wxNullColour; -wxPalette wxNullPalette; - -/* Default window names */ -const wxChar *wxControlNameStr = wxT("control"); -const wxChar *wxButtonNameStr = wxT("button"); -const wxChar *wxCanvasNameStr = wxT("canvas"); -const wxChar *wxCheckBoxNameStr = wxT("check"); -const wxChar *wxChoiceNameStr = wxT("choice"); -const wxChar *wxComboBoxNameStr = wxT("comboBox"); -const wxChar *wxDialogNameStr = wxT("dialog"); -const wxChar *wxFrameNameStr = wxT("frame"); -const wxChar *wxGaugeNameStr = wxT("gauge"); -const wxChar *wxStaticBoxNameStr = wxT("groupBox"); -const wxChar *wxListBoxNameStr = wxT("listBox"); -const wxChar *wxStaticTextNameStr = wxT("message"); -const wxChar *wxStaticBitmapNameStr = wxT("message"); -const wxChar *wxMultiTextNameStr = wxT("multitext"); -const wxChar *wxPanelNameStr = wxT("panel"); -const wxChar *wxRadioBoxNameStr = wxT("radioBox"); -const wxChar *wxRadioButtonNameStr = wxT("radioButton"); -const wxChar *wxBitmapRadioButtonNameStr = wxT("radioButton"); -const wxChar *wxScrollBarNameStr = wxT("scrollBar"); -const wxChar *wxSliderNameStr = wxT("slider"); -const wxChar *wxStaticNameStr = wxT("static"); -const wxChar *wxTextCtrlWindowNameStr = wxT("textWindow"); -const wxChar *wxTextCtrlNameStr = wxT("text"); -const wxChar *wxVirtListBoxNameStr = wxT("virtListBox"); -const wxChar *wxButtonBarNameStr = wxT("buttonbar"); -const wxChar *wxEnhDialogNameStr = wxT("Shell"); -const wxChar *wxToolBarNameStr = wxT("toolbar"); -const wxChar *wxStatusLineNameStr = wxT("status_line"); -const wxChar *wxGetTextFromUserPromptStr = wxT("Input Text"); -const wxChar *wxMessageBoxCaptionStr = wxT("Message"); -const wxChar *wxFileSelectorPromptStr = wxT("Select a file"); -const wxChar *wxFileSelectorDefaultWildcardStr = wxT("*"); -const wxChar *wxDirDialogNameStr = wxT("wxDirCtrl"); -const wxChar *wxDirDialogDefaultFolderStr = wxT("/"); -const wxChar *wxTreeCtrlNameStr = wxT("wxTreeCtrl"); - -/* See wx/utils.h */ -const wxChar *wxFloatToStringStr = wxT("%.2f"); -const wxChar *wxDoubleToStringStr = wxT("%.2f"); - -/* Dafaults for wxWindow etc. */ -const wxSize wxDefaultSize(-1, -1); -const wxPoint wxDefaultPosition(-1, -1); diff --git a/src/gtk1/dataobj.cpp b/src/gtk1/dataobj.cpp deleted file mode 100644 index 0a32b1fbd2..0000000000 --- a/src/gtk1/dataobj.cpp +++ /dev/null @@ -1,385 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: dataobj.cpp -// Purpose: wxDataObject class -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#include "wx/dataobj.h" -#include "wx/app.h" -#include "wx/debug.h" -#include "wx/mstream.h" -#include "wx/image.h" -#include "wx/log.h" - -#include - -//------------------------------------------------------------------------- -// global data -//------------------------------------------------------------------------- - -GdkAtom g_textAtom = 0; -GdkAtom g_pngAtom = 0; -GdkAtom g_fileAtom = 0; - -//------------------------------------------------------------------------- -// wxDataFormat -//------------------------------------------------------------------------- - -wxDataFormat::wxDataFormat() -{ - // do *not* call PrepareFormats() from here for 2 reasons: - // - // 1. we will have time to do it later because some other Set function - // must be called before we really need them - // - // 2. doing so prevents us from declaring global wxDataFormats because - // calling PrepareFormats (and thus gdk_atom_intern) before GDK is - // initialised will result in a crash - m_type = wxDF_INVALID; - m_format = (GdkAtom) 0; -} - -wxDataFormat::wxDataFormat( wxDataFormatId type ) -{ - PrepareFormats(); - SetType( type ); -} - -wxDataFormat::wxDataFormat( const wxChar *id ) -{ - PrepareFormats(); - SetId( id ); -} - -wxDataFormat::wxDataFormat( const wxString &id ) -{ - PrepareFormats(); - SetId( id ); -} - -wxDataFormat::wxDataFormat( NativeFormat format ) -{ - PrepareFormats(); - SetId( format ); -} - -void wxDataFormat::SetType( wxDataFormatId type ) -{ - PrepareFormats(); - - if (type == wxDF_UNICODETEXT) - type = wxDF_TEXT; - - m_type = type; - - if (m_type == wxDF_TEXT) - m_format = g_textAtom; - else - if (m_type == wxDF_BITMAP) - m_format = g_pngAtom; - else - if (m_type == wxDF_FILENAME) - m_format = g_fileAtom; - else - { - wxFAIL_MSG( wxT("invalid dataformat") ); - } -} - -wxDataFormatId wxDataFormat::GetType() const -{ - return m_type; -} - -wxString wxDataFormat::GetId() const -{ - wxString ret = wxString::FromAscii( gdk_atom_name( m_format ) ); - return ret; -} - -void wxDataFormat::SetId( NativeFormat format ) -{ - PrepareFormats(); - m_format = format; - - if (m_format == g_textAtom) - m_type = wxDF_TEXT; - else - if (m_format == g_pngAtom) - m_type = wxDF_BITMAP; - else - if (m_format == g_fileAtom) - m_type = wxDF_FILENAME; - else - m_type = wxDF_PRIVATE; -} - -void wxDataFormat::SetId( const wxChar *id ) -{ - PrepareFormats(); - m_type = wxDF_PRIVATE; - wxString tmp( id ); - m_format = gdk_atom_intern( (const char*) tmp.ToAscii(), FALSE ); -} - -void wxDataFormat::PrepareFormats() -{ - // VZ: GNOME included in RedHat 6.1 uses the MIME types below and not the - // atoms STRING and file:ALL as the old code was, but normal X apps - // use STRING for text selection when transfering the data via - // clipboard, for example, so do use STRING for now (GNOME apps will - // probably support STRING as well for compatibility anyhow), but use - // text/uri-list for file dnd because compatibility is not important - // here (with whom?) - if (!g_textAtom) -#if wxUSE_UNICODE - g_textAtom = gdk_atom_intern( "UTF8_STRING", FALSE ); -#else - g_textAtom = gdk_atom_intern( "STRING" /* "text/plain" */, FALSE ); -#endif - if (!g_pngAtom) - g_pngAtom = gdk_atom_intern( "image/png", FALSE ); - if (!g_fileAtom) - g_fileAtom = gdk_atom_intern( "text/uri-list", FALSE ); -} - -//------------------------------------------------------------------------- -// wxDataObject -//------------------------------------------------------------------------- - -wxDataObject::wxDataObject() -{ -} - -wxDataObject::~wxDataObject() -{ - // dtor is empty but needed for Darwin and AIX -- otherwise it doesn't link -} - -bool wxDataObject::IsSupportedFormat(const wxDataFormat& format, Direction dir) const -{ - size_t nFormatCount = GetFormatCount(dir); - if ( nFormatCount == 1 ) - { - return format == GetPreferredFormat(); - } - else - { - wxDataFormat *formats = new wxDataFormat[nFormatCount]; - GetAllFormats(formats,dir); - - size_t n; - for ( n = 0; n < nFormatCount; n++ ) - { - if ( formats[n] == format ) - break; - } - - delete [] formats; - - // found? - return n < nFormatCount; - } -} - -// ---------------------------------------------------------------------------- -// wxFileDataObject -// ---------------------------------------------------------------------------- - -bool wxFileDataObject::GetDataHere(void *buf) const -{ - wxString filenames; - - for (size_t i = 0; i < m_filenames.GetCount(); i++) - { - filenames += wxT("file:"); - filenames += m_filenames[i]; - filenames += wxT("\r\n"); - } - - memcpy( buf, filenames.mbc_str(), filenames.Len() + 1 ); - - return TRUE; -} - -size_t wxFileDataObject::GetDataSize() const -{ - size_t res = 0; - - for (size_t i = 0; i < m_filenames.GetCount(); i++) - { - // This is junk in UTF-8 - res += m_filenames[i].Len(); - res += 5 + 2; // "file:" (5) + "\r\n" (2) - } - - return res + 1; -} - -bool wxFileDataObject::SetData(size_t WXUNUSED(size), const void *buf) -{ - // VZ: old format -#if 0 - // filenames are stores as a string with #0 as deliminators - const char *filenames = (const char*) buf; - size_t pos = 0; - for(;;) - { - if (filenames[0] == 0) - break; - if (pos >= size) - break; - wxString file( filenames ); // this returns the first file - AddFile( file ); - pos += file.Len()+1; - filenames += file.Len()+1; - } -#else // 1 - m_filenames.Empty(); - - // the text/uri-list format is a sequence of URIs (filenames prefixed by - // "file:" as far as I see) delimited by "\r\n" of total length size - // (I wonder what happens if the file has '\n' in its filename??) - wxString filename; - for ( const char *p = (const char *)buf; ; p++ ) - { - // some broken programs (testdnd GTK+ sample!) omit the trailing - // "\r\n", so check for '\0' explicitly here instead of doing it in - // the loop statement to account for it - if ( (*p == '\r' && *(p+1) == '\n') || !*p ) - { - size_t lenPrefix = 5; // strlen("file:") - if ( filename.Left(lenPrefix).MakeLower() == _T("file:") ) - { - // sometimes the syntax is "file:filename", sometimes it's - // URL-like: "file://filename" - deal with both - if ( filename[lenPrefix] == _T('/') && - filename[lenPrefix + 1] == _T('/') ) - { - // skip the slashes - lenPrefix += 2; - } - - AddFile(filename.c_str() + lenPrefix); - filename.Empty(); - } - else - { - wxLogDebug(_T("Unsupported URI '%s' in wxFileDataObject"), - filename.c_str()); - } - - if ( !*p ) - break; - - // skip '\r' - p++; - } - else - { - filename += *p; - } - } -#endif // 0/1 - - return TRUE; -} - -void wxFileDataObject::AddFile( const wxString &filename ) -{ - m_filenames.Add( filename ); -} - -// ---------------------------------------------------------------------------- -// wxBitmapDataObject -// ---------------------------------------------------------------------------- - -wxBitmapDataObject::wxBitmapDataObject() -{ - Init(); -} - -wxBitmapDataObject::wxBitmapDataObject( const wxBitmap& bitmap ) - : wxBitmapDataObjectBase(bitmap) -{ - Init(); - - DoConvertToPng(); -} - -wxBitmapDataObject::~wxBitmapDataObject() -{ - Clear(); -} - -void wxBitmapDataObject::SetBitmap( const wxBitmap &bitmap ) -{ - ClearAll(); - - wxBitmapDataObjectBase::SetBitmap(bitmap); - - DoConvertToPng(); -} - -bool wxBitmapDataObject::GetDataHere(void *buf) const -{ - if ( !m_pngSize ) - { - wxFAIL_MSG( wxT("attempt to copy empty bitmap failed") ); - - return FALSE; - } - - memcpy(buf, m_pngData, m_pngSize); - - return TRUE; -} - -bool wxBitmapDataObject::SetData(size_t size, const void *buf) -{ - Clear(); - - wxCHECK_MSG( wxImage::FindHandler(wxBITMAP_TYPE_PNG) != NULL, - FALSE, wxT("You must call wxImage::AddHandler(new wxPNGHandler); to be able to use clipboard with bitmaps!") ); - - m_pngSize = size; - m_pngData = malloc(m_pngSize); - - memcpy(m_pngData, buf, m_pngSize); - - wxMemoryInputStream mstream((char*) m_pngData, m_pngSize); - wxImage image; - if ( !image.LoadFile( mstream, wxBITMAP_TYPE_PNG ) ) - { - return FALSE; - } - - m_bitmap = wxBitmap(image); - - return m_bitmap.Ok(); -} - -void wxBitmapDataObject::DoConvertToPng() -{ - if ( !m_bitmap.Ok() ) - return; - - wxCHECK_RET( wxImage::FindHandler(wxBITMAP_TYPE_PNG) != NULL, - wxT("You must call wxImage::AddHandler(new wxPNGHandler); to be able to use clipboard with bitmaps!") ); - - wxImage image = m_bitmap.ConvertToImage(); - - wxCountingOutputStream count; - image.SaveFile(count, wxBITMAP_TYPE_PNG); - - m_pngSize = count.GetSize() + 100; // sometimes the size seems to vary ??? - m_pngData = malloc(m_pngSize); - - wxMemoryOutputStream mstream((char*) m_pngData, m_pngSize); - image.SaveFile(mstream, wxBITMAP_TYPE_PNG); -} - - diff --git a/src/gtk1/dc.cpp b/src/gtk1/dc.cpp deleted file mode 100644 index f4b8e635e9..0000000000 --- a/src/gtk1/dc.cpp +++ /dev/null @@ -1,209 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: dc.cpp -// Purpose: -// Author: Robert Roebling -// RCS-ID: $Id$ -// Copyright: (c) 1998 Robert Roebling, Markus Holzem -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/dc.h" - -#include -#include - -//----------------------------------------------------------------------------- -// constants -//----------------------------------------------------------------------------- - -#define mm2inches 0.0393700787402 -#define inches2mm 25.4 -#define mm2twips 56.6929133859 -#define twips2mm 0.0176388888889 -#define mm2pt 2.83464566929 -#define pt2mm 0.352777777778 - -//----------------------------------------------------------------------------- -// wxDC -//----------------------------------------------------------------------------- - -IMPLEMENT_ABSTRACT_CLASS(wxDC, wxDCBase) - -wxDC::wxDC() -{ - m_ok = FALSE; - - m_mm_to_pix_x = (double)wxGetDisplaySize().GetWidth() / - (double)wxGetDisplaySizeMM().GetWidth(); - m_mm_to_pix_y = (double)wxGetDisplaySize().GetHeight() / - (double)wxGetDisplaySizeMM().GetHeight(); - - m_needComputeScaleX = FALSE; /* not used yet */ - m_needComputeScaleY = FALSE; /* not used yet */ - - m_logicalFunction = wxCOPY; - - m_pen = *wxBLACK_PEN; - m_font = *wxNORMAL_FONT; - m_brush = *wxWHITE_BRUSH; -} - -void wxDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) -{ - m_clipping = TRUE; - m_clipX1 = x; - m_clipY1 = y; - m_clipX2 = x + width; - m_clipY2 = y + height; -} - -void wxDC::DestroyClippingRegion() -{ - m_clipping = FALSE; -} - -// --------------------------------------------------------------------------- -// get DC capabilities -// --------------------------------------------------------------------------- - -void wxDC::DoGetSizeMM( int* width, int* height ) const -{ - int w = 0; - int h = 0; - GetSize( &w, &h ); - if (width) *width = int( double(w) / (m_userScaleX*m_mm_to_pix_x) ); - if (height) *height = int( double(h) / (m_userScaleY*m_mm_to_pix_y) ); -} - -// Resolution in pixels per logical inch -wxSize wxDC::GetPPI() const -{ - // TODO (should probably be pure virtual) - return wxSize(0, 0); -} - -// --------------------------------------------------------------------------- -// set various DC parameters -// --------------------------------------------------------------------------- - -void wxDC::ComputeScaleAndOrigin() -{ - m_scaleX = m_logicalScaleX * m_userScaleX; - m_scaleY = m_logicalScaleY * m_userScaleY; -} - -void wxDC::SetMapMode( int mode ) -{ - switch (mode) - { - case wxMM_TWIPS: - SetLogicalScale( twips2mm*m_mm_to_pix_x, twips2mm*m_mm_to_pix_y ); - break; - case wxMM_POINTS: - SetLogicalScale( pt2mm*m_mm_to_pix_x, pt2mm*m_mm_to_pix_y ); - break; - case wxMM_METRIC: - SetLogicalScale( m_mm_to_pix_x, m_mm_to_pix_y ); - break; - case wxMM_LOMETRIC: - SetLogicalScale( m_mm_to_pix_x/10.0, m_mm_to_pix_y/10.0 ); - break; - default: - case wxMM_TEXT: - SetLogicalScale( 1.0, 1.0 ); - break; - } - m_mappingMode = mode; - -/* we don't do this mega optimisation - if (mode != wxMM_TEXT) - { - m_needComputeScaleX = TRUE; - m_needComputeScaleY = TRUE; - } -*/ -} - -void wxDC::SetUserScale( double x, double y ) -{ - // allow negative ? -> no - m_userScaleX = x; - m_userScaleY = y; - ComputeScaleAndOrigin(); -} - -void wxDC::SetLogicalScale( double x, double y ) -{ - // allow negative ? - m_logicalScaleX = x; - m_logicalScaleY = y; - ComputeScaleAndOrigin(); -} - -void wxDC::SetLogicalOrigin( wxCoord x, wxCoord y ) -{ - m_logicalOriginX = x * m_signX; // is this still correct ? - m_logicalOriginY = y * m_signY; - ComputeScaleAndOrigin(); -} - -void wxDC::SetDeviceOrigin( wxCoord x, wxCoord y ) -{ - // only wxPostScripDC has m_signX = -1, we override SetDeviceOrigin there - m_deviceOriginX = x; - m_deviceOriginY = y; - ComputeScaleAndOrigin(); -} - -void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp ) -{ - // only wxPostScripDC has m_signX = -1, we override SetAxisOrientation there - m_signX = (xLeftRight ? 1 : -1); - m_signY = (yBottomUp ? -1 : 1); - ComputeScaleAndOrigin(); -} - -// --------------------------------------------------------------------------- -// coordinates transformations -// --------------------------------------------------------------------------- - -wxCoord wxDCBase::DeviceToLogicalX(wxCoord x) const -{ - return ((wxDC *)this)->XDEV2LOG(x); -} - -wxCoord wxDCBase::DeviceToLogicalY(wxCoord y) const -{ - return ((wxDC *)this)->YDEV2LOG(y); -} - -wxCoord wxDCBase::DeviceToLogicalXRel(wxCoord x) const -{ - return ((wxDC *)this)->XDEV2LOGREL(x); -} - -wxCoord wxDCBase::DeviceToLogicalYRel(wxCoord y) const -{ - return ((wxDC *)this)->YDEV2LOGREL(y); -} - -wxCoord wxDCBase::LogicalToDeviceX(wxCoord x) const -{ - return ((wxDC *)this)->XLOG2DEV(x); -} - -wxCoord wxDCBase::LogicalToDeviceY(wxCoord y) const -{ - return ((wxDC *)this)->YLOG2DEV(y); -} - -wxCoord wxDCBase::LogicalToDeviceXRel(wxCoord x) const -{ - return ((wxDC *)this)->XLOG2DEVREL(x); -} - -wxCoord wxDCBase::LogicalToDeviceYRel(wxCoord y) const -{ - return ((wxDC *)this)->YLOG2DEVREL(y); -} - diff --git a/src/gtk1/dcclient.cpp b/src/gtk1/dcclient.cpp deleted file mode 100644 index 822b809cdc..0000000000 --- a/src/gtk1/dcclient.cpp +++ /dev/null @@ -1,2372 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: gtk/dcclient.cpp -// Purpose: -// Author: Robert Roebling -// RCS-ID: $Id$ -// Copyright: (c) 1998 Robert Roebling, Markus Holzem, Chris Breeze -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifdef __VMS -#define XCopyPlane XCOPYPLANE -#endif - -#include "wx/dcclient.h" -#include "wx/dcmemory.h" -#include "wx/image.h" -#include "wx/module.h" -#include "wx/log.h" -#include "wx/fontutil.h" - -#include "wx/gtk/win_gtk.h" - -#include // for floating-point functions - -#include -#include -#include -#include - -//----------------------------------------------------------------------------- -// local defines -//----------------------------------------------------------------------------- - -#define USE_PAINT_REGION 1 - -//----------------------------------------------------------------------------- -// local data -//----------------------------------------------------------------------------- - -#include "bdiag.xbm" -#include "fdiag.xbm" -#include "cdiag.xbm" -#include "horiz.xbm" -#include "verti.xbm" -#include "cross.xbm" -#define num_hatches 6 - -#define IS_15_PIX_HATCH(s) ((s)==wxCROSSDIAG_HATCH || (s)==wxHORIZONTAL_HATCH || (s)==wxVERTICAL_HATCH) -#define IS_16_PIX_HATCH(s) ((s)!=wxCROSSDIAG_HATCH && (s)!=wxHORIZONTAL_HATCH && (s)!=wxVERTICAL_HATCH) - - -static GdkPixmap *hatches[num_hatches]; -static GdkPixmap **hatch_bitmap = (GdkPixmap **) NULL; - -extern GtkWidget *wxGetRootWindow(); - -//----------------------------------------------------------------------------- -// constants -//----------------------------------------------------------------------------- - -const double RAD2DEG = 180.0 / M_PI; - -// ---------------------------------------------------------------------------- -// private functions -// ---------------------------------------------------------------------------- - -static inline double dmax(double a, double b) { return a > b ? a : b; } -static inline double dmin(double a, double b) { return a < b ? a : b; } - -static inline double DegToRad(double deg) { return (deg * M_PI) / 180.0; } - -//----------------------------------------------------------------------------- -// temporary implementation of the missing GDK function -//----------------------------------------------------------------------------- - -#include "gdk/gdkprivate.h" - -void gdk_wx_draw_bitmap(GdkDrawable *drawable, - GdkGC *gc, - GdkDrawable *src, - gint xsrc, - gint ysrc, - gint xdest, - gint ydest, - gint width, - gint height) -{ - g_return_if_fail (drawable != NULL); - g_return_if_fail (src != NULL); - g_return_if_fail (gc != NULL); - -#ifdef __WXGTK20__ - gint src_width, src_height; - gdk_drawable_get_size(src, &src_width, &src_height); - if (width == -1) width = src_width; - if (height == -1) height = src_height; - - XCopyPlane( GDK_WINDOW_XDISPLAY(drawable), - GDK_WINDOW_XID(src), - GDK_WINDOW_XID(drawable), - GDK_GC_XGC(gc), - xsrc, ysrc, - width, height, - 0, 0, - 1 ); -#else - GdkWindowPrivate *drawable_private; - GdkWindowPrivate *src_private; - GdkGCPrivate *gc_private; - - drawable_private = (GdkWindowPrivate*) drawable; - src_private = (GdkWindowPrivate*) src; - if (drawable_private->destroyed || src_private->destroyed) - return; - - gint src_width = src_private->width; - gint src_height = src_private->height; - - gc_private = (GdkGCPrivate*) gc; - - if (width == -1) width = src_width; - if (height == -1) height = src_height; - - XCopyPlane( drawable_private->xdisplay, - src_private->xwindow, - drawable_private->xwindow, - gc_private->xgc, - xsrc, ysrc, - width, height, - xdest, ydest, - 1 ); -#endif -} - -//----------------------------------------------------------------------------- -// Implement Pool of Graphic contexts. Creating them takes too much time. -//----------------------------------------------------------------------------- - -#define GC_POOL_SIZE 200 - -enum wxPoolGCType -{ - wxGC_ERROR = 0, - wxTEXT_MONO, - wxBG_MONO, - wxPEN_MONO, - wxBRUSH_MONO, - wxTEXT_COLOUR, - wxBG_COLOUR, - wxPEN_COLOUR, - wxBRUSH_COLOUR, - wxTEXT_SCREEN, - wxBG_SCREEN, - wxPEN_SCREEN, - wxBRUSH_SCREEN -}; - -struct wxGC -{ - GdkGC *m_gc; - wxPoolGCType m_type; - bool m_used; -}; - -#define GC_POOL_ALLOC_SIZE 100 - -static int wxGCPoolSize = 0; - -static wxGC *wxGCPool = NULL; - -static void wxInitGCPool() -{ - // This really could wait until the first call to - // wxGetPoolGC, but we will make the first allocation - // now when other initialization is being performed. - - // Set initial pool size. - wxGCPoolSize = GC_POOL_ALLOC_SIZE; - - // Allocate initial pool. - wxGCPool = (wxGC *)malloc(wxGCPoolSize * sizeof(wxGC)); - if (wxGCPool == NULL) - { - // If we cannot malloc, then fail with error - // when debug is enabled. If debug is not enabled, - // the problem will eventually get caught - // in wxGetPoolGC. - wxFAIL_MSG( wxT("Cannot allocate GC pool") ); - return; - } - - // Zero initial pool. - memset(wxGCPool, 0, wxGCPoolSize * sizeof(wxGC)); -} - -static void wxCleanUpGCPool() -{ - for (int i = 0; i < wxGCPoolSize; i++) - { - if (wxGCPool[i].m_gc) - gdk_gc_unref( wxGCPool[i].m_gc ); - } - - free(wxGCPool); - wxGCPool = NULL; - wxGCPoolSize = 0; -} - -static GdkGC* wxGetPoolGC( GdkWindow *window, wxPoolGCType type ) -{ - wxGC *pptr; - - // Look for an available GC. - for (int i = 0; i < wxGCPoolSize; i++) - { - if (!wxGCPool[i].m_gc) - { - wxGCPool[i].m_gc = gdk_gc_new( window ); - gdk_gc_set_exposures( wxGCPool[i].m_gc, FALSE ); - wxGCPool[i].m_type = type; - wxGCPool[i].m_used = FALSE; - } - if ((!wxGCPool[i].m_used) && (wxGCPool[i].m_type == type)) - { - wxGCPool[i].m_used = TRUE; - return wxGCPool[i].m_gc; - } - } - - // We did not find an available GC. - // We need to grow the GC pool. - pptr = (wxGC *)realloc(wxGCPool, - (wxGCPoolSize + GC_POOL_ALLOC_SIZE)*sizeof(wxGC)); - if (pptr != NULL) - { - // Initialize newly allocated pool. - wxGCPool = pptr; - memset(&wxGCPool[wxGCPoolSize], 0, - GC_POOL_ALLOC_SIZE*sizeof(wxGC)); - - // Initialize entry we will return. - wxGCPool[wxGCPoolSize].m_gc = gdk_gc_new( window ); - gdk_gc_set_exposures( wxGCPool[wxGCPoolSize].m_gc, FALSE ); - wxGCPool[wxGCPoolSize].m_type = type; - wxGCPool[wxGCPoolSize].m_used = TRUE; - - // Set new value of pool size. - wxGCPoolSize += GC_POOL_ALLOC_SIZE; - - // Return newly allocated entry. - return wxGCPool[wxGCPoolSize-GC_POOL_ALLOC_SIZE].m_gc; - } - - // The realloc failed. Fall through to error. - wxFAIL_MSG( wxT("No GC available") ); - - return (GdkGC*) NULL; -} - -static void wxFreePoolGC( GdkGC *gc ) -{ - for (int i = 0; i < wxGCPoolSize; i++) - { - if (wxGCPool[i].m_gc == gc) - { - wxGCPool[i].m_used = FALSE; - return; - } - } - - wxFAIL_MSG( wxT("Wrong GC") ); -} - -//----------------------------------------------------------------------------- -// wxWindowDC -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC) - -wxWindowDC::wxWindowDC() -{ - m_penGC = (GdkGC *) NULL; - m_brushGC = (GdkGC *) NULL; - m_textGC = (GdkGC *) NULL; - m_bgGC = (GdkGC *) NULL; - m_cmap = (GdkColormap *) NULL; - m_isMemDC = FALSE; - m_isScreenDC = FALSE; - m_owner = (wxWindow *)NULL; -#ifdef __WXGTK20__ - m_context = (PangoContext *)NULL; - m_fontdesc = (PangoFontDescription *)NULL; -#endif -} - -wxWindowDC::wxWindowDC( wxWindow *window ) -{ - wxASSERT_MSG( window, wxT("DC needs a window") ); - - m_penGC = (GdkGC *) NULL; - m_brushGC = (GdkGC *) NULL; - m_textGC = (GdkGC *) NULL; - m_bgGC = (GdkGC *) NULL; - m_cmap = (GdkColormap *) NULL; - m_owner = (wxWindow *)NULL; - m_isMemDC = FALSE; - m_isScreenDC = FALSE; - m_font = window->GetFont(); - - GtkWidget *widget = window->m_wxwindow; - - // some controls don't have m_wxwindow - like wxStaticBox, but the user - // code should still be able to create wxClientDCs for them, so we will - // use the parent window here then - if ( !widget ) - { - window = window->GetParent(); - widget = window->m_wxwindow; - } - - wxASSERT_MSG( widget, wxT("DC needs a widget") ); - -#ifdef __WXGTK20__ - m_context = window->GtkGetPangoDefaultContext(); - m_fontdesc = widget->style->font_desc; -#endif - - GtkPizza *pizza = GTK_PIZZA( widget ); - m_window = pizza->bin_window; - - /* not realized ? */ - if (!m_window) - { - /* don't report problems */ - m_ok = TRUE; - - return; - } - - m_cmap = gtk_widget_get_colormap( widget ? widget : window->m_widget ); - - SetUpDC(); - - /* this must be done after SetUpDC, bacause SetUpDC calls the - repective SetBrush, SetPen, SetBackground etc functions - to set up the DC. SetBackground call m_owner->SetBackground - and this might not be desired as the standard dc background - is white whereas a window might assume gray to be the - standard (as e.g. wxStatusBar) */ - - m_owner = window; -} - -wxWindowDC::~wxWindowDC() -{ - Destroy(); -} - -void wxWindowDC::SetUpDC() -{ - m_ok = TRUE; - - wxASSERT_MSG( !m_penGC, wxT("GCs already created") ); - - if (m_isScreenDC) - { - m_penGC = wxGetPoolGC( m_window, wxPEN_SCREEN ); - m_brushGC = wxGetPoolGC( m_window, wxBRUSH_SCREEN ); - m_textGC = wxGetPoolGC( m_window, wxTEXT_SCREEN ); - m_bgGC = wxGetPoolGC( m_window, wxBG_SCREEN ); - } - else - if (m_isMemDC && (((wxMemoryDC*)this)->m_selected.GetDepth() == 1)) - { - m_penGC = wxGetPoolGC( m_window, wxPEN_MONO ); - m_brushGC = wxGetPoolGC( m_window, wxBRUSH_MONO ); - m_textGC = wxGetPoolGC( m_window, wxTEXT_MONO ); - m_bgGC = wxGetPoolGC( m_window, wxBG_MONO ); - } - else - { - m_penGC = wxGetPoolGC( m_window, wxPEN_COLOUR ); - m_brushGC = wxGetPoolGC( m_window, wxBRUSH_COLOUR ); - m_textGC = wxGetPoolGC( m_window, wxTEXT_COLOUR ); - m_bgGC = wxGetPoolGC( m_window, wxBG_COLOUR ); - } - -#ifdef __WXGTK20__ - if (m_isMemDC) - { - m_context = gdk_pango_context_get(); - m_fontdesc = pango_context_get_font_description(m_context); - } -#endif - - /* background colour */ - m_backgroundBrush = *wxWHITE_BRUSH; - m_backgroundBrush.GetColour().CalcPixel( m_cmap ); - GdkColor *bg_col = m_backgroundBrush.GetColour().GetColor(); - - /* m_textGC */ - m_textForegroundColour.CalcPixel( m_cmap ); - gdk_gc_set_foreground( m_textGC, m_textForegroundColour.GetColor() ); - - m_textBackgroundColour.CalcPixel( m_cmap ); - gdk_gc_set_background( m_textGC, m_textBackgroundColour.GetColor() ); - - gdk_gc_set_fill( m_textGC, GDK_SOLID ); - - /* m_penGC */ - m_pen.GetColour().CalcPixel( m_cmap ); - gdk_gc_set_foreground( m_penGC, m_pen.GetColour().GetColor() ); - gdk_gc_set_background( m_penGC, bg_col ); - - gdk_gc_set_line_attributes( m_penGC, 0, GDK_LINE_SOLID, GDK_CAP_NOT_LAST, GDK_JOIN_ROUND ); - - /* m_brushGC */ - m_brush.GetColour().CalcPixel( m_cmap ); - gdk_gc_set_foreground( m_brushGC, m_brush.GetColour().GetColor() ); - gdk_gc_set_background( m_brushGC, bg_col ); - - gdk_gc_set_fill( m_brushGC, GDK_SOLID ); - - /* m_bgGC */ - gdk_gc_set_background( m_bgGC, bg_col ); - gdk_gc_set_foreground( m_bgGC, bg_col ); - - gdk_gc_set_fill( m_bgGC, GDK_SOLID ); - - /* ROPs */ - gdk_gc_set_function( m_textGC, GDK_COPY ); - gdk_gc_set_function( m_brushGC, GDK_COPY ); - gdk_gc_set_function( m_penGC, GDK_COPY ); - - /* clipping */ - gdk_gc_set_clip_rectangle( m_penGC, (GdkRectangle *) NULL ); - gdk_gc_set_clip_rectangle( m_brushGC, (GdkRectangle *) NULL ); - gdk_gc_set_clip_rectangle( m_textGC, (GdkRectangle *) NULL ); - gdk_gc_set_clip_rectangle( m_bgGC, (GdkRectangle *) NULL ); - - if (!hatch_bitmap) - { - hatch_bitmap = hatches; - hatch_bitmap[0] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, bdiag_bits, bdiag_width, bdiag_height ); - hatch_bitmap[1] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, cdiag_bits, cdiag_width, cdiag_height ); - hatch_bitmap[2] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, fdiag_bits, fdiag_width, fdiag_height ); - hatch_bitmap[3] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, cross_bits, cross_width, cross_height ); - hatch_bitmap[4] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, horiz_bits, horiz_width, horiz_height ); - hatch_bitmap[5] = gdk_bitmap_create_from_data( (GdkWindow *) NULL, verti_bits, verti_width, verti_height ); - } -} - -void wxWindowDC::DoGetSize( int* width, int* height ) const -{ - wxCHECK_RET( m_owner, _T("GetSize() doesn't work without window") ); - - m_owner->GetSize(width, height); -} - -extern bool wxDoFloodFill(wxDC *dc, wxCoord x, wxCoord y, - const wxColour & col, int style); - -bool wxWindowDC::DoFloodFill(wxCoord x, wxCoord y, - const wxColour& col, int style) -{ - return wxDoFloodFill(this, x, y, col, style); -} - -bool wxWindowDC::DoGetPixel( wxCoord x1, wxCoord y1, wxColour *col ) const -{ - // Generic (and therefore rather inefficient) method. - // Could be improved. - wxMemoryDC memdc; - wxBitmap bitmap(1, 1); - memdc.SelectObject(bitmap); - memdc.Blit(0, 0, 1, 1, (wxDC*) this, x1, y1); - memdc.SelectObject(wxNullBitmap); - - wxImage image = bitmap.ConvertToImage(); - col->Set(image.GetRed(0, 0), image.GetGreen(0, 0), image.GetBlue(0, 0)); - return TRUE; -} - -void wxWindowDC::DoDrawLine( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2 ) -{ - wxCHECK_RET( Ok(), wxT("invalid window dc") ); - - if (m_pen.GetStyle() != wxTRANSPARENT) - { - if (m_window) - gdk_draw_line( m_window, m_penGC, XLOG2DEV(x1), YLOG2DEV(y1), XLOG2DEV(x2), YLOG2DEV(y2) ); - - CalcBoundingBox(x1, y1); - CalcBoundingBox(x2, y2); - } -} - -void wxWindowDC::DoCrossHair( wxCoord x, wxCoord y ) -{ - wxCHECK_RET( Ok(), wxT("invalid window dc") ); - - if (m_pen.GetStyle() != wxTRANSPARENT) - { - int w = 0; - int h = 0; - GetSize( &w, &h ); - wxCoord xx = XLOG2DEV(x); - wxCoord yy = YLOG2DEV(y); - if (m_window) - { - gdk_draw_line( m_window, m_penGC, 0, yy, XLOG2DEVREL(w), yy ); - gdk_draw_line( m_window, m_penGC, xx, 0, xx, YLOG2DEVREL(h) ); - } - } -} - -void wxWindowDC::DoDrawArc( wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, - wxCoord xc, wxCoord yc ) -{ - wxCHECK_RET( Ok(), wxT("invalid window dc") ); - - wxCoord xx1 = XLOG2DEV(x1); - wxCoord yy1 = YLOG2DEV(y1); - wxCoord xx2 = XLOG2DEV(x2); - wxCoord yy2 = YLOG2DEV(y2); - wxCoord xxc = XLOG2DEV(xc); - wxCoord yyc = YLOG2DEV(yc); - double dx = xx1 - xxc; - double dy = yy1 - yyc; - double radius = sqrt((double)(dx*dx+dy*dy)); - wxCoord r = (wxCoord)radius; - double radius1, radius2; - - if (xx1 == xx2 && yy1 == yy2) - { - radius1 = 0.0; - radius2 = 360.0; - } - else - if (radius == 0.0) - { - radius1 = radius2 = 0.0; - } - else - { - radius1 = (xx1 - xxc == 0) ? - (yy1 - yyc < 0) ? 90.0 : -90.0 : - -atan2(double(yy1-yyc), double(xx1-xxc)) * RAD2DEG; - radius2 = (xx2 - xxc == 0) ? - (yy2 - yyc < 0) ? 90.0 : -90.0 : - -atan2(double(yy2-yyc), double(xx2-xxc)) * RAD2DEG; - } - wxCoord alpha1 = wxCoord(radius1 * 64.0); - wxCoord alpha2 = wxCoord((radius2 - radius1) * 64.0); - while (alpha2 <= 0) alpha2 += 360*64; - while (alpha1 > 360*64) alpha1 -= 360*64; - - if (m_window) - { - if (m_brush.GetStyle() != wxTRANSPARENT) - { - if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask())) - { - gdk_gc_set_ts_origin( m_textGC, - m_deviceOriginX % m_brush.GetStipple()->GetWidth(), - m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); - gdk_draw_arc( m_window, m_textGC, TRUE, xxc-r, yyc-r, 2*r,2*r, alpha1, alpha2 ); - gdk_gc_set_ts_origin( m_textGC, 0, 0 ); - } else - if (IS_15_PIX_HATCH(m_brush.GetStyle())) - { - gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % 15, m_deviceOriginY % 15 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xxc-r, yyc-r, 2*r,2*r, alpha1, alpha2 ); - gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); - } else - if (IS_16_PIX_HATCH(m_brush.GetStyle())) - { - gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % 16, m_deviceOriginY % 16 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xxc-r, yyc-r, 2*r,2*r, alpha1, alpha2 ); - gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); - } else - if (m_brush.GetStyle() == wxSTIPPLE) - { - gdk_gc_set_ts_origin( m_brushGC, - m_deviceOriginX % m_brush.GetStipple()->GetWidth(), - m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xxc-r, yyc-r, 2*r,2*r, alpha1, alpha2 ); - gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); - } - else - { - gdk_draw_arc( m_window, m_brushGC, TRUE, xxc-r, yyc-r, 2*r,2*r, alpha1, alpha2 ); - } - } - - if (m_pen.GetStyle() != wxTRANSPARENT) - { - gdk_draw_arc( m_window, m_penGC, FALSE, xxc-r, yyc-r, 2*r,2*r, alpha1, alpha2 ); - - gdk_draw_line( m_window, m_penGC, xx1, yy1, xxc, yyc ); - gdk_draw_line( m_window, m_penGC, xxc, yyc, xx2, yy2 ); - } - } - - CalcBoundingBox (x1, y1); - CalcBoundingBox (x2, y2); -} - -void wxWindowDC::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord width, wxCoord height, double sa, double ea ) -{ - wxCHECK_RET( Ok(), wxT("invalid window dc") ); - - wxCoord xx = XLOG2DEV(x); - wxCoord yy = YLOG2DEV(y); - wxCoord ww = m_signX * XLOG2DEVREL(width); - wxCoord hh = m_signY * YLOG2DEVREL(height); - - // CMB: handle -ve width and/or height - if (ww < 0) { ww = -ww; xx = xx - ww; } - if (hh < 0) { hh = -hh; yy = yy - hh; } - - if (m_window) - { - wxCoord start = wxCoord(sa * 64.0); - wxCoord end = wxCoord((ea-sa) * 64.0); - - if (m_brush.GetStyle() != wxTRANSPARENT) - { - if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask())) - { - gdk_gc_set_ts_origin( m_textGC, - m_deviceOriginX % m_brush.GetStipple()->GetWidth(), - m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); - gdk_draw_arc( m_window, m_textGC, TRUE, xx, yy, ww, hh, start, end ); - gdk_gc_set_ts_origin( m_textGC, 0, 0 ); - } else - if (IS_15_PIX_HATCH(m_brush.GetStyle())) - { - gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % 15, m_deviceOriginY % 15 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, ww, hh, start, end ); - gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); - } else - if (IS_16_PIX_HATCH(m_brush.GetStyle())) - { - gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % 16, m_deviceOriginY % 16 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, ww, hh, start, end ); - gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); - } else - if (m_brush.GetStyle() == wxSTIPPLE) - { - gdk_gc_set_ts_origin( m_brushGC, - m_deviceOriginX % m_brush.GetStipple()->GetWidth(), - m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, ww, hh, start, end ); - gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); - } - else - { - gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, ww, hh, start, end ); - } - } - - if (m_pen.GetStyle() != wxTRANSPARENT) - gdk_draw_arc( m_window, m_penGC, FALSE, xx, yy, ww, hh, start, end ); - } - - CalcBoundingBox (x, y); - CalcBoundingBox (x + width, y + height); -} - -void wxWindowDC::DoDrawPoint( wxCoord x, wxCoord y ) -{ - wxCHECK_RET( Ok(), wxT("invalid window dc") ); - - if ((m_pen.GetStyle() != wxTRANSPARENT) && m_window) - gdk_draw_point( m_window, m_penGC, XLOG2DEV(x), YLOG2DEV(y) ); - - CalcBoundingBox (x, y); -} - -void wxWindowDC::DoDrawLines( int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset ) -{ - wxCHECK_RET( Ok(), wxT("invalid window dc") ); - - if (m_pen.GetStyle() == wxTRANSPARENT) return; - if (n <= 0) return; - - GdkPoint *gpts = new GdkPoint[n]; - if (! gpts) - { - wxFAIL_MSG( wxT("Cannot allocate PolyLine") ); - return; - } - - for (int i = 0; i < n; i++) - { - wxCoord x1 = XLOG2DEV(points[i].x + xoffset); - wxCoord y1 = YLOG2DEV(points[i].y + yoffset); - - CalcBoundingBox( x1 + xoffset, y1 + yoffset ); - - gpts[i].x = x1; - gpts[i].y = y1; - } - - if (m_window) - gdk_draw_lines( m_window, m_penGC, gpts, n); - - delete[] gpts; -} - -void wxWindowDC::DoDrawPolygon( int n, wxPoint points[], wxCoord xoffset, wxCoord yoffset, int WXUNUSED(fillStyle) ) -{ - wxCHECK_RET( Ok(), wxT("invalid window dc") ); - - if (n <= 0) return; - - GdkPoint *gdkpoints = new GdkPoint[n+1]; - int i; - for (i = 0 ; i < n ; i++) - { - gdkpoints[i].x = XLOG2DEV(points[i].x + xoffset); - gdkpoints[i].y = YLOG2DEV(points[i].y + yoffset); - - CalcBoundingBox( points[i].x + xoffset, points[i].y + yoffset ); - } - - if (m_window) - { - if (m_brush.GetStyle() != wxTRANSPARENT) - { - if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask())) - { - gdk_gc_set_ts_origin( m_textGC, - m_deviceOriginX % m_brush.GetStipple()->GetWidth(), - m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); - gdk_draw_polygon( m_window, m_textGC, TRUE, gdkpoints, n ); - gdk_gc_set_ts_origin( m_textGC, 0, 0 ); - } else - if (IS_15_PIX_HATCH(m_brush.GetStyle())) - { - gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % 15, m_deviceOriginY % 15 ); - gdk_draw_polygon( m_window, m_brushGC, TRUE, gdkpoints, n ); - gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); - } else - if (IS_16_PIX_HATCH(m_brush.GetStyle())) - { - gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % 16, m_deviceOriginY % 16 ); - gdk_draw_polygon( m_window, m_brushGC, TRUE, gdkpoints, n ); - gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); - } else - if (m_brush.GetStyle() == wxSTIPPLE) - { - gdk_gc_set_ts_origin( m_brushGC, - m_deviceOriginX % m_brush.GetStipple()->GetWidth(), - m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); - gdk_draw_polygon( m_window, m_brushGC, TRUE, gdkpoints, n ); - gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); - } - else - { - gdk_draw_polygon( m_window, m_brushGC, TRUE, gdkpoints, n ); - } - } - - if (m_pen.GetStyle() != wxTRANSPARENT) - { -/* - for (i = 0 ; i < n ; i++) - { - gdk_draw_line( m_window, m_penGC, - gdkpoints[i%n].x, - gdkpoints[i%n].y, - gdkpoints[(i+1)%n].x, - gdkpoints[(i+1)%n].y); - } -*/ - gdk_draw_polygon( m_window, m_penGC, FALSE, gdkpoints, n ); - - } - } - - delete[] gdkpoints; -} - -void wxWindowDC::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) -{ - wxCHECK_RET( Ok(), wxT("invalid window dc") ); - - wxCoord xx = XLOG2DEV(x); - wxCoord yy = YLOG2DEV(y); - wxCoord ww = m_signX * XLOG2DEVREL(width); - wxCoord hh = m_signY * YLOG2DEVREL(height); - - // CMB: draw nothing if transformed w or h is 0 - if (ww == 0 || hh == 0) return; - - // CMB: handle -ve width and/or height - if (ww < 0) { ww = -ww; xx = xx - ww; } - if (hh < 0) { hh = -hh; yy = yy - hh; } - - if (m_window) - { - if (m_brush.GetStyle() != wxTRANSPARENT) - { - if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask())) - { - gdk_gc_set_ts_origin( m_textGC, - m_deviceOriginX % m_brush.GetStipple()->GetWidth(), - m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); - gdk_draw_rectangle( m_window, m_textGC, TRUE, xx, yy, ww, hh ); - gdk_gc_set_ts_origin( m_textGC, 0, 0 ); - } else - if (IS_15_PIX_HATCH(m_brush.GetStyle())) - { - gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % 15, m_deviceOriginY % 15 ); - gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx, yy, ww, hh ); - gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); - } else - if (IS_16_PIX_HATCH(m_brush.GetStyle())) - { - gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % 16, m_deviceOriginY % 16 ); - gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx, yy, ww, hh ); - gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); - } else - if (m_brush.GetStyle() == wxSTIPPLE) - { - gdk_gc_set_ts_origin( m_brushGC, - m_deviceOriginX % m_brush.GetStipple()->GetWidth(), - m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); - gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx, yy, ww, hh ); - gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); - } - else - { - gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx, yy, ww, hh ); - } - } - - if (m_pen.GetStyle() != wxTRANSPARENT) - gdk_draw_rectangle( m_window, m_penGC, FALSE, xx, yy, ww-1, hh-1 ); - } - - CalcBoundingBox( x, y ); - CalcBoundingBox( x + width, y + height ); -} - -void wxWindowDC::DoDrawRoundedRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord height, double radius ) -{ - wxCHECK_RET( Ok(), wxT("invalid window dc") ); - - if (radius < 0.0) radius = - radius * ((width < height) ? width : height); - - wxCoord xx = XLOG2DEV(x); - wxCoord yy = YLOG2DEV(y); - wxCoord ww = m_signX * XLOG2DEVREL(width); - wxCoord hh = m_signY * YLOG2DEVREL(height); - wxCoord rr = XLOG2DEVREL((wxCoord)radius); - - // CMB: handle -ve width and/or height - if (ww < 0) { ww = -ww; xx = xx - ww; } - if (hh < 0) { hh = -hh; yy = yy - hh; } - - // CMB: if radius is zero use DrawRectangle() instead to avoid - // X drawing errors with small radii - if (rr == 0) - { - DrawRectangle( x, y, width, height ); - return; - } - - // CMB: draw nothing if transformed w or h is 0 - if (ww == 0 || hh == 0) return; - - // CMB: adjust size if outline is drawn otherwise the result is - // 1 pixel too wide and high - if (m_pen.GetStyle() != wxTRANSPARENT) - { - ww--; - hh--; - } - - if (m_window) - { - // CMB: ensure dd is not larger than rectangle otherwise we - // get an hour glass shape - wxCoord dd = 2 * rr; - if (dd > ww) dd = ww; - if (dd > hh) dd = hh; - rr = dd / 2; - - if (m_brush.GetStyle() != wxTRANSPARENT) - { - if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask())) - { - gdk_gc_set_ts_origin( m_textGC, - m_deviceOriginX % m_brush.GetStipple()->GetWidth(), - m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); - gdk_draw_rectangle( m_window, m_textGC, TRUE, xx+rr, yy, ww-dd+1, hh ); - gdk_draw_rectangle( m_window, m_textGC, TRUE, xx, yy+rr, ww, hh-dd+1 ); - gdk_draw_arc( m_window, m_textGC, TRUE, xx, yy, dd, dd, 90*64, 90*64 ); - gdk_draw_arc( m_window, m_textGC, TRUE, xx+ww-dd, yy, dd, dd, 0, 90*64 ); - gdk_draw_arc( m_window, m_textGC, TRUE, xx+ww-dd, yy+hh-dd, dd, dd, 270*64, 90*64 ); - gdk_draw_arc( m_window, m_textGC, TRUE, xx, yy+hh-dd, dd, dd, 180*64, 90*64 ); - gdk_gc_set_ts_origin( m_textGC, 0, 0 ); - } else - if (IS_15_PIX_HATCH(m_brush.GetStyle())) - { - gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % 15, m_deviceOriginY % 15 ); - gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx+rr, yy, ww-dd+1, hh ); - gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx, yy+rr, ww, hh-dd+1 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, dd, dd, 90*64, 90*64 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx+ww-dd, yy, dd, dd, 0, 90*64 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx+ww-dd, yy+hh-dd, dd, dd, 270*64, 90*64 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy+hh-dd, dd, dd, 180*64, 90*64 ); - gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); - } else - if (IS_16_PIX_HATCH(m_brush.GetStyle())) - { - gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % 16, m_deviceOriginY % 16 ); - gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx+rr, yy, ww-dd+1, hh ); - gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx, yy+rr, ww, hh-dd+1 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, dd, dd, 90*64, 90*64 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx+ww-dd, yy, dd, dd, 0, 90*64 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx+ww-dd, yy+hh-dd, dd, dd, 270*64, 90*64 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy+hh-dd, dd, dd, 180*64, 90*64 ); - gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); - } else - if (m_brush.GetStyle() == wxSTIPPLE) - { - gdk_gc_set_ts_origin( m_brushGC, - m_deviceOriginX % m_brush.GetStipple()->GetWidth(), - m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); - gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx+rr, yy, ww-dd+1, hh ); - gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx, yy+rr, ww, hh-dd+1 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, dd, dd, 90*64, 90*64 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx+ww-dd, yy, dd, dd, 0, 90*64 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx+ww-dd, yy+hh-dd, dd, dd, 270*64, 90*64 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy+hh-dd, dd, dd, 180*64, 90*64 ); - gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); - } - else - { - gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx+rr, yy, ww-dd+1, hh ); - gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx, yy+rr, ww, hh-dd+1 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, dd, dd, 90*64, 90*64 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx+ww-dd, yy, dd, dd, 0, 90*64 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx+ww-dd, yy+hh-dd, dd, dd, 270*64, 90*64 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy+hh-dd, dd, dd, 180*64, 90*64 ); - } - } - - if (m_pen.GetStyle() != wxTRANSPARENT) - { - gdk_draw_line( m_window, m_penGC, xx+rr+1, yy, xx+ww-rr, yy ); - gdk_draw_line( m_window, m_penGC, xx+rr+1, yy+hh, xx+ww-rr, yy+hh ); - gdk_draw_line( m_window, m_penGC, xx, yy+rr+1, xx, yy+hh-rr ); - gdk_draw_line( m_window, m_penGC, xx+ww, yy+rr+1, xx+ww, yy+hh-rr ); - gdk_draw_arc( m_window, m_penGC, FALSE, xx, yy, dd, dd, 90*64, 90*64 ); - gdk_draw_arc( m_window, m_penGC, FALSE, xx+ww-dd, yy, dd, dd, 0, 90*64 ); - gdk_draw_arc( m_window, m_penGC, FALSE, xx+ww-dd, yy+hh-dd, dd, dd, 270*64, 90*64 ); - gdk_draw_arc( m_window, m_penGC, FALSE, xx, yy+hh-dd, dd, dd, 180*64, 90*64 ); - } - } - - // this ignores the radius - CalcBoundingBox( x, y ); - CalcBoundingBox( x + width, y + height ); -} - -void wxWindowDC::DoDrawEllipse( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) -{ - wxCHECK_RET( Ok(), wxT("invalid window dc") ); - - wxCoord xx = XLOG2DEV(x); - wxCoord yy = YLOG2DEV(y); - wxCoord ww = m_signX * XLOG2DEVREL(width); - wxCoord hh = m_signY * YLOG2DEVREL(height); - - // CMB: handle -ve width and/or height - if (ww < 0) { ww = -ww; xx = xx - ww; } - if (hh < 0) { hh = -hh; yy = yy - hh; } - - if (m_window) - { - if (m_brush.GetStyle() != wxTRANSPARENT) - { - if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask())) - { - gdk_gc_set_ts_origin( m_textGC, - m_deviceOriginX % m_brush.GetStipple()->GetWidth(), - m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); - gdk_draw_arc( m_window, m_textGC, TRUE, xx, yy, ww, hh, 0, 360*64 ); - gdk_gc_set_ts_origin( m_textGC, 0, 0 ); - } else - if (IS_15_PIX_HATCH(m_brush.GetStyle())) - { - gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % 15, m_deviceOriginY % 15 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, ww, hh, 0, 360*64 ); - gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); - } else - if (IS_16_PIX_HATCH(m_brush.GetStyle())) - { - gdk_gc_set_ts_origin( m_brushGC, m_deviceOriginX % 16, m_deviceOriginY % 16 ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, ww, hh, 0, 360*64 ); - gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); - } else - if (m_brush.GetStyle() == wxSTIPPLE) - { - gdk_gc_set_ts_origin( m_brushGC, - m_deviceOriginX % m_brush.GetStipple()->GetWidth(), - m_deviceOriginY % m_brush.GetStipple()->GetHeight() ); - gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, ww, hh, 0, 360*64 ); - gdk_gc_set_ts_origin( m_brushGC, 0, 0 ); - } - else - { - gdk_draw_arc( m_window, m_brushGC, TRUE, xx, yy, ww, hh, 0, 360*64 ); - } - } - - if (m_pen.GetStyle() != wxTRANSPARENT) - gdk_draw_arc( m_window, m_penGC, FALSE, xx, yy, ww, hh, 0, 360*64 ); - } - - CalcBoundingBox( x, y ); - CalcBoundingBox( x + width, y + height ); -} - -void wxWindowDC::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y ) -{ - // VZ: egcs 1.0.3 refuses to compile this without cast, no idea why - DoDrawBitmap( (const wxBitmap&)icon, x, y, (bool)TRUE ); -} - -void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap, - wxCoord x, wxCoord y, - bool useMask ) -{ - wxCHECK_RET( Ok(), wxT("invalid window dc") ); - - wxCHECK_RET( bitmap.Ok(), wxT("invalid bitmap") ); - - bool is_mono = (bitmap.GetBitmap() != NULL); - - // scale/translate size and position - int xx = XLOG2DEV(x); - int yy = YLOG2DEV(y); - - int w = bitmap.GetWidth(); - int h = bitmap.GetHeight(); - - CalcBoundingBox( x, y ); - CalcBoundingBox( x + w, y + h ); - - if (!m_window) return; - - int ww = XLOG2DEVREL(w); - int hh = YLOG2DEVREL(h); - - // compare to current clipping region - if (!m_currentClippingRegion.IsNull()) - { - wxRegion tmp( xx,yy,ww,hh ); - tmp.Intersect( m_currentClippingRegion ); - if (tmp.IsEmpty()) - return; - } - - // scale bitmap if required - wxBitmap use_bitmap = bitmap; - if ((w != ww) || (h != hh)) - use_bitmap = use_bitmap.Rescale( 0, 0, ww, hh, ww, hh ); - - // apply mask if any - GdkBitmap *mask = (GdkBitmap *) NULL; - if (use_bitmap.GetMask()) mask = use_bitmap.GetMask()->GetBitmap(); - - GdkBitmap *new_mask = (GdkBitmap*) NULL; - - if (useMask && mask) - { - if (!m_currentClippingRegion.IsNull()) - { - GdkColor col; - new_mask = gdk_pixmap_new( wxGetRootWindow()->window, ww, hh, 1 ); - GdkGC *gc = gdk_gc_new( new_mask ); - col.pixel = 0; - gdk_gc_set_foreground( gc, &col ); - gdk_draw_rectangle( new_mask, gc, TRUE, 0, 0, ww, hh ); - col.pixel = 0; - gdk_gc_set_background( gc, &col ); - col.pixel = 1; - gdk_gc_set_foreground( gc, &col ); - gdk_gc_set_clip_region( gc, m_currentClippingRegion.GetRegion() ); - gdk_gc_set_clip_origin( gc, -xx, -yy ); - gdk_gc_set_fill( gc, GDK_OPAQUE_STIPPLED ); - gdk_gc_set_stipple( gc, mask ); - gdk_draw_rectangle( new_mask, gc, TRUE, 0, 0, ww, hh ); - gdk_gc_unref( gc ); - } - - if (is_mono) - { - if (new_mask) - gdk_gc_set_clip_mask( m_textGC, new_mask ); - else - gdk_gc_set_clip_mask( m_textGC, mask ); - gdk_gc_set_clip_origin( m_textGC, xx, yy ); - } - else - { - if (new_mask) - gdk_gc_set_clip_mask( m_penGC, new_mask ); - else - gdk_gc_set_clip_mask( m_penGC, mask ); - gdk_gc_set_clip_origin( m_penGC, xx, yy ); - } - } - - // Draw XPixmap or XBitmap, depending on what the wxBitmap contains. For - // drawing a mono-bitmap (XBitmap) we use the current text GC - if (is_mono) - { -#ifdef __WXGTK20__ - GdkPixmap *bitmap = gdk_pixmap_new( wxGetRootWindow()->window, ww, hh, -1 ); - GdkGC *gc = gdk_gc_new( bitmap ); - gdk_gc_set_foreground( gc, m_textForegroundColour.GetColor() ); - gdk_gc_set_background( gc, m_textBackgroundColour.GetColor() ); - gdk_wx_draw_bitmap( bitmap, gc, use_bitmap.GetBitmap(), 0, 0, 0, 0, -1, -1 ); - - gdk_draw_drawable( m_window, m_textGC, bitmap, 0, 0, xx, yy, -1, -1 ); - - gdk_bitmap_unref( bitmap ); - gdk_gc_unref( gc ); -#else - gdk_wx_draw_bitmap( m_window, m_textGC, use_bitmap.GetBitmap(), 0, 0, xx, yy, -1, -1 ); -#endif - } - else - { - gdk_draw_pixmap( m_window, m_penGC, use_bitmap.GetPixmap(), 0, 0, xx, yy, -1, -1 ); - } - - // remove mask again if any - if (useMask && mask) - { - if (is_mono) - { - gdk_gc_set_clip_mask( m_textGC, (GdkBitmap *) NULL ); - gdk_gc_set_clip_origin( m_textGC, 0, 0 ); - if (!m_currentClippingRegion.IsNull()) - gdk_gc_set_clip_region( m_textGC, m_currentClippingRegion.GetRegion() ); - } - else - { - gdk_gc_set_clip_mask( m_penGC, (GdkBitmap *) NULL ); - gdk_gc_set_clip_origin( m_penGC, 0, 0 ); - if (!m_currentClippingRegion.IsNull()) - gdk_gc_set_clip_region( m_penGC, m_currentClippingRegion.GetRegion() ); - } - } - - if (new_mask) - gdk_bitmap_unref( new_mask ); -} - -bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, - wxCoord width, wxCoord height, - wxDC *source, - wxCoord xsrc, wxCoord ysrc, - int logical_func, - bool useMask, - wxCoord xsrcMask, wxCoord ysrcMask ) -{ - wxCHECK_MSG( Ok(), FALSE, wxT("invalid window dc") ); - - wxCHECK_MSG( source, FALSE, wxT("invalid source dc") ); - - if (!m_window) return FALSE; - - // transform the source DC coords to the device ones - xsrc = source->XLOG2DEV(xsrc); - ysrc = source->YLOG2DEV(ysrc); - - wxClientDC *srcDC = (wxClientDC*)source; - wxMemoryDC *memDC = (wxMemoryDC*)source; - - bool use_bitmap_method = FALSE; - bool is_mono = FALSE; - - // TODO: use the mask origin when drawing transparently - if (xsrcMask == -1 && ysrcMask == -1) - { - xsrcMask = xsrc; - ysrcMask = ysrc; - } - - if (srcDC->m_isMemDC) - { - if (!memDC->m_selected.Ok()) return FALSE; - - is_mono = (memDC->m_selected.GetDepth() == 1); - - // we use the "XCopyArea" way to copy a memory dc into - // a different window if the memory dc BOTH - // a) doesn't have any mask or its mask isn't used - // b) it is clipped - // c) is not 1-bit - - if (useMask && (memDC->m_selected.GetMask())) - { - // we HAVE TO use the direct way for memory dcs - // that have mask since the XCopyArea doesn't know - // about masks - use_bitmap_method = TRUE; - } - else if (is_mono) - { - // we HAVE TO use the direct way for memory dcs - // that are bitmaps because XCopyArea doesn't cope - // with different bit depths - use_bitmap_method = TRUE; - } - else if ((xsrc == 0) && (ysrc == 0) && - (width == memDC->m_selected.GetWidth()) && - (height == memDC->m_selected.GetHeight())) - { - // we SHOULD use the direct way if all of the bitmap - // in the memory dc is copied in which case XCopyArea - // wouldn't be able able to boost performace by reducing - // the area to be scaled - use_bitmap_method = TRUE; - } - else - { - use_bitmap_method = FALSE; - } - } - - CalcBoundingBox( xdest, ydest ); - CalcBoundingBox( xdest + width, ydest + height ); - - // scale/translate size and position - wxCoord xx = XLOG2DEV(xdest); - wxCoord yy = YLOG2DEV(ydest); - - wxCoord ww = XLOG2DEVREL(width); - wxCoord hh = YLOG2DEVREL(height); - - // compare to current clipping region - if (!m_currentClippingRegion.IsNull()) - { - wxRegion tmp( xx,yy,ww,hh ); - tmp.Intersect( m_currentClippingRegion ); - if (tmp.IsEmpty()) - return TRUE; - } - - int old_logical_func = m_logicalFunction; - SetLogicalFunction( logical_func ); - - if (use_bitmap_method) - { - // scale/translate bitmap size - wxCoord bm_width = memDC->m_selected.GetWidth(); - wxCoord bm_height = memDC->m_selected.GetHeight(); - - // interpret userscale of src too - double xsc,ysc; - memDC->GetUserScale(&xsc,&ysc); - bm_width = (int) (bm_width / xsc); - bm_height = (int) (bm_height / ysc); - - wxCoord bm_ww = XLOG2DEVREL( bm_width ); - wxCoord bm_hh = YLOG2DEVREL( bm_height ); - - // Get clip coords for the bitmap. If we don't - // use wxBitmap::Rescale(), which can clip the - // bitmap, these are the same as the original - // coordinates - wxCoord cx = xx; - wxCoord cy = yy; - wxCoord cw = ww; - wxCoord ch = hh; - - // Scale bitmap if required - wxBitmap use_bitmap; - if ((bm_width != bm_ww) || (bm_height != bm_hh)) - { - // This indicates that the blitting code below will get - // a clipped bitmap and therefore needs to move the origin - // accordingly - wxRegion tmp( xx,yy,ww,hh ); - tmp.Intersect( m_currentClippingRegion ); - tmp.GetBox(cx,cy,cw,ch); - - // Scale and clipped bitmap - use_bitmap = memDC->m_selected.Rescale(cx-xx,cy-yy,cw,ch,bm_ww,bm_hh); - } - else - { - // Don't scale bitmap - use_bitmap = memDC->m_selected; - } - - // apply mask if any - GdkBitmap *mask = (GdkBitmap *) NULL; - if (use_bitmap.GetMask()) mask = use_bitmap.GetMask()->GetBitmap(); - - GdkBitmap *new_mask = (GdkBitmap*) NULL; - - if (useMask && mask) - { - if (!m_currentClippingRegion.IsNull()) - { - GdkColor col; - new_mask = gdk_pixmap_new( wxGetRootWindow()->window, bm_ww, bm_hh, 1 ); - GdkGC *gc = gdk_gc_new( new_mask ); - col.pixel = 0; - gdk_gc_set_foreground( gc, &col ); - gdk_draw_rectangle( new_mask, gc, TRUE, 0, 0, bm_ww, bm_hh ); - col.pixel = 0; - gdk_gc_set_background( gc, &col ); - col.pixel = 1; - gdk_gc_set_foreground( gc, &col ); - gdk_gc_set_clip_region( gc, m_currentClippingRegion.GetRegion() ); - // was: gdk_gc_set_clip_origin( gc, -xx, -yy ); - gdk_gc_set_clip_origin( gc, -cx, -cy ); - gdk_gc_set_fill( gc, GDK_OPAQUE_STIPPLED ); - gdk_gc_set_stipple( gc, mask ); - gdk_draw_rectangle( new_mask, gc, TRUE, 0, 0, bm_ww, bm_hh ); - gdk_gc_unref( gc ); - } - - if (is_mono) - { - if (new_mask) - gdk_gc_set_clip_mask( m_textGC, new_mask ); - else - gdk_gc_set_clip_mask( m_textGC, mask ); - // was: gdk_gc_set_clip_origin( m_textGC, xx, yy ); - gdk_gc_set_clip_origin( m_textGC, cx, cy ); - } - else - { - if (new_mask) - gdk_gc_set_clip_mask( m_penGC, new_mask ); - else - gdk_gc_set_clip_mask( m_penGC, mask ); - // was: gdk_gc_set_clip_origin( m_penGC, xx, yy ); - gdk_gc_set_clip_origin( m_penGC, cx, cy ); - } - } - - // Draw XPixmap or XBitmap, depending on what the wxBitmap contains. For - // drawing a mono-bitmap (XBitmap) we use the current text GC - - if (is_mono) - { -#ifdef __WXGTK20__ - GdkPixmap *bitmap = gdk_pixmap_new( wxGetRootWindow()->window, bm_ww, bm_hh, -1 ); - GdkGC *gc = gdk_gc_new( bitmap ); - gdk_gc_set_foreground( gc, m_textForegroundColour.GetColor() ); - gdk_gc_set_background( gc, m_textBackgroundColour.GetColor() ); - gdk_wx_draw_bitmap( bitmap, gc, use_bitmap.GetBitmap(), 0, 0, 0, 0, -1, -1 ); - - gdk_draw_drawable( m_window, m_textGC, bitmap, xsrc, ysrc, cx, cy, cw, ch ); - - gdk_bitmap_unref( bitmap ); - gdk_gc_unref( gc ); -#else - // was: gdk_wx_draw_bitmap( m_window, m_textGC, use_bitmap.GetBitmap(), xsrc, ysrc, xx, yy, ww, hh ); - gdk_wx_draw_bitmap( m_window, m_textGC, use_bitmap.GetBitmap(), xsrc, ysrc, cx, cy, cw, ch ); -#endif - } - else - { - // was: gdk_draw_pixmap( m_window, m_penGC, use_bitmap.GetPixmap(), xsrc, ysrc, xx, yy, ww, hh ); - gdk_draw_pixmap( m_window, m_penGC, use_bitmap.GetPixmap(), xsrc, ysrc, cx, cy, cw, ch ); - } - - // remove mask again if any - if (useMask && mask) - { - if (is_mono) - { - gdk_gc_set_clip_mask( m_textGC, (GdkBitmap *) NULL ); - gdk_gc_set_clip_origin( m_textGC, 0, 0 ); - if (!m_currentClippingRegion.IsNull()) - gdk_gc_set_clip_region( m_textGC, m_currentClippingRegion.GetRegion() ); - } - else - { - gdk_gc_set_clip_mask( m_penGC, (GdkBitmap *) NULL ); - gdk_gc_set_clip_origin( m_penGC, 0, 0 ); - if (!m_currentClippingRegion.IsNull()) - gdk_gc_set_clip_region( m_penGC, m_currentClippingRegion.GetRegion() ); - } - } - - if (new_mask) - gdk_bitmap_unref( new_mask ); - } - else // use_bitmap_method - { - if ((width != ww) || (height != hh)) - { - // get clip coords - wxRegion tmp( xx,yy,ww,hh ); - tmp.Intersect( m_currentClippingRegion ); - wxCoord cx,cy,cw,ch; - tmp.GetBox(cx,cy,cw,ch); - - // rescale bitmap - wxBitmap bitmap = memDC->m_selected.Rescale( cx-xx, cy-yy, cw, ch, ww, hh ); - - // draw scaled bitmap - // was: gdk_draw_pixmap( m_window, m_penGC, bitmap.GetPixmap(), 0, 0, xx, yy, -1, -1 ); - gdk_draw_pixmap( m_window, m_penGC, bitmap.GetPixmap(), 0, 0, cx, cy, -1, -1 ); - } - else - { - // No scaling and not a memory dc with a mask either - - // copy including child window contents - gdk_gc_set_subwindow( m_penGC, GDK_INCLUDE_INFERIORS ); - gdk_window_copy_area( m_window, m_penGC, xx, yy, - srcDC->GetWindow(), - xsrc, ysrc, width, height ); - gdk_gc_set_subwindow( m_penGC, GDK_CLIP_BY_CHILDREN ); - } - } - - SetLogicalFunction( old_logical_func ); - - return TRUE; -} - -void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) -{ - wxCHECK_RET( Ok(), wxT("invalid window dc") ); - - if (!m_window) return; - - if (text.empty()) return; - -#ifndef __WXGTK20__ - GdkFont *font = m_font.GetInternalFont( m_scaleY ); - - wxCHECK_RET( font, wxT("invalid font") ); -#endif - -#ifdef __WXGTK20__ - wxCHECK_RET( m_context, wxT("no Pango context") ); -#endif - - x = XLOG2DEV(x); - y = YLOG2DEV(y); - -#ifdef __WXGTK20__ - // TODO: the layout engine should be abstracted at a higher level! - PangoLayout *layout = pango_layout_new(m_context); - -#if wxUSE_UNICODE - const wxCharBuffer data = wxConvUTF8.cWC2MB( text ); -#else - const wxWCharBuffer wdata = wxConvLocal.cMB2WC( text ); - const wxCharBuffer data = wxConvUTF8.cWC2MB( wdata ); -#endif - - pango_layout_set_text( layout, (const char*)data, strlen((const char*)data) ); - - if (fabs(m_scaleY - 1.0) < 0.00001) - { - // If there is a user or actually any scale applied to - // the device context, scale the font. - - // scale font description - gint oldSize = pango_font_description_get_size( m_fontdesc ); - double size = oldSize; - size = size * m_scaleY; - pango_font_description_set_size( m_fontdesc, (gint)size ); - - // actually apply scaled font - pango_layout_set_font_description( layout, m_fontdesc ); - - // Draw layout. - gdk_draw_layout( m_window, m_textGC, x, y, layout ); - - // reset unscaled size - pango_font_description_set_size( m_fontdesc, oldSize ); - } - else - { - // actually apply font - pango_layout_set_font_description( layout, m_fontdesc ); - - // Draw layout. - gdk_draw_layout( m_window, m_textGC, x, y, layout ); - } - -#if 0 - // Measure layout - int w,h; - pango_layout_get_pixel_size( m_layout, &w, &h ); -#else - int w = 10; - int h = 10; -#endif - wxCoord width = w; - wxCoord height = h; - - g_object_unref( G_OBJECT( layout ) ); -#else // GTK+ 1.x - wxCoord width = gdk_string_width( font, text.mbc_str() ); - wxCoord height = font->ascent + font->descent; - - if ( m_backgroundMode == wxSOLID ) - { - gdk_gc_set_foreground( m_textGC, m_textBackgroundColour.GetColor() ); - gdk_draw_rectangle( m_window, m_textGC, TRUE, x, y, width, height ); - gdk_gc_set_foreground( m_textGC, m_textForegroundColour.GetColor() ); - } - gdk_draw_string( m_window, font, m_textGC, x, y + font->ascent, text.mbc_str() ); - - /* CMB 17/7/98: simple underline: ignores scaling and underlying - X font's XA_UNDERLINE_POSITION and XA_UNDERLINE_THICKNESS - properties (see wxXt implementation) */ - if (m_font.GetUnderlined()) - { - wxCoord ul_y = y + font->ascent; - if (font->descent > 0) ul_y++; - gdk_draw_line( m_window, m_textGC, x, ul_y, x + width, ul_y); - } -#endif // GTK+ 2.0/1.x - - - width = wxCoord(width / m_scaleX); - height = wxCoord(height / m_scaleY); - CalcBoundingBox (x + width, y + height); - CalcBoundingBox (x, y); -} - -void wxWindowDC::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord y, double angle ) -{ - if (angle == 0.0) - { - DrawText(text, x, y); - return; - } - - wxCHECK_RET( Ok(), wxT("invalid window dc") ); - - if (!m_window) return; - - GdkFont *font = m_font.GetInternalFont( m_scaleY ); - - wxCHECK_RET( font, wxT("invalid font") ); - - // the size of the text - wxCoord w = gdk_string_width( font, text.mbc_str() ); - wxCoord h = font->ascent + font->descent; - - // draw the string normally - wxBitmap src(w, h); - wxMemoryDC dc; - dc.SelectObject(src); - dc.SetFont(GetFont()); - dc.SetBackground(*wxWHITE_BRUSH); - dc.SetBrush(*wxBLACK_BRUSH); - dc.Clear(); - dc.DrawText(text, 0, 0); - dc.SelectObject(wxNullBitmap); - - // Calculate the size of the rotated bounding box. - double rad = DegToRad(angle); - double dx = cos(rad), - dy = sin(rad); - - // the rectngle vertices are counted clockwise with the first one being at - // (0, 0) (or, rather, at (x, y)) - double x2 = w*dx, - y2 = -w*dy; // y axis points to the bottom, hence minus - double x4 = h*dy, - y4 = h*dx; - double x3 = x4 + x2, - y3 = y4 + y2; - - // calc max and min - wxCoord maxX = (wxCoord)(dmax(x2, dmax(x3, x4)) + 0.5), - maxY = (wxCoord)(dmax(y2, dmax(y3, y4)) + 0.5), - minX = (wxCoord)(dmin(x2, dmin(x3, x4)) - 0.5), - minY = (wxCoord)(dmin(y2, dmin(y3, y4)) - 0.5); - - // prepare to blit-with-rotate the bitmap to the DC - wxImage image = src.ConvertToImage(); - - GdkColor *colText = m_textForegroundColour.GetColor(), - *colBack = m_textBackgroundColour.GetColor(); - - bool textColSet = TRUE; - - unsigned char *data = image.GetData(); - - // paint pixel by pixel - for ( wxCoord srcX = 0; srcX < w; srcX++ ) - { - for ( wxCoord srcY = 0; srcY < h; srcY++ ) - { - // transform source coords to dest coords - double r = sqrt((double)srcX*srcX + srcY*srcY); - double angleOrig = atan2((double)srcY, (double)srcX) - rad; - wxCoord dstX = (wxCoord)(r*cos(angleOrig) + 0.5), - dstY = (wxCoord)(r*sin(angleOrig) + 0.5); - - // black pixel? - bool textPixel = data[(srcY*w + srcX)*3] == 0; - if ( textPixel || (m_backgroundMode == wxSOLID) ) - { - // change colour if needed - if ( textPixel != textColSet ) - { - gdk_gc_set_foreground( m_textGC, textPixel ? colText - : colBack ); - - textColSet = textPixel; - } - - // don't use DrawPoint() because it uses the current pen - // colour, and we don't need it here - gdk_draw_point( m_window, m_textGC, - XLOG2DEV(x) + dstX, YLOG2DEV(y) + dstY ); - } - } - } - - // it would be better to draw with non underlined font and draw the line - // manually here (it would be more straight...) -#if 0 - if ( m_font.GetUnderlined() ) - { - gdk_draw_line( m_window, m_textGC, - XLOG2DEV(x + x4), YLOG2DEV(y + y4 + font->descent), - XLOG2DEV(x + x3), YLOG2DEV(y + y3 + font->descent)); - } -#endif // 0 - - // restore the font colour - gdk_gc_set_foreground( m_textGC, colText ); - - // update the bounding box - CalcBoundingBox(x + minX, y + minY); - CalcBoundingBox(x + maxX, y + maxY); -} - -void wxWindowDC::DoGetTextExtent(const wxString &string, - wxCoord *width, wxCoord *height, - wxCoord *descent, wxCoord *externalLeading, - wxFont *theFont) const -{ - if (string.IsEmpty()) - { - if (width) (*width) = 0; - if (height) (*height) = 0; - return; - } - -#ifdef __WXGTK20__ - // Create layout and set font description - PangoLayout *layout = pango_layout_new( m_context ); - if (theFont) - pango_layout_set_font_description( layout, theFont->GetNativeFontInfo()->description ); - else - pango_layout_set_font_description( layout, m_fontdesc ); - - // Set layout's text -#if wxUSE_UNICODE - const wxCharBuffer data = wxConvUTF8.cWC2MB( string ); -#else - const wxWCharBuffer wdata = wxConvLocal.cMB2WC( string ); - const wxCharBuffer data = wxConvUTF8.cWC2MB( wdata ); -#endif - pango_layout_set_text( layout, (const char*) data, strlen((const char*)data) ); - - // Measure text. - int w,h; - pango_layout_get_pixel_size( layout, &w, &h ); - - if (width) (*width) = (wxCoord) w; - if (height) (*height) = (wxCoord) h; - if (descent) - { - // Do something about metrics here. TODO. - (*descent) = 0; - } - if (externalLeading) (*externalLeading) = 0; // ?? - - g_object_unref( G_OBJECT( layout ) ); -#else - wxFont fontToUse = m_font; - if (theFont) fontToUse = *theFont; - - GdkFont *font = fontToUse.GetInternalFont( m_scaleY ); - if (width) (*width) = wxCoord(gdk_string_width( font, string.mbc_str() ) / m_scaleX); - if (height) (*height) = wxCoord((font->ascent + font->descent) / m_scaleY); - if (descent) (*descent) = wxCoord(font->descent / m_scaleY); - if (externalLeading) (*externalLeading) = 0; // ?? -#endif -} - -wxCoord wxWindowDC::GetCharWidth() const -{ -#ifdef __WXGTK20__ - // There should be an easier way. - PangoLayout *layout = pango_layout_new(m_context); - pango_layout_set_font_description(layout, m_fontdesc); - pango_layout_set_text(layout, "H", 1 ); - int w,h; - pango_layout_get_pixel_size(layout, &w, &h); - g_object_unref( G_OBJECT( layout ) ); - return w; -#else - GdkFont *font = m_font.GetInternalFont( m_scaleY ); - wxCHECK_MSG( font, -1, wxT("invalid font") ); - - return wxCoord(gdk_string_width( font, "H" ) / m_scaleX); -#endif -} - -wxCoord wxWindowDC::GetCharHeight() const -{ -#ifdef __WXGTK20__ - // There should be an easier way. - PangoLayout *layout = pango_layout_new(m_context); - pango_layout_set_font_description(layout, m_fontdesc); - pango_layout_set_text(layout, "H", 1); - int w,h; - pango_layout_get_pixel_size(layout, &w, &h); - g_object_unref( G_OBJECT( layout ) ); - return h; -#else - GdkFont *font = m_font.GetInternalFont( m_scaleY ); - wxCHECK_MSG( font, -1, wxT("invalid font") ); - - return wxCoord((font->ascent + font->descent) / m_scaleY); -#endif -} - -void wxWindowDC::Clear() -{ - wxCHECK_RET( Ok(), wxT("invalid window dc") ); - - if (!m_window) return; - - // VZ: the code below results in infinite recursion and crashes when - // dc.Clear() is done from OnPaint() so I disable it for now. - // I don't know what the correct fix is but Clear() surely should not - // reenter OnPaint()! -#if 0 - /* - we either are a memory dc or have a window as the - owner. anything else shouldn't happen. - - we don't use gdk_window_clear() as we don't set - the window's background colour anymore. it is too - much pain to keep the DC's and the window's back- - ground colour in synch. */ - - if (m_owner) - { - m_owner->Clear(); - return; - } - - if (m_isMemDC) - { - int width,height; - GetSize( &width, &height ); - gdk_draw_rectangle( m_window, m_bgGC, TRUE, 0, 0, width, height ); - return; - } -#else // 1 - int width,height; - GetSize( &width, &height ); - gdk_draw_rectangle( m_window, m_bgGC, TRUE, 0, 0, width, height ); -#endif // 0/1 -} - -void wxWindowDC::SetFont( const wxFont &font ) -{ - // It is common practice to set the font to wxNullFont, so - // don't consider it to be an error - // wxCHECK_RET( font.Ok(), _T("invalid font in wxWindowDC::SetFont") ); - - m_font = font; -#ifdef __WXGTK20__ - if (m_font.Ok()) - { - m_fontdesc = m_font.GetNativeFontInfo()->description; - - if (m_owner) - { - m_context = m_owner->GtkGetPangoDefaultContext(); - } - } -#endif -} - -void wxWindowDC::SetPen( const wxPen &pen ) -{ - wxCHECK_RET( Ok(), wxT("invalid window dc") ); - - if (m_pen == pen) return; - - m_pen = pen; - - if (!m_pen.Ok()) return; - - if (!m_window) return; - - gint width = m_pen.GetWidth(); - if (width <= 0) - { - // CMB: if width is non-zero scale it with the dc - width = 1; - } - else - { - // X doesn't allow different width in x and y and so we take - // the average - double w = 0.5 + - ( fabs((double) XLOG2DEVREL(width)) + - fabs((double) YLOG2DEVREL(width)) ) / 2.0; - width = (int)w; - } - - static const wxGTKDash dotted[] = {1, 1}; - static const wxGTKDash short_dashed[] = {2, 2}; - static const wxGTKDash wxCoord_dashed[] = {2, 4}; - static const wxGTKDash dotted_dashed[] = {3, 3, 1, 3}; - - // We express dash pattern in pen width unit, so we are - // independent of zoom factor and so on... - int req_nb_dash; - const wxGTKDash *req_dash; - - GdkLineStyle lineStyle = GDK_LINE_SOLID; - switch (m_pen.GetStyle()) - { - case wxUSER_DASH: - { - lineStyle = GDK_LINE_ON_OFF_DASH; - req_nb_dash = m_pen.GetDashCount(); - req_dash = (wxGTKDash*)m_pen.GetDash(); - break; - } - case wxDOT: - { - lineStyle = GDK_LINE_ON_OFF_DASH; - req_nb_dash = 2; - req_dash = dotted; - break; - } - case wxLONG_DASH: - { - lineStyle = GDK_LINE_ON_OFF_DASH; - req_nb_dash = 2; - req_dash = wxCoord_dashed; - break; - } - case wxSHORT_DASH: - { - lineStyle = GDK_LINE_ON_OFF_DASH; - req_nb_dash = 2; - req_dash = short_dashed; - break; - } - case wxDOT_DASH: - { -// lineStyle = GDK_LINE_DOUBLE_DASH; - lineStyle = GDK_LINE_ON_OFF_DASH; - req_nb_dash = 4; - req_dash = dotted_dashed; - break; - } - - case wxTRANSPARENT: - case wxSTIPPLE_MASK_OPAQUE: - case wxSTIPPLE: - case wxSOLID: - default: - { - lineStyle = GDK_LINE_SOLID; - req_dash = (wxGTKDash*)NULL; - req_nb_dash = 0; - break; - } - } - -#if (GTK_MINOR_VERSION > 0) || (GTK_MAJOR_VERSION > 1) - if (req_dash && req_nb_dash) - { - wxGTKDash *real_req_dash = new wxGTKDash[req_nb_dash]; - if (real_req_dash) - { - for (int i = 0; i < req_nb_dash; i++) - real_req_dash[i] = req_dash[i] * width; - gdk_gc_set_dashes( m_penGC, 0, real_req_dash, req_nb_dash ); - delete[] real_req_dash; - } - else - { - // No Memory. We use non-scaled dash pattern... - gdk_gc_set_dashes( m_penGC, 0, (wxGTKDash*)req_dash, req_nb_dash ); - } - } -#endif // GTK+ > 1.0 - - GdkCapStyle capStyle = GDK_CAP_ROUND; - switch (m_pen.GetCap()) - { - case wxCAP_PROJECTING: { capStyle = GDK_CAP_PROJECTING; break; } - case wxCAP_BUTT: { capStyle = GDK_CAP_BUTT; break; } - case wxCAP_ROUND: - default: - { - if (width <= 1) - { - width = 0; - capStyle = GDK_CAP_NOT_LAST; - } - else - { - capStyle = GDK_CAP_ROUND; - } - break; - } - } - - GdkJoinStyle joinStyle = GDK_JOIN_ROUND; - switch (m_pen.GetJoin()) - { - case wxJOIN_BEVEL: { joinStyle = GDK_JOIN_BEVEL; break; } - case wxJOIN_MITER: { joinStyle = GDK_JOIN_MITER; break; } - case wxJOIN_ROUND: - default: { joinStyle = GDK_JOIN_ROUND; break; } - } - - gdk_gc_set_line_attributes( m_penGC, width, lineStyle, capStyle, joinStyle ); - - m_pen.GetColour().CalcPixel( m_cmap ); - gdk_gc_set_foreground( m_penGC, m_pen.GetColour().GetColor() ); -} - -void wxWindowDC::SetBrush( const wxBrush &brush ) -{ - wxCHECK_RET( Ok(), wxT("invalid window dc") ); - - if (m_brush == brush) return; - - m_brush = brush; - - if (!m_brush.Ok()) return; - - if (!m_window) return; - - m_brush.GetColour().CalcPixel( m_cmap ); - gdk_gc_set_foreground( m_brushGC, m_brush.GetColour().GetColor() ); - - gdk_gc_set_fill( m_brushGC, GDK_SOLID ); - - if ((m_brush.GetStyle() == wxSTIPPLE) && (m_brush.GetStipple()->Ok())) - { - if (m_brush.GetStipple()->GetPixmap()) - { - gdk_gc_set_fill( m_brushGC, GDK_TILED ); - gdk_gc_set_tile( m_brushGC, m_brush.GetStipple()->GetPixmap() ); - } - else - { - gdk_gc_set_fill( m_brushGC, GDK_STIPPLED ); - gdk_gc_set_stipple( m_brushGC, m_brush.GetStipple()->GetBitmap() ); - } - } - - if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask())) - { - gdk_gc_set_fill( m_textGC, GDK_OPAQUE_STIPPLED); - gdk_gc_set_stipple( m_textGC, m_brush.GetStipple()->GetMask()->GetBitmap() ); - } - - if (IS_HATCH(m_brush.GetStyle())) - { - gdk_gc_set_fill( m_brushGC, GDK_STIPPLED ); - int num = m_brush.GetStyle() - wxBDIAGONAL_HATCH; - gdk_gc_set_stipple( m_brushGC, hatches[num] ); - } -} - -void wxWindowDC::SetBackground( const wxBrush &brush ) -{ - /* CMB 21/7/98: Added SetBackground. Sets background brush - * for Clear() and bg colour for shapes filled with cross-hatch brush */ - - wxCHECK_RET( Ok(), wxT("invalid window dc") ); - - if (m_backgroundBrush == brush) return; - - m_backgroundBrush = brush; - - if (!m_backgroundBrush.Ok()) return; - - if (!m_window) return; - - 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() ); - - gdk_gc_set_fill( m_bgGC, GDK_SOLID ); - - if ((m_backgroundBrush.GetStyle() == wxSTIPPLE) && (m_backgroundBrush.GetStipple()->Ok())) - { - if (m_backgroundBrush.GetStipple()->GetPixmap()) - { - gdk_gc_set_fill( m_bgGC, GDK_TILED ); - gdk_gc_set_tile( m_bgGC, m_backgroundBrush.GetStipple()->GetPixmap() ); - } - else - { - gdk_gc_set_fill( m_bgGC, GDK_STIPPLED ); - gdk_gc_set_stipple( m_bgGC, m_backgroundBrush.GetStipple()->GetBitmap() ); - } - } - - if (IS_HATCH(m_backgroundBrush.GetStyle())) - { - gdk_gc_set_fill( m_bgGC, GDK_STIPPLED ); - int num = m_backgroundBrush.GetStyle() - wxBDIAGONAL_HATCH; - gdk_gc_set_stipple( m_bgGC, hatches[num] ); - } -} - -void wxWindowDC::SetLogicalFunction( int function ) -{ - wxCHECK_RET( Ok(), wxT("invalid window dc") ); - - if (m_logicalFunction == function) - return; - - // VZ: shouldn't this be a CHECK? - if (!m_window) - return; - - GdkFunction mode; - switch (function) - { - case wxXOR: mode = GDK_XOR; break; - case wxINVERT: mode = GDK_INVERT; break; -#if (GTK_MINOR_VERSION > 0) || (GTK_MAJOR_VERSION > 1) - case wxOR_REVERSE: mode = GDK_OR_REVERSE; break; - case wxAND_REVERSE: mode = GDK_AND_REVERSE; break; - case wxCLEAR: mode = GDK_CLEAR; break; - case wxSET: mode = GDK_SET; break; - case wxOR_INVERT: mode = GDK_OR_INVERT; break; - case wxAND: mode = GDK_AND; break; - case wxOR: mode = GDK_OR; break; - case wxEQUIV: mode = GDK_EQUIV; break; - case wxNAND: mode = GDK_NAND; break; - case wxAND_INVERT: mode = GDK_AND_INVERT; break; - case wxCOPY: mode = GDK_COPY; break; - case wxNO_OP: mode = GDK_NOOP; break; - case wxSRC_INVERT: mode = GDK_COPY_INVERT; break; - - // unsupported by GTK - case wxNOR: mode = GDK_COPY; break; -#endif // GTK+ > 1.0 - default: - wxFAIL_MSG( wxT("unsupported logical function") ); - mode = GDK_COPY; - } - - m_logicalFunction = function; - - gdk_gc_set_function( m_penGC, mode ); - gdk_gc_set_function( m_brushGC, mode ); - - // to stay compatible with wxMSW, we don't apply ROPs to the text - // operations (i.e. DrawText/DrawRotatedText). - // True, but mono-bitmaps use the m_textGC and they use ROPs as well. - gdk_gc_set_function( m_textGC, mode ); -} - -void wxWindowDC::SetTextForeground( const wxColour &col ) -{ - wxCHECK_RET( Ok(), wxT("invalid window dc") ); - - // don't set m_textForegroundColour to an invalid colour as we'd crash - // later then (we use m_textForegroundColour.GetColor() without checking - // in a few places) - if ( !col.Ok() || (m_textForegroundColour == col) ) - return; - - m_textForegroundColour = col; - - if ( m_window ) - { - m_textForegroundColour.CalcPixel( m_cmap ); - gdk_gc_set_foreground( m_textGC, m_textForegroundColour.GetColor() ); - } -} - -void wxWindowDC::SetTextBackground( const wxColour &col ) -{ - wxCHECK_RET( Ok(), wxT("invalid window dc") ); - - // same as above - if ( !col.Ok() || (m_textBackgroundColour == col) ) - return; - - m_textBackgroundColour = col; - - if ( m_window ) - { - m_textBackgroundColour.CalcPixel( m_cmap ); - gdk_gc_set_background( m_textGC, m_textBackgroundColour.GetColor() ); - } -} - -void wxWindowDC::SetBackgroundMode( int mode ) -{ - wxCHECK_RET( Ok(), wxT("invalid window dc") ); - - m_backgroundMode = mode; - - if (!m_window) return; - - // CMB 21/7/98: fill style of cross-hatch brushes is affected by - // transparent/solid background mode - - if (m_brush.GetStyle() != wxSOLID && m_brush.GetStyle() != wxTRANSPARENT) - { - gdk_gc_set_fill( m_brushGC, - (m_backgroundMode == wxTRANSPARENT) ? GDK_STIPPLED : GDK_OPAQUE_STIPPLED); - } -} - -void wxWindowDC::SetPalette( const wxPalette& WXUNUSED(palette) ) -{ - wxFAIL_MSG( wxT("wxWindowDC::SetPalette not implemented") ); -} - -void wxWindowDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) -{ - wxCHECK_RET( Ok(), wxT("invalid window dc") ); - - if (!m_window) return; - - wxRect rect; - rect.x = XLOG2DEV(x); - rect.y = YLOG2DEV(y); - rect.width = XLOG2DEVREL(width); - rect.height = YLOG2DEVREL(height); - - if (!m_currentClippingRegion.IsNull()) - m_currentClippingRegion.Intersect( rect ); - else - m_currentClippingRegion.Union( rect ); - -#if USE_PAINT_REGION - if (!m_paintClippingRegion.IsNull()) - m_currentClippingRegion.Intersect( m_paintClippingRegion ); -#endif - - wxCoord xx, yy, ww, hh; - m_currentClippingRegion.GetBox( xx, yy, ww, hh ); - wxDC::DoSetClippingRegion( xx, yy, ww, hh ); - - gdk_gc_set_clip_region( m_penGC, m_currentClippingRegion.GetRegion() ); - gdk_gc_set_clip_region( m_brushGC, m_currentClippingRegion.GetRegion() ); - gdk_gc_set_clip_region( m_textGC, m_currentClippingRegion.GetRegion() ); - gdk_gc_set_clip_region( m_bgGC, m_currentClippingRegion.GetRegion() ); -} - -void wxWindowDC::DoSetClippingRegionAsRegion( const wxRegion ®ion ) -{ - wxCHECK_RET( Ok(), wxT("invalid window dc") ); - - if (region.Empty()) - { - DestroyClippingRegion(); - return; - } - - if (!m_window) return; - - if (!m_currentClippingRegion.IsNull()) - m_currentClippingRegion.Intersect( region ); - else - m_currentClippingRegion.Union( region ); - -#if USE_PAINT_REGION - if (!m_paintClippingRegion.IsNull()) - m_currentClippingRegion.Intersect( m_paintClippingRegion ); -#endif - - wxCoord xx, yy, ww, hh; - m_currentClippingRegion.GetBox( xx, yy, ww, hh ); - wxDC::DoSetClippingRegion( xx, yy, ww, hh ); - - gdk_gc_set_clip_region( m_penGC, m_currentClippingRegion.GetRegion() ); - gdk_gc_set_clip_region( m_brushGC, m_currentClippingRegion.GetRegion() ); - gdk_gc_set_clip_region( m_textGC, m_currentClippingRegion.GetRegion() ); - gdk_gc_set_clip_region( m_bgGC, m_currentClippingRegion.GetRegion() ); -} - -void wxWindowDC::DestroyClippingRegion() -{ - wxCHECK_RET( Ok(), wxT("invalid window dc") ); - - wxDC::DestroyClippingRegion(); - - m_currentClippingRegion.Clear(); - -#if USE_PAINT_REGION - if (!m_paintClippingRegion.IsEmpty()) - m_currentClippingRegion.Union( m_paintClippingRegion ); -#endif - - if (!m_window) return; - - if (m_currentClippingRegion.IsEmpty()) - { - gdk_gc_set_clip_rectangle( m_penGC, (GdkRectangle *) NULL ); - gdk_gc_set_clip_rectangle( m_brushGC, (GdkRectangle *) NULL ); - gdk_gc_set_clip_rectangle( m_textGC, (GdkRectangle *) NULL ); - gdk_gc_set_clip_rectangle( m_bgGC, (GdkRectangle *) NULL ); - } - else - { - gdk_gc_set_clip_region( m_penGC, m_currentClippingRegion.GetRegion() ); - gdk_gc_set_clip_region( m_brushGC, m_currentClippingRegion.GetRegion() ); - gdk_gc_set_clip_region( m_textGC, m_currentClippingRegion.GetRegion() ); - gdk_gc_set_clip_region( m_bgGC, m_currentClippingRegion.GetRegion() ); - } -} - -void wxWindowDC::Destroy() -{ - if (m_penGC) wxFreePoolGC( m_penGC ); - m_penGC = (GdkGC*) NULL; - if (m_brushGC) wxFreePoolGC( m_brushGC ); - m_brushGC = (GdkGC*) NULL; - if (m_textGC) wxFreePoolGC( m_textGC ); - m_textGC = (GdkGC*) NULL; - if (m_bgGC) wxFreePoolGC( m_bgGC ); - m_bgGC = (GdkGC*) NULL; -} - -void wxWindowDC::ComputeScaleAndOrigin() -{ - /* CMB: copy scale to see if it changes */ - double origScaleX = m_scaleX; - double origScaleY = m_scaleY; - - wxDC::ComputeScaleAndOrigin(); - - /* CMB: if scale has changed call SetPen to recalulate the line width */ - if ((m_scaleX != origScaleX || m_scaleY != origScaleY) && - (m_pen.Ok())) - { - /* this is a bit artificial, but we need to force wxDC to think - the pen has changed */ - wxPen pen = m_pen; - m_pen = wxNullPen; - SetPen( pen ); - } -} - -// Resolution in pixels per logical inch -wxSize wxWindowDC::GetPPI() const -{ - return wxSize( (int) (m_mm_to_pix_x * 25.4 + 0.5), (int) (m_mm_to_pix_y * 25.4 + 0.5)); -} - -int wxWindowDC::GetDepth() const -{ - wxFAIL_MSG(wxT("not implemented")); - - return -1; -} - - -//----------------------------------------------------------------------------- -// wxPaintDC -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxClientDC) - -wxPaintDC::wxPaintDC( wxWindow *win ) - : wxClientDC( win ) -{ -#if USE_PAINT_REGION - if (!win->m_clipPaintRegion) - return; - - m_paintClippingRegion = win->GetUpdateRegion(); - GdkRegion *region = m_paintClippingRegion.GetRegion(); - if ( region ) - { - m_currentClippingRegion.Union( m_paintClippingRegion ); - - gdk_gc_set_clip_region( m_penGC, region ); - gdk_gc_set_clip_region( m_brushGC, region ); - gdk_gc_set_clip_region( m_textGC, region ); - gdk_gc_set_clip_region( m_bgGC, region ); - } -#endif // USE_PAINT_REGION -} - -//----------------------------------------------------------------------------- -// wxClientDC -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC) - -wxClientDC::wxClientDC( wxWindow *win ) - : wxWindowDC( win ) -{ - wxCHECK_RET( win, _T("NULL window in wxClientDC::wxClientDC") ); - -#ifdef __WXUNIVERSAL__ - wxPoint ptOrigin = win->GetClientAreaOrigin(); - SetDeviceOrigin(ptOrigin.x, ptOrigin.y); - wxSize size = win->GetClientSize(); - SetClippingRegion(wxPoint(0, 0), size); -#endif // __WXUNIVERSAL__ -} - -void wxClientDC::DoGetSize(int *width, int *height) const -{ - wxCHECK_RET( m_owner, _T("GetSize() doesn't work without window") ); - - m_owner->GetClientSize( width, height ); -} - -// ---------------------------------------------------------------------------- -// wxDCModule -// ---------------------------------------------------------------------------- - -class wxDCModule : public wxModule -{ -public: - bool OnInit(); - void OnExit(); - -private: - DECLARE_DYNAMIC_CLASS(wxDCModule) -}; - -IMPLEMENT_DYNAMIC_CLASS(wxDCModule, wxModule) - -bool wxDCModule::OnInit() -{ - wxInitGCPool(); - return TRUE; -} - -void wxDCModule::OnExit() -{ - wxCleanUpGCPool(); -} diff --git a/src/gtk1/dcmemory.cpp b/src/gtk1/dcmemory.cpp deleted file mode 100644 index 039212d1c0..0000000000 --- a/src/gtk1/dcmemory.cpp +++ /dev/null @@ -1,140 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: dcmemory.cpp -// Purpose: -// Author: Robert Roebling -// RCS-ID: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/dcmemory.h" - -#include -#include - -//----------------------------------------------------------------------------- -// wxMemoryDC -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxWindowDC) - -wxMemoryDC::wxMemoryDC() : wxWindowDC() -{ - m_ok = FALSE; - - m_cmap = gtk_widget_get_default_colormap(); -} - -wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) ) - : wxWindowDC() -{ - m_ok = FALSE; - - m_cmap = gtk_widget_get_default_colormap(); -} - -wxMemoryDC::~wxMemoryDC() -{ -} - -void wxMemoryDC::SelectObject( const wxBitmap& bitmap ) -{ - Destroy(); - m_selected = bitmap; - if (m_selected.Ok()) - { - if (m_selected.GetPixmap()) - { - m_window = m_selected.GetPixmap(); - } - else - { - m_window = m_selected.GetBitmap(); - } - - m_isMemDC = TRUE; - - SetUpDC(); - } - else - { - m_ok = FALSE; - m_window = (GdkWindow *) NULL; - } -} - -void wxMemoryDC::SetPen( const wxPen &pen ) -{ - if (m_selected.Ok() && m_selected.GetBitmap() && (*wxTRANSPARENT_PEN != pen)) - { - if (*wxWHITE_PEN == pen) - wxWindowDC::SetPen( *wxBLACK_PEN ); - else - wxWindowDC::SetPen( *wxWHITE_PEN ); - } - else - { - wxWindowDC::SetPen( pen ); - } -} - -void wxMemoryDC::SetBrush( const wxBrush &brush ) -{ - if (m_selected.Ok() && m_selected.GetBitmap() && (*wxTRANSPARENT_BRUSH != brush)) - { - if (*wxWHITE_BRUSH == brush) - wxWindowDC::SetBrush( *wxBLACK_BRUSH ); - else - wxWindowDC::SetBrush( *wxWHITE_BRUSH ); - } - else - { - wxWindowDC::SetBrush( brush ); - } -} - -void wxMemoryDC::SetTextForeground( const wxColour &col ) -{ - if (m_selected.Ok() && m_selected.GetBitmap()) - { - if (col == *wxWHITE) - wxWindowDC::SetTextForeground( *wxBLACK ); - else - wxWindowDC::SetTextForeground( *wxWHITE ); - } - else - { - wxWindowDC::SetTextForeground( col ); - } -} - -void wxMemoryDC::SetTextBackground( const wxColour &col ) -{ - if (m_selected.Ok() && m_selected.GetBitmap()) - { - if (col == *wxWHITE) - wxWindowDC::SetTextBackground( *wxBLACK ); - else - wxWindowDC::SetTextBackground( *wxWHITE ); - } - else - { - wxWindowDC::SetTextBackground( col ); - } -} - -void wxMemoryDC::DoGetSize( int *width, int *height ) const -{ - if (m_selected.Ok()) - { - if (width) (*width) = m_selected.GetWidth(); - if (height) (*height) = m_selected.GetHeight(); - } - else - { - if (width) (*width) = 0; - if (height) (*height) = 0; - } -} - - diff --git a/src/gtk1/dcscreen.cpp b/src/gtk1/dcscreen.cpp deleted file mode 100644 index cf16e10dc5..0000000000 --- a/src/gtk1/dcscreen.cpp +++ /dev/null @@ -1,103 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: dcscreen.cpp -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/dcscreen.h" -#include "wx/window.h" - -#include -#include -#include - -//----------------------------------------------------------------------------- -// global data initialization -//----------------------------------------------------------------------------- - -GdkWindow *wxScreenDC::sm_overlayWindow = (GdkWindow*) NULL; -int wxScreenDC::sm_overlayWindowX = 0; -int wxScreenDC::sm_overlayWindowY = 0; - -//----------------------------------------------------------------------------- -// wxScreenDC -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxScreenDC,wxPaintDC) - -wxScreenDC::wxScreenDC() -{ - m_ok = FALSE; - m_cmap = gdk_colormap_get_system(); - m_window = GDK_ROOT_PARENT(); - - m_isScreenDC = TRUE; - - SetUpDC(); - - gdk_gc_set_subwindow( m_penGC, GDK_INCLUDE_INFERIORS ); - gdk_gc_set_subwindow( m_brushGC, GDK_INCLUDE_INFERIORS ); - gdk_gc_set_subwindow( m_textGC, GDK_INCLUDE_INFERIORS ); - gdk_gc_set_subwindow( m_bgGC, GDK_INCLUDE_INFERIORS ); -} - -wxScreenDC::~wxScreenDC() -{ - gdk_gc_set_subwindow( m_penGC, GDK_CLIP_BY_CHILDREN ); - gdk_gc_set_subwindow( m_brushGC, GDK_CLIP_BY_CHILDREN ); - gdk_gc_set_subwindow( m_textGC, GDK_CLIP_BY_CHILDREN ); - gdk_gc_set_subwindow( m_bgGC, GDK_CLIP_BY_CHILDREN ); - - EndDrawingOnTop(); -} - -bool wxScreenDC::StartDrawingOnTop( wxWindow *window ) -{ - if (!window) return StartDrawingOnTop(); - - int x = 0; - int y = 0; - window->GetPosition( &x, &y ); - int w = 0; - int h = 0; - window->GetSize( &w, &h ); - window->ClientToScreen( &x, &y ); - - wxRect rect; - rect.x = x; - rect.y = y; - rect.width = 0; - rect.height = 0; - - return StartDrawingOnTop( &rect ); -} - -bool wxScreenDC::StartDrawingOnTop( wxRect *rect ) -{ - int x = 0; - int y = 0; - int width = gdk_screen_width(); - int height = gdk_screen_height(); - if (rect) - { - x = rect->x; - y = rect->y; - width = rect->width; - height = rect->height; - } - - return TRUE; -} - -bool wxScreenDC::EndDrawingOnTop() -{ - return TRUE; -} - -void wxScreenDC::DoGetSize(int *width, int *height) const -{ - wxDisplaySize(width, height); -} diff --git a/src/gtk1/descrip.mms b/src/gtk1/descrip.mms deleted file mode 100644 index c87ecab7ae..0000000000 --- a/src/gtk1/descrip.mms +++ /dev/null @@ -1,224 +0,0 @@ -#***************************************************************************** -# * -# Make file for VMS * -# Author : J.Jansen (joukj@hrem.stm.tudelft.nl) * -# Date : 2 March 2000 * -# * -#***************************************************************************** -.first - define wx [--.include.wx] - -.ifdef __WXUNIVERSAL__ -CXX_DEFINE = /define=(__WXGTK__=1,__WXUNIVERSAL__==1)/float=ieee\ - /name=(as_is,short)/ieee=denorm/assume=(nostdnew,noglobal_array_new) -CC_DEFINE = /define=(__WXGTK__=1,__WXUNIVERSAL__==1)/float=ieee\ - /name=(as_is,short)/ieee=denorm -.else -CXX_DEFINE = /define=(__WXGTK__=1)/float=ieee/name=(as_is,short)/iee=denorm\ - /assume=(nostdnew,noglobal_array_new) -CC_DEFINE = /define=(__WXGTK__=1)/float=ieee/name=(as_is,short)/iee=denorm -.endif - -.suffixes : .cpp - -.cpp.obj : - cxx $(CXXFLAGS)$(CXX_DEFINE) $(MMS$TARGET_NAME).cpp -.c.obj : - cc $(CFLAGS)$(CC_DEFINE) $(MMS$TARGET_NAME).c - -OBJECTS = \ - app.obj,\ - bitmap.obj,\ - brush.obj,\ - clipbrd.obj,\ - colour.obj,\ - cursor.obj,\ - data.obj,\ - dataobj.obj,\ - dc.obj,\ - dcclient.obj,\ - dcmemory.obj,\ - dcscreen.obj,\ - dnd.obj,\ - font.obj,\ - gdiobj.obj,\ - glcanvas.obj,\ - gsockgtk.obj,\ - icon.obj,\ - main.obj,\ - minifram.obj,\ - pen.obj,\ - popupwin.obj,\ - region.obj,\ - settings.obj,\ - timer.obj,\ - tooltip.obj,\ - toplevel.obj,\ - utilsgtk.obj,\ - utilsres.obj,\ - win_gtk.obj,\ - window.obj - -OBJECTS0= \ - bmpbuttn.obj,\ - button.obj,\ - checkbox.obj,\ - checklst.obj,\ - choice.obj,\ - combobox.obj,\ - control.obj,\ - dialog.obj,\ - fontdlg.obj,\ - frame.obj,\ - gauge.obj,\ - listbox.obj,\ - mdi.obj,\ - menu.obj,\ - notebook.obj,\ - radiobox.obj,\ - radiobut.obj,\ - scrolbar.obj,\ - scrolwin.obj,\ - slider.obj,\ - spinbutt.obj,\ - spinctrl.obj,\ - statbmp.obj,\ - statbox.obj,\ - statline.obj,\ - stattext.obj,\ - tbargtk.obj,\ - textctrl.obj,\ - tglbtn.obj - -SOURCES =\ - app.cpp,\ - bitmap.cpp,\ - bmpbuttn.cpp,\ - brush.cpp,\ - button.cpp,\ - checkbox.cpp,\ - checklst.cpp,\ - choice.cpp,\ - clipbrd.cpp,\ - colour.cpp,\ - combobox.cpp,\ - control.cpp,\ - cursor.cpp,\ - data.cpp,\ - dataobj.cpp,\ - dc.cpp,\ - dcclient.cpp,\ - dcmemory.cpp,\ - dcscreen.cpp,\ - dialog.cpp,\ - dnd.cpp,\ - font.cpp,\ - fontdlg.cpp,\ - frame.cpp,\ - gauge.cpp,\ - gdiobj.cpp,\ - glcanvas.cpp,\ - gsockgtk.c,\ - icon.cpp,\ - listbox.cpp,\ - main.cpp,\ - mdi.cpp,\ - menu.cpp,\ - minifram.cpp,\ - notebook.cpp,\ - pen.cpp,\ - popupwin.cpp,\ - radiobox.cpp,\ - radiobut.cpp,\ - region.cpp,\ - scrolbar.cpp,\ - scrolwin.cpp,\ - settings.cpp,\ - slider.cpp,\ - spinbutt.cpp,\ - spinctrl.cpp,\ - statbmp.cpp,\ - statbox.cpp,\ - statline.cpp,\ - stattext.cpp,\ - tbargtk.cpp,\ - textctrl.cpp,\ - tglbtn.cpp,\ - timer.cpp,\ - tooltip.cpp,\ - toplevel.cpp,\ - utilsgtk.cpp,\ - utilsres.cpp,\ - win_gtk.c,\ - window.cpp - -all : $(SOURCES) - $(MMS)$(MMSQUALIFIERS) $(OBJECTS) -.ifdef __WXUNIVERSAL__ - library [--.lib]libwx_gtk_univ.olb $(OBJECTS) -.else - library [--.lib]libwx_gtk.olb $(OBJECTS) - $(MMS)$(MMSQUALIFIERS) $(OBJECTS0) - library [--.lib]libwx_gtk.olb $(OBJECTS0) -.endif - -app.obj : app.cpp -bitmap.obj : bitmap.cpp -bmpbuttn.obj : bmpbuttn.cpp -brush.obj : brush.cpp -button.obj : button.cpp -checkbox.obj : checkbox.cpp -checklst.obj : checklst.cpp -choice.obj : choice.cpp -clipbrd.obj :clipbrd.cpp -colour.obj : colour.cpp -combobox.obj : combobox.cpp -control.obj : control.cpp -cursor.obj : cursor.cpp -data.obj : data.cpp -dataobj.obj : dataobj.cpp -dc.obj : dc.cpp -dcclient.obj : dcclient.cpp -dcmemory.obj : dcmemory.cpp -dcscreen.obj : dcscreen.cpp -dialog.obj : dialog.cpp -dnd.obj : dnd.cpp -font.obj : font.cpp -fontdlg.obj : fontdlg.cpp -frame.obj : frame.cpp -gauge.obj : gauge.cpp -gdiobj.obj : gdiobj.cpp -glcanvas.obj : glcanvas.cpp -gsockgtk.obj : gsockgtk.c -icon.obj : icon.cpp -listbox.obj : listbox.cpp -main.obj : main.cpp -mdi.obj : mdi.cpp -menu.obj : menu.cpp -minifram.obj : minifram.cpp -notebook.obj : notebook.cpp -pen.obj : pen.cpp -popupwin.obj : popupwin.cpp -radiobox.obj : radiobox.cpp -radiobut.obj : radiobut.cpp -region.obj : region.cpp -scrolbar.obj : scrolbar.cpp -scrolwin.obj : scrolwin.cpp -settings.obj : settings.cpp -slider.obj : slider.cpp -spinbutt.obj : spinbutt.cpp -spinctrl.obj : spinctrl.cpp -statbmp.obj : statbmp.cpp -statbox.obj : statbox.cpp -statline.obj : statline.cpp -stattext.obj : stattext.cpp -tbargtk.obj : tbargtk.cpp -textctrl.obj : textctrl.cpp -tglbtn.obj : tglbtn.cpp -timer.obj : timer.cpp -tooltip.obj : tooltip.cpp -toplevel.obj : toplevel.cpp -utilsgtk.obj : utilsgtk.cpp -utilsres.obj : utilsres.cpp -win_gtk.obj : win_gtk.c -window.obj : window.cpp diff --git a/src/gtk1/dialog.cpp b/src/gtk1/dialog.cpp deleted file mode 100644 index 756c6959b4..0000000000 --- a/src/gtk1/dialog.cpp +++ /dev/null @@ -1,239 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: dialog.cpp -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/dialog.h" -#include "wx/frame.h" -#include "wx/app.h" -#include "wx/cursor.h" - -#include -#include -#include - -#include "wx/gtk/win_gtk.h" - -//----------------------------------------------------------------------------- -// idle system -//----------------------------------------------------------------------------- - -extern void wxapp_install_idle_handler(); -extern bool g_isIdle; -extern int g_openDialogs; - -//----------------------------------------------------------------------------- -// wxDialog -//----------------------------------------------------------------------------- - -BEGIN_EVENT_TABLE(wxDialog,wxDialogBase) - EVT_BUTTON (wxID_OK, wxDialog::OnOK) - EVT_BUTTON (wxID_CANCEL, wxDialog::OnCancel) - EVT_BUTTON (wxID_APPLY, wxDialog::OnApply) - EVT_CLOSE (wxDialog::OnCloseWindow) -END_EVENT_TABLE() - -IMPLEMENT_DYNAMIC_CLASS(wxDialog,wxTopLevelWindow) - -void wxDialog::Init() -{ - m_returnCode = 0; - m_sizeSet = FALSE; - m_modalShowing = FALSE; - m_themeEnabled = TRUE; -} - -wxDialog::wxDialog( wxWindow *parent, - wxWindowID id, const wxString &title, - const wxPoint &pos, const wxSize &size, - long style, const wxString &name ) -{ - Init(); - - (void)Create( parent, id, title, pos, size, style, name ); -} - -bool wxDialog::Create( wxWindow *parent, - wxWindowID id, const wxString &title, - const wxPoint &pos, const wxSize &size, - long style, const wxString &name ) -{ - SetExtraStyle(GetExtraStyle() | wxTOPLEVEL_EX_DIALOG); - - // all dialogs should have tab traversal enabled - style |= wxTAB_TRAVERSAL; - - return wxTopLevelWindow::Create(parent, id, title, pos, size, style, name); -} - -void wxDialog::OnApply( wxCommandEvent &WXUNUSED(event) ) -{ - if (Validate()) - TransferDataFromWindow(); -} - -void wxDialog::OnCancel( wxCommandEvent &WXUNUSED(event) ) -{ - if (IsModal()) - { - EndModal(wxID_CANCEL); - } - else - { - SetReturnCode(wxID_CANCEL); - Show(FALSE); - } -} - -void wxDialog::OnOK( wxCommandEvent &WXUNUSED(event) ) -{ - if (Validate() && TransferDataFromWindow()) - { - if (IsModal()) - { - EndModal(wxID_OK); - } - else - { - SetReturnCode(wxID_OK); - Show(FALSE); - } - } -} - -void wxDialog::OnPaint( wxPaintEvent& WXUNUSED(event) ) -{ - // yes -} - -void wxDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event)) -{ - // We'll send a Cancel message by default, - // which may close the dialog. - // Check for looping if the Cancel event handler calls Close(). - - // Note that if a cancel button and handler aren't present in the dialog, - // nothing will happen when you close the dialog via the window manager, or - // via Close(). - // We wouldn't want to destroy the dialog by default, since the dialog may have been - // created on the stack. - // However, this does mean that calling dialog->Close() won't delete the dialog - // unless the handler for wxID_CANCEL does so. So use Destroy() if you want to be - // sure to destroy the dialog. - // The default OnCancel (above) simply ends a modal dialog, and hides a modeless dialog. - - static wxList s_closing; - - if (s_closing.Member(this)) - return; // no loops - - s_closing.Append(this); - - wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); - cancelEvent.SetEventObject( this ); - GetEventHandler()->ProcessEvent(cancelEvent); - s_closing.DeleteObject(this); -} - -bool wxDialog::Show( bool show ) -{ - if (!show && IsModal()) - { - EndModal( wxID_CANCEL ); - } - - if (show && !m_sizeSet) - { - /* by calling GtkOnSize here, we don't have to call - either after showing the frame, which would entail - much ugly flicker nor from within the size_allocate - handler, because GTK 1.1.X forbids that. */ - - GtkOnSize( m_x, m_y, m_width, m_height ); - } - - bool ret = wxWindow::Show( show ); - - if (show) InitDialog(); - - return ret; -} - -bool wxDialog::IsModal() const -{ - return m_modalShowing; -} - -void wxDialog::SetModal( bool WXUNUSED(flag) ) -{ -/* - if (flag) - m_windowStyle |= wxDIALOG_MODAL; - else - if (m_windowStyle & wxDIALOG_MODAL) m_windowStyle -= wxDIALOG_MODAL; -*/ - wxFAIL_MSG( wxT("wxDialog:SetModal obsolete now") ); -} - -int wxDialog::ShowModal() -{ - if (IsModal()) - { - wxFAIL_MSG( wxT("wxDialog:ShowModal called twice") ); - return GetReturnCode(); - } - - // use the apps top level window as parent if none given unless explicitly - // forbidden - if ( !GetParent() && !(GetWindowStyleFlag() & wxDIALOG_NO_PARENT) ) - { - wxWindow *parent = wxTheApp->GetTopWindow(); - if ( parent && - parent != this && - parent->IsBeingDeleted() && - !(parent->GetExtraStyle() & wxWS_EX_TRANSIENT) ) - { - m_parent = parent; - gtk_window_set_transient_for( GTK_WINDOW(m_widget), GTK_WINDOW(parent->m_widget) ); - } - } - - wxBusyCursorSuspender cs; // temporarily suppress the busy cursor - - Show( TRUE ); - - SetFocus(); - - m_modalShowing = TRUE; - - g_openDialogs++; - - gtk_grab_add( m_widget ); - gtk_main(); - gtk_grab_remove( m_widget ); - - g_openDialogs--; - - return GetReturnCode(); -} - -void wxDialog::EndModal( int retCode ) -{ - SetReturnCode( retCode ); - - if (!IsModal()) - { - wxFAIL_MSG( wxT("wxDialog:EndModal called twice") ); - return; - } - - m_modalShowing = FALSE; - - gtk_main_quit(); - - Show( FALSE ); -} diff --git a/src/gtk1/dnd.cpp b/src/gtk1/dnd.cpp deleted file mode 100644 index 4742e0b033..0000000000 --- a/src/gtk1/dnd.cpp +++ /dev/null @@ -1,930 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: dnd.cpp -// Purpose: wxDropTarget class -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////////// - -#include "wx/dnd.h" -#include "wx/log.h" - - -#if wxUSE_DRAG_AND_DROP - -#include "wx/window.h" -#include "wx/app.h" -#include "wx/gdicmn.h" -#include "wx/intl.h" -#include "wx/utils.h" - -#include "wx/gtk/private.h" - -#include - -#include -#include - -//----------------------------------------------------------------------------- -// idle system -//----------------------------------------------------------------------------- - -extern void wxapp_install_idle_handler(); -extern bool g_isIdle; - -//----------------------------------------------------------------------------- -// thread system -//----------------------------------------------------------------------------- - -#if wxUSE_THREADS -#endif - -//---------------------------------------------------------------------------- -// global data -//---------------------------------------------------------------------------- - -extern bool g_blockEventsOnDrag; - -// the flags used for the last DoDragDrop() -static long gs_flagsForDrag = 0; - -// the trace mask we use with wxLogTrace() - call -// wxLog::AddTraceMask(TRACE_DND) to enable the trace messages from here -// (there are quite a few of them, so don't enable this by default) -static const wxChar *TRACE_DND = _T("dnd"); - -//---------------------------------------------------------------------------- -// standard icons -//---------------------------------------------------------------------------- - -/* Copyright (c) Julian Smart */ -static const char * page_xpm[] = { -/* columns rows colors chars-per-pixel */ -"32 32 37 1", -"5 c #7198D9", -", c #769CDA", -"2 c #DCE6F6", -"i c #FFFFFF", -"e c #779DDB", -": c #9AB6E4", -"9 c #EAF0FA", -"- c #B1C7EB", -"$ c #6992D7", -"y c #F7F9FD", -"= c #BED0EE", -"q c #F0F5FC", -"; c #A8C0E8", -"@ c #366BC2", -" c None", -"u c #FDFEFF", -"8 c #5987D3", -"* c #C4D5F0", -"7 c #7CA0DC", -"O c #487BCE", -"< c #6B94D7", -"& c #CCDAF2", -"> c #89A9DF", -"3 c #5584D1", -"w c #82A5DE", -"1 c #3F74CB", -"+ c #3A70CA", -". c #3569BF", -"% c #D2DFF4", -"# c #3366BB", -"r c #F5F8FD", -"0 c #FAFCFE", -"4 c #DFE8F7", -"X c #5E8AD4", -"o c #5282D0", -"t c #B8CCEC", -"6 c #E5EDF9", -/* pixels */ -" ", -" ", -" ", -" ", -" ", -" .XXXooOO++@# ", -" $%&*=-;::>,<1 ", -" $2%&*=-;::><:3 ", -" $42%&*=-;::<&:3 ", -" 56477<<<<8<<9&:X ", -" 59642%&*=-;<09&:5 ", -" 5q9642%&*=-<<<<<# ", -" 5qqw777<<<<<88:>+ ", -" erqq9642%&*=t;::+ ", -" eyrqq9642%&*=t;:O ", -" eyywwww777<<<SetDragContext( context ); - - /* we don't need return values. this event is just for - information */ - drop_target->OnLeave(); - - /* this has to be done because GDK has no "drag_enter" event */ - drop_target->m_firstMotion = TRUE; - - /* after this, invalidate the drop_target's GdkDragContext */ - drop_target->SetDragContext( (GdkDragContext*) NULL ); -} - -// ---------------------------------------------------------------------------- -// "drag_motion" -// ---------------------------------------------------------------------------- - -static gboolean target_drag_motion( GtkWidget *WXUNUSED(widget), - GdkDragContext *context, - gint x, - gint y, - guint time, - wxDropTarget *drop_target ) -{ - if (g_isIdle) wxapp_install_idle_handler(); - - /* Owen Taylor: "if the coordinates not in a drop zone, - return FALSE, otherwise call gtk_drag_status() and - return TRUE" */ - - /* inform the wxDropTarget about the current GdkDragContext. - this is only valid for the duration of this call */ - drop_target->SetDragContext( context ); - - // GTK+ always supposes that we want to copy the data by default while we - // might want to move it, so examine not only suggested_action - which is - // only good if we don't have our own preferences - but also the actions - // field - wxDragResult result; - if ( (gs_flagsForDrag & wxDrag_DefaultMove) == wxDrag_DefaultMove && - (context->actions & GDK_ACTION_MOVE ) ) - { - // move is requested by the program and allowed by GTK+ - do it, even - // though suggested_action may be currently wxDragCopy - result = wxDragMove; - } - else // use whatever GTK+ says we should - { - result = ConvertFromGTK(context->suggested_action); - - if ( (result == wxDragMove) && !(gs_flagsForDrag & wxDrag_AllowMove) ) - { - // we're requested to move but we can't - result = wxDragCopy; - } - } - - if (drop_target->m_firstMotion) - { - /* the first "drag_motion" event substitutes a "drag_enter" event */ - result = drop_target->OnEnter( x, y, result ); - } - else - { - /* give program a chance to react (i.e. to say no by returning FALSE) */ - result = drop_target->OnDragOver( x, y, result ); - } - - bool ret = wxIsDragResultOk( result ); - if (ret) - { - GdkDragAction action; - if (result == wxDragCopy) - action = GDK_ACTION_COPY; - else if (result == wxDragLink) - action = GDK_ACTION_LINK; - else - action = GDK_ACTION_MOVE; - - gdk_drag_status( context, action, time ); - } - - /* after this, invalidate the drop_target's GdkDragContext */ - drop_target->SetDragContext( (GdkDragContext*) NULL ); - - /* this has to be done because GDK has no "drag_enter" event */ - drop_target->m_firstMotion = FALSE; - - return ret; -} - -// ---------------------------------------------------------------------------- -// "drag_drop" -// ---------------------------------------------------------------------------- - -static gboolean target_drag_drop( GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - guint time, - wxDropTarget *drop_target ) -{ - if (g_isIdle) wxapp_install_idle_handler(); - - /* Owen Taylor: "if the drop is not in a drop zone, - return FALSE, otherwise, if you aren't accepting - the drop, call gtk_drag_finish() with success == FALSE - otherwise call gtk_drag_data_get()" */ - -// printf( "drop.\n" ); - - /* this seems to make a difference between not accepting - due to wrong target area and due to wrong format. let - us hope that this is not required.. */ - - /* inform the wxDropTarget about the current GdkDragContext. - this is only valid for the duration of this call */ - drop_target->SetDragContext( context ); - - /* inform the wxDropTarget about the current drag widget. - this is only valid for the duration of this call */ - drop_target->SetDragWidget( widget ); - - /* inform the wxDropTarget about the current drag time. - this is only valid for the duration of this call */ - drop_target->SetDragTime( time ); - -/* - wxDragResult result = wxDragMove; - if (context->suggested_action == GDK_ACTION_COPY) result = wxDragCopy; -*/ - - /* reset the block here as someone might very well - show a dialog as a reaction to a drop and this - wouldn't work without events */ - g_blockEventsOnDrag = FALSE; - - bool ret = drop_target->OnDrop( x, y ); - - if (!ret) - { - wxLogTrace(TRACE_DND, wxT( "Drop target: OnDrop returned FALSE") ); - - /* cancel the whole thing */ - gtk_drag_finish( context, - FALSE, /* no success */ - FALSE, /* don't delete data on dropping side */ - time ); - } - else - { - wxLogTrace(TRACE_DND, wxT( "Drop target: OnDrop returned TRUE") ); - -#if wxUSE_THREADS - /* disable GUI threads */ -#endif - - GdkAtom format = drop_target->GetMatchingPair(); - - // this does happen somehow, see bug 555111 - wxCHECK_MSG( format, FALSE, _T("no matching GdkAtom for format?") ) - -/* - GdkDragAction action = GDK_ACTION_MOVE; - if (result == wxDragCopy) action == GDK_ACTION_COPY; - context->action = action; -*/ - /* this should trigger an "drag_data_received" event */ - gtk_drag_get_data( widget, - context, - format, - time ); - -#if wxUSE_THREADS - /* re-enable GUI threads */ -#endif - } - - /* after this, invalidate the drop_target's GdkDragContext */ - drop_target->SetDragContext( (GdkDragContext*) NULL ); - - /* after this, invalidate the drop_target's drag widget */ - drop_target->SetDragWidget( (GtkWidget*) NULL ); - - /* this has to be done because GDK has no "drag_enter" event */ - drop_target->m_firstMotion = TRUE; - - return ret; -} - -// ---------------------------------------------------------------------------- -// "drag_data_received" -// ---------------------------------------------------------------------------- - -static void target_drag_data_received( GtkWidget *WXUNUSED(widget), - GdkDragContext *context, - gint x, - gint y, - GtkSelectionData *data, - guint WXUNUSED(info), - guint time, - wxDropTarget *drop_target ) -{ - if (g_isIdle) wxapp_install_idle_handler(); - - /* Owen Taylor: "call gtk_drag_finish() with - success == TRUE" */ - - if ((data->length <= 0) || (data->format != 8)) - { - /* negative data length and non 8-bit data format - qualifies for junk */ - gtk_drag_finish (context, FALSE, FALSE, time); - - return; - } - - wxLogTrace(TRACE_DND, wxT( "Drop target: data received event") ); - - /* inform the wxDropTarget about the current GtkSelectionData. - this is only valid for the duration of this call */ - drop_target->SetDragData( data ); - - wxDragResult result = ConvertFromGTK(context->suggested_action); - - if ( wxIsDragResultOk( drop_target->OnData( x, y, result ) ) ) - { - wxLogTrace(TRACE_DND, wxT( "Drop target: OnData returned TRUE") ); - - /* tell GTK that data transfer was successfull */ - gtk_drag_finish( context, TRUE, FALSE, time ); - } - else - { - wxLogTrace(TRACE_DND, wxT( "Drop target: OnData returned FALSE") ); - - /* tell GTK that data transfer was not successfull */ - gtk_drag_finish( context, FALSE, FALSE, time ); - } - - /* after this, invalidate the drop_target's drag data */ - drop_target->SetDragData( (GtkSelectionData*) NULL ); -} - -//---------------------------------------------------------------------------- -// wxDropTarget -//---------------------------------------------------------------------------- - -wxDropTarget::wxDropTarget( wxDataObject *data ) - : wxDropTargetBase( data ) -{ - m_firstMotion = TRUE; - m_dragContext = (GdkDragContext*) NULL; - m_dragWidget = (GtkWidget*) NULL; - m_dragData = (GtkSelectionData*) NULL; - m_dragTime = 0; -} - -wxDragResult wxDropTarget::OnDragOver( wxCoord WXUNUSED(x), - wxCoord WXUNUSED(y), - wxDragResult def ) -{ - // GetMatchingPair() checks for m_dataObject too, no need to do it here - - // disable the debug message from GetMatchingPair() - there are too many - // of them otherwise -#ifdef __WXDEBUG__ - wxLogNull noLog; -#endif // Debug - - return (GetMatchingPair() != (GdkAtom) 0) ? def : wxDragNone; -} - -bool wxDropTarget::OnDrop( wxCoord WXUNUSED(x), wxCoord WXUNUSED(y) ) -{ - if (!m_dataObject) - return FALSE; - - return (GetMatchingPair() != (GdkAtom) 0); -} - -wxDragResult wxDropTarget::OnData( wxCoord WXUNUSED(x), wxCoord WXUNUSED(y), - wxDragResult def ) -{ - if (!m_dataObject) - return wxDragNone; - - if (GetMatchingPair() == (GdkAtom) 0) - return wxDragNone; - - return GetData() ? def : wxDragNone; -} - -GdkAtom wxDropTarget::GetMatchingPair() -{ - if (!m_dataObject) - return (GdkAtom) 0; - - if (!m_dragContext) - return (GdkAtom) 0; - - GList *child = m_dragContext->targets; - while (child) - { - GdkAtom formatAtom = (GdkAtom) GPOINTER_TO_INT(child->data); - wxDataFormat format( formatAtom ); - -#ifdef __WXDEBUG__ - wxLogTrace(TRACE_DND, wxT("Drop target: drag has format: %s"), - format.GetId().c_str()); -#endif // Debug - - if (m_dataObject->IsSupportedFormat( format )) - return formatAtom; - - child = child->next; - } - - return (GdkAtom) 0; -} - -bool wxDropTarget::GetData() -{ - if (!m_dragData) - return FALSE; - - if (!m_dataObject) - return FALSE; - - wxDataFormat dragFormat( m_dragData->target ); - - if (!m_dataObject->IsSupportedFormat( dragFormat )) - return FALSE; - - m_dataObject->SetData( dragFormat, (size_t)m_dragData->length, (const void*)m_dragData->data ); - - return TRUE; -} - -void wxDropTarget::UnregisterWidget( GtkWidget *widget ) -{ - wxCHECK_RET( widget != NULL, wxT("unregister widget is NULL") ); - - gtk_drag_dest_unset( widget ); - - gtk_signal_disconnect_by_func( GTK_OBJECT(widget), - GTK_SIGNAL_FUNC(target_drag_leave), (gpointer) this ); - - gtk_signal_disconnect_by_func( GTK_OBJECT(widget), - GTK_SIGNAL_FUNC(target_drag_motion), (gpointer) this ); - - gtk_signal_disconnect_by_func( GTK_OBJECT(widget), - GTK_SIGNAL_FUNC(target_drag_drop), (gpointer) this ); - - gtk_signal_disconnect_by_func( GTK_OBJECT(widget), - GTK_SIGNAL_FUNC(target_drag_data_received), (gpointer) this ); -} - -void wxDropTarget::RegisterWidget( GtkWidget *widget ) -{ - wxCHECK_RET( widget != NULL, wxT("register widget is NULL") ); - - /* gtk_drag_dest_set() determines what default behaviour we'd like - GTK to supply. we don't want to specify out targets (=formats) - or actions in advance (i.e. not GTK_DEST_DEFAULT_MOTION and - not GTK_DEST_DEFAULT_DROP). instead we react individually to - "drag_motion" and "drag_drop" events. this makes it possible - to allow dropping on only a small area. we should set - GTK_DEST_DEFAULT_HIGHLIGHT as this will switch on the nice - highlighting if dragging over standard controls, but this - seems to be broken without the other two. */ - - gtk_drag_dest_set( widget, - (GtkDestDefaults) 0, /* no default behaviour */ - (GtkTargetEntry*) NULL, /* we don't supply any formats here */ - 0, /* number of targets = 0 */ - (GdkDragAction) 0 ); /* we don't supply any actions here */ - - gtk_signal_connect( GTK_OBJECT(widget), "drag_leave", - GTK_SIGNAL_FUNC(target_drag_leave), (gpointer) this ); - - gtk_signal_connect( GTK_OBJECT(widget), "drag_motion", - GTK_SIGNAL_FUNC(target_drag_motion), (gpointer) this ); - - gtk_signal_connect( GTK_OBJECT(widget), "drag_drop", - GTK_SIGNAL_FUNC(target_drag_drop), (gpointer) this ); - - gtk_signal_connect( GTK_OBJECT(widget), "drag_data_received", - GTK_SIGNAL_FUNC(target_drag_data_received), (gpointer) this ); -} - -//---------------------------------------------------------------------------- -// "drag_data_get" -//---------------------------------------------------------------------------- - -static void -source_drag_data_get (GtkWidget *WXUNUSED(widget), - GdkDragContext *WXUNUSED(context), - GtkSelectionData *selection_data, - guint WXUNUSED(info), - guint WXUNUSED(time), - wxDropSource *drop_source ) -{ - if (g_isIdle) wxapp_install_idle_handler(); - - wxDataFormat format( selection_data->target ); - - wxLogTrace(TRACE_DND, wxT("Drop source: format requested: %s"), - format.GetId().c_str()); - - drop_source->m_retValue = wxDragCancel; - - wxDataObject *data = drop_source->GetDataObject(); - - if (!data) - { - wxLogTrace(TRACE_DND, wxT("Drop source: no data object") ); - return; - } - - if (!data->IsSupportedFormat(format)) - { - wxLogTrace(TRACE_DND, wxT("Drop source: unsupported format") ); - return; - } - - if (data->GetDataSize(format) == 0) - { - wxLogTrace(TRACE_DND, wxT("Drop source: empty data") ); - return; - } - - size_t size = data->GetDataSize(format); - -// printf( "data size: %d.\n", (int)data_size ); - - guchar *d = new guchar[size]; - - if (!data->GetDataHere( format, (void*)d )) - { - delete[] d; - return; - } - -#if wxUSE_THREADS - /* disable GUI threads */ -#endif - - gtk_selection_data_set( selection_data, - selection_data->target, - 8, // 8-bit - d, - size ); - -#if wxUSE_THREADS - /* enable GUI threads */ -#endif - - delete[] d; -} - -//---------------------------------------------------------------------------- -// "drag_data_delete" -//---------------------------------------------------------------------------- - -static void source_drag_data_delete( GtkWidget *WXUNUSED(widget), - GdkDragContext *context, - wxDropSource *WXUNUSED(drop_source) ) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - - // printf( "Drag source: drag_data_delete\n" ); -} - -//---------------------------------------------------------------------------- -// "drag_begin" -//---------------------------------------------------------------------------- - -static void source_drag_begin( GtkWidget *WXUNUSED(widget), - GdkDragContext *WXUNUSED(context), - wxDropSource *WXUNUSED(drop_source) ) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - - // printf( "Drag source: drag_begin.\n" ); -} - -//---------------------------------------------------------------------------- -// "drag_end" -//---------------------------------------------------------------------------- - -static void source_drag_end( GtkWidget *WXUNUSED(widget), - GdkDragContext *WXUNUSED(context), - wxDropSource *drop_source ) -{ - if (g_isIdle) wxapp_install_idle_handler(); - - // printf( "Drag source: drag_end.\n" ); - - drop_source->m_waiting = FALSE; -} - -//----------------------------------------------------------------------------- -// "configure_event" from m_iconWindow -//----------------------------------------------------------------------------- - -static gint -gtk_dnd_window_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *WXUNUSED(event), wxDropSource *source ) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - - source->GiveFeedback( ConvertFromGTK(source->m_dragContext->action) ); - - return 0; -} - -//--------------------------------------------------------------------------- -// wxDropSource -//--------------------------------------------------------------------------- - -wxDropSource::wxDropSource(wxWindow *win, - const wxIcon &iconCopy, - const wxIcon &iconMove, - const wxIcon &iconNone) -{ - m_waiting = TRUE; - - m_iconWindow = (GtkWidget*) NULL; - - m_window = win; - m_widget = win->m_widget; - if (win->m_wxwindow) m_widget = win->m_wxwindow; - - m_retValue = wxDragCancel; - - SetIcons(iconCopy, iconMove, iconNone); -} - -wxDropSource::wxDropSource(wxDataObject& data, - wxWindow *win, - const wxIcon &iconCopy, - const wxIcon &iconMove, - const wxIcon &iconNone) -{ - m_waiting = TRUE; - - SetData( data ); - - m_iconWindow = (GtkWidget*) NULL; - - m_window = win; - m_widget = win->m_widget; - if (win->m_wxwindow) m_widget = win->m_wxwindow; - - m_retValue = wxDragCancel; - - SetIcons(iconCopy, iconMove, iconNone); -} - -void wxDropSource::SetIcons(const wxIcon &iconCopy, - const wxIcon &iconMove, - const wxIcon &iconNone) -{ - m_iconCopy = iconCopy; - m_iconMove = iconMove; - m_iconNone = iconNone; - - if ( !m_iconCopy.Ok() ) - m_iconCopy = wxIcon(page_xpm); - if ( !m_iconMove.Ok() ) - m_iconMove = m_iconCopy; - if ( !m_iconNone.Ok() ) - m_iconNone = m_iconCopy; -} - -wxDropSource::~wxDropSource() -{ -} - -void wxDropSource::PrepareIcon( int action, GdkDragContext *context ) -{ - // get the right icon to display - wxIcon *icon = NULL; - if ( action & GDK_ACTION_MOVE ) - icon = &m_iconMove; - else if ( action & GDK_ACTION_COPY ) - icon = &m_iconCopy; - else - icon = &m_iconNone; - - GdkBitmap *mask; - if ( icon->GetMask() ) - mask = icon->GetMask()->GetBitmap(); - else - mask = (GdkBitmap *)NULL; - - GdkPixmap *pixmap = icon->GetPixmap(); - - gint width,height; - gdk_window_get_size (pixmap, &width, &height); - - GdkColormap *colormap = gtk_widget_get_colormap( m_widget ); -#ifndef __WXGTK20__ - gtk_widget_push_visual (gdk_colormap_get_visual (colormap)); -#endif - gtk_widget_push_colormap (colormap); - - m_iconWindow = gtk_window_new (GTK_WINDOW_POPUP); - gtk_widget_set_events (m_iconWindow, GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK); - gtk_widget_set_app_paintable (GTK_WIDGET (m_iconWindow), TRUE); - -#ifndef __WXGTK20__ - gtk_widget_pop_visual (); -#endif - gtk_widget_pop_colormap (); - - gtk_widget_set_usize (m_iconWindow, width, height); - gtk_widget_realize (m_iconWindow); - - gtk_signal_connect( GTK_OBJECT(m_iconWindow), "configure_event", - GTK_SIGNAL_FUNC(gtk_dnd_window_configure_callback), (gpointer)this ); - - gdk_window_set_back_pixmap (m_iconWindow->window, pixmap, FALSE); - - if (mask) - gtk_widget_shape_combine_mask (m_iconWindow, mask, 0, 0); - - gtk_drag_set_icon_widget( context, m_iconWindow, 0, 0 ); -} - -wxDragResult wxDropSource::DoDragDrop(int flags) -{ - wxCHECK_MSG( m_data && m_data->GetFormatCount(), wxDragNone, - wxT("Drop source: no data") ); - - // still in drag - if (g_blockEventsOnDrag) - return wxDragNone; - - // disabled for now - g_blockEventsOnDrag = TRUE; - - RegisterWindow(); - - m_waiting = TRUE; - - GtkTargetList *target_list = gtk_target_list_new( (GtkTargetEntry*) NULL, 0 ); - - wxDataFormat *array = new wxDataFormat[ m_data->GetFormatCount() ]; - m_data->GetAllFormats( array ); - size_t count = m_data->GetFormatCount(); - for (size_t i = 0; i < count; i++) - { - GdkAtom atom = array[i]; - wxLogTrace(TRACE_DND, wxT("Drop source: Supported atom %s"), gdk_atom_name( atom )); - gtk_target_list_add( target_list, atom, 0, 0 ); - } - delete[] array; - - GdkEventMotion event; - event.window = m_widget->window; - int x = 0; - int y = 0; - GdkModifierType state; - gdk_window_get_pointer( event.window, &x, &y, &state ); - event.x = x; - event.y = y; - event.state = state; - event.time = (guint32)GDK_CURRENT_TIME; - - /* GTK wants to know which button was pressed which caused the dragging */ - int button_number = 0; - if (event.state & GDK_BUTTON1_MASK) button_number = 1; - else if (event.state & GDK_BUTTON2_MASK) button_number = 2; - else if (event.state & GDK_BUTTON3_MASK) button_number = 3; - -#if wxUSE_THREADS - /* disable GUI threads */ -#endif - - /* don't start dragging if no button is down */ - if (button_number) - { - int action = GDK_ACTION_COPY; - if ( flags & wxDrag_AllowMove ) - action |= GDK_ACTION_MOVE; - - // VZ: as we already use g_blockEventsOnDrag it shouldn't be that bad - // to use a global to pass the flags to the drop target but I'd - // surely prefer a better way to do it - gs_flagsForDrag = flags; - - GdkDragContext *context = gtk_drag_begin( m_widget, - target_list, - (GdkDragAction)action, - button_number, /* number of mouse button which started drag */ - (GdkEvent*) &event ); - - m_dragContext = context; - - PrepareIcon( action, context ); - - while (m_waiting) - gtk_main_iteration(); - - m_retValue = ConvertFromGTK(context->action); - if ( m_retValue == wxDragNone ) - m_retValue = wxDragCancel; - } - -#if wxUSE_THREADS - /* re-enable GUI threads */ -#endif - - g_blockEventsOnDrag = FALSE; - - UnregisterWindow(); - - return m_retValue; -} - -void wxDropSource::RegisterWindow() -{ - if (!m_widget) return; - - gtk_signal_connect( GTK_OBJECT(m_widget), "drag_data_get", - GTK_SIGNAL_FUNC (source_drag_data_get), (gpointer) this); - gtk_signal_connect (GTK_OBJECT(m_widget), "drag_data_delete", - GTK_SIGNAL_FUNC (source_drag_data_delete), (gpointer) this ); - gtk_signal_connect (GTK_OBJECT(m_widget), "drag_begin", - GTK_SIGNAL_FUNC (source_drag_begin), (gpointer) this ); - gtk_signal_connect (GTK_OBJECT(m_widget), "drag_end", - GTK_SIGNAL_FUNC (source_drag_end), (gpointer) this ); - -} - -void wxDropSource::UnregisterWindow() -{ - if (!m_widget) return; - - gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget), - GTK_SIGNAL_FUNC(source_drag_data_get), (gpointer) this ); - gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget), - GTK_SIGNAL_FUNC(source_drag_data_delete), (gpointer) this ); - gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget), - GTK_SIGNAL_FUNC(source_drag_begin), (gpointer) this ); - gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget), - GTK_SIGNAL_FUNC(source_drag_end), (gpointer) this ); -} - -#endif - // wxUSE_DRAG_AND_DROP diff --git a/src/gtk1/evtloop.cpp b/src/gtk1/evtloop.cpp deleted file mode 100644 index c831a3e605..0000000000 --- a/src/gtk1/evtloop.cpp +++ /dev/null @@ -1,120 +0,0 @@ -/////////////////////////////////////////////////////////////////////////////// -// Name: gtk/evtloop.cpp -// Purpose: implements wxEventLoop for GTK+ -// Author: Vadim Zeitlin -// Modified by: -// Created: 10.07.01 -// RCS-ID: $Id$ -// Copyright: (c) 2001 Vadim Zeitlin -// License: wxWindows license -/////////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#ifndef WX_PRECOMP -#endif //WX_PRECOMP - -#include "wx/evtloop.h" - -#include - -// ---------------------------------------------------------------------------- -// wxEventLoopImpl -// ---------------------------------------------------------------------------- - -class WXDLLEXPORT wxEventLoopImpl -{ -public: - // ctor - wxEventLoopImpl() { SetExitCode(0); } - - // set/get the exit code - void SetExitCode(int exitcode) { m_exitcode = exitcode; } - int GetExitCode() const { return m_exitcode; } - -private: - // the exit code of the event loop - int m_exitcode; -}; - -// ============================================================================ -// wxEventLoop implementation -// ============================================================================ - -// ---------------------------------------------------------------------------- -// wxEventLoop running and exiting -// ---------------------------------------------------------------------------- - -wxEventLoop *wxEventLoop::ms_activeLoop = NULL; - -wxEventLoop::~wxEventLoop() -{ - wxASSERT_MSG( !m_impl, _T("should have been deleted in Run()") ); -} - -bool wxEventLoop::IsRunning() const -{ - return m_impl != NULL; -} - -int wxEventLoop::Run() -{ - // event loops are not recursive, you need to create another loop! - wxCHECK_MSG( !IsRunning(), -1, _T("can't reenter a message loop") ); - - wxEventLoop *oldLoop = ms_activeLoop; - ms_activeLoop = this; - - m_impl = new wxEventLoopImpl; - - gtk_main(); - - int exitcode = m_impl->GetExitCode(); - delete m_impl; - m_impl = NULL; - - ms_activeLoop = oldLoop; - - return exitcode; -} - -void wxEventLoop::Exit(int rc) -{ - wxCHECK_RET( IsRunning(), _T("can't call Exit() if not running") ); - - m_impl->SetExitCode(rc); - - gtk_main_quit(); -} - -// ---------------------------------------------------------------------------- -// wxEventLoop message processing dispatching -// ---------------------------------------------------------------------------- - -bool wxEventLoop::Pending() const -{ - return gtk_events_pending() > 0; -} - -bool wxEventLoop::Dispatch() -{ - wxCHECK_MSG( IsRunning(), FALSE, _T("can't call Dispatch() if not running") ); - - gtk_main_iteration(); - - return TRUE; -} - diff --git a/src/gtk1/fdiag.xbm b/src/gtk1/fdiag.xbm deleted file mode 100644 index 67d3b4732a..0000000000 --- a/src/gtk1/fdiag.xbm +++ /dev/null @@ -1,6 +0,0 @@ -#define fdiag_width 16 -#define fdiag_height 16 -static char fdiag_bits[] = { - 0x01, 0x01, 0x02, 0x02, 0x04, 0x04, 0x08, 0x08, 0x10, 0x10, 0x20, 0x20, - 0x40, 0x40, 0x80, 0x80, 0x01, 0x01, 0x02, 0x02, 0x04, 0x04, 0x08, 0x08, - 0x10, 0x10, 0x20, 0x20, 0x40, 0x40, 0x80, 0x80}; diff --git a/src/gtk1/filedlg.cpp b/src/gtk1/filedlg.cpp deleted file mode 100644 index 43e4cc9f7d..0000000000 --- a/src/gtk1/filedlg.cpp +++ /dev/null @@ -1,271 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: gtk/filedlg.cpp -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/filedlg.h" -#include "wx/utils.h" -#include "wx/intl.h" -#include "wx/generic/msgdlgg.h" - - -#include - -//----------------------------------------------------------------------------- -// idle system -//----------------------------------------------------------------------------- - -extern void wxapp_install_idle_handler(); -extern bool g_isIdle; - -//----------------------------------------------------------------------------- -// "delete_event" -//----------------------------------------------------------------------------- - -static -bool gtk_filedialog_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxDialog *win ) -{ - if (g_isIdle) wxapp_install_idle_handler(); - -/* - printf( "OnDelete from " ); - if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) - printf( win->GetClassInfo()->GetClassName() ); - printf( ".\n" ); -*/ - - win->Close(); - - return TRUE; -} - -//----------------------------------------------------------------------------- -// "clicked" for OK-button -//----------------------------------------------------------------------------- - -static -void gtk_filedialog_ok_callback( GtkWidget *WXUNUSED(widget), wxFileDialog *dialog ) -{ - if (g_isIdle) wxapp_install_idle_handler(); - - int style = dialog->GetStyle(); - - GtkFileSelection *filedlg = GTK_FILE_SELECTION(dialog->m_widget); - char *filename = gtk_file_selection_get_filename(filedlg); - - if ( (style & wxSAVE) && ( style & wxOVERWRITE_PROMPT ) ) - { - if (wxFileExists( filename )) - { - wxString msg; - msg.Printf( _("File '%s' already exists, do you really want to " - "overwrite it?"), filename); - - if (wxMessageBox(msg, _("Confirm"), wxYES_NO) != wxYES) - return; - } - } - else if ( (style & wxOPEN) && ( style & wxFILE_MUST_EXIST) ) - { - if ( !wxFileExists( filename ) ) - { - wxMessageBox(_("Please choose an existing file."), _("Error"), wxOK); - - return; - } - } - - // change to the directory where the user went if asked - if ( style & wxCHANGE_DIR ) - { - wxString cwd; - wxSplitPath(filename, &cwd, NULL, NULL); - - if ( cwd != wxGetCwd() ) - { - wxSetWorkingDirectory(cwd); - } - } - - dialog->SetPath( filename ); - - wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK); - event.SetEventObject( dialog ); - dialog->GetEventHandler()->ProcessEvent( event ); -} - -//----------------------------------------------------------------------------- -// "clicked" for Cancel-button -//----------------------------------------------------------------------------- - -static -void gtk_filedialog_cancel_callback( GtkWidget *WXUNUSED(w), wxFileDialog *dialog ) -{ - if (g_isIdle) wxapp_install_idle_handler(); - - wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); - event.SetEventObject( dialog ); - dialog->GetEventHandler()->ProcessEvent( event ); -} - -//----------------------------------------------------------------------------- -// wxFileDialog -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxFileDialog,wxDialog) - -wxFileDialog::wxFileDialog( wxWindow *parent, const wxString& message, - const wxString& defaultDir, const wxString& defaultFileName, - const wxString& wildCard, - long style, const wxPoint& pos ) -{ - m_needParent = FALSE; - - if (!PreCreation( parent, pos, wxDefaultSize ) || - !CreateBase( parent, -1, pos, wxDefaultSize, style | wxDIALOG_MODAL, wxDefaultValidator, wxT("filedialog") )) - { - wxFAIL_MSG( wxT("wxXX creation failed") ); - return; - } - - m_message = message; - m_path = wxT(""); - m_fileName = defaultFileName; - m_dir = defaultDir; - m_wildCard = wildCard; - m_dialogStyle = style; - m_filterIndex = 1; - - m_widget = gtk_file_selection_new( m_message.mbc_str() ); - - int x = (gdk_screen_width () - 400) / 2; - int y = (gdk_screen_height () - 400) / 2; - gtk_widget_set_uposition( m_widget, x, y ); - - GtkFileSelection *sel = GTK_FILE_SELECTION(m_widget); - gtk_file_selection_hide_fileop_buttons( sel ); // they don't work anyway - - m_path.Append(m_dir); - if( ! m_path.IsEmpty() && m_path.Last()!=wxT('/') ) - m_path.Append('/'); - m_path.Append(m_fileName); - - if(m_path.Length()>1) gtk_file_selection_set_filename(sel,m_path.mbc_str()); - - gtk_signal_connect( GTK_OBJECT(sel->ok_button), "clicked", - GTK_SIGNAL_FUNC(gtk_filedialog_ok_callback), (gpointer*)this ); - - // strange way to internationalize - gtk_label_set( GTK_LABEL( GTK_BUTTON(sel->ok_button)->child ), wxConvCurrent->cWX2MB(_("OK")) ); - - gtk_signal_connect( GTK_OBJECT(sel->cancel_button), "clicked", - GTK_SIGNAL_FUNC(gtk_filedialog_cancel_callback), (gpointer*)this ); - - // strange way to internationalize - gtk_label_set( GTK_LABEL( GTK_BUTTON(sel->cancel_button)->child ), wxConvCurrent->cWX2MB(_("Cancel")) ); - - gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event", - GTK_SIGNAL_FUNC(gtk_filedialog_delete_callback), (gpointer)this ); -} - -void wxFileDialog::SetPath(const wxString& path) -{ - // not only set the full path but also update filename and dir - m_path = path; - if ( !!path ) - { - wxString ext; - wxSplitPath(path, &m_dir, &m_fileName, &ext); - if (!ext.IsEmpty()) - { - m_fileName += wxT("."); - m_fileName += ext; - } - } -} - -// ---------------------------------------------------------------------------- -// global functions -// ---------------------------------------------------------------------------- - -wxString -wxFileSelectorEx(const wxChar *message, - const wxChar *default_path, - const wxChar *default_filename, - int *indexDefaultExtension, - const wxChar *wildcard, - int flags, - wxWindow *parent, - int x, int y) -{ - // TODO: implement this somehow - return wxFileSelector(message, default_path, default_filename, wxT(""), - wildcard, flags, parent, x, y); -} - -wxString wxFileSelector( const wxChar *title, - const wxChar *defaultDir, const wxChar *defaultFileName, - const wxChar *defaultExtension, const wxChar *filter, int flags, - wxWindow *parent, int x, int y ) -{ - wxString filter2; - if ( defaultExtension && !filter ) - filter2 = wxString(wxT("*.")) + wxString(defaultExtension) ; - else if ( filter ) - filter2 = filter; - - wxString defaultDirString; - if (defaultDir) - defaultDirString = defaultDir; - - wxString defaultFilenameString; - if (defaultFileName) - defaultFilenameString = defaultFileName; - - wxFileDialog fileDialog( parent, title, defaultDirString, defaultFilenameString, filter2, flags, wxPoint(x, y) ); - - if ( fileDialog.ShowModal() == wxID_OK ) - { - return fileDialog.GetPath(); - } - else - { - return wxEmptyString; - } -} - -wxString wxLoadFileSelector( const wxChar *what, const wxChar *extension, const wxChar *default_name, wxWindow *parent ) -{ - wxChar *ext = (wxChar *)extension; - - wxString prompt = wxString::Format(_("Load %s file"), what); - - if (*ext == wxT('.')) - ext++; - - wxString wild = wxString::Format(_T("*.%s"), ext); - - return wxFileSelector(prompt, (const wxChar *) NULL, default_name, - ext, wild, 0, parent); -} - -wxString wxSaveFileSelector(const wxChar *what, const wxChar *extension, const wxChar *default_name, - wxWindow *parent ) -{ - wxChar *ext = (wxChar *)extension; - - wxString prompt = wxString::Format(_("Save %s file"), what); - - if (*ext == wxT('.')) - ext++; - - wxString wild = wxString::Format(_T("*.%s"), ext); - - return wxFileSelector(prompt, (const wxChar *) NULL, default_name, - ext, wild, 0, parent); -} - diff --git a/src/gtk1/files.lst b/src/gtk1/files.lst deleted file mode 100644 index e21b9a06cd..0000000000 --- a/src/gtk1/files.lst +++ /dev/null @@ -1,993 +0,0 @@ -# This file was automatically generated by tmake -# DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST! CHANGE GTK.T! -ALL_SOURCES = \ - generic/accel.cpp \ - generic/busyinfo.cpp \ - generic/calctrl.cpp \ - generic/caret.cpp \ - generic/choicdgg.cpp \ - generic/colrdlgg.cpp \ - generic/dcbuffer.cpp \ - generic/dcpsg.cpp \ - generic/dirctrlg.cpp \ - generic/dirdlgg.cpp \ - generic/dragimgg.cpp \ - generic/fdrepdlg.cpp \ - generic/filedlgg.cpp \ - generic/fontdlgg.cpp \ - generic/grid.cpp \ - generic/gridctrl.cpp \ - generic/gridsel.cpp \ - generic/helpext.cpp \ - generic/helphtml.cpp \ - generic/imaglist.cpp \ - generic/laywin.cpp \ - generic/listctrl.cpp \ - generic/logg.cpp \ - generic/msgdlgg.cpp \ - generic/numdlgg.cpp \ - generic/paletteg.cpp \ - generic/panelg.cpp \ - generic/printps.cpp \ - generic/prntdlgg.cpp \ - generic/progdlgg.cpp \ - generic/prop.cpp \ - generic/propform.cpp \ - generic/proplist.cpp \ - generic/sashwin.cpp \ - generic/scrlwing.cpp \ - generic/spinctlg.cpp \ - generic/splash.cpp \ - generic/splitter.cpp \ - generic/statusbr.cpp \ - generic/tabg.cpp \ - generic/tbarsmpl.cpp \ - generic/textdlgg.cpp \ - generic/tipdlg.cpp \ - generic/tipwin.cpp \ - generic/treectlg.cpp \ - generic/treelay.cpp \ - generic/wizard.cpp \ - common/appcmn.cpp \ - common/artprov.cpp \ - common/artstd.cpp \ - common/choiccmn.cpp \ - common/clipcmn.cpp \ - common/clntdata.cpp \ - common/cmdline.cpp \ - common/cmdproc.cpp \ - common/cmndata.cpp \ - common/config.cpp \ - common/containr.cpp \ - common/cshelp.cpp \ - common/ctrlcmn.cpp \ - common/ctrlsub.cpp \ - common/datetime.cpp \ - common/datstrm.cpp \ - common/db.cpp \ - common/dbgrid.cpp \ - common/dbtable.cpp \ - common/dcbase.cpp \ - common/dircmn.cpp \ - common/dlgcmn.cpp \ - common/dndcmn.cpp \ - common/dobjcmn.cpp \ - common/docmdi.cpp \ - common/docview.cpp \ - common/dseldlg.cpp \ - common/dynarray.cpp \ - common/dynlib.cpp \ - common/dynload.cpp \ - common/effects.cpp \ - common/encconv.cpp \ - common/event.cpp \ - common/extended.c \ - common/fddlgcmn.cpp \ - common/ffile.cpp \ - common/file.cpp \ - common/fileconf.cpp \ - common/filefn.cpp \ - common/filename.cpp \ - common/filesys.cpp \ - common/fontcmn.cpp \ - common/fontmap.cpp \ - common/framecmn.cpp \ - common/fs_inet.cpp \ - common/fs_mem.cpp \ - common/fs_zip.cpp \ - common/ftp.cpp \ - common/gaugecmn.cpp \ - common/gdicmn.cpp \ - common/geometry.cpp \ - common/gifdecod.cpp \ - common/hash.cpp \ - common/hashmap.cpp \ - common/helpbase.cpp \ - common/http.cpp \ - common/iconbndl.cpp \ - common/imagall.cpp \ - common/imagbmp.cpp \ - common/image.cpp \ - common/imagfill.cpp \ - common/imaggif.cpp \ - common/imagiff.cpp \ - common/imagjpeg.cpp \ - common/imagpcx.cpp \ - common/imagpng.cpp \ - common/imagpnm.cpp \ - common/imagtiff.cpp \ - common/imagxpm.cpp \ - common/intl.cpp \ - common/ipcbase.cpp \ - common/layout.cpp \ - common/lboxcmn.cpp \ - common/list.cpp \ - common/log.cpp \ - common/longlong.cpp \ - common/matrix.cpp \ - common/memory.cpp \ - common/menucmn.cpp \ - common/mimecmn.cpp \ - common/module.cpp \ - common/msgout.cpp \ - common/mstream.cpp \ - common/nbkbase.cpp \ - common/object.cpp \ - common/paper.cpp \ - common/popupcmn.cpp \ - common/prntbase.cpp \ - common/process.cpp \ - common/protocol.cpp \ - common/quantize.cpp \ - common/radiocmn.cpp \ - common/regex.cpp \ - common/resource.cpp \ - common/rgncmn.cpp \ - common/sckaddr.cpp \ - common/sckfile.cpp \ - common/sckipc.cpp \ - common/sckstrm.cpp \ - common/settcmn.cpp \ - common/sizer.cpp \ - common/socket.cpp \ - common/statbar.cpp \ - common/strconv.cpp \ - common/stream.cpp \ - common/string.cpp \ - common/sysopt.cpp \ - common/tbarbase.cpp \ - common/textbuf.cpp \ - common/textcmn.cpp \ - common/textfile.cpp \ - common/timercmn.cpp \ - common/tokenzr.cpp \ - common/toplvcmn.cpp \ - common/treebase.cpp \ - common/txtstrm.cpp \ - common/unzip.c \ - common/url.cpp \ - common/utilscmn.cpp \ - common/valgen.cpp \ - common/validate.cpp \ - common/valtext.cpp \ - common/variant.cpp \ - common/wfstream.cpp \ - common/wincmn.cpp \ - common/wxchar.cpp \ - common/wxexpr.cpp \ - common/xpmdecod.cpp \ - common/zipstrm.cpp \ - common/zstream.cpp \ - gtk/app.cpp \ - gtk/bitmap.cpp \ - gtk/bmpbuttn.cpp \ - gtk/brush.cpp \ - gtk/button.cpp \ - gtk/checkbox.cpp \ - gtk/checklst.cpp \ - gtk/choice.cpp \ - gtk/clipbrd.cpp \ - gtk/colour.cpp \ - gtk/combobox.cpp \ - gtk/control.cpp \ - gtk/cursor.cpp \ - gtk/data.cpp \ - gtk/dataobj.cpp \ - gtk/dc.cpp \ - gtk/dcclient.cpp \ - gtk/dcmemory.cpp \ - gtk/dcscreen.cpp \ - gtk/dialog.cpp \ - gtk/dnd.cpp \ - gtk/evtloop.cpp \ - gtk/font.cpp \ - gtk/fontdlg.cpp \ - gtk/frame.cpp \ - gtk/gauge.cpp \ - gtk/gdiobj.cpp \ - gtk/gsockgtk.c \ - gtk/icon.cpp \ - gtk/joystick.cpp \ - gtk/listbox.cpp \ - gtk/main.cpp \ - gtk/mdi.cpp \ - gtk/menu.cpp \ - gtk/minifram.cpp \ - gtk/notebook.cpp \ - gtk/pen.cpp \ - gtk/popupwin.cpp \ - gtk/radiobox.cpp \ - gtk/radiobut.cpp \ - gtk/region.cpp \ - gtk/scrolbar.cpp \ - gtk/scrolwin.cpp \ - gtk/settings.cpp \ - gtk/slider.cpp \ - gtk/spinbutt.cpp \ - gtk/spinctrl.cpp \ - gtk/statbmp.cpp \ - gtk/statbox.cpp \ - gtk/statline.cpp \ - gtk/stattext.cpp \ - gtk/tbargtk.cpp \ - gtk/textctrl.cpp \ - gtk/tglbtn.cpp \ - gtk/timer.cpp \ - gtk/tooltip.cpp \ - gtk/toplevel.cpp \ - gtk/utilsgtk.cpp \ - gtk/utilsres.cpp \ - gtk/wave.cpp \ - gtk/win_gtk.c \ - gtk/window.cpp \ - unix/dialup.cpp \ - unix/dir.cpp \ - unix/fontenum.cpp \ - unix/fontutil.cpp \ - unix/gsocket.c \ - unix/mimetype.cpp \ - unix/snglinst.cpp \ - unix/threadpsx.cpp \ - unix/utilsunx.cpp \ - unix/utilsx11.cpp \ - html/helpctrl.cpp \ - html/helpdata.cpp \ - html/helpfrm.cpp \ - html/htmlcell.cpp \ - html/htmlfilt.cpp \ - html/htmlpars.cpp \ - html/htmltag.cpp \ - html/htmlwin.cpp \ - html/htmprint.cpp \ - html/m_dflist.cpp \ - html/m_fonts.cpp \ - html/m_hline.cpp \ - html/m_image.cpp \ - html/m_layout.cpp \ - html/m_links.cpp \ - html/m_list.cpp \ - html/m_pre.cpp \ - html/m_style.cpp \ - html/m_tables.cpp \ - html/winpars.cpp - -ALL_HEADERS = \ - accel.h \ - app.h \ - arrimpl.cpp \ - artprov.h \ - bitmap.h \ - bmpbuttn.h \ - brush.h \ - buffer.h \ - build.h \ - busyinfo.h \ - button.h \ - calctrl.h \ - caret.h \ - checkbox.h \ - checklst.h \ - chkconf.h \ - choicdlg.h \ - choice.h \ - clipbrd.h \ - clntdata.h \ - cmdline.h \ - cmdproc.h \ - cmndata.h \ - colordlg.h \ - colour.h \ - combobox.h \ - confbase.h \ - config.h \ - containr.h \ - control.h \ - cshelp.h \ - ctrlsub.h \ - cursor.h \ - dataobj.h \ - date.h \ - datetime.h \ - datetime.inl \ - datstrm.h \ - db.h \ - dbgrid.h \ - dbkeyg.h \ - dbtable.h \ - dc.h \ - dcbuffer.h \ - dcclient.h \ - dcmemory.h \ - dcprint.h \ - dcps.h \ - dcscreen.h \ - dde.h \ - debug.h \ - defs.h \ - dialog.h \ - dialup.h \ - dir.h \ - dirctrl.h \ - dirdlg.h \ - dnd.h \ - docmdi.h \ - docview.h \ - dragimag.h \ - dynarray.h \ - dynlib.h \ - dynload.h \ - effects.h \ - encconv.h \ - event.h \ - expr.h \ - fdrepdlg.h \ - features.h \ - ffile.h \ - file.h \ - fileconf.h \ - filedlg.h \ - filefn.h \ - filename.h \ - filesys.h \ - font.h \ - fontdlg.h \ - fontenc.h \ - fontenum.h \ - fontmap.h \ - fontutil.h \ - frame.h \ - fs_inet.h \ - fs_mem.h \ - fs_zip.h \ - gauge.h \ - gdicmn.h \ - gdiobj.h \ - geometry.h \ - gifdecod.h \ - glcanvas.h \ - grid.h \ - gsocket.h \ - hash.h \ - hashmap.h \ - help.h \ - helpbase.h \ - helphtml.h \ - helpwin.h \ - icon.h \ - iconbndl.h \ - imagbmp.h \ - image.h \ - imaggif.h \ - imagiff.h \ - imagjpeg.h \ - imaglist.h \ - imagpcx.h \ - imagpng.h \ - imagpnm.h \ - imagtiff.h \ - imagxpm.h \ - intl.h \ - ioswrap.h \ - ipc.h \ - ipcbase.h \ - isql.h \ - isqlext.h \ - joystick.h \ - layout.h \ - laywin.h \ - list.h \ - listbase.h \ - listbox.h \ - listctrl.h \ - listimpl.cpp \ - log.h \ - longlong.h \ - matrix.h \ - mdi.h \ - memconf.h \ - memory.h \ - memtext.h \ - menu.h \ - menuitem.h \ - metafile.h \ - mimetype.h \ - minifram.h \ - module.h \ - msgdlg.h \ - msgout.h \ - mstream.h \ - notebook.h \ - object.h \ - odbc.h \ - ownerdrw.h \ - palette.h \ - panel.h \ - paper.h \ - pen.h \ - platform.h \ - popupwin.h \ - print.h \ - printdlg.h \ - prntbase.h \ - process.h \ - progdlg.h \ - prop.h \ - propform.h \ - proplist.h \ - quantize.h \ - radiobox.h \ - radiobut.h \ - regex.h \ - region.h \ - resource.h \ - sashwin.h \ - sckaddr.h \ - sckipc.h \ - sckstrm.h \ - scrolbar.h \ - scrolwin.h \ - settings.h \ - sizer.h \ - slider.h \ - snglinst.h \ - socket.h \ - spinbutt.h \ - spinctrl.h \ - splash.h \ - splitter.h \ - stack.h \ - statbmp.h \ - statbox.h \ - statline.h \ - stattext.h \ - statusbr.h \ - strconv.h \ - stream.h \ - string.h \ - sysopt.h \ - tab.h \ - tabctrl.h \ - taskbar.h \ - tbarbase.h \ - tbarsmpl.h \ - textbuf.h \ - textctrl.h \ - textdlg.h \ - textfile.h \ - tglbtn.h \ - thread.h \ - thrimpl.cpp \ - time.h \ - timer.h \ - tipdlg.h \ - tipwin.h \ - tokenzr.h \ - toolbar.h \ - tooltip.h \ - toplevel.h \ - treebase.h \ - treectrl.h \ - txtstrm.h \ - types.h \ - url.h \ - utils.h \ - valgen.h \ - validate.h \ - valtext.h \ - variant.h \ - vector.h \ - version.h \ - volume.h \ - wave.h \ - wfstream.h \ - window.h \ - wizard.h \ - wx.h \ - wx_cw.h \ - wx_cw_cm.h \ - wx_cw_d.h \ - wxchar.h \ - wxexpr.h \ - wxhtml.h \ - wxprec.h \ - xpmdecod.h \ - zipstrm.h \ - zstream.h \ - gtk/accel.h \ - gtk/app.h \ - gtk/bitmap.h \ - gtk/bmpbuttn.h \ - gtk/brush.h \ - gtk/button.h \ - gtk/checkbox.h \ - gtk/checklst.h \ - gtk/choice.h \ - gtk/clipbrd.h \ - gtk/colour.h \ - gtk/combobox.h \ - gtk/control.h \ - gtk/cursor.h \ - gtk/dataform.h \ - gtk/dataobj.h \ - gtk/dataobj2.h \ - gtk/dc.h \ - gtk/dcclient.h \ - gtk/dcmemory.h \ - gtk/dcscreen.h \ - gtk/dialog.h \ - gtk/dnd.h \ - gtk/filedlg.h \ - gtk/font.h \ - gtk/fontdlg.h \ - gtk/frame.h \ - gtk/gauge.h \ - gtk/gdiobj.h \ - gtk/glcanvas.h \ - gtk/icon.h \ - gtk/joystick.h \ - gtk/listbox.h \ - gtk/mdi.h \ - gtk/menu.h \ - gtk/menuitem.h \ - gtk/minifram.h \ - gtk/notebook.h \ - gtk/pen.h \ - gtk/popupwin.h \ - gtk/radiobox.h \ - gtk/radiobut.h \ - gtk/region.h \ - gtk/scrolbar.h \ - gtk/scrolwin.h \ - gtk/slider.h \ - gtk/spinbutt.h \ - gtk/spinctrl.h \ - gtk/statbmp.h \ - gtk/statbox.h \ - gtk/statline.h \ - gtk/stattext.h \ - gtk/tbargtk.h \ - gtk/textctrl.h \ - gtk/tglbtn.h \ - gtk/timer.h \ - gtk/tooltip.h \ - gtk/toplevel.h \ - gtk/treectrl.h \ - gtk/wave.h \ - gtk/win_gtk.h \ - gtk/window.h \ - generic/accel.h \ - generic/calctrl.h \ - generic/caret.h \ - generic/choicdgg.h \ - generic/colrdlgg.h \ - generic/dcpsg.h \ - generic/dirctrlg.h \ - generic/dirdlgg.h \ - generic/dragimgg.h \ - generic/fdrepdlg.h \ - generic/filedlgg.h \ - generic/fontdlgg.h \ - generic/grid.h \ - generic/gridctrl.h \ - generic/gridg.h \ - generic/helpext.h \ - generic/helphtml.h \ - generic/imaglist.h \ - generic/laywin.h \ - generic/listctrl.h \ - generic/msgdlgg.h \ - generic/notebook.h \ - generic/paletteg.h \ - generic/panelg.h \ - generic/printps.h \ - generic/prntdlgg.h \ - generic/progdlgg.h \ - generic/sashwin.h \ - generic/scrolwin.h \ - generic/spinctlg.h \ - generic/splash.h \ - generic/splitter.h \ - generic/statusbr.h \ - generic/tabg.h \ - generic/textdlgg.h \ - generic/timer.h \ - generic/treectlg.h \ - generic/wizard.h \ - unix/execute.h \ - unix/fontutil.h \ - unix/gsockunx.h \ - unix/mimetype.h \ - unix/utilsx11.h \ - html/forcelnk.h \ - html/helpctrl.h \ - html/helpdata.h \ - html/helpfrm.h \ - html/htmlcell.h \ - html/htmldefs.h \ - html/htmlfilt.h \ - html/htmlpars.h \ - html/htmlproc.h \ - html/htmltag.h \ - html/htmlwin.h \ - html/htmprint.h \ - html/m_templ.h \ - html/winpars.h \ - protocol/file.h \ - protocol/ftp.h \ - protocol/http.h \ - protocol/protocol.h - -COMMONOBJS = \ - appcmn.o \ - artprov.o \ - artstd.o \ - choiccmn.o \ - clipcmn.o \ - clntdata.o \ - cmdline.o \ - cmdproc.o \ - cmndata.o \ - config.o \ - containr.o \ - cshelp.o \ - ctrlcmn.o \ - ctrlsub.o \ - datetime.o \ - datstrm.o \ - db.o \ - dbgrid.o \ - dbtable.o \ - dcbase.o \ - dircmn.o \ - dlgcmn.o \ - dndcmn.o \ - dobjcmn.o \ - docmdi.o \ - docview.o \ - dseldlg.o \ - dynarray.o \ - dynlib.o \ - dynload.o \ - effects.o \ - encconv.o \ - event.o \ - extended.o \ - fddlgcmn.o \ - ffile.o \ - file.o \ - fileconf.o \ - filefn.o \ - filename.o \ - filesys.o \ - fontcmn.o \ - fontmap.o \ - framecmn.o \ - fs_inet.o \ - fs_mem.o \ - fs_zip.o \ - ftp.o \ - gaugecmn.o \ - gdicmn.o \ - geometry.o \ - gifdecod.o \ - hash.o \ - hashmap.o \ - helpbase.o \ - http.o \ - iconbndl.o \ - imagall.o \ - imagbmp.o \ - image.o \ - imagfill.o \ - imaggif.o \ - imagiff.o \ - imagjpeg.o \ - imagpcx.o \ - imagpng.o \ - imagpnm.o \ - imagtiff.o \ - imagxpm.o \ - intl.o \ - ipcbase.o \ - layout.o \ - lboxcmn.o \ - list.o \ - log.o \ - longlong.o \ - matrix.o \ - memory.o \ - menucmn.o \ - mimecmn.o \ - module.o \ - msgout.o \ - mstream.o \ - nbkbase.o \ - object.o \ - paper.o \ - popupcmn.o \ - prntbase.o \ - process.o \ - protocol.o \ - quantize.o \ - radiocmn.o \ - regex.o \ - resource.o \ - rgncmn.o \ - sckaddr.o \ - sckfile.o \ - sckipc.o \ - sckstrm.o \ - settcmn.o \ - sizer.o \ - socket.o \ - statbar.o \ - strconv.o \ - stream.o \ - string.o \ - sysopt.o \ - tbarbase.o \ - textbuf.o \ - textcmn.o \ - textfile.o \ - timercmn.o \ - tokenzr.o \ - toplvcmn.o \ - treebase.o \ - txtstrm.o \ - unzip.o \ - url.o \ - utilscmn.o \ - valgen.o \ - validate.o \ - valtext.o \ - variant.o \ - wfstream.o \ - wincmn.o \ - wxchar.o \ - wxexpr.o \ - xpmdecod.o \ - zipstrm.o \ - zstream.o - -GUIOBJS = \ - accel.o \ - busyinfo.o \ - calctrl.o \ - caret.o \ - choicdgg.o \ - colrdlgg.o \ - dcbuffer.o \ - dcpsg.o \ - dirctrlg.o \ - dirdlgg.o \ - dragimgg.o \ - fdrepdlg.o \ - filedlgg.o \ - fontdlgg.o \ - grid.o \ - gridctrl.o \ - gridsel.o \ - helpext.o \ - helphtml.o \ - imaglist.o \ - laywin.o \ - listctrl.o \ - logg.o \ - msgdlgg.o \ - numdlgg.o \ - paletteg.o \ - panelg.o \ - printps.o \ - prntdlgg.o \ - progdlgg.o \ - prop.o \ - propform.o \ - proplist.o \ - sashwin.o \ - scrlwing.o \ - spinctlg.o \ - splash.o \ - splitter.o \ - statusbr.o \ - tabg.o \ - tbarsmpl.o \ - textdlgg.o \ - tipdlg.o \ - tipwin.o \ - treectlg.o \ - treelay.o \ - wizard.o \ - app.o \ - bitmap.o \ - bmpbuttn.o \ - brush.o \ - button.o \ - checkbox.o \ - checklst.o \ - choice.o \ - clipbrd.o \ - colour.o \ - combobox.o \ - control.o \ - cursor.o \ - data.o \ - dataobj.o \ - dc.o \ - dcclient.o \ - dcmemory.o \ - dcscreen.o \ - dialog.o \ - dnd.o \ - evtloop.o \ - font.o \ - fontdlg.o \ - frame.o \ - gauge.o \ - gdiobj.o \ - gsockgtk.o \ - icon.o \ - joystick.o \ - listbox.o \ - main.o \ - mdi.o \ - menu.o \ - minifram.o \ - notebook.o \ - pen.o \ - popupwin.o \ - radiobox.o \ - radiobut.o \ - region.o \ - scrolbar.o \ - scrolwin.o \ - settings.o \ - slider.o \ - spinbutt.o \ - spinctrl.o \ - statbmp.o \ - statbox.o \ - statline.o \ - stattext.o \ - tbargtk.o \ - textctrl.o \ - tglbtn.o \ - timer.o \ - tooltip.o \ - toplevel.o \ - utilsgtk.o \ - utilsres.o \ - wave.o \ - win_gtk.o \ - window.o - -GUI_LOWLEVEL_OBJS = \ - accel.o \ - busyinfo.o \ - calctrl.o \ - caret.o \ - choicdgg.o \ - colrdlgg.o \ - dcbuffer.o \ - dcpsg.o \ - dirctrlg.o \ - dirdlgg.o \ - dragimgg.o \ - fdrepdlg.o \ - filedlgg.o \ - fontdlgg.o \ - grid.o \ - gridctrl.o \ - gridsel.o \ - helpext.o \ - helphtml.o \ - imaglist.o \ - laywin.o \ - listctrl.o \ - logg.o \ - msgdlgg.o \ - numdlgg.o \ - paletteg.o \ - panelg.o \ - printps.o \ - prntdlgg.o \ - progdlgg.o \ - prop.o \ - propform.o \ - proplist.o \ - sashwin.o \ - scrlwing.o \ - spinctlg.o \ - splash.o \ - splitter.o \ - tabg.o \ - tbarsmpl.o \ - textdlgg.o \ - tipdlg.o \ - tipwin.o \ - treectlg.o \ - treelay.o \ - wizard.o \ - app.o \ - bitmap.o \ - brush.o \ - clipbrd.o \ - colour.o \ - cursor.o \ - data.o \ - dataobj.o \ - dc.o \ - dcclient.o \ - dcmemory.o \ - dcscreen.o \ - dnd.o \ - evtloop.o \ - font.o \ - gdiobj.o \ - gsockgtk.o \ - icon.o \ - main.o \ - pen.o \ - popupwin.o \ - region.o \ - settings.o \ - timer.o \ - tooltip.o \ - toplevel.o \ - utilsgtk.o \ - win_gtk.o \ - window.o - -UNIXOBJS = \ - dialup.o \ - dir.o \ - fontenum.o \ - fontutil.o \ - gsocket.o \ - mimetype.o \ - snglinst.o \ - threadpsx.o \ - utilsunx.o \ - utilsx11.o - -HTMLOBJS = \ - helpctrl.o \ - helpdata.o \ - helpfrm.o \ - htmlcell.o \ - htmlfilt.o \ - htmlpars.o \ - htmltag.o \ - htmlwin.o \ - htmprint.o \ - m_dflist.o \ - m_fonts.o \ - m_hline.o \ - m_image.o \ - m_layout.o \ - m_links.o \ - m_list.o \ - m_pre.o \ - m_style.o \ - m_tables.o \ - winpars.o - diff --git a/src/gtk1/font.cpp b/src/gtk1/font.cpp deleted file mode 100644 index 0a5e274d66..0000000000 --- a/src/gtk1/font.cpp +++ /dev/null @@ -1,986 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: gtk/font.cpp -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -#include "wx/font.h" -#include "wx/fontutil.h" -#include "wx/cmndata.h" -#include "wx/utils.h" -#include "wx/log.h" -#include "wx/gdicmn.h" -#include "wx/tokenzr.h" -#include "wx/settings.h" - -#include - -#include "wx/gtk/private.h" -#include - -// ---------------------------------------------------------------------------- -// constants -// ---------------------------------------------------------------------------- - -// the default size (in points) for the fonts -static const int wxDEFAULT_FONT_SIZE = 12; - -// ---------------------------------------------------------------------------- -// wxScaledFontList: maps the font sizes to the GDK fonts for the given font -// ---------------------------------------------------------------------------- - -WX_DECLARE_HASH_MAP(int, GdkFont *, wxIntegerHash, wxIntegerEqual, - wxScaledFontList); - -// ---------------------------------------------------------------------------- -// wxFontRefData -// ---------------------------------------------------------------------------- - -class wxFontRefData : public wxObjectRefData -{ -public: - // from broken down font parameters, also default ctor - wxFontRefData(int size = -1, - int family = wxFONTFAMILY_DEFAULT, - int style = wxFONTSTYLE_NORMAL, - int weight = wxFONTWEIGHT_NORMAL, - bool underlined = FALSE, - const wxString& faceName = wxEmptyString, - wxFontEncoding encoding = wxFONTENCODING_DEFAULT); - - // from XFLD - wxFontRefData(const wxString& fontname); - - // copy ctor - wxFontRefData( const wxFontRefData& data ); - - virtual ~wxFontRefData(); - - // do we have the native font info? - bool HasNativeFont() const - { -#ifdef __WXGTK20__ - // we always have a Pango font description - return TRUE; -#else // GTK 1.x - // only use m_nativeFontInfo if it had been initialized - return !m_nativeFontInfo.IsDefault(); -#endif // GTK 2.0/1.x - } - - // setters: all of them also take care to modify m_nativeFontInfo if we - // have it so as to not lose the information not carried by our fields - void SetPointSize(int pointSize); - void SetFamily(int family); - void SetStyle(int style); - void SetWeight(int weight); - void SetUnderlined(bool underlined); - void SetFaceName(const wxString& facename); - void SetEncoding(wxFontEncoding encoding); - - void SetNoAntiAliasing( bool no = TRUE ) { m_noAA = no; } - bool GetNoAntiAliasing() { return m_noAA; } - - // and this one also modifies all the other font data fields - void SetNativeFontInfo(const wxNativeFontInfo& info); - - // debugger helper: shows what the font really is - // - // VZ: I need this as my gdb either shows wildly wrong values or crashes - // when I ask it to "p fontRefData" :-( -#if defined(__WXDEBUG__) && !defined(__WXGTK20__) - void Dump() const - { - wxPrintf(_T("%s-%s-%s-%d-%d\n"), - m_faceName.c_str(), - m_weight == wxFONTWEIGHT_NORMAL - ? _T("normal") - : m_weight == wxFONTWEIGHT_BOLD - ? _T("bold") - : _T("light"), - m_style == wxFONTSTYLE_NORMAL ? _T("regular") : _T("italic"), - m_pointSize, - m_encoding); - } -#endif // Debug - -protected: - // common part of all ctors - void Init(int pointSize, - int family, - int style, - int weight, - bool underlined, - const wxString& faceName, - wxFontEncoding encoding); - - // set all fields from (already initialized and valid) m_nativeFontInfo - void InitFromNative(); - -private: - // clear m_scaled_xfonts if any - void ClearGdkFonts(); - -#ifndef __WXGTK20__ - // the map of font sizes to "GdkFont *" - wxScaledFontList m_scaled_xfonts; -#endif // GTK 2.0/1.x - - int m_pointSize; - int m_family, - m_style, - m_weight; - bool m_underlined; - wxString m_faceName; - wxFontEncoding m_encoding; // Unused under GTK 2.0 - bool m_noAA; // No anti-aliasing - - // The native font info, basicly an XFLD under GTK 1.2 and - // the pango font description under GTK 2.0. - wxNativeFontInfo m_nativeFontInfo; - - friend class wxFont; -}; - -// ---------------------------------------------------------------------------- -// wxFontRefData -// ---------------------------------------------------------------------------- - -void wxFontRefData::Init(int pointSize, - int family, - int style, - int weight, - bool underlined, - const wxString& faceName, - wxFontEncoding encoding) -{ - m_family = family == wxFONTFAMILY_DEFAULT ? wxFONTFAMILY_SWISS : family; - - m_faceName = faceName; - - // we accept both wxDEFAULT and wxNORMAL here - should we? - m_style = style == wxDEFAULT ? wxFONTSTYLE_NORMAL : style; - m_weight = weight == wxDEFAULT ? wxFONTWEIGHT_NORMAL : weight; - - // and here, do we really want to forbid creation of the font of the size - // 90 (the value of wxDEFAULT)?? - m_pointSize = pointSize == wxDEFAULT || pointSize == -1 - ? wxDEFAULT_FONT_SIZE - : pointSize; - - m_underlined = underlined; - m_encoding = encoding; - - m_noAA = FALSE; - -#ifdef __WXGTK20__ - // Create native font info - m_nativeFontInfo.description = pango_font_description_new(); - - // And set its values - if (!m_faceName.empty()) - { - pango_font_description_set_family( m_nativeFontInfo.description, wxGTK_CONV(m_faceName) ); - } - else - { - switch (m_family) - { - case wxFONTFAMILY_MODERN: - case wxFONTFAMILY_TELETYPE: - pango_font_description_set_family( m_nativeFontInfo.description, "monospace" ); - break; - case wxFONTFAMILY_ROMAN: - pango_font_description_set_family( m_nativeFontInfo.description, "serif" ); - break; - case wxFONTFAMILY_SWISS: - // SWISS = sans serif - default: - pango_font_description_set_family( m_nativeFontInfo.description, "sans" ); - break; - } - } - - SetStyle( m_style ); - SetPointSize( m_pointSize ); - SetWeight( m_weight ); -#endif // GTK 2.0 -} - -void wxFontRefData::InitFromNative() -{ - m_noAA = FALSE; - -#ifdef __WXGTK20__ - // Get native info - PangoFontDescription *desc = m_nativeFontInfo.description; - - // init fields - m_faceName = wxGTK_CONV_BACK( pango_font_description_get_family( desc ) ); - - // Pango sometimes needs to have a size - int pango_size = pango_font_description_get_size( desc ); - if (pango_size == 0) - pango_font_description_set_size( desc, 12 * PANGO_SCALE); - - m_pointSize = pango_font_description_get_size( desc ) / PANGO_SCALE; - - // wxPrintf( wxT("face %s m_pointSize %d\n"), m_faceName.c_str(), m_pointSize ); - - switch (pango_font_description_get_style( desc )) - { - case PANGO_STYLE_NORMAL: - m_style = wxFONTSTYLE_NORMAL; - break; - case PANGO_STYLE_ITALIC: - m_style = wxFONTSTYLE_ITALIC; - break; - case PANGO_STYLE_OBLIQUE: - m_style = wxFONTSTYLE_SLANT; - break; - } - - switch (pango_font_description_get_weight( desc )) - { - case PANGO_WEIGHT_ULTRALIGHT: - m_weight = wxFONTWEIGHT_LIGHT; - break; - case PANGO_WEIGHT_LIGHT: - m_weight = wxFONTWEIGHT_LIGHT; - break; - case PANGO_WEIGHT_NORMAL: - m_weight = wxFONTWEIGHT_NORMAL; - break; - case PANGO_WEIGHT_BOLD: - m_weight = wxFONTWEIGHT_BOLD; - break; - case PANGO_WEIGHT_ULTRABOLD: - m_weight = wxFONTWEIGHT_BOLD; - break; - case PANGO_WEIGHT_HEAVY: - m_weight = wxFONTWEIGHT_BOLD; - break; - } - - if (m_faceName == wxT("monospace")) - { - m_family = wxFONTFAMILY_TELETYPE; - } - else if (m_faceName == wxT("sans")) - { - m_family = wxFONTFAMILY_SWISS; - } - else if (m_faceName == wxT("serif")) - { - m_family = wxFONTFAMILY_ROMAN; - } - else - { - m_family = wxFONTFAMILY_UNKNOWN; - } - - // Pango description are never underlined (?) - m_underlined = FALSE; - - // Cannot we choose that - m_encoding = wxFONTENCODING_SYSTEM; -#else // GTK 1.x - // get the font parameters from the XLFD - // ------------------------------------- - - m_faceName = m_nativeFontInfo.GetXFontComponent(wxXLFD_FAMILY); - - m_weight = wxFONTWEIGHT_NORMAL; - - wxString w = m_nativeFontInfo.GetXFontComponent(wxXLFD_WEIGHT).Upper(); - if ( !w.empty() && w != _T('*') ) - { - // the test below catches all of BOLD, EXTRABOLD, DEMIBOLD, ULTRABOLD - // and BLACK - if ( ((w[0u] == _T('B') && (!wxStrcmp(w.c_str() + 1, wxT("OLD")) || - !wxStrcmp(w.c_str() + 1, wxT("LACK"))))) || - wxStrstr(w.c_str() + 1, _T("BOLD")) ) - { - m_weight = wxFONTWEIGHT_BOLD; - } - else if ( w == _T("LIGHT") || w == _T("THIN") ) - { - m_weight = wxFONTWEIGHT_LIGHT; - } - } - - switch ( wxToupper(*m_nativeFontInfo. - GetXFontComponent(wxXLFD_SLANT).c_str()) ) - { - case _T('I'): // italique - m_style = wxFONTSTYLE_ITALIC; - break; - - case _T('O'): // oblique - m_style = wxFONTSTYLE_SLANT; - break; - - default: - m_style = wxFONTSTYLE_NORMAL; - } - - long ptSize; - if ( m_nativeFontInfo.GetXFontComponent(wxXLFD_POINTSIZE).ToLong(&ptSize) ) - { - // size in XLFD is in 10 point units - m_pointSize = (int)(ptSize / 10); - } - else - { - m_pointSize = wxDEFAULT_FONT_SIZE; - } - - // examine the spacing: if the font is monospaced, assume wxTELETYPE - // family for compatibility with the old code which used it instead of - // IsFixedWidth() - if ( m_nativeFontInfo.GetXFontComponent(wxXLFD_SPACING).Upper() == _T('M') ) - { - m_family = wxFONTFAMILY_TELETYPE; - } - else // not monospaceed - { - // don't even try guessing it, it doesn't work for too many fonts - // anyhow - m_family = wxFONTFAMILY_UNKNOWN; - } - - // X fonts are never underlined... - m_underlined = FALSE; - - // deal with font encoding - wxString - registry = m_nativeFontInfo.GetXFontComponent(wxXLFD_REGISTRY).Upper(), - encoding = m_nativeFontInfo.GetXFontComponent(wxXLFD_ENCODING).Upper(); - - if ( registry == _T("ISO8859") ) - { - int cp; - if ( wxSscanf(encoding, wxT("%d"), &cp) == 1 ) - { - m_encoding = (wxFontEncoding)(wxFONTENCODING_ISO8859_1 + cp - 1); - } - } - else if ( registry == _T("MICROSOFT") ) - { - int cp; - if ( wxSscanf(encoding, wxT("cp125%d"), &cp) == 1 ) - { - m_encoding = (wxFontEncoding)(wxFONTENCODING_CP1250 + cp); - } - } - else if ( registry == _T("KOI8") ) - { - m_encoding = wxFONTENCODING_KOI8; - } - else // unknown encoding - { - // may be give a warning here? or use wxFontMapper? - m_encoding = wxFONTENCODING_SYSTEM; - } -#endif // GTK 2.0/1.x -} - -wxFontRefData::wxFontRefData( const wxFontRefData& data ) - : wxObjectRefData() -{ - m_pointSize = data.m_pointSize; - m_family = data.m_family; - m_style = data.m_style; - m_weight = data.m_weight; - - m_underlined = data.m_underlined; - - m_faceName = data.m_faceName; - m_encoding = data.m_encoding; - - m_noAA = data.m_noAA; - - // Forces a copy of the internal data. wxNativeFontInfo should probably - // have a copy ctor and assignment operator to fix this properly but that - // would break binary compatibility... - m_nativeFontInfo.FromString(data.m_nativeFontInfo.ToString()); -} - -wxFontRefData::wxFontRefData(int size, int family, int style, - int weight, bool underlined, - const wxString& faceName, - wxFontEncoding encoding) -{ - Init(size, family, style, weight, underlined, faceName, encoding); -} - -wxFontRefData::wxFontRefData(const wxString& fontname) -{ - // VZ: FromString() should really work in both cases, doesn't it? -#ifdef __WXGTK20__ - m_nativeFontInfo.FromString( fontname ); -#else // GTK 1.x - m_nativeFontInfo.SetXFontName(fontname); -#endif // GTK 2.0/1.x - - InitFromNative(); -} - -void wxFontRefData::ClearGdkFonts() -{ -#ifndef __WXGTK20__ - for ( wxScaledFontList::iterator i = m_scaled_xfonts.begin(); - i != m_scaled_xfonts.end(); - ++i ) - { - GdkFont *font = i->second; - gdk_font_unref( font ); - } - - m_scaled_xfonts.clear(); -#endif // GTK 1.x -} - -wxFontRefData::~wxFontRefData() -{ - ClearGdkFonts(); -} - -// ---------------------------------------------------------------------------- -// wxFontRefData SetXXX() -// ---------------------------------------------------------------------------- - -void wxFontRefData::SetPointSize(int pointSize) -{ - m_pointSize = pointSize; - -#ifdef __WXGTK20__ - // Get native info - PangoFontDescription *desc = m_nativeFontInfo.description; - - pango_font_description_set_size( desc, m_pointSize * PANGO_SCALE ); -#else - if ( HasNativeFont() ) - { - wxString size; - if ( pointSize == -1 ) - size = _T('*'); - else - size.Printf(_T("%d"), 10*pointSize); - - m_nativeFontInfo.SetXFontComponent(wxXLFD_POINTSIZE, size); - } -#endif -} - -void wxFontRefData::SetFamily(int family) -{ - m_family = family; - - // TODO: what are we supposed to do with m_nativeFontInfo here? -} - -void wxFontRefData::SetStyle(int style) -{ - m_style = style; - -#ifdef __WXGTK20__ - // Get native info - PangoFontDescription *desc = m_nativeFontInfo.description; - - switch ( style ) - { - case wxFONTSTYLE_ITALIC: - pango_font_description_set_style( desc, PANGO_STYLE_ITALIC ); - break; - case wxFONTSTYLE_SLANT: - pango_font_description_set_style( desc, PANGO_STYLE_OBLIQUE ); - break; - default: - wxFAIL_MSG( _T("unknown font style") ); - // fall through - case wxFONTSTYLE_NORMAL: - pango_font_description_set_style( desc, PANGO_STYLE_NORMAL ); - break; - } -#else - if ( HasNativeFont() ) - { - wxString slant; - switch ( style ) - { - case wxFONTSTYLE_ITALIC: - slant = _T('i'); - break; - - case wxFONTSTYLE_SLANT: - slant = _T('o'); - break; - - default: - wxFAIL_MSG( _T("unknown font style") ); - // fall through - - case wxFONTSTYLE_NORMAL: - slant = _T('r'); - } - - m_nativeFontInfo.SetXFontComponent(wxXLFD_SLANT, slant); - } -#endif -} - -void wxFontRefData::SetWeight(int weight) -{ - m_weight = weight; - -#ifdef __WXGTK20__ - PangoFontDescription *desc = m_nativeFontInfo.description; - switch ( weight ) - { - case wxFONTWEIGHT_BOLD: - pango_font_description_set_weight(desc, PANGO_WEIGHT_BOLD); - break; - - case wxFONTWEIGHT_LIGHT: - pango_font_description_set_weight(desc, PANGO_WEIGHT_LIGHT); - break; - - default: - wxFAIL_MSG( _T("unknown font weight") ); - // fall through - - case wxFONTWEIGHT_NORMAL: - // unspecified - pango_font_description_set_weight(desc, PANGO_WEIGHT_NORMAL); - } -#else //!__WXGTK20__ - if ( HasNativeFont() ) - { - wxString boldness; - switch ( weight ) - { - case wxFONTWEIGHT_BOLD: - boldness = _T("bold"); - break; - - case wxFONTWEIGHT_LIGHT: - boldness = _T("light"); - break; - - default: - wxFAIL_MSG( _T("unknown font weight") ); - // fall through - - case wxFONTWEIGHT_NORMAL: - // unspecified - boldness = _T("medium"); - } - - m_nativeFontInfo.SetXFontComponent(wxXLFD_WEIGHT, boldness); - } -#endif -} - -void wxFontRefData::SetUnderlined(bool underlined) -{ - m_underlined = underlined; - - // the XLFD doesn't have "underlined" field anyhow -} - -void wxFontRefData::SetFaceName(const wxString& facename) -{ - m_faceName = facename; - -#ifndef __WXGTK20__ - if ( HasNativeFont() ) - { - m_nativeFontInfo.SetXFontComponent(wxXLFD_FAMILY, facename); - } -#endif -} - -void wxFontRefData::SetEncoding(wxFontEncoding encoding) -{ - m_encoding = encoding; - -#ifndef __WXGTK20__ - if ( HasNativeFont() ) - { - wxNativeEncodingInfo info; - if ( wxGetNativeFontEncoding(encoding, &info) ) - { - m_nativeFontInfo.SetXFontComponent(wxXLFD_REGISTRY, info.xregistry); - m_nativeFontInfo.SetXFontComponent(wxXLFD_ENCODING, info.xencoding); - } - } -#endif -} - -void wxFontRefData::SetNativeFontInfo(const wxNativeFontInfo& info) -{ - // previously cached fonts shouldn't be used - ClearGdkFonts(); - - m_nativeFontInfo = info; - - // set all the other font parameters from the native font info - InitFromNative(); -} - -// ---------------------------------------------------------------------------- -// wxFont creation -// ---------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject) - -void wxFont::Init() -{ -} - -wxFont::wxFont(const wxNativeFontInfo& info) -{ - Init(); - -#ifdef __WXGTK20__ - Create( info.GetPointSize(), - info.GetFamily(), - info.GetStyle(), - info.GetWeight(), - info.GetUnderlined(), - info.GetFaceName(), - info.GetEncoding() ); -#else - (void) Create(info.GetXFontName()); -#endif -} - -bool wxFont::Create( int pointSize, - int family, - int style, - int weight, - bool underlined, - const wxString& face, - wxFontEncoding encoding) -{ - UnRef(); - - m_refData = new wxFontRefData(pointSize, family, style, weight, - underlined, face, encoding); - - return TRUE; -} - -bool wxFont::Create(const wxString& fontname) -{ - // VZ: does this really happen? - if ( fontname.empty() ) - { - *this = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); - - return TRUE; - } - - m_refData = new wxFontRefData(fontname); - - return TRUE; -} - -void wxFont::Unshare() -{ - if (!m_refData) - { - m_refData = new wxFontRefData(); - } - else - { - wxFontRefData* ref = new wxFontRefData(*(wxFontRefData*)m_refData); - UnRef(); - m_refData = ref; - } -} - -wxFont::~wxFont() -{ -} - -// ---------------------------------------------------------------------------- -// accessors -// ---------------------------------------------------------------------------- - -int wxFont::GetPointSize() const -{ - wxCHECK_MSG( Ok(), 0, wxT("invalid font") ); - - return M_FONTDATA->m_pointSize; -} - -wxString wxFont::GetFaceName() const -{ - wxCHECK_MSG( Ok(), wxT(""), wxT("invalid font") ); - - return M_FONTDATA->m_faceName; -} - -int wxFont::GetFamily() const -{ - wxCHECK_MSG( Ok(), 0, wxT("invalid font") ); - - return M_FONTDATA->m_family; -} - -int wxFont::GetStyle() const -{ - wxCHECK_MSG( Ok(), 0, wxT("invalid font") ); - - return M_FONTDATA->m_style; -} - -int wxFont::GetWeight() const -{ - wxCHECK_MSG( Ok(), 0, wxT("invalid font") ); - - return M_FONTDATA->m_weight; -} - -bool wxFont::GetUnderlined() const -{ - wxCHECK_MSG( Ok(), FALSE, wxT("invalid font") ); - - return M_FONTDATA->m_underlined; -} - -wxFontEncoding wxFont::GetEncoding() const -{ - wxCHECK_MSG( Ok(), wxFONTENCODING_DEFAULT, wxT("invalid font") ); - - return M_FONTDATA->m_encoding; -} - -bool wxFont::GetNoAntiAliasing() -{ - wxCHECK_MSG( Ok(), wxFONTENCODING_DEFAULT, wxT("invalid font") ); - - return M_FONTDATA->m_noAA; -} - -wxNativeFontInfo *wxFont::GetNativeFontInfo() const -{ - wxCHECK_MSG( Ok(), (wxNativeFontInfo *)NULL, wxT("invalid font") ); - -#ifndef __WXGTK20__ // ??? - if ( M_FONTDATA->m_nativeFontInfo.GetXFontName().empty() ) - GetInternalFont(); -#endif - - return new wxNativeFontInfo(M_FONTDATA->m_nativeFontInfo); -} - -bool wxFont::IsFixedWidth() const -{ - wxCHECK_MSG( Ok(), FALSE, wxT("invalid font") ); - -#ifndef __WXGTK20__ - if ( M_FONTDATA->HasNativeFont() ) - { - // the monospace fonts are supposed to have "M" in the spacing field - wxString spacing = M_FONTDATA-> - m_nativeFontInfo.GetXFontComponent(wxXLFD_SPACING); - - return spacing.Upper() == _T('M'); - } -#endif - - return wxFontBase::IsFixedWidth(); -} - -// ---------------------------------------------------------------------------- -// change font attributes -// ---------------------------------------------------------------------------- - -void wxFont::SetPointSize(int pointSize) -{ - Unshare(); - - M_FONTDATA->SetPointSize(pointSize); -} - -void wxFont::SetFamily(int family) -{ - Unshare(); - - M_FONTDATA->SetFamily(family); -} - -void wxFont::SetStyle(int style) -{ - Unshare(); - - M_FONTDATA->SetStyle(style); -} - -void wxFont::SetWeight(int weight) -{ - Unshare(); - - M_FONTDATA->SetWeight(weight); -} - -void wxFont::SetFaceName(const wxString& faceName) -{ - Unshare(); - - M_FONTDATA->SetFaceName(faceName); -} - -void wxFont::SetUnderlined(bool underlined) -{ - Unshare(); - - M_FONTDATA->SetUnderlined(underlined); -} - -void wxFont::SetEncoding(wxFontEncoding encoding) -{ - Unshare(); - - M_FONTDATA->SetEncoding(encoding); -} - -void wxFont::SetNativeFontInfo( const wxNativeFontInfo& info ) -{ - Unshare(); - - M_FONTDATA->SetNativeFontInfo( info ); -} - -void wxFont::SetNoAntiAliasing( bool no ) -{ - Unshare(); - - M_FONTDATA->SetNoAntiAliasing( no ); -} - -// ---------------------------------------------------------------------------- -// get internal representation of font -// ---------------------------------------------------------------------------- - -static GdkFont *g_systemDefaultGuiFont = (GdkFont*) NULL; - -// this is also used from tbargtk.cpp and tooltip.cpp, hence extern -extern GdkFont *GtkGetDefaultGuiFont() -{ - if (!g_systemDefaultGuiFont) - { - GtkWidget *widget = gtk_button_new(); - GtkStyle *def = gtk_rc_get_style( widget ); - if (def) - { - g_systemDefaultGuiFont = gdk_font_ref( GET_STYLE_FONT(def) ); - } - else - { - def = gtk_widget_get_default_style(); - if (def) - g_systemDefaultGuiFont = gdk_font_ref( GET_STYLE_FONT(def) ); - } - gtk_widget_destroy( widget ); - } - else - { - // already have it, but ref it once more before returning - gdk_font_ref(g_systemDefaultGuiFont); - } - - return g_systemDefaultGuiFont; -} - -GdkFont *wxFont::GetInternalFont( float scale ) const -{ - GdkFont *font = (GdkFont *) NULL; - - wxCHECK_MSG( Ok(), font, wxT("invalid font") ) - -#ifdef __WXGTK20__ - if (*this == wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT)) - { - font = GtkGetDefaultGuiFont(); - } - else - { - PangoFontDescription * - font_description = GetNativeFontInfo()->description; - - font = gdk_font_from_description( font_description ); - } -#else // GTK 1.x - long int_scale = long(scale * 100.0 + 0.5); // key for fontlist - int point_scale = (int)((M_FONTDATA->m_pointSize * 10 * int_scale) / 100); - - wxScaledFontList& list = M_FONTDATA->m_scaled_xfonts; - wxScaledFontList::iterator i = list.find(int_scale); - if ( i != list.end() ) - { - font = i->second; - } - else // we don't have this font in this size yet - { - if (*this == wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT)) - { - font = GtkGetDefaultGuiFont(); - } - - if ( !font ) - { - // do we have the XLFD? - if ( M_FONTDATA->HasNativeFont() ) - { - font = wxLoadFont(M_FONTDATA->m_nativeFontInfo.GetXFontName()); - } - - // no XLFD of no exact match - try the approximate one now - if ( !font ) - { - wxString xfontname; - font = wxLoadQueryNearestFont( point_scale, - M_FONTDATA->m_family, - M_FONTDATA->m_style, - M_FONTDATA->m_weight, - M_FONTDATA->m_underlined, - M_FONTDATA->m_faceName, - M_FONTDATA->m_encoding, - &xfontname); - if ( font ) - { - M_FONTDATA->m_nativeFontInfo.SetXFontName(xfontname); - M_FONTDATA->InitFromNative(); - } - } - } - - if ( font ) - { - list[int_scale] = font; - } - } -#endif // GTK 2.0/1.x - - // it's quite useless to make it a wxCHECK because we're going to crash - // anyhow... - wxASSERT_MSG( font, wxT("could not load any font?") ); - - return font; -} - diff --git a/src/gtk1/fontdlg.cpp b/src/gtk1/fontdlg.cpp deleted file mode 100644 index 5730d731ca..0000000000 --- a/src/gtk1/fontdlg.cpp +++ /dev/null @@ -1,183 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: gtk/fontdlg.cpp -// Purpose: wxFontDialog -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/defs.h" - -#if wxUSE_FONTDLG - -#include "wx/fontutil.h" -#include "wx/fontdlg.h" -#include "wx/utils.h" -#include "wx/intl.h" -#include "wx/debug.h" -#include "wx/msgdlg.h" - -#include "wx/gtk/private.h" - -//----------------------------------------------------------------------------- -// idle system -//----------------------------------------------------------------------------- - -extern void wxapp_install_idle_handler(); -extern bool g_isIdle; - -//----------------------------------------------------------------------------- -// "delete_event" -//----------------------------------------------------------------------------- - -static -bool gtk_fontdialog_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxDialog *win ) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - -/* - printf( "OnDelete from " ); - if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) - printf( win->GetClassInfo()->GetClassName() ); - printf( ".\n" ); -*/ - - win->Close(); - - return TRUE; -} - -//----------------------------------------------------------------------------- -// "clicked" for OK-button -//----------------------------------------------------------------------------- - -static -void gtk_fontdialog_ok_callback( GtkWidget *WXUNUSED(widget), wxFontDialog *dialog ) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - - GtkFontSelectionDialog *fontdlg = GTK_FONT_SELECTION_DIALOG(dialog->m_widget); - -#ifndef __WXGTK20__ - GdkFont *gfont = gtk_font_selection_dialog_get_font(fontdlg); - - if (!gfont) - { - wxMessageBox(_("Please choose a valid font."), _("Error"), - wxOK | wxICON_ERROR); - return; - } -#endif - - gchar *fontname = gtk_font_selection_dialog_get_font_name( fontdlg ); - dialog->SetChosenFont( fontname); - g_free( fontname ); - - wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK); - event.SetEventObject( dialog ); - dialog->GetEventHandler()->ProcessEvent( event ); -} - -//----------------------------------------------------------------------------- -// "clicked" for Cancel-button -//----------------------------------------------------------------------------- - -static -void gtk_fontdialog_cancel_callback( GtkWidget *WXUNUSED(w), wxFontDialog *dialog ) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - - wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); - event.SetEventObject( dialog ); - dialog->GetEventHandler()->ProcessEvent( event ); -} - -//----------------------------------------------------------------------------- -// wxFontDialog -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog) - -bool wxFontDialog::DoCreate(wxWindow *parent) -{ - m_needParent = FALSE; - - if (!PreCreation( parent, wxDefaultPosition, wxDefaultSize ) || - !CreateBase( parent, -1, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE, - wxDefaultValidator, wxT("fontdialog") )) - { - wxFAIL_MSG( wxT("wxFontDialog creation failed") ); - return FALSE; - } - - wxString m_message( _("Choose font") ); - m_widget = gtk_font_selection_dialog_new( wxGTK_CONV( m_message ) ); - - int x = (gdk_screen_width () - 400) / 2; - int y = (gdk_screen_height () - 400) / 2; - gtk_widget_set_uposition( m_widget, x, y ); - - GtkFontSelectionDialog *sel = GTK_FONT_SELECTION_DIALOG(m_widget); - - gtk_signal_connect( GTK_OBJECT(sel->ok_button), "clicked", - GTK_SIGNAL_FUNC(gtk_fontdialog_ok_callback), (gpointer*)this ); - -#ifndef __WXGTK20__ - // strange way to internationalize - gtk_label_set( GTK_LABEL( BUTTON_CHILD(sel->ok_button) ), _("OK") ); -#endif - - gtk_signal_connect( GTK_OBJECT(sel->cancel_button), "clicked", - GTK_SIGNAL_FUNC(gtk_fontdialog_cancel_callback), (gpointer*)this ); - -#ifndef __WXGTK20__ - // strange way to internationalize - gtk_label_set( GTK_LABEL( BUTTON_CHILD(sel->cancel_button) ), _("Cancel") ); -#endif - - gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event", - GTK_SIGNAL_FUNC(gtk_fontdialog_delete_callback), (gpointer)this ); - -#ifndef __WXGTK20__ - wxFont font = m_fontData.GetInitialFont(); - if( font.Ok() ) - { - wxNativeFontInfo *info = font.GetNativeFontInfo(); - - if ( info ) - { - const wxString& fontname = info->GetXFontName(); - if ( !fontname ) - font.GetInternalFont(); - gtk_font_selection_dialog_set_font_name - ( - sel, - wxConvCurrent->cWX2MB(fontname) - ); - } - else - { - // this is not supposed to happen! - wxFAIL_MSG(_T("font is ok but no native font info?")); - } - } -#endif - - return TRUE; -} - -wxFontDialog::~wxFontDialog() -{ -} - -void wxFontDialog::SetChosenFont(const char *fontname) -{ - m_fontData.SetChosenFont(wxFont( wxString::FromAscii(fontname) )); -} - -#endif // wxUSE_FONTDLG - diff --git a/src/gtk1/frame.cpp b/src/gtk1/frame.cpp deleted file mode 100644 index f689135c8d..0000000000 --- a/src/gtk1/frame.cpp +++ /dev/null @@ -1,679 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: frame.cpp -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -#include "wx/defs.h" - -#include "wx/dialog.h" -#include "wx/control.h" -#include "wx/app.h" -#include "wx/menu.h" -#if wxUSE_TOOLBAR - #include "wx/toolbar.h" -#endif -#if wxUSE_STATUSBAR - #include "wx/statusbr.h" -#endif -#include "wx/dcclient.h" - -#include -#include "wx/gtk/private.h" - -#include -#include - -#include "wx/gtk/win_gtk.h" - -// ---------------------------------------------------------------------------- -// constants -// ---------------------------------------------------------------------------- - -const int wxSTATUS_HEIGHT = 25; -const int wxPLACE_HOLDER = 0; - -// ---------------------------------------------------------------------------- -// idle system -// ---------------------------------------------------------------------------- - -extern void wxapp_install_idle_handler(); -extern bool g_isIdle; -extern int g_openDialogs; - -// ---------------------------------------------------------------------------- -// event tables -// ---------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxTopLevelWindow) - -// ============================================================================ -// implementation -// ============================================================================ - -// ---------------------------------------------------------------------------- -// GTK callbacks -// ---------------------------------------------------------------------------- - -#if wxUSE_MENUS_NATIVE - -//----------------------------------------------------------------------------- -// "child_attached" of menu bar -//----------------------------------------------------------------------------- - -static void gtk_menu_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win ) -{ - if (!win->m_hasVMT) return; - - win->m_menuBarDetached = FALSE; - win->GtkUpdateSize(); -} - -//----------------------------------------------------------------------------- -// "child_detached" of menu bar -//----------------------------------------------------------------------------- - -static void gtk_menu_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win ) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - - if (!win->m_hasVMT) return; - - // Raise the client area area - gdk_window_raise( win->m_wxwindow->window ); - - win->m_menuBarDetached = TRUE; - win->GtkUpdateSize(); -} - -#endif // wxUSE_MENUS_NATIVE - -#if wxUSE_TOOLBAR -//----------------------------------------------------------------------------- -// "child_attached" of tool bar -//----------------------------------------------------------------------------- - -static void gtk_toolbar_attached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win ) -{ - if (!win->m_hasVMT) return; - - win->m_toolBarDetached = FALSE; - win->GtkUpdateSize(); -} - -//----------------------------------------------------------------------------- -// "child_detached" of tool bar -//----------------------------------------------------------------------------- - -static void gtk_toolbar_detached_callback( GtkWidget *WXUNUSED(widget), GtkWidget *WXUNUSED(child), wxFrame *win ) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - - if (!win->m_hasVMT) return; - - // Raise the client area area - gdk_window_raise( win->m_wxwindow->window ); - - win->m_toolBarDetached = TRUE; - win->GtkUpdateSize(); -} -#endif // wxUSE_TOOLBAR - - -// ---------------------------------------------------------------------------- -// wxFrame itself -// ---------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// InsertChild for wxFrame -//----------------------------------------------------------------------------- - -/* Callback for wxFrame. This very strange beast has to be used because - * C++ has no virtual methods in a constructor. We have to emulate a - * virtual function here as wxWindows requires different ways to insert - * a child in container classes. */ - -static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child ) -{ - wxASSERT( GTK_IS_WIDGET(child->m_widget) ); - - if (!parent->m_insertInClientArea) - { - // These are outside the client area - wxFrame* frame = (wxFrame*) parent; - gtk_pizza_put( GTK_PIZZA(frame->m_mainWidget), - GTK_WIDGET(child->m_widget), - child->m_x, - child->m_y, - child->m_width, - child->m_height ); - -#if wxUSE_TOOLBAR_NATIVE - // We connect to these events for recalculating the client area - // space when the toolbar is floating - if (wxIS_KIND_OF(child,wxToolBar)) - { - wxToolBar *toolBar = (wxToolBar*) child; - if (toolBar->GetWindowStyle() & wxTB_DOCKABLE) - { - gtk_signal_connect( GTK_OBJECT(toolBar->m_widget), "child_attached", - GTK_SIGNAL_FUNC(gtk_toolbar_attached_callback), (gpointer)parent ); - - gtk_signal_connect( GTK_OBJECT(toolBar->m_widget), "child_detached", - GTK_SIGNAL_FUNC(gtk_toolbar_detached_callback), (gpointer)parent ); - } - } -#endif // wxUSE_TOOLBAR - } - else - { - // These are inside the client area - gtk_pizza_put( GTK_PIZZA(parent->m_wxwindow), - GTK_WIDGET(child->m_widget), - child->m_x, - child->m_y, - child->m_width, - child->m_height ); - } - - // Resize on OnInternalIdle - parent->GtkUpdateSize(); -} - -// ---------------------------------------------------------------------------- -// wxFrame creation -// ---------------------------------------------------------------------------- - -void wxFrame::Init() -{ - m_menuBarDetached = FALSE; - m_toolBarDetached = FALSE; - m_menuBarHeight = 2; -} - -bool wxFrame::Create( wxWindow *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos, - const wxSize& sizeOrig, - long style, - const wxString &name ) -{ - bool rt = wxTopLevelWindow::Create(parent, id, title, pos, sizeOrig, - style, name); - m_insertCallback = (wxInsertChildFunction) wxInsertChildInFrame; - - return rt; -} - -wxFrame::~wxFrame() -{ - m_isBeingDeleted = TRUE; - DeleteAllBars(); -} - -// ---------------------------------------------------------------------------- -// overridden wxWindow methods -// ---------------------------------------------------------------------------- - -void wxFrame::DoGetClientSize( int *width, int *height ) const -{ - wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); - - wxTopLevelWindow::DoGetClientSize( width, height ); - - if (height) - { -#if wxUSE_MENUS_NATIVE - // menu bar - if (m_frameMenuBar) - { - if (!m_menuBarDetached) - (*height) -= m_menuBarHeight; - else - (*height) -= wxPLACE_HOLDER; - } -#endif // wxUSE_MENUS_NATIVE - -#if wxUSE_STATUSBAR - // status bar - if (m_frameStatusBar && m_frameStatusBar->IsShown()) - (*height) -= wxSTATUS_HEIGHT; -#endif // wxUSE_STATUSBAR - -#if wxUSE_TOOLBAR - // tool bar - if (m_frameToolBar && m_frameToolBar->IsShown()) - { - if (m_toolBarDetached) - { - *height -= wxPLACE_HOLDER; - } - else - { - int x, y; - m_frameToolBar->GetSize( &x, &y ); - if ( m_frameToolBar->GetWindowStyle() & wxTB_VERTICAL ) - { - *width -= x; - } - else - { - *height -= y; - } - } - } -#endif // wxUSE_TOOLBAR - } -} - -void wxFrame::DoSetClientSize( int width, int height ) -{ - wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); - -#if wxUSE_MENUS_NATIVE - // menu bar - if (m_frameMenuBar) - { - if (!m_menuBarDetached) - height += m_menuBarHeight; - else - height += wxPLACE_HOLDER; - } -#endif // wxUSE_MENUS_NATIVE - -#if wxUSE_STATUSBAR - // status bar - if (m_frameStatusBar && m_frameStatusBar->IsShown()) height += wxSTATUS_HEIGHT; -#endif - -#if wxUSE_TOOLBAR - // tool bar - if (m_frameToolBar && m_frameToolBar->IsShown()) - { - if (m_toolBarDetached) - { - height += wxPLACE_HOLDER; - } - else - { - int x, y; - m_frameToolBar->GetSize( &x, &y ); - if ( m_frameToolBar->GetWindowStyle() & wxTB_VERTICAL ) - { - width += x; - } - else - { - height += y; - } - } - } -#endif - - wxTopLevelWindow::DoSetClientSize( width, height ); -} - -void wxFrame::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; - - // avoid recursions - if (m_resizing) return; - m_resizing = TRUE; - - // this shouldn't happen: wxFrame, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow - wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid frame") ); - - m_width = width; - m_height = height; - - // space occupied by m_frameToolBar and m_frameMenuBar - int client_area_x_offset = 0, - client_area_y_offset = 0; - - /* wxMDIChildFrame derives from wxFrame but it _is_ a wxWindow as it uses - wxWindow::Create to create it's GTK equivalent. m_mainWidget is only - set in wxFrame::Create so it is used to check what kind of frame we - have here. if m_mainWidget is NULL it is a wxMDIChildFrame and so we - skip the part which handles m_frameMenuBar, m_frameToolBar and (most - importantly) m_mainWidget */ - - int minWidth = GetMinWidth(), - minHeight = GetMinHeight(), - maxWidth = GetMaxWidth(), - maxHeight = GetMaxHeight(); - - if ((minWidth != -1) && (m_width < minWidth)) m_width = minWidth; - if ((minHeight != -1) && (m_height < minHeight)) m_height = minHeight; - if ((maxWidth != -1) && (m_width > maxWidth)) m_width = maxWidth; - if ((maxHeight != -1) && (m_height > maxHeight)) m_height = maxHeight; - - if (m_mainWidget) - { - // set size hints - gint flag = 0; // GDK_HINT_POS; - if ((minWidth != -1) || (minHeight != -1)) flag |= GDK_HINT_MIN_SIZE; - if ((maxWidth != -1) || (maxHeight != -1)) flag |= GDK_HINT_MAX_SIZE; - GdkGeometry geom; - geom.min_width = minWidth; - geom.min_height = minHeight; - geom.max_width = maxWidth; - geom.max_height = maxHeight; - gtk_window_set_geometry_hints( GTK_WINDOW(m_widget), - (GtkWidget*) NULL, - &geom, - (GdkWindowHints) flag ); - - // I revert back to wxGTK's original behaviour. m_mainWidget holds - // the menubar, the toolbar and the client area, which is represented - // by m_wxwindow. - // This hurts in the eye, but I don't want to call SetSize() - // because I don't want to call any non-native functions here. - -#if wxUSE_MENUS_NATIVE - if (m_frameMenuBar) - { - int xx = m_miniEdge; - int yy = m_miniEdge + m_miniTitle; - int ww = m_width - 2*m_miniEdge; - int hh = m_menuBarHeight; - if (m_menuBarDetached) hh = wxPLACE_HOLDER; - m_frameMenuBar->m_x = xx; - m_frameMenuBar->m_y = yy; - m_frameMenuBar->m_width = ww; - m_frameMenuBar->m_height = hh; - gtk_pizza_set_size( GTK_PIZZA(m_mainWidget), - m_frameMenuBar->m_widget, - xx, yy, ww, hh ); - client_area_y_offset += hh; - } -#endif // wxUSE_MENUS_NATIVE - -#if wxUSE_TOOLBAR - if ((m_frameToolBar) && m_frameToolBar->IsShown() && - (m_frameToolBar->m_widget->parent == m_mainWidget)) - { - int xx = m_miniEdge; - int yy = m_miniEdge + m_miniTitle; -#if wxUSE_MENUS_NATIVE - if (m_frameMenuBar) - { - if (!m_menuBarDetached) - yy += m_menuBarHeight; - else - yy += wxPLACE_HOLDER; - } -#endif // wxUSE_MENUS_NATIVE - - m_frameToolBar->m_x = xx; - m_frameToolBar->m_y = yy; - - // don't change the toolbar's reported height/width - int ww, hh; - if ( m_frameToolBar->GetWindowStyle() & wxTB_VERTICAL ) - { - ww = m_toolBarDetached ? wxPLACE_HOLDER - : m_frameToolBar->m_width; - hh = m_height - 2*m_miniEdge; - - client_area_x_offset += ww; - } - else - { - ww = m_width - 2*m_miniEdge; - hh = m_toolBarDetached ? wxPLACE_HOLDER - : m_frameToolBar->m_height; - - client_area_y_offset += hh; - } - - gtk_pizza_set_size( GTK_PIZZA(m_mainWidget), - m_frameToolBar->m_widget, - xx, yy, ww, hh ); - } -#endif // wxUSE_TOOLBAR - - int client_x = client_area_x_offset + m_miniEdge; - int client_y = client_area_y_offset + m_miniEdge + m_miniTitle; - int client_w = m_width - client_area_x_offset - 2*m_miniEdge; - int client_h = m_height - client_area_y_offset- 2*m_miniEdge - m_miniTitle; - gtk_pizza_set_size( GTK_PIZZA(m_mainWidget), - m_wxwindow, - client_x, client_y, client_w, client_h ); - } - else - { - // If there is no m_mainWidget between m_widget and m_wxwindow there - // is no need to set the size or position of m_wxwindow. - } - -#if wxUSE_STATUSBAR - if (m_frameStatusBar && m_frameStatusBar->IsShown()) - { - int xx = 0 + m_miniEdge; - int yy = m_height - wxSTATUS_HEIGHT - m_miniEdge - client_area_y_offset; - int ww = m_width - 2*m_miniEdge; - int hh = wxSTATUS_HEIGHT; - m_frameStatusBar->m_x = xx; - m_frameStatusBar->m_y = yy; - m_frameStatusBar->m_width = ww; - m_frameStatusBar->m_height = hh; - gtk_pizza_set_size( GTK_PIZZA(m_wxwindow), - m_frameStatusBar->m_widget, - xx, yy, ww, hh ); - gtk_widget_draw( m_frameStatusBar->m_widget, (GdkRectangle*) NULL ); - } -#endif // wxUSE_STATUSBAR - - m_sizeSet = TRUE; - - // send size event to frame - wxSizeEvent event( wxSize(m_width,m_height), GetId() ); - event.SetEventObject( this ); - GetEventHandler()->ProcessEvent( event ); - -#if wxUSE_STATUSBAR - // send size event to status bar - if (m_frameStatusBar) - { - wxSizeEvent event2( wxSize(m_frameStatusBar->m_width,m_frameStatusBar->m_height), m_frameStatusBar->GetId() ); - event2.SetEventObject( m_frameStatusBar ); - m_frameStatusBar->GetEventHandler()->ProcessEvent( event2 ); - } -#endif // wxUSE_STATUSBAR - - m_resizing = FALSE; -} - -void wxFrame::OnInternalIdle() -{ - wxTopLevelWindow::OnInternalIdle(); - -#if wxUSE_MENUS_NATIVE - if (m_frameMenuBar) m_frameMenuBar->OnInternalIdle(); -#endif // wxUSE_MENUS_NATIVE -#if wxUSE_TOOLBAR - if (m_frameToolBar) m_frameToolBar->OnInternalIdle(); -#endif -#if wxUSE_STATUSBAR - if (m_frameStatusBar) m_frameStatusBar->OnInternalIdle(); -#endif -} - -// ---------------------------------------------------------------------------- -// menu/tool/status bar stuff -// ---------------------------------------------------------------------------- - -#if wxUSE_MENUS_NATIVE - -void wxFrame::DetachMenuBar() -{ - wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); - wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid frame") ); - - if ( m_frameMenuBar ) - { - m_frameMenuBar->UnsetInvokingWindow( this ); - - if (m_frameMenuBar->GetWindowStyle() & wxMB_DOCKABLE) - { - gtk_signal_disconnect_by_func( GTK_OBJECT(m_frameMenuBar->m_widget), - GTK_SIGNAL_FUNC(gtk_menu_attached_callback), (gpointer)this ); - - gtk_signal_disconnect_by_func( GTK_OBJECT(m_frameMenuBar->m_widget), - GTK_SIGNAL_FUNC(gtk_menu_detached_callback), (gpointer)this ); - } - - gtk_widget_ref( m_frameMenuBar->m_widget ); - - gtk_container_remove( GTK_CONTAINER(m_mainWidget), m_frameMenuBar->m_widget ); - } - - wxFrameBase::DetachMenuBar(); -} - -void wxFrame::AttachMenuBar( wxMenuBar *menuBar ) -{ - wxFrameBase::AttachMenuBar(menuBar); - - if (m_frameMenuBar) - { - m_frameMenuBar->SetInvokingWindow( this ); - - m_frameMenuBar->SetParent(this); - gtk_pizza_put( GTK_PIZZA(m_mainWidget), - m_frameMenuBar->m_widget, - m_frameMenuBar->m_x, - m_frameMenuBar->m_y, - m_frameMenuBar->m_width, - m_frameMenuBar->m_height ); - - if (menuBar->GetWindowStyle() & wxMB_DOCKABLE) - { - gtk_signal_connect( GTK_OBJECT(menuBar->m_widget), "child_attached", - GTK_SIGNAL_FUNC(gtk_menu_attached_callback), (gpointer)this ); - - gtk_signal_connect( GTK_OBJECT(menuBar->m_widget), "child_detached", - GTK_SIGNAL_FUNC(gtk_menu_detached_callback), (gpointer)this ); - } - - m_frameMenuBar->Show( TRUE ); - - UpdateMenuBarSize(); - } - else - { - m_menuBarHeight = 2; - GtkUpdateSize(); // resize window in OnInternalIdle - } -} - -void wxFrame::UpdateMenuBarSize() -{ - wxASSERT_MSG( m_frameMenuBar, _T("Updating non existant menubar?") ); - - GtkRequisition req; - - req.width = 2; - req.height = 2; - - (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(m_frameMenuBar->m_widget) )->size_request ) - (m_frameMenuBar->m_widget, &req ); - - m_menuBarHeight = req.height; - - // resize window in OnInternalIdle - - GtkUpdateSize(); -} - -#endif // wxUSE_MENUS_NATIVE - -#if wxUSE_TOOLBAR - -wxToolBar* wxFrame::CreateToolBar( long style, wxWindowID id, const wxString& name ) -{ - wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); - - m_insertInClientArea = FALSE; - - m_frameToolBar = wxFrameBase::CreateToolBar( style, id, name ); - - m_insertInClientArea = TRUE; - - GtkUpdateSize(); - - return m_frameToolBar; -} - -void wxFrame::SetToolBar(wxToolBar *toolbar) -{ - bool hadTbar = m_frameToolBar != NULL; - - wxFrameBase::SetToolBar(toolbar); - - if ( m_frameToolBar ) - { - // insert into toolbar area if not already there - if ((m_frameToolBar->m_widget->parent) && - (m_frameToolBar->m_widget->parent != m_mainWidget)) - { - GetChildren().DeleteObject( m_frameToolBar ); - - gtk_widget_reparent( m_frameToolBar->m_widget, m_mainWidget ); - GtkUpdateSize(); - } - } - else // toolbar unset - { - // still need to update size if it had been there before - if ( hadTbar ) - { - GtkUpdateSize(); - } - } -} - -#endif // wxUSE_TOOLBAR - -#if wxUSE_STATUSBAR - -wxStatusBar* wxFrame::CreateStatusBar(int number, - long style, - wxWindowID id, - const wxString& name) -{ - wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); - - // because it will change when toolbar is added - GtkUpdateSize(); - - return wxFrameBase::CreateStatusBar( number, style, id, name ); -} - -void wxFrame::PositionStatusBar() -{ - if ( !m_frameStatusBar ) - return; - - GtkUpdateSize(); -} -#endif // wxUSE_STATUSBAR - diff --git a/src/gtk1/gauge.cpp b/src/gtk1/gauge.cpp deleted file mode 100644 index cc0410e701..0000000000 --- a/src/gtk1/gauge.cpp +++ /dev/null @@ -1,102 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: gauge.cpp -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/gauge.h" - -#if wxUSE_GAUGE - -#include - -//----------------------------------------------------------------------------- -// wxGauge -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxGauge, wxControl) - -bool wxGauge::Create( wxWindow *parent, - wxWindowID id, - int range, - const wxPoint& pos, - const wxSize& size, - long style, - const wxValidator& validator, - const wxString& name ) -{ - m_needParent = TRUE; - - if (!PreCreation( parent, pos, size ) || - !CreateBase( parent, id, pos, size, style, validator, name )) - { - wxFAIL_MSG( wxT("wxGauge creation failed") ); - return FALSE; - } - - m_rangeMax = range; - - m_widget = gtk_progress_bar_new(); - if ( style & wxGA_VERTICAL ) - { - gtk_progress_bar_set_orientation( GTK_PROGRESS_BAR(m_widget), - GTK_PROGRESS_BOTTOM_TO_TOP ); - } - - m_parent->DoAddChild( this ); - - PostCreation(); - - Show( TRUE ); - - return TRUE; -} - -void wxGauge::DoSetGauge() -{ - wxASSERT_MSG( 0 <= m_gaugePos && m_gaugePos <= m_rangeMax, - _T("invalid gauge position in DoSetGauge()") ); - - gtk_progress_bar_update( GTK_PROGRESS_BAR(m_widget), - m_rangeMax ? ((float)m_gaugePos)/m_rangeMax : 0.); -} - -void wxGauge::SetRange( int range ) -{ - m_rangeMax = range; - if (m_gaugePos > m_rangeMax) - m_gaugePos = m_rangeMax; - - DoSetGauge(); -} - -void wxGauge::SetValue( int pos ) -{ - wxCHECK_RET( pos <= m_rangeMax, _T("invalid value in wxGauge::SetValue()") ); - - m_gaugePos = pos; - - DoSetGauge(); -} - -int wxGauge::GetRange() const -{ - return m_rangeMax; -} - -int wxGauge::GetValue() const -{ - return m_gaugePos; -} - -void wxGauge::ApplyWidgetStyle() -{ - SetWidgetStyle(); - gtk_widget_set_style( m_widget, m_widgetStyle ); -} - -#endif // wxUSE_GAUGE - diff --git a/src/gtk1/gdiobj.cpp b/src/gtk1/gdiobj.cpp deleted file mode 100644 index 1e1ac0e7c6..0000000000 --- a/src/gtk1/gdiobj.cpp +++ /dev/null @@ -1,13 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: gdiobj.cpp -// Purpose: wxGDIObject class -// Author: Julian Smart -// RCS-ID: $Id$ -// Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/gdiobj.h" - -IMPLEMENT_DYNAMIC_CLASS(wxGDIObject, wxObject) - diff --git a/src/gtk1/glcanvas.cpp b/src/gtk1/glcanvas.cpp deleted file mode 100644 index 16d05e5a39..0000000000 --- a/src/gtk1/glcanvas.cpp +++ /dev/null @@ -1,495 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: gtk/glcanvas.cpp -// Purpose: wxGLCanvas, for using OpenGL/Mesa with wxWindows and GTK -// Author: Robert Roebling -// Modified by: -// Created: 17/08/98 -// RCS-ID: $Id$ -// Copyright: (c) Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/setup.h" - -#if wxUSE_GLCANVAS - -#include "wx/glcanvas.h" - -#include "wx/frame.h" -#include "wx/colour.h" -#include "wx/module.h" -#include "wx/app.h" - -extern "C" -{ -#include "gtk/gtk.h" -#include "gdk/gdk.h" -#include "gdk/gdkx.h" -} - -#include "wx/gtk/win_gtk.h" - -//--------------------------------------------------------------------------- -// global data -//--------------------------------------------------------------------------- - -XVisualInfo *g_vi = (XVisualInfo*) NULL; - -//----------------------------------------------------------------------------- -// idle system -//----------------------------------------------------------------------------- - -extern void wxapp_install_idle_handler(); -extern bool g_isIdle; - -//--------------------------------------------------------------------------- -// wxGLContext -//--------------------------------------------------------------------------- - -IMPLEMENT_CLASS(wxGLContext,wxObject) - -wxGLContext::wxGLContext( bool WXUNUSED(isRGB), wxWindow *win, const wxPalette& WXUNUSED(palette) ) -{ - m_window = win; - m_widget = win->m_wxwindow; - - wxGLCanvas *gc = (wxGLCanvas*) win; - XVisualInfo *vi = (XVisualInfo *) gc->m_vi; - - wxCHECK_RET( vi, _T("invalid visual for OpenGl") ); - - m_glContext = glXCreateContext( GDK_DISPLAY(), vi, None, GL_TRUE ); - - wxCHECK_RET( m_glContext, _T("Couldn't create OpenGl context") ); -} - -wxGLContext::wxGLContext( - bool WXUNUSED(isRGB), wxWindow *win, - const wxPalette& WXUNUSED(palette), - const wxGLContext *other /* for sharing display lists */ -) -{ - m_window = win; - m_widget = win->m_wxwindow; - - wxGLCanvas *gc = (wxGLCanvas*) win; - XVisualInfo *vi = (XVisualInfo *) gc->m_vi; - - wxCHECK_RET( vi, _T("invalid visual for OpenGl") ); - - m_glContext = glXCreateContext( GDK_DISPLAY(), vi, - other ? other->m_glContext : None, - GL_TRUE ); - - if ( !m_glContext ) - { - wxFAIL_MSG( _T("Couldn't create OpenGl context") ); - } -} - -wxGLContext::~wxGLContext() -{ - if (!m_glContext) return; - - if (m_glContext == glXGetCurrentContext()) - { - glXMakeCurrent( GDK_DISPLAY(), None, NULL); - } - - glXDestroyContext( GDK_DISPLAY(), m_glContext ); -} - -void wxGLContext::SwapBuffers() -{ - if (m_glContext) - { - GdkWindow *window = GTK_PIZZA(m_widget)->bin_window; - glXSwapBuffers( GDK_DISPLAY(), GDK_WINDOW_XWINDOW( window ) ); - } -} - -void wxGLContext::SetCurrent() -{ - if (m_glContext) - { - GdkWindow *window = GTK_PIZZA(m_widget)->bin_window; - glXMakeCurrent( GDK_DISPLAY(), GDK_WINDOW_XWINDOW(window), m_glContext ); - } -} - -void wxGLContext::SetColour(const wxChar *colour) -{ - float r = 0.0; - float g = 0.0; - float b = 0.0; - wxColour *col = wxTheColourDatabase->FindColour(colour); - if (col) - { - r = (float)(col->Red()/256.0); - g = (float)(col->Green()/256.0); - b = (float)(col->Blue()/256.0); - glColor3f( r, g, b); - } -} - -void wxGLContext::SetupPixelFormat() -{ -} - -void wxGLContext::SetupPalette( const wxPalette& WXUNUSED(palette) ) -{ -} - -wxPalette wxGLContext::CreateDefaultPalette() -{ - return wxNullPalette; -} - -//----------------------------------------------------------------------------- -// "realize" from m_wxwindow -//----------------------------------------------------------------------------- - -static gint -gtk_glwindow_realized_callback( GtkWidget * WXUNUSED(widget), wxGLCanvas *win ) -{ - wxGLContext *share= win->m_sharedContext; - if (share==NULL && win->m_sharedContextOf) share=win->m_sharedContextOf->GetContext(); - - win->m_glContext = new wxGLContext( TRUE, win, wxNullPalette, share ); - - return FALSE; -} - -//----------------------------------------------------------------------------- -// "map" from m_wxwindow -//----------------------------------------------------------------------------- - -static gint -gtk_glwindow_map_callback( GtkWidget * WXUNUSED(widget), wxGLCanvas *win ) -{ - if (win->m_glContext/* && win->m_exposed*/) - { - wxPaintEvent event( win->GetId() ); - event.SetEventObject( win ); - win->GetEventHandler()->ProcessEvent( event ); - - win->m_exposed = FALSE; - win->GetUpdateRegion().Clear(); - } - - return FALSE; -} - -//----------------------------------------------------------------------------- -// "expose_event" of m_wxwindow -//----------------------------------------------------------------------------- - -static void -gtk_glwindow_expose_callback( GtkWidget *WXUNUSED(widget), GdkEventExpose *gdk_event, wxGLCanvas *win ) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - - win->m_exposed = TRUE; - - win->GetUpdateRegion().Union( gdk_event->area.x, - gdk_event->area.y, - gdk_event->area.width, - gdk_event->area.height ); -} - -//----------------------------------------------------------------------------- -// "draw" of m_wxwindow -//----------------------------------------------------------------------------- - -#ifndef __WXGTK20__ -static void -gtk_glwindow_draw_callback( GtkWidget *WXUNUSED(widget), GdkRectangle *rect, wxGLCanvas *win ) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - - win->m_exposed = TRUE; - - win->GetUpdateRegion().Union( rect->x, rect->y, - rect->width, rect->height ); -} -#endif - -//----------------------------------------------------------------------------- -// "size_allocate" of m_wxwindow -//----------------------------------------------------------------------------- - -static void -gtk_glcanvas_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxGLCanvas *win ) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - - if (!win->m_hasVMT) - return; - - wxSizeEvent event( wxSize(win->m_width,win->m_height), win->GetId() ); - event.SetEventObject( win ); - win->GetEventHandler()->ProcessEvent( event ); -} - -//--------------------------------------------------------------------------- -// wxGlCanvas -//--------------------------------------------------------------------------- - -IMPLEMENT_CLASS(wxGLCanvas, wxWindow) - -BEGIN_EVENT_TABLE(wxGLCanvas, wxWindow) - EVT_SIZE(wxGLCanvas::OnSize) -END_EVENT_TABLE() - -wxGLCanvas::wxGLCanvas( wxWindow *parent, wxWindowID id, - const wxPoint& pos, const wxSize& size, - long style, const wxString& name, - int *attribList, - const wxPalette& palette ) -{ - Create( parent, NULL, NULL, id, pos, size, style, name, attribList, palette ); -} - -wxGLCanvas::wxGLCanvas( wxWindow *parent, - const wxGLContext *shared, - wxWindowID id, - const wxPoint& pos, const wxSize& size, - long style, const wxString& name, - int *attribList, - const wxPalette& palette ) -{ - Create( parent, shared, NULL, id, pos, size, style, name, attribList, palette ); -} - -wxGLCanvas::wxGLCanvas( wxWindow *parent, - const wxGLCanvas *shared, - wxWindowID id, - const wxPoint& pos, const wxSize& size, - long style, const wxString& name, - int *attribList, - const wxPalette& palette ) -{ - Create( parent, NULL, shared, id, pos, size, style, name, attribList, palette ); -} - -bool wxGLCanvas::Create( wxWindow *parent, - const wxGLContext *shared, - const wxGLCanvas *shared_context_of, - wxWindowID id, - const wxPoint& pos, const wxSize& size, - long style, const wxString& name, - int *attribList, - const wxPalette& palette) -{ - m_sharedContext = (wxGLContext*)shared; // const_cast - m_sharedContextOf = (wxGLCanvas*)shared_context_of; // const_cast - m_glContext = (wxGLContext*) NULL; - - m_exposed = FALSE; - m_noExpose = TRUE; - m_nativeSizeEvent = TRUE; - - XVisualInfo *vi = NULL; - if (wxTheApp->m_glVisualInfo != NULL) - { - vi = (XVisualInfo *) wxTheApp->m_glVisualInfo; - m_canFreeVi = FALSE; // owned by wxTheApp - don't free upon destruction - } - else - { - vi = (XVisualInfo *) ChooseGLVisual(attribList); - m_canFreeVi = TRUE; - } - m_vi = vi; // save for later use - - wxCHECK_MSG( m_vi, FALSE, _T("required visual couldn't be found") ); - - GdkVisual *visual = gdkx_visual_get( vi->visualid ); - GdkColormap *colormap = gdk_colormap_new( gdkx_visual_get(vi->visualid), TRUE ); - - gtk_widget_push_colormap( colormap ); - gtk_widget_push_visual( visual ); - - wxWindow::Create( parent, id, pos, size, style, name ); - - m_glWidget = m_wxwindow; - -#ifdef __WXGTK20__ - gtk_widget_set_double_buffered( m_glWidget, FALSE ); -#endif - - gtk_pizza_set_clear( GTK_PIZZA(m_wxwindow), FALSE ); - - gtk_signal_connect( GTK_OBJECT(m_wxwindow), "realize", - GTK_SIGNAL_FUNC(gtk_glwindow_realized_callback), (gpointer) this ); - - gtk_signal_connect( GTK_OBJECT(m_wxwindow), "map", - GTK_SIGNAL_FUNC(gtk_glwindow_map_callback), (gpointer) this ); - - gtk_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event", - GTK_SIGNAL_FUNC(gtk_glwindow_expose_callback), (gpointer)this ); - -#ifndef __WXGTK20__ - gtk_signal_connect( GTK_OBJECT(m_wxwindow), "draw", - GTK_SIGNAL_FUNC(gtk_glwindow_draw_callback), (gpointer)this ); -#endif - - gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", - GTK_SIGNAL_FUNC(gtk_glcanvas_size_callback), (gpointer)this ); - - gtk_widget_pop_visual(); - gtk_widget_pop_colormap(); - - if (GTK_WIDGET_REALIZED(m_wxwindow)) - gtk_glwindow_realized_callback( m_wxwindow, this ); - - if (GTK_WIDGET_MAPPED(m_wxwindow)) - gtk_glwindow_map_callback( m_wxwindow, this ); - - return TRUE; -} - -wxGLCanvas::~wxGLCanvas() -{ - XVisualInfo *vi = (XVisualInfo *) m_vi; - - if (vi && m_canFreeVi) XFree( vi ); - if (m_glContext) delete m_glContext; -} - -void* wxGLCanvas::ChooseGLVisual(int *attribList) -{ - int data[512]; - if (!attribList) - { - // default settings if attriblist = 0 - data[0] = GLX_RGBA; - data[1] = GLX_DOUBLEBUFFER; - data[2] = GLX_DEPTH_SIZE; data[3] = 1; - data[4] = GLX_RED_SIZE; data[5] = 1; - data[6] = GLX_GREEN_SIZE; data[7] = 1; - data[8] = GLX_BLUE_SIZE; data[9] = 1; - data[10] = GLX_ALPHA_SIZE; data[11] = 0; - data[12] = None; - - attribList = (int*) data; - } - else - { - int arg=0, p=0; - - while( (attribList[arg]!=0) && (p<510) ) - { - switch( attribList[arg++] ) - { - case WX_GL_RGBA: data[p++] = GLX_RGBA; break; - case WX_GL_BUFFER_SIZE: - data[p++]=GLX_BUFFER_SIZE; data[p++]=attribList[arg++]; break; - case WX_GL_LEVEL: - data[p++]=GLX_LEVEL; data[p++]=attribList[arg++]; break; - case WX_GL_DOUBLEBUFFER: data[p++] = GLX_DOUBLEBUFFER; break; - case WX_GL_STEREO: data[p++] = GLX_STEREO; break; - case WX_GL_AUX_BUFFERS: - data[p++]=GLX_AUX_BUFFERS; data[p++]=attribList[arg++]; break; - case WX_GL_MIN_RED: - data[p++]=GLX_RED_SIZE; data[p++]=attribList[arg++]; break; - case WX_GL_MIN_GREEN: - data[p++]=GLX_GREEN_SIZE; data[p++]=attribList[arg++]; break; - case WX_GL_MIN_BLUE: - data[p++]=GLX_BLUE_SIZE; data[p++]=attribList[arg++]; break; - case WX_GL_MIN_ALPHA: - data[p++]=GLX_ALPHA_SIZE; data[p++]=attribList[arg++]; break; - case WX_GL_DEPTH_SIZE: - data[p++]=GLX_DEPTH_SIZE; data[p++]=attribList[arg++]; break; - case WX_GL_STENCIL_SIZE: - data[p++]=GLX_STENCIL_SIZE; data[p++]=attribList[arg++]; break; - case WX_GL_MIN_ACCUM_RED: - data[p++]=GLX_ACCUM_RED_SIZE; data[p++]=attribList[arg++]; break; - case WX_GL_MIN_ACCUM_GREEN: - data[p++]=GLX_ACCUM_GREEN_SIZE; data[p++]=attribList[arg++]; break; - case WX_GL_MIN_ACCUM_BLUE: - data[p++]=GLX_ACCUM_BLUE_SIZE; data[p++]=attribList[arg++]; break; - case WX_GL_MIN_ACCUM_ALPHA: - data[p++]=GLX_ACCUM_ALPHA_SIZE; data[p++]=attribList[arg++]; break; - default: - break; - } - } - data[p] = 0; - - attribList = (int*) data; - } - - - Display *dpy = GDK_DISPLAY(); - - return glXChooseVisual( dpy, DefaultScreen(dpy), attribList ); -} - -void wxGLCanvas::SwapBuffers() -{ - if (m_glContext) - m_glContext->SwapBuffers(); -} - -void wxGLCanvas::OnSize(wxSizeEvent& WXUNUSED(event)) -{ -} - -void wxGLCanvas::SetCurrent() -{ - if (m_glContext) - m_glContext->SetCurrent(); -} - -void wxGLCanvas::SetColour( const wxChar *colour ) -{ - if (m_glContext) - m_glContext->SetColour( colour ); -} - -void wxGLCanvas::OnInternalIdle() -{ - if (m_glContext && m_exposed) - { - wxPaintEvent event( GetId() ); - event.SetEventObject( this ); - GetEventHandler()->ProcessEvent( event ); - - m_exposed = FALSE; - GetUpdateRegion().Clear(); - } - - wxWindow::OnInternalIdle(); -} - - - -//--------------------------------------------------------------------------- -// wxGLApp -//--------------------------------------------------------------------------- - -IMPLEMENT_CLASS(wxGLApp, wxApp) - -wxGLApp::~wxGLApp() -{ - if (m_glVisualInfo) - XFree(m_glVisualInfo); -} - -bool wxGLApp::InitGLVisual(int *attribList) -{ - if (m_glVisualInfo) - XFree(m_glVisualInfo); - - m_glVisualInfo = wxGLCanvas::ChooseGLVisual(attribList); - - return m_glVisualInfo != NULL; -} - -#endif - // wxUSE_GLCANVAS - diff --git a/src/gtk1/gsockgtk.c b/src/gtk1/gsockgtk.c deleted file mode 100644 index 17582c0f59..0000000000 --- a/src/gtk1/gsockgtk.c +++ /dev/null @@ -1,120 +0,0 @@ -/* ------------------------------------------------------------------------- - * Project: GSocket (Generic Socket) for WX - * Name: gsockgtk.c - * Copyright: (c) Guilhem Lavaux - * Licence: wxWindows Licence - * Purpose: GSocket: GTK part - * CVSID: $Id$ - * ------------------------------------------------------------------------- - */ -#include "wx/setup.h" - -#if wxUSE_SOCKETS - -#include -#include -#include - -#include -#include - -#include "wx/gsocket.h" -#include "wx/unix/gsockunx.h" - - -void _GSocket_GDK_Input(gpointer data, - gint source, - GdkInputCondition condition) -{ - GSocket *socket = (GSocket *)data; - - if (condition & GDK_INPUT_READ) - _GSocket_Detected_Read(socket); - if (condition & GDK_INPUT_WRITE) - _GSocket_Detected_Write(socket); -} - -int _GSocket_GUI_Init(GSocket *socket) -{ - gint *m_id; - - socket->m_gui_dependent = (char *)malloc(sizeof(gint)*2); - m_id = (gint *)(socket->m_gui_dependent); - - m_id[0] = -1; - m_id[1] = -1; - - return TRUE; -} - -void _GSocket_GUI_Destroy(GSocket *socket) -{ - free(socket->m_gui_dependent); -} - -void _GSocket_Install_Callback(GSocket *socket, GSocketEvent event) -{ - gint *m_id = (gint *)(socket->m_gui_dependent); - int c; - - if (socket->m_fd == -1) - return; - - switch (event) - { - case GSOCK_LOST: /* fall-through */ - case GSOCK_INPUT: c = 0; break; - case GSOCK_OUTPUT: c = 1; break; - case GSOCK_CONNECTION: c = ((socket->m_server) ? 0 : 1); break; - default: return; - } - - if (m_id[c] != -1) - gdk_input_remove(m_id[c]); - - m_id[c] = gdk_input_add(socket->m_fd, - (c ? GDK_INPUT_WRITE : GDK_INPUT_READ), - _GSocket_GDK_Input, - (gpointer)socket); -} - -void _GSocket_Uninstall_Callback(GSocket *socket, GSocketEvent event) -{ - gint *m_id = (gint *)(socket->m_gui_dependent); - int c; - - assert( m_id != NULL ); - - switch (event) - { - case GSOCK_LOST: /* fall-through */ - case GSOCK_INPUT: c = 0; break; - case GSOCK_OUTPUT: c = 1; break; - case GSOCK_CONNECTION: c = ((socket->m_server) ? 0 : 1); break; - default: return; - } - - if (m_id[c] != -1) - gdk_input_remove(m_id[c]); - - m_id[c] = -1; -} - -void _GSocket_Enable_Events(GSocket *socket) -{ - _GSocket_Install_Callback(socket, GSOCK_INPUT); - _GSocket_Install_Callback(socket, GSOCK_OUTPUT); -} - -void _GSocket_Disable_Events(GSocket *socket) -{ - _GSocket_Uninstall_Callback(socket, GSOCK_INPUT); - _GSocket_Uninstall_Callback(socket, GSOCK_OUTPUT); -} - -#else /* !wxUSE_SOCKETS */ - -/* some compilers don't like having empty source files */ -static int wxDummyGsockVar = 0; - -#endif /* wxUSE_SOCKETS/!wxUSE_SOCKETS */ diff --git a/src/gtk1/horiz.xbm b/src/gtk1/horiz.xbm deleted file mode 100644 index ff3309bcc4..0000000000 --- a/src/gtk1/horiz.xbm +++ /dev/null @@ -1,6 +0,0 @@ -#define horiz_width 15 -#define horiz_height 15 -static char horiz_bits[] = { - 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00}; diff --git a/src/gtk1/icon.cpp b/src/gtk1/icon.cpp deleted file mode 100644 index 02c76de99c..0000000000 --- a/src/gtk1/icon.cpp +++ /dev/null @@ -1,48 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: icon.cpp -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/icon.h" - -//----------------------------------------------------------------------------- -// wxIcon -//----------------------------------------------------------------------------- - -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 ) -{ -} - -wxIcon::wxIcon() : wxBitmap() -{ -} - -wxIcon::wxIcon( const wxIcon& icon ) : wxBitmap() -{ - Ref(icon); -} - -wxIcon& wxIcon::operator = ( const wxIcon& icon ) -{ - if (*this == icon) return (*this); - Ref(icon); - return *this; -} - -void wxIcon::CopyFromBitmap(const wxBitmap& bmp) -{ - wxIcon *icon = (wxIcon*)(&bmp); - *this = *icon; -} diff --git a/src/gtk1/joystick.cpp b/src/gtk1/joystick.cpp deleted file mode 100644 index c223288254..0000000000 --- a/src/gtk1/joystick.cpp +++ /dev/null @@ -1,364 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: joystick.cpp -// Purpose: wxJoystick class -// Author: Ported to Linux by Guilhem Lavaux -// Modified by: -// Created: 05/23/98 -// RCS-ID: $Id$ -// Copyright: (c) Guilhem Lavaux -// Licence: wxWindows license -///////////////////////////////////////////////////////////////////////////// - -#include "wx/defs.h" - -#if wxUSE_JOYSTICK - -#include "wx/joystick.h" - -#include -#include -#include -#include -#include -#include -#include - -#include "wx/event.h" -#include "wx/window.h" - -#define JOYSTICK_AXE_MAX 32767 -#define JOYSTICK_AXE_MIN -32767 - -IMPLEMENT_DYNAMIC_CLASS(wxJoystick, wxObject) - -wxJoystick::wxJoystick(int joystick) -{ - wxString dev_name; - // Assume it's the same device name on all Linux systems ... - dev_name.Printf( wxT("/dev/js%d"), (joystick == wxJOYSTICK1) ? 0 : 1); // FIXME Unicode? - - m_joystick = open(dev_name.fn_str(), O_RDWR); - m_lastposition = wxPoint(-1, -1); - for (int i=0;i<15;i++) - m_axe[i] = 0; - if (m_joystick != -1) - Create(); -} - -//////////////////////////////////////////////////////////////////////////// -// Background thread -//////////////////////////////////////////////////////////////////////////// -void *wxJoystick::Entry(void) -{ - struct js_event j_evt; - wxJoystickEvent jwx_event; - fd_set read_fds; - struct timeval time_out = {0, 0}; - - FD_ZERO(&read_fds); - while (1) { - TestDestroy(); - - if (m_polling) { - FD_SET(m_joystick, &read_fds); - select(m_joystick+1, &read_fds, NULL, NULL, &time_out); - if (FD_ISSET(m_joystick, &read_fds)) - read(m_joystick, &j_evt, sizeof(j_evt)); - else - j_evt.type = 0; - } else { - read(m_joystick, &j_evt, sizeof(j_evt)); - } - - if ((j_evt.type & JS_EVENT_AXIS) == JS_EVENT_AXIS) { - switch (j_evt.number) { - case 1: - m_lastposition.x = j_evt.value; - jwx_event.SetEventType(wxEVT_JOY_MOVE); - break; - case 2: - m_lastposition.y = j_evt.value; - jwx_event.SetEventType(wxEVT_JOY_MOVE); - break; - case 3: - m_axe[3] = j_evt.value; - jwx_event.SetEventType(wxEVT_JOY_ZMOVE); - break; - default: - m_axe[j_evt.number] = j_evt.value; - jwx_event.SetEventType(wxEVT_JOY_MOVE); - break; - } - jwx_event.SetPosition(m_lastposition); - jwx_event.SetZPosition(m_axe[3]); - } - if ((j_evt.type & JS_EVENT_BUTTON) == JS_EVENT_BUTTON) { - register int mask = 1 << j_evt.number; - char button = m_buttons & mask; - - m_buttons &= ~mask; - if (button) { - jwx_event.SetEventType(wxEVT_JOY_BUTTON_UP); - } else { - jwx_event.SetEventType(wxEVT_JOY_BUTTON_DOWN); - m_buttons |= mask; - } - - jwx_event.SetButtonState(m_buttons); - jwx_event.SetButtonChange(j_evt.number); - } - } - if (m_catchwin) - m_catchwin->ProcessEvent(jwx_event); - if (m_polling) - usleep(m_polling*1000); -} - -//////////////////////////////////////////////////////////////////////////// -// State -//////////////////////////////////////////////////////////////////////////// - -wxPoint wxJoystick::GetPosition(void) const -{ - return m_lastposition; -} - -int wxJoystick::GetZPosition(void) const -{ - return m_axe[3]; -} - -int wxJoystick::GetButtonState(void) const -{ - return m_buttons; -} - -int wxJoystick::GetPOVPosition(void) const -{ - return -1; -} - -int wxJoystick::GetPOVCTSPosition(void) const -{ - return -1; -} - -int wxJoystick::GetRudderPosition(void) const -{ - return m_axe[4]; -} - -int wxJoystick::GetUPosition(void) const -{ - return m_axe[5]; -} - -int wxJoystick::GetVPosition(void) const -{ - return m_axe[6]; -} - -int wxJoystick::GetMovementThreshold(void) const -{ - return 0; -} - -void wxJoystick::SetMovementThreshold(int threshold) -{ -} - -//////////////////////////////////////////////////////////////////////////// -// Capabilities -//////////////////////////////////////////////////////////////////////////// - -bool wxJoystick::IsOk(void) const -{ - return (m_joystick != -1); -} - -int wxJoystick::GetNumberJoysticks(void) const -{ - wxString dev_name; - int fd, j; - - for (j=0;j<2;j++) { - dev_name.Printf(wxT("/dev/js%d"), j); - fd = open(dev_name.fn_str(), O_RDONLY); - if (fd == -1) - return j; - close(fd); - } - return j; -} - -int wxJoystick::GetManufacturerId(void) const -{ - return 0; -} - -int wxJoystick::GetProductId(void) const -{ - return 0; -} - -wxString wxJoystick::GetProductName(void) const -{ - wxString dev_name; - // 2002-08-20 johan@linkdata.se - // Return the device name in lieu of a better one - dev_name.Printf( wxT("/dev/js%d"), (m_joystick == wxJOYSTICK1) ? 0 : 1); // FIXME Unicode? - return dev_name; -} - -int wxJoystick::GetXMin(void) const -{ - return JOYSTICK_AXE_MAX; -} - -int wxJoystick::GetYMin(void) const -{ - return JOYSTICK_AXE_MAX; -} - -int wxJoystick::GetZMin(void) const -{ - return JOYSTICK_AXE_MAX; -} - -int wxJoystick::GetXMax(void) const -{ - return JOYSTICK_AXE_MAX; -} - -int wxJoystick::GetYMax(void) const -{ - return JOYSTICK_AXE_MAX; -} - -int wxJoystick::GetZMax(void) const -{ - return JOYSTICK_AXE_MAX; -} - -int wxJoystick::GetNumberButtons(void) const -{ - int nb; - - ioctl(m_joystick, JSIOCGBUTTONS, &nb); - - return nb; -} - -int wxJoystick::GetNumberAxes(void) const -{ - int nb; - - ioctl(m_joystick, JSIOCGAXES, &nb); - - return nb; -} - -int wxJoystick::GetMaxButtons(void) const -{ - return 15; // internal -} - -int wxJoystick::GetMaxAxes(void) const -{ - return 15; // internal -} - -int wxJoystick::GetPollingMin(void) const -{ - return -1; -} - -int wxJoystick::GetPollingMax(void) const -{ - return -1; -} - -int wxJoystick::GetRudderMin(void) const -{ - return JOYSTICK_AXE_MIN; -} - -int wxJoystick::GetRudderMax(void) const -{ - return JOYSTICK_AXE_MAX; -} - -int wxJoystick::GetUMin(void) const -{ - return JOYSTICK_AXE_MIN; -} - -int wxJoystick::GetUMax(void) const -{ - return JOYSTICK_AXE_MAX; -} - -int wxJoystick::GetVMin(void) const -{ - return JOYSTICK_AXE_MIN; -} - -int wxJoystick::GetVMax(void) const -{ - return JOYSTICK_AXE_MAX; -} - -bool wxJoystick::HasRudder(void) const -{ - return GetNumberAxes() >= 4; -} - -bool wxJoystick::HasZ(void) const -{ - return GetNumberAxes() >= 3; -} - -bool wxJoystick::HasU(void) const -{ - return GetNumberAxes() >= 5; -} - -bool wxJoystick::HasV(void) const -{ - return GetNumberAxes() >= 6; -} - -bool wxJoystick::HasPOV(void) const -{ - return FALSE; -} - -bool wxJoystick::HasPOV4Dir(void) const -{ - return FALSE; -} - -bool wxJoystick::HasPOVCTS(void) const -{ - return FALSE; -} - -//////////////////////////////////////////////////////////////////////////// -// Operations -//////////////////////////////////////////////////////////////////////////// - -bool wxJoystick::SetCapture(wxWindow* win, int pollingFreq) -{ - m_catchwin = win; - m_polling = pollingFreq; - return TRUE; -} - -bool wxJoystick::ReleaseCapture(void) -{ - m_catchwin = NULL; - m_polling = 0; - return TRUE; -} -#endif // wxUSE_JOYSTICK - diff --git a/src/gtk1/listbox.cpp b/src/gtk1/listbox.cpp deleted file mode 100644 index dd5155161e..0000000000 --- a/src/gtk1/listbox.cpp +++ /dev/null @@ -1,1076 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: listbox.cpp -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/listbox.h" - -#if wxUSE_LISTBOX - -#include "wx/dynarray.h" -#include "wx/utils.h" -#include "wx/intl.h" -#include "wx/checklst.h" -#include "wx/settings.h" -#include "wx/gtk/private.h" - -#if wxUSE_TOOLTIPS -#include "wx/tooltip.h" -#endif - -#include -#include -#include - -//----------------------------------------------------------------------------- -// idle system -//----------------------------------------------------------------------------- - -extern void wxapp_install_idle_handler(); -extern bool g_isIdle; - -//----------------------------------------------------------------------------- -// data -//----------------------------------------------------------------------------- - -extern bool g_blockEventsOnDrag; -extern bool g_blockEventsOnScroll; -extern wxCursor g_globalCursor; -extern wxWindowGTK *g_delayedFocus; - -static bool g_hasDoubleClicked = FALSE; - -//----------------------------------------------------------------------------- -// idle callback for SetFirstItem -//----------------------------------------------------------------------------- - -struct wxlistbox_idle_struct -{ - wxListBox *m_listbox; - int m_item; - gint m_tag; -}; - -extern "C" gint wxlistbox_idle_callback( gpointer gdata ) -{ - wxlistbox_idle_struct* data = (wxlistbox_idle_struct*) gdata; - gdk_threads_enter(); - - gtk_idle_remove( data->m_tag ); - - // check that the items haven't been deleted from the listbox since we had - // installed this callback - wxListBox *lbox = data->m_listbox; - if ( data->m_item < lbox->GetCount() ) - { - lbox->SetFirstItem( data->m_item ); - } - - delete data; - - gdk_threads_leave(); - - return TRUE; -} - -//----------------------------------------------------------------------------- -// "button_release_event" -//----------------------------------------------------------------------------- - -/* we would normally emit a wxEVT_COMMAND_LISTBOX_DOUBLECLICKED event once - a GDK_2BUTTON_PRESS occurs, but this has the particular problem of the - listbox keeping the focus until it receives a GDK_BUTTON_RELEASE event. - this can lead to race conditions so that we emit the dclick event - after the GDK_BUTTON_RELEASE event after the GDK_2BUTTON_PRESS event */ - -static gint -gtk_listbox_button_release_callback( GtkWidget * WXUNUSED(widget), - GdkEventButton * WXUNUSED(gdk_event), - wxListBox *listbox ) -{ - if (g_isIdle) wxapp_install_idle_handler(); - - if (g_blockEventsOnDrag) return FALSE; - if (g_blockEventsOnScroll) return FALSE; - - if (!listbox->m_hasVMT) return FALSE; - - if (!g_hasDoubleClicked) return FALSE; - - wxCommandEvent event( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, listbox->GetId() ); - event.SetEventObject( listbox ); - - wxArrayInt aSelections; - int n, count = listbox->GetSelections(aSelections); - if ( count > 0 ) - { - n = aSelections[0]; - if ( listbox->HasClientObjectData() ) - event.SetClientObject( listbox->GetClientObject(n) ); - else if ( listbox->HasClientUntypedData() ) - event.SetClientData( listbox->GetClientData(n) ); - event.SetString( listbox->GetString(n) ); - } - else - { - n = -1; - } - - event.m_commandInt = n; - - listbox->GetEventHandler()->ProcessEvent( event ); - - return FALSE; -} - -//----------------------------------------------------------------------------- -// "button_press_event" -//----------------------------------------------------------------------------- - -static gint -gtk_listbox_button_press_callback( GtkWidget *widget, - GdkEventButton *gdk_event, - wxListBox *listbox ) -{ - if (g_isIdle) wxapp_install_idle_handler(); - - if (g_blockEventsOnDrag) return FALSE; - if (g_blockEventsOnScroll) return FALSE; - - if (!listbox->m_hasVMT) return FALSE; - - int sel = listbox->GtkGetIndex( widget ); - -#if wxUSE_CHECKLISTBOX - if ((listbox->m_hasCheckBoxes) && (gdk_event->x < 15) && (gdk_event->type != GDK_2BUTTON_PRESS)) - { - wxCheckListBox *clb = (wxCheckListBox *)listbox; - - clb->Check( sel, !clb->IsChecked(sel) ); - - wxCommandEvent event( wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, listbox->GetId() ); - event.SetEventObject( listbox ); - event.SetInt( sel ); - listbox->GetEventHandler()->ProcessEvent( event ); - } -#endif // wxUSE_CHECKLISTBOX - - /* emit wxEVT_COMMAND_LISTBOX_DOUBLECLICKED later */ - g_hasDoubleClicked = (gdk_event->type == GDK_2BUTTON_PRESS); - - return FALSE; -} - -//----------------------------------------------------------------------------- -// "key_press_event" -//----------------------------------------------------------------------------- - -static gint -gtk_listbox_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxListBox *listbox ) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - - if (g_blockEventsOnDrag) - return FALSE; - - bool ret = FALSE; - - if ((gdk_event->keyval == GDK_Tab) || (gdk_event->keyval == GDK_ISO_Left_Tab)) - { - wxNavigationKeyEvent new_event; - /* GDK reports GDK_ISO_Left_Tab for SHIFT-TAB */ - new_event.SetDirection( (gdk_event->keyval == GDK_Tab) ); - /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */ - new_event.SetWindowChange( (gdk_event->state & GDK_CONTROL_MASK) ); - new_event.SetCurrentFocus( listbox ); - ret = listbox->GetEventHandler()->ProcessEvent( new_event ); - } - - if ((gdk_event->keyval == GDK_Return) && (!ret)) - { - // eat return in all modes - ret = TRUE; - } - -#if wxUSE_CHECKLISTBOX - if ((gdk_event->keyval == ' ') && (listbox->m_hasCheckBoxes) && (!ret)) - { - int sel = listbox->GtkGetIndex( widget ); - - wxCheckListBox *clb = (wxCheckListBox *)listbox; - - clb->Check( sel, !clb->IsChecked(sel) ); - - wxCommandEvent new_event( wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, listbox->GetId() ); - new_event.SetEventObject( listbox ); - new_event.SetInt( sel ); - ret = listbox->GetEventHandler()->ProcessEvent( new_event ); - } -#endif // wxUSE_CHECKLISTBOX - - if (ret) - { - gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" ); - return TRUE; - } - - return FALSE; -} - -//----------------------------------------------------------------------------- -// "select" and "deselect" -//----------------------------------------------------------------------------- - -static void gtk_listitem_select_cb( GtkWidget *widget, wxListBox *listbox, bool is_selection ); - -static void gtk_listitem_select_callback( GtkWidget *widget, wxListBox *listbox ) -{ - gtk_listitem_select_cb( widget, listbox, TRUE ); -} - -static void gtk_listitem_deselect_callback( GtkWidget *widget, wxListBox *listbox ) -{ - gtk_listitem_select_cb( widget, listbox, FALSE ); -} - -static void gtk_listitem_select_cb( GtkWidget *widget, wxListBox *listbox, bool is_selection ) -{ - if (g_isIdle) wxapp_install_idle_handler(); - - if (!listbox->m_hasVMT) return; - if (g_blockEventsOnDrag) return; - - if (listbox->m_blockEvent) return; - - wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, listbox->GetId() ); - event.SetEventObject( listbox ); - -// MSW doesn't do that either -// event.SetExtraLong( (long) is_selection ); - - - if ((listbox->GetWindowStyleFlag() & wxLB_SINGLE) != 0) - { - int sel = listbox->GtkGetIndex( widget ); - - if (listbox->m_prevSelection != sel) - gtk_list_unselect_item( listbox->m_list, listbox->m_prevSelection ); - - listbox->m_prevSelection = sel; - } - - wxArrayInt aSelections; - int n, count = listbox->GetSelections(aSelections); - if ( count > 0 ) - { - n = aSelections[0]; - if ( listbox->HasClientObjectData() ) - event.SetClientObject( listbox->GetClientObject(n) ); - else if ( listbox->HasClientUntypedData() ) - event.SetClientData( listbox->GetClientData(n) ); - event.SetString( listbox->GetString(n) ); - } - else - { - n = -1; - } - - event.m_commandInt = n; - -// No longer required with new code in wxLB_SINGLE -// listbox->GetEventHandler()->AddPendingEvent( event ); - listbox->GetEventHandler()->ProcessEvent( event ); -} - -//----------------------------------------------------------------------------- -// wxListBox -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxListBox,wxControl) - -// ---------------------------------------------------------------------------- -// construction -// ---------------------------------------------------------------------------- - -wxListBox::wxListBox() -{ - m_list = (GtkList *) NULL; -#if wxUSE_CHECKLISTBOX - m_hasCheckBoxes = FALSE; -#endif // wxUSE_CHECKLISTBOX -} - -bool wxListBox::Create( wxWindow *parent, wxWindowID id, - const wxPoint &pos, const wxSize &size, - int n, const wxString choices[], - long style, const wxValidator& validator, - const wxString &name ) -{ - m_needParent = TRUE; - m_acceptsFocus = TRUE; - m_prevSelection = 0; // or -1 ?? - m_blockEvent = FALSE; - - if (!PreCreation( parent, pos, size ) || - !CreateBase( parent, id, pos, size, style, validator, name )) - { - wxFAIL_MSG( wxT("wxListBox creation failed") ); - return FALSE; - } - - m_widget = gtk_scrolled_window_new( (GtkAdjustment*) NULL, (GtkAdjustment*) NULL ); - 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() ); - - GtkSelectionMode mode; - if (style & wxLB_MULTIPLE) - { - mode = GTK_SELECTION_MULTIPLE; - } - else if (style & wxLB_EXTENDED) - { - mode = GTK_SELECTION_EXTENDED; - } - else - { - // if style was 0 set single mode - m_windowStyle |= wxLB_SINGLE; - mode = GTK_SELECTION_MULTIPLE; - } - - gtk_list_set_selection_mode( GTK_LIST(m_list), mode ); - - gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW(m_widget), GTK_WIDGET(m_list) ); - - /* make list scroll when moving the focus down using cursor keys */ - gtk_container_set_focus_vadjustment( - GTK_CONTAINER(m_list), - gtk_scrolled_window_get_vadjustment( - GTK_SCROLLED_WINDOW(m_widget))); - - gtk_widget_show( GTK_WIDGET(m_list) ); - - if ( style & wxLB_SORT ) - { - // this will change DoAppend() behaviour - m_strings = new wxSortedArrayString; - } - else - { - m_strings = (wxSortedArrayString *)NULL; - } - - for (int i = 0; i < n; i++) - { - // add one by one - DoAppend(choices[i]); - } - - // call it after appending the strings to the listbox, otherwise it doesn't - // work correctly - SetBestSize( size ); - - m_parent->DoAddChild( this ); - - PostCreation(); - - SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOX ) ); - SetForegroundColour( parent->GetForegroundColour() ); - SetFont( parent->GetFont() ); - - Show( TRUE ); - - return TRUE; -} - -wxListBox::~wxListBox() -{ - m_hasVMT = FALSE; - - Clear(); - - if (m_strings) - delete m_strings; -} - -// ---------------------------------------------------------------------------- -// adding items -// ---------------------------------------------------------------------------- - -void wxListBox::DoInsertItems(const wxArrayString& items, int pos) -{ - wxCHECK_RET( m_list != NULL, wxT("invalid listbox") ); - - // VZ: notice that InsertItems knows nothing about sorting, so calling it - // from outside (and not from our own Append) is likely to break - // everything - - // code elsewhere supposes we have as many items in m_clientList as items - // in the listbox - wxASSERT_MSG( m_clientList.GetCount() == (size_t)GetCount(), - wxT("bug in client data management") ); - - GList *children = m_list->children; - int length = g_list_length(children); - - wxCHECK_RET( pos <= length, wxT("invalid index in wxListBox::InsertItems") ); - - size_t nItems = items.GetCount(); - int index; - - if (m_strings) - { - for (size_t n = 0; n < nItems; n++) - { - index = m_strings->Add( items[n] ); - - if (index != GetCount()) - { - GtkAddItem( items[n], index ); - wxNode *node = m_clientList.Nth( index ); - m_clientList.Insert( node, (wxObject*) NULL ); - } - else - { - GtkAddItem( items[n] ); - m_clientList.Append( (wxObject*) NULL ); - } - } - } - else - { - if (pos == length) - { - for ( size_t n = 0; n < nItems; n++ ) - { - GtkAddItem( items[n] ); - - m_clientList.Append((wxObject *)NULL); - } - } - else - { - wxNode *node = m_clientList.Nth( pos ); - for ( size_t n = 0; n < nItems; n++ ) - { - GtkAddItem( items[n], pos+n ); - - m_clientList.Insert( node, (wxObject *)NULL ); - } - } - } - - wxASSERT_MSG( m_clientList.GetCount() == (size_t)GetCount(), - wxT("bug in client data management") ); -} - -int wxListBox::DoAppend( const wxString& item ) -{ - if (m_strings) - { - // need to determine the index - int index = m_strings->Add( item ); - - // only if not at the end anyway - if (index != GetCount()) - { - GtkAddItem( item, index ); - - wxNode *node = m_clientList.Nth( index ); - m_clientList.Insert( node, (wxObject *)NULL ); - - return index; - } - } - - GtkAddItem(item); - - m_clientList.Append((wxObject *)NULL); - - return GetCount() - 1; -} - -void wxListBox::GtkAddItem( const wxString &item, int pos ) -{ - wxCHECK_RET( m_list != NULL, wxT("invalid listbox") ); - - GtkWidget *list_item; - - wxString label(item); -#if wxUSE_CHECKLISTBOX - if (m_hasCheckBoxes) - { - label.Prepend(wxCHECKLBOX_STRING); - } -#endif // wxUSE_CHECKLISTBOX - - list_item = gtk_list_item_new_with_label( wxGTK_CONV( label ) ); - - GList *gitem_list = g_list_alloc (); - gitem_list->data = list_item; - - if (pos == -1) - gtk_list_append_items( GTK_LIST (m_list), gitem_list ); - else - gtk_list_insert_items( GTK_LIST (m_list), gitem_list, pos ); - - gtk_signal_connect( GTK_OBJECT(list_item), "select", - GTK_SIGNAL_FUNC(gtk_listitem_select_callback), (gpointer)this ); - - if (HasFlag(wxLB_MULTIPLE) || HasFlag(wxLB_EXTENDED)) - gtk_signal_connect( GTK_OBJECT(list_item), "deselect", - GTK_SIGNAL_FUNC(gtk_listitem_deselect_callback), (gpointer)this ); - - gtk_signal_connect( GTK_OBJECT(list_item), - "button_press_event", - (GtkSignalFunc)gtk_listbox_button_press_callback, - (gpointer) this ); - - gtk_signal_connect_after( GTK_OBJECT(list_item), - "button_release_event", - (GtkSignalFunc)gtk_listbox_button_release_callback, - (gpointer) this ); - - gtk_signal_connect( GTK_OBJECT(list_item), - "key_press_event", - (GtkSignalFunc)gtk_listbox_key_press_callback, - (gpointer)this ); - - ConnectWidget( list_item ); - - gtk_widget_show( list_item ); - - if (GTK_WIDGET_REALIZED(m_widget)) - { - gtk_widget_realize( list_item ); - gtk_widget_realize( GTK_BIN(list_item)->child ); - - // Apply current widget style to the new list_item - if (m_widgetStyle) - { - gtk_widget_set_style( GTK_WIDGET( list_item ), m_widgetStyle ); - GtkBin *bin = GTK_BIN( list_item ); - GtkWidget *label = GTK_WIDGET( bin->child ); - gtk_widget_set_style( label, m_widgetStyle ); - } - -#if wxUSE_TOOLTIPS - if (m_tooltip) m_tooltip->Apply( this ); -#endif - } -} - -void wxListBox::DoSetItems( const wxArrayString& items, - void **clientData) -{ - Clear(); - - DoInsertItems(items, 0); - - if ( clientData ) - { - size_t count = items.GetCount(); - for ( size_t n = 0; n < count; n++ ) - { - SetClientData(n, clientData[n]); - } - } -} - -// ---------------------------------------------------------------------------- -// deleting items -// ---------------------------------------------------------------------------- - -void wxListBox::Clear() -{ - wxCHECK_RET( m_list != NULL, wxT("invalid listbox") ); - - gtk_list_clear_items( m_list, 0, GetCount() ); - - if ( GTK_LIST(m_list)->last_focus_child != NULL ) - { - // This should be NULL, I think. - GTK_LIST(m_list)->last_focus_child = NULL; - } - - if ( HasClientObjectData() ) - { - // destroy the data (due to Robert's idea of using wxList - // and not wxList we can't just say - // m_clientList.DeleteContents(TRUE) - this would crash! - wxNode *node = m_clientList.First(); - while ( node ) - { - delete (wxClientData *)node->Data(); - node = node->Next(); - } - } - m_clientList.Clear(); - - if ( m_strings ) - m_strings->Clear(); -} - -void wxListBox::Delete( int n ) -{ - wxCHECK_RET( m_list != NULL, wxT("invalid listbox") ); - - GList *child = g_list_nth( m_list->children, n ); - - wxCHECK_RET( child, wxT("wrong listbox index") ); - - GList *list = g_list_append( (GList*) NULL, child->data ); - gtk_list_remove_items( m_list, list ); - g_list_free( list ); - - wxNode *node = m_clientList.Nth( n ); - if ( node ) - { - if ( m_clientDataItemsType == wxClientData_Object ) - { - wxClientData *cd = (wxClientData*)node->Data(); - delete cd; - } - - m_clientList.DeleteNode( node ); - } - - if ( m_strings ) - m_strings->Remove(n); -} - -// ---------------------------------------------------------------------------- -// client data -// ---------------------------------------------------------------------------- - -void wxListBox::DoSetItemClientData( int n, void* clientData ) -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid listbox control") ); - - wxNode *node = m_clientList.Nth( n ); - wxCHECK_RET( node, wxT("invalid index in wxListBox::DoSetItemClientData") ); - - node->SetData( (wxObject*) clientData ); -} - -void* wxListBox::DoGetItemClientData( int n ) const -{ - wxCHECK_MSG( m_widget != NULL, NULL, wxT("invalid listbox control") ); - - wxNode *node = m_clientList.Nth( n ); - wxCHECK_MSG( node, NULL, wxT("invalid index in wxListBox::DoGetItemClientData") ); - - return node->Data(); -} - -void wxListBox::DoSetItemClientObject( int n, wxClientData* clientData ) -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid listbox control") ); - - wxNode *node = m_clientList.Nth( n ); - wxCHECK_RET( node, wxT("invalid index in wxListBox::DoSetItemClientObject") ); - - // wxItemContainer already deletes data for us - - node->SetData( (wxObject*) clientData ); -} - -wxClientData* wxListBox::DoGetItemClientObject( int n ) const -{ - wxCHECK_MSG( m_widget != NULL, (wxClientData*) NULL, wxT("invalid listbox control") ); - - wxNode *node = m_clientList.Nth( n ); - wxCHECK_MSG( node, (wxClientData *)NULL, - wxT("invalid index in wxListBox::DoGetItemClientObject") ); - - return (wxClientData*) node->Data(); -} - -// ---------------------------------------------------------------------------- -// string list access -// ---------------------------------------------------------------------------- - -wxString wxListBox::GetRealLabel(GList *item) const -{ - GtkBin *bin = GTK_BIN( item->data ); - GtkLabel *label = GTK_LABEL( bin->child ); - - wxString str; - -#ifdef __WXGTK20__ - str = wxGTK_CONV_BACK( gtk_label_get_text( label ) ); -#else - str = wxString( label->label ); -#endif - -#if wxUSE_CHECKLISTBOX - // checklistboxes have "[±] " prepended to their lables, remove it - // - // NB: 4 below is the length of wxCHECKLBOX_STRING from wx/gtk/checklst.h - if ( m_hasCheckBoxes ) - str.erase(0, 4); -#endif // wxUSE_CHECKLISTBOX - - return str; -} - -void wxListBox::SetString( int n, const wxString &string ) -{ - wxCHECK_RET( m_list != NULL, wxT("invalid listbox") ); - - GList *child = g_list_nth( m_list->children, n ); - if (child) - { - GtkBin *bin = GTK_BIN( child->data ); - GtkLabel *label = GTK_LABEL( bin->child ); - - wxString str; -#if wxUSE_CHECKLISTBOX - if (m_hasCheckBoxes) - str += wxCHECKLBOX_STRING; -#endif // wxUSE_CHECKLISTBOX - str += string; - - gtk_label_set( label, wxGTK_CONV( str ) ); - } - else - { - wxFAIL_MSG(wxT("wrong listbox index")); - } -} - -wxString wxListBox::GetString( int n ) const -{ - wxCHECK_MSG( m_list != NULL, wxT(""), wxT("invalid listbox") ); - - GList *child = g_list_nth( m_list->children, n ); - if (child) - { - return GetRealLabel(child); - } - - wxFAIL_MSG(wxT("wrong listbox index")); - - return wxT(""); -} - -int wxListBox::GetCount() const -{ - wxCHECK_MSG( m_list != NULL, -1, wxT("invalid listbox") ); - - GList *children = m_list->children; - return g_list_length(children); -} - -int wxListBox::FindString( const wxString &item ) const -{ - wxCHECK_MSG( m_list != NULL, -1, wxT("invalid listbox") ); - - GList *child = m_list->children; - int count = 0; - while (child) - { - if ( GetRealLabel(child) == item ) - return count; - - count++; - child = child->next; - } - - // it's not an error if the string is not found -> no wxCHECK - - return wxNOT_FOUND; -} - -// ---------------------------------------------------------------------------- -// selection -// ---------------------------------------------------------------------------- - -int wxListBox::GetSelection() const -{ - wxCHECK_MSG( m_list != NULL, -1, wxT("invalid listbox") ); - - GList *child = m_list->children; - int count = 0; - while (child) - { - if (GTK_WIDGET(child->data)->state == GTK_STATE_SELECTED) return count; - count++; - child = child->next; - } - return -1; -} - -int wxListBox::GetSelections( wxArrayInt& aSelections ) const -{ - wxCHECK_MSG( m_list != NULL, -1, wxT("invalid listbox") ); - - // get the number of selected items first - GList *child = m_list->children; - int count = 0; - for (child = m_list->children; child != NULL; child = child->next) - { - if (GTK_WIDGET(child->data)->state == GTK_STATE_SELECTED) - count++; - } - - aSelections.Empty(); - - if (count > 0) - { - // now fill the list - aSelections.Alloc(count); // optimization attempt - int i = 0; - for (child = m_list->children; child != NULL; child = child->next, i++) - { - if (GTK_WIDGET(child->data)->state == GTK_STATE_SELECTED) - aSelections.Add(i); - } - } - - return count; -} - -bool wxListBox::IsSelected( int n ) const -{ - wxCHECK_MSG( m_list != NULL, FALSE, wxT("invalid listbox") ); - - GList *target = g_list_nth( m_list->children, n ); - - wxCHECK_MSG( target, FALSE, wxT("invalid listbox index") ); - - return (GTK_WIDGET(target->data)->state == GTK_STATE_SELECTED) ; -} - -void wxListBox::SetSelection( int n, bool select ) -{ - wxCHECK_RET( m_list != NULL, wxT("invalid listbox") ); - - m_blockEvent = TRUE; - - if (select) - { - if ((m_windowStyle & wxLB_SINGLE) != 0) - gtk_list_unselect_item( m_list, m_prevSelection ); - gtk_list_select_item( m_list, n ); - m_prevSelection = n; - } - else - gtk_list_unselect_item( m_list, n ); - - m_blockEvent = FALSE; -} - -void wxListBox::DoSetFirstItem( int n ) -{ - wxCHECK_RET( m_list, wxT("invalid listbox") ); - - if (gdk_pointer_is_grabbed () && GTK_WIDGET_HAS_GRAB (m_list)) - return; - - // terribly efficient - const gchar *vadjustment_key = "gtk-vadjustment"; - guint vadjustment_key_id = g_quark_from_static_string (vadjustment_key); - - GtkAdjustment *adjustment = - (GtkAdjustment*) gtk_object_get_data_by_id (GTK_OBJECT (m_list), vadjustment_key_id); - wxCHECK_RET( adjustment, wxT("invalid listbox code") ); - - GList *target = g_list_nth( m_list->children, n ); - wxCHECK_RET( target, wxT("invalid listbox index") ); - - GtkWidget *item = GTK_WIDGET(target->data); - wxCHECK_RET( item, wxT("invalid listbox code") ); - - if (item->allocation.y == -1) - { - wxlistbox_idle_struct* data = new wxlistbox_idle_struct; - data->m_listbox = this; - data->m_item = n; - data->m_tag = gtk_idle_add_priority( 800, wxlistbox_idle_callback, (gpointer) data ); - - return; - } - - float y = item->allocation.y; - if (y > adjustment->upper - adjustment->page_size) - y = adjustment->upper - adjustment->page_size; - gtk_adjustment_set_value( adjustment, y ); -} - -// ---------------------------------------------------------------------------- -// helpers -// ---------------------------------------------------------------------------- - -int wxListBox::GtkGetIndex( GtkWidget *item ) const -{ - if (item) - { - GList *child = m_list->children; - int count = 0; - while (child) - { - if (GTK_WIDGET(child->data) == item) return count; - count++; - child = child->next; - } - } - return -1; -} - -#if wxUSE_TOOLTIPS -void wxListBox::ApplyToolTip( GtkTooltips *tips, const wxChar *tip ) -{ - GList *child = m_list->children; - while (child) - { - gtk_tooltips_set_tip( tips, GTK_WIDGET( child->data ), wxConvCurrent->cWX2MB(tip), (gchar*) NULL ); - child = child->next; - } -} -#endif // wxUSE_TOOLTIPS - -GtkWidget *wxListBox::GetConnectWidget() -{ - return GTK_WIDGET(m_list); -} - -bool wxListBox::IsOwnGtkWindow( GdkWindow *window ) -{ - if (m_widget->window == window) return TRUE; - - if (GTK_WIDGET(m_list)->window == window) return TRUE; - - GList *child = m_list->children; - while (child) - { - GtkWidget *bin = GTK_WIDGET( child->data ); - if (bin->window == window) return TRUE; - child = child->next; - } - - return FALSE; -} - -void wxListBox::ApplyWidgetStyle() -{ - SetWidgetStyle(); - - if (m_backgroundColour.Ok()) - { - GdkWindow *window = GTK_WIDGET(m_list)->window; - if ( window ) - { - m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) ); - gdk_window_set_background( window, m_backgroundColour.GetColor() ); - gdk_window_clear( window ); - } - } - - GList *child = m_list->children; - while (child) - { - gtk_widget_set_style( GTK_WIDGET(child->data), m_widgetStyle ); - - GtkBin *bin = GTK_BIN( child->data ); - GtkWidget *label = GTK_WIDGET( bin->child ); - gtk_widget_set_style( label, m_widgetStyle ); - - child = child->next; - } -} - -void wxListBox::OnInternalIdle() -{ - wxCursor cursor = m_cursor; - if (g_globalCursor.Ok()) cursor = g_globalCursor; - - if (GTK_WIDGET(m_list)->window && cursor.Ok()) - { - /* I now set the cursor the anew in every OnInternalIdle call - as setting the cursor in a parent window also effects the - windows above so that checking for the current cursor is - not possible. */ - - gdk_window_set_cursor( GTK_WIDGET(m_list)->window, cursor.GetCursor() ); - - GList *child = m_list->children; - while (child) - { - GtkBin *bin = GTK_BIN( child->data ); - GtkWidget *label = GTK_WIDGET( bin->child ); - - if (!label->window) - break; - else - gdk_window_set_cursor( label->window, cursor.GetCursor() ); - - child = child->next; - } - } - - if (g_delayedFocus == this) - { - if (GTK_WIDGET_REALIZED(m_widget)) - { - gtk_widget_grab_focus( m_widget ); - g_delayedFocus = NULL; - } - } - - UpdateWindowUI(); -} - -wxSize wxListBox::DoGetBestSize() const -{ - int lbWidth = 100; // some defaults - int lbHeight = 110; - int wLine; - - // Find the widest line - for(int i = 0; i < GetCount(); i++) { - wxString str(GetString(i)); - GetTextExtent(str, &wLine, NULL); - lbWidth = wxMax(lbWidth, wLine); - } - - // Add room for the scrollbar - lbWidth += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X); - - // And just a bit more - int cx, cy; - GetTextExtent( wxT("X"), &cx, &cy); - lbWidth += 3 * cx; - - // don't make the listbox too tall (limit height to around 10 items) but don't - // make it too small neither - lbHeight = (cy+4) * wxMin(wxMax(GetCount(), 3), 10); - - return wxSize(lbWidth, lbHeight); -} - -void wxListBox::FixUpMouseEvent(GtkWidget *widget, wxCoord& x, wxCoord& y) -{ - // the mouse event coords are relative to the listbox items, we need to - // translate them to the normal client coords - x += widget->allocation.x; - y += widget->allocation.y; -} - -#endif // wxUSE_LISTBOX - diff --git a/src/gtk1/main.cpp b/src/gtk1/main.cpp deleted file mode 100644 index 96d7e9e4b6..0000000000 --- a/src/gtk1/main.cpp +++ /dev/null @@ -1,14 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: main.cpp -// Purpose: Entry point -// Author: Julian Smart -// Modified by: -// Created: 17/09/98 -// RCS-ID: $Id$ -// Copyright: (c) Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - - -// We don't put main() in the library any more. RR. - diff --git a/src/gtk1/mdi.cpp b/src/gtk1/mdi.cpp deleted file mode 100644 index 133fe6e459..0000000000 --- a/src/gtk1/mdi.cpp +++ /dev/null @@ -1,495 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: mdi.cpp -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/mdi.h" - -#if wxUSE_MDI_ARCHITECTURE - -#include "wx/dialog.h" -#include "wx/menu.h" -#include "wx/intl.h" -#include "wx/gtk/private.h" - -#include -#include -#include -#include "wx/gtk/win_gtk.h" - -//----------------------------------------------------------------------------- -// constants -//----------------------------------------------------------------------------- - -const int wxMENU_HEIGHT = 27; - -//----------------------------------------------------------------------------- -// idle system -//----------------------------------------------------------------------------- - -extern void wxapp_install_idle_handler(); -extern bool g_isIdle; - -//----------------------------------------------------------------------------- -// globals -//----------------------------------------------------------------------------- - -extern wxList wxPendingDelete; - -//----------------------------------------------------------------------------- -// "switch_page" -//----------------------------------------------------------------------------- - -static void -gtk_mdi_page_change_callback( GtkNotebook *WXUNUSED(widget), - GtkNotebookPage *page, - gint WXUNUSED(page_num), - wxMDIParentFrame *parent ) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - - // send deactivate event to old child - - wxMDIChildFrame *child = parent->GetActiveChild(); - if (child) - { - wxActivateEvent event1( wxEVT_ACTIVATE, FALSE, child->GetId() ); - event1.SetEventObject( child); - child->GetEventHandler()->ProcessEvent( event1 ); - } - - // send activate event to new child - - wxMDIClientWindow *client_window = parent->GetClientWindow(); - if (!client_window) - return; - - child = (wxMDIChildFrame*) NULL; - - wxNode *node = client_window->GetChildren().First(); - while (node) - { - wxMDIChildFrame *child_frame = (wxMDIChildFrame *)node->Data(); - if (child_frame->m_page == page) - { - child = child_frame; - break; - } - node = node->Next(); - } - - if (!child) - return; - - wxActivateEvent event2( wxEVT_ACTIVATE, TRUE, child->GetId() ); - event2.SetEventObject( child); - child->GetEventHandler()->ProcessEvent( event2 ); -} - -//----------------------------------------------------------------------------- -// wxMDIParentFrame -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame,wxFrame) - -void wxMDIParentFrame::Init() -{ - m_justInserted = FALSE; - m_clientWindow = (wxMDIClientWindow *) NULL; -} - -wxMDIParentFrame::~wxMDIParentFrame() -{ -} - -bool wxMDIParentFrame::Create(wxWindow *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos, - const wxSize& size, - long style, - const wxString& name ) -{ - wxFrame::Create( parent, id, title, pos, size, style, name ); - - OnCreateClient(); - - return TRUE; -} - -void wxMDIParentFrame::GtkOnSize( int x, int y, int width, int height ) -{ - wxFrame::GtkOnSize( x, y, width, height ); - - wxMDIChildFrame *child_frame = GetActiveChild(); - if (!child_frame) return; - - wxMenuBar *menu_bar = child_frame->m_menuBar; - if (!menu_bar) return; - if (!menu_bar->m_widget) return; - - menu_bar->m_x = 0; - menu_bar->m_y = 0; - menu_bar->m_width = m_width; - menu_bar->m_height = wxMENU_HEIGHT; - gtk_pizza_set_size( GTK_PIZZA(m_mainWidget), - menu_bar->m_widget, - 0, 0, m_width, wxMENU_HEIGHT ); -} - -void wxMDIParentFrame::OnInternalIdle() -{ - /* if a an MDI child window has just been inserted - it has to be brought to the top in idle time. we - simply set the last notebook page active as new - pages can only be appended at the end */ - - if (m_justInserted) - { - GtkNotebook *notebook = GTK_NOTEBOOK(m_clientWindow->m_widget); - gtk_notebook_set_page( notebook, g_list_length( notebook->children ) - 1 ); - - m_justInserted = FALSE; - return; - } - - wxFrame::OnInternalIdle(); - - wxMDIChildFrame *active_child_frame = GetActiveChild(); - bool visible_child_menu = FALSE; - - wxNode *node = m_clientWindow->GetChildren().First(); - while (node) - { - wxObject *child = node->Data(); - wxMDIChildFrame *child_frame = wxDynamicCast(child, wxMDIChildFrame); - if ( child_frame ) - { - wxMenuBar *menu_bar = child_frame->m_menuBar; - if ( menu_bar ) - { - if (child_frame == active_child_frame) - { - if (menu_bar->Show(TRUE)) - { - menu_bar->m_width = m_width; - menu_bar->m_height = wxMENU_HEIGHT; - gtk_pizza_set_size( GTK_PIZZA(m_mainWidget), - menu_bar->m_widget, - 0, 0, m_width, wxMENU_HEIGHT ); - menu_bar->SetInvokingWindow( child_frame ); - } - visible_child_menu = TRUE; - } - else - { - if (menu_bar->Show(FALSE)) - { - menu_bar->UnsetInvokingWindow( child_frame ); - } - } - } - } - - node = node->Next(); - } - - /* show/hide parent menu bar as required */ - if ((m_frameMenuBar) && - (m_frameMenuBar->IsShown() == visible_child_menu)) - { - if (visible_child_menu) - { - m_frameMenuBar->Show( FALSE ); - m_frameMenuBar->UnsetInvokingWindow( this ); - } - else - { - m_frameMenuBar->Show( TRUE ); - m_frameMenuBar->SetInvokingWindow( this ); - - m_frameMenuBar->m_width = m_width; - m_frameMenuBar->m_height = wxMENU_HEIGHT; - gtk_pizza_set_size( GTK_PIZZA(m_mainWidget), - m_frameMenuBar->m_widget, - 0, 0, m_width, wxMENU_HEIGHT ); - } - } -} - -void wxMDIParentFrame::DoGetClientSize(int *width, int *height ) const -{ - wxFrame::DoGetClientSize( width, height ); -} - -wxMDIChildFrame *wxMDIParentFrame::GetActiveChild() const -{ - if (!m_clientWindow) return (wxMDIChildFrame*) NULL; - - GtkNotebook *notebook = GTK_NOTEBOOK(m_clientWindow->m_widget); - if (!notebook) return (wxMDIChildFrame*) NULL; - - gint i = gtk_notebook_get_current_page( notebook ); - if (i < 0) return (wxMDIChildFrame*) NULL; - - GtkNotebookPage* page = (GtkNotebookPage*) (g_list_nth(notebook->children,i)->data); - if (!page) return (wxMDIChildFrame*) NULL; - - wxNode *node = m_clientWindow->GetChildren().First(); - while (node) - { - wxMDIChildFrame *child_frame = (wxMDIChildFrame *)node->Data(); - if (child_frame->m_page == page) - return child_frame; - node = node->Next(); - } - - return (wxMDIChildFrame*) NULL; -} - -wxMDIClientWindow *wxMDIParentFrame::GetClientWindow() const -{ - return m_clientWindow; -} - -wxMDIClientWindow *wxMDIParentFrame::OnCreateClient() -{ - m_clientWindow = new wxMDIClientWindow( this ); - return m_clientWindow; -} - -void wxMDIParentFrame::ActivateNext() -{ - if (m_clientWindow) - gtk_notebook_next_page( GTK_NOTEBOOK(m_clientWindow->m_widget) ); -} - -void wxMDIParentFrame::ActivatePrevious() -{ - if (m_clientWindow) - gtk_notebook_prev_page( GTK_NOTEBOOK(m_clientWindow->m_widget) ); -} - -//----------------------------------------------------------------------------- -// wxMDIChildFrame -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame,wxFrame) - -BEGIN_EVENT_TABLE(wxMDIChildFrame, wxFrame) - EVT_ACTIVATE(wxMDIChildFrame::OnActivate) - EVT_MENU_HIGHLIGHT_ALL(wxMDIChildFrame::OnMenuHighlight) -END_EVENT_TABLE() - -wxMDIChildFrame::wxMDIChildFrame() -{ - m_menuBar = (wxMenuBar *) NULL; - m_page = (GtkNotebookPage *) NULL; -} - -wxMDIChildFrame::wxMDIChildFrame( wxMDIParentFrame *parent, - wxWindowID id, const wxString& title, - const wxPoint& WXUNUSED(pos), const wxSize& size, - long style, const wxString& name ) -{ - m_menuBar = (wxMenuBar *) NULL; - m_page = (GtkNotebookPage *) NULL; - Create( parent, id, title, wxDefaultPosition, size, style, name ); -} - -wxMDIChildFrame::~wxMDIChildFrame() -{ - if (m_menuBar) - delete m_menuBar; -} - -bool wxMDIChildFrame::Create( wxMDIParentFrame *parent, - wxWindowID id, const wxString& title, - const wxPoint& WXUNUSED(pos), const wxSize& size, - long style, const wxString& name ) -{ - m_title = title; - - return wxWindow::Create( parent->GetClientWindow(), id, wxDefaultPosition, size, style, name ); -} - -void wxMDIChildFrame::DoSetSize( int x, int y, int width, int height, int sizeFlags ) -{ - wxWindow::DoSetSize( x, y, width, height, sizeFlags ); -} - -void wxMDIChildFrame::DoSetClientSize(int width, int height) -{ - wxWindow::DoSetClientSize( width, height ); -} - -void wxMDIChildFrame::DoGetClientSize( int *width, int *height ) const -{ - wxWindow::DoGetClientSize( width, height ); -} - -void wxMDIChildFrame::AddChild( wxWindowBase *child ) -{ - wxWindow::AddChild(child); -} - -void wxMDIChildFrame::SetMenuBar( wxMenuBar *menu_bar ) -{ - wxASSERT_MSG( m_menuBar == NULL, wxT("Only one menubar allowed") ); - - m_menuBar = menu_bar; - - if (m_menuBar) - { - wxMDIParentFrame *mdi_frame = (wxMDIParentFrame*)m_parent->GetParent(); - - m_menuBar->SetParent( mdi_frame ); - - /* insert the invisible menu bar into the _parent_ mdi frame */ - gtk_pizza_put( GTK_PIZZA(mdi_frame->m_mainWidget), - m_menuBar->m_widget, - 0, 0, mdi_frame->m_width, wxMENU_HEIGHT ); - } -} - -wxMenuBar *wxMDIChildFrame::GetMenuBar() const -{ - return m_menuBar; -} - -void wxMDIChildFrame::Activate() -{ - wxMDIParentFrame* parent = (wxMDIParentFrame*) GetParent(); - GtkNotebook* notebook = GTK_NOTEBOOK(parent->m_widget); - gint pageno = gtk_notebook_page_num( notebook, m_widget ); - gtk_notebook_set_page( notebook, pageno ); -} - -void wxMDIChildFrame::OnActivate( wxActivateEvent& WXUNUSED(event) ) -{ -} - -void wxMDIChildFrame::OnMenuHighlight( wxMenuEvent& event ) -{ -#if wxUSE_STATUSBAR - wxMDIParentFrame *mdi_frame = (wxMDIParentFrame*)m_parent->GetParent(); - if ( !ShowMenuHelp(mdi_frame->GetStatusBar(), event.GetMenuId()) ) - { - // we don't have any help text for this item, but may be the MDI frame - // does? - mdi_frame->OnMenuHighlight(event); - } -#endif // wxUSE_STATUSBAR -} - -void wxMDIChildFrame::SetTitle( const wxString &title ) -{ - if ( title == m_title ) - return; - - m_title = title; - - wxMDIParentFrame* parent = (wxMDIParentFrame*) GetParent(); - GtkNotebook* notebook = GTK_NOTEBOOK(parent->m_widget); - gtk_notebook_set_tab_label_text(notebook, m_widget, wxGTK_CONV( title ) ); -} - -//----------------------------------------------------------------------------- -// "size_allocate" -//----------------------------------------------------------------------------- - -static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxWindow *win ) -{ - if (g_isIdle) wxapp_install_idle_handler(); - - if ((win->m_x == alloc->x) && - (win->m_y == alloc->y) && - (win->m_width == alloc->width) && - (win->m_height == alloc->height) && - (win->m_sizeSet)) - { - return; - } - - win->SetSize( alloc->x, alloc->y, alloc->width, alloc->height ); -} - -//----------------------------------------------------------------------------- -// InsertChild callback for wxMDIClientWindow -//----------------------------------------------------------------------------- - -static void wxInsertChildInMDI( wxMDIClientWindow* parent, wxMDIChildFrame* child ) -{ - wxString s = child->m_title; - if (s.IsNull()) s = _("MDI child"); - - GtkWidget *label_widget = gtk_label_new( s.mbc_str() ); - gtk_misc_set_alignment( GTK_MISC(label_widget), 0.0, 0.5 ); - - gtk_signal_connect( GTK_OBJECT(child->m_widget), "size_allocate", - GTK_SIGNAL_FUNC(gtk_page_size_callback), (gpointer)child ); - - GtkNotebook *notebook = GTK_NOTEBOOK(parent->m_widget); - - gtk_notebook_append_page( notebook, child->m_widget, label_widget ); - - child->m_page = (GtkNotebookPage*) (g_list_last(notebook->children)->data); - - wxMDIParentFrame *parent_frame = (wxMDIParentFrame*) parent->GetParent(); - parent_frame->m_justInserted = TRUE; -} - -//----------------------------------------------------------------------------- -// wxMDIClientWindow -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxMDIClientWindow,wxWindow) - -wxMDIClientWindow::wxMDIClientWindow() -{ -} - -wxMDIClientWindow::wxMDIClientWindow( wxMDIParentFrame *parent, long style ) -{ - CreateClient( parent, style ); -} - -wxMDIClientWindow::~wxMDIClientWindow() -{ -} - -bool wxMDIClientWindow::CreateClient( wxMDIParentFrame *parent, long style ) -{ - m_needParent = TRUE; - - m_insertCallback = (wxInsertChildFunction)wxInsertChildInMDI; - - if (!PreCreation( parent, wxDefaultPosition, wxDefaultSize ) || - !CreateBase( parent, -1, wxDefaultPosition, wxDefaultSize, style, wxDefaultValidator, wxT("wxMDIClientWindow") )) - { - wxFAIL_MSG( wxT("wxMDIClientWindow creation failed") ); - return FALSE; - } - - m_widget = gtk_notebook_new(); - - gtk_signal_connect( GTK_OBJECT(m_widget), "switch_page", - GTK_SIGNAL_FUNC(gtk_mdi_page_change_callback), (gpointer)parent ); - - gtk_notebook_set_scrollable( GTK_NOTEBOOK(m_widget), 1 ); - - m_parent->DoAddChild( this ); - - PostCreation(); - - Show( TRUE ); - - return TRUE; -} - -#endif diff --git a/src/gtk1/menu.cpp b/src/gtk1/menu.cpp deleted file mode 100644 index 90e9616a4e..0000000000 --- a/src/gtk1/menu.cpp +++ /dev/null @@ -1,1464 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: menu.cpp -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/log.h" -#include "wx/intl.h" -#include "wx/app.h" -#include "wx/bitmap.h" -#include "wx/menu.h" - -#if wxUSE_ACCEL - #include "wx/accel.h" -#endif // wxUSE_ACCEL - -#include "wx/gtk/private.h" - -#include - -// FIXME: is this right? somehow I don't think so (VZ) -#ifdef __WXGTK20__ - #include - - #define gtk_accel_group_attach(g, o) gtk_window_add_accel_group((o), (g)) - #define gtk_accel_group_detach(g, o) gtk_window_remove_accel_group((o), (g)) - #define gtk_menu_ensure_uline_accel_group(m) gtk_menu_get_accel_group(m) - - #define ACCEL_OBJECT GtkWindow - #define ACCEL_OBJECTS(a) (a)->acceleratables - #define ACCEL_OBJ_CAST(obj) ((GtkWindow*) obj) -#else // GTK+ 1.x - #define ACCEL_OBJECT GtkObject - #define ACCEL_OBJECTS(a) (a)->attach_objects - #define ACCEL_OBJ_CAST(obj) GTK_OBJECT(obj) -#endif - -//----------------------------------------------------------------------------- -// idle system -//----------------------------------------------------------------------------- - -extern void wxapp_install_idle_handler(); -extern bool g_isIdle; - -#if GTK_CHECK_VERSION(1, 2, 0) && wxUSE_ACCEL - static wxString GetHotKey( const wxMenuItem& item ); -#endif - -//----------------------------------------------------------------------------- -// idle system -//----------------------------------------------------------------------------- - -static wxString wxReplaceUnderscore( const wxString& title ) -{ - const wxChar *pc; - - /* GTK 1.2 wants to have "_" instead of "&" for accelerators */ - wxString str; - pc = title; - while (*pc != wxT('\0')) - { - if ((*pc == wxT('&')) && (*(pc+1) == wxT('&'))) - { - // "&" is doubled to indicate "&" instead of accelerator - ++pc; - str << wxT('&'); - } - else if (*pc == wxT('&')) - { -#if GTK_CHECK_VERSION(1, 2, 0) - str << wxT('_'); -#endif - } -#if GTK_CHECK_VERSION(2, 0, 0) - else if (*pc == wxT('/')) - { - str << wxT("\\/"); - } - else if (*pc == wxT('\\')) - { - str << wxT("\\\\"); - } -#elif GTK_CHECK_VERSION(1, 2, 0) - else if (*pc == wxT('/')) - { - str << wxT('\\'); - } -#endif - else - { -#ifdef __WXGTK12__ - if ( *pc == wxT('_') ) - { - // underscores must be doubled to prevent them from being - // interpreted as accelerator character prefix by GTK - str << *pc; - } -#endif // GTK+ 1.2 - - str << *pc; - } - ++pc; - } - return str; -} - -//----------------------------------------------------------------------------- -// activate message from GTK -//----------------------------------------------------------------------------- - -static void gtk_menu_open_callback( GtkWidget *widget, wxMenu *menu ) -{ - if (g_isIdle) wxapp_install_idle_handler(); - - wxMenuEvent event( wxEVT_MENU_OPEN, -1 ); - event.SetEventObject( menu ); - - wxEvtHandler* handler = menu->GetEventHandler(); - if (handler && handler->ProcessEvent(event)) - return; - - wxWindow *win = menu->GetInvokingWindow(); - if (win) win->GetEventHandler()->ProcessEvent( event ); -} - -//----------------------------------------------------------------------------- -// wxMenuBar -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxMenuBar,wxWindow) - -wxMenuBar::wxMenuBar( long style ) -{ - /* the parent window is known after wxFrame::SetMenu() */ - m_needParent = FALSE; - m_style = style; - m_invokingWindow = (wxWindow*) NULL; - - if (!PreCreation( (wxWindow*) NULL, wxDefaultPosition, wxDefaultSize ) || - !CreateBase( (wxWindow*) NULL, -1, wxDefaultPosition, wxDefaultSize, style, wxDefaultValidator, wxT("menubar") )) - { - wxFAIL_MSG( wxT("wxMenuBar creation failed") ); - return; - } - - m_menus.DeleteContents( TRUE ); - - /* GTK 1.2.0 doesn't have gtk_item_factory_get_item(), but GTK 1.2.1 has. */ -#if GTK_CHECK_VERSION(1, 2, 1) - m_accel = gtk_accel_group_new(); - m_factory = gtk_item_factory_new( GTK_TYPE_MENU_BAR, "
", m_accel ); - m_menubar = gtk_item_factory_get_widget( m_factory, "
" ); -#else - m_menubar = gtk_menu_bar_new(); -#endif - - if (style & wxMB_DOCKABLE) - { - m_widget = gtk_handle_box_new(); - gtk_container_add( GTK_CONTAINER(m_widget), GTK_WIDGET(m_menubar) ); - gtk_widget_show( GTK_WIDGET(m_menubar) ); - } - else - { - m_widget = GTK_WIDGET(m_menubar); - } - - PostCreation(); - - ApplyWidgetStyle(); -} - -wxMenuBar::wxMenuBar() -{ - /* the parent window is known after wxFrame::SetMenu() */ - m_needParent = FALSE; - m_style = 0; - m_invokingWindow = (wxWindow*) NULL; - - if (!PreCreation( (wxWindow*) NULL, wxDefaultPosition, wxDefaultSize ) || - !CreateBase( (wxWindow*) NULL, -1, wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, wxT("menubar") )) - { - wxFAIL_MSG( wxT("wxMenuBar creation failed") ); - return; - } - - m_menus.DeleteContents( TRUE ); - - /* GTK 1.2.0 doesn't have gtk_item_factory_get_item(), but GTK 1.2.1 has. */ -#if GTK_CHECK_VERSION(1, 2, 1) - m_accel = gtk_accel_group_new(); - m_factory = gtk_item_factory_new( GTK_TYPE_MENU_BAR, "
", m_accel ); - m_menubar = gtk_item_factory_get_widget( m_factory, "
" ); -#else - m_menubar = gtk_menu_bar_new(); -#endif - - m_widget = GTK_WIDGET(m_menubar); - - PostCreation(); - - ApplyWidgetStyle(); -} - -wxMenuBar::~wxMenuBar() -{ -// gtk_object_unref( GTK_OBJECT(m_factory) ); why not ? -} - -static void wxMenubarUnsetInvokingWindow( wxMenu *menu, wxWindow *win ) -{ - menu->SetInvokingWindow( (wxWindow*) NULL ); - - wxWindow *top_frame = win; - while (top_frame->GetParent() && !(top_frame->IsTopLevel())) - top_frame = top_frame->GetParent(); - - /* support for native hot keys */ - gtk_accel_group_detach( menu->m_accel, ACCEL_OBJ_CAST(top_frame->m_widget) ); - - wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst(); - while (node) - { - wxMenuItem *menuitem = node->GetData(); - if (menuitem->IsSubMenu()) - wxMenubarUnsetInvokingWindow( menuitem->GetSubMenu(), win ); - node = node->GetNext(); - } -} - -static void wxMenubarSetInvokingWindow( wxMenu *menu, wxWindow *win ) -{ - menu->SetInvokingWindow( win ); - -#if GTK_CHECK_VERSION(1, 2, 1) - wxWindow *top_frame = win; - while (top_frame->GetParent() && !(top_frame->IsTopLevel())) - top_frame = top_frame->GetParent(); - - /* support for native hot keys */ - ACCEL_OBJECT *obj = ACCEL_OBJ_CAST(top_frame->m_widget); - if ( !g_slist_find( ACCEL_OBJECTS(menu->m_accel), obj ) ) - gtk_accel_group_attach( menu->m_accel, obj ); -#endif // GTK+ 1.2.1+ - - wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst(); - while (node) - { - wxMenuItem *menuitem = node->GetData(); - if (menuitem->IsSubMenu()) - wxMenubarSetInvokingWindow( menuitem->GetSubMenu(), win ); - node = node->GetNext(); - } -} - -void wxMenuBar::SetInvokingWindow( wxWindow *win ) -{ - m_invokingWindow = win; -#if GTK_CHECK_VERSION(1, 2, 1) - wxWindow *top_frame = win; - while (top_frame->GetParent() && !(top_frame->IsTopLevel())) - top_frame = top_frame->GetParent(); - - /* support for native key accelerators indicated by underscroes */ - ACCEL_OBJECT *obj = ACCEL_OBJ_CAST(top_frame->m_widget); - if ( !g_slist_find( ACCEL_OBJECTS(m_accel), obj ) ) - gtk_accel_group_attach( m_accel, obj ); -#endif // GTK+ 1.2.1+ - - wxMenuList::Node *node = m_menus.GetFirst(); - while (node) - { - wxMenu *menu = node->GetData(); - wxMenubarSetInvokingWindow( menu, win ); - node = node->GetNext(); - } -} - -void wxMenuBar::UnsetInvokingWindow( wxWindow *win ) -{ - m_invokingWindow = (wxWindow*) NULL; -#if GTK_CHECK_VERSION(1, 2, 1) - wxWindow *top_frame = win; - while (top_frame->GetParent() && !(top_frame->IsTopLevel())) - top_frame = top_frame->GetParent(); - - /* support for native key accelerators indicated by underscroes */ - gtk_accel_group_detach( m_accel, ACCEL_OBJ_CAST(top_frame->m_widget) ); -#endif // GTK+ 1.2.1+ - - wxMenuList::Node *node = m_menus.GetFirst(); - while (node) - { - wxMenu *menu = node->GetData(); - wxMenubarUnsetInvokingWindow( menu, win ); - node = node->GetNext(); - } -} - -bool wxMenuBar::Append( wxMenu *menu, const wxString &title ) -{ - if ( !wxMenuBarBase::Append( menu, title ) ) - return FALSE; - - return GtkAppend(menu, title); -} - -bool wxMenuBar::GtkAppend(wxMenu *menu, const wxString& title) -{ - wxString str( wxReplaceUnderscore( title ) ); - - /* this doesn't have much effect right now */ - menu->SetTitle( str ); - - /* GTK 1.2.0 doesn't have gtk_item_factory_get_item(), but GTK 1.2.1 has. */ -#if GTK_CHECK_VERSION(1, 2, 1) - - wxString buf; - buf << wxT('/') << str.c_str(); - - /* local buffer in multibyte form */ - char cbuf[400]; - strcpy(cbuf, wxGTK_CONV(buf) ); - - GtkItemFactoryEntry entry; - entry.path = (gchar *)cbuf; // const_cast - entry.accelerator = (gchar*) NULL; - entry.callback = (GtkItemFactoryCallback) NULL; - entry.callback_action = 0; - entry.item_type = (char *)""; - - 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 tmp = wxT("
/"); - const wxChar *pc; - for ( pc = str; *pc != wxT('\0'); pc++ ) - { - // contrary to the common sense, we must throw out _all_ underscores, - // (i.e. "Hello__World" => "HelloWorld" and not "Hello_World" as we - // might naively think). IMHO it's a bug in GTK+ (VZ) - while (*pc == wxT('_')) - pc++; - tmp << *pc; - } - menu->m_owner = gtk_item_factory_get_item( m_factory, wxGTK_CONV( tmp ) ); - gtk_menu_item_set_submenu( GTK_MENU_ITEM(menu->m_owner), menu->m_menu ); -#else - - menu->m_owner = gtk_menu_item_new_with_label( wxGTK_CONV( str ) ); - gtk_widget_show( menu->m_owner ); - gtk_menu_item_set_submenu( GTK_MENU_ITEM(menu->m_owner), menu->m_menu ); - - gtk_menu_bar_append( GTK_MENU_BAR(m_menubar), menu->m_owner ); - -#endif - - gtk_signal_connect( GTK_OBJECT(menu->m_owner), "activate", - GTK_SIGNAL_FUNC(gtk_menu_open_callback), - (gpointer)menu ); - - // m_invokingWindow is set after wxFrame::SetMenuBar(). This call enables - // addings menu later on. - if (m_invokingWindow) - { - wxMenubarSetInvokingWindow( menu, m_invokingWindow ); - - // OPTIMISE ME: we should probably cache this, or pass it - // directly, but for now this is a minimal - // change to validate the new dynamic sizing. - // see (and refactor :) similar code in Remove - // below. - - wxFrame *frame = wxDynamicCast( m_invokingWindow, wxFrame ); - - if( frame ) - frame->UpdateMenuBarSize(); - } - - return TRUE; -} - -bool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title) -{ - if ( !wxMenuBarBase::Insert(pos, menu, title) ) - return FALSE; - - // GTK+ doesn't have a function to insert a menu using GtkItemFactory (as - // of version 1.2.6), so we first append the item and then change its - // index - if ( !GtkAppend(menu, title) ) - return FALSE; - - if (pos+1 >= m_menus.GetCount()) - return TRUE; - - GtkMenuShell *menu_shell = GTK_MENU_SHELL(m_factory->widget); - gpointer data = g_list_last(menu_shell->children)->data; - menu_shell->children = g_list_remove(menu_shell->children, data); - menu_shell->children = g_list_insert(menu_shell->children, data, pos); - - return TRUE; -} - -wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title) -{ - // remove the old item and insert a new one - wxMenu *menuOld = Remove(pos); - if ( menuOld && !Insert(pos, menu, title) ) - { - return (wxMenu*) NULL; - } - - // either Insert() succeeded or Remove() failed and menuOld is NULL - return menuOld; -} - -static wxMenu *CopyMenu (wxMenu *menu) -{ - wxMenu *menucopy = new wxMenu (); - wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst(); - while (node) - { - wxMenuItem *item = node->GetData(); - int itemid = item->GetId(); - wxString text = item->GetText(); - text.Replace(wxT("_"), wxT("&")); - wxMenu *submenu = item->GetSubMenu(); - if (!submenu) - { - wxMenuItem* itemcopy = new wxMenuItem(menucopy, - itemid, text, - menu->GetHelpString(itemid)); - itemcopy->SetBitmap(item->GetBitmap()); - itemcopy->SetCheckable(item->IsCheckable()); - menucopy->Append(itemcopy); - } - else - menucopy->Append (itemid, text, CopyMenu(submenu), - menu->GetHelpString(itemid)); - - node = node->GetNext(); - } - - return menucopy; -} - -wxMenu *wxMenuBar::Remove(size_t pos) -{ - wxMenu *menu = wxMenuBarBase::Remove(pos); - if ( !menu ) - return (wxMenu*) NULL; - -/* - GtkMenuShell *menu_shell = GTK_MENU_SHELL(m_factory->widget); - - printf( "factory entries before %d\n", (int)g_slist_length(m_factory->items) ); - printf( "menu shell entries before %d\n", (int)g_list_length( menu_shell->children ) ); -*/ - - wxMenu *menucopy = CopyMenu( menu ); - - // unparent calls unref() and that would delete the widget so we raise - // the ref count to 2 artificially before invoking unparent. - gtk_widget_ref( menu->m_menu ); - gtk_widget_unparent( menu->m_menu ); - - gtk_widget_destroy( menu->m_owner ); - delete menu; - - menu = menucopy; -/* - printf( "factory entries after %d\n", (int)g_slist_length(m_factory->items) ); - printf( "menu shell entries after %d\n", (int)g_list_length( menu_shell->children ) ); -*/ - - if (m_invokingWindow) - { - // OPTIMISE ME: see comment in GtkAppend - - wxFrame *frame = wxDynamicCast( m_invokingWindow, wxFrame ); - - if( frame ) - frame->UpdateMenuBarSize(); - } - - return menu; -} - -static int FindMenuItemRecursive( const wxMenu *menu, const wxString &menuString, const wxString &itemString ) -{ - if (wxMenuItem::GetLabelFromText(menu->GetTitle()) == wxMenuItem::GetLabelFromText(menuString)) - { - int res = menu->FindItem( itemString ); - if (res != wxNOT_FOUND) - return res; - } - - wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst(); - while (node) - { - wxMenuItem *item = node->GetData(); - if (item->IsSubMenu()) - return FindMenuItemRecursive(item->GetSubMenu(), menuString, itemString); - - node = node->GetNext(); - } - - return wxNOT_FOUND; -} - -int wxMenuBar::FindMenuItem( const wxString &menuString, const wxString &itemString ) const -{ - wxMenuList::Node *node = m_menus.GetFirst(); - while (node) - { - wxMenu *menu = node->GetData(); - int res = FindMenuItemRecursive( menu, menuString, itemString); - if (res != -1) - return res; - node = node->GetNext(); - } - - return wxNOT_FOUND; -} - -// Find a wxMenuItem using its id. Recurses down into sub-menus -static wxMenuItem* FindMenuItemByIdRecursive(const wxMenu* menu, int id) -{ - wxMenuItem* result = menu->FindChildItem(id); - - wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst(); - while ( node && result == NULL ) - { - wxMenuItem *item = node->GetData(); - if (item->IsSubMenu()) - { - result = FindMenuItemByIdRecursive( item->GetSubMenu(), id ); - } - node = node->GetNext(); - } - - return result; -} - -wxMenuItem* wxMenuBar::FindItem( int id, wxMenu **menuForItem ) const -{ - wxMenuItem* result = 0; - wxMenuList::Node *node = m_menus.GetFirst(); - while (node && result == 0) - { - wxMenu *menu = node->GetData(); - result = FindMenuItemByIdRecursive( menu, id ); - node = node->GetNext(); - } - - if ( menuForItem ) - { - *menuForItem = result ? result->GetMenu() : (wxMenu *)NULL; - } - - return result; -} - -void wxMenuBar::EnableTop( size_t pos, bool flag ) -{ - wxMenuList::Node *node = m_menus.Item( pos ); - - wxCHECK_RET( node, wxT("menu not found") ); - - wxMenu* menu = node->GetData(); - - if (menu->m_owner) - gtk_widget_set_sensitive( menu->m_owner, flag ); -} - -wxString wxMenuBar::GetLabelTop( size_t pos ) const -{ - wxMenuList::Node *node = m_menus.Item( pos ); - - wxCHECK_MSG( node, wxT("invalid"), wxT("menu not found") ); - - wxMenu* menu = node->GetData(); - - wxString label; - wxString text( menu->GetTitle() ); - for ( const wxChar *pc = text.c_str(); *pc; pc++ ) - { - if ( *pc == wxT('_') ) - { - // '_' is the escape character for GTK+ - continue; - } - - // don't remove ampersands '&' since if we have them in the menu title - // it means that they were doubled to indicate "&" instead of accelerator - - label += *pc; - } - - return label; -} - -void wxMenuBar::SetLabelTop( size_t pos, const wxString& label ) -{ - wxMenuList::Node *node = m_menus.Item( pos ); - - wxCHECK_RET( node, wxT("menu not found") ); - - wxMenu* menu = node->GetData(); - - wxString str( wxReplaceUnderscore( label ) ); - - menu->SetTitle( str ); - - if (menu->m_owner) - { - GtkLabel *label = GTK_LABEL( GTK_BIN(menu->m_owner)->child ); - - /* set new text */ - gtk_label_set( label, wxGTK_CONV( str ) ); - - /* reparse key accel */ - (void)gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV( str ) ); - gtk_accel_label_refetch( GTK_ACCEL_LABEL(label) ); - } - -} - -//----------------------------------------------------------------------------- -// "activate" -//----------------------------------------------------------------------------- - -static void gtk_menu_clicked_callback( GtkWidget *widget, wxMenu *menu ) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - - int id = menu->FindMenuIdByMenuItem(widget); - - /* should find it for normal (not popup) menu */ - wxASSERT_MSG( (id != -1) || (menu->GetInvokingWindow() != NULL), - _T("menu item not found in gtk_menu_clicked_callback") ); - - if (!menu->IsEnabled(id)) - return; - - wxMenuItem* item = menu->FindChildItem( id ); - wxCHECK_RET( item, wxT("error in menu item callback") ); - - if (item->IsCheckable()) - { - bool isReallyChecked = item->IsChecked(), - isInternallyChecked = item->wxMenuItemBase::IsChecked(); - - // ensure that the internal state is always consistent with what is - // shown on the screen - item->wxMenuItemBase::Check(isReallyChecked); - - // we must not report the events for the radio button going up nor the - // events resulting from the calls to wxMenuItem::Check() - if ( (item->GetKind() == wxITEM_RADIO && !isReallyChecked) || - (isInternallyChecked == isReallyChecked) ) - { - return; - } - } - - - // Is this menu on a menubar? (possibly nested) - wxFrame* frame = NULL; - wxMenu* pm = menu; - while ( pm && !frame ) - { - if ( pm->IsAttached() ) - frame = pm->GetMenuBar()->GetFrame(); - pm = pm->GetParent(); - } - - if (frame) - { - // If it is attached then let the frame send the event. - // Don't call frame->ProcessCommand(id) because it toggles - // checkable items and we've already done that above. - wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, id); - commandEvent.SetEventObject(frame); - if (item->IsCheckable()) - commandEvent.SetInt(item->IsChecked()); - commandEvent.SetEventObject(menu); - - frame->GetEventHandler()->ProcessEvent(commandEvent); - } - else - { - // otherwise let the menu have it - menu->SendEvent(id, item->IsCheckable() ? item->IsChecked() : -1); - } -} - -//----------------------------------------------------------------------------- -// "select" -//----------------------------------------------------------------------------- - -static void gtk_menu_hilight_callback( GtkWidget *widget, wxMenu *menu ) -{ - if (g_isIdle) wxapp_install_idle_handler(); - - int id = menu->FindMenuIdByMenuItem(widget); - - wxASSERT( id != -1 ); // should find it! - - if (!menu->IsEnabled(id)) - return; - - wxMenuEvent event( wxEVT_MENU_HIGHLIGHT, id ); - event.SetEventObject( menu ); - - wxEvtHandler* handler = menu->GetEventHandler(); - if (handler && handler->ProcessEvent(event)) - return; - - wxWindow *win = menu->GetInvokingWindow(); - if (win) win->GetEventHandler()->ProcessEvent( event ); -} - -//----------------------------------------------------------------------------- -// "deselect" -//----------------------------------------------------------------------------- - -static void gtk_menu_nolight_callback( GtkWidget *widget, wxMenu *menu ) -{ - if (g_isIdle) wxapp_install_idle_handler(); - - int id = menu->FindMenuIdByMenuItem(widget); - - wxASSERT( id != -1 ); // should find it! - - if (!menu->IsEnabled(id)) - return; - - wxMenuEvent event( wxEVT_MENU_HIGHLIGHT, -1 ); - event.SetEventObject( menu ); - - wxEvtHandler* handler = menu->GetEventHandler(); - if (handler && handler->ProcessEvent(event)) - return; - - wxWindow *win = menu->GetInvokingWindow(); - if (win) - win->GetEventHandler()->ProcessEvent( event ); -} - -//----------------------------------------------------------------------------- -// wxMenuItem -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxMenuItem, wxObject) - -wxMenuItem *wxMenuItemBase::New(wxMenu *parentMenu, - int id, - const wxString& name, - const wxString& help, - wxItemKind kind, - wxMenu *subMenu) -{ - return new wxMenuItem(parentMenu, id, name, help, kind, subMenu); -} - -wxMenuItem::wxMenuItem(wxMenu *parentMenu, - int id, - const wxString& text, - const wxString& help, - wxItemKind kind, - wxMenu *subMenu) - : wxMenuItemBase(parentMenu, id, text, help, kind, subMenu) -{ - Init(text); -} - -wxMenuItem::wxMenuItem(wxMenu *parentMenu, - int id, - const wxString& text, - const wxString& help, - bool isCheckable, - wxMenu *subMenu) - : wxMenuItemBase(parentMenu, id, text, help, - isCheckable ? wxITEM_CHECK : wxITEM_NORMAL, subMenu) -{ - Init(text); -} - -void wxMenuItem::Init(const wxString& text) -{ - m_labelWidget = (GtkWidget *) NULL; - m_menuItem = (GtkWidget *) NULL; - - DoSetText(text); -} - -wxMenuItem::~wxMenuItem() -{ - // don't delete menu items, the menus take care of that -} - -// return the menu item text without any menu accels -/* static */ -wxString wxMenuItemBase::GetLabelFromText(const wxString& text) -{ - wxString label; - - for ( const wxChar *pc = text.c_str(); *pc; pc++ ) - { - if ( *pc == wxT('_') ) - { - // GTK 1.2 escapes "xxx_xxx" to "xxx__xxx" - pc++; - label += *pc; - continue; - } - -#if GTK_CHECK_VERSION(2, 0, 0) - if ( *pc == wxT('\\') ) - { - // GTK 2.0 escapes "xxx/xxx" to "xxx\/xxx" - pc++; - label += *pc; - continue; - } -#endif - - if ( (*pc == wxT('&')) && (*(pc+1) != wxT('&')) ) - { - // wxMSW escapes "&" - // "&" is doubled to indicate "&" instead of accelerator - continue; - } - - label += *pc; - } - return label; -} - -void wxMenuItem::SetText( const wxString& str ) -{ - // Some optimization to avoid flicker - wxString oldLabel = m_text; - oldLabel = wxStripMenuCodes(oldLabel.BeforeFirst('\t')); - oldLabel.Replace(wxT("_"), wxT("")); - wxString label1 = wxStripMenuCodes(str.BeforeFirst('\t')); - if (oldLabel == label1) - return; - - DoSetText(str); - - if (m_menuItem) - { - GtkLabel *label; - if (m_labelWidget) - label = (GtkLabel*) m_labelWidget; - else - label = GTK_LABEL( GTK_BIN(m_menuItem)->child ); - -#if GTK_CHECK_VERSION(2, 0, 0) - // We have to imitate item_factory_unescape_label here - wxString tmp; - for (size_t n = 0; n < m_text.Len(); n++) - { - if (m_text[n] != wxT('\\')) - tmp += m_text[n]; - } - - gtk_label_set_text_with_mnemonic( GTK_LABEL(label), wxGTK_CONV(tmp) ); -#else - // set new text - gtk_label_set( label, wxGTK_CONV( m_text ) ); - - // reparse key accel - (void)gtk_label_parse_uline (GTK_LABEL(label), wxGTK_CONV(m_text) ); - gtk_accel_label_refetch( GTK_ACCEL_LABEL(label) ); -#endif - } -} - -// it's valid for this function to be called even if m_menuItem == NULL -void wxMenuItem::DoSetText( const wxString& str ) -{ - // '\t' is the deliminator indicating a hot key - m_text.Empty(); - const wxChar *pc = str; - while ( (*pc != wxT('\0')) && (*pc != wxT('\t')) ) - { - if ((*pc == wxT('&')) && (*(pc+1) == wxT('&'))) - { - // "&" is doubled to indicate "&" instead of accelerator - ++pc; - m_text << wxT('&'); - } - else if (*pc == wxT('&')) - { - m_text << wxT('_'); - } -#if GTK_CHECK_VERSION(2, 0, 0) - else if ( *pc == wxT('_') ) // escape underscores - { - m_text << wxT("__"); - } - else if (*pc == wxT('/')) // we have to escape slashes - { - m_text << wxT("\\/"); - } - else if (*pc == wxT('\\')) // we have to double backslashes - { - m_text << wxT("\\\\"); - } -#else - else if ( *pc == wxT('_') ) // escape underscores - { - m_text << wxT("__"); - } - else if (*pc == wxT('/')) /* we have to filter out slashes ... */ - { - m_text << wxT('\\'); /* ... and replace them with back slashes */ - } -#endif - else { - m_text << *pc; - } - ++pc; - } - - m_hotKey = wxT(""); - - if(*pc == wxT('\t')) - { - pc++; - m_hotKey = pc; - } -} - -#if wxUSE_ACCEL - -wxAcceleratorEntry *wxMenuItem::GetAccel() const -{ - if ( !GetHotKey() ) - { - // nothing - return (wxAcceleratorEntry *)NULL; - } - - // as wxGetAccelFromString() looks for TAB, insert a dummy one here - wxString label; - label << wxT('\t') << GetHotKey(); - - return wxGetAccelFromString(label); -} - -#endif // wxUSE_ACCEL - -void wxMenuItem::Check( bool check ) -{ - wxCHECK_RET( m_menuItem, wxT("invalid menu item") ); - - if (check == m_isChecked) - return; - - wxMenuItemBase::Check( check ); - - switch ( GetKind() ) - { - case wxITEM_CHECK: - case wxITEM_RADIO: - gtk_check_menu_item_set_state( (GtkCheckMenuItem*)m_menuItem, (gint)check ); - break; - - default: - wxFAIL_MSG( _T("can't check this item") ); - } -} - -void wxMenuItem::Enable( bool enable ) -{ - wxCHECK_RET( m_menuItem, wxT("invalid menu item") ); - - gtk_widget_set_sensitive( m_menuItem, enable ); - wxMenuItemBase::Enable( enable ); -} - -bool wxMenuItem::IsChecked() const -{ - wxCHECK_MSG( m_menuItem, FALSE, wxT("invalid menu item") ); - - wxCHECK_MSG( IsCheckable(), FALSE, - wxT("can't get state of uncheckable item!") ); - - return ((GtkCheckMenuItem*)m_menuItem)->active != 0; -} - -wxString wxMenuItem::GetFactoryPath() const -{ - /* in order to get the pointer to the item we need the item text - _without_ underscores */ - wxString path( wxT("
/") ); - - for ( const wxChar *pc = m_text.c_str(); *pc; pc++ ) - { - if ( *pc == wxT('_') ) - { -#ifdef __WXGTK20__ - pc++; -#else - // remove '_' unconditionally - continue; -#endif - } - - // don't remove ampersands '&' since if we have them in the menu item title - // it means that they were doubled to indicate "&" instead of accelerator - - path += *pc; - } - - return path; -} - -//----------------------------------------------------------------------------- -// wxMenu -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxMenu,wxEvtHandler) - -void wxMenu::Init() -{ - m_accel = gtk_accel_group_new(); - m_factory = gtk_item_factory_new( GTK_TYPE_MENU, "
", m_accel ); - m_menu = gtk_item_factory_get_widget( m_factory, "
" ); - - m_owner = (GtkWidget*) NULL; - - /* Tearoffs are entries, just like separators. So if we want this - menu to be a tear-off one, we just append a tearoff entry - immediately. */ - if(m_style & wxMENU_TEAROFF) - { - GtkItemFactoryEntry entry; - entry.path = (char *)"/tearoff"; - entry.callback = (GtkItemFactoryCallback) NULL; - entry.callback_action = 0; - entry.item_type = (char *)""; - entry.accelerator = (gchar*) NULL; - gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */ - //GtkWidget *menuItem = gtk_item_factory_get_widget( m_factory, "
/tearoff" ); - } - - // append the title as the very first entry if we have it - if ( !!m_title ) - { - Append(-2, m_title); - AppendSeparator(); - } -} - -wxMenu::~wxMenu() -{ - m_items.Clear(); - - if ( GTK_IS_WIDGET( m_menu )) - gtk_widget_destroy( m_menu ); - - gtk_object_unref( GTK_OBJECT(m_factory) ); -} - -bool wxMenu::GtkAppend(wxMenuItem *mitem) -{ - GtkWidget *menuItem; - - // does this item terminate the current radio group? - bool endOfRadioGroup = TRUE; - - if ( mitem->IsSeparator() ) - { - GtkItemFactoryEntry entry; - entry.path = (char *)"/sep"; - entry.callback = (GtkItemFactoryCallback) NULL; - entry.callback_action = 0; - entry.item_type = (char *)""; - entry.accelerator = (gchar*) NULL; - - gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */ - - /* this will be wrong for more than one separator. do we care? */ - menuItem = gtk_item_factory_get_widget( m_factory, "
/sep" ); - - // we might have a separator inside a radio group - endOfRadioGroup = FALSE; - } - else if ( mitem->IsSubMenu() ) - { - /* text has "_" instead of "&" after mitem->SetText() */ - wxString text( mitem->GetText() ); - - /* local buffer in multibyte form */ - char buf[200]; - strcpy( buf, "/" ); - strcat( buf, wxGTK_CONV( text ) ); - - GtkItemFactoryEntry entry; - entry.path = buf; - entry.callback = (GtkItemFactoryCallback) 0; - entry.callback_action = 0; - entry.item_type = (char *)""; - entry.accelerator = (gchar*) NULL; - - gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */ - - wxString path( mitem->GetFactoryPath() ); - menuItem = gtk_item_factory_get_item( m_factory, wxGTK_CONV( path ) ); - - gtk_menu_item_set_submenu( GTK_MENU_ITEM(menuItem), mitem->GetSubMenu()->m_menu ); - - // if adding a submenu to a menu already existing in the menu bar, we - // must set invoking window to allow processing events from this - // submenu - if ( m_invokingWindow ) - wxMenubarSetInvokingWindow(mitem->GetSubMenu(), m_invokingWindow); - } - else // a normal item - { - // text has "_" instead of "&" after mitem->SetText() so don't use it - wxString text( mitem->GetText() ); - - // buffers containing the menu item path and type in multibyte form - char bufPath[256], - bufType[256]; - - strcpy( bufPath, "/" ); - strncat( bufPath, wxGTK_CONV(text), WXSIZEOF(bufPath) - 2 ); - bufPath[WXSIZEOF(bufPath) - 1] = '\0'; - - GtkItemFactoryEntry entry; - entry.path = bufPath; - entry.callback = (GtkItemFactoryCallback) gtk_menu_clicked_callback; - entry.callback_action = 0; - - wxString pathRadio; - const char *item_type; - switch ( mitem->GetKind() ) - { - case wxITEM_CHECK: - item_type = ""; - break; - - case wxITEM_RADIO: - if ( m_pathLastRadio.empty() ) - { - // start of a new radio group - item_type = ""; - wxString tmp( wxGTK_CONV_BACK( bufPath ) ); - tmp.Remove(0,1); - m_pathLastRadio = tmp; - } - else // continue the radio group - { - pathRadio = m_pathLastRadio; - pathRadio.Replace(wxT("_"), wxT("")); - pathRadio.Prepend(wxT("
/")); - - strncpy(bufType, wxGTK_CONV(pathRadio), WXSIZEOF(bufType)); - bufType[WXSIZEOF(bufType) - 1] = '\0'; - item_type = bufType; - } - - // continue the existing radio group, if any - endOfRadioGroup = FALSE; - break; - - - default: - wxFAIL_MSG( _T("unexpected menu item kind") ); - // fall through - - case wxITEM_NORMAL: - item_type = ""; -#if defined(__WXGTK20__) && wxUSE_IMAGE - if (mitem->GetBitmap().Ok()) - { - item_type = ""; - // GTK2's image factory know about image items, but they need to - // get a GdkPixbuf structure, which we need to create on the fly. - // This Pixbuf structure needs to be static so we create it and - // just make it a memory leak... - wxImage image( mitem->GetBitmap().ConvertToImage() ); - size_t size = 4 + // magic - 20 + // header - image.GetHeight() * image.GetWidth() * 4; // RGBA - - unsigned char *dest = new unsigned char[size]; - entry.extra_data = dest; - - unsigned char *source = image.GetData(); - bool has_mask = image.HasMask(); - unsigned char mask_r = image.GetMaskRed(); - unsigned char mask_b = image.GetMaskBlue(); - unsigned char mask_g = image.GetMaskGreen(); - wxUint32 tmp; - - // Magic - *dest = 'G'; dest++; *dest = 'd'; dest++; *dest = 'k'; dest++; *dest = 'P'; dest++; - // Data size - tmp = size; - *dest = tmp >> 24; dest++; *dest = tmp >> 16; dest++; *dest = tmp >> 8; dest++; *dest = tmp; dest++; - // Pixdata type - *dest = 1; dest++; *dest = 1; dest++; *dest = 0; dest++; *dest = 2; dest++; - // Rowstride - tmp = image.GetWidth()*4; - *dest = tmp >> 24; dest++; *dest = tmp >> 16; dest++; *dest = tmp >> 8; dest++; *dest = tmp; dest++; - // Width - tmp = image.GetWidth(); - *dest = tmp >> 24; dest++; *dest = tmp >> 16; dest++; *dest = tmp >> 8; dest++; *dest = tmp; dest++; - // Height - tmp = image.GetHeight(); - *dest = tmp >> 24; dest++; *dest = tmp >> 16; dest++; *dest = tmp >> 8; dest++; *dest = tmp; dest++; - - for (int i = 0; i < image.GetWidth()*image.GetHeight(); i++) - { - unsigned char r = *source; source++; - unsigned char g = *source; source++; - unsigned char b = *source; source++; - *dest = r; dest++; - *dest = g; dest++; - *dest = b; dest++; - if (has_mask && (r == mask_r) && (g == mask_g) && (b == mask_b)) - *dest = 0; - else - *dest = 255; - dest++; - } - break; - } -#endif // GTK 2.0+ - break; - } - - entry.item_type = (char *)item_type; // cast needed for GTK+ - entry.accelerator = (gchar*) NULL; - -#if wxUSE_ACCEL - // due to an apparent bug in GTK+, we have to use a static buffer here - - // otherwise GTK+ 1.2.2 manages to override the memory we pass to it - // somehow! (VZ) - char s_accel[50]; // should be big enough, we check for overruns - wxString tmp( GetHotKey(*mitem) ); - strncpy(s_accel, wxGTK_CONV( tmp ), WXSIZEOF(s_accel)); - s_accel[WXSIZEOF(s_accel) - 1] = '\0'; - entry.accelerator = s_accel; -#else // !wxUSE_ACCEL - entry.accelerator = (char*) NULL; -#endif // wxUSE_ACCEL/!wxUSE_ACCEL - - gtk_item_factory_create_item( m_factory, &entry, (gpointer) this, 2 ); /* what is 2 ? */ - - wxString path( mitem->GetFactoryPath() ); - menuItem = gtk_item_factory_get_widget( m_factory, wxGTK_CONV( path ) ); - - if (!menuItem) - wxLogError( wxT("Wrong menu path: %s\n"), path.c_str() ); - } - - if ( !mitem->IsSeparator() ) - { - wxASSERT_MSG( menuItem, wxT("invalid menuitem") ); - - gtk_signal_connect( GTK_OBJECT(menuItem), "select", - GTK_SIGNAL_FUNC(gtk_menu_hilight_callback), - (gpointer)this ); - - gtk_signal_connect( GTK_OBJECT(menuItem), "deselect", - GTK_SIGNAL_FUNC(gtk_menu_nolight_callback), - (gpointer)this ); - } - - mitem->SetMenuItem(menuItem); - - if ( endOfRadioGroup ) - { - m_pathLastRadio.clear(); - } - - return TRUE; -} - -bool wxMenu::DoAppend(wxMenuItem *mitem) -{ - return GtkAppend(mitem) && wxMenuBase::DoAppend(mitem); -} - -bool wxMenu::DoInsert(size_t pos, wxMenuItem *item) -{ - if ( !wxMenuBase::DoInsert(pos, item) ) - return FALSE; - -#ifdef __WXGTK12__ - // GTK+ doesn't have a function to insert a menu using GtkItemFactory (as - // of version 1.2.6), so we first append the item and then change its - // index - if ( !GtkAppend(item) ) - return FALSE; - - if ( m_style & wxMENU_TEAROFF ) - { - // change the position as the first item is the tear-off marker - pos++; - } - - GtkMenuShell *menu_shell = GTK_MENU_SHELL(m_factory->widget); - gpointer data = g_list_last(menu_shell->children)->data; - menu_shell->children = g_list_remove(menu_shell->children, data); - menu_shell->children = g_list_insert(menu_shell->children, data, pos); - - return TRUE; -#else // GTK < 1.2 - // this should be easy to do... - wxFAIL_MSG( wxT("not implemented") ); - - return FALSE; -#endif // GTK 1.2/1.0 -} - -wxMenuItem *wxMenu::DoRemove(wxMenuItem *item) -{ - if ( !wxMenuBase::DoRemove(item) ) - return (wxMenuItem *)NULL; - - // TODO: this code doesn't delete the item factory item and this seems - // impossible as of GTK 1.2.6. - gtk_widget_destroy( item->GetMenuItem() ); - - return item; -} - -int wxMenu::FindMenuIdByMenuItem( GtkWidget *menuItem ) const -{ - wxNode *node = m_items.First(); - while (node) - { - wxMenuItem *item = (wxMenuItem*)node->Data(); - if (item->GetMenuItem() == menuItem) - return item->GetId(); - node = node->Next(); - } - - return wxNOT_FOUND; -} - -// ---------------------------------------------------------------------------- -// helpers -// ---------------------------------------------------------------------------- - -#if GTK_CHECK_VERSION(1, 2, 0) && wxUSE_ACCEL - -static wxString GetHotKey( const wxMenuItem& item ) -{ - wxString hotkey; - - wxAcceleratorEntry *accel = item.GetAccel(); - if ( accel ) - { - int flags = accel->GetFlags(); - if ( flags & wxACCEL_ALT ) - hotkey += wxT(""); - if ( flags & wxACCEL_CTRL ) - hotkey += wxT(""); - if ( flags & wxACCEL_SHIFT ) - hotkey += wxT(""); - - int code = accel->GetKeyCode(); - switch ( code ) - { - case WXK_F1: - case WXK_F2: - case WXK_F3: - case WXK_F4: - case WXK_F5: - case WXK_F6: - case WXK_F7: - case WXK_F8: - case WXK_F9: - case WXK_F10: - case WXK_F11: - case WXK_F12: - hotkey << wxT('F') << code - WXK_F1 + 1; - break; - - // TODO: we should use gdk_keyval_name() (a.k.a. - // XKeysymToString) here as well as hardcoding the keysym - // names this might be not portable - case WXK_NUMPAD_INSERT: - hotkey << wxT("KP_Insert" ); - break; - case WXK_NUMPAD_DELETE: - hotkey << wxT("KP_Delete" ); - break; - case WXK_INSERT: - hotkey << wxT("Insert" ); - break; - case WXK_DELETE: - hotkey << wxT("Delete" ); - break; - case WXK_UP: - hotkey << wxT("Up" ); - break; - case WXK_DOWN: - hotkey << wxT("Down" ); - break; - case WXK_PAGEUP: - case WXK_PRIOR: - hotkey << wxT("Prior" ); - break; - case WXK_PAGEDOWN: - case WXK_NEXT: - hotkey << wxT("Next" ); - break; - case WXK_LEFT: - hotkey << wxT("Left" ); - break; - case WXK_RIGHT: - hotkey << wxT("Right" ); - break; - case WXK_HOME: - hotkey << wxT("Home" ); - break; - case WXK_END: - hotkey << wxT("End" ); - break; - case WXK_RETURN: - hotkey << wxT("Return" ); - break; - - // if there are any other keys wxGetAccelFromString() may - // return, we should process them here - - default: - if ( code < 127 ) - { - wxString name = wxGTK_CONV_BACK( gdk_keyval_name((guint)code) ); - if ( name ) - { - hotkey << name; - break; - } - } - - wxFAIL_MSG( wxT("unknown keyboard accel") ); - } - - delete accel; - } - - return hotkey; -} - -#endif // wxUSE_ACCEL - diff --git a/src/gtk1/minifram.cpp b/src/gtk1/minifram.cpp deleted file mode 100644 index 8df3e746db..0000000000 --- a/src/gtk1/minifram.cpp +++ /dev/null @@ -1,385 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: minifram.cpp -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/minifram.h" - -#if wxUSE_MINIFRAME - -#include "wx/dcscreen.h" - -#include "gtk/gtk.h" -#include "wx/gtk/win_gtk.h" -#include "wx/gtk/private.h" - -#include -#include -#include - -//----------------------------------------------------------------------------- -// idle system -//----------------------------------------------------------------------------- - -extern void wxapp_install_idle_handler(); -extern bool g_isIdle; - -//----------------------------------------------------------------------------- -// data -//----------------------------------------------------------------------------- - -extern bool g_blockEventsOnDrag; -extern bool g_blockEventsOnScroll; -extern GtkWidget *wxGetRootWindow(); - -//----------------------------------------------------------------------------- -// local functions -//----------------------------------------------------------------------------- - -/* draw XOR rectangle when moving mine frame around */ - -static void DrawFrame( GtkWidget *widget, int x, int y, int w, int h ) -{ - int org_x = 0; - int org_y = 0; - gdk_window_get_origin( widget->window, &org_x, &org_y ); - x += org_x; - y += org_y; - - GdkGC *gc = gdk_gc_new( GDK_ROOT_PARENT() ); - gdk_gc_set_subwindow( gc, GDK_INCLUDE_INFERIORS ); - gdk_gc_set_function( gc, GDK_INVERT ); - - gdk_draw_rectangle( GDK_ROOT_PARENT(), gc, FALSE, x, y, w, h ); - gdk_gc_unref( gc ); -} - -//----------------------------------------------------------------------------- -// "expose_event" of m_mainWidget -//----------------------------------------------------------------------------- - -static void gtk_window_own_expose_callback( GtkWidget *widget, GdkEventExpose *gdk_event, wxFrame *win ) -{ - if (g_isIdle) wxapp_install_idle_handler(); - - if (!win->m_hasVMT) return; - if (gdk_event->count > 0) return; - - GtkPizza *pizza = GTK_PIZZA(widget); - - gtk_draw_shadow( widget->style, - pizza->bin_window, - GTK_STATE_NORMAL, - GTK_SHADOW_OUT, - 0, 0, - win->m_width, win->m_height ); - - if (!win->GetTitle().IsEmpty() && - ((win->GetWindowStyle() & wxCAPTION) || - (win->GetWindowStyle() & wxTINY_CAPTION_HORIZ) || - (win->GetWindowStyle() & wxTINY_CAPTION_VERT))) - { - wxClientDC dc(win); - dc.SetFont( *wxSMALL_FONT ); - int height = dc.GetCharHeight(); - - GdkGC *gc = gdk_gc_new( pizza->bin_window ); - gdk_gc_set_foreground( gc, &widget->style->bg[GTK_STATE_SELECTED] ); - gdk_draw_rectangle( pizza->bin_window, gc, TRUE, - 3, - 3, - win->m_width - 7, - height+1 ); - gdk_gc_unref( gc ); - - // Hack alert - dc.m_window = pizza->bin_window; - dc.SetTextForeground( *wxWHITE ); - dc.DrawText( win->GetTitle(), 6, 3 ); - } -} - -//----------------------------------------------------------------------------- -// "draw" of m_mainWidget -//----------------------------------------------------------------------------- - -#ifndef __WXGTK20__ -static void gtk_window_own_draw_callback( GtkWidget *widget, GdkRectangle *WXUNUSED(rect), wxFrame *win ) -{ - if (g_isIdle) wxapp_install_idle_handler(); - - if (!win->m_hasVMT) return; - - GtkPizza *pizza = GTK_PIZZA(widget); - - gtk_draw_shadow( widget->style, - pizza->bin_window, - GTK_STATE_NORMAL, - GTK_SHADOW_OUT, - 0, 0, - win->m_width, win->m_height ); - - if (!win->m_title.IsEmpty() && - ((win->GetWindowStyle() & wxCAPTION) || - (win->GetWindowStyle() & wxTINY_CAPTION_HORIZ) || - (win->GetWindowStyle() & wxTINY_CAPTION_VERT))) - { - wxClientDC dc(win); - dc.SetFont( *wxSMALL_FONT ); - int height = dc.GetCharHeight(); - - GdkGC *gc = gdk_gc_new( pizza->bin_window ); - gdk_gc_set_foreground( gc, &widget->style->bg[GTK_STATE_SELECTED] ); - gdk_draw_rectangle( pizza->bin_window, gc, TRUE, - 3, - 3, - win->m_width - 7, - height+1 ); - gdk_gc_unref( gc ); - - // Hack alert - dc.m_window = pizza->bin_window; - dc.SetTextForeground( *wxWHITE ); - dc.DrawText( win->GetTitle(), 6, 3 ); - } -} -#endif - -//----------------------------------------------------------------------------- -// "button_press_event" of m_mainWidget -//----------------------------------------------------------------------------- - -static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxMiniFrame *win ) -{ - if (g_isIdle) wxapp_install_idle_handler(); - - if (!win->m_hasVMT) return FALSE; - if (g_blockEventsOnDrag) return TRUE; - if (g_blockEventsOnScroll) return TRUE; - - if (win->m_isDragging) return TRUE; - - GtkPizza *pizza = GTK_PIZZA(widget); - if (gdk_event->window != pizza->bin_window) return TRUE; - - wxClientDC dc(win); - dc.SetFont( *wxSMALL_FONT ); - int height = dc.GetCharHeight() + 1; - - if (gdk_event->y > height) return TRUE; - - gdk_window_raise( win->m_widget->window ); - - gdk_pointer_grab( widget->window, FALSE, - (GdkEventMask) - (GDK_BUTTON_PRESS_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_POINTER_MOTION_MASK | - GDK_POINTER_MOTION_HINT_MASK | - GDK_BUTTON_MOTION_MASK | - GDK_BUTTON1_MOTION_MASK), - (GdkWindow *) NULL, - (GdkCursor *) NULL, - (unsigned int) GDK_CURRENT_TIME ); - - win->m_diffX = (int)gdk_event->x; - win->m_diffY = (int)gdk_event->y; - DrawFrame( widget, 0, 0, win->m_width, win->m_height ); - win->m_oldX = 0; - win->m_oldY = 0; - - win->m_isDragging = TRUE; - - return TRUE; -} - -//----------------------------------------------------------------------------- -// "button_release_event" of m_mainWidget -//----------------------------------------------------------------------------- - -static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxMiniFrame *win ) -{ - if (g_isIdle) wxapp_install_idle_handler(); - - if (!win->m_hasVMT) return FALSE; - if (g_blockEventsOnDrag) return TRUE; - if (g_blockEventsOnScroll) return TRUE; - - if (!win->m_isDragging) return TRUE; - - win->m_isDragging = FALSE; - - int x = (int)gdk_event->x; - int y = (int)gdk_event->y; - - DrawFrame( widget, win->m_oldX, win->m_oldY, win->m_width, win->m_height ); - gdk_pointer_ungrab ( (guint32)GDK_CURRENT_TIME ); - int org_x = 0; - int org_y = 0; - gdk_window_get_origin( widget->window, &org_x, &org_y ); - x += org_x - win->m_diffX; - y += org_y - win->m_diffY; - win->m_x = x; - win->m_y = y; - gtk_widget_set_uposition( win->m_widget, x, y ); - - return TRUE; -} - -//----------------------------------------------------------------------------- -// "motion_notify_event" of m_mainWidget -//----------------------------------------------------------------------------- - -static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_event, wxMiniFrame *win ) -{ - if (g_isIdle) wxapp_install_idle_handler(); - - if (!win->m_hasVMT) return FALSE; - if (g_blockEventsOnDrag) return TRUE; - if (g_blockEventsOnScroll) return TRUE; - - if (!win->m_isDragging) return TRUE; - - if (gdk_event->is_hint) - { - int x = 0; - int y = 0; - GdkModifierType state; - gdk_window_get_pointer(gdk_event->window, &x, &y, &state); - gdk_event->x = x; - gdk_event->y = y; - gdk_event->state = state; - } - - DrawFrame( widget, win->m_oldX, win->m_oldY, win->m_width, win->m_height ); - win->m_oldX = (int)gdk_event->x - win->m_diffX; - win->m_oldY = (int)gdk_event->y - win->m_diffY; - DrawFrame( widget, win->m_oldX, win->m_oldY, win->m_width, win->m_height ); - - return TRUE; -} - -//----------------------------------------------------------------------------- -// "clicked" of X system button -//----------------------------------------------------------------------------- - -static void gtk_button_clicked_callback( GtkWidget *WXUNUSED(widget), wxMiniFrame *mf ) -{ - if (g_isIdle) wxapp_install_idle_handler(); - - mf->Close(); -} - -//----------------------------------------------------------------------------- -// wxMiniFrame -//----------------------------------------------------------------------------- - -static const char *cross_xpm[] = { -/* columns rows colors chars-per-pixel */ -"5 5 16 1", -" c Gray0", -". c #bf0000", -"X c #00bf00", -"o c #bfbf00", -"O c #0000bf", -"+ c #bf00bf", -"@ c #00bfbf", -"# c None", -"$ c #808080", -"% c Red", -"& c Green", -"* c Yellow", -"= c Blue", -"- c Magenta", -"; c Cyan", -": c Gray100", -/* pixels */ -" ### ", -"# # #", -"## ##", -"# # #", -" ### ", -}; - -IMPLEMENT_DYNAMIC_CLASS(wxMiniFrame,wxFrame) - -bool wxMiniFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title, - const wxPoint &pos, const wxSize &size, - long style, const wxString &name ) -{ - style = style | wxCAPTION; - - if ((style & wxCAPTION) || (style & wxTINY_CAPTION_HORIZ) || (style & wxTINY_CAPTION_VERT)) - m_miniTitle = 13; - - m_miniEdge = 3; - m_isDragging = FALSE; - m_oldX = -1; - m_oldY = -1; - m_diffX = 0; - m_diffY = 0; - - wxFrame::Create( parent, id, title, pos, size, style, name ); - - if (m_parent && (GTK_IS_WINDOW(m_parent->m_widget))) - { - gtk_window_set_transient_for( GTK_WINDOW(m_widget), GTK_WINDOW(m_parent->m_widget) ); - } - - if ((style & wxSYSTEM_MENU) && - ((style & wxCAPTION) || (style & wxTINY_CAPTION_HORIZ) || (style & wxTINY_CAPTION_VERT))) - { - GdkBitmap *mask = (GdkBitmap*) NULL; - GdkPixmap *pixmap = gdk_pixmap_create_from_xpm_d - ( - wxGetRootWindow()->window, - &mask, - NULL, - (char **)cross_xpm - ); - - GtkWidget *pw = gtk_pixmap_new( pixmap, mask ); - gdk_bitmap_unref( mask ); - gdk_pixmap_unref( pixmap ); - gtk_widget_show( pw ); - - GtkWidget *close_button = gtk_button_new(); - gtk_container_add( GTK_CONTAINER(close_button), pw ); - - gtk_pizza_put( GTK_PIZZA(m_mainWidget), - close_button, - size.x-16, 4, 11, 11 ); - - gtk_widget_show( close_button ); - - gtk_signal_connect( GTK_OBJECT(close_button), "clicked", - GTK_SIGNAL_FUNC(gtk_button_clicked_callback), (gpointer*)this ); - } - - /* these are called when the borders are drawn */ - gtk_signal_connect( GTK_OBJECT(m_mainWidget), "expose_event", - GTK_SIGNAL_FUNC(gtk_window_own_expose_callback), (gpointer)this ); - -#ifndef __WXGTK20__ - gtk_signal_connect( GTK_OBJECT(m_mainWidget), "draw", - GTK_SIGNAL_FUNC(gtk_window_own_draw_callback), (gpointer)this ); -#endif - - /* these are required for dragging the mini frame around */ - gtk_signal_connect( GTK_OBJECT(m_mainWidget), "button_press_event", - GTK_SIGNAL_FUNC(gtk_window_button_press_callback), (gpointer)this ); - - gtk_signal_connect( GTK_OBJECT(m_mainWidget), "button_release_event", - GTK_SIGNAL_FUNC(gtk_window_button_release_callback), (gpointer)this ); - - gtk_signal_connect( GTK_OBJECT(m_mainWidget), "motion_notify_event", - GTK_SIGNAL_FUNC(gtk_window_motion_notify_callback), (gpointer)this ); - - return TRUE; -} - -#endif diff --git a/src/gtk1/notebook.cpp b/src/gtk1/notebook.cpp deleted file mode 100644 index 8668047196..0000000000 --- a/src/gtk1/notebook.cpp +++ /dev/null @@ -1,705 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: notebook.cpp -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling, Vadim Zeitlin -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/notebook.h" - -#if wxUSE_NOTEBOOK - -#include "wx/panel.h" -#include "wx/utils.h" -#include "wx/imaglist.h" -#include "wx/intl.h" -#include "wx/log.h" - -#include "wx/gtk/private.h" -#include "wx/gtk/win_gtk.h" - -#include - -// ---------------------------------------------------------------------------- -// events -// ---------------------------------------------------------------------------- - -DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED) -DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING) - -//----------------------------------------------------------------------------- -// idle system -//----------------------------------------------------------------------------- - -extern void wxapp_install_idle_handler(); -extern bool g_isIdle; - -//----------------------------------------------------------------------------- -// data -//----------------------------------------------------------------------------- - -extern bool g_blockEventsOnDrag; - -//----------------------------------------------------------------------------- -// wxGtkNotebookPage -//----------------------------------------------------------------------------- - -// VZ: this is rather ugly as we keep the pages themselves in an array (it -// allows us to have quite a few functions implemented in the base class) -// but the page data is kept in a separate list, so we must maintain them -// in sync manually... of course, the list had been there before the base -// class which explains it but it still would be nice to do something -// about this one day - -class wxGtkNotebookPage: public wxObject -{ -public: - wxGtkNotebookPage() - { - m_image = -1; - m_page = (GtkNotebookPage *) NULL; - m_box = (GtkWidget *) NULL; - } - - wxString m_text; - int m_image; - GtkNotebookPage *m_page; - GtkLabel *m_label; - GtkWidget *m_box; // in which the label and image are packed -}; - -#include "wx/listimpl.cpp" -WX_DEFINE_LIST(wxGtkNotebookPagesList); - -//----------------------------------------------------------------------------- -// "switch_page" -//----------------------------------------------------------------------------- - -static void gtk_notebook_page_change_callback(GtkNotebook *WXUNUSED(widget), - GtkNotebookPage *WXUNUSED(page), - gint page, - wxNotebook *notebook ) -{ - // are you trying to call SetSelection() from a notebook event handler? - // you shouldn't! - wxCHECK_RET( !notebook->m_inSwitchPage, - _T("gtk_notebook_page_change_callback reentered") ); - - notebook->m_inSwitchPage = TRUE; - if (g_isIdle) - wxapp_install_idle_handler(); - - int old = notebook->GetSelection(); - - wxNotebookEvent eventChanging( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, - notebook->GetId(), page, old ); - eventChanging.SetEventObject( notebook ); - - if ( (notebook->GetEventHandler()->ProcessEvent(eventChanging)) && - !eventChanging.IsAllowed() ) - { - /* program doesn't allow the page change */ - gtk_signal_emit_stop_by_name( GTK_OBJECT(notebook->m_widget), - "switch_page" ); - } - else // change allowed - { - // make wxNotebook::GetSelection() return the correct (i.e. consistent - // with wxNotebookEvent::GetSelection()) value even though the page is - // not really changed in GTK+ - notebook->m_selection = page; - - wxNotebookEvent eventChanged( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, - notebook->GetId(), page, old ); - eventChanged.SetEventObject( notebook ); - notebook->GetEventHandler()->ProcessEvent( eventChanged ); - } - - notebook->m_inSwitchPage = FALSE; -} - -//----------------------------------------------------------------------------- -// "size_allocate" -//----------------------------------------------------------------------------- - -static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxWindow *win ) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - - if ((win->m_x == alloc->x) && - (win->m_y == alloc->y) && - (win->m_width == alloc->width) && - (win->m_height == alloc->height)) - { - return; - } - - win->SetSize( alloc->x, alloc->y, alloc->width, alloc->height ); - - /* GTK 1.2 up to version 1.2.5 is broken so that we have to call allocate - here in order to make repositioning after resizing to take effect. */ - if ((gtk_major_version == 1) && - (gtk_minor_version == 2) && - (gtk_micro_version < 6) && - (win->m_wxwindow) && - (GTK_WIDGET_REALIZED(win->m_wxwindow))) - { - gtk_widget_size_allocate( win->m_wxwindow, alloc ); - } -} - -//----------------------------------------------------------------------------- -// "realize" from m_widget -//----------------------------------------------------------------------------- - -static gint -gtk_notebook_realized_callback( GtkWidget * WXUNUSED(widget), wxWindow *win ) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - - /* GTK 1.2 up to version 1.2.5 is broken so that we have to call a queue_resize - here in order to make repositioning before showing to take effect. */ - gtk_widget_queue_resize( win->m_widget ); - - return FALSE; -} - -//----------------------------------------------------------------------------- -// "key_press_event" -//----------------------------------------------------------------------------- - -static gint gtk_notebook_key_press_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxNotebook *win ) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - - if (!win->m_hasVMT) return FALSE; - if (g_blockEventsOnDrag) return FALSE; - - // win is a control: tab can be propagated up - if ((gdk_event->keyval == GDK_Tab) || (gdk_event->keyval == GDK_ISO_Left_Tab)) - { - int sel = win->GetSelection(); - if (sel == -1) - return TRUE; - - wxGtkNotebookPage *nb_page = win->GetNotebookPage(sel); - wxCHECK_MSG( nb_page, FALSE, _T("invalid selection in wxNotebook") ); - - wxNavigationKeyEvent event; - event.SetEventObject( win ); - /* GDK reports GDK_ISO_Left_Tab for SHIFT-TAB */ - event.SetDirection( (gdk_event->keyval == GDK_Tab) ); - /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */ - event.SetWindowChange( (gdk_event->state & GDK_CONTROL_MASK) ); - event.SetCurrentFocus( win ); - - wxNotebookPage *client = win->GetPage(sel); - if ( !client->GetEventHandler()->ProcessEvent( event ) ) - { - client->SetFocus(); - } - - gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" ); - return TRUE; - } - - return FALSE; -} - -//----------------------------------------------------------------------------- -// InsertChild callback for wxNotebook -//----------------------------------------------------------------------------- - -static void wxInsertChildInNotebook( wxNotebook* WXUNUSED(parent), wxWindow* WXUNUSED(child) ) -{ - /* we don't do anything here but pray */ -} - -//----------------------------------------------------------------------------- -// wxNotebook -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxNotebook,wxControl) - -BEGIN_EVENT_TABLE(wxNotebook, wxControl) - EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey) -END_EVENT_TABLE() - -void wxNotebook::Init() -{ - m_padding = 0; - m_inSwitchPage = FALSE; - - m_imageList = (wxImageList *) NULL; - m_pagesData.DeleteContents( TRUE ); - m_selection = -1; - m_themeEnabled = TRUE; -} - -wxNotebook::wxNotebook() -{ - Init(); -} - -wxNotebook::wxNotebook( wxWindow *parent, wxWindowID id, - const wxPoint& pos, const wxSize& size, - long style, const wxString& name ) -{ - Init(); - Create( parent, id, pos, size, style, name ); -} - -wxNotebook::~wxNotebook() -{ - /* don't generate change page events any more */ - gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget), - GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback), (gpointer) this ); - - DeleteAllPages(); -} - -bool wxNotebook::Create(wxWindow *parent, wxWindowID id, - const wxPoint& pos, const wxSize& size, - long style, const wxString& name ) -{ - m_needParent = TRUE; - m_acceptsFocus = TRUE; - m_insertCallback = (wxInsertChildFunction)wxInsertChildInNotebook; - - if (!PreCreation( parent, pos, size ) || - !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) - { - wxFAIL_MSG( wxT("wxNoteBook creation failed") ); - return FALSE; - } - - - m_widget = gtk_notebook_new(); - - gtk_notebook_set_scrollable( GTK_NOTEBOOK(m_widget), 1 ); - - gtk_signal_connect( GTK_OBJECT(m_widget), "switch_page", - GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback), (gpointer)this ); - - m_parent->DoAddChild( this ); - - if (m_windowStyle & wxNB_RIGHT) - gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget), GTK_POS_RIGHT ); - if (m_windowStyle & wxNB_LEFT) - gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget), GTK_POS_LEFT ); - if (m_windowStyle & wxNB_BOTTOM) - gtk_notebook_set_tab_pos( GTK_NOTEBOOK(m_widget), GTK_POS_BOTTOM ); - - gtk_signal_connect( GTK_OBJECT(m_widget), "key_press_event", - GTK_SIGNAL_FUNC(gtk_notebook_key_press_callback), (gpointer)this ); - - PostCreation(); - - SetFont( parent->GetFont() ); - - gtk_signal_connect( GTK_OBJECT(m_widget), "realize", - GTK_SIGNAL_FUNC(gtk_notebook_realized_callback), (gpointer) this ); - - Show( TRUE ); - - return TRUE; -} - -int wxNotebook::GetSelection() const -{ - wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid notebook") ); - - if ( m_selection == -1 ) - { - GList *nb_pages = GTK_NOTEBOOK(m_widget)->children; - - if (g_list_length(nb_pages) != 0) - { - GtkNotebook *notebook = GTK_NOTEBOOK(m_widget); - - gpointer cur = notebook->cur_page; - if ( cur != NULL ) - { - wxConstCast(this, wxNotebook)->m_selection = - g_list_index( nb_pages, cur ); - } - } - } - - return m_selection; -} - -wxString wxNotebook::GetPageText( int page ) const -{ - wxCHECK_MSG( m_widget != NULL, wxT(""), wxT("invalid notebook") ); - - wxGtkNotebookPage* nb_page = GetNotebookPage(page); - if (nb_page) - return nb_page->m_text; - else - return wxT(""); -} - -int wxNotebook::GetPageImage( int page ) const -{ - wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid notebook") ); - - wxGtkNotebookPage* nb_page = GetNotebookPage(page); - if (nb_page) - return nb_page->m_image; - else - return -1; -} - -wxGtkNotebookPage* wxNotebook::GetNotebookPage( int page ) const -{ - wxCHECK_MSG( m_widget != NULL, (wxGtkNotebookPage*) NULL, wxT("invalid notebook") ); - - wxCHECK_MSG( page < (int)m_pagesData.GetCount(), (wxGtkNotebookPage*) NULL, wxT("invalid notebook index") ); - - return m_pagesData.Item(page)->GetData(); -} - -int wxNotebook::SetSelection( int page ) -{ - wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid notebook") ); - - wxCHECK_MSG( page >= 0 && page < (int)m_pagesData.GetCount(), -1, wxT("invalid notebook index") ); - - int selOld = GetSelection(); - - // cache the selection - m_selection = page; - gtk_notebook_set_page( GTK_NOTEBOOK(m_widget), page ); - - wxNotebookPage *client = GetPage(page); - if ( client ) - client->SetFocus(); - - return selOld; -} - -bool wxNotebook::SetPageText( int page, const wxString &text ) -{ - wxCHECK_MSG( m_widget != NULL, FALSE, wxT("invalid notebook") ); - - wxGtkNotebookPage* nb_page = GetNotebookPage(page); - - wxCHECK_MSG( nb_page, FALSE, wxT("SetPageText: invalid page index") ); - - nb_page->m_text = text; - - gtk_label_set( nb_page->m_label, wxGTK_CONV( nb_page->m_text ) ); - - return TRUE; -} - -bool wxNotebook::SetPageImage( int page, int image ) -{ - /* HvdH 28-12-98: now it works, but it's a bit of a kludge */ - - wxGtkNotebookPage* nb_page = GetNotebookPage(page); - - if (!nb_page) return FALSE; - - /* Optimization posibility: return immediately if image unchanged. - * Not enabled because it may break existing (stupid) code that - * manipulates the imagelist to cycle images */ - - /* if (image == nb_page->m_image) return TRUE; */ - - /* For different cases: - 1) no image -> no image - 2) image -> no image - 3) no image -> image - 4) image -> image */ - - if (image == -1 && nb_page->m_image == -1) - return TRUE; /* Case 1): Nothing to do. */ - - GtkWidget *pixmapwid = (GtkWidget*) NULL; - - if (nb_page->m_image != -1) - { - /* Case 2) or 4). There is already an image in the gtkhbox. Let's find it */ - - GList *child = gtk_container_children(GTK_CONTAINER(nb_page->m_box)); - while (child) - { - if (GTK_IS_PIXMAP(child->data)) - { - pixmapwid = GTK_WIDGET(child->data); - break; - } - child = child->next; - } - - /* We should have the pixmap widget now */ - wxASSERT(pixmapwid != NULL); - - if (image == -1) - { - /* If there's no new widget, just remove the old from the box */ - gtk_container_remove(GTK_CONTAINER(nb_page->m_box), pixmapwid); - nb_page->m_image = -1; - - return TRUE; /* Case 2) */ - } - } - - /* Only cases 3) and 4) left */ - wxASSERT( m_imageList != NULL ); /* Just in case */ - - /* Construct the new pixmap */ - const wxBitmap *bmp = m_imageList->GetBitmap(image); - GdkPixmap *pixmap = bmp->GetPixmap(); - GdkBitmap *mask = (GdkBitmap*) NULL; - if ( bmp->GetMask() ) - { - mask = bmp->GetMask()->GetBitmap(); - } - - if (pixmapwid == NULL) - { - /* Case 3) No old pixmap. Create a new one and prepend it to the hbox */ - pixmapwid = gtk_pixmap_new (pixmap, mask ); - - /* CHECKME: Are these pack flags okay? */ - gtk_box_pack_start(GTK_BOX(nb_page->m_box), pixmapwid, FALSE, FALSE, m_padding); - gtk_widget_show(pixmapwid); - } - else - { - /* Case 4) Simply replace the pixmap */ - gtk_pixmap_set(GTK_PIXMAP(pixmapwid), pixmap, mask); - } - - nb_page->m_image = image; - - return TRUE; -} - -void wxNotebook::SetPageSize( const wxSize &WXUNUSED(size) ) -{ - wxFAIL_MSG( wxT("wxNotebook::SetPageSize not implemented") ); -} - -void wxNotebook::SetPadding( const wxSize &padding ) -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid notebook") ); - - m_padding = padding.GetWidth(); - - int i; - for (i=0; im_image != -1) - { - // gtk_box_set_child_packing sets padding on BOTH sides - // icon provides left padding, label provides center and right - int image = nb_page->m_image; - SetPageImage(i,-1); - SetPageImage(i,image); - } - wxASSERT(nb_page->m_label); - gtk_box_set_child_packing(GTK_BOX(nb_page->m_box), - GTK_WIDGET(nb_page->m_label), - FALSE, FALSE, m_padding, GTK_PACK_END); - } -} - -void wxNotebook::SetTabSize(const wxSize& WXUNUSED(sz)) -{ - wxFAIL_MSG( wxT("wxNotebook::SetTabSize not implemented") ); -} - -bool wxNotebook::DeleteAllPages() -{ - wxCHECK_MSG( m_widget != NULL, FALSE, wxT("invalid notebook") ); - - while (m_pagesData.GetCount() > 0) - DeletePage( m_pagesData.GetCount()-1 ); - - wxASSERT_MSG( GetPageCount() == 0, _T("all pages must have been deleted") ); - - return wxNotebookBase::DeleteAllPages(); -} - -bool wxNotebook::DeletePage( int page ) -{ - // GTK sets GtkNotebook.cur_page to NULL before sending the switch page - // event so we have to store the selection internally - if ( m_selection == -1 ) - { - m_selection = GetSelection(); - if ( m_selection == (int)m_pagesData.GetCount() - 1 ) - { - // the index will become invalid after the page is deleted - m_selection = -1; - } - } - - // it will call our DoRemovePage() to do the real work - return wxNotebookBase::DeletePage(page); -} - -wxNotebookPage *wxNotebook::DoRemovePage( int page ) -{ - wxNotebookPage *client = wxNotebookBase::DoRemovePage(page); - if ( !client ) - return NULL; - - gtk_widget_ref( client->m_widget ); - gtk_widget_unrealize( client->m_widget ); - gtk_widget_unparent( client->m_widget ); - - gtk_notebook_remove_page( GTK_NOTEBOOK(m_widget), page ); - - m_pagesData.DeleteObject(GetNotebookPage(page)); - - return client; -} - -bool wxNotebook::InsertPage( int position, - wxNotebookPage* win, - const wxString& text, - bool select, - int imageId ) -{ - wxCHECK_MSG( m_widget != NULL, FALSE, wxT("invalid notebook") ); - - wxCHECK_MSG( win->GetParent() == this, FALSE, - wxT("Can't add a page whose parent is not the notebook!") ); - - wxCHECK_MSG( position >= 0 && position <= GetPageCount(), FALSE, - _T("invalid page index in wxNotebookPage::InsertPage()") ); - - /* don't receive switch page during addition */ - gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget), - GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback), (gpointer) this ); - - if (m_themeEnabled) - win->SetThemeEnabled(TRUE); - - GtkNotebook *notebook = GTK_NOTEBOOK(m_widget); - - wxGtkNotebookPage *nb_page = new wxGtkNotebookPage(); - - if ( position == GetPageCount() ) - m_pagesData.Append( nb_page ); - else - m_pagesData.Insert( m_pagesData.Item( position ), nb_page ); - - m_pages.Insert(win, position); - - nb_page->m_box = gtk_hbox_new( FALSE, 1 ); - gtk_container_border_width( GTK_CONTAINER(nb_page->m_box), 2 ); - - gtk_signal_connect( GTK_OBJECT(win->m_widget), "size_allocate", - GTK_SIGNAL_FUNC(gtk_page_size_callback), (gpointer)win ); - - if (position < 0) - gtk_notebook_append_page( notebook, win->m_widget, nb_page->m_box ); - else - gtk_notebook_insert_page( notebook, win->m_widget, nb_page->m_box, position ); - - nb_page->m_page = (GtkNotebookPage*) g_list_last(notebook->children)->data; - - /* set the label image */ - nb_page->m_image = imageId; - - if (imageId != -1) - { - wxASSERT( m_imageList != NULL ); - - const wxBitmap *bmp = m_imageList->GetBitmap(imageId); - GdkPixmap *pixmap = bmp->GetPixmap(); - GdkBitmap *mask = (GdkBitmap*) NULL; - if ( bmp->GetMask() ) - { - mask = bmp->GetMask()->GetBitmap(); - } - - GtkWidget *pixmapwid = gtk_pixmap_new (pixmap, mask ); - - gtk_box_pack_start(GTK_BOX(nb_page->m_box), pixmapwid, FALSE, FALSE, m_padding); - - gtk_widget_show(pixmapwid); - } - - /* set the label text */ - nb_page->m_text = text; - if (nb_page->m_text.IsEmpty()) nb_page->m_text = wxT(""); - - nb_page->m_label = GTK_LABEL( gtk_label_new(wxGTK_CONV(nb_page->m_text)) ); - gtk_box_pack_end( GTK_BOX(nb_page->m_box), GTK_WIDGET(nb_page->m_label), FALSE, FALSE, m_padding ); - - /* show the label */ - gtk_widget_show( GTK_WIDGET(nb_page->m_label) ); - if (select && (m_pagesData.GetCount() > 1)) - { - if (position < 0) - SetSelection( GetPageCount()-1 ); - else - SetSelection( position ); - } - - gtk_signal_connect( GTK_OBJECT(m_widget), "switch_page", - GTK_SIGNAL_FUNC(gtk_notebook_page_change_callback), (gpointer)this ); - - return TRUE; -} - -void wxNotebook::OnNavigationKey(wxNavigationKeyEvent& event) -{ - if (event.IsWindowChange()) - AdvanceSelection( event.GetDirection() ); - else - event.Skip(); -} - -#if wxUSE_CONSTRAINTS - -// override these 2 functions to do nothing: everything is done in OnSize -void wxNotebook::SetConstraintSizes( bool WXUNUSED(recurse) ) -{ - // don't set the sizes of the pages - their correct size is not yet known - wxControl::SetConstraintSizes(FALSE); -} - -bool wxNotebook::DoPhase( int WXUNUSED(nPhase) ) -{ - return TRUE; -} - -#endif - -void wxNotebook::ApplyWidgetStyle() -{ - // TODO, font for labels etc - - SetWidgetStyle(); - gtk_widget_set_style( m_widget, m_widgetStyle ); -} - -bool wxNotebook::IsOwnGtkWindow( GdkWindow *window ) -{ - return ((m_widget->window == window) || - (NOTEBOOK_PANEL(m_widget) == window)); -} - -//----------------------------------------------------------------------------- -// wxNotebookEvent -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxNotifyEvent) - -#endif diff --git a/src/gtk1/pen.cpp b/src/gtk1/pen.cpp deleted file mode 100644 index 94ee5a43bf..0000000000 --- a/src/gtk1/pen.cpp +++ /dev/null @@ -1,203 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: pen.cpp -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/pen.h" - -#include - -//----------------------------------------------------------------------------- -// wxPen -//----------------------------------------------------------------------------- - -class wxPenRefData: public wxObjectRefData -{ -public: - wxPenRefData() - { - m_width = 1; - m_style = wxSOLID; - m_joinStyle = wxJOIN_ROUND; - m_capStyle = wxCAP_ROUND; - m_dash = (wxGTKDash*) NULL; - m_countDashes = 0; - } - - wxPenRefData( const wxPenRefData& data ) - : wxObjectRefData() - { - m_style = data.m_style; - m_width = data.m_width; - m_joinStyle = data.m_joinStyle; - m_capStyle = data.m_capStyle; - m_colour = data.m_colour; - m_countDashes = data.m_countDashes; -/* - if (data.m_dash) TODO - m_dash = new -*/ - m_dash = data.m_dash; - } - - bool operator == (const wxPenRefData& data) const - { - return (m_style == data.m_style && - m_width == data.m_width && - m_joinStyle == data.m_joinStyle && - m_capStyle == data.m_capStyle && - m_colour == data.m_colour); - } - - int m_width; - int m_style; - int m_joinStyle; - int m_capStyle; - wxColour m_colour; - int m_countDashes; - wxGTKDash *m_dash; -}; - -//----------------------------------------------------------------------------- - -#define M_PENDATA ((wxPenRefData *)m_refData) - -IMPLEMENT_DYNAMIC_CLASS(wxPen,wxGDIObject) - -wxPen::wxPen( const wxColour &colour, int width, int style ) -{ - m_refData = new wxPenRefData(); - M_PENDATA->m_width = width; - M_PENDATA->m_style = style; - M_PENDATA->m_colour = colour; -} - -wxPen::~wxPen() -{ - // m_refData unrefed in ~wxObject -} - -wxObjectRefData *wxPen::CreateRefData() const -{ - return new wxPenRefData; -} - -wxObjectRefData *wxPen::CloneRefData(const wxObjectRefData *data) const -{ - return new wxPenRefData(*(wxPenRefData *)data); -} - -bool wxPen::operator == ( const wxPen& pen ) const -{ - if (m_refData == pen.m_refData) return TRUE; - - if (!m_refData || !pen.m_refData) return FALSE; - - return ( *(wxPenRefData*)m_refData == *(wxPenRefData*)pen.m_refData ); -} - -void wxPen::SetColour( const wxColour &colour ) -{ - AllocExclusive(); - - M_PENDATA->m_colour = colour; -} - -void wxPen::SetDashes( int number_of_dashes, const wxDash *dash ) -{ - AllocExclusive(); - - M_PENDATA->m_countDashes = number_of_dashes; - M_PENDATA->m_dash = (wxGTKDash *)dash; /* TODO */ -} - -void wxPen::SetColour( int red, int green, int blue ) -{ - AllocExclusive(); - - M_PENDATA->m_colour.Set( red, green, blue ); -} - -void wxPen::SetCap( int capStyle ) -{ - AllocExclusive(); - - M_PENDATA->m_capStyle = capStyle; -} - -void wxPen::SetJoin( int joinStyle ) -{ - AllocExclusive(); - - M_PENDATA->m_joinStyle = joinStyle; -} - -void wxPen::SetStyle( int style ) -{ - AllocExclusive(); - - M_PENDATA->m_style = style; -} - -void wxPen::SetWidth( int width ) -{ - AllocExclusive(); - - M_PENDATA->m_width = width; -} - -int wxPen::GetDashes( wxDash **ptr ) const -{ - *ptr = (M_PENDATA ? (wxDash*)M_PENDATA->m_dash : (wxDash*) NULL); - return (M_PENDATA ? M_PENDATA->m_countDashes : 0); -} - -int wxPen::GetDashCount() const -{ - return (M_PENDATA->m_countDashes); -} - -wxDash* wxPen::GetDash() const -{ - return (wxDash*)M_PENDATA->m_dash; -} - -int wxPen::GetCap() const -{ - wxCHECK_MSG( Ok(), -1, wxT("invalid pen") ); - - return M_PENDATA->m_capStyle; -} - -int wxPen::GetJoin() const -{ - wxCHECK_MSG( Ok(), -1, wxT("invalid pen") ); - - return M_PENDATA->m_joinStyle; -} - -int wxPen::GetStyle() const -{ - wxCHECK_MSG( Ok(), -1, wxT("invalid pen") ); - - return M_PENDATA->m_style; -} - -int wxPen::GetWidth() const -{ - wxCHECK_MSG( Ok(), -1, wxT("invalid pen") ); - - return M_PENDATA->m_width; -} - -wxColour &wxPen::GetColour() const -{ - wxCHECK_MSG( Ok(), wxNullColour, wxT("invalid pen") ); - - return M_PENDATA->m_colour; -} - diff --git a/src/gtk1/popupwin.cpp b/src/gtk1/popupwin.cpp deleted file mode 100644 index 3a393f86a4..0000000000 --- a/src/gtk1/popupwin.cpp +++ /dev/null @@ -1,359 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: popupwin.cpp -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/defs.h" - -#if wxUSE_POPUPWIN - -#include "wx/popupwin.h" -#include "wx/frame.h" -#include "wx/app.h" -#include "wx/cursor.h" - -#include -#include -#include - -#include "wx/gtk/win_gtk.h" - -//----------------------------------------------------------------------------- -// idle system -//----------------------------------------------------------------------------- - -extern void wxapp_install_idle_handler(); -extern bool g_isIdle; - -//----------------------------------------------------------------------------- -// "focus" from m_window -//----------------------------------------------------------------------------- - -static gint gtk_dialog_focus_callback( GtkWidget *widget, GtkDirectionType WXUNUSED(d), wxWindow *WXUNUSED(win) ) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - - // This disables GTK's tab traversal - gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "focus" ); - return TRUE; -} - -//----------------------------------------------------------------------------- -// "delete_event" -//----------------------------------------------------------------------------- - -bool gtk_dialog_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxPopupWindow *win ) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - - if (win->IsEnabled()) - win->Close(); - - return TRUE; -} - -//----------------------------------------------------------------------------- -// "size_allocate" -//----------------------------------------------------------------------------- - -static void gtk_dialog_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxPopupWindow *win ) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - - if (!win->m_hasVMT) return; - - if ((win->m_width != alloc->width) || (win->m_height != alloc->height)) - { - win->m_width = alloc->width; - win->m_height = alloc->height; - win->GtkUpdateSize(); - } -} - -//----------------------------------------------------------------------------- -// "realize" from m_widget -//----------------------------------------------------------------------------- - -/* we cannot MWM hints and icons before the widget has been realized, - so we do this directly after realization */ - -static gint -gtk_dialog_realized_callback( GtkWidget * WXUNUSED(widget), wxPopupWindow *win ) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - - /* all this is for Motif Window Manager "hints" and is supposed to be - recognized by other WM as well. not tested. */ - long decor = (long) GDK_DECOR_BORDER; - long func = (long) GDK_FUNC_MOVE ; - - gdk_window_set_decorations( win->m_widget->window, (GdkWMDecoration)decor); - gdk_window_set_functions( win->m_widget->window, (GdkWMFunction)func); - - /* GTK's shrinking/growing policy */ - if ((win->GetWindowStyle() & wxRESIZE_BORDER) == 0) - gtk_window_set_policy(GTK_WINDOW(win->m_widget), 0, 0, 1); - else - gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1); - - return FALSE; -} - -//----------------------------------------------------------------------------- -// InsertChild for wxPopupWindow -//----------------------------------------------------------------------------- - -/* Callback for wxFrame. This very strange beast has to be used because - * C++ has no virtual methods in a constructor. We have to emulate a - * virtual function here as wxWindows requires different ways to insert - * a child in container classes. */ - -static void wxInsertChildInDialog( wxPopupWindow* parent, wxWindow* child ) -{ - gtk_pizza_put( GTK_PIZZA(parent->m_wxwindow), - GTK_WIDGET(child->m_widget), - child->m_x, - child->m_y, - child->m_width, - child->m_height ); - - if (parent->HasFlag(wxTAB_TRAVERSAL)) - { - /* we now allow a window to get the focus as long as it - doesn't have any children. */ - GTK_WIDGET_UNSET_FLAGS( parent->m_wxwindow, GTK_CAN_FOCUS ); - } -} - -//----------------------------------------------------------------------------- -// wxPopupWindow -//----------------------------------------------------------------------------- - -BEGIN_EVENT_TABLE(wxPopupWindow,wxPopupWindowBase) -#ifdef __WXUNIVERSAL__ - EVT_SIZE(wxPopupWindow::OnSize) -#endif -END_EVENT_TABLE() - -IMPLEMENT_DYNAMIC_CLASS(wxPopupWindow, wxWindow) - -wxPopupWindow::~wxPopupWindow() -{ - if (GTK_WIDGET_HAS_GRAB(m_widget)) - gtk_grab_remove( m_widget ); -} - -bool wxPopupWindow::Create( wxWindow *parent, int style ) -{ - m_needParent = FALSE; - - if (!PreCreation( parent, wxDefaultPosition, wxDefaultSize ) || - !CreateBase( parent, -1, wxDefaultPosition, wxDefaultSize, style, wxDefaultValidator, wxT("popup") )) - { - wxFAIL_MSG( wxT("wxPopupWindow creation failed") ); - return FALSE; - } - - // All dialogs should really have this style - m_windowStyle |= wxTAB_TRAVERSAL; - - m_insertCallback = (wxInsertChildFunction) wxInsertChildInDialog; - - m_widget = gtk_window_new( GTK_WINDOW_POPUP ); - - if ((m_parent) && (GTK_IS_WINDOW(m_parent->m_widget))) - gtk_window_set_transient_for( GTK_WINDOW(m_widget), GTK_WINDOW(m_parent->m_widget) ); - - GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS ); - - gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event", - GTK_SIGNAL_FUNC(gtk_dialog_delete_callback), (gpointer)this ); - - m_wxwindow = gtk_pizza_new(); - gtk_widget_show( m_wxwindow ); - GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); - - gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow ); - - if (m_parent) m_parent->AddChild( this ); - - PostCreation(); - - /* we cannot set MWM hints before the widget has - been realized, so we do this directly after realization */ - gtk_signal_connect( GTK_OBJECT(m_widget), "realize", - GTK_SIGNAL_FUNC(gtk_dialog_realized_callback), (gpointer) this ); - - /* the user resized the frame by dragging etc. */ - gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", - GTK_SIGNAL_FUNC(gtk_dialog_size_callback), (gpointer)this ); - - /* disable native tab traversal */ - gtk_signal_connect( GTK_OBJECT(m_widget), "focus", - GTK_SIGNAL_FUNC(gtk_dialog_focus_callback), (gpointer)this ); - - return TRUE; -} - -void wxPopupWindow::DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y), int WXUNUSED(width), int WXUNUSED(height) ) -{ - wxFAIL_MSG( wxT("DoMoveWindow called for wxPopupWindow") ); -} - -void wxPopupWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags ) -{ - wxASSERT_MSG( (m_widget != NULL), wxT("invalid dialog") ); - wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid dialog") ); - - if (m_resizing) return; /* I don't like recursions */ - m_resizing = TRUE; - - int old_x = m_x; - int old_y = m_y; - - int old_width = m_width; - int old_height = m_height; - - if ((sizeFlags & wxSIZE_ALLOW_MINUS_ONE) == 0) - { - if (x != -1) m_x = x; - if (y != -1) m_y = y; - if (width != -1) m_width = width; - if (height != -1) m_height = height; - } - else - { - m_x = x; - m_y = y; - m_width = width; - m_height = height; - } - -/* - if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH) - { - if (width == -1) m_width = 80; - } - - if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT) - { - if (height == -1) m_height = 26; - } -*/ - - int minWidth = GetMinWidth(), - minHeight = GetMinHeight(), - maxWidth = GetMaxWidth(), - maxHeight = GetMaxHeight(); - - if ((minWidth != -1) && (m_width < minWidth)) m_width = minWidth; - if ((minHeight != -1) && (m_height < minHeight)) m_height = minHeight; - if ((maxWidth != -1) && (m_width > maxWidth)) m_width = maxWidth; - if ((maxHeight != -1) && (m_height > maxHeight)) m_height = maxHeight; - - if ((m_x != -1) || (m_y != -1)) - { - if ((m_x != old_x) || (m_y != old_y)) - { - /* we set the position here and when showing the dialog - for the first time in idle time */ - gtk_widget_set_uposition( m_widget, m_x, m_y ); - } - } - - if ((m_width != old_width) || (m_height != old_height)) - { - gtk_widget_set_usize( m_widget, m_width, m_height ); - - /* actual resizing is deferred to GtkOnSize in idle time and - when showing the dialog */ - m_sizeSet = FALSE; - - } - - m_resizing = FALSE; -} - -void wxPopupWindow::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; - - int minWidth = GetMinWidth(), - minHeight = GetMinHeight(), - maxWidth = GetMaxWidth(), - maxHeight = GetMaxHeight(); - - if ((minWidth != -1) && (m_width < minWidth)) m_width = minWidth; - if ((minHeight != -1) && (m_height < minHeight)) m_height = minHeight; - if ((maxWidth != -1) && (m_width > maxWidth)) m_width = maxWidth; - if ((maxHeight != -1) && (m_height > maxHeight)) m_height = maxHeight; - - /* set size hints */ - gint flag = 0; // GDK_HINT_POS; - if ((minWidth != -1) || (minHeight != -1)) flag |= GDK_HINT_MIN_SIZE; - if ((maxWidth != -1) || (maxHeight != -1)) flag |= GDK_HINT_MAX_SIZE; - GdkGeometry geom; - geom.min_width = minWidth; - geom.min_height = minHeight; - geom.max_width = maxWidth; - geom.max_height = maxHeight; - gtk_window_set_geometry_hints( GTK_WINDOW(m_widget), - (GtkWidget*) NULL, - &geom, - (GdkWindowHints) flag ); - - m_sizeSet = TRUE; - - wxSizeEvent event( wxSize(m_width,m_height), GetId() ); - event.SetEventObject( this ); - GetEventHandler()->ProcessEvent( event ); -} - -void wxPopupWindow::OnInternalIdle() -{ - if (!m_sizeSet && GTK_WIDGET_REALIZED(m_wxwindow)) - GtkOnSize( m_x, m_y, m_width, m_height ); - - wxWindow::OnInternalIdle(); -} - -bool wxPopupWindow::Show( bool show ) -{ - if (show && !m_sizeSet) - { - /* by calling GtkOnSize here, we don't have to call - either after showing the frame, which would entail - much ugly flicker nor from within the size_allocate - handler, because GTK 1.1.X forbids that. */ - - GtkOnSize( m_x, m_y, m_width, m_height ); - } - - if (!show) - gtk_grab_remove( m_widget ); - - bool ret = wxWindow::Show( show ); - - if (show) - gtk_grab_add( m_widget ); - - return ret; -} - -#endif // wxUSE_POPUPWIN diff --git a/src/gtk1/radiobox.cpp b/src/gtk1/radiobox.cpp deleted file mode 100644 index 5f99ca4fa1..0000000000 --- a/src/gtk1/radiobox.cpp +++ /dev/null @@ -1,738 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: radiobox.cpp -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/defs.h" - -#if wxUSE_RADIOBOX - -#include "wx/radiobox.h" - -#include "wx/dialog.h" -#include "wx/frame.h" -#include "wx/log.h" - -#include "wx/gtk/private.h" -#include - -#include "wx/gtk/win_gtk.h" - -//----------------------------------------------------------------------------- -// idle system -//----------------------------------------------------------------------------- - -extern void wxapp_install_idle_handler(); -extern bool g_isIdle; - -//----------------------------------------------------------------------------- -// data -//----------------------------------------------------------------------------- - -extern bool g_blockEventsOnDrag; -extern wxWindowGTK *g_delayedFocus; - -//----------------------------------------------------------------------------- -// "clicked" -//----------------------------------------------------------------------------- - -static void gtk_radiobutton_clicked_callback( GtkToggleButton *button, wxRadioBox *rb ) -{ - if (g_isIdle) wxapp_install_idle_handler(); - - if (!rb->m_hasVMT) return; - if (g_blockEventsOnDrag) return; - - if (!button->active) return; - - wxCommandEvent event( wxEVT_COMMAND_RADIOBOX_SELECTED, rb->GetId() ); - event.SetInt( rb->GetSelection() ); - event.SetString( rb->GetStringSelection() ); - event.SetEventObject( rb ); - rb->GetEventHandler()->ProcessEvent(event); -} - -//----------------------------------------------------------------------------- -// "key_press_event" -//----------------------------------------------------------------------------- - -static gint gtk_radiobox_keypress_callback( GtkWidget *widget, GdkEventKey *gdk_event, wxRadioBox *rb ) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - - if (!rb->m_hasVMT) return FALSE; - if (g_blockEventsOnDrag) return FALSE; - - if ((gdk_event->keyval != GDK_Up) && - (gdk_event->keyval != GDK_Down) && - (gdk_event->keyval != GDK_Left) && - (gdk_event->keyval != GDK_Right)) - { - return FALSE; - } - - wxNode *node = rb->m_boxes.Find( (wxObject*) widget ); - if (!node) - { - return FALSE; - } - - gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" ); - - if ((gdk_event->keyval == GDK_Up) || - (gdk_event->keyval == GDK_Left)) - { - if (node == rb->m_boxes.First()) - node = rb->m_boxes.Last(); - else - node = node->Previous(); - } - else - { - if (node == rb->m_boxes.Last()) - node = rb->m_boxes.First(); - else - node = node->Next(); - } - - GtkWidget *button = (GtkWidget*) node->Data(); - - gtk_widget_grab_focus( button ); - - return TRUE; -} - -static gint gtk_radiobutton_focus_in( GtkWidget *widget, - GdkEvent *WXUNUSED(event), - wxRadioBox *win ) -{ - if ( win->m_lostFocus ) - { - // no, we didn't really lose it - win->m_lostFocus = FALSE; - } - else if ( !win->m_hasFocus ) - { - win->m_hasFocus = TRUE; - - wxFocusEvent event( wxEVT_SET_FOCUS, win->GetId() ); - event.SetEventObject( win ); - - // never stop the signal emission, it seems to break the kbd handling - // inside the radiobox - (void)win->GetEventHandler()->ProcessEvent( event ); - } - - return FALSE; -} - -static gint gtk_radiobutton_focus_out( GtkWidget *widget, - GdkEvent *WXUNUSED(event), - wxRadioBox *win ) -{ - // wxASSERT_MSG( win->m_hasFocus, _T("got focus out without any focus in?") ); - // Replace with a warning, else we dump core a lot! - // if (!win->m_hasFocus) - // wxLogWarning(_T("Radiobox got focus out without any focus in.") ); - - // we might have lost the focus, but may be not - it may have just gone to - // another button in the same radiobox, so we'll check for it in the next - // idle iteration (leave m_hasFocus == TRUE for now) - win->m_lostFocus = TRUE; - - return FALSE; -} - -//----------------------------------------------------------------------------- -// wxRadioBox -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxRadioBox,wxControl) - -void wxRadioBox::Init() -{ - m_needParent = TRUE; - m_acceptsFocus = TRUE; - - m_hasFocus = - m_lostFocus = FALSE; -} - -bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title, - const wxPoint &pos, const wxSize &size, - int n, const wxString choices[], int majorDim, - long style, const wxValidator& validator, - const wxString &name ) -{ - if (!PreCreation( parent, pos, size ) || - !CreateBase( parent, id, pos, size, style, validator, name )) - { - wxFAIL_MSG( wxT("wxRadioBox creation failed") ); - return FALSE; - } - - m_widget = gtk_frame_new( wxGTK_CONV( title ) ); - - // majorDim may be 0 if all trailing parameters were omitted, so don't - // assert here but just use the correct value for it - m_majorDim = majorDim == 0 ? n : majorDim; - - GtkRadioButton *m_radio = (GtkRadioButton*) NULL; - - wxString label; - GSList *radio_button_group = (GSList *) NULL; - for (int i = 0; i < n; i++) - { - if ( i != 0 ) - radio_button_group = gtk_radio_button_group( GTK_RADIO_BUTTON(m_radio) ); - - label.Empty(); - for ( const wxChar *pc = choices[i]; *pc; pc++ ) - { - if ( *pc != wxT('&') ) - label += *pc; - } - - m_radio = GTK_RADIO_BUTTON( gtk_radio_button_new_with_label( radio_button_group, wxGTK_CONV( label ) ) ); - - gtk_signal_connect( GTK_OBJECT(m_radio), "key_press_event", - GTK_SIGNAL_FUNC(gtk_radiobox_keypress_callback), (gpointer)this ); - - m_boxes.Append( (wxObject*) m_radio ); - - ConnectWidget( GTK_WIDGET(m_radio) ); - - if (!i) gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(m_radio), TRUE ); - - gtk_signal_connect( GTK_OBJECT(m_radio), "clicked", - GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this ); - - gtk_signal_connect( GTK_OBJECT(m_radio), "focus_in_event", - GTK_SIGNAL_FUNC(gtk_radiobutton_focus_in), (gpointer)this ); - - gtk_signal_connect( GTK_OBJECT(m_radio), "focus_out_event", - GTK_SIGNAL_FUNC(gtk_radiobutton_focus_out), (gpointer)this ); - - gtk_pizza_put( GTK_PIZZA(m_parent->m_wxwindow), - GTK_WIDGET(m_radio), - m_x+10, m_y+10+(i*24), 10, 10 ); - } - - m_parent->DoAddChild( this ); - - PostCreation(); - - ApplyWidgetStyle(); - - SetLabel( title ); - - SetFont( parent->GetFont() ); - - wxSize ls = LayoutItems(); - - GtkRequisition req; - req.width = 2; - req.height = 2; - (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(m_widget) )->size_request ) (m_widget, &req ); - if (req.width > ls.x) ls.x = req.width; - - wxSize newSize = size; - if (newSize.x == -1) newSize.x = ls.x; - if (newSize.y == -1) newSize.y = ls.y; - SetSize( newSize.x, newSize.y ); - - SetBackgroundColour( parent->GetBackgroundColour() ); - SetForegroundColour( parent->GetForegroundColour() ); - - Show( TRUE ); - - return TRUE; -} - -wxRadioBox::~wxRadioBox() -{ - wxNode *node = m_boxes.First(); - while (node) - { - GtkWidget *button = GTK_WIDGET( node->Data() ); - gtk_widget_destroy( button ); - node = node->Next(); - } -} - -void wxRadioBox::DoSetSize( int x, int y, int width, int height, int sizeFlags ) -{ - wxWindow::DoSetSize( x, y, width, height, sizeFlags ); - - LayoutItems(); -} - -wxSize wxRadioBox::LayoutItems() -{ - int x = 7; - int y = 15; - - if ( m_majorDim == 0 ) - { - // avoid dividing by 0 below - wxFAIL_MSG( wxT("dimension of radiobox should not be 0!") ); - - m_majorDim = 1; - } - - int num_per_major = (m_boxes.GetCount() - 1) / m_majorDim +1; - - wxSize res( 0, 0 ); - - int num_of_cols = 0; - int num_of_rows = 0; - if (HasFlag(wxRA_SPECIFY_COLS)) - { - num_of_cols = m_majorDim; - num_of_rows = num_per_major; - } - else - { - num_of_cols = num_per_major; - num_of_rows = m_majorDim; - } - - if ( HasFlag(wxRA_SPECIFY_COLS) || - (HasFlag(wxRA_SPECIFY_ROWS) && (num_of_cols > 1)) ) - { - for (int j = 0; j < num_of_cols; j++) - { - y = 15; - - int max_len = 0; - wxNode *node = m_boxes.Nth( j*num_of_rows ); - for (int i1 = 0; i1< num_of_rows; i1++) - { - GtkWidget *button = GTK_WIDGET( node->Data() ); - - GtkRequisition req; - req.width = 2; - req.height = 2; - (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(button) )->size_request ) - (button, &req ); - - if (req.width > max_len) max_len = req.width; - - gtk_pizza_move( GTK_PIZZA(m_parent->m_wxwindow), button, m_x+x, m_y+y ); - y += req.height; - - node = node->Next(); - if (!node) break; - } - - // we don't know the max_len before - - node = m_boxes.Nth( j*num_of_rows ); - for (int i2 = 0; i2< num_of_rows; i2++) - { - GtkWidget *button = GTK_WIDGET( node->Data() ); - - gtk_pizza_resize( GTK_PIZZA(m_parent->m_wxwindow), button, max_len, 20 ); - - node = node->Next(); - if (!node) break; - } - - if (y > res.y) res.y = y; - - x += max_len + 2; - } - - res.x = x+4; - res.y += 4; - } - else - { - int max = 0; - - wxNode *node = m_boxes.First(); - while (node) - { - GtkWidget *button = GTK_WIDGET( node->Data() ); - - GtkRequisition req; - req.width = 2; - req.height = 2; - (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(button) )->size_request ) - (button, &req ); - - if (req.width > max) max = req.width; - - node = node->Next(); - } - - node = m_boxes.First(); - while (node) - { - GtkWidget *button = GTK_WIDGET( node->Data() ); - - gtk_pizza_set_size( GTK_PIZZA(m_parent->m_wxwindow), button, m_x+x, m_y+y, max, 20 ); - x += max; - - node = node->Next(); - } - res.x = x+4; - res.y = 40; - } - - return res; -} - -bool wxRadioBox::Show( bool show ) -{ - wxCHECK_MSG( m_widget != NULL, FALSE, wxT("invalid radiobox") ); - - if (!wxControl::Show(show)) - { - // nothing to do - return FALSE; - } - - if ((m_windowStyle & wxNO_BORDER) != 0) - gtk_widget_hide( m_widget ); - - wxNode *node = m_boxes.First(); - while (node) - { - GtkWidget *button = GTK_WIDGET( node->Data() ); - - if (show) gtk_widget_show( button ); else gtk_widget_hide( button ); - - node = node->Next(); - } - - return TRUE; -} - -int wxRadioBox::FindString( const wxString &find ) const -{ - wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid radiobox") ); - - int count = 0; - - wxNode *node = m_boxes.First(); - while (node) - { - GtkLabel *label = GTK_LABEL( BUTTON_CHILD(node->Data()) ); -#ifdef __WXGTK20__ - wxString str( wxGTK_CONV_BACK( gtk_label_get_text(label) ) ); -#else - wxString str( label->label ); -#endif - if (find == str) - return count; - - count++; - - node = node->Next(); - } - - return -1; -} - -void wxRadioBox::SetFocus() -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") ); - - if (m_boxes.GetCount() == 0) return; - - wxNode *node = m_boxes.First(); - while (node) - { - GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->Data() ); - if (button->active) - { - gtk_widget_grab_focus( GTK_WIDGET(button) ); - return; - } - node = node->Next(); - } -} - -void wxRadioBox::SetSelection( int n ) -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") ); - - wxNode *node = m_boxes.Nth( n ); - - wxCHECK_RET( node, wxT("radiobox wrong index") ); - - GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->Data() ); - - GtkDisableEvents(); - - gtk_toggle_button_set_active( button, 1 ); - - GtkEnableEvents(); -} - -int wxRadioBox::GetSelection(void) const -{ - wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid radiobox") ); - - int count = 0; - - wxNode *node = m_boxes.First(); - while (node) - { - GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->Data() ); - if (button->active) return count; - count++; - node = node->Next(); - } - - wxFAIL_MSG( wxT("wxRadioBox none selected") ); - - return -1; -} - -wxString wxRadioBox::GetString( int n ) const -{ - wxCHECK_MSG( m_widget != NULL, wxT(""), wxT("invalid radiobox") ); - - wxNode *node = m_boxes.Nth( n ); - - wxCHECK_MSG( node, wxT(""), wxT("radiobox wrong index") ); - - GtkLabel *label = GTK_LABEL( BUTTON_CHILD(node->Data()) ); - -#ifdef __WXGTK20__ - wxString str( wxGTK_CONV_BACK( gtk_label_get_text(label) ) ); -#else - wxString str( label->label ); -#endif - - return str; -} - -void wxRadioBox::SetLabel( const wxString& label ) -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") ); - - wxControl::SetLabel( label ); - - gtk_frame_set_label( GTK_FRAME(m_widget), wxGTK_CONV( wxControl::GetLabel() ) ); -} - -void wxRadioBox::SetString( int item, const wxString& label ) -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") ); - - wxNode *node = m_boxes.Nth( item ); - - wxCHECK_RET( node, wxT("radiobox wrong index") ); - - GtkLabel *g_label = GTK_LABEL( BUTTON_CHILD(node->Data()) ); - - gtk_label_set( g_label, wxGTK_CONV( label ) ); -} - -bool wxRadioBox::Enable( bool enable ) -{ - if ( !wxControl::Enable( enable ) ) - return FALSE; - - wxNode *node = m_boxes.First(); - while (node) - { - GtkButton *button = GTK_BUTTON( node->Data() ); - GtkLabel *label = GTK_LABEL( BUTTON_CHILD(button) ); - - gtk_widget_set_sensitive( GTK_WIDGET(button), enable ); - gtk_widget_set_sensitive( GTK_WIDGET(label), enable ); - node = node->Next(); - } - - return TRUE; -} - -void wxRadioBox::Enable( int item, bool enable ) -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") ); - - wxNode *node = m_boxes.Nth( item ); - - wxCHECK_RET( node, wxT("radiobox wrong index") ); - - GtkButton *button = GTK_BUTTON( node->Data() ); - GtkLabel *label = GTK_LABEL( BUTTON_CHILD(button) ); - - gtk_widget_set_sensitive( GTK_WIDGET(button), enable ); - gtk_widget_set_sensitive( GTK_WIDGET(label), enable ); -} - -void wxRadioBox::Show( int item, bool show ) -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") ); - - wxNode *node = m_boxes.Nth( item ); - - wxCHECK_RET( node, wxT("radiobox wrong index") ); - - GtkWidget *button = GTK_WIDGET( node->Data() ); - - if (show) - gtk_widget_show( button ); - else - gtk_widget_hide( button ); -} - -wxString wxRadioBox::GetStringSelection() const -{ - wxCHECK_MSG( m_widget != NULL, wxT(""), wxT("invalid radiobox") ); - - wxNode *node = m_boxes.First(); - while (node) - { - GtkToggleButton *button = GTK_TOGGLE_BUTTON( node->Data() ); - if (button->active) - { - GtkLabel *label = GTK_LABEL( BUTTON_CHILD(node->Data()) ); - -#ifdef __WXGTK20__ - wxString str( wxGTK_CONV_BACK( gtk_label_get_text(label) ) ); -#else - wxString str( label->label ); -#endif - return str; - } - node = node->Next(); - } - - wxFAIL_MSG( wxT("wxRadioBox none selected") ); - return wxT(""); -} - -bool wxRadioBox::SetStringSelection( const wxString &s ) -{ - wxCHECK_MSG( m_widget != NULL, FALSE, wxT("invalid radiobox") ); - - int res = FindString( s ); - if (res == -1) return FALSE; - SetSelection( res ); - - return TRUE; -} - -int wxRadioBox::GetCount() const -{ - return m_boxes.Number(); -} - -int wxRadioBox::GetNumberOfRowsOrCols() const -{ - return 1; -} - -void wxRadioBox::SetNumberOfRowsOrCols( int WXUNUSED(n) ) -{ - wxFAIL_MSG(wxT("wxRadioBox::SetNumberOfRowsOrCols not implemented.")); -} - -void wxRadioBox::GtkDisableEvents() -{ - wxNode *node = m_boxes.First(); - while (node) - { - gtk_signal_disconnect_by_func( GTK_OBJECT(node->Data()), - GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this ); - - node = node->Next(); - } -} - -void wxRadioBox::GtkEnableEvents() -{ - wxNode *node = m_boxes.First(); - while (node) - { - gtk_signal_connect( GTK_OBJECT(node->Data()), "clicked", - GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this ); - - node = node->Next(); - } -} - -void wxRadioBox::ApplyWidgetStyle() -{ - SetWidgetStyle(); - - gtk_widget_set_style( m_widget, m_widgetStyle ); - - wxNode *node = m_boxes.First(); - while (node) - { - GtkWidget *widget = GTK_WIDGET( node->Data() ); - gtk_widget_set_style( widget, m_widgetStyle ); - - gtk_widget_set_style( BUTTON_CHILD(node->Data()), m_widgetStyle ); - - node = node->Next(); - } -} - -#if wxUSE_TOOLTIPS -void wxRadioBox::ApplyToolTip( GtkTooltips *tips, const wxChar *tip ) -{ - wxNode *node = m_boxes.First(); - while (node) - { - GtkWidget *widget = GTK_WIDGET( node->Data() ); - gtk_tooltips_set_tip( tips, widget, wxConvCurrent->cWX2MB(tip), (gchar*) NULL ); - node = node->Next(); - } -} -#endif // wxUSE_TOOLTIPS - -bool wxRadioBox::IsOwnGtkWindow( GdkWindow *window ) -{ - if (window == m_widget->window) return TRUE; - - wxNode *node = m_boxes.First(); - while (node) - { - GtkWidget *button = GTK_WIDGET( node->Data() ); - - if (window == button->window) return TRUE; - - node = node->Next(); - } - - return FALSE; -} - -void wxRadioBox::OnInternalIdle() -{ - if ( m_lostFocus ) - { - m_hasFocus = FALSE; - m_lostFocus = FALSE; - - wxFocusEvent event( wxEVT_KILL_FOCUS, GetId() ); - event.SetEventObject( this ); - - (void)GetEventHandler()->ProcessEvent( event ); - } - - if (g_delayedFocus == this) - { - if (GTK_WIDGET_REALIZED(m_widget)) - { - g_delayedFocus = NULL; - SetFocus(); - } - } -} - -#endif // wxUSE_RADIOBOX - diff --git a/src/gtk1/radiobut.cpp b/src/gtk1/radiobut.cpp deleted file mode 100644 index e9a81718f7..0000000000 --- a/src/gtk1/radiobut.cpp +++ /dev/null @@ -1,245 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: radiobut.cpp -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/defs.h" - -#if wxUSE_RADIOBOX - -#include "wx/radiobut.h" - -#include "wx/gtk/private.h" - -//----------------------------------------------------------------------------- -// idle system -//----------------------------------------------------------------------------- - -extern void wxapp_install_idle_handler(); -extern bool g_isIdle; - -//----------------------------------------------------------------------------- -// data -//----------------------------------------------------------------------------- - -extern bool g_blockEventsOnDrag; -extern wxCursor g_globalCursor; -extern wxWindowGTK *g_delayedFocus; - -//----------------------------------------------------------------------------- -// "clicked" -//----------------------------------------------------------------------------- - -static -void gtk_radiobutton_clicked_callback( GtkToggleButton *button, wxRadioButton *rb ) -{ - if (g_isIdle) wxapp_install_idle_handler(); - - if (!rb->m_hasVMT) return; - - if (g_blockEventsOnDrag) return; - - if (!button->active) return; - - if (rb->m_blockEvent) return; - - wxCommandEvent event( wxEVT_COMMAND_RADIOBUTTON_SELECTED, rb->GetId()); - event.SetInt( rb->GetValue() ); - event.SetEventObject( rb ); - rb->GetEventHandler()->ProcessEvent( event ); -} - -//----------------------------------------------------------------------------- -// wxRadioButton -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxRadioButton,wxControl) - -bool wxRadioButton::Create( wxWindow *parent, - wxWindowID id, - const wxString& label, - const wxPoint& pos, - const wxSize& size, - long style, - const wxValidator& validator, - const wxString& name ) -{ - m_acceptsFocus = TRUE; - m_needParent = TRUE; - - m_blockEvent = FALSE; - - if (!PreCreation( parent, pos, size ) || - !CreateBase( parent, id, pos, size, style, validator, name )) - { - wxFAIL_MSG( wxT("wxRadioButton creation failed") ); - return FALSE; - } - - if (HasFlag(wxRB_GROUP)) - { - // start a new group - m_radioButtonGroup = (GSList*) NULL; - } - else - { - // search backward for last group start - wxRadioButton *chief = (wxRadioButton*) NULL; - wxWindowList::Node *node = parent->GetChildren().GetLast(); - while (node) - { - wxWindow *child = node->GetData(); - if (child->IsRadioButton()) - { - chief = (wxRadioButton*) child; - if (child->HasFlag(wxRB_GROUP)) - break; - } - node = node->GetPrevious(); - } - if (chief) - { - // we are part of the group started by chief - m_radioButtonGroup = gtk_radio_button_group( GTK_RADIO_BUTTON(chief->m_widget) ); - } - else - { - // start a new group - m_radioButtonGroup = (GSList*) NULL; - } - } - - m_widget = gtk_radio_button_new_with_label( m_radioButtonGroup, wxGTK_CONV( label ) ); - - SetLabel(label); - - gtk_signal_connect( GTK_OBJECT(m_widget), "clicked", - GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this ); - - m_parent->DoAddChild( this ); - - PostCreation(); - - SetFont( parent->GetFont() ); - - wxSize size_best( DoGetBestSize() ); - wxSize new_size( size ); - if (new_size.x == -1) - new_size.x = size_best.x; - if (new_size.y == -1) - new_size.y = size_best.y; - if ((new_size.x != size.x) || (new_size.y != size.y)) - SetSize( new_size.x, new_size.y ); - - SetBackgroundColour( parent->GetBackgroundColour() ); - SetForegroundColour( parent->GetForegroundColour() ); - - Show( TRUE ); - - return TRUE; -} - -void wxRadioButton::SetLabel( const wxString& label ) -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid radiobutton") ); - - wxControl::SetLabel( label ); - GtkLabel *g_label = GTK_LABEL( BUTTON_CHILD(m_widget) ); -#ifdef __WXGTK20__ - wxString label2 = PrepareLabelMnemonics( label ); - gtk_label_set_text_with_mnemonic( g_label, wxGTK_CONV( label2 ) ); -#else - gtk_label_set( g_label, wxGTK_CONV( GetLabel() ) ); -#endif -} - -void wxRadioButton::SetValue( bool val ) -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid radiobutton") ); - - if (val == GetValue()) - return; - - m_blockEvent = TRUE; - - if (val) - { - gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(m_widget), TRUE ); - } - else - { - // should give an assert - // RL - No it shouldn't. A wxGenericValidator might try to set it - // as FALSE. Failing silently is probably TRTTD here. - } - - m_blockEvent = FALSE; -} - -bool wxRadioButton::GetValue() const -{ - wxCHECK_MSG( m_widget != NULL, FALSE, wxT("invalid radiobutton") ); - - return GTK_TOGGLE_BUTTON(m_widget)->active; -} - -bool wxRadioButton::Enable( bool enable ) -{ - if ( !wxControl::Enable( enable ) ) - return FALSE; - - gtk_widget_set_sensitive( BUTTON_CHILD(m_widget), enable ); - - return TRUE; -} - -void wxRadioButton::ApplyWidgetStyle() -{ - SetWidgetStyle(); - gtk_widget_set_style( m_widget, m_widgetStyle ); - gtk_widget_set_style( BUTTON_CHILD(m_widget), m_widgetStyle ); -} - -bool wxRadioButton::IsOwnGtkWindow( GdkWindow *window ) -{ - return window == TOGGLE_BUTTON_EVENT_WIN(m_widget); -} - -void wxRadioButton::OnInternalIdle() -{ - wxCursor cursor = m_cursor; - if (g_globalCursor.Ok()) cursor = g_globalCursor; - - GdkWindow *win = TOGGLE_BUTTON_EVENT_WIN(m_widget); - if ( win && cursor.Ok()) - { - /* I now set the cursor the anew in every OnInternalIdle call - as setting the cursor in a parent window also effects the - windows above so that checking for the current cursor is - not possible. */ - - gdk_window_set_cursor( win, cursor.GetCursor() ); - } - - if (g_delayedFocus == this) - { - if (GTK_WIDGET_REALIZED(m_widget)) - { - gtk_widget_grab_focus( m_widget ); - g_delayedFocus = NULL; - } - } - - UpdateWindowUI(); -} - -wxSize wxRadioButton::DoGetBestSize() const -{ - return wxControl::DoGetBestSize(); -} - -#endif diff --git a/src/gtk1/region.cpp b/src/gtk1/region.cpp deleted file mode 100644 index b124f43449..0000000000 --- a/src/gtk1/region.cpp +++ /dev/null @@ -1,629 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: gtk/region.cpp -// Purpose: -// Author: Robert Roebling -// Modified: VZ at 05.10.00: use AllocExclusive(), comparison fixed -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -#include "wx/log.h" - -#include "wx/region.h" - -#include "wx/gtk/private.h" - -#ifndef __WXGTK20__ - -// ---------------------------------------------------------------------------- -// wxGdkRegion: creates a new region in ctor and destroys in dtor -// ---------------------------------------------------------------------------- - -class wxGdkRegion -{ -public: - wxGdkRegion() { m_region = gdk_region_new(); } - ~wxGdkRegion() { gdk_region_destroy(m_region); } - - operator GdkRegion *() const { return m_region; } - -private: - GdkRegion *m_region; -}; - -#endif // __WXGTK20__ - -// ---------------------------------------------------------------------------- -// wxRegionRefData: private class containing the information about the region -// ---------------------------------------------------------------------------- - -class wxRegionRefData : public wxObjectRefData -{ -public: - wxRegionRefData() - { - m_region = NULL; - } - - wxRegionRefData(const wxRegionRefData& refData) - : wxObjectRefData() - { -#ifdef __WXGTK20__ - m_region = gdk_region_copy(refData.m_region); -#else - m_region = gdk_regions_union(wxGdkRegion(), refData.m_region); -#endif - } - - ~wxRegionRefData() - { - if (m_region) - gdk_region_destroy( m_region ); - } - - GdkRegion *m_region; -}; - -// ---------------------------------------------------------------------------- -// macros -// ---------------------------------------------------------------------------- - -#define M_REGIONDATA ((wxRegionRefData *)m_refData) -#define M_REGIONDATA_OF(rgn) ((wxRegionRefData *)(rgn.m_refData)) - -IMPLEMENT_DYNAMIC_CLASS(wxRegion, wxGDIObject) -IMPLEMENT_DYNAMIC_CLASS(wxRegionIterator,wxObject) - -// ---------------------------------------------------------------------------- -// wxRegion construction -// ---------------------------------------------------------------------------- - -#define M_REGIONDATA ((wxRegionRefData *)m_refData) - -void wxRegion::InitRect(wxCoord x, wxCoord y, wxCoord w, wxCoord h) -{ - GdkRectangle rect; - rect.x = x; - rect.y = y; - rect.width = w; - rect.height = h; - - m_refData = new wxRegionRefData(); - -#ifdef __WXGTK20__ - M_REGIONDATA->m_region = gdk_region_rectangle( &rect ); -#else - M_REGIONDATA->m_region = gdk_region_union_with_rect( wxGdkRegion(), &rect ); -#endif -} - -wxRegion::wxRegion( GdkRegion *region ) -{ - m_refData = new wxRegionRefData(); -#ifdef __WXGTK20__ - M_REGIONDATA->m_region = gdk_region_copy( region ); -#else - M_REGIONDATA->m_region = gdk_regions_union(wxGdkRegion(), region); -#endif -} - -wxRegion::wxRegion( size_t n, const wxPoint *points, int fillStyle ) -{ - GdkPoint *gdkpoints = new GdkPoint[n]; - for ( size_t i = 0 ; i < n ; i++ ) - { - gdkpoints[i].x = points[i].x; - gdkpoints[i].y = points[i].y; - } - - m_refData = new wxRegionRefData(); - - GdkRegion* reg = gdk_region_polygon - ( - gdkpoints, - n, - fillStyle == wxWINDING_RULE ? GDK_WINDING_RULE - : GDK_EVEN_ODD_RULE - ); - - M_REGIONDATA->m_region = reg; - - delete [] gdkpoints; -} - -wxRegion::~wxRegion() -{ - // m_refData unrefed in ~wxObject -} - -wxObjectRefData *wxRegion::CreateRefData() const -{ - return new wxRegionRefData; -} - -wxObjectRefData *wxRegion::CloneRefData(const wxObjectRefData *data) const -{ - return new wxRegionRefData(*(wxRegionRefData *)data); -} - -// ---------------------------------------------------------------------------- -// wxRegion comparison -// ---------------------------------------------------------------------------- - -bool wxRegion::operator==( const wxRegion& region ) -{ - if (m_refData == region.m_refData) return TRUE; - - if (!m_refData || !region.m_refData) return FALSE; - - // compare the regions themselves, not the pointers to ref data! - return gdk_region_equal(M_REGIONDATA->m_region, - M_REGIONDATA_OF(region)->m_region); -} - -// ---------------------------------------------------------------------------- -// wxRegion operations -// ---------------------------------------------------------------------------- - -void wxRegion::Clear() -{ - UnRef(); -} - -bool wxRegion::Union( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) -{ - // workaround for a strange GTK/X11 bug: taking union with an empty - // rectangle results in an empty region which is definitely not what we - // want - if ( !width || !height ) - return TRUE; - - if ( !m_refData ) - { - InitRect(x, y, width, height); - } - else - { - AllocExclusive(); - - GdkRectangle rect; - rect.x = x; - rect.y = y; - rect.width = width; - rect.height = height; - -#ifdef __WXGTK20__ - gdk_region_union_with_rect( M_REGIONDATA->m_region, &rect ); -#else - GdkRegion *reg = gdk_region_union_with_rect( M_REGIONDATA->m_region, &rect ); - gdk_region_destroy( M_REGIONDATA->m_region ); - M_REGIONDATA->m_region = reg; -#endif - } - - return TRUE; -} - -bool wxRegion::Union( const wxRect& rect ) -{ - return Union( rect.x, rect.y, rect.width, rect.height ); -} - -bool wxRegion::Union( const wxRegion& region ) -{ - if (region.IsNull()) - return FALSE; - - if (!m_refData) - { - m_refData = new wxRegionRefData(); - M_REGIONDATA->m_region = gdk_region_new(); - } - else - { - AllocExclusive(); - } - -#ifdef __WXGTK20__ - gdk_region_union( M_REGIONDATA->m_region, region.GetRegion() ); -#else - GdkRegion *reg = gdk_regions_union( M_REGIONDATA->m_region, region.GetRegion() ); - gdk_region_destroy( M_REGIONDATA->m_region ); - M_REGIONDATA->m_region = reg; -#endif - - return TRUE; -} - -bool wxRegion::Intersect( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) -{ - wxRegion reg( x, y, width, height ); - - return Intersect( reg ); -} - -bool wxRegion::Intersect( const wxRect& rect ) -{ - wxRegion reg( rect ); - - return Intersect( reg ); -} - -bool wxRegion::Intersect( const wxRegion& region ) -{ - if (region.IsNull()) - return FALSE; - - if (!m_refData) - { - // intersecting with invalid region doesn't make sense - return FALSE; - } - - AllocExclusive(); - -#ifdef __WXGTK20__ - gdk_region_intersect( M_REGIONDATA->m_region, region.GetRegion() ); -#else - GdkRegion *reg = gdk_regions_intersect( M_REGIONDATA->m_region, region.GetRegion() ); - gdk_region_destroy( M_REGIONDATA->m_region ); - M_REGIONDATA->m_region = reg; -#endif - - return TRUE; -} - -bool wxRegion::Subtract( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) -{ - wxRegion reg( x, y, width, height ); - return Subtract( reg ); -} - -bool wxRegion::Subtract( const wxRect& rect ) -{ - wxRegion reg( rect ); - return Subtract( reg ); -} - -bool wxRegion::Subtract( const wxRegion& region ) -{ - if (region.IsNull()) - return FALSE; - - if (!m_refData) - { - // subtracting from an invalid region doesn't make sense - return FALSE; - } - - AllocExclusive(); - -#ifdef __WXGTK20__ - gdk_region_subtract( M_REGIONDATA->m_region, region.GetRegion() ); -#else - GdkRegion *reg = gdk_regions_subtract( M_REGIONDATA->m_region, region.GetRegion() ); - gdk_region_destroy( M_REGIONDATA->m_region ); - M_REGIONDATA->m_region = reg; -#endif - - return TRUE; -} - -bool wxRegion::Xor( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) -{ - wxRegion reg( x, y, width, height ); - return Xor( reg ); -} - -bool wxRegion::Xor( const wxRect& rect ) -{ - wxRegion reg( rect ); - return Xor( reg ); -} - -bool wxRegion::Xor( const wxRegion& region ) -{ - if (region.IsNull()) - return FALSE; - - if (!m_refData) - { - return FALSE; - } - - AllocExclusive(); - -#ifdef __WXGTK20__ - gdk_region_xor( M_REGIONDATA->m_region, region.GetRegion() ); -#else - GdkRegion *reg = gdk_regions_xor( M_REGIONDATA->m_region, region.GetRegion() ); - gdk_region_destroy( M_REGIONDATA->m_region ); - M_REGIONDATA->m_region = reg; -#endif - - return TRUE; -} - -bool wxRegion::Offset( wxCoord x, wxCoord y ) -{ - if (!m_refData) - return FALSE; - - AllocExclusive(); - - gdk_region_offset( M_REGIONDATA->m_region, x, y ); - - return TRUE; -} - -// ---------------------------------------------------------------------------- -// wxRegion tests -// ---------------------------------------------------------------------------- - -void wxRegion::GetBox( wxCoord &x, wxCoord &y, wxCoord &w, wxCoord &h ) const -{ - if ( m_refData ) - { - GdkRectangle rect; - gdk_region_get_clipbox( M_REGIONDATA->m_region, &rect ); - x = rect.x; - y = rect.y; - w = rect.width; - h = rect.height; - } - else - { - x = 0; - y = 0; - w = -1; - h = -1; - } -} - -wxRect wxRegion::GetBox() const -{ - wxCoord x, y, w, h; - GetBox( x, y, w, h ); - return wxRect( x, y, w, h ); -} - -bool wxRegion::Empty() const -{ - if (!m_refData) - return TRUE; - - return gdk_region_empty( M_REGIONDATA->m_region ); -} - -wxRegionContain wxRegion::Contains( wxCoord x, wxCoord y ) const -{ - if (!m_refData) - return wxOutRegion; - - if (gdk_region_point_in( M_REGIONDATA->m_region, x, y )) - return wxInRegion; - else - return wxOutRegion; -} - -wxRegionContain wxRegion::Contains( wxCoord x, wxCoord y, wxCoord w, wxCoord h ) const -{ - if (!m_refData) - return wxOutRegion; - - GdkRectangle rect; - rect.x = x; - rect.y = y; - rect.width = w; - rect.height = h; - GdkOverlapType res = gdk_region_rect_in( M_REGIONDATA->m_region, &rect ); - switch (res) - { - case GDK_OVERLAP_RECTANGLE_IN: return wxInRegion; - case GDK_OVERLAP_RECTANGLE_OUT: return wxOutRegion; - case GDK_OVERLAP_RECTANGLE_PART: return wxPartRegion; - } - return wxOutRegion; -} - -wxRegionContain wxRegion::Contains(const wxPoint& pt) const -{ - return Contains( pt.x, pt.y ); -} - -wxRegionContain wxRegion::Contains(const wxRect& rect) const -{ - return Contains( rect.x, rect.y, rect.width, rect.height ); -} - -GdkRegion *wxRegion::GetRegion() const -{ - if (!m_refData) - return (GdkRegion*) NULL; - - return M_REGIONDATA->m_region; -} - -// ---------------------------------------------------------------------------- -// wxRegionIterator -// ---------------------------------------------------------------------------- - -#ifndef __WXGTK20__ - -// the following structures must match the private structures -// in X11 region code ( xc/lib/X11/region.h ) - -// this makes the Region type transparent -// and we have access to the region rectangles - -#include - -struct _XBox { - short x1, x2, y1, y2; -}; - -struct _XRegion { - long size , numRects; - _XBox *rects, extents; -}; - -#endif // GTK+ 1.x - -class wxRIRefData: public wxObjectRefData -{ -public: - wxRIRefData() { Init(); } - virtual ~wxRIRefData(); - - void CreateRects( const wxRegion& r ); - - void Init() { m_rects = NULL; m_numRects = 0; } - - wxRect *m_rects; - size_t m_numRects; -}; - -wxRIRefData::~wxRIRefData() -{ - delete [] m_rects; -} - -void wxRIRefData::CreateRects( const wxRegion& region ) -{ - delete [] m_rects; - - Init(); - - GdkRegion *gdkregion = region.GetRegion(); - if (!gdkregion) - return; - -#ifdef __WXGTK20__ - GdkRectangle *gdkrects = NULL; - gint numRects = 0; - gdk_region_get_rectangles( gdkregion, &gdkrects, &numRects ); - - m_numRects = numRects; - if (numRects) - { - m_rects = new wxRect[m_numRects]; - for (size_t i=0; i < m_numRects; ++i) - { - GdkRectangle &gr = gdkrects[i]; - wxRect &wr = m_rects[i]; - wr.x = gr.x; - wr.y = gr.y; - wr.width = gr.width; - wr.height = gr.height; - } - } - g_free( gdkrects ); -#else // GTK+ 1.x - Region r = ((GdkRegionPrivate *)gdkregion)->xregion; - if (r) - { - m_numRects = r->numRects; - if (m_numRects) - { - m_rects = new wxRect[m_numRects]; - for (size_t i=0; i < m_numRects; ++i) - { - _XBox &xr = r->rects[i]; - wxRect &wr = m_rects[i]; - wr.x = xr.x1; - wr.y = xr.y1; - wr.width = xr.x2-xr.x1; - wr.height = xr.y2-xr.y1; - } - } - } -#endif // GTK+ 2.0/1.x -} - -wxRegionIterator::wxRegionIterator() -{ - m_refData = new wxRIRefData(); - Reset(); -} - -wxRegionIterator::wxRegionIterator( const wxRegion& region ) -{ - m_refData = new wxRIRefData(); - Reset(region); -} - -void wxRegionIterator::Reset( const wxRegion& region ) -{ - m_region = region; - ((wxRIRefData*)m_refData)->CreateRects(region); - Reset(); -} - -bool wxRegionIterator::HaveRects() const -{ - return m_current < ((wxRIRefData*)m_refData)->m_numRects; -} - -wxRegionIterator& wxRegionIterator::operator ++ () -{ - if (HaveRects()) - ++m_current; - - return *this; -} - -wxRegionIterator wxRegionIterator::operator ++ (int) -{ - wxRegionIterator tmp = *this; - if (HaveRects()) - ++m_current; - - return tmp; -} - -wxCoord wxRegionIterator::GetX() const -{ - wxCHECK_MSG( HaveRects(), 0, _T("invalid wxRegionIterator") ); - - return ((wxRIRefData*)m_refData)->m_rects[m_current].x; -} - -wxCoord wxRegionIterator::GetY() const -{ - wxCHECK_MSG( HaveRects(), 0, _T("invalid wxRegionIterator") ); - - return ((wxRIRefData*)m_refData)->m_rects[m_current].y; -} - -wxCoord wxRegionIterator::GetW() const -{ - wxCHECK_MSG( HaveRects(), 0, _T("invalid wxRegionIterator") ); - - return ((wxRIRefData*)m_refData)->m_rects[m_current].width; -} - -wxCoord wxRegionIterator::GetH() const -{ - wxCHECK_MSG( HaveRects(), 0, _T("invalid wxRegionIterator") ); - - return ((wxRIRefData*)m_refData)->m_rects[m_current].height; -} - -wxRect wxRegionIterator::GetRect() const -{ - wxRect r; - if( HaveRects() ) - r = ((wxRIRefData*)m_refData)->m_rects[m_current]; - - return r; -} - diff --git a/src/gtk1/scrolbar.cpp b/src/gtk1/scrolbar.cpp deleted file mode 100644 index 28bde0551b..0000000000 --- a/src/gtk1/scrolbar.cpp +++ /dev/null @@ -1,335 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/gtk/scrolbar.cpp -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - - -#include "wx/defs.h" - -#if wxUSE_SCROLLBAR - -#include "wx/scrolbar.h" - -#include "wx/utils.h" - -#include - -#include "wx/gtk/private.h" - -//----------------------------------------------------------------------------- -// idle system -//----------------------------------------------------------------------------- - -extern void wxapp_install_idle_handler(); -extern bool g_isIdle; - -//----------------------------------------------------------------------------- -// data -//----------------------------------------------------------------------------- - -extern bool g_blockEventsOnDrag; -extern bool g_blockEventsOnScroll; - -static const float sensitivity = 0.02; - -//----------------------------------------------------------------------------- -// "value_changed" -//----------------------------------------------------------------------------- - -// FIXME: is GtkScrollType really passed to us as 2nd argument? - -static void gtk_scrollbar_callback( GtkAdjustment *adjust, - SCROLLBAR_CBACK_ARG - wxScrollBar *win ) -{ - if (g_isIdle) wxapp_install_idle_handler(); - - if (!win->m_hasVMT) return; - if (g_blockEventsOnDrag) return; - - float diff = adjust->value - win->m_oldPos; - if (fabs(diff) < sensitivity) return; - - win->m_oldPos = adjust->value; - - wxEventType command = GtkScrollTypeToWx(GET_SCROLL_TYPE(win->m_widget)); - - double dvalue = adjust->value; - int value = (int)(dvalue < 0 ? dvalue - 0.5 : dvalue + 0.5); - - int orient = win->HasFlag(wxSB_VERTICAL) ? wxVERTICAL : wxHORIZONTAL; - - wxScrollEvent event( command, win->GetId(), value, orient ); - event.SetEventObject( win ); - win->GetEventHandler()->ProcessEvent( event ); - -/* - wxCommandEvent cevent( wxEVT_COMMAND_SCROLLBAR_UPDATED, win->GetId() ); - cevent.SetEventObject( win ); - win->ProcessEvent( cevent ); -*/ -} - -//----------------------------------------------------------------------------- -// "button_press_event" from slider -//----------------------------------------------------------------------------- - -static gint gtk_scrollbar_button_press_callback( GtkRange *widget, - GdkEventButton *gdk_event, - wxScrollBar *win ) -{ - if (g_isIdle) wxapp_install_idle_handler(); - -// g_blockEventsOnScroll = TRUE; doesn't work in DialogEd - - // FIXME: there is no slider field any more, what was meant here? -#ifndef __WXGTK20__ - win->m_isScrolling = (gdk_event->window == widget->slider); -#endif - - return FALSE; -} - -//----------------------------------------------------------------------------- -// "button_release_event" from slider -//----------------------------------------------------------------------------- - -static gint -gtk_scrollbar_button_release_callback( GtkRange *WXUNUSED(widget), - GdkEventButton *WXUNUSED(gdk_event), - wxScrollBar *win ) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - -// g_blockEventsOnScroll = FALSE; - - if (win->m_isScrolling) - { - wxEventType command = wxEVT_SCROLL_THUMBRELEASE; - int value = (int)ceil(win->m_adjust->value); - int orient = win->HasFlag(wxSB_VERTICAL) ? wxVERTICAL : wxHORIZONTAL; - - wxScrollEvent event( command, win->GetId(), value, orient ); - event.SetEventObject( win ); - win->GetEventHandler()->ProcessEvent( event ); - } - - win->m_isScrolling = FALSE; - - return FALSE; -} - -//----------------------------------------------------------------------------- -// wxScrollBar -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxScrollBar,wxControl) - -wxScrollBar::~wxScrollBar() -{ -} - -bool wxScrollBar::Create(wxWindow *parent, wxWindowID id, - const wxPoint& pos, const wxSize& size, - long style, const wxValidator& validator, const wxString& name ) -{ - m_needParent = TRUE; - m_acceptsFocus = TRUE; - - if (!PreCreation( parent, pos, size ) || - !CreateBase( parent, id, pos, size, style, validator, name )) - { - wxFAIL_MSG( wxT("wxScrollBar creation failed") ); - return FALSE; - } - - m_oldPos = 0.0; - - if ((style & wxSB_VERTICAL) == wxSB_VERTICAL) - m_widget = gtk_vscrollbar_new( (GtkAdjustment *) NULL ); - else - m_widget = gtk_hscrollbar_new( (GtkAdjustment *) NULL ); - - m_adjust = gtk_range_get_adjustment( GTK_RANGE(m_widget) ); - - gtk_signal_connect( GTK_OBJECT(m_adjust), - "value_changed", - (GtkSignalFunc) gtk_scrollbar_callback, - (gpointer) this ); - - gtk_signal_connect( GTK_OBJECT(m_widget), - "button_press_event", - (GtkSignalFunc)gtk_scrollbar_button_press_callback, - (gpointer) this ); - - gtk_signal_connect( GTK_OBJECT(m_widget), - "button_release_event", - (GtkSignalFunc)gtk_scrollbar_button_release_callback, - (gpointer) this ); - - m_parent->DoAddChild( this ); - - PostCreation(); - - SetBestSize(size); - - SetBackgroundColour( parent->GetBackgroundColour() ); - - Show( TRUE ); - - return TRUE; -} - -int wxScrollBar::GetThumbPosition() const -{ - double val = m_adjust->value; - return (int)(val < 0 ? val - 0.5 : val + 0.5); -} - -int wxScrollBar::GetThumbSize() const -{ - return (int)(m_adjust->page_size+0.5); -} - -int wxScrollBar::GetPageSize() const -{ - return (int)(m_adjust->page_increment+0.5); -} - -int wxScrollBar::GetRange() const -{ - return (int)(m_adjust->upper+0.5); -} - -void wxScrollBar::SetThumbPosition( int viewStart ) -{ - if (m_isScrolling) return; - - float fpos = (float)viewStart; - m_oldPos = fpos; - if (fabs(fpos-m_adjust->value) < 0.2) return; - m_adjust->value = fpos; - - gtk_signal_disconnect_by_func( GTK_OBJECT(m_adjust), - (GtkSignalFunc) gtk_scrollbar_callback, - (gpointer) this ); - - gtk_signal_emit_by_name( GTK_OBJECT(m_adjust), "value_changed" ); - - gtk_signal_connect( GTK_OBJECT(m_adjust), - "value_changed", - (GtkSignalFunc) gtk_scrollbar_callback, - (gpointer) this ); -} - -void wxScrollBar::SetScrollbar( int position, int thumbSize, int range, int pageSize, - bool WXUNUSED(refresh) ) -{ - float fpos = (float)position; - float frange = (float)range; - float fthumb = (float)thumbSize; - float fpage = (float)pageSize; - - if ((fabs(frange-m_adjust->upper) < 0.2) && - (fabs(fthumb-m_adjust->page_size) < 0.2) && - (fabs(fpage-m_adjust->page_increment) < 0.2)) - { - SetThumbPosition( position ); - return; - } - - m_oldPos = fpos; - - m_adjust->lower = 0.0; - m_adjust->upper = frange; - m_adjust->value = fpos; - m_adjust->step_increment = 1.0; - m_adjust->page_increment = (float)(wxMax(fpage,0)); - m_adjust->page_size = fthumb; - - gtk_signal_emit_by_name( GTK_OBJECT(m_adjust), "changed" ); -} - -/* Backward compatibility */ -int wxScrollBar::GetValue() const -{ - return GetThumbPosition(); -} - -void wxScrollBar::SetValue( int viewStart ) -{ - SetThumbPosition( viewStart ); -} - -void wxScrollBar::GetValues( int *viewStart, int *viewLength, int *objectLength, int *pageLength ) const -{ - int pos = (int)(m_adjust->value+0.5); - int thumb = (int)(m_adjust->page_size+0.5); - int page = (int)(m_adjust->page_increment+0.5); - int range = (int)(m_adjust->upper+0.5); - - *viewStart = pos; - *viewLength = range; - *objectLength = thumb; - *pageLength = page; -} - -int wxScrollBar::GetViewLength() const -{ - return (int)(m_adjust->upper+0.5); -} - -int wxScrollBar::GetObjectLength() const -{ - return (int)(m_adjust->page_size+0.5); -} - -void wxScrollBar::SetPageSize( int pageLength ) -{ - int pos = (int)(m_adjust->value+0.5); - int thumb = (int)(m_adjust->page_size+0.5); - int range = (int)(m_adjust->upper+0.5); - SetScrollbar( pos, thumb, range, pageLength ); -} - -void wxScrollBar::SetObjectLength( int objectLength ) -{ - int pos = (int)(m_adjust->value+0.5); - int page = (int)(m_adjust->page_increment+0.5); - int range = (int)(m_adjust->upper+0.5); - SetScrollbar( pos, objectLength, range, page ); -} - -void wxScrollBar::SetViewLength( int viewLength ) -{ - int pos = (int)(m_adjust->value+0.5); - int thumb = (int)(m_adjust->page_size+0.5); - int page = (int)(m_adjust->page_increment+0.5); - SetScrollbar( pos, thumb, viewLength, page ); -} - -bool wxScrollBar::IsOwnGtkWindow( GdkWindow *window ) -{ - GtkRange *range = GTK_RANGE(m_widget); - return ( (window == GTK_WIDGET(range)->window) -#ifndef __WXGTK20__ - || (window == range->trough) - || (window == range->slider) - || (window == range->step_forw) - || (window == range->step_back) -#endif // GTK+ 1.x - ); -} - -void wxScrollBar::ApplyWidgetStyle() -{ - SetWidgetStyle(); - gtk_widget_set_style( m_widget, m_widgetStyle ); -} - -#endif diff --git a/src/gtk1/scrolwin.cpp b/src/gtk1/scrolwin.cpp deleted file mode 100644 index d1a3592018..0000000000 --- a/src/gtk1/scrolwin.cpp +++ /dev/null @@ -1,973 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: gtk/scrolwin.cpp -// Purpose: wxScrolledWindow implementation -// Author: Julian Smart -// Modified by: Ron Lee -// Created: 01/02/97 -// RCS-ID: $Id$ -// Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows license -///////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ - #pragma hdrstop -#endif - -#include "wx/utils.h" -#include "wx/dcclient.h" - -#include "wx/scrolwin.h" -#include "wx/panel.h" -#include "wx/sizer.h" - -#include "wx/gtk/private.h" -#include "wx/gtk/win_gtk.h" - -// ---------------------------------------------------------------------------- -// event tables -// ---------------------------------------------------------------------------- - -BEGIN_EVENT_TABLE(wxScrolledWindow, wxPanel) - EVT_SCROLLWIN(wxScrolledWindow::OnScroll) - EVT_SIZE(wxScrolledWindow::OnSize) - EVT_PAINT(wxScrolledWindow::OnPaint) - EVT_CHAR(wxScrolledWindow::OnChar) -END_EVENT_TABLE() - -IMPLEMENT_DYNAMIC_CLASS(wxScrolledWindow, wxPanel) - -// ============================================================================ -// implementation -// ============================================================================ - -//----------------------------------------------------------------------------- -// data -//----------------------------------------------------------------------------- - -extern bool g_blockEventsOnDrag; -extern bool g_blockEventsOnScroll; - -//----------------------------------------------------------------------------- -// idle system -//----------------------------------------------------------------------------- - -extern void wxapp_install_idle_handler(); -extern bool g_isIdle; - -//----------------------------------------------------------------------------- -// "value_changed" from m_vAdjust -//----------------------------------------------------------------------------- - -static void gtk_scrolled_window_vscroll_callback( GtkAdjustment *adjust, - SCROLLBAR_CBACK_ARG - wxScrolledWindow *win ) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - - if (g_blockEventsOnDrag) return; - - if (!win->m_hasVMT) return; - - win->GtkVScroll( adjust->value, - GET_SCROLL_TYPE(GTK_SCROLLED_WINDOW(win->m_widget)->vscrollbar) ); -} - -//----------------------------------------------------------------------------- -// "value_changed" from m_hAdjust -//----------------------------------------------------------------------------- - -static void gtk_scrolled_window_hscroll_callback( GtkAdjustment *adjust, - SCROLLBAR_CBACK_ARG - wxScrolledWindow *win ) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - - if (g_blockEventsOnDrag) return; - if (!win->m_hasVMT) return; - - win->GtkHScroll( adjust->value, - GET_SCROLL_TYPE(GTK_SCROLLED_WINDOW(win->m_widget)->hscrollbar) ); -} - -//----------------------------------------------------------------------------- -// "button_press_event" from scrollbar -//----------------------------------------------------------------------------- - -static gint gtk_scrollbar_button_press_callback( GtkRange *widget, - GdkEventButton *gdk_event, - wxWindowGTK *win) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - - g_blockEventsOnScroll = TRUE; - - // FIXME: there is no slider field any more, what was meant here? -#ifndef __WXGTK20__ - win->m_isScrolling = (gdk_event->window == widget->slider); -#endif - - return FALSE; -} - -//----------------------------------------------------------------------------- -// "button_release_event" from scrollbar -//----------------------------------------------------------------------------- - -static gint gtk_scrollbar_button_release_callback( GtkRange *widget, - GdkEventButton *WXUNUSED(gdk_event), - wxWindowGTK *win) -{ -// don't test here as we can release the mouse while being over -// a different window than the slider -// -// if (gdk_event->window != widget->slider) return FALSE; - - g_blockEventsOnScroll = FALSE; - - if (win->m_isScrolling) - { - wxEventType command = wxEVT_SCROLLWIN_THUMBRELEASE; - int value = -1; - int dir = -1; - - GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(win->m_widget); - if (widget == GTK_RANGE(scrolledWindow->hscrollbar)) - { - value = (int)(win->m_hAdjust->value+0.5); - dir = wxHORIZONTAL; - } - if (widget == GTK_RANGE(scrolledWindow->vscrollbar)) - { - value = (int)(win->m_vAdjust->value+0.5); - dir = wxVERTICAL; - } - - wxScrollWinEvent event( command, value, dir ); - event.SetEventObject( win ); - win->GetEventHandler()->ProcessEvent( event ); - } - - win->m_isScrolling = FALSE; - - return FALSE; -} - -//----------------------------------------------------------------------------- -// InsertChild for wxScrolledWindow -//----------------------------------------------------------------------------- - -static void wxInsertChildInScrolledWindow( wxWindow* parent, wxWindow* child ) -{ - // The window might have been scrolled already, do we - // have to adapt the position. - GtkPizza *pizza = GTK_PIZZA(parent->m_wxwindow); - child->m_x += pizza->xoffset; - child->m_y += pizza->yoffset; - - gtk_pizza_put( GTK_PIZZA(parent->m_wxwindow), - GTK_WIDGET(child->m_widget), - child->m_x, - child->m_y, - child->m_width, - child->m_height ); -} - -// ---------------------------------------------------------------------------- -// wxScrolledWindow creation -// ---------------------------------------------------------------------------- - -void wxScrolledWindow::Init() -{ - m_xScrollPixelsPerLine = 0; - m_yScrollPixelsPerLine = 0; - m_xScrollingEnabled = TRUE; - m_yScrollingEnabled = TRUE; - m_xScrollPosition = 0; - m_yScrollPosition = 0; - m_xScrollLinesPerPage = 0; - m_yScrollLinesPerPage = 0; - m_targetWindow = (wxWindow*) NULL; - m_scaleX = 1.0; - m_scaleY = 1.0; - m_hasScrolling = TRUE; -} - -bool wxScrolledWindow::Create(wxWindow *parent, - wxWindowID id, - const wxPoint& pos, - const wxSize& size, - long style, - const wxString& name) -{ - Init(); - - if (!PreCreation( parent, pos, size ) || - !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) - { - wxFAIL_MSG( wxT("wxWindow creation failed") ); - return FALSE; - } - - m_insertCallback = wxInsertChildInScrolledWindow; - - m_targetWindow = this; - - m_widget = gtk_scrolled_window_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL ); - GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS ); - - GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(m_widget); - - GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT_GET_CLASS(m_widget) ); - scroll_class->scrollbar_spacing = 0; - - gtk_scrolled_window_set_policy( scrolledWindow, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC ); - - m_hAdjust = gtk_range_get_adjustment( GTK_RANGE(scrolledWindow->hscrollbar) ); - m_vAdjust = gtk_range_get_adjustment( GTK_RANGE(scrolledWindow->vscrollbar) ); - - m_wxwindow = gtk_pizza_new(); - - gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow ); - - GtkPizza *pizza = GTK_PIZZA(m_wxwindow); - - if (HasFlag(wxRAISED_BORDER)) - { - gtk_pizza_set_shadow_type( pizza, GTK_MYSHADOW_OUT ); - } - else if (HasFlag(wxSUNKEN_BORDER)) - { - gtk_pizza_set_shadow_type( pizza, GTK_MYSHADOW_IN ); - } - else if (HasFlag(wxSIMPLE_BORDER)) - { - gtk_pizza_set_shadow_type( pizza, GTK_MYSHADOW_THIN ); - } - else - { - gtk_pizza_set_shadow_type( pizza, GTK_MYSHADOW_NONE ); - } - - GTK_WIDGET_SET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); - m_acceptsFocus = TRUE; - - // I _really_ don't want scrollbars in the beginning - m_vAdjust->lower = 0.0; - m_vAdjust->upper = 1.0; - m_vAdjust->value = 0.0; - m_vAdjust->step_increment = 1.0; - m_vAdjust->page_increment = 2.0; - gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "changed" ); - m_hAdjust->lower = 0.0; - m_hAdjust->upper = 1.0; - m_hAdjust->value = 0.0; - m_hAdjust->step_increment = 1.0; - m_hAdjust->page_increment = 2.0; - gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "changed" ); - - // Handlers for new scrollbar values - GtkVConnectEvent(); - GtkHConnectEvent(); - - // these handlers block mouse events to any window during scrolling such as - // motion events and prevent GTK and wxWindows from fighting over where the - // slider should be - - gtk_signal_connect( GTK_OBJECT(scrolledWindow->vscrollbar), "button_press_event", - (GtkSignalFunc)gtk_scrollbar_button_press_callback, (gpointer) this ); - - gtk_signal_connect( GTK_OBJECT(scrolledWindow->hscrollbar), "button_press_event", - (GtkSignalFunc)gtk_scrollbar_button_press_callback, (gpointer) this ); - - gtk_signal_connect( GTK_OBJECT(scrolledWindow->vscrollbar), "button_release_event", - (GtkSignalFunc)gtk_scrollbar_button_release_callback, (gpointer) this ); - - gtk_signal_connect( GTK_OBJECT(scrolledWindow->hscrollbar), "button_release_event", - (GtkSignalFunc)gtk_scrollbar_button_release_callback, (gpointer) this ); - - gtk_widget_show( m_wxwindow ); - - if (m_parent) - m_parent->DoAddChild( this ); - - m_focusWidget = m_wxwindow; - - PostCreation(); - - Show( TRUE ); - - return TRUE; -} - -// ---------------------------------------------------------------------------- -// setting scrolling parameters -// ---------------------------------------------------------------------------- - -void wxScrolledWindow::DoSetVirtualSize( int x, int y ) -{ - wxPanel::DoSetVirtualSize( x, y ); - AdjustScrollbars(); - -#if wxUSE_CONSTRAINTS - if (GetAutoLayout()) - Layout(); -#endif -} - -/* - * pixelsPerUnitX/pixelsPerUnitY: number of pixels per unit (e.g. pixels per text line) - * noUnitsX/noUnitsY: : no. units per scrollbar - */ -void wxScrolledWindow::SetScrollbars( int pixelsPerUnitX, int pixelsPerUnitY, - int noUnitsX, int noUnitsY, - int xPos, int yPos, bool noRefresh ) -{ - int xs, ys; - GetViewStart (& xs, & ys); - - int old_x = m_xScrollPixelsPerLine * xs; - int old_y = m_yScrollPixelsPerLine * ys; - - m_xScrollPixelsPerLine = pixelsPerUnitX; - m_yScrollPixelsPerLine = pixelsPerUnitY; - - m_hAdjust->value = m_xScrollPosition = xPos; - m_vAdjust->value = m_yScrollPosition = yPos; - - // Setting hints here should arguably be deprecated, but without it - // a sizer might override this manual scrollbar setting in old code. - m_targetWindow->SetVirtualSizeHints( noUnitsX * pixelsPerUnitX, noUnitsY * pixelsPerUnitY ); - - m_targetWindow->SetVirtualSize( noUnitsX * pixelsPerUnitX, noUnitsY * pixelsPerUnitY ); - - if (!noRefresh) - { - int new_x = m_xScrollPixelsPerLine * m_xScrollPosition; - int new_y = m_yScrollPixelsPerLine * m_yScrollPosition; - - m_targetWindow->ScrollWindow( old_x - new_x, old_y - new_y ); - } -} - -void wxScrolledWindow::AdjustScrollbars() -{ - int w, h; - int vw, vh; - - m_targetWindow->GetClientSize( &w, &h ); - m_targetWindow->GetVirtualSize( &vw, &vh ); - - if (m_xScrollPixelsPerLine == 0) - { - m_hAdjust->upper = 1.0; - m_hAdjust->page_size = 1.0; - } - else - { - m_hAdjust->upper = vw / m_xScrollPixelsPerLine; - m_hAdjust->page_size = (w / m_xScrollPixelsPerLine); - - // If the scrollbar hits the right side, move the window - // right to keep it from over extending. - - if ((m_hAdjust->value != 0.0) && (m_hAdjust->value + m_hAdjust->page_size > m_hAdjust->upper)) - { - m_hAdjust->value = m_hAdjust->upper - m_hAdjust->page_size; - if (m_hAdjust->value < 0.0) - m_hAdjust->value = 0.0; - - if (GetChildren().GetCount() == 0) - m_xScrollPosition = (int)m_hAdjust->value; // This is enough without child windows - else - gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "value_changed" ); // Actually scroll window - } - } - - if (m_yScrollPixelsPerLine == 0) - { - m_vAdjust->upper = 1.0; - m_vAdjust->page_size = 1.0; - } - else - { - m_vAdjust->upper = vh / m_yScrollPixelsPerLine; - m_vAdjust->page_size = (h / m_yScrollPixelsPerLine); - - if ((m_vAdjust->value != 0.0) && (m_vAdjust->value + m_vAdjust->page_size > m_vAdjust->upper)) - { - m_vAdjust->value = m_vAdjust->upper - m_vAdjust->page_size; - if (m_vAdjust->value < 0.0) - m_vAdjust->value = 0.0; - - if (GetChildren().GetCount() == 0) - m_yScrollPosition = (int)m_vAdjust->value; - else - gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "value_changed" ); - } - } - - m_xScrollLinesPerPage = (int)(m_hAdjust->page_size + 0.5); - m_yScrollLinesPerPage = (int)(m_vAdjust->page_size + 0.5); - - gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "changed" ); - gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "changed" ); -} - - -// ---------------------------------------------------------------------------- -// target window handling -// ---------------------------------------------------------------------------- - -void wxScrolledWindow::SetTargetWindow( wxWindow *target, bool WXUNUSED(pushEventHandler) ) -{ - wxASSERT_MSG( target, wxT("target window must not be NULL") ); - m_targetWindow = target; -} - -wxWindow *wxScrolledWindow::GetTargetWindow() -{ - return m_targetWindow; -} - -// Override this function if you don't want to have wxScrolledWindow -// automatically change the origin according to the scroll position. -void wxScrolledWindow::PrepareDC(wxDC& dc) -{ - dc.SetDeviceOrigin( -m_xScrollPosition * m_xScrollPixelsPerLine, - -m_yScrollPosition * m_yScrollPixelsPerLine ); -} - -void wxScrolledWindow::SetScrollRate( int xstep, int ystep ) -{ - int old_x = m_xScrollPixelsPerLine * m_xScrollPosition; - int old_y = m_yScrollPixelsPerLine * m_yScrollPosition; - - m_xScrollPixelsPerLine = xstep; - m_yScrollPixelsPerLine = ystep; - - int new_x = m_xScrollPixelsPerLine * m_xScrollPosition; - int new_y = m_yScrollPixelsPerLine * m_yScrollPosition; - - m_targetWindow->ScrollWindow( old_x - new_x, old_y - new_y ); - - AdjustScrollbars(); -} - -void wxScrolledWindow::GetScrollPixelsPerUnit (int *x_unit, int *y_unit) const -{ - if ( x_unit ) - *x_unit = m_xScrollPixelsPerLine; - if ( y_unit ) - *y_unit = m_yScrollPixelsPerLine; -} - -int wxScrolledWindow::GetScrollPageSize(int orient) const -{ - if ( orient == wxHORIZONTAL ) - return m_xScrollLinesPerPage; - else - return m_yScrollLinesPerPage; -} - -void wxScrolledWindow::SetScrollPageSize(int orient, int pageSize) -{ - if ( orient == wxHORIZONTAL ) - m_xScrollLinesPerPage = pageSize; - else - m_yScrollLinesPerPage = pageSize; -} - -void wxScrolledWindow::OnScroll(wxScrollWinEvent& event) -{ - int orient = event.GetOrientation(); - - int nScrollInc = CalcScrollInc(event); - if (nScrollInc == 0) return; - - if (orient == wxHORIZONTAL) - { - int newPos = m_xScrollPosition + nScrollInc; - SetScrollPos(wxHORIZONTAL, newPos, TRUE ); - } - else - { - int newPos = m_yScrollPosition + nScrollInc; - SetScrollPos(wxVERTICAL, newPos, TRUE ); - } - - if (orient == wxHORIZONTAL) - { - m_xScrollPosition += nScrollInc; - } - else - { - m_yScrollPosition += nScrollInc; - } - - if (orient == wxHORIZONTAL) - { - if (m_xScrollingEnabled) - m_targetWindow->ScrollWindow(-m_xScrollPixelsPerLine * nScrollInc, 0, (const wxRect *) NULL); - else - m_targetWindow->Refresh(); - } - else - { - if (m_yScrollingEnabled) - m_targetWindow->ScrollWindow(0, -m_yScrollPixelsPerLine * nScrollInc, (const wxRect *) NULL); - else - m_targetWindow->Refresh(); - } -} - -void wxScrolledWindow::Scroll( int x_pos, int y_pos ) -{ - wxASSERT_MSG( m_targetWindow != 0, _T("No target window") ); - - if (((x_pos == -1) || (x_pos == m_xScrollPosition)) && - ((y_pos == -1) || (y_pos == m_yScrollPosition))) return; - - if ((x_pos != -1) && (m_xScrollPixelsPerLine)) - { - int max = (int)(m_hAdjust->upper - m_hAdjust->page_size + 0.5); - if (max < 0) max = 0; - if (x_pos > max) x_pos = max; - if (x_pos < 0) x_pos = 0; - - int old_x = m_xScrollPosition; - m_xScrollPosition = x_pos; - m_hAdjust->value = x_pos; - - m_targetWindow->ScrollWindow( (old_x-m_xScrollPosition)*m_xScrollPixelsPerLine, 0 ); - - // Just update the scrollbar, don't send any wxWindows event - GtkHDisconnectEvent(); - gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "value_changed" ); - GtkHConnectEvent(); - } - - if ((y_pos != -1) && (m_yScrollPixelsPerLine)) - { - int max = (int)(m_vAdjust->upper - m_vAdjust->page_size + 0.5); - if (max < 0) max = 0; - if (y_pos > max) y_pos = max; - if (y_pos < 0) y_pos = 0; - - int old_y = m_yScrollPosition; - m_yScrollPosition = y_pos; - m_vAdjust->value = y_pos; - - m_targetWindow->ScrollWindow( 0, (old_y-m_yScrollPosition)*m_yScrollPixelsPerLine ); - - // Just update the scrollbar, don't send any wxWindows event - GtkVDisconnectEvent(); - gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "value_changed" ); - GtkVConnectEvent(); - } -} - -// TODO: [VH]Scroll functions should be combined - -void wxScrolledWindow::GtkVScroll( float value, unsigned int scroll_type ) -{ - wxASSERT_MSG( m_targetWindow != 0, _T("No target window") ); - - if (m_yScrollPixelsPerLine == 0) - return; - - int y_pos = (int)(value+0.5); - - if (y_pos == m_yScrollPosition) - return; - - wxEventType command = GtkScrollWinTypeToWx(scroll_type); - - wxScrollWinEvent event( command, y_pos, wxVERTICAL ); - event.SetEventObject( this ); - GetEventHandler()->ProcessEvent( event ); -} - -void wxScrolledWindow::GtkHScroll( float value, unsigned int scroll_type ) -{ - wxASSERT_MSG( m_targetWindow != 0, _T("No target window") ); - - if (m_xScrollPixelsPerLine == 0) - return; - - int x_pos = (int)(value+0.5); - - if (x_pos == m_xScrollPosition) - return; - - wxEventType command = GtkScrollWinTypeToWx(scroll_type); - - wxScrollWinEvent event( command, x_pos, wxHORIZONTAL ); - event.SetEventObject( this ); - GetEventHandler()->ProcessEvent( event ); -} - -void wxScrolledWindow::EnableScrolling (bool x_scroll, bool y_scroll) -{ - m_xScrollingEnabled = x_scroll; - m_yScrollingEnabled = y_scroll; -} - -// Where the current view starts from -void wxScrolledWindow::GetViewStart (int *x, int *y) const -{ - if ( x ) - *x = m_xScrollPosition; - if ( y ) - *y = m_yScrollPosition; -} - -void wxScrolledWindow::DoCalcScrolledPosition(int x, int y, int *xx, int *yy) const -{ - int xs, ys; - GetViewStart (& xs, & ys); - - if ( xx ) - *xx = x - xs * m_xScrollPixelsPerLine; - if ( yy ) - *yy = y - ys * m_yScrollPixelsPerLine; -} - -void wxScrolledWindow::DoCalcUnscrolledPosition(int x, int y, int *xx, int *yy) const -{ - int xs, ys; - GetViewStart (& xs, & ys); - - if ( xx ) - *xx = x + xs * m_xScrollPixelsPerLine; - if ( yy ) - *yy = y + ys * m_yScrollPixelsPerLine; -} - -int wxScrolledWindow::CalcScrollInc(wxScrollWinEvent& event) -{ - int pos = event.GetPosition(); - int orient = event.GetOrientation(); - - int nScrollInc = 0; - if (event.GetEventType() == wxEVT_SCROLLWIN_TOP) - { - if (orient == wxHORIZONTAL) - nScrollInc = - m_xScrollPosition; - else - nScrollInc = - m_yScrollPosition; - } else - if (event.GetEventType() == wxEVT_SCROLLWIN_BOTTOM) - { - if (orient == wxHORIZONTAL) - nScrollInc = GetVirtualSize().GetWidth() / m_xScrollPixelsPerLine - m_xScrollPosition; - else - nScrollInc = GetVirtualSize().GetHeight() / m_yScrollPixelsPerLine - m_yScrollPosition; - } else - if (event.GetEventType() == wxEVT_SCROLLWIN_LINEUP) - { - nScrollInc = -1; - } else - if (event.GetEventType() == wxEVT_SCROLLWIN_LINEDOWN) - { - nScrollInc = 1; - } else - if (event.GetEventType() == wxEVT_SCROLLWIN_PAGEUP) - { - if (orient == wxHORIZONTAL) - nScrollInc = -GetScrollPageSize(wxHORIZONTAL); - else - nScrollInc = -GetScrollPageSize(wxVERTICAL); - } else - if (event.GetEventType() == wxEVT_SCROLLWIN_PAGEDOWN) - { - if (orient == wxHORIZONTAL) - nScrollInc = GetScrollPageSize(wxHORIZONTAL); - else - nScrollInc = GetScrollPageSize(wxVERTICAL); - } else - if ((event.GetEventType() == wxEVT_SCROLLWIN_THUMBTRACK) || - (event.GetEventType() == wxEVT_SCROLLWIN_THUMBRELEASE)) - { - if (orient == wxHORIZONTAL) - nScrollInc = pos - m_xScrollPosition; - else - nScrollInc = pos - m_yScrollPosition; - } - - if (orient == wxHORIZONTAL) - { - if (m_xScrollPixelsPerLine > 0) - { - int max = (int)(m_hAdjust->upper - m_hAdjust->page_size + 0.5); - if (max < 0) max = 0; - - if ( (m_xScrollPosition + nScrollInc) < 0 ) - nScrollInc = -m_xScrollPosition; // As -ve as we can go - else if ( (m_xScrollPosition + nScrollInc) > max ) - nScrollInc = max - m_xScrollPosition; // As +ve as we can go - } - else - m_targetWindow->Refresh(); - } - else - { - if (m_yScrollPixelsPerLine > 0) - { - int max = (int)(m_vAdjust->upper - m_vAdjust->page_size + 0.5); - if (max < 0) max = 0; - - if ( (m_yScrollPosition + nScrollInc) < 0 ) - nScrollInc = -m_yScrollPosition; // As -ve as we can go - else if ( (m_yScrollPosition + nScrollInc) > max ) - nScrollInc = max - m_yScrollPosition; // As +ve as we can go - } - else - m_targetWindow->Refresh(); - } - - return nScrollInc; -} - -void wxScrolledWindow::SetScrollPos( int orient, int pos, bool refresh ) -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid window") ); - - wxCHECK_RET( m_wxwindow != NULL, wxT("window needs client area for scrolling") ); - - if (orient == wxHORIZONTAL) - { - int max = (int)(m_hAdjust->upper - m_hAdjust->page_size + 0.5); - if (max < 0) max = 0; - - if (pos > max) pos = 0; - if (pos < 0) pos = 0; - - if (pos == (int)(m_hAdjust->value+0.5)) return; - m_hAdjust->value = pos; - } - else - { - int max = (int)(m_vAdjust->upper - m_vAdjust->page_size + 0.5); - if (max < 0) max = 0; - - if (pos > max) pos = 0; - if (pos < 0) pos = 0; - - if (pos == (int)(m_vAdjust->value+0.5)) return; - m_vAdjust->value = pos; - } - - if (m_wxwindow->window) - { - if (orient == wxHORIZONTAL) - { - // Just update the scrollbar, don't send any wxWindows event - GtkHDisconnectEvent(); - gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "value_changed" ); - GtkHConnectEvent(); - } - else - { - // Just update the scrollbar, don't send any wxWindows event - GtkVDisconnectEvent(); - gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "value_changed" ); - GtkVConnectEvent(); - } - } -} - -void wxScrolledWindow::GtkVConnectEvent() -{ - gtk_signal_connect( GTK_OBJECT(m_vAdjust), "value_changed", - (GtkSignalFunc) gtk_scrolled_window_vscroll_callback, (gpointer) this ); -} - -void wxScrolledWindow::GtkHConnectEvent() -{ - gtk_signal_connect( GTK_OBJECT(m_hAdjust), "value_changed", - (GtkSignalFunc) gtk_scrolled_window_hscroll_callback, (gpointer) this ); -} - -void wxScrolledWindow::GtkHDisconnectEvent() -{ - gtk_signal_disconnect_by_func( GTK_OBJECT(m_hAdjust), - (GtkSignalFunc) gtk_scrolled_window_hscroll_callback, (gpointer) this ); -} - -void wxScrolledWindow::GtkVDisconnectEvent() -{ - gtk_signal_disconnect_by_func( GTK_OBJECT(m_vAdjust), - (GtkSignalFunc) gtk_scrolled_window_vscroll_callback, (gpointer) this ); -} - -bool wxScrolledWindow::Layout() -{ - if (GetSizer() && m_targetWindow == this) - { - // If we're the scroll target, take into account the - // virtual size and scrolled position of the window. - - int x, y, w, h; - CalcScrolledPosition(0,0, &x,&y); - GetVirtualSize(&w, &h); - GetSizer()->SetDimension(x, y, w, h); - return TRUE; - } - else - return wxPanel::Layout(); // fall back to default for LayoutConstraints -} - -// ---------------------------------------------------------------------------- -// event handlers -// ---------------------------------------------------------------------------- - -// Default OnSize resets scrollbars, if any -void wxScrolledWindow::OnSize(wxSizeEvent& WXUNUSED(event)) -{ - if( GetAutoLayout() || m_targetWindow->GetAutoLayout() ) - { - if( m_targetWindow != this ) - m_targetWindow->FitInside(); - - FitInside(); - - // FIXME: Something is really weird here... This should be - // called by FitInside above (and apparently is), yet the - // scrollsub sample will get the scrollbar wrong if resized - // quickly. This masks the bug, but is surely not the right - // answer at all. - AdjustScrollbars(); - } - else - { - AdjustScrollbars(); - } -} - -// This calls OnDraw, having adjusted the origin according to the current -// scroll position -void wxScrolledWindow::OnPaint(wxPaintEvent& WXUNUSED(event)) -{ - wxPaintDC dc(this); - PrepareDC(dc); - - OnDraw(dc); -} - -// kbd handling: notice that we use OnChar() and not OnKeyDown() for -// compatibility here - if we used OnKeyDown(), the programs which process -// arrows themselves in their OnChar() would never get the message and like -// this they always have the priority -void wxScrolledWindow::OnChar(wxKeyEvent& event) -{ - int stx, sty, // view origin - szx, szy, // view size (total) - clix, cliy; // view size (on screen) - - GetViewStart(&stx, &sty); - GetClientSize(&clix, &cliy); - GetVirtualSize(&szx, &szy); - - if( m_xScrollPixelsPerLine ) - { - clix /= m_xScrollPixelsPerLine; - szx /= m_xScrollPixelsPerLine; - } - else - { - clix = 0; - szx = -1; - } - if( m_yScrollPixelsPerLine ) - { - cliy /= m_yScrollPixelsPerLine; - szy /= m_yScrollPixelsPerLine; - } - else - { - cliy = 0; - szy = -1; - } - - int xScrollOld = GetScrollPos(wxHORIZONTAL), - yScrollOld = GetScrollPos(wxVERTICAL); - - int dsty; - switch ( event.KeyCode() ) - { - case WXK_PAGEUP: - case WXK_PRIOR: - dsty = sty - (5 * cliy / 6); - Scroll(-1, (dsty == -1) ? 0 : dsty); - break; - - case WXK_PAGEDOWN: - case WXK_NEXT: - Scroll(-1, sty + (5 * cliy / 6)); - break; - - case WXK_HOME: - Scroll(0, event.ControlDown() ? 0 : -1); - break; - - case WXK_END: - Scroll(szx - clix, event.ControlDown() ? szy - cliy : -1); - break; - - case WXK_UP: - Scroll(-1, sty - 1); - break; - - case WXK_DOWN: - Scroll(-1, sty + 1); - break; - - case WXK_LEFT: - Scroll(stx - 1, -1); - break; - - case WXK_RIGHT: - Scroll(stx + 1, -1); - break; - - default: - // not for us - event.Skip(); - return; - } - - int xScroll = GetScrollPos(wxHORIZONTAL); - if ( xScroll != xScrollOld ) - { - wxScrollWinEvent event(wxEVT_SCROLLWIN_THUMBTRACK, xScroll, - wxHORIZONTAL); - event.SetEventObject(this); - GetEventHandler()->ProcessEvent(event); - } - - int yScroll = GetScrollPos(wxVERTICAL); - if ( yScroll != yScrollOld ) - { - wxScrollWinEvent event(wxEVT_SCROLLWIN_THUMBTRACK, yScroll, - wxVERTICAL); - event.SetEventObject(this); - GetEventHandler()->ProcessEvent(event); - } -} - - -// vi:sts=4:sw=4:et diff --git a/src/gtk1/settings.cpp b/src/gtk1/settings.cpp deleted file mode 100644 index f7eb33fb68..0000000000 --- a/src/gtk1/settings.cpp +++ /dev/null @@ -1,397 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: gtk/settings.cpp -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/settings.h" -#include "wx/debug.h" -#include "wx/module.h" -#include "wx/cmndata.h" -#include "wx/fontutil.h" - -#include -#include -#include - -#define SHIFT (8*(sizeof(short int)-sizeof(char))) - -//wxColour *g_systemWinColour = (wxColour *) NULL; -wxColour *g_systemBtnFaceColour = (wxColour *) NULL; -wxColour *g_systemBtnShadowColour = (wxColour *) NULL; -wxColour *g_systemBtnHighlightColour = (wxColour *) NULL; -wxColour *g_systemHighlightColour = (wxColour *) NULL; -wxColour *g_systemHighlightTextColour = (wxColour *) NULL; -wxColour *g_systemListBoxColour = (wxColour *) NULL; -wxColour *g_systemBtnTextColour = (wxColour *) NULL; - -wxFont *g_systemFont = (wxFont *) NULL; - -// ---------------------------------------------------------------------------- -// wxSystemSettingsModule -// ---------------------------------------------------------------------------- - -class wxSystemSettingsModule : public wxModule -{ -public: - bool OnInit() { return TRUE; } - void OnExit() - { - //delete g_systemWinColour; - delete g_systemBtnFaceColour; - delete g_systemBtnShadowColour; - delete g_systemBtnHighlightColour; - delete g_systemHighlightColour; - delete g_systemHighlightTextColour; - delete g_systemListBoxColour; - delete g_systemFont; - delete g_systemBtnTextColour; - } - DECLARE_DYNAMIC_CLASS(wxSystemSettingsModule) -}; - -IMPLEMENT_DYNAMIC_CLASS(wxSystemSettingsModule, wxModule) - -// ---------------------------------------------------------------------------- -// wxSystemSettings implementation -// ---------------------------------------------------------------------------- - -// kind of widget to use in GetColourFromGTKWidget -enum wxGtkWidgetType -{ - wxGTK_BUTTON, - wxGTK_LIST -}; - -// the colour we need -enum wxGtkColourType -{ - wxGTK_FG, - wxGTK_BG, - wxGTK_BASE -}; - -// wxSystemSettings::GetColour() helper: get the colours from a GTK+ -// widget style, return true if we did get them, false to use defaults -static bool GetColourFromGTKWidget(int& red, int& green, int& blue, - wxGtkWidgetType type = wxGTK_BUTTON, - GtkStateType state = GTK_STATE_NORMAL, - wxGtkColourType colour = wxGTK_BG) -{ - GtkWidget *widget; - switch ( type ) - { - default: - wxFAIL_MSG( _T("unexpected GTK widget type") ); - // fall through - - case wxGTK_BUTTON: - widget = gtk_button_new(); - break; - - case wxGTK_LIST: - widget = gtk_list_new(); - } - - GtkStyle *def = gtk_rc_get_style( widget ); - if ( !def ) - def = gtk_widget_get_default_style(); - - bool ok; - if ( def ) - { - GdkColor *col; - switch ( colour ) - { - default: - wxFAIL_MSG( _T("unexpected GTK colour type") ); - // fall through - - case wxGTK_FG: - col = def->fg; - break; - - case wxGTK_BG: - col = def->bg; - break; - - case wxGTK_BASE: - col = def->base; - break; - } - - red = col[state].red; - green = col[state].green; - blue = col[state].blue; - - ok = TRUE; - } - else - { - ok = FALSE; - } - - gtk_widget_destroy( widget ); - - return ok; -} - -wxColour wxSystemSettingsNative::GetColour( wxSystemColour index ) -{ - switch (index) - { - case wxSYS_COLOUR_SCROLLBAR: - case wxSYS_COLOUR_BACKGROUND: - case wxSYS_COLOUR_ACTIVECAPTION: - case wxSYS_COLOUR_INACTIVECAPTION: - case wxSYS_COLOUR_MENU: - case wxSYS_COLOUR_WINDOWFRAME: - case wxSYS_COLOUR_ACTIVEBORDER: - case wxSYS_COLOUR_INACTIVEBORDER: - case wxSYS_COLOUR_BTNFACE: - case wxSYS_COLOUR_MENUBAR: - case wxSYS_COLOUR_3DLIGHT: - if (!g_systemBtnFaceColour) - { - int red, green, blue; - if ( !GetColourFromGTKWidget(red, green, blue) ) - { - red = - green = 0; - blue = 0x9c40; - } - - g_systemBtnFaceColour = new wxColour( red >> SHIFT, - green >> SHIFT, - blue >> SHIFT ); - } - return *g_systemBtnFaceColour; - - case wxSYS_COLOUR_WINDOW: - return *wxWHITE; - - case wxSYS_COLOUR_3DDKSHADOW: - return *wxBLACK; - - case wxSYS_COLOUR_GRAYTEXT: - case wxSYS_COLOUR_BTNSHADOW: - //case wxSYS_COLOUR_3DSHADOW: - if (!g_systemBtnShadowColour) - { - wxColour faceColour(GetColour(wxSYS_COLOUR_3DFACE)); - g_systemBtnShadowColour = - new wxColour((unsigned char) (faceColour.Red() * 0.666), - (unsigned char) (faceColour.Green() * 0.666), - (unsigned char) (faceColour.Blue() * 0.666)); - } - - return *g_systemBtnShadowColour; - - case wxSYS_COLOUR_3DHIGHLIGHT: - //case wxSYS_COLOUR_BTNHIGHLIGHT: - return * wxWHITE; -/* I think this should normally be white (JACS 8/2000) - - Hmm, I'm quite sure it shouldn't ... (VZ 20.08.01) - if (!g_systemBtnHighlightColour) - { - g_systemBtnHighlightColour = - new wxColour( 0xea60 >> SHIFT, - 0xea60 >> SHIFT, - 0xea60 >> SHIFT ); - } - return *g_systemBtnHighlightColour; -*/ - - case wxSYS_COLOUR_HIGHLIGHT: - if (!g_systemHighlightColour) - { - int red, green, blue; - if ( !GetColourFromGTKWidget(red, green, blue, - wxGTK_BUTTON, - GTK_STATE_SELECTED) ) - { - red = - green = 0; - blue = 0x9c40; - } - - g_systemHighlightColour = new wxColour( red >> SHIFT, - green >> SHIFT, - blue >> SHIFT ); - } - return *g_systemHighlightColour; - - case wxSYS_COLOUR_LISTBOX: - if (!g_systemListBoxColour) - { - int red, green, blue; - if ( GetColourFromGTKWidget(red, green, blue, - wxGTK_LIST, - GTK_STATE_NORMAL, - wxGTK_BASE) ) - { - g_systemListBoxColour = new wxColour( red >> SHIFT, - green >> SHIFT, - blue >> SHIFT ); - } - else - { - g_systemListBoxColour = new wxColour(*wxWHITE); - } - } - return *g_systemListBoxColour; - - case wxSYS_COLOUR_MENUTEXT: - case wxSYS_COLOUR_WINDOWTEXT: - case wxSYS_COLOUR_CAPTIONTEXT: - case wxSYS_COLOUR_INACTIVECAPTIONTEXT: - case wxSYS_COLOUR_BTNTEXT: - case wxSYS_COLOUR_INFOTEXT: - if (!g_systemBtnTextColour) - { - int red, green, blue; - if ( !GetColourFromGTKWidget(red, green, blue, - wxGTK_BUTTON, - GTK_STATE_NORMAL, - wxGTK_FG) ) - { - red = - green = - blue = 0; - } - - g_systemBtnTextColour = new wxColour( red >> SHIFT, - green >> SHIFT, - blue >> SHIFT ); - } - return *g_systemBtnTextColour; - - // this (as well as wxSYS_COLOUR_INFOTEXT above) is used for - // tooltip windows - Robert, please change this code to use the - // real GTK tooltips when/if you can (TODO) - case wxSYS_COLOUR_INFOBK: - return wxColour(255, 255, 225); - - case wxSYS_COLOUR_HIGHLIGHTTEXT: - if (!g_systemHighlightTextColour) - { - wxColour hclr = GetColour(wxSYS_COLOUR_HIGHLIGHT); - if (hclr.Red() > 200 && hclr.Green() > 200 && hclr.Blue() > 200) - g_systemHighlightTextColour = new wxColour(*wxBLACK); - else - g_systemHighlightTextColour = new wxColour(*wxWHITE); - } - return *g_systemHighlightTextColour; - - case wxSYS_COLOUR_APPWORKSPACE: - return *wxWHITE; // ? - - case wxSYS_COLOUR_HOTLIGHT: - case wxSYS_COLOUR_GRADIENTACTIVECAPTION: - case wxSYS_COLOUR_GRADIENTINACTIVECAPTION: - case wxSYS_COLOUR_MENUHILIGHT: - // TODO - return *wxBLACK; - - case wxSYS_COLOUR_MAX: - default: - wxFAIL_MSG( _T("unknown system colour index") ); - } - - return *wxWHITE; -} - -wxFont wxSystemSettingsNative::GetFont( wxSystemFont index ) -{ - switch (index) - { - case wxSYS_OEM_FIXED_FONT: - case wxSYS_ANSI_FIXED_FONT: - case wxSYS_SYSTEM_FIXED_FONT: - { - return *wxNORMAL_FONT; - } - case wxSYS_ANSI_VAR_FONT: - case wxSYS_SYSTEM_FONT: - case wxSYS_DEVICE_DEFAULT_FONT: - case wxSYS_DEFAULT_GUI_FONT: - { - if (!g_systemFont) - { -#ifdef __WXGTK20__ - GtkWidget *widget = gtk_button_new(); - GtkStyle *def = gtk_rc_get_style( widget ); - if ( !def || !def->font_desc ) - def = gtk_widget_get_default_style(); - if ( def && def->font_desc ) - { - wxNativeFontInfo info; - info.description = def->font_desc; - g_systemFont = new wxFont(info); - } - else - { - GtkSettings *settings = gtk_settings_get_default(); - gchar *font_name = NULL; - g_object_get ( settings, - "gtk-font-name", - &font_name, - NULL); - if (!font_name) - g_systemFont = new wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL ); - else - g_systemFont = new wxFont(wxString::FromAscii(font_name)); - g_free (font_name); - } - gtk_widget_destroy( widget ); -#else - g_systemFont = new wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL ); -#endif - } - return *g_systemFont; - } - - default: - return wxNullFont; - } -} - -int wxSystemSettingsNative::GetMetric( wxSystemMetric index ) -{ - switch (index) - { - case wxSYS_SCREEN_X: return gdk_screen_width(); - case wxSYS_SCREEN_Y: return gdk_screen_height(); - case wxSYS_HSCROLL_Y: return 15; - case wxSYS_VSCROLL_X: return 15; - - // VZ: is there any way to get the cursor size with GDK? - case wxSYS_CURSOR_X: return 16; - case wxSYS_CURSOR_Y: return 16; - // MBN: ditto for icons - case wxSYS_ICON_X: return 32; - case wxSYS_ICON_Y: return 32; - default: - wxFAIL_MSG( wxT("wxSystemSettings::GetMetric not fully implemented") ); - return 0; - } -} - -bool wxSystemSettingsNative::HasFeature(wxSystemFeature index) -{ - switch (index) - { - case wxSYS_CAN_ICONIZE_FRAME: - return FALSE; - break; - case wxSYS_CAN_DRAW_FRAME_DECORATIONS: - return TRUE; - break; - default: - return FALSE; - } -} diff --git a/src/gtk1/slider.cpp b/src/gtk1/slider.cpp deleted file mode 100644 index 37e9491980..0000000000 --- a/src/gtk1/slider.cpp +++ /dev/null @@ -1,286 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: gtk/slider.cpp -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/slider.h" - -#if wxUSE_SLIDER - -#include "wx/utils.h" - -#include - -#include "wx/gtk/private.h" - -//----------------------------------------------------------------------------- -// idle system -//----------------------------------------------------------------------------- - -extern void wxapp_install_idle_handler(); -extern bool g_isIdle; - -//----------------------------------------------------------------------------- -// data -//----------------------------------------------------------------------------- - -extern bool g_blockEventsOnDrag; - -static const float sensitivity = 0.02; - -//----------------------------------------------------------------------------- -// "value_changed" -//----------------------------------------------------------------------------- - -static void gtk_slider_callback( GtkAdjustment *adjust, - SCROLLBAR_CBACK_ARG - wxSlider *win ) -{ - if (g_isIdle) wxapp_install_idle_handler(); - - if (!win->m_hasVMT) return; - if (g_blockEventsOnDrag) return; - - float diff = adjust->value - win->m_oldPos; - if (fabs(diff) < sensitivity) return; - - win->m_oldPos = adjust->value; - - wxEventType command = GtkScrollTypeToWx(GET_SCROLL_TYPE(win->m_widget)); - - double dvalue = adjust->value; - int value = (int)(dvalue < 0 ? dvalue - 0.5 : dvalue + 0.5); - - int orient = win->GetWindowStyleFlag() & wxSL_VERTICAL ? wxVERTICAL - : wxHORIZONTAL; - - wxScrollEvent event( command, win->GetId(), value, orient ); - event.SetEventObject( win ); - win->GetEventHandler()->ProcessEvent( event ); - - wxCommandEvent cevent( wxEVT_COMMAND_SLIDER_UPDATED, win->GetId() ); - cevent.SetEventObject( win ); - cevent.SetInt( value ); - win->GetEventHandler()->ProcessEvent( cevent ); -} - -//----------------------------------------------------------------------------- -// wxSlider -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxSlider,wxControl) - -bool wxSlider::Create(wxWindow *parent, wxWindowID id, - int value, int minValue, int maxValue, - const wxPoint& pos, const wxSize& size, - long style, const wxValidator& validator, const wxString& name ) -{ - m_acceptsFocus = TRUE; - m_needParent = TRUE; - - if (!PreCreation( parent, pos, size ) || - !CreateBase( parent, id, pos, size, style, validator, name )) - { - wxFAIL_MSG( wxT("wxSlider creation failed") ); - return FALSE; - } - - m_oldPos = 0.0; - - if (style & wxSL_VERTICAL) - m_widget = gtk_vscale_new( (GtkAdjustment *) NULL ); - else - m_widget = gtk_hscale_new( (GtkAdjustment *) NULL ); - - if (style & wxSL_LABELS) - { - gtk_scale_set_draw_value( GTK_SCALE( m_widget ), TRUE ); - gtk_scale_set_digits( GTK_SCALE( m_widget ), 0 ); - - /* labels need more space and too small window will - cause junk to appear on the dialog */ - if (style & wxSL_VERTICAL) - { - wxSize sz( size ); - if (sz.x < 35) - { - sz.x = 35; - SetSize( sz ); - } - } - else - { - wxSize sz( size ); - if (sz.y < 35) - { - sz.y = 35; - SetSize( sz ); - } - } - } - else - gtk_scale_set_draw_value( GTK_SCALE( m_widget ), FALSE ); - - m_adjust = gtk_range_get_adjustment( GTK_RANGE(m_widget) ); - - GtkEnableEvents(); - - SetRange( minValue, maxValue ); - SetValue( value ); - - m_parent->DoAddChild( this ); - - PostCreation(); - - SetBackgroundColour( parent->GetBackgroundColour() ); - - Show( TRUE ); - - return TRUE; -} - -int wxSlider::GetValue() const -{ - // we want to round to the nearest integer, i.e. 0.9 is rounded to 1 and - // -0.9 is rounded to -1 - double val = m_adjust->value; - return (int)(val < 0 ? val - 0.5 : val + 0.5); -} - -void wxSlider::SetValue( int value ) -{ - float fpos = (float)value; - m_oldPos = fpos; - if (fabs(fpos-m_adjust->value) < 0.2) return; - - m_adjust->value = fpos; - - GtkDisableEvents(); - - gtk_signal_emit_by_name( GTK_OBJECT(m_adjust), "value_changed" ); - - GtkEnableEvents(); -} - -void wxSlider::SetRange( int minValue, int maxValue ) -{ - float fmin = (float)minValue; - float fmax = (float)maxValue; - - if ((fabs(fmin-m_adjust->lower) < 0.2) && - (fabs(fmax-m_adjust->upper) < 0.2)) - { - return; - } - - m_adjust->lower = fmin; - m_adjust->upper = fmax; - m_adjust->step_increment = 1.0; - m_adjust->page_increment = ceil((fmax-fmin) / 10.0); - - GtkDisableEvents(); - - gtk_signal_emit_by_name( GTK_OBJECT(m_adjust), "changed" ); - - GtkEnableEvents(); -} - -int wxSlider::GetMin() const -{ - return (int)ceil(m_adjust->lower); -} - -int wxSlider::GetMax() const -{ - return (int)ceil(m_adjust->upper); -} - -void wxSlider::SetPageSize( int pageSize ) -{ - float fpage = (float)pageSize; - - if (fabs(fpage-m_adjust->page_increment) < 0.2) return; - - m_adjust->page_increment = fpage; - - GtkDisableEvents(); - - gtk_signal_emit_by_name( GTK_OBJECT(m_adjust), "changed" ); - - GtkEnableEvents(); -} - -int wxSlider::GetPageSize() const -{ - return (int)ceil(m_adjust->page_increment); -} - -void wxSlider::SetThumbLength( int len ) -{ - float flen = (float)len; - - if (fabs(flen-m_adjust->page_size) < 0.2) return; - - m_adjust->page_size = flen; - - GtkDisableEvents(); - - gtk_signal_emit_by_name( GTK_OBJECT(m_adjust), "changed" ); - - GtkEnableEvents(); -} - -int wxSlider::GetThumbLength() const -{ - return (int)ceil(m_adjust->page_size); -} - -void wxSlider::SetLineSize( int WXUNUSED(lineSize) ) -{ -} - -int wxSlider::GetLineSize() const -{ - return 0; -} - -bool wxSlider::IsOwnGtkWindow( GdkWindow *window ) -{ - GtkRange *range = GTK_RANGE(m_widget); -#ifdef __WXGTK20__ - return (range->event_window == window); -#else - return ( (window == GTK_WIDGET(range)->window) - || (window == range->trough) - || (window == range->slider) - || (window == range->step_forw) - || (window == range->step_back) ); -#endif -} - -void wxSlider::ApplyWidgetStyle() -{ - SetWidgetStyle(); - gtk_widget_set_style( m_widget, m_widgetStyle ); -} - -void wxSlider::GtkDisableEvents() -{ - gtk_signal_disconnect_by_func( GTK_OBJECT(m_adjust), - GTK_SIGNAL_FUNC(gtk_slider_callback), - (gpointer) this ); -} - -void wxSlider::GtkEnableEvents() -{ - gtk_signal_connect( GTK_OBJECT (m_adjust), - "value_changed", - GTK_SIGNAL_FUNC(gtk_slider_callback), - (gpointer) this ); -} - -#endif diff --git a/src/gtk1/spinbutt.cpp b/src/gtk1/spinbutt.cpp deleted file mode 100644 index 1c9bf76d8c..0000000000 --- a/src/gtk1/spinbutt.cpp +++ /dev/null @@ -1,235 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: spinbutt.cpp -// Purpose: wxSpinButton -// Author: Robert -// Modified by: -// RCS-ID: $Id$ -// Copyright: (c) Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/spinbutt.h" - -#if wxUSE_SPINBTN - -#include "wx/utils.h" - -#include - -#include "wx/gtk/private.h" - -//----------------------------------------------------------------------------- -// idle system -//----------------------------------------------------------------------------- - -extern void wxapp_install_idle_handler(); -extern bool g_isIdle; - -//----------------------------------------------------------------------------- -// data -//----------------------------------------------------------------------------- - -extern bool g_blockEventsOnDrag; - -static const float sensitivity = 0.02; - -//----------------------------------------------------------------------------- -// "value_changed" -//----------------------------------------------------------------------------- - -static void gtk_spinbutt_callback( GtkWidget *WXUNUSED(widget), wxSpinButton *win ) -{ - if (g_isIdle) wxapp_install_idle_handler(); - - if (!win->m_hasVMT) return; - if (g_blockEventsOnDrag) return; - - float diff = win->m_adjust->value - win->m_oldPos; - if (fabs(diff) < sensitivity) return; - - wxEventType command = wxEVT_NULL; - - float line_step = win->m_adjust->step_increment; - - if (fabs(diff-line_step) < sensitivity) command = wxEVT_SCROLL_LINEUP; - else if (fabs(diff+line_step) < sensitivity) command = wxEVT_SCROLL_LINEDOWN; - else command = wxEVT_SCROLL_THUMBTRACK; - - int value = (int)ceil(win->m_adjust->value); - - wxSpinEvent event( command, win->GetId()); - event.SetPosition( value ); - event.SetEventObject( win ); - - if ((win->GetEventHandler()->ProcessEvent( event )) && - !event.IsAllowed() ) - { - /* program has vetoed */ - win->m_adjust->value = win->m_oldPos; - - gtk_signal_disconnect_by_func( GTK_OBJECT (win->m_adjust), - (GtkSignalFunc) gtk_spinbutt_callback, - (gpointer) win ); - - gtk_signal_emit_by_name( GTK_OBJECT(win->m_adjust), "value_changed" ); - - gtk_signal_connect( GTK_OBJECT (win->m_adjust), - "value_changed", - (GtkSignalFunc) gtk_spinbutt_callback, - (gpointer) win ); - return; - } - - win->m_oldPos = win->m_adjust->value; - - /* always send a thumbtrack event */ - if (command != wxEVT_SCROLL_THUMBTRACK) - { - command = wxEVT_SCROLL_THUMBTRACK; - wxSpinEvent event2( command, win->GetId()); - event2.SetPosition( value ); - event2.SetEventObject( win ); - win->GetEventHandler()->ProcessEvent( event2 ); - } -} - -//----------------------------------------------------------------------------- -// wxSpinButton -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxSpinButton,wxControl) -IMPLEMENT_DYNAMIC_CLASS(wxSpinEvent, wxNotifyEvent) - -BEGIN_EVENT_TABLE(wxSpinButton, wxControl) - EVT_SIZE(wxSpinButton::OnSize) -END_EVENT_TABLE() - -bool wxSpinButton::Create(wxWindow *parent, - wxWindowID id, - const wxPoint& pos, - const wxSize& size, - long style, - const wxString& name) -{ - m_needParent = TRUE; - - wxSize new_size = size, - sizeBest = DoGetBestSize(); - new_size.x = sizeBest.x; // override width always - if (new_size.y == -1) - new_size.y = sizeBest.y; - - if (!PreCreation( parent, pos, new_size ) || - !CreateBase( parent, id, pos, new_size, style, wxDefaultValidator, name )) - { - wxFAIL_MSG( wxT("wxXX creation failed") ); - return FALSE; - } - - m_oldPos = 0.0; - - m_adjust = (GtkAdjustment*) gtk_adjustment_new( 0.0, 0.0, 100.0, 1.0, 5.0, 0.0); - - m_widget = gtk_spin_button_new( m_adjust, 0, 0 ); - - gtk_spin_button_set_wrap( GTK_SPIN_BUTTON(m_widget), - (int)(m_windowStyle & wxSP_WRAP) ); - - gtk_signal_connect( GTK_OBJECT (m_adjust), - "value_changed", - (GtkSignalFunc) gtk_spinbutt_callback, - (gpointer) this ); - - m_parent->DoAddChild( this ); - - PostCreation(); - - SetBackgroundColour( parent->GetBackgroundColour() ); - - Show( TRUE ); - - return TRUE; -} - -int wxSpinButton::GetMin() const -{ - wxCHECK_MSG( (m_widget != NULL), 0, wxT("invalid spin button") ); - - return (int)ceil(m_adjust->lower); -} - -int wxSpinButton::GetMax() const -{ - wxCHECK_MSG( (m_widget != NULL), 0, wxT("invalid spin button") ); - - return (int)ceil(m_adjust->upper); -} - -int wxSpinButton::GetValue() const -{ - wxCHECK_MSG( (m_widget != NULL), 0, wxT("invalid spin button") ); - - return (int)ceil(m_adjust->value); -} - -void wxSpinButton::SetValue( int value ) -{ - wxCHECK_RET( (m_widget != NULL), wxT("invalid spin button") ); - - float fpos = (float)value; - m_oldPos = fpos; - if (fabs(fpos-m_adjust->value) < sensitivity) return; - - m_adjust->value = fpos; - - gtk_signal_emit_by_name( GTK_OBJECT(m_adjust), "value_changed" ); -} - -void wxSpinButton::SetRange(int minVal, int maxVal) -{ - wxCHECK_RET( (m_widget != NULL), wxT("invalid spin button") ); - - float fmin = (float)minVal; - float fmax = (float)maxVal; - - if ((fabs(fmin-m_adjust->lower) < sensitivity) && - (fabs(fmax-m_adjust->upper) < sensitivity)) - { - return; - } - - m_adjust->lower = fmin; - m_adjust->upper = fmax; - - gtk_signal_emit_by_name( GTK_OBJECT(m_adjust), "changed" ); - - // these two calls are required due to some bug in GTK - Refresh(); - SetFocus(); -} - -void wxSpinButton::OnSize( wxSizeEvent &WXUNUSED(event) ) -{ - wxCHECK_RET( (m_widget != NULL), wxT("invalid spin button") ); - - m_width = DoGetBestSize().x; - gtk_widget_set_usize( m_widget, m_width, m_height ); -} - -bool wxSpinButton::IsOwnGtkWindow( GdkWindow *window ) -{ - return GTK_SPIN_BUTTON(m_widget)->panel == window; -} - -void wxSpinButton::ApplyWidgetStyle() -{ - SetWidgetStyle(); - gtk_widget_set_style( m_widget, m_widgetStyle ); -} - -wxSize wxSpinButton::DoGetBestSize() const -{ - return wxSize(15, 26); -} - -#endif diff --git a/src/gtk1/spinctrl.cpp b/src/gtk1/spinctrl.cpp deleted file mode 100644 index 739ea647de..0000000000 --- a/src/gtk1/spinctrl.cpp +++ /dev/null @@ -1,301 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: spinbutt.cpp -// Purpose: wxSpinCtrl -// Author: Robert -// Modified by: -// RCS-ID: $Id$ -// Copyright: (c) Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/spinctrl.h" - -#if wxUSE_SPINCTRL - -#include "wx/utils.h" - -#include "wx/textctrl.h" // for wxEVT_COMMAND_TEXT_UPDATED - -#include - -#include "wx/gtk/private.h" - -//----------------------------------------------------------------------------- -// idle system -//----------------------------------------------------------------------------- - -extern void wxapp_install_idle_handler(); -extern bool g_isIdle; - -static const float sensitivity = 0.02; - -//----------------------------------------------------------------------------- -// data -//----------------------------------------------------------------------------- - -extern bool g_blockEventsOnDrag; - -//----------------------------------------------------------------------------- -// "value_changed" -//----------------------------------------------------------------------------- - -static void gtk_spinctrl_callback( GtkWidget *WXUNUSED(widget), wxSpinCtrl *win ) -{ - if (g_isIdle) wxapp_install_idle_handler(); - - if (!win->m_hasVMT) return; - if (g_blockEventsOnDrag) return; - - wxCommandEvent event( wxEVT_COMMAND_SPINCTRL_UPDATED, win->GetId()); - event.SetEventObject( win ); - - // note that we don't use wxSpinCtrl::GetValue() here because it would - // adjust the value to fit into the control range and this means that we - // would never be able to enter an "invalid" value in the control, even - // temporarily - and trying to enter 10 into the control which accepts the - // values in range 5..50 is then, ummm, quite challenging (hint: you can't - // enter 1!) (VZ) - event.SetInt( (int)ceil(win->m_adjust->value) ); - win->GetEventHandler()->ProcessEvent( event ); -} - -//----------------------------------------------------------------------------- -// "changed" -//----------------------------------------------------------------------------- - -static void -gtk_spinctrl_text_changed_callback( GtkWidget *WXUNUSED(widget), wxSpinCtrl *win ) -{ - if (!win->m_hasVMT) return; - - if (g_isIdle) - wxapp_install_idle_handler(); - - wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, win->GetId() ); - event.SetEventObject( win ); - - // see above - event.SetInt( (int)ceil(win->m_adjust->value) ); - win->GetEventHandler()->ProcessEvent( event ); -} - -//----------------------------------------------------------------------------- -// wxSpinCtrl -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxSpinCtrl,wxControl) - -BEGIN_EVENT_TABLE(wxSpinCtrl, wxControl) - EVT_CHAR(wxSpinCtrl::OnChar) -END_EVENT_TABLE() - -bool wxSpinCtrl::Create(wxWindow *parent, wxWindowID id, - const wxString& value, - const wxPoint& pos, const wxSize& size, - long style, - int min, int max, int initial, - const wxString& name) -{ - m_needParent = TRUE; - m_acceptsFocus = TRUE; - - if (!PreCreation( parent, pos, size ) || - !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) - { - wxFAIL_MSG( wxT("wxSpinCtrl creation failed") ); - return FALSE; - } - - m_oldPos = initial; - - m_adjust = (GtkAdjustment*) gtk_adjustment_new( initial, min, max, 1.0, 5.0, 0.0); - - m_widget = gtk_spin_button_new( m_adjust, 1, 0 ); - - gtk_spin_button_set_wrap( GTK_SPIN_BUTTON(m_widget), - (int)(m_windowStyle & wxSP_WRAP) ); - - GtkEnableEvents(); - - m_parent->DoAddChild( this ); - - PostCreation(); - - SetFont( parent->GetFont() ); - - wxSize size_best( DoGetBestSize() ); - wxSize new_size( size ); - if (new_size.x == -1) - new_size.x = size_best.x; - if (new_size.y == -1) - new_size.y = size_best.y; - if (new_size.y > size_best.y) - new_size.y = size_best.y; - if ((new_size.x != size.x) || (new_size.y != size.y)) - SetSize( new_size.x, new_size.y ); - - SetBackgroundColour( parent->GetBackgroundColour() ); - - SetValue( value ); - - Show( TRUE ); - - return TRUE; -} - -void wxSpinCtrl::GtkDisableEvents() -{ - gtk_signal_disconnect_by_func( GTK_OBJECT(m_adjust), - GTK_SIGNAL_FUNC(gtk_spinctrl_callback), - (gpointer) this ); - - gtk_signal_disconnect_by_func( GTK_OBJECT(m_widget), - GTK_SIGNAL_FUNC(gtk_spinctrl_text_changed_callback), - (gpointer) this ); -} - -void wxSpinCtrl::GtkEnableEvents() -{ - gtk_signal_connect( GTK_OBJECT (m_adjust), - "value_changed", - GTK_SIGNAL_FUNC(gtk_spinctrl_callback), - (gpointer) this ); - - gtk_signal_connect( GTK_OBJECT(m_widget), - "changed", - GTK_SIGNAL_FUNC(gtk_spinctrl_text_changed_callback), - (gpointer)this); -} - -int wxSpinCtrl::GetMin() const -{ - wxCHECK_MSG( (m_widget != NULL), 0, wxT("invalid spin button") ); - - return (int)ceil(m_adjust->lower); -} - -int wxSpinCtrl::GetMax() const -{ - wxCHECK_MSG( (m_widget != NULL), 0, wxT("invalid spin button") ); - - return (int)ceil(m_adjust->upper); -} - -int wxSpinCtrl::GetValue() const -{ - wxCHECK_MSG( (m_widget != NULL), 0, wxT("invalid spin button") ); - - gtk_spin_button_update( GTK_SPIN_BUTTON(m_widget) ); - - return (int)ceil(m_adjust->value); -} - -void wxSpinCtrl::SetValue( const wxString& value ) -{ - wxCHECK_RET( (m_widget != NULL), wxT("invalid spin button") ); - - int n; - if ( (wxSscanf(value, wxT("%d"), &n) == 1) ) - { - // a number - set it - SetValue(n); - } - else - { - // invalid number - set text as is (wxMSW compatible) - GtkDisableEvents(); - gtk_entry_set_text( GTK_ENTRY(m_widget), wxGTK_CONV( value ) ); - GtkEnableEvents(); - } -} - -void wxSpinCtrl::SetValue( int value ) -{ - wxCHECK_RET( (m_widget != NULL), wxT("invalid spin button") ); - - float fpos = (float)value; - m_oldPos = fpos; - if (fabs(fpos-m_adjust->value) < sensitivity) return; - - m_adjust->value = fpos; - - GtkDisableEvents(); - gtk_signal_emit_by_name( GTK_OBJECT(m_adjust), "value_changed" ); - GtkEnableEvents(); -} - -void wxSpinCtrl::SetRange(int minVal, int maxVal) -{ - wxCHECK_RET( (m_widget != NULL), wxT("invalid spin button") ); - - float fmin = (float)minVal; - float fmax = (float)maxVal; - - if ((fabs(fmin-m_adjust->lower) < sensitivity) && - (fabs(fmax-m_adjust->upper) < sensitivity)) - { - return; - } - - m_adjust->lower = fmin; - m_adjust->upper = fmax; - - gtk_signal_emit_by_name( GTK_OBJECT(m_adjust), "changed" ); - - // these two calls are required due to some bug in GTK - Refresh(); - SetFocus(); -} - -void wxSpinCtrl::OnChar( wxKeyEvent &event ) -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid spin ctrl") ); - - if (event.KeyCode() == WXK_RETURN) - { - wxWindow *top_frame = m_parent; - while (top_frame->GetParent() && !(top_frame->GetParent()->IsTopLevel())) - top_frame = top_frame->GetParent(); - - if ( GTK_IS_WINDOW(top_frame->m_widget) ) - { - GtkWindow *window = GTK_WINDOW(top_frame->m_widget); - if ( window ) - { - GtkWidget *widgetDef = window->default_widget; - - if ( widgetDef && GTK_IS_WINDOW(widgetDef) ) - { - gtk_widget_activate(widgetDef); - return; - } - } - } - } - - event.Skip(); -} - -bool wxSpinCtrl::IsOwnGtkWindow( GdkWindow *window ) -{ - if (GTK_SPIN_BUTTON(m_widget)->entry.text_area == window) return TRUE; - - if (GTK_SPIN_BUTTON(m_widget)->panel == window) return TRUE; - - return FALSE; -} - -void wxSpinCtrl::ApplyWidgetStyle() -{ - SetWidgetStyle(); - gtk_widget_set_style( m_widget, m_widgetStyle ); -} - -wxSize wxSpinCtrl::DoGetBestSize() const -{ - wxSize ret( wxControl::DoGetBestSize() ); - return wxSize(95, ret.y); -} - -#endif - // wxUSE_SPINCTRL diff --git a/src/gtk1/statbmp.cpp b/src/gtk1/statbmp.cpp deleted file mode 100644 index 0a8cc8826e..0000000000 --- a/src/gtk1/statbmp.cpp +++ /dev/null @@ -1,122 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: statbmp.cpp -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/defs.h" - -#if wxUSE_STATBMP - -#include "wx/statbmp.h" - -#include "gdk/gdk.h" -#include "gtk/gtk.h" - -//----------------------------------------------------------------------------- -// wxStaticBitmap -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap,wxControl) - -wxStaticBitmap::wxStaticBitmap(void) -{ -} - -wxStaticBitmap::wxStaticBitmap( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap, - const wxPoint &pos, const wxSize &size, - long style, const wxString &name ) -{ - Create( parent, id, bitmap, pos, size, style, name ); -} - -void wxStaticBitmap::CreatePixmapWidget() -{ - wxCHECK_RET( m_bitmap.Ok(), wxT("should only be called if we have a bitmap") ); - - GdkBitmap *mask = (GdkBitmap *) NULL; - if ( m_bitmap.GetMask() ) - mask = m_bitmap.GetMask()->GetBitmap(); - m_widget = gtk_pixmap_new( m_bitmap.GetPixmap(), mask ); - - // insert GTK representation - (*m_parent->m_insertCallback)(m_parent, this); - - gtk_widget_show( m_widget ); - - m_focusWidget = m_widget; - - PostCreation(); -} - -bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bitmap, - const wxPoint &pos, const wxSize &size, - long style, const wxString &name ) -{ - m_needParent = TRUE; - - if (!PreCreation( parent, pos, size ) || - !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) - { - wxFAIL_MSG( wxT("wxXX creation failed") ); - return FALSE; - } - - m_bitmap = bitmap; - - if (m_bitmap.Ok()) - { - GdkBitmap *mask = (GdkBitmap *) NULL; - if ( m_bitmap.GetMask() ) - mask = m_bitmap.GetMask()->GetBitmap(); - m_widget = gtk_pixmap_new( m_bitmap.GetPixmap(), mask ); - - SetBestSize( size ); - } - else - { - m_widget = gtk_label_new( "Bitmap" ); - - m_focusWidget = m_widget; - - PostCreation(); - } - - m_parent->DoAddChild( this ); - - Show( TRUE ); - - return TRUE; -} - -void wxStaticBitmap::SetBitmap( const wxBitmap &bitmap ) -{ - bool hasWidget = m_bitmap.Ok(); - m_bitmap = bitmap; - - if (m_bitmap.Ok()) - { - if (!hasWidget) - { - gtk_widget_destroy( m_widget ); - - /* recreate m_widget because we've created a label - and not a bitmap above */ - CreatePixmapWidget(); - } - else - { - GdkBitmap *mask = (GdkBitmap *) NULL; - if (m_bitmap.GetMask()) mask = m_bitmap.GetMask()->GetBitmap(); - gtk_pixmap_set( GTK_PIXMAP(m_widget), m_bitmap.GetPixmap(), mask ); - } - - SetBestSize(wxSize(bitmap.GetWidth(), bitmap.GetHeight())); - } -} - -#endif // wxUSE_STATBMP - diff --git a/src/gtk1/statbox.cpp b/src/gtk1/statbox.cpp deleted file mode 100644 index cea94cda1a..0000000000 --- a/src/gtk1/statbox.cpp +++ /dev/null @@ -1,99 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: gtk/statbox.cpp -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/defs.h" - -#if wxUSE_STATBOX - -#include "wx/statbox.h" -#include "wx/gtk/private.h" - -#include "gdk/gdk.h" -#include "gtk/gtk.h" - -//----------------------------------------------------------------------------- -// wxStaticBox -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl) - -wxStaticBox::wxStaticBox() -{ -} - -wxStaticBox::wxStaticBox( wxWindow *parent, - wxWindowID id, - const wxString &label, - const wxPoint& pos, - const wxSize& size, - long style, - const wxString& name ) -{ - Create( parent, id, label, pos, size, style, name ); -} - -bool wxStaticBox::Create( wxWindow *parent, - wxWindowID id, - const wxString& label, - const wxPoint& pos, - const wxSize& size, - long style, - const wxString& name ) -{ - m_needParent = TRUE; - - if (!PreCreation( parent, pos, size ) || - !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) - { - wxFAIL_MSG( wxT("wxStaticBox creation failed") ); - return FALSE; - } - - wxControl::SetLabel(label); - - m_widget = gtk_frame_new(m_label.empty() ? (char *)NULL : (const char*) wxGTK_CONV( m_label ) ); - - m_parent->DoAddChild( this ); - - PostCreation(); - - InheritAttributes(); - - // need to set non default alignment? - gfloat xalign; - if ( style & wxALIGN_CENTER ) - xalign = 0.5; - else if ( style & wxALIGN_RIGHT ) - xalign = 1.0; - else // wxALIGN_LEFT - xalign = 0.0; - - if ( xalign ) - gtk_frame_set_label_align(GTK_FRAME( m_widget ), xalign, 0.0); - - Show( TRUE ); - - return TRUE; -} - -void wxStaticBox::SetLabel( const wxString &label ) -{ - wxControl::SetLabel( label ); - - gtk_frame_set_label( GTK_FRAME( m_widget ), - m_label.empty() ? (char *)NULL : (const char*) wxGTK_CONV( m_label ) ); -} - -void wxStaticBox::ApplyWidgetStyle() -{ - SetWidgetStyle(); - gtk_widget_set_style( m_widget, m_widgetStyle ); -} - -#endif // wxUSE_STATBOX diff --git a/src/gtk1/statline.cpp b/src/gtk1/statline.cpp deleted file mode 100644 index 0def049b0d..0000000000 --- a/src/gtk1/statline.cpp +++ /dev/null @@ -1,77 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: statline.cpp -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/statline.h" - -#if wxUSE_STATLINE - -#include "gdk/gdk.h" -#include "gtk/gtk.h" - -//----------------------------------------------------------------------------- -// wxStaticLine -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxStaticLine, wxControl) - -wxStaticLine::wxStaticLine() -{ -} - -wxStaticLine::wxStaticLine( wxWindow *parent, wxWindowID id, - const wxPoint &pos, const wxSize &size, - long style, const wxString &name ) -{ - Create( parent, id, pos, size, style, name ); -} - -bool wxStaticLine::Create( wxWindow *parent, wxWindowID id, - const wxPoint &pos, const wxSize &size, - long style, const wxString &name ) -{ - m_needParent = TRUE; - - if (!PreCreation( parent, pos, size ) || - !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) - { - wxFAIL_MSG( wxT("wxStaticLine creation failed") ); - return FALSE; - } - - if ( IsVertical() ) - { - m_widget = gtk_vseparator_new(); - if (size.x == -1) - { - wxSize new_size( size ); - new_size.x = 4; - SetSize( new_size ); - } - } - else - { - m_widget = gtk_hseparator_new(); - if (size.y == -1) - { - wxSize new_size( size ); - new_size.y = 4; - SetSize( new_size ); - } - } - - m_parent->DoAddChild( this ); - - PostCreation(); - - Show( TRUE ); - - return TRUE; -} - -#endif diff --git a/src/gtk1/stattext.cpp b/src/gtk1/stattext.cpp deleted file mode 100644 index 5ede7c8315..0000000000 --- a/src/gtk1/stattext.cpp +++ /dev/null @@ -1,164 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: stattext.cpp -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/defs.h" - -#if wxUSE_STATTEXT - -#include "wx/stattext.h" -#include "wx/gtk/private.h" - -#include "gdk/gdk.h" -#include "gtk/gtk.h" - -//----------------------------------------------------------------------------- -// wxStaticText -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxStaticText,wxControl) - -wxStaticText::wxStaticText() -{ -} - -wxStaticText::wxStaticText(wxWindow *parent, - wxWindowID id, - const wxString &label, - const wxPoint &pos, - const wxSize &size, - long style, - const wxString &name) -{ - Create( parent, id, label, pos, size, style, name ); -} - -bool wxStaticText::Create(wxWindow *parent, - wxWindowID id, - const wxString &label, - const wxPoint &pos, - const wxSize &size, - long style, - const wxString &name ) -{ - m_needParent = TRUE; - - if (!PreCreation( parent, pos, size ) || - !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) - { - wxFAIL_MSG( wxT("wxXX creation failed") ); - return FALSE; - } - - // notice that we call the base class version which will just remove the - // '&' characters from the string, but not set the label's text to it - // because the label is not yet created and because SetLabel() has a side - // effect of changing the control size which might not be desirable - wxControl::SetLabel(label); - m_widget = gtk_label_new( wxGTK_CONV( m_label ) ); - - GtkJustification justify; - if ( style & wxALIGN_CENTER ) - justify = GTK_JUSTIFY_CENTER; - else if ( style & wxALIGN_RIGHT ) - justify = GTK_JUSTIFY_RIGHT; - else // wxALIGN_LEFT is 0 - justify = GTK_JUSTIFY_LEFT; - gtk_label_set_justify(GTK_LABEL(m_widget), justify); - - // GTK_JUSTIFY_LEFT is 0, RIGHT 1 and CENTER 2 - static const float labelAlignments[] = { 0.0, 1.0, 0.5 }; - gtk_misc_set_alignment(GTK_MISC(m_widget), labelAlignments[justify], 0.0); - - // do not move this call elsewhere - gtk_label_set_line_wrap( GTK_LABEL(m_widget), FALSE ); - - m_parent->DoAddChild( this ); - - PostCreation(); - - ApplyWidgetStyle(); - - wxControl::SetFont( parent->GetFont() ); - - wxSize size_best( DoGetBestSize() ); - wxSize new_size( size ); - if (new_size.x == -1) - new_size.x = size_best.x; - if (new_size.y == -1) - new_size.y = size_best.y; - if ((new_size.x != size.x) || (new_size.y != size.y)) - SetSize( new_size.x, new_size.y ); - - SetBackgroundColour( parent->GetBackgroundColour() ); - SetForegroundColour( parent->GetForegroundColour() ); - Show( TRUE ); - - return TRUE; -} - -wxString wxStaticText::GetLabel() const -{ - GtkLabel *label = GTK_LABEL(m_widget); - -#ifdef __WXGTK20__ - wxString str = wxGTK_CONV_BACK( gtk_label_get_text( label ) ); -#else - wxString str = wxString( label->label ); -#endif - - return wxString(str); -} - -void wxStaticText::SetLabel( const wxString &label ) -{ - wxControl::SetLabel(label); - - gtk_label_set( GTK_LABEL(m_widget), wxGTK_CONV( m_label ) ); - - // adjust the label size to the new label unless disabled - if (!HasFlag(wxST_NO_AUTORESIZE)) - SetSize( GetBestSize() ); -} - -bool wxStaticText::SetFont( const wxFont &font ) -{ - bool ret = wxControl::SetFont(font); - - // adjust the label size to the new label unless disabled - if (!HasFlag(wxST_NO_AUTORESIZE)) - SetSize( GetBestSize() ); - - return ret; -} - -void wxStaticText::ApplyWidgetStyle() -{ - SetWidgetStyle(); - gtk_widget_set_style( m_widget, m_widgetStyle ); -} - -wxSize wxStaticText::DoGetBestSize() const -{ - // Do not return any arbitrary default value... - wxASSERT_MSG( m_widget, wxT("wxStaticText::DoGetBestSize called before creation") ); - - // this invalidates the size request - gtk_label_set_line_wrap( GTK_LABEL(m_widget), TRUE ); - gtk_label_set_line_wrap( GTK_LABEL(m_widget), FALSE ); - - GtkRequisition req; - req.width = 2; - req.height = 2; - (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(m_widget) )->size_request ) - (m_widget, &req ); - - return wxSize(req.width, req.height); -} - -#endif // wxUSE_STATTEXT diff --git a/src/gtk1/tbargtk.cpp b/src/gtk1/tbargtk.cpp deleted file mode 100644 index 73959fa6ef..0000000000 --- a/src/gtk1/tbargtk.cpp +++ /dev/null @@ -1,649 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: tbargtk.cpp -// Purpose: GTK toolbar -// Author: Robert Roebling -// Modified: 13.12.99 by VZ to derive from wxToolBarBase -// RCS-ID: $Id$ -// Copyright: (c) Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -#include "wx/toolbar.h" - -#if wxUSE_TOOLBAR_NATIVE - -#include "wx/frame.h" - -#include -#include "wx/gtk/private.h" - -extern GdkFont *GtkGetDefaultGuiFont(); - -// ---------------------------------------------------------------------------- -// globals -// ---------------------------------------------------------------------------- - -// idle system -extern void wxapp_install_idle_handler(); -extern bool g_isIdle; - -// data -extern bool g_blockEventsOnDrag; -extern wxCursor g_globalCursor; - -// ---------------------------------------------------------------------------- -// private functions -// ---------------------------------------------------------------------------- - -// translate wxWindows toolbar style flags to GTK orientation and style -static void GetGtkStyle(long style, - GtkOrientation *orient, GtkToolbarStyle *gtkStyle) -{ - *orient = style & wxTB_VERTICAL ? GTK_ORIENTATION_VERTICAL - : GTK_ORIENTATION_HORIZONTAL; - - - if ( style & wxTB_TEXT ) - { - *gtkStyle = style & wxTB_NOICONS ? GTK_TOOLBAR_TEXT : GTK_TOOLBAR_BOTH; - } - else // no text, hence we must have the icons or what would we show? - { - *gtkStyle = GTK_TOOLBAR_ICONS; - } -} - -// ---------------------------------------------------------------------------- -// wxToolBarTool -// ---------------------------------------------------------------------------- - -class wxToolBarTool : public wxToolBarToolBase -{ -public: - wxToolBarTool(wxToolBar *tbar, - int id, - const wxString& label, - const wxBitmap& bitmap1, - const wxBitmap& bitmap2, - wxItemKind kind, - wxObject *clientData, - const wxString& shortHelpString, - const wxString& longHelpString) - : wxToolBarToolBase(tbar, id, label, bitmap1, bitmap2, kind, - clientData, shortHelpString, longHelpString) - { - Init(); - } - - wxToolBarTool(wxToolBar *tbar, wxControl *control) - : wxToolBarToolBase(tbar, control) - { - Init(); - } - - // is this a radio button? - // - // unlike GetKind(), can be called for any kind of tools, not just buttons - bool IsRadio() const { return IsButton() && GetKind() == wxITEM_RADIO; } - - // this is only called for the normal buttons, i.e. not separators nor - // controls - GtkToolbarChildType GetGtkChildType() const - { - switch ( GetKind() ) - { - case wxITEM_CHECK: - return GTK_TOOLBAR_CHILD_TOGGLEBUTTON; - - case wxITEM_RADIO: - return GTK_TOOLBAR_CHILD_RADIOBUTTON; - - default: - wxFAIL_MSG( _T("unknown toolbar child type") ); - // fall through - - case wxITEM_NORMAL: - return GTK_TOOLBAR_CHILD_BUTTON; - } - } - - GtkWidget *m_item; - GtkWidget *m_pixmap; - -protected: - void Init(); -}; - -// ---------------------------------------------------------------------------- -// wxWin macros -// ---------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxToolBar, wxToolBarBase) - -// ============================================================================ -// implementation -// ============================================================================ - -//----------------------------------------------------------------------------- -// "clicked" (internal from gtk_toolbar) -//----------------------------------------------------------------------------- - -static void gtk_toolbar_callback( GtkWidget *WXUNUSED(widget), - wxToolBarTool *tool ) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - - wxToolBar *tbar = (wxToolBar *)tool->GetToolBar(); - - if (tbar->m_blockEvent) return; - - if (g_blockEventsOnDrag) return; - if (!tool->IsEnabled()) return; - - if (tool->CanBeToggled()) - { - tool->Toggle(); - - wxBitmap bitmap = tool->GetBitmap(); - if ( bitmap.Ok() ) - { - GtkPixmap *pixmap = GTK_PIXMAP( tool->m_pixmap ); - - GdkBitmap *mask = bitmap.GetMask() ? bitmap.GetMask()->GetBitmap() - : (GdkBitmap *)NULL; - - gtk_pixmap_set( pixmap, bitmap.GetPixmap(), mask ); - } - - if ( tool->IsRadio() && !tool->IsToggled() ) - { - // radio button went up, don't report this as a wxWin event - return; - } - } - - tbar->OnLeftClick( tool->GetId(), tool->IsToggled() ); -} - -//----------------------------------------------------------------------------- -// "enter_notify_event" / "leave_notify_event" -//----------------------------------------------------------------------------- - -static gint gtk_toolbar_tool_callback( GtkWidget *WXUNUSED(widget), - GdkEventCrossing *gdk_event, - wxToolBarTool *tool ) -{ - if (g_isIdle) wxapp_install_idle_handler(); - - if (g_blockEventsOnDrag) return TRUE; - - wxToolBar *tb = (wxToolBar *)tool->GetToolBar(); - - // emit the event - if( gdk_event->type == GDK_ENTER_NOTIFY ) - tb->OnMouseEnter( tool->GetId() ); - else - tb->OnMouseEnter( -1 ); - - return FALSE; -} - -//----------------------------------------------------------------------------- -// InsertChild callback for wxToolBar -//----------------------------------------------------------------------------- - -static void wxInsertChildInToolBar( wxToolBar* WXUNUSED(parent), - wxWindow* WXUNUSED(child) ) -{ - // we don't do anything here -} - -// ---------------------------------------------------------------------------- -// wxToolBarTool -// ---------------------------------------------------------------------------- - -void wxToolBarTool::Init() -{ - m_item = - m_pixmap = (GtkWidget *)NULL; -} - -wxToolBarToolBase *wxToolBar::CreateTool(int id, - const wxString& text, - const wxBitmap& bitmap1, - const wxBitmap& bitmap2, - wxItemKind kind, - wxObject *clientData, - const wxString& shortHelpString, - const wxString& longHelpString) -{ - return new wxToolBarTool(this, id, text, bitmap1, bitmap2, kind, - clientData, shortHelpString, longHelpString); -} - -wxToolBarToolBase *wxToolBar::CreateTool(wxControl *control) -{ - return new wxToolBarTool(this, control); -} - -//----------------------------------------------------------------------------- -// wxToolBar construction -//----------------------------------------------------------------------------- - -void wxToolBar::Init() -{ - m_fg = - m_bg = (GdkColor *)NULL; - m_toolbar = (GtkToolbar *)NULL; - m_blockEvent = FALSE; - m_defaultWidth = 32; - m_defaultHeight = 32; -} - -wxToolBar::~wxToolBar() -{ - delete m_fg; - delete m_bg; -} - -bool wxToolBar::Create( wxWindow *parent, - wxWindowID id, - const wxPoint& pos, - const wxSize& size, - long style, - const wxString& name ) -{ - m_needParent = TRUE; - m_insertCallback = (wxInsertChildFunction)wxInsertChildInToolBar; - - if ( !PreCreation( parent, pos, size ) || - !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) - { - wxFAIL_MSG( wxT("wxToolBar creation failed") ); - - return FALSE; - } - -#ifdef __WXGTK20__ - m_toolbar = GTK_TOOLBAR( gtk_toolbar_new() ); - GtkSetStyle(); - - // Doesn't work this way. - // GtkToolbarSpaceStyle space_style = GTK_TOOLBAR_SPACE_EMPTY; - // gtk_widget_style_set (GTK_WIDGET (m_toolbar), "space_style", &space_style, NULL); -#else - GtkOrientation orient; - GtkToolbarStyle gtkStyle; - GetGtkStyle(style, &orient, >kStyle); - - m_toolbar = GTK_TOOLBAR( gtk_toolbar_new(orient, gtkStyle) ); -#endif - - SetToolSeparation(7); - - if (style & wxTB_DOCKABLE) - { - m_widget = gtk_handle_box_new(); - gtk_container_add( GTK_CONTAINER(m_widget), GTK_WIDGET(m_toolbar) ); - gtk_widget_show( GTK_WIDGET(m_toolbar) ); - - if (style & wxTB_FLAT) - gtk_handle_box_set_shadow_type( GTK_HANDLE_BOX(m_widget), GTK_SHADOW_NONE ); - } - else - { - m_widget = gtk_event_box_new(); - gtk_container_add( GTK_CONTAINER(m_widget), GTK_WIDGET(m_toolbar) ); - ConnectWidget( m_widget ); - gtk_widget_show(GTK_WIDGET(m_toolbar)); - } - - gtk_toolbar_set_tooltips( GTK_TOOLBAR(m_toolbar), TRUE ); - - // FIXME: there is no such function for toolbars in 2.0 -#ifndef __WXGTK20__ - if (style & wxTB_FLAT) - gtk_toolbar_set_button_relief( GTK_TOOLBAR(m_toolbar), GTK_RELIEF_NONE ); -#endif - - m_parent->DoAddChild( this ); - - PostCreation(); - - Show( TRUE ); - - return TRUE; -} - -void wxToolBar::GtkSetStyle() -{ - GtkOrientation orient; - GtkToolbarStyle style; - GetGtkStyle(GetWindowStyle(), &orient, &style); - - gtk_toolbar_set_orientation(m_toolbar, orient); - gtk_toolbar_set_style(m_toolbar, style); -} - -void wxToolBar::SetWindowStyleFlag( long style ) -{ - wxToolBarBase::SetWindowStyleFlag(style); - - if ( m_toolbar ) - GtkSetStyle(); -} - -bool wxToolBar::DoInsertTool(size_t pos, wxToolBarToolBase *toolBase) -{ - wxToolBarTool *tool = (wxToolBarTool *)toolBase; - -#ifndef __WXGTK20__ - // if we have inserted a space before all the tools we must change the GTK - // index by 1 - size_t posGtk = m_xMargin > 1 ? pos + 1 : pos; -#else - size_t posGtk = pos; -#endif - - if ( tool->IsButton() ) - { - if ( !HasFlag(wxTB_NOICONS) ) - { - wxBitmap bitmap = tool->GetNormalBitmap(); - - wxCHECK_MSG( bitmap.Ok(), FALSE, - wxT("invalid bitmap for wxToolBar icon") ); - - wxCHECK_MSG( bitmap.GetBitmap() == NULL, FALSE, - wxT("wxToolBar doesn't support GdkBitmap") ); - - wxCHECK_MSG( bitmap.GetPixmap() != NULL, FALSE, - wxT("wxToolBar::Add needs a wxBitmap") ); - - GtkWidget *tool_pixmap = (GtkWidget *)NULL; - - GdkPixmap *pixmap = bitmap.GetPixmap(); - - GdkBitmap *mask = (GdkBitmap *)NULL; - if ( bitmap.GetMask() ) - mask = bitmap.GetMask()->GetBitmap(); - - tool_pixmap = gtk_pixmap_new( pixmap, mask ); - gtk_pixmap_set_build_insensitive( GTK_PIXMAP(tool_pixmap), TRUE ); - - gtk_misc_set_alignment( GTK_MISC(tool_pixmap), 0.5, 0.5 ); - - tool->m_pixmap = tool_pixmap; - } - } - - switch ( tool->GetStyle() ) - { - case wxTOOL_STYLE_BUTTON: - // for a radio button we need the widget which starts the radio - // group it belongs to, i.e. the first radio button immediately - // preceding this one - { - GtkWidget *widget = NULL; - - if ( tool->IsRadio() ) - { - wxToolBarToolsList::Node *node = pos ? m_tools.Item(pos - 1) - : NULL; - while ( node ) - { - wxToolBarTool *tool = (wxToolBarTool *)node->GetData(); - if ( !tool->IsRadio() ) - break; - - widget = tool->m_item; - - node = node->GetPrevious(); - } - - if ( !widget ) - { - // this is the first button in the radio button group, - // it will be toggled automatically by GTK so bring the - // internal flag in sync - tool->Toggle(TRUE); - } - } - - tool->m_item = gtk_toolbar_insert_element - ( - m_toolbar, - tool->GetGtkChildType(), - widget, - tool->GetLabel().empty() - ? NULL - : (const char*) wxGTK_CONV( tool->GetLabel() ), - tool->GetShortHelp().empty() - ? NULL - : (const char*) wxGTK_CONV( tool->GetShortHelp() ), - "", // tooltip_private_text (?) - tool->m_pixmap, - (GtkSignalFunc)gtk_toolbar_callback, - (gpointer)tool, - posGtk - ); - - if ( !tool->m_item ) - { - wxFAIL_MSG( _T("gtk_toolbar_insert_element() failed") ); - - return FALSE; - } - - gtk_signal_connect( GTK_OBJECT(tool->m_item), - "enter_notify_event", - GTK_SIGNAL_FUNC(gtk_toolbar_tool_callback), - (gpointer)tool ); - gtk_signal_connect( GTK_OBJECT(tool->m_item), - "leave_notify_event", - GTK_SIGNAL_FUNC(gtk_toolbar_tool_callback), - (gpointer)tool ); - } - break; - - case wxTOOL_STYLE_SEPARATOR: - gtk_toolbar_insert_space( m_toolbar, posGtk ); - - // skip the rest - return TRUE; - - case wxTOOL_STYLE_CONTROL: - gtk_toolbar_insert_widget( - m_toolbar, - tool->GetControl()->m_widget, - (const char *) NULL, - (const char *) NULL, - posGtk - ); - break; - } - - GtkRequisition req; - (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(m_widget) )->size_request ) - (m_widget, &req ); - m_width = req.width + m_xMargin; - m_height = req.height + 2*m_yMargin; - - return TRUE; -} - -bool wxToolBar::DoDeleteTool(size_t WXUNUSED(pos), wxToolBarToolBase *toolBase) -{ - wxToolBarTool *tool = (wxToolBarTool *)toolBase; - - switch ( tool->GetStyle() ) - { - case wxTOOL_STYLE_CONTROL: - tool->GetControl()->Destroy(); - break; - - case wxTOOL_STYLE_BUTTON: - gtk_widget_destroy( tool->m_item ); - break; - - //case wxTOOL_STYLE_SEPARATOR: -- nothing to do - } - - return TRUE; -} - -// ---------------------------------------------------------------------------- -// wxToolBar tools state -// ---------------------------------------------------------------------------- - -void wxToolBar::DoEnableTool(wxToolBarToolBase *toolBase, bool enable) -{ - wxToolBarTool *tool = (wxToolBarTool *)toolBase; - - if (tool->m_item) - { - gtk_widget_set_sensitive( tool->m_item, enable ); - } -} - -void wxToolBar::DoToggleTool( wxToolBarToolBase *toolBase, bool toggle ) -{ - wxToolBarTool *tool = (wxToolBarTool *)toolBase; - - GtkWidget *item = tool->m_item; - if ( item && GTK_IS_TOGGLE_BUTTON(item) ) - { - wxBitmap bitmap = tool->GetBitmap(); - if ( bitmap.Ok() ) - { - GtkPixmap *pixmap = GTK_PIXMAP( tool->m_pixmap ); - - GdkBitmap *mask = bitmap.GetMask() ? bitmap.GetMask()->GetBitmap() - : (GdkBitmap *)NULL; - - gtk_pixmap_set( pixmap, bitmap.GetPixmap(), mask ); - } - - m_blockEvent = TRUE; - - gtk_toggle_button_set_state( GTK_TOGGLE_BUTTON(item), toggle ); - - m_blockEvent = FALSE; - } -} - -void wxToolBar::DoSetToggle(wxToolBarToolBase * WXUNUSED(tool), - bool WXUNUSED(toggle)) -{ - // VZ: absolutely no idea about how to do it - wxFAIL_MSG( _T("not implemented") ); -} - -// ---------------------------------------------------------------------------- -// wxToolBar geometry -// ---------------------------------------------------------------------------- - -wxToolBarToolBase *wxToolBar::FindToolForPosition(wxCoord WXUNUSED(x), - wxCoord WXUNUSED(y)) const -{ - // VZ: GTK+ doesn't seem to have such thing - wxFAIL_MSG( _T("wxToolBar::FindToolForPosition() not implemented") ); - - return (wxToolBarToolBase *)NULL; -} - -void wxToolBar::SetMargins( int x, int y ) -{ - wxCHECK_RET( GetToolsCount() == 0, - wxT("wxToolBar::SetMargins must be called before adding tools.") ); - -#ifndef __WXGTK20__ - if (x > 1) - gtk_toolbar_append_space( m_toolbar ); // oh well -#endif - - m_xMargin = x; - m_yMargin = y; -} - -void wxToolBar::SetToolSeparation( int separation ) -{ - // FIXME: this function disappeared -#ifndef __WXGTK20__ - gtk_toolbar_set_space_size( m_toolbar, separation ); -#endif - - m_toolSeparation = separation; -} - -void wxToolBar::SetToolShortHelp( int id, const wxString& helpString ) -{ - wxToolBarTool *tool = (wxToolBarTool *)FindById(id); - - if ( tool ) - { - (void)tool->SetShortHelp(helpString); - gtk_tooltips_set_tip(m_toolbar->tooltips, tool->m_item, - wxGTK_CONV( helpString ), ""); - } -} - -// ---------------------------------------------------------------------------- -// wxToolBar idle handling -// ---------------------------------------------------------------------------- - -void wxToolBar::OnInternalIdle() -{ - wxCursor cursor = m_cursor; - if (g_globalCursor.Ok()) cursor = g_globalCursor; - - if (cursor.Ok()) - { - /* I now set the cursor the anew in every OnInternalIdle call - as setting the cursor in a parent window also effects the - windows above so that checking for the current cursor is - not possible. */ - - if (HasFlag(wxTB_DOCKABLE) && (m_widget->window)) - { - /* if the toolbar is dockable, then m_widget stands for the - GtkHandleBox widget, which uses its own window so that we - can set the cursor for it. if the toolbar is not dockable, - m_widget comes from m_toolbar which uses its parent's - window ("windowless windows") and thus we cannot set the - cursor. */ - gdk_window_set_cursor( m_widget->window, cursor.GetCursor() ); - } - - wxToolBarToolsList::Node *node = m_tools.GetFirst(); - while ( node ) - { - wxToolBarTool *tool = (wxToolBarTool *)node->GetData(); - node = node->GetNext(); - - GtkWidget *item = tool->m_item; - if ( item ) - { - GdkWindow *window = item->window; - - if ( window ) - { - gdk_window_set_cursor( window, cursor.GetCursor() ); - } - } - } - } - - UpdateWindowUI(); -} - -#endif // wxUSE_TOOLBAR_NATIVE diff --git a/src/gtk1/textctrl.cpp b/src/gtk1/textctrl.cpp deleted file mode 100644 index ebb049da8a..0000000000 --- a/src/gtk1/textctrl.cpp +++ /dev/null @@ -1,1721 +0,0 @@ - -///////////////////////////////////////////////////////////////////////////// -// Name: textctrl.cpp -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling, Vadim Zeitlin -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/textctrl.h" -#include "wx/utils.h" -#include "wx/intl.h" -#include "wx/log.h" -#include "wx/settings.h" -#include "wx/panel.h" -#include "wx/strconv.h" -#include "wx/fontutil.h" // for wxNativeFontInfo (GetNativeFontInfo()) - -#include -#include -#include -#include // for fabs - -#include "wx/gtk/private.h" -#include - -//----------------------------------------------------------------------------- -// idle system -//----------------------------------------------------------------------------- - -extern void wxapp_install_idle_handler(); -extern bool g_isIdle; - -//----------------------------------------------------------------------------- -// data -//----------------------------------------------------------------------------- - -extern bool g_blockEventsOnDrag; -extern wxCursor g_globalCursor; -extern wxWindowGTK *g_delayedFocus; - -// ---------------------------------------------------------------------------- -// helpers -// ---------------------------------------------------------------------------- - -#ifdef __WXGTK20__ -static void wxGtkTextInsert(GtkWidget *text, - GtkTextBuffer *text_buffer, - const wxTextAttr& attr, - wxCharBuffer buffer) - -{ - PangoFontDescription *font_description = attr.HasFont() - ? attr.GetFont().GetNativeFontInfo()->description - : NULL; - - GdkColor *colFg = attr.HasTextColour() ? attr.GetTextColour().GetColor() - : NULL; - - GdkColor *colBg = attr.HasBackgroundColour() - ? attr.GetBackgroundColour().GetColor() - : NULL; - - GtkTextIter start, end; - GtkTextMark *mark; - // iterators are invalidated by any mutation that affects 'indexable' buffer contents, - // so we save current position in a mark - // we need a mark of left gravity, so we cannot use - // mark = gtk_text_buffer_get_insert (text_buffer) - - gtk_text_buffer_get_iter_at_mark( text_buffer, &start, - gtk_text_buffer_get_insert (text_buffer) ); - mark = gtk_text_buffer_create_mark( text_buffer, NULL, &start, TRUE/*left gravity*/ ); - - gtk_text_buffer_insert_at_cursor( text_buffer, buffer, strlen(buffer) ); - - gtk_text_buffer_get_iter_at_mark( text_buffer, &end, - gtk_text_buffer_get_insert (text_buffer) ); - gtk_text_buffer_get_iter_at_mark( text_buffer, &start, mark ); - - GtkTextTag *tag; - tag = gtk_text_buffer_create_tag( text_buffer, NULL, "font-desc", font_description, - "foreground-gdk", colFg, - "background-gdk", colBg, NULL ); - gtk_text_buffer_apply_tag( text_buffer, tag, &start, &end ); -} -#else -static void wxGtkTextInsert(GtkWidget *text, - const wxTextAttr& attr, - const char *txt, - size_t len) -{ - GdkFont *font = attr.HasFont() ? attr.GetFont().GetInternalFont() - : NULL; - - GdkColor *colFg = attr.HasTextColour() ? attr.GetTextColour().GetColor() - : NULL; - - GdkColor *colBg = attr.HasBackgroundColour() - ? attr.GetBackgroundColour().GetColor() - : NULL; - - gtk_text_insert( GTK_TEXT(text), font, colFg, colBg, txt, len ); -} -#endif // GTK 1.x - -// ---------------------------------------------------------------------------- -// "insert_text" for GtkEntry -// ---------------------------------------------------------------------------- - -static void -gtk_insert_text_callback(GtkEditable *editable, - const gchar *new_text, - gint new_text_length, - gint *position, - wxTextCtrl *win) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - - // we should only be called if we have a max len limit at all - GtkEntry *entry = GTK_ENTRY (editable); - - wxCHECK_RET( entry->text_max_length, _T("shouldn't be called") ); - - // check that we don't overflow the max length limit - // - // FIXME: this doesn't work when we paste a string which is going to be - // truncated - if ( entry->text_length == entry->text_max_length ) - { - // we don't need to run the base class version at all - gtk_signal_emit_stop_by_name(GTK_OBJECT(editable), "insert_text"); - - // remember that the next changed signal is to be ignored to avoid - // generating a dummy wxEVT_COMMAND_TEXT_UPDATED event - win->IgnoreNextTextUpdate(); - - // and generate the correct one ourselves - wxCommandEvent event(wxEVT_COMMAND_TEXT_MAXLEN, win->GetId()); - event.SetEventObject(win); - event.SetString(win->GetValue()); - win->GetEventHandler()->ProcessEvent( event ); - } -} - -//----------------------------------------------------------------------------- -// "changed" -//----------------------------------------------------------------------------- - -static void -gtk_text_changed_callback( GtkWidget *widget, wxTextCtrl *win ) -{ - if ( win->IgnoreTextUpdate() ) - return; - - if (!win->m_hasVMT) return; - - if (g_isIdle) - wxapp_install_idle_handler(); - - win->SetModified(); - win->UpdateFontIfNeeded(); - - wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, win->GetId() ); - event.SetEventObject( win ); - event.SetString( win->GetValue() ); - win->GetEventHandler()->ProcessEvent( event ); -} - -//----------------------------------------------------------------------------- -// "changed" from vertical scrollbar -//----------------------------------------------------------------------------- - -#ifndef __WXGTK20__ -static void -gtk_scrollbar_changed_callback( GtkWidget *WXUNUSED(widget), wxTextCtrl *win ) -{ - if (!win->m_hasVMT) return; - - if (g_isIdle) - wxapp_install_idle_handler(); - - win->CalculateScrollbar(); -} -#endif - -// ---------------------------------------------------------------------------- -// redraw callback for multiline text -// ---------------------------------------------------------------------------- - -#ifndef __WXGTK20__ - -// redrawing a GtkText from inside a wxYield() call results in crashes (the -// text sample shows it in its "Add lines" command which shows wxProgressDialog -// which implicitly calls wxYield()) so we override GtkText::draw() and simply -// don't do anything if we're inside wxYield() - -extern bool wxIsInsideYield; - -extern "C" { - typedef void (*GtkDrawCallback)(GtkWidget *widget, GdkRectangle *rect); -} - -static GtkDrawCallback gs_gtk_text_draw = NULL; - -extern "C" -void wxgtk_text_draw( GtkWidget *widget, GdkRectangle *rect) -{ - if ( !wxIsInsideYield ) - { - wxCHECK_RET( gs_gtk_text_draw != wxgtk_text_draw, - _T("infinite recursion in wxgtk_text_draw aborted") ); - - gs_gtk_text_draw(widget, rect); - } -} - -#endif // __WXGTK20__ - -//----------------------------------------------------------------------------- -// wxTextCtrl -//----------------------------------------------------------------------------- - -IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl,wxControl) - -BEGIN_EVENT_TABLE(wxTextCtrl, wxControl) - EVT_CHAR(wxTextCtrl::OnChar) - - EVT_MENU(wxID_CUT, wxTextCtrl::OnCut) - EVT_MENU(wxID_COPY, wxTextCtrl::OnCopy) - EVT_MENU(wxID_PASTE, wxTextCtrl::OnPaste) - EVT_MENU(wxID_UNDO, wxTextCtrl::OnUndo) - EVT_MENU(wxID_REDO, wxTextCtrl::OnRedo) - - EVT_UPDATE_UI(wxID_CUT, wxTextCtrl::OnUpdateCut) - EVT_UPDATE_UI(wxID_COPY, wxTextCtrl::OnUpdateCopy) - EVT_UPDATE_UI(wxID_PASTE, wxTextCtrl::OnUpdatePaste) - EVT_UPDATE_UI(wxID_UNDO, wxTextCtrl::OnUpdateUndo) - EVT_UPDATE_UI(wxID_REDO, wxTextCtrl::OnUpdateRedo) -END_EVENT_TABLE() - -void wxTextCtrl::Init() -{ - m_ignoreNextUpdate = - m_modified = FALSE; - m_updateFont = FALSE; - m_text = - m_vScrollbar = (GtkWidget *)NULL; -} - -wxTextCtrl::wxTextCtrl( wxWindow *parent, - wxWindowID id, - const wxString &value, - const wxPoint &pos, - const wxSize &size, - long style, - const wxValidator& validator, - const wxString &name ) -{ - Init(); - - Create( parent, id, value, pos, size, style, validator, name ); -} - -bool wxTextCtrl::Create( wxWindow *parent, - wxWindowID id, - const wxString &value, - const wxPoint &pos, - const wxSize &size, - long style, - const wxValidator& validator, - const wxString &name ) -{ - m_needParent = TRUE; - m_acceptsFocus = TRUE; - - if (!PreCreation( parent, pos, size ) || - !CreateBase( parent, id, pos, size, style, validator, name )) - { - wxFAIL_MSG( wxT("wxTextCtrl creation failed") ); - return FALSE; - } - - - m_vScrollbarVisible = FALSE; - - bool multi_line = (style & wxTE_MULTILINE) != 0; - -#ifdef __WXGTK20__ - GtkTextBuffer *buffer = NULL; -#endif - - if (multi_line) - { -#ifdef __WXGTK20__ - // Create view - m_text = gtk_text_view_new(); - - buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_text) ); - - // create scrolled window - m_widget = gtk_scrolled_window_new( NULL, NULL ); - gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( m_widget ), - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC ); - - // Insert view into scrolled window - gtk_container_add( GTK_CONTAINER(m_widget), m_text ); - - // Global settings which can be overridden by tags, I guess. - if (HasFlag( wxHSCROLL )) - gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW( m_text ), GTK_WRAP_NONE ); - else - gtk_text_view_set_wrap_mode( GTK_TEXT_VIEW( m_text ), GTK_WRAP_WORD ); - - if (!HasFlag(wxNO_BORDER)) - gtk_scrolled_window_set_shadow_type( GTK_SCROLLED_WINDOW(m_widget), GTK_SHADOW_IN ); -#else - // create our control ... - m_text = gtk_text_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL ); - - // ... and put into the upper left hand corner of the table - bool bHasHScrollbar = FALSE; - m_widget = gtk_table_new(bHasHScrollbar ? 2 : 1, 2, FALSE); - GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS ); - gtk_table_attach( GTK_TABLE(m_widget), m_text, 0, 1, 0, 1, - (GtkAttachOptions)(GTK_FILL | GTK_EXPAND | GTK_SHRINK), - (GtkAttachOptions)(GTK_FILL | GTK_EXPAND | GTK_SHRINK), - 0, 0); - - // always wrap words - gtk_text_set_word_wrap( GTK_TEXT(m_text), TRUE ); - - // finally, put the vertical scrollbar in the upper right corner - m_vScrollbar = gtk_vscrollbar_new( GTK_TEXT(m_text)->vadj ); - GTK_WIDGET_UNSET_FLAGS( m_vScrollbar, GTK_CAN_FOCUS ); - gtk_table_attach(GTK_TABLE(m_widget), m_vScrollbar, 1, 2, 0, 1, - GTK_FILL, - (GtkAttachOptions)(GTK_EXPAND | GTK_FILL | GTK_SHRINK), - 0, 0); -#endif - } - else - { - // a single-line text control: no need for scrollbars - m_widget = - m_text = gtk_entry_new(); - } - - m_parent->DoAddChild( this ); - - m_focusWidget = m_text; - - PostCreation(); - - SetFont( parent->GetFont() ); - - wxSize size_best( DoGetBestSize() ); - wxSize new_size( size ); - if (new_size.x == -1) - new_size.x = size_best.x; - if (new_size.y == -1) - new_size.y = size_best.y; - if ((new_size.x != size.x) || (new_size.y != size.y)) - SetSize( new_size.x, new_size.y ); - - if (multi_line) - gtk_widget_show(m_text); - -#ifndef __WXGTK20__ - if (multi_line) - { - gtk_signal_connect(GTK_OBJECT(GTK_TEXT(m_text)->vadj), "changed", - (GtkSignalFunc) gtk_scrollbar_changed_callback, (gpointer) this ); - - // only initialize gs_gtk_text_draw once, starting from the next the - // klass::draw will already be wxgtk_text_draw - if ( !gs_gtk_text_draw ) - { - GtkDrawCallback& - draw = GTK_WIDGET_CLASS(GTK_OBJECT(m_text)->klass)->draw; - - gs_gtk_text_draw = draw; - - draw = wxgtk_text_draw; - } - } -#endif // GTK+ 1.x - - if (!value.IsEmpty()) - { -#ifdef __WXGTK20__ - SetValue( value ); -#else - -#if !GTK_CHECK_VERSION(1, 2, 0) - // if we don't realize it, GTK 1.0.6 dies with a SIGSEGV in - // gtk_editable_insert_text() - gtk_widget_realize(m_text); -#endif // GTK 1.0 - - gint tmp = 0; -#if wxUSE_UNICODE - wxWX2MBbuf val = value.mbc_str(); - gtk_editable_insert_text( GTK_EDITABLE(m_text), val, strlen(val), &tmp ); -#else - gtk_editable_insert_text( GTK_EDITABLE(m_text), value, value.Length(), &tmp ); -#endif - - if (multi_line) - { - // Bring editable's cursor uptodate. Bug in GTK. - SET_EDITABLE_POS(m_text, gtk_text_get_point( GTK_TEXT(m_text) )); - } - -#endif - } - - if (style & wxTE_PASSWORD) - { - if (!multi_line) - gtk_entry_set_visibility( GTK_ENTRY(m_text), FALSE ); - } - - if (style & wxTE_READONLY) - { - if (!multi_line) - gtk_entry_set_editable( GTK_ENTRY(m_text), FALSE ); -#ifdef __WXGTK20__ - else - gtk_text_view_set_editable( GTK_TEXT_VIEW( m_text), FALSE); - } -#else - } - else - { - if (multi_line) - gtk_text_set_editable( GTK_TEXT(m_text), 1 ); - } -#endif - - // We want to be notified about text changes. -#ifdef __WXGTK20__ - if (multi_line) - { - g_signal_connect( G_OBJECT(buffer), "changed", - GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); - } - else -#endif - { - gtk_signal_connect( GTK_OBJECT(m_text), "changed", - GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this); - } - - // we don't set a valid background colour, because the window - // manager should use a default one - m_backgroundColour = wxColour(); - - wxColour colFg = parent->GetForegroundColour(); - SetForegroundColour( colFg ); - - m_cursor = wxCursor( wxCURSOR_IBEAM ); - - wxTextAttr attrDef( colFg, m_backgroundColour, parent->GetFont() ); - SetDefaultStyle( attrDef ); - - Show( TRUE ); - - return TRUE; -} - -void wxTextCtrl::CalculateScrollbar() -{ -#ifndef __WXGTK20__ - if ((m_windowStyle & wxTE_MULTILINE) == 0) return; - - GtkAdjustment *adj = GTK_TEXT(m_text)->vadj; - - if (adj->upper - adj->page_size < 0.8) - { - if (m_vScrollbarVisible) - { - gtk_widget_hide( m_vScrollbar ); - m_vScrollbarVisible = FALSE; - } - } - else - { - if (!m_vScrollbarVisible) - { - gtk_widget_show( m_vScrollbar ); - m_vScrollbarVisible = TRUE; - } - } -#endif -} - -wxString wxTextCtrl::GetValue() const -{ - wxCHECK_MSG( m_text != NULL, wxT(""), wxT("invalid text ctrl") ); - - wxString tmp; - if (m_windowStyle & wxTE_MULTILINE) - { -#ifdef __WXGTK20__ - GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_text) ); - - GtkTextIter start; - gtk_text_buffer_get_start_iter( text_buffer, &start ); - GtkTextIter end; - gtk_text_buffer_get_end_iter( text_buffer, &end ); - gchar *text = gtk_text_buffer_get_text( text_buffer, &start, &end, TRUE ); - -#if wxUSE_UNICODE - wxWCharBuffer buffer( wxConvUTF8.cMB2WX( text ) ); -#else - wxCharBuffer buffer( wxConvLocal.cWC2WX( wxConvUTF8.cMB2WC( text ) ) ); -#endif - tmp = buffer; - - g_free( text ); -#else - gint len = gtk_text_get_length( GTK_TEXT(m_text) ); - char *text = gtk_editable_get_chars( GTK_EDITABLE(m_text), 0, len ); - tmp = text; - g_free( text ); -#endif - } - else - { - tmp = wxGTK_CONV_BACK( gtk_entry_get_text( GTK_ENTRY(m_text) ) ); - } - - return tmp; -} - -void wxTextCtrl::SetValue( const wxString &value ) -{ - wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") ); - - if (m_windowStyle & wxTE_MULTILINE) - { -#ifdef __WXGTK20__ - -#if wxUSE_UNICODE - wxCharBuffer buffer( wxConvUTF8.cWX2MB( value) ); -#else - wxCharBuffer buffer( wxConvUTF8.cWC2MB( wxConvLocal.cWX2WC( value ) ) ); -#endif - GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_text) ); - gtk_text_buffer_set_text( text_buffer, buffer, strlen(buffer) ); - -#else - gint len = gtk_text_get_length( GTK_TEXT(m_text) ); - gtk_editable_delete_text( GTK_EDITABLE(m_text), 0, len ); - len = 0; - gtk_editable_insert_text( GTK_EDITABLE(m_text), value.mbc_str(), value.Length(), &len ); -#endif - } - else - { - gtk_entry_set_text( GTK_ENTRY(m_text), wxGTK_CONV( value ) ); - } - - // GRG, Jun/2000: Changed this after a lot of discussion in - // the lists. wxWindows 2.2 will have a set of flags to - // customize this behaviour. - SetInsertionPoint(0); - - m_modified = FALSE; -} - -void wxTextCtrl::WriteText( const wxString &text ) -{ - wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") ); - - if ( text.empty() ) - return; - - if ( m_windowStyle & wxTE_MULTILINE ) - { -#ifdef __WXGTK20__ - -#if wxUSE_UNICODE - wxCharBuffer buffer( wxConvUTF8.cWX2MB( text ) ); -#else - wxCharBuffer buffer( wxConvUTF8.cWC2MB( wxConvLocal.cWX2WC( text ) ) ); -#endif - GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_text) ); - - // TODO: Call whatever is needed to delete the selection. - wxGtkTextInsert( m_text, text_buffer, m_defaultStyle, buffer ); - - // Scroll to cursor. - GtkTextIter iter; - gtk_text_buffer_get_iter_at_mark( text_buffer, &iter, gtk_text_buffer_get_insert( text_buffer ) ); - gtk_text_view_scroll_to_iter( GTK_TEXT_VIEW(m_text), &iter, 0.0, FALSE, 0.0, 1.0 ); - -#else // GTK 1.x - // After cursor movements, gtk_text_get_point() is wrong by one. - gtk_text_set_point( GTK_TEXT(m_text), GET_EDITABLE_POS(m_text) ); - - // always use m_defaultStyle, even if it is empty as otherwise - // resetting the style and appending some more text wouldn't work: if - // we don't specify the style explicitly, the old style would be used - gtk_editable_delete_selection( GTK_EDITABLE(m_text) ); - wxGtkTextInsert(m_text, m_defaultStyle, text.c_str(), text.Len()); - - // Bring editable's cursor back uptodate. - SET_EDITABLE_POS(m_text, gtk_text_get_point( GTK_TEXT(m_text) )); -#endif // GTK 1.x/2.0 - } - else // single line - { - // First remove the selection if there is one - gtk_editable_delete_selection( GTK_EDITABLE(m_text) ); - - // This moves the cursor pos to behind the inserted text. - gint len = GET_EDITABLE_POS(m_text); - -#ifdef __WXGTK20__ - -#if wxUSE_UNICODE - wxCharBuffer buffer( wxConvUTF8.cWX2MB( text ) ); -#else - wxCharBuffer buffer( wxConvUTF8.cWC2MB( wxConvLocal.cWX2WC( text ) ) ); -#endif - gtk_editable_insert_text( GTK_EDITABLE(m_text), buffer, strlen(buffer), &len ); - -#else - gtk_editable_insert_text( GTK_EDITABLE(m_text), text.c_str(), text.Len(), &len ); -#endif - - // Bring entry's cursor uptodate. - gtk_entry_set_position( GTK_ENTRY(m_text), len ); - } - - m_modified = TRUE; -} - -void wxTextCtrl::AppendText( const wxString &text ) -{ - SetInsertionPointEnd(); - WriteText( text ); -} - -wxString wxTextCtrl::GetLineText( long lineNo ) const -{ - if (m_windowStyle & wxTE_MULTILINE) - { -#ifndef __WXGTK20__ - gint len = gtk_text_get_length( GTK_TEXT(m_text) ); - char *text = gtk_editable_get_chars( GTK_EDITABLE(m_text), 0, len ); - - if (text) - { - wxString buf(wxT("")); - long i; - int currentLine = 0; - for (i = 0; currentLine != lineNo && text[i]; i++ ) - if (text[i] == '\n') - currentLine++; - // Now get the text - int j; - for (j = 0; text[i] && text[i] != '\n'; i++, j++ ) - buf += text[i]; - - g_free( text ); - return buf; - } - else - { - return wxEmptyString; - } -#else - GtkTextBuffer *text_buffer; - text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(m_text)); - GtkTextIter line; - gtk_text_buffer_get_iter_at_line(text_buffer,&line,lineNo); - GtkTextIter end; - gtk_text_buffer_get_end_iter(text_buffer,&end ); - gchar *text = gtk_text_buffer_get_text(text_buffer,&line,&end,TRUE); - wxString result( wxGTK_CONV_BACK(text) ); - g_free(text); - return result.BeforeFirst(wxT('\n')); -#endif - } - else - { - if (lineNo == 0) return GetValue(); - return wxEmptyString; - } -} - -void wxTextCtrl::OnDropFiles( wxDropFilesEvent &WXUNUSED(event) ) -{ - /* If you implement this, don't forget to update the documentation! - * (file docs/latex/wx/text.tex) */ - wxFAIL_MSG( wxT("wxTextCtrl::OnDropFiles not implemented") ); -} - -bool wxTextCtrl::PositionToXY(long pos, long *x, long *y ) const -{ - if ( m_windowStyle & wxTE_MULTILINE ) - { - wxString text = GetValue(); - - // cast to prevent warning. But pos really should've been unsigned. - if( (unsigned long)pos > text.Len() ) - return FALSE; - - *x=0; // First Col - *y=0; // First Line - - const wxChar* stop = text.c_str() + pos; - for ( const wxChar *p = text.c_str(); p < stop; p++ ) - { - if (*p == wxT('\n')) - { - (*y)++; - *x=0; - } - else - (*x)++; - } - } - else // single line control - { - if ( pos <= GTK_ENTRY(m_text)->text_length ) - { - *y = 0; - *x = pos; - } - else - { - // index out of bounds - return FALSE; - } - } - - return TRUE; -} - -long wxTextCtrl::XYToPosition(long x, long y ) const -{ - if (!(m_windowStyle & wxTE_MULTILINE)) return 0; - - long pos=0; - for( int i=0; iline_start_cache ) - { - // tell the programmer that it didn't work - wxLogDebug(_T("Can't call SetSelection() before realizing the control")); - return; - } -#endif - - if (m_windowStyle & wxTE_MULTILINE) - { -#ifdef __WXGTK20__ - GtkTextBuffer *buf = gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_text) ); - - GtkTextIter fromi, toi; - gtk_text_buffer_get_iter_at_offset( buf, &fromi, from ); - gtk_text_buffer_get_iter_at_offset( buf, &toi, to ); - - gtk_text_buffer_place_cursor( buf, &toi ); - gtk_text_buffer_move_mark_by_name( buf, "selection_bound", &fromi ); -#else - gtk_editable_select_region( GTK_EDITABLE(m_text), (gint)from, (gint)to ); -#endif - } - else - { - gtk_editable_select_region( GTK_EDITABLE(m_text), (gint)from, (gint)to ); - } -} - -void wxTextCtrl::ShowPosition( long pos ) -{ -#ifndef __WXGTK20__ - if (m_windowStyle & wxTE_MULTILINE) - { - GtkAdjustment *vp = GTK_TEXT(m_text)->vadj; - float totalLines = (float) GetNumberOfLines(); - long posX; - long posY; - PositionToXY(pos, &posX, &posY); - float posLine = (float) posY; - float p = (posLine/totalLines)*(vp->upper - vp->lower) + vp->lower; - gtk_adjustment_set_value(GTK_TEXT(m_text)->vadj, p); - } -#endif -} - -long wxTextCtrl::GetInsertionPoint() const -{ - wxCHECK_MSG( m_text != NULL, 0, wxT("invalid text ctrl") ); - -#ifdef __WXGTK20__ - if (m_windowStyle & wxTE_MULTILINE) - { - GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_text) ); - - // There is no direct accessor for the cursor, but - // internally, the cursor is the "mark" called - // "insert" in the text view's btree structure. - - GtkTextMark *mark = gtk_text_buffer_get_insert( text_buffer ); - GtkTextIter cursor; - gtk_text_buffer_get_iter_at_mark( text_buffer, &cursor, mark ); - - return gtk_text_iter_get_offset( &cursor ); - } - else -#endif - { - return (long) GET_EDITABLE_POS(m_text); - } -} - -long wxTextCtrl::GetLastPosition() const -{ - wxCHECK_MSG( m_text != NULL, 0, wxT("invalid text ctrl") ); - - int pos = 0; - - if (m_windowStyle & wxTE_MULTILINE) - { -#ifdef __WXGTK20__ - GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_text) ); - GtkTextIter end; - gtk_text_buffer_get_end_iter( text_buffer, &end ); - - pos = gtk_text_iter_get_offset( &end ); -#else - pos = gtk_text_get_length( GTK_TEXT(m_text) ); -#endif - } - else - { - pos = GTK_ENTRY(m_text)->text_length; - } - - return (long)pos; -} - -void wxTextCtrl::Remove( long from, long to ) -{ - wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") ); - -#ifdef __WXGTK20__ - if (m_windowStyle & wxTE_MULTILINE) - { - GtkTextBuffer * - text_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_text) ); - - GtkTextIter fromi, toi; - gtk_text_buffer_get_iter_at_offset( text_buffer, &fromi, from ); - gtk_text_buffer_get_iter_at_offset( text_buffer, &toi, to ); - - gtk_text_buffer_delete( text_buffer, &fromi, &toi ); - } - else // single line -#endif - gtk_editable_delete_text( GTK_EDITABLE(m_text), (gint)from, (gint)to ); -} - -void wxTextCtrl::Replace( long from, long to, const wxString &value ) -{ - wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") ); - - Remove( from, to ); - - if (!value.IsEmpty()) - { -#ifdef __WXGTK20__ - SetInsertionPoint( from ); - WriteText( value ); -#else // GTK 1.x - gint pos = (gint)from; -#if wxUSE_UNICODE - wxWX2MBbuf buf = value.mbc_str(); - gtk_editable_insert_text( GTK_EDITABLE(m_text), buf, strlen(buf), &pos ); -#else - gtk_editable_insert_text( GTK_EDITABLE(m_text), value, value.Length(), &pos ); -#endif // wxUSE_UNICODE -#endif // GTK 1.x/2.x - } -} - -void wxTextCtrl::Cut() -{ - wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") ); - -#ifndef __WXGTK20__ - gtk_editable_cut_clipboard( GTK_EDITABLE(m_text) DUMMY_CLIPBOARD_ARG ); -#endif -} - -void wxTextCtrl::Copy() -{ - wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") ); - -#ifndef __WXGTK20__ - gtk_editable_copy_clipboard( GTK_EDITABLE(m_text) DUMMY_CLIPBOARD_ARG ); -#endif -} - -void wxTextCtrl::Paste() -{ - wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") ); - -#ifndef __WXGTK20__ - gtk_editable_paste_clipboard( GTK_EDITABLE(m_text) DUMMY_CLIPBOARD_ARG ); -#endif -} - -// Undo/redo -void wxTextCtrl::Undo() -{ - // TODO - wxFAIL_MSG( wxT("wxTextCtrl::Undo not implemented") ); -} - -void wxTextCtrl::Redo() -{ - // TODO - wxFAIL_MSG( wxT("wxTextCtrl::Redo not implemented") ); -} - -bool wxTextCtrl::CanUndo() const -{ - // TODO - //wxFAIL_MSG( wxT("wxTextCtrl::CanUndo not implemented") ); - return FALSE; -} - -bool wxTextCtrl::CanRedo() const -{ - // TODO - //wxFAIL_MSG( wxT("wxTextCtrl::CanRedo not implemented") ); - return FALSE; -} - -// If the return values from and to are the same, there is no -// selection. -void wxTextCtrl::GetSelection(long* fromOut, long* toOut) const -{ - wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") ); - - gint from = -1; - gint to = -1; - bool haveSelection = FALSE; - -#ifdef __WXGTK20__ - if (m_windowStyle & wxTE_MULTILINE) - { - GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (m_text)); - GtkTextIter ifrom, ito; - if ( gtk_text_buffer_get_selection_bounds(buffer, &ifrom, &ito) ) - { - haveSelection = TRUE; - from = gtk_text_iter_get_offset(&ifrom); - to = gtk_text_iter_get_offset(&ito); - } - } - else // not multi-line - { - if ( gtk_editable_get_selection_bounds( GTK_EDITABLE(m_text), - &from, &to) ) - { - haveSelection = TRUE; - } - } -#else // not GTK2 - if ( (GTK_EDITABLE(m_text)->has_selection) ) - { - haveSelection = TRUE; - from = (long) GTK_EDITABLE(m_text)->selection_start_pos; - to = (long) GTK_EDITABLE(m_text)->selection_end_pos; - } -#endif - - if (! haveSelection ) - from = to = GetInsertionPoint(); - - if ( from > to ) - { - // exchange them to be compatible with wxMSW - gint tmp = from; - from = to; - to = tmp; - } - - if ( fromOut ) - *fromOut = from; - if ( toOut ) - *toOut = to; -} - - -bool wxTextCtrl::IsEditable() const -{ - wxCHECK_MSG( m_text != NULL, FALSE, wxT("invalid text ctrl") ); - -#ifdef __WXGTK20__ - if (m_windowStyle & wxTE_MULTILINE) - { - return gtk_text_view_get_editable(GTK_TEXT_VIEW(m_text)); - } - else - { - return gtk_editable_get_editable(GTK_EDITABLE(m_text)); - } -#else - return GTK_EDITABLE(m_text)->editable; -#endif -} - -bool wxTextCtrl::IsModified() const -{ - return m_modified; -} - -void wxTextCtrl::Clear() -{ - SetValue( wxT("") ); -} - -void wxTextCtrl::OnChar( wxKeyEvent &key_event ) -{ - wxCHECK_RET( m_text != NULL, wxT("invalid text ctrl") ); - - if ((key_event.KeyCode() == WXK_RETURN) && (m_windowStyle & wxPROCESS_ENTER)) - { - wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER, m_windowId); - event.SetEventObject(this); - event.SetString(GetValue()); - if (GetEventHandler()->ProcessEvent(event)) return; - } - - if ((key_event.KeyCode() == WXK_RETURN) && !(m_windowStyle & wxTE_MULTILINE)) - { - // This will invoke the dialog default action, such - // as the clicking the default button. - - wxWindow *top_frame = m_parent; - while (top_frame->GetParent() && !(top_frame->IsTopLevel())) - top_frame = top_frame->GetParent(); - - if (top_frame && GTK_IS_WINDOW(top_frame->m_widget)) - { - GtkWindow *window = GTK_WINDOW(top_frame->m_widget); - - if (window->default_widget) - { - gtk_widget_activate (window->default_widget); - return; - } - } - } - - key_event.Skip(); -} - -GtkWidget* wxTextCtrl::GetConnectWidget() -{ - return GTK_WIDGET(m_text); -} - -bool wxTextCtrl::IsOwnGtkWindow( GdkWindow *window ) -{ - if (m_windowStyle & wxTE_MULTILINE) - { -#ifdef __WXGTK20__ - return window == gtk_text_view_get_window( GTK_TEXT_VIEW( m_text ), GTK_TEXT_WINDOW_TEXT ); // pure guesswork -#else - return (window == GTK_TEXT(m_text)->text_area); -#endif - } - else - { - return (window == GTK_ENTRY(m_text)->text_area); - } -} - -// the font will change for subsequent text insertiongs -bool wxTextCtrl::SetFont( const wxFont &font ) -{ - wxCHECK_MSG( m_text != NULL, FALSE, wxT("invalid text ctrl") ); - - if ( !wxTextCtrlBase::SetFont(font) ) - { - // font didn't change, nothing to do - return FALSE; - } - - if ( m_windowStyle & wxTE_MULTILINE ) - { - m_updateFont = TRUE; - - m_defaultStyle.SetFont(font); - - ChangeFontGlobally(); - } - - return TRUE; -} - -void wxTextCtrl::ChangeFontGlobally() -{ - // this method is very inefficient and hence should be called as rarely as - // possible! - wxASSERT_MSG( (m_windowStyle & wxTE_MULTILINE) && m_updateFont, - _T("shouldn't be called for single line controls") ); - - wxString value = GetValue(); - if ( !value.IsEmpty() ) - { - m_updateFont = FALSE; - - Clear(); - AppendText(value); - } -} - -void wxTextCtrl::UpdateFontIfNeeded() -{ - if ( m_updateFont ) - ChangeFontGlobally(); -} - -bool wxTextCtrl::SetForegroundColour(const wxColour& colour) -{ - if ( !wxControl::SetForegroundColour(colour) ) - return FALSE; - - // update default fg colour too - m_defaultStyle.SetTextColour(colour); - - return TRUE; -} - -bool wxTextCtrl::SetBackgroundColour( const wxColour &colour ) -{ - wxCHECK_MSG( m_text != NULL, FALSE, wxT("invalid text ctrl") ); - - if ( !wxControl::SetBackgroundColour( colour ) ) - return FALSE; - - if (!m_widget->window) - return FALSE; - - wxColour sysbg = wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ); - if (sysbg.Red() == colour.Red() && - sysbg.Green() == colour.Green() && - sysbg.Blue() == colour.Blue()) - { - return FALSE; // FIXME or TRUE? - } - - if (!m_backgroundColour.Ok()) - return FALSE; - - if (m_windowStyle & wxTE_MULTILINE) - { -#ifndef __WXGTK20__ - GdkWindow *window = GTK_TEXT(m_text)->text_area; - if (!window) - return FALSE; - m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) ); - gdk_window_set_background( window, m_backgroundColour.GetColor() ); - gdk_window_clear( window ); -#endif - } - - // change active background color too - m_defaultStyle.SetBackgroundColour( colour ); - - return TRUE; -} - -bool wxTextCtrl::SetStyle( long start, long end, const wxTextAttr& style ) -{ - if ( m_windowStyle & wxTE_MULTILINE ) - { - if ( style.IsDefault() ) - { - // nothing to do - return TRUE; - } -#ifdef __WXGTK20__ - GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( GTK_TEXT_VIEW(m_text) ); - gint l = gtk_text_buffer_get_char_count( text_buffer ); - - wxCHECK_MSG( start >= 0 && end <= l, FALSE, - _T("invalid range in wxTextCtrl::SetStyle") ); - - GtkTextIter starti, endi; - gtk_text_buffer_get_iter_at_offset( text_buffer, &starti, start ); - gtk_text_buffer_get_iter_at_offset( text_buffer, &endi, end ); - - // use the attributes from style which are set in it and fall back - // first to the default style and then to the text control default - // colours for the others - wxTextAttr attr = wxTextAttr::Combine(style, m_defaultStyle, this); - - PangoFontDescription *font_description = attr.HasFont() - ? attr.GetFont().GetNativeFontInfo()->description - : NULL; - - GdkColor *colFg = attr.HasTextColour() ? attr.GetTextColour().GetColor() - : NULL; - - GdkColor *colBg = attr.HasBackgroundColour() - ? attr.GetBackgroundColour().GetColor() - : NULL; - - GtkTextTag *tag; - tag = gtk_text_buffer_create_tag( text_buffer, NULL, "font-desc", font_description, - "foreground-gdk", colFg, - "background-gdk", colBg, NULL ); - gtk_text_buffer_apply_tag( text_buffer, tag, &starti, &endi ); - - return TRUE; -#else - // VERY dirty way to do that - removes the required text and re-adds it - // with styling (FIXME) - - gint l = gtk_text_get_length( GTK_TEXT(m_text) ); - - wxCHECK_MSG( start >= 0 && end <= l, FALSE, - _T("invalid range in wxTextCtrl::SetStyle") ); - - gint old_pos = gtk_editable_get_position( GTK_EDITABLE(m_text) ); - char *text = gtk_editable_get_chars( GTK_EDITABLE(m_text), start, end ); - wxString tmp(text,*wxConvCurrent); - g_free( text ); - - gtk_editable_delete_text( GTK_EDITABLE(m_text), start, end ); - gtk_editable_set_position( GTK_EDITABLE(m_text), start ); - -#if wxUSE_UNICODE - wxWX2MBbuf buf = tmp.mbc_str(); - const char *txt = buf; - size_t txtlen = strlen(buf); -#else - const char *txt = tmp; - size_t txtlen = tmp.length(); -#endif - - // use the attributes from style which are set in it and fall back - // first to the default style and then to the text control default - // colours for the others - wxGtkTextInsert(m_text, - wxTextAttr::Combine(style, m_defaultStyle, this), - txt, - txtlen); - - /* does not seem to help under GTK+ 1.2 !!! - gtk_editable_set_position( GTK_EDITABLE(m_text), old_pos ); */ - SetInsertionPoint( old_pos ); -#endif - return TRUE; - } - else // singe line - { - // cannot do this for GTK+'s Entry widget - return FALSE; - } -} - -void wxTextCtrl::ApplyWidgetStyle() -{ - if (m_windowStyle & wxTE_MULTILINE) - { - // how ? - } - else - { - SetWidgetStyle(); - gtk_widget_set_style( m_text, m_widgetStyle ); - } -} - -void wxTextCtrl::OnCut(wxCommandEvent& WXUNUSED(event)) -{ - Cut(); -} - -void wxTextCtrl::OnCopy(wxCommandEvent& WXUNUSED(event)) -{ - Copy(); -} - -void wxTextCtrl::OnPaste(wxCommandEvent& WXUNUSED(event)) -{ - Paste(); -} - -void wxTextCtrl::OnUndo(wxCommandEvent& WXUNUSED(event)) -{ - Undo(); -} - -void wxTextCtrl::OnRedo(wxCommandEvent& WXUNUSED(event)) -{ - Redo(); -} - -void wxTextCtrl::OnUpdateCut(wxUpdateUIEvent& event) -{ - event.Enable( CanCut() ); -} - -void wxTextCtrl::OnUpdateCopy(wxUpdateUIEvent& event) -{ - event.Enable( CanCopy() ); -} - -void wxTextCtrl::OnUpdatePaste(wxUpdateUIEvent& event) -{ - event.Enable( CanPaste() ); -} - -void wxTextCtrl::OnUpdateUndo(wxUpdateUIEvent& event) -{ - event.Enable( CanUndo() ); -} - -void wxTextCtrl::OnUpdateRedo(wxUpdateUIEvent& event) -{ - event.Enable( CanRedo() ); -} - -void wxTextCtrl::OnInternalIdle() -{ - wxCursor cursor = m_cursor; - if (g_globalCursor.Ok()) cursor = g_globalCursor; - - if (cursor.Ok()) - { -#ifndef __WXGTK20__ - GdkWindow *window = (GdkWindow*) NULL; - if (HasFlag(wxTE_MULTILINE)) - window = GTK_TEXT(m_text)->text_area; - else - window = GTK_ENTRY(m_text)->text_area; - - if (window) - gdk_window_set_cursor( window, cursor.GetCursor() ); - - if (!g_globalCursor.Ok()) - cursor = *wxSTANDARD_CURSOR; - - window = m_widget->window; - if ((window) && !(GTK_WIDGET_NO_WINDOW(m_widget))) - gdk_window_set_cursor( window, cursor.GetCursor() ); -#endif - } - - if (g_delayedFocus == this) - { - if (GTK_WIDGET_REALIZED(m_widget)) - { - gtk_widget_grab_focus( m_widget ); - g_delayedFocus = NULL; - } - } - - UpdateWindowUI(); -} - -wxSize wxTextCtrl::DoGetBestSize() const -{ - // FIXME should be different for multi-line controls... - wxSize ret( wxControl::DoGetBestSize() ); - return wxSize(80, ret.y); -} - -// ---------------------------------------------------------------------------- -// freeze/thaw -// ---------------------------------------------------------------------------- - -void wxTextCtrl::Freeze() -{ -#ifndef __WXGTK20__ - if ( HasFlag(wxTE_MULTILINE) ) - { - gtk_text_freeze(GTK_TEXT(m_text)); - } -#endif -} - -void wxTextCtrl::Thaw() -{ -#ifndef __WXGTK20__ - if ( HasFlag(wxTE_MULTILINE) ) - { - GTK_TEXT(m_text)->vadj->value = 0.0; - - gtk_text_thaw(GTK_TEXT(m_text)); - } -#endif -} - -// ---------------------------------------------------------------------------- -// scrolling -// ---------------------------------------------------------------------------- - -GtkAdjustment *wxTextCtrl::GetVAdj() const -{ -#ifdef __WXGTK20__ - return NULL; -#else - return HasFlag(wxTE_MULTILINE) ? GTK_TEXT(m_text)->vadj : NULL; -#endif -} - -bool wxTextCtrl::DoScroll(GtkAdjustment *adj, int diff) -{ -#ifndef __WXGTK20__ - float value = adj->value + diff; - - if ( value < 0 ) - value = 0; - - float upper = adj->upper - adj->page_size; - if ( value > upper ) - value = upper; - - // did we noticeably change the scroll position? - if ( fabs(adj->value - value) < 0.2 ) - { - // well, this is what Robert does in wxScrollBar, so it must be good... - return FALSE; - } - - adj->value = value; - - gtk_signal_emit_by_name(GTK_OBJECT(adj), "value_changed"); - -#endif - return TRUE; -} - -bool wxTextCtrl::ScrollLines(int lines) -{ -#ifdef __WXGTK20__ - return FALSE; -#else - GtkAdjustment *adj = GetVAdj(); - if ( !adj ) - return FALSE; - - // this is hardcoded to 10 in GTK+ 1.2 (great idea) - static const int KEY_SCROLL_PIXELS = 10; - - return DoScroll(adj, lines*KEY_SCROLL_PIXELS); -#endif -} - -bool wxTextCtrl::ScrollPages(int pages) -{ -#ifdef __WXGTK20__ - return FALSE; -#else - GtkAdjustment *adj = GetVAdj(); - if ( !adj ) - return FALSE; - - return DoScroll(adj, (int)ceil(pages*adj->page_increment)); -#endif -} - diff --git a/src/gtk1/tglbtn.cpp b/src/gtk1/tglbtn.cpp deleted file mode 100644 index f7f8064346..0000000000 --- a/src/gtk1/tglbtn.cpp +++ /dev/null @@ -1,188 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wx/gtk/tglbtn.cpp -// Purpose: Definition of the wxToggleButton class, which implements a -// toggle button under wxGTK. -// Author: John Norris, minor changes by Axel Schlueter -// Modified by: -// Created: 08.02.01 -// RCS-ID: $Id$ -// Copyright: (c) 2000 Johnny C. Norris II -// License: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/tglbtn.h" -#include "wx/button.h" - -#if wxUSE_TOGGLEBTN - -#include "wx/gtk/private.h" - -extern void wxapp_install_idle_handler(); -extern bool g_isIdle; -extern bool g_blockEventsOnDrag; -extern wxCursor g_globalCursor; -extern wxWindowGTK *g_delayedFocus; - -static void gtk_togglebutton_clicked_callback(GtkWidget *WXUNUSED(widget), wxToggleButton *cb) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - - if (!cb->m_hasVMT || g_blockEventsOnDrag) - return; - - if (cb->m_blockEvent) return; - - // Generate a wx event. - wxCommandEvent event(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, cb->GetId()); - event.SetInt(cb->GetValue()); - event.SetEventObject(cb); - cb->GetEventHandler()->ProcessEvent(event); -} - -IMPLEMENT_DYNAMIC_CLASS(wxToggleButton, wxControl) -DEFINE_EVENT_TYPE(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED) - -bool wxToggleButton::Create(wxWindow *parent, wxWindowID id, - const wxString &label, const wxPoint &pos, - const wxSize &size, long style, - const wxValidator& validator, - const wxString &name) -{ - m_needParent = TRUE; - m_acceptsFocus = TRUE; - - m_blockEvent = FALSE; - - if (!PreCreation(parent, pos, size) || - !CreateBase(parent, id, pos, size, style, validator, name )) { - wxFAIL_MSG(wxT("wxToggleButton creation failed")); - return FALSE; - } - - wxControl::SetLabel(label); - - // Create the gtk widget. - m_widget = gtk_toggle_button_new_with_label( wxGTK_CONV( m_label ) ); - - gtk_signal_connect(GTK_OBJECT(m_widget), "clicked", - GTK_SIGNAL_FUNC(gtk_togglebutton_clicked_callback), - (gpointer *)this); - - m_parent->DoAddChild(this); - - PostCreation(); - - SetFont(parent->GetFont()); - - wxSize size_best(DoGetBestSize()); - wxSize new_size(size); - if (new_size.x == -1) - new_size.x = size_best.x; - if (new_size.y == -1) - new_size.y = size_best.y; - if ((new_size.x != size.x) || (new_size.y != size.y)) - SetSize(new_size.x, new_size.y); - - SetBackgroundColour(parent->GetBackgroundColour()); - SetForegroundColour(parent->GetForegroundColour()); - - Show(TRUE); - - return TRUE; -} - -// void SetValue(bool state) -// Set the value of the toggle button. -void wxToggleButton::SetValue(bool state) -{ - wxCHECK_RET(m_widget != NULL, wxT("invalid toggle button")); - - if (state == GetValue()) - return; - - m_blockEvent = TRUE; - - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(m_widget), state); - - m_blockEvent = FALSE; -} - -// bool GetValue() const -// Get the value of the toggle button. -bool wxToggleButton::GetValue() const -{ - wxCHECK_MSG(m_widget != NULL, FALSE, wxT("invalid toggle button")); - - return GTK_TOGGLE_BUTTON(m_widget)->active; -} - -void wxToggleButton::SetLabel(const wxString& label) -{ - wxCHECK_RET(m_widget != NULL, wxT("invalid toggle button")); - - wxControl::SetLabel(label); - - gtk_label_set(GTK_LABEL(BUTTON_CHILD(m_widget)), wxGTK_CONV( GetLabel() ) ); -} - -bool wxToggleButton::Enable(bool enable /*=TRUE*/) -{ - if (!wxControl::Enable(enable)) - return FALSE; - - gtk_widget_set_sensitive(BUTTON_CHILD(m_widget), enable); - - return TRUE; -} - -void wxToggleButton::ApplyWidgetStyle() -{ - SetWidgetStyle(); - gtk_widget_set_style(m_widget, m_widgetStyle); - gtk_widget_set_style(BUTTON_CHILD(m_widget), m_widgetStyle); -} - -bool wxToggleButton::IsOwnGtkWindow(GdkWindow *window) -{ - return window == TOGGLE_BUTTON_EVENT_WIN(m_widget); -} - -void wxToggleButton::OnInternalIdle() -{ - wxCursor cursor = m_cursor; - - if (g_globalCursor.Ok()) - cursor = g_globalCursor; - - GdkWindow *win = TOGGLE_BUTTON_EVENT_WIN(m_widget); - if ( win && cursor.Ok() ) - { - /* I now set the cursor the anew in every OnInternalIdle call - as setting the cursor in a parent window also effects the - windows above so that checking for the current cursor is - not possible. */ - - gdk_window_set_cursor(win, cursor.GetCursor()); - } - - UpdateWindowUI(); -} - -// wxSize DoGetBestSize() const -// Get the "best" size for this control. -wxSize wxToggleButton::DoGetBestSize() const -{ - wxSize ret(wxControl::DoGetBestSize()); - - if (!HasFlag(wxBU_EXACTFIT)) - { - if (ret.x < 80) ret.x = 80; - } - - - return ret; -} - -#endif // wxUSE_TOGGLEBTN - diff --git a/src/gtk1/threadno.cpp b/src/gtk1/threadno.cpp deleted file mode 100644 index 81969e87d2..0000000000 --- a/src/gtk1/threadno.cpp +++ /dev/null @@ -1,183 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: thread.cpp -// Purpose: Solaris thread support -// Author: Guilhem Lavaux -// Modified by: -// Created: 04/22/98 -// RCS-ID: $Id$ -// Copyright: (c) Wolfram Gloger (1996, 1997); Guilhem Lavaux (1998) -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/wx.h" -#include "wx/module.h" -#include "wx/thread.h" -#include "wx/log.h" - -wxMutex::wxMutex() -{ - m_locked = 0; -} - -wxMutex::~wxMutex() -{ - if (m_locked) - wxLogDebug( "wxMutex warning: destroying a locked mutex (%d locks)", m_locked ); -} - -wxMutexError wxMutex::Lock() -{ - m_locked++; - return wxMUTEX_NO_ERROR; -} - -wxMutexError wxMutex::TryLock() -{ - if (m_locked > 0) - return wxMUTEX_BUSY; - m_locked++; - return wxMUTEX_NO_ERROR; -} - -wxMutexError wxMutex::Unlock() -{ - if (m_locked == 0) - return wxMUTEX_UNLOCKED; - m_locked--; - return wxMUTEX_NO_ERROR; -} - -wxCondition::wxCondition() -{ -} - -wxCondition::~wxCondition() -{ -} - -void wxCondition::Wait(wxMutex& WXUNUSED(mutex)) -{ -} - -bool wxCondition::Wait(wxMutex& WXUNUSED(mutex), unsigned long WXUNUSED(sec), - unsigned long WXUNUSED(nsec)) -{ - return FALSE; -} - -void wxCondition::Signal() -{ -} - -void wxCondition::Broadcast() -{ -} - -struct wxThreadInternal -{ - int thread_id; - void* exit_status; -}; - -wxThreadError wxThread::Create() -{ - p_internal->exit_status = Entry(); - OnExit(); - return wxTHREAD_NO_ERROR; -} - -wxThreadError wxThread::Destroy() -{ - return wxTHREAD_NOT_RUNNING; -} - -wxThreadError wxThread::Pause() -{ - return wxTHREAD_NOT_RUNNING; -} - -wxThreadError wxThread::Resume() -{ - return wxTHREAD_NOT_RUNNING; -} - -void wxThread::DeferDestroy( bool WXUNUSED(on) ) -{ -} - -void wxThread::TestDestroy() -{ -} - -void *wxThread::Join() -{ - return p_internal->exit_status; -} - -unsigned long wxThread::GetID() const -{ - return 0; -} - -bool wxThread::IsMain() -{ - return TRUE; -} - -bool wxThread::IsRunning() const -{ - return FALSE; -} - -bool wxThread::IsAlive() const -{ - return FALSE; -} - -void wxThread::SetPriority(int WXUNUSED(prio)) { } -int wxThread::GetPriority() const { return 0; } - -wxMutex *wxMainMutex; // controls access to all GUI functions - -wxThread::wxThread() -{ - p_internal = new wxThreadInternal(); -} - -wxThread::~wxThread() -{ - Destroy(); - Join(); - delete p_internal; -} - -// The default callback just joins the thread and throws away the result. -void wxThread::OnExit() -{ - Join(); -} - -IMPLEMENT_DYNAMIC_CLASS(wxThreadModule, wxModule) - -bool wxThreadModule::OnInit() -{ - wxMainMutex = new wxMutex(); - wxMainMutex->Lock(); - return TRUE; -} - -void wxThreadModule::OnExit() -{ - wxMainMutex->Unlock(); - delete wxMainMutex; -} - - - -void wxMutexGuiEnter() -{ -} - -void wxMutexGuiLeave() -{ -} diff --git a/src/gtk1/threadsgi.cpp b/src/gtk1/threadsgi.cpp deleted file mode 100644 index 1582c85019..0000000000 --- a/src/gtk1/threadsgi.cpp +++ /dev/null @@ -1,266 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: threadsgi.cpp -// Purpose: wxThread (SGI) Implementation -// Author: Original from Wolfram Gloger/Guilhem Lavaux -// Modified by: -// Created: 04/22/98 -// RCS-ID: $Id$ -// Copyright: (c) Wolfram Gloger (1996, 1997); Guilhem Lavaux (1998) -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include -#include - -#include -#include -#include -#include "wx/thread.h" -#include "wx/module.h" -#include "wx/utils.h" -#include "wx/log.h" - -#include "gdk/gdk.h" -#include "gtk/gtk.h" - -enum thread_state -{ - STATE_IDLE = 0, - STATE_RUNNING, - STATE_CANCELED, - STATE_EXITED -}; - -///////////////////////////////////////////////////////////////////////////// -// Static variables -///////////////////////////////////////////////////////////////////////////// - -static int p_mainid; -wxMutex *wxMainMutex; - -#include "threadgui.inc" - -///////////////////////////////////////////////////////////////////////////// -// Unix implementations (SGI threads) -///////////////////////////////////////////////////////////////////////////// - -class wxMutexInternal { -public: - abilock_t p_mutex; -}; - -wxMutex::wxMutex() -{ - m_locked = 0; - p_internal = new wxMutexInternal; - init_lock(&(p_internal->p_mutex)); -} - -wxMutex::~wxMutex() -{ - if (m_locked > 0) - wxLogDebug( "wxMutex warning: freeing a locked mutex (%d locks)\n", m_locked ); - delete p_internal; -} - -wxMutexError wxMutex::Lock() -{ - spin_lock(&(p_internal->p_mutex)); - m_locked++; - return wxMUTEX_NO_ERROR; -} - -wxMutexError wxMutex::TryLock() -{ - if (acquire_lock(&(p_internal->p_mutex)) != 0) - return wxMUTEX_BUSY; - m_locked++; - return wxMUTEX_NO_ERROR; -} - -wxMutexError wxMutex::Unlock() -{ - if (m_locked == 0) - return wxMUTEX_UNLOCKED; - release_lock(&(p_internal->p_mutex)); - m_locked--; - return wxMUTEX_NO_ERROR; -} - -// GL: Don't know how it works on SGI. Wolfram ? - -wxCondition::wxCondition() {} -wxCondition::~wxCondition() {} -int wxCondition::Wait(wxMutex& WXUNUSED(mutex)) { return 0;} -int wxCondition::Wait(wxMutex& WXUNUSED(mutex), unsigned long WXUNUSED(sec), - unsigned long WXUNUSED(nsec)) { return 0; } -int wxCondition::Signal() { return 0; } -int wxCondition::Broadcast() { return 0; } - -class -wxThreadPrivate { -public: - wxThreadPrivate() { thread_id = 0; state = STATE_IDLE; } - ~wxThreadPrivate() {} - static void SprocStart(void *ptr); - static void SignalHandler(int sig); -public: - int state, thread_id; - void* exit_status; -}; - -void wxThreadPrivate::SprocStart(void *ptr) -{ - void* status; - - wxThread *thr = (wxThread *)ptr; - - thr->p_internal->thread_id = getpid(); - thr->p_internal->exit_status = 0; - status = thr->Entry(); - thr->Exit(status); -} - -void wxThread::Exit(void* status) -{ - wxThread* ptr = this; - THREAD_SEND_EXIT_MSG(ptr); - p_internal->state = STATE_EXITED; - p_internal->exit_status = status; - _exit(0); -} - -wxThreadError wxThread::Create() -{ - if (p_internal->state != STATE_IDLE) - return wxTHREAD_RUNNING; - p_internal->state = STATE_RUNNING; - if (sproc(p_internal->SprocStart, PR_SALL, this) < 0) { - p_internal->state = STATE_IDLE; - return wxTHREAD_NO_RESOURCE; - } - return wxTHREAD_NO_ERROR; -} - -wxThreadError wxThread::Destroy() -{ - if (p_internal->state == STATE_RUNNING) - p_internal->state = STATE_CANCELED; - - return wxTHREAD_NO_ERROR; -} - -wxThreadError wxThread::Pause() -{ - return wxTHREAD_NO_ERROR; -} - -wxThreadError wxThread::Resume() -{ - return wxTHREAD_NO_ERROR; -} - -void *wxThread::Join() -{ - if (p_internal->state != STATE_IDLE) { - bool do_unlock = wxThread::IsMain(); - int stat; - - if (do_unlock) - wxMainMutex->Unlock(); - waitpid(p_internal->thread_id, &stat, 0); - if (do_unlock) - wxMainMutex->Lock(); - if (!WIFEXITED(stat) && !WIFSIGNALED(stat)) - return 0; - p_internal->state = STATE_IDLE; - return p_internal->exit_status; - } - return 0; -} - -unsigned long wxThread::GetID() const -{ - return (unsigned long)p_internal->thread_id; -} - -void wxThread::TestDestroy() -{ - if (p_internal->state == STATE_CANCELED) { - p_internal->exit_status = 0; - _exit(0); - } -} - -void wxThread::SetPriority(int prio) -{ -} - -int wxThread::GetPriority() const -{ - return 0; -} - -bool wxThread::IsMain() -{ - return (int)getpid() == main_id; -} - -bool wxThread::IsAlive() const -{ - return (p_internal->state == STATE_RUNNING); -} - -bool wxThread::IsRunning() const -{ - return (p_internal->state == STATE_RUNNING); -} - -wxThread::wxThread() -{ - p_internal = new wxThreadPrivate(); -} - -wxThread::~wxThread() -{ - Cancel(); - Join(); - delete p_internal; -} - -// The default callback just joins the thread and throws away the result. -void wxThread::OnExit() -{ - Join(); -} - -// Global initialization - -class wxThreadModule : public wxModule -{ -public: - virtual bool OnInit(); - virtual void OnExit(); - -private: - DECLARE_DYNAMIC_CLASS(wxThreadModule) -}; - -IMPLEMENT_DYNAMIC_CLASS(wxThreadModule, wxModule) - -bool wxThreadModule::OnInit() -{ - wxMainMutex = new wxMutex(); - wxThreadGuiInit(); - p_mainid = (int)getpid(); - wxMainMutex->Lock(); - return TRUE; -} - -void wxThreadModule::OnExit() -{ - wxMainMutex->Unlock(); - wxThreadGuiExit(); - delete wxMainMutex; -} - diff --git a/src/gtk1/timer.cpp b/src/gtk1/timer.cpp deleted file mode 100644 index 71b3d71617..0000000000 --- a/src/gtk1/timer.cpp +++ /dev/null @@ -1,85 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: gtk/timer.cpp -// Purpose: wxTimer implementation -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/defs.h" - -#if wxUSE_TIMER - -#include "wx/timer.h" - -#include "gtk/gtk.h" - -// ---------------------------------------------------------------------------- -// wxTimer -// ---------------------------------------------------------------------------- - -IMPLEMENT_ABSTRACT_CLASS(wxTimer, wxObject) - -extern "C" gint timeout_callback( gpointer data ) -{ - wxTimer *timer = (wxTimer*)data; - - // Don't change the order of anything in this callback! - - if ( timer->IsOneShot() ) - { - // This sets m_tag to -1 - timer->Stop(); - } - - // when getting called from GDK's timer handler we - // are no longer within GDK's grab on the GUI - // thread so we must lock it here ourselves - gdk_threads_enter(); - - timer->Notify(); - - /* release lock again */ - gdk_threads_leave(); - - if (timer->IsOneShot()) - return FALSE; - - return TRUE; -} - -void wxTimer::Init() -{ - m_tag = -1; - m_milli = 1000; -} - -wxTimer::~wxTimer() -{ - wxTimer::Stop(); -} - -bool wxTimer::Start( int millisecs, bool oneShot ) -{ - (void)wxTimerBase::Start(millisecs, oneShot); - - if (m_tag != -1) - gtk_timeout_remove( m_tag ); - - m_tag = gtk_timeout_add( m_milli, timeout_callback, this ); - - return TRUE; -} - -void wxTimer::Stop() -{ - if (m_tag != -1) - { - gtk_timeout_remove( m_tag ); - m_tag = -1; - } -} - -#endif // wxUSE_TIMER - diff --git a/src/gtk1/tooltip.cpp b/src/gtk1/tooltip.cpp deleted file mode 100644 index 145d70fea3..0000000000 --- a/src/gtk1/tooltip.cpp +++ /dev/null @@ -1,81 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: tooltip.cpp -// Purpose: wxToolTip implementation -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/setup.h" - -#if wxUSE_TOOLTIPS - -#include "wx/window.h" -#include "wx/tooltip.h" - -#include "wx/gtk/private.h" - -extern GdkFont *GtkGetDefaultGuiFont(); - -//----------------------------------------------------------------------------- -// global data -//----------------------------------------------------------------------------- - -static GtkTooltips *ss_tooltips = (GtkTooltips*) NULL; - -//----------------------------------------------------------------------------- -// wxToolTip -//----------------------------------------------------------------------------- - -IMPLEMENT_ABSTRACT_CLASS(wxToolTip, wxObject) - -wxToolTip::wxToolTip( const wxString &tip ) -{ - m_text = tip; - m_window = (wxWindow*) NULL; -} - -void wxToolTip::SetTip( const wxString &tip ) -{ - m_text = tip; - Apply( m_window ); -} - -void wxToolTip::Apply( wxWindow *win ) -{ - if (!win) return; - - if (!ss_tooltips) - { - ss_tooltips = gtk_tooltips_new(); - } - - m_window = win; - - if (m_text.IsEmpty()) - m_window->ApplyToolTip( ss_tooltips, (wxChar*) NULL ); - else - m_window->ApplyToolTip( ss_tooltips, m_text ); -} - -void wxToolTip::Enable( bool flag ) -{ - if (!ss_tooltips) return; - - if (flag) - gtk_tooltips_enable( ss_tooltips ); - else - gtk_tooltips_disable( ss_tooltips ); -} - -void wxToolTip::SetDelay( long msecs ) -{ - if (!ss_tooltips) - return; - - gtk_tooltips_set_delay( ss_tooltips, (int)msecs ); -} - -#endif - diff --git a/src/gtk1/toplevel.cpp b/src/gtk1/toplevel.cpp deleted file mode 100644 index 6e102b6c0d..0000000000 --- a/src/gtk1/toplevel.cpp +++ /dev/null @@ -1,1019 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: toplevel.cpp -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// ============================================================================ -// declarations -// ============================================================================ - -// ---------------------------------------------------------------------------- -// headers -// ---------------------------------------------------------------------------- - -#ifdef __VMS -#define XIconifyWindow XICONIFYWINDOW -#endif - -#include "wx/defs.h" - -#include "wx/log.h" -#include "wx/dialog.h" -#include "wx/control.h" -#include "wx/app.h" -#include "wx/dcclient.h" -#include "wx/gtk/private.h" -#include "wx/timer.h" -#include "wx/settings.h" - -#include -#include -#include -#include -#include - -#include "wx/gtk/win_gtk.h" - -#include "wx/unix/utilsx11.h" - -// XA_CARDINAL -#include - -// ---------------------------------------------------------------------------- -// idle system -// ---------------------------------------------------------------------------- - -extern void wxapp_install_idle_handler(); -extern bool g_isIdle; - -// ---------------------------------------------------------------------------- -// data -// ---------------------------------------------------------------------------- - -extern wxList wxPendingDelete; - -extern int g_openDialogs; -extern wxWindowGTK *g_delayedFocus; - -//----------------------------------------------------------------------------- -// "focus" from m_window -//----------------------------------------------------------------------------- - -static gint gtk_frame_focus_callback( GtkWidget *widget, GtkDirectionType WXUNUSED(d), wxWindow *WXUNUSED(win) ) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - - // This disables GTK's tab traversal - gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "focus" ); - return TRUE; -} - -//----------------------------------------------------------------------------- -// "size_allocate" -//----------------------------------------------------------------------------- - -static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxTopLevelWindowGTK *win ) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - - if (!win->m_hasVMT) - return; - - if ((win->m_width != alloc->width) || (win->m_height != alloc->height)) - { -/* - wxPrintf( "OnSize from " ); - if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) - wxPrintf( win->GetClassInfo()->GetClassName() ); - wxPrintf( " %d %d %d %d\n", (int)alloc->x, - (int)alloc->y, - (int)alloc->width, - (int)alloc->height ); -*/ - - win->m_width = alloc->width; - win->m_height = alloc->height; - win->m_queuedFullRedraw = TRUE; - win->GtkUpdateSize(); - } -} - -//----------------------------------------------------------------------------- -// "delete_event" -//----------------------------------------------------------------------------- - -static gint gtk_frame_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxTopLevelWindowGTK *win ) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - - if (win->IsEnabled() && - (g_openDialogs == 0 || (win->GetExtraStyle() & wxTOPLEVEL_EX_DIALOG) || - win->IsGrabbed())) - win->Close(); - - return TRUE; -} - - -//----------------------------------------------------------------------------- -// "configure_event" -//----------------------------------------------------------------------------- - -static gint -gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *WXUNUSED(event), wxTopLevelWindowGTK *win ) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - - if (!win->m_hasVMT || !win->IsShown()) - return FALSE; - - int x = 0; - int y = 0; - gdk_window_get_root_origin( win->m_widget->window, &x, &y ); - win->m_x = x; - win->m_y = y; - - wxMoveEvent mevent( wxPoint(win->m_x,win->m_y), win->GetId() ); - mevent.SetEventObject( win ); - win->GetEventHandler()->ProcessEvent( mevent ); - - return FALSE; -} - -//----------------------------------------------------------------------------- -// "realize" from m_widget -//----------------------------------------------------------------------------- - -// we cannot MWM hints and icons before the widget has been realized, -// so we do this directly after realization - -static void -gtk_frame_realized_callback( GtkWidget * WXUNUSED(widget), - wxTopLevelWindowGTK *win ) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - - // All this is for Motif Window Manager "hints" and is supposed to be - // recognized by other WM as well. Not tested. - gdk_window_set_decorations(win->m_widget->window, - (GdkWMDecoration)win->m_gdkDecor); - gdk_window_set_functions(win->m_widget->window, - (GdkWMFunction)win->m_gdkFunc); - - // GTK's shrinking/growing policy - if ((win->m_gdkFunc & GDK_FUNC_RESIZE) == 0) - gtk_window_set_policy(GTK_WINDOW(win->m_widget), 0, 0, 1); - else - gtk_window_set_policy(GTK_WINDOW(win->m_widget), 1, 1, 1); - - // reset the icon - wxIconBundle iconsOld = win->GetIcons(); - if ( iconsOld.GetIcon(-1).Ok() ) - { - win->SetIcon( wxNullIcon ); - win->SetIcons( iconsOld ); - } -} - -//----------------------------------------------------------------------------- -// "map_event" from m_widget -//----------------------------------------------------------------------------- - -static void -gtk_frame_map_callback( GtkWidget * WXUNUSED(widget), - GdkEvent * WXUNUSED(event), - wxTopLevelWindow *win ) -{ - win->SetIconizeState(FALSE); -} - -//----------------------------------------------------------------------------- -// "unmap_event" from m_widget -//----------------------------------------------------------------------------- - -static void -gtk_frame_unmap_callback( GtkWidget * WXUNUSED(widget), - GdkEvent * WXUNUSED(event), - wxTopLevelWindow *win ) -{ - win->SetIconizeState(TRUE); -} - -//----------------------------------------------------------------------------- -// "expose_event" of m_client -//----------------------------------------------------------------------------- - -static int gtk_window_expose_callback( GtkWidget *widget, GdkEventExpose *gdk_event, wxWindow *win ) -{ - GtkPizza *pizza = GTK_PIZZA(widget); - - gtk_paint_flat_box (win->m_widget->style, - pizza->bin_window, GTK_STATE_NORMAL, - GTK_SHADOW_NONE, - &gdk_event->area, - win->m_widget, - (char *)"base", - 0, 0, -1, -1); - - return FALSE; -} - -//----------------------------------------------------------------------------- -// "draw" of m_client -//----------------------------------------------------------------------------- - -#ifndef __WXGTK20__ - -static void gtk_window_draw_callback( GtkWidget *widget, GdkRectangle *rect, wxWindow *win ) -{ - GtkPizza *pizza = GTK_PIZZA(widget); - - gtk_paint_flat_box (win->m_widget->style, - pizza->bin_window, GTK_STATE_NORMAL, - GTK_SHADOW_NONE, - rect, - win->m_widget, - (char *)"base", - 0, 0, -1, -1); -} - -#endif // GTK+ 1.x - -// ---------------------------------------------------------------------------- -// wxTopLevelWindowGTK itself -// ---------------------------------------------------------------------------- - -//----------------------------------------------------------------------------- -// InsertChild for wxTopLevelWindowGTK -//----------------------------------------------------------------------------- - -/* Callback for wxTopLevelWindowGTK. This very strange beast has to be used because - * C++ has no virtual methods in a constructor. We have to emulate a - * virtual function here as wxWindows requires different ways to insert - * a child in container classes. */ - -static void wxInsertChildInTopLevelWindow( wxTopLevelWindowGTK* parent, wxWindow* child ) -{ - wxASSERT( GTK_IS_WIDGET(child->m_widget) ); - - if (!parent->m_insertInClientArea) - { - // these are outside the client area - wxTopLevelWindowGTK* frame = (wxTopLevelWindowGTK*) parent; - gtk_pizza_put( GTK_PIZZA(frame->m_mainWidget), - GTK_WIDGET(child->m_widget), - child->m_x, - child->m_y, - child->m_width, - child->m_height ); - } - else - { - // these are inside the client area - gtk_pizza_put( GTK_PIZZA(parent->m_wxwindow), - GTK_WIDGET(child->m_widget), - child->m_x, - child->m_y, - child->m_width, - child->m_height ); - } - - // resize on OnInternalIdle - parent->GtkUpdateSize(); -} - -// ---------------------------------------------------------------------------- -// wxTopLevelWindowGTK creation -// ---------------------------------------------------------------------------- - -void wxTopLevelWindowGTK::Init() -{ - m_sizeSet = FALSE; - m_miniEdge = 0; - m_miniTitle = 0; - m_mainWidget = (GtkWidget*) NULL; - m_insertInClientArea = TRUE; - m_isIconized = FALSE; - m_fsIsShowing = FALSE; - m_themeEnabled = TRUE; - m_gdkDecor = m_gdkFunc = 0; - m_grabbed = FALSE; -} - -bool wxTopLevelWindowGTK::Create( wxWindow *parent, - wxWindowID id, - const wxString& title, - const wxPoint& pos, - const wxSize& sizeOrig, - long style, - const wxString &name ) -{ - // always create a frame of some reasonable, even if arbitrary, size (at - // least for MSW compatibility) - wxSize size = sizeOrig; - if ( size.x == -1 || size.y == -1 ) - { - wxSize sizeDpy = wxGetDisplaySize(); - if ( size.x == -1 ) - size.x = sizeDpy.x / 3; - if ( size.y == -1 ) - size.y = sizeDpy.y / 5; - } - - wxTopLevelWindows.Append( this ); - - m_needParent = FALSE; - - if (!PreCreation( parent, pos, size ) || - !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) - { - wxFAIL_MSG( wxT("wxTopLevelWindowGTK creation failed") ); - return FALSE; - } - - m_title = title; - - m_insertCallback = (wxInsertChildFunction) wxInsertChildInTopLevelWindow; - - GtkWindowType win_type = GTK_WINDOW_TOPLEVEL; - - if (style & wxFRAME_TOOL_WINDOW) - win_type = GTK_WINDOW_POPUP; - - if (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG) - { - // there is no more GTK_WINDOW_DIALOG in 2.0 -#ifdef __WXGTK20__ - win_type = GTK_WINDOW_TOPLEVEL; -#else - win_type = GTK_WINDOW_DIALOG; -#endif - } - - m_widget = gtk_window_new( win_type ); - - if (m_parent && (((GTK_IS_WINDOW(m_parent->m_widget)) && - (GetExtraStyle() & wxTOPLEVEL_EX_DIALOG)) || - (style & wxFRAME_FLOAT_ON_PARENT))) - { - gtk_window_set_transient_for( GTK_WINDOW(m_widget), GTK_WINDOW(m_parent->m_widget) ); - } - - if (!name.IsEmpty()) - gtk_window_set_wmclass( GTK_WINDOW(m_widget), wxGTK_CONV( name ), wxGTK_CONV( name ) ); - - gtk_window_set_title( GTK_WINDOW(m_widget), wxGTK_CONV( title ) ); - GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS ); - - gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event", - GTK_SIGNAL_FUNC(gtk_frame_delete_callback), (gpointer)this ); - - // m_mainWidget holds the toolbar, the menubar and the client area - m_mainWidget = gtk_pizza_new(); - gtk_widget_show( m_mainWidget ); - GTK_WIDGET_UNSET_FLAGS( m_mainWidget, GTK_CAN_FOCUS ); - gtk_container_add( GTK_CONTAINER(m_widget), m_mainWidget ); - - // for m_mainWidget themes - gtk_signal_connect( GTK_OBJECT(m_mainWidget), "expose_event", - GTK_SIGNAL_FUNC(gtk_window_expose_callback), (gpointer)this ); -#ifndef __WXGTK20__ - gtk_signal_connect( GTK_OBJECT(m_mainWidget), "draw", - GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this ); -#endif - - // m_wxwindow only represents the client area without toolbar and menubar - m_wxwindow = gtk_pizza_new(); - gtk_widget_show( m_wxwindow ); - gtk_container_add( GTK_CONTAINER(m_mainWidget), m_wxwindow ); - - // we donm't allow the frame to get the focus as otherwise - // the frame will grab it at arbitrary focus changes - GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); - - if (m_parent) m_parent->AddChild( this ); - - // the user resized the frame by dragging etc. - gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", - GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this ); - - PostCreation(); - - if ((m_x != -1) || (m_y != -1)) - gtk_widget_set_uposition( m_widget, m_x, m_y ); - - gtk_window_set_default_size( GTK_WINDOW(m_widget), m_width, m_height ); - - // we cannot set MWM hints and icons before the widget has - // been realized, so we do this directly after realization - gtk_signal_connect( GTK_OBJECT(m_widget), "realize", - GTK_SIGNAL_FUNC(gtk_frame_realized_callback), (gpointer) this ); - - // the only way to get the window size is to connect to this event - gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event", - GTK_SIGNAL_FUNC(gtk_frame_configure_callback), (gpointer)this ); - - // map and unmap for iconized state - gtk_signal_connect( GTK_OBJECT(m_widget), "map_event", - GTK_SIGNAL_FUNC(gtk_frame_map_callback), (gpointer)this ); - gtk_signal_connect( GTK_OBJECT(m_widget), "unmap_event", - GTK_SIGNAL_FUNC(gtk_frame_unmap_callback), (gpointer)this ); - - // the only way to get the window size is to connect to this event - gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event", - GTK_SIGNAL_FUNC(gtk_frame_configure_callback), (gpointer)this ); - - // disable native tab traversal - gtk_signal_connect( GTK_OBJECT(m_widget), "focus", - GTK_SIGNAL_FUNC(gtk_frame_focus_callback), (gpointer)this ); - - // decorations - if ((m_miniEdge > 0) || (style & wxSIMPLE_BORDER) || (style & wxNO_BORDER)) - { - m_gdkDecor = 0; - m_gdkFunc = 0; - } - else - { - m_gdkDecor = (long) GDK_DECOR_BORDER; - m_gdkFunc = (long) GDK_FUNC_MOVE | GDK_FUNC_CLOSE; - - // All this is for Motif Window Manager "hints" and is supposed to be - // recognized by other WMs as well. - if ((style & wxCAPTION) != 0) - { - m_gdkDecor |= GDK_DECOR_TITLE; - } - if ((style & wxSYSTEM_MENU) != 0) - { - m_gdkDecor |= GDK_DECOR_MENU; - } - if ((style & wxMINIMIZE_BOX) != 0) - { - m_gdkFunc |= GDK_FUNC_MINIMIZE; - m_gdkDecor |= GDK_DECOR_MINIMIZE; - } - if ((style & wxMAXIMIZE_BOX) != 0) - { - m_gdkFunc |= GDK_FUNC_MAXIMIZE; - m_gdkDecor |= GDK_DECOR_MAXIMIZE; - } - if ((style & wxRESIZE_BORDER) != 0) - { - m_gdkFunc |= GDK_FUNC_RESIZE; - m_gdkDecor |= GDK_DECOR_RESIZEH; - } - } - - return TRUE; -} - -wxTopLevelWindowGTK::~wxTopLevelWindowGTK() -{ - if (m_grabbed) - { - wxASSERT_MSG( FALSE, _T("Window still grabbed")); - RemoveGrab(); - } - - m_isBeingDeleted = TRUE; - - // it may also be GtkScrolledWindow in the case of an MDI child - if (GTK_IS_WINDOW(m_widget)) - { - gtk_window_set_focus( GTK_WINDOW(m_widget), NULL ); - } -} - - - -bool wxTopLevelWindowGTK::ShowFullScreen(bool show, long style ) -{ - if (show == m_fsIsShowing) return FALSE; // return what? - - m_fsIsShowing = show; - - GdkWindow *window = m_widget->window; - wxX11FullScreenMethod method = - wxGetFullScreenMethodX11((WXDisplay*)GDK_DISPLAY(), - (WXWindow)GDK_ROOT_WINDOW()); - - if (show) - { - m_fsSaveFlag = style; - GetPosition( &m_fsSaveFrame.x, &m_fsSaveFrame.y ); - GetSize( &m_fsSaveFrame.width, &m_fsSaveFrame.height ); - - int screen_width,screen_height; - wxDisplaySize( &screen_width, &screen_height ); - - gint client_x, client_y, root_x, root_y; - gint width, height; - - if (method != wxX11_FS_WMSPEC) - { - // don't do it always, Metacity hates it - m_fsSaveGdkFunc = m_gdkFunc; - m_fsSaveGdkDecor = m_gdkDecor; - m_gdkFunc = m_gdkDecor = 0; - gdk_window_set_decorations(window, (GdkWMDecoration)0); - gdk_window_set_functions(window, (GdkWMFunction)0); - } - - gdk_window_get_origin (m_widget->window, &root_x, &root_y); - gdk_window_get_geometry (m_widget->window, &client_x, &client_y, - &width, &height, NULL); - - gdk_window_move_resize (m_widget->window, -client_x, -client_y, - screen_width + 1, screen_height + 1); - - wxSetFullScreenStateX11((WXDisplay*)GDK_DISPLAY(), - (WXWindow)GDK_ROOT_WINDOW(), - (WXWindow)GDK_WINDOW_XWINDOW(window), - show, &m_fsSaveFrame, method); - } - else - { - if (method != wxX11_FS_WMSPEC) - { - // don't do it always, Metacity hates it - m_gdkFunc = m_fsSaveGdkFunc; - m_gdkDecor = m_fsSaveGdkDecor; - gdk_window_set_decorations(window, (GdkWMDecoration)m_gdkDecor); - gdk_window_set_functions(window, (GdkWMFunction)m_gdkFunc); - } - - wxSetFullScreenStateX11((WXDisplay*)GDK_DISPLAY(), - (WXWindow)GDK_ROOT_WINDOW(), - (WXWindow)GDK_WINDOW_XWINDOW(window), - show, &m_fsSaveFrame, method); - - SetSize(m_fsSaveFrame.x, m_fsSaveFrame.y, - m_fsSaveFrame.width, m_fsSaveFrame.height); - } - - - return TRUE; -} - -// ---------------------------------------------------------------------------- -// overridden wxWindow methods -// ---------------------------------------------------------------------------- - -bool wxTopLevelWindowGTK::Show( bool show ) -{ - wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); - - if (show && !m_sizeSet) - { - /* by calling GtkOnSize here, we don't have to call - either after showing the frame, which would entail - much ugly flicker or from within the size_allocate - handler, because GTK 1.1.X forbids that. */ - - GtkOnSize( m_x, m_y, m_width, m_height ); - } - - return wxWindow::Show( show ); -} - -void wxTopLevelWindowGTK::DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y), int WXUNUSED(width), int WXUNUSED(height) ) -{ - wxFAIL_MSG( wxT("DoMoveWindow called for wxTopLevelWindowGTK") ); -} - -void wxTopLevelWindowGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags ) -{ - wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); - - // this shouldn't happen: wxFrame, wxMDIParentFrame and wxMDIChildFrame have m_wxwindow - wxASSERT_MSG( (m_wxwindow != NULL), wxT("invalid frame") ); - - // avoid recursions - if (m_resizing) - return; - m_resizing = TRUE; - - int old_x = m_x; - int old_y = m_y; - - int old_width = m_width; - int old_height = m_height; - - if ((sizeFlags & wxSIZE_ALLOW_MINUS_ONE) == 0) - { - if (x != -1) m_x = x; - if (y != -1) m_y = y; - } - else - { - m_x = x; - m_y = y; - } - if (width != -1) m_width = width; - if (height != -1) m_height = height; - -/* - if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH) - { - if (width == -1) m_width = 80; - } - - if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT) - { - if (height == -1) m_height = 26; - } -*/ - - int minWidth = GetMinWidth(), - minHeight = GetMinHeight(), - maxWidth = GetMaxWidth(), - maxHeight = GetMaxHeight(); - - if ((minWidth != -1) && (m_width < minWidth)) m_width = minWidth; - if ((minHeight != -1) && (m_height < minHeight)) m_height = minHeight; - if ((maxWidth != -1) && (m_width > maxWidth)) m_width = maxWidth; - if ((maxHeight != -1) && (m_height > maxHeight)) m_height = maxHeight; - - if ((m_x != -1) || (m_y != -1)) - { - if ((m_x != old_x) || (m_y != old_y)) - { - gtk_widget_set_uposition( m_widget, m_x, m_y ); - } - } - - if ((m_width != old_width) || (m_height != old_height)) - { - if (m_widget->window) - gdk_window_resize( m_widget->window, m_width, m_height ); - else - gtk_window_set_default_size( GTK_WINDOW(m_widget), m_width, m_height ); - - /* we set the size in GtkOnSize, i.e. mostly the actual resizing is - done either directly before the frame is shown or in idle time - so that different calls to SetSize() don't lead to flicker. */ - m_sizeSet = FALSE; - } - - m_resizing = FALSE; -} - -void wxTopLevelWindowGTK::DoGetClientSize( int *width, int *height ) const -{ - wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); - - wxWindow::DoGetClientSize( width, height ); - if (height) - { - // mini edge - *height -= m_miniEdge*2 + m_miniTitle; - } - if (width) - { - *width -= m_miniEdge*2; - } -} - -void wxTopLevelWindowGTK::DoSetClientSize( int width, int height ) -{ - wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); - - DoSetSize(-1, -1, - width + m_miniEdge*2, height + m_miniEdge*2 + m_miniTitle, 0); -} - -void wxTopLevelWindowGTK::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; - - // avoid recursions - if (m_resizing) return; - m_resizing = TRUE; - - if ( m_wxwindow == NULL ) return; - - m_width = width; - m_height = height; - - // wxMDIChildFrame derives from wxFrame but it _is_ a wxWindow as it uses - // wxWindow::Create to create it's GTK equivalent. m_mainWidget is only - // set in wxFrame::Create so it is used to check what kind of frame we - // have here. if m_mainWidget is NULL it is a wxMDIChildFrame and so we - // skip the part which handles m_frameMenuBar, m_frameToolBar and (most - // importantly) m_mainWidget - - int minWidth = GetMinWidth(), - minHeight = GetMinHeight(), - maxWidth = GetMaxWidth(), - maxHeight = GetMaxHeight(); - - if (wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA) - { - // GPE's window manager doesn't like size hints - // at all, esp. when the user has to use the - // virtual keyboard. - minWidth = -1; - minHeight = -1; - maxWidth = -1; - maxHeight = -1; - } - - if ((minWidth != -1) && (m_width < minWidth)) m_width = minWidth; - if ((minHeight != -1) && (m_height < minHeight)) m_height = minHeight; - if ((maxWidth != -1) && (m_width > maxWidth)) m_width = maxWidth; - if ((maxHeight != -1) && (m_height > maxHeight)) m_height = maxHeight; - - if (m_mainWidget) - { - // set size hints - gint flag = 0; // GDK_HINT_POS; - GdkGeometry geom; - - if ((minWidth != -1) || (minHeight != -1)) flag |= GDK_HINT_MIN_SIZE; - if ((maxWidth != -1) || (maxHeight != -1)) flag |= GDK_HINT_MAX_SIZE; - - geom.min_width = minWidth; - geom.min_height = minHeight; - - // Because of the way we set GDK_HINT_MAX_SIZE above, if either of - // maxHeight or maxWidth is set, we must set them both, else the - // remaining -1 will be taken literally. - - // I'm certain this also happens elsewhere, and is the probable - // cause of other such things as: - // Gtk-WARNING **: gtk_widget_size_allocate(): - // attempt to allocate widget with width 65535 and height 600 - // but I don't have time to track them all now.. - // - // Really we need to encapulate all this height/width business and - // stop any old method from ripping at the members directly and - // scattering -1's without regard for who might resolve them later. - - geom.max_width = ( maxHeight == -1 ) ? maxWidth - : ( maxWidth == -1 ) ? wxGetDisplaySize().GetWidth() - : maxWidth ; - - geom.max_height = ( maxWidth == -1 ) ? maxHeight // ( == -1 here ) - : ( maxHeight == -1 ) ? wxGetDisplaySize().GetHeight() - : maxHeight ; - - gtk_window_set_geometry_hints( GTK_WINDOW(m_widget), - (GtkWidget*) NULL, - &geom, - (GdkWindowHints) flag ); - - /* I revert back to wxGTK's original behaviour. m_mainWidget holds the - * menubar, the toolbar and the client area, which is represented by - * m_wxwindow. - * this hurts in the eye, but I don't want to call SetSize() - * because I don't want to call any non-native functions here. */ - - int client_x = m_miniEdge; - int client_y = m_miniEdge + m_miniTitle; - int client_w = m_width - 2*m_miniEdge; - int client_h = m_height - 2*m_miniEdge - m_miniTitle; - - gtk_pizza_set_size( GTK_PIZZA(m_mainWidget), - m_wxwindow, - client_x, client_y, client_w, client_h ); - } - else - { - // If there is no m_mainWidget between m_widget and m_wxwindow there - // is no need to set the size or position of m_wxwindow. - } - - m_sizeSet = TRUE; - - // send size event to frame - wxSizeEvent event( wxSize(m_width,m_height), GetId() ); - event.SetEventObject( this ); - GetEventHandler()->ProcessEvent( event ); - - m_resizing = FALSE; -} - -void wxTopLevelWindowGTK::OnInternalIdle() -{ - if (!m_sizeSet && GTK_WIDGET_REALIZED(m_wxwindow)) - { - GtkOnSize( m_x, m_y, m_width, m_height ); - - // we'll come back later - if (g_isIdle) - wxapp_install_idle_handler(); - return; - } - - // set the focus if not done yet and if we can already do it - if ( GTK_WIDGET_REALIZED(m_wxwindow) ) - { - if ( g_delayedFocus && - wxGetTopLevelParent((wxWindow*)g_delayedFocus) == this ) - { - wxLogTrace(_T("focus"), - _T("Setting focus from wxTLW::OnIdle() to %s(%s)"), - g_delayedFocus->GetClassInfo()->GetClassName(), - g_delayedFocus->GetLabel().c_str()); - - g_delayedFocus->SetFocus(); - g_delayedFocus = NULL; - } - } - - wxWindow::OnInternalIdle(); -} - -// ---------------------------------------------------------------------------- -// frame title/icon -// ---------------------------------------------------------------------------- - -void wxTopLevelWindowGTK::SetTitle( const wxString &title ) -{ - wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); - - m_title = title; - gtk_window_set_title( GTK_WINDOW(m_widget), wxGTK_CONV( title ) ); -} - -void wxTopLevelWindowGTK::DoSetIcon( const wxIcon &icon ) -{ - if ( !icon.Ok() ) - return; - - if (!m_widget->window) - return; - - wxMask *mask = icon.GetMask(); - GdkBitmap *bm = (GdkBitmap *) NULL; - if (mask) bm = mask->GetBitmap(); - - gdk_window_set_icon( m_widget->window, (GdkWindow *) NULL, icon.GetPixmap(), bm ); -} - -void wxTopLevelWindowGTK::SetIcon( const wxIcon &icon ) -{ - SetIcons( wxIconBundle( icon ) ); -} - -void wxTopLevelWindowGTK::SetIcons( const wxIconBundle &icons ) -{ - wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") ); - GdkWindow* window = m_widget->window; - - wxTopLevelWindowBase::SetIcons( icons ); - - DoSetIcon( icons.GetIcon( -1 ) ); - if ( window ) - { - wxSetIconsX11( (WXDisplay*)GDK_WINDOW_XDISPLAY( window ), - (WXWindow)GDK_WINDOW_XWINDOW( window ), icons ); - } -} - -// ---------------------------------------------------------------------------- -// frame state: maximized/iconized/normal -// ---------------------------------------------------------------------------- - -void wxTopLevelWindowGTK::Maximize(bool maximize) -{ -#ifdef __WXGTK20__ - if (maximize) - gtk_window_maximize( GTK_WINDOW( m_widget ) ); - else - gtk_window_unmaximize( GTK_WINDOW( m_widget ) ); -#else - wxFAIL_MSG( _T("not implemented") ); -#endif -} - -bool wxTopLevelWindowGTK::IsMaximized() const -{ - // wxFAIL_MSG( _T("not implemented") ); - - // This is an approximation - return FALSE; -} - -void wxTopLevelWindowGTK::Restore() -{ -#ifdef __GTK20__ - // "Present" seems similar enough to "restore" - gtk_window_present( GTK_WINDOW( m_widget ) ); -#else - wxFAIL_MSG( _T("not implemented") ); -#endif -} - -void wxTopLevelWindowGTK::Iconize( bool iconize ) -{ -#ifdef __WXGTK20__ - if (iconize) - gtk_window_iconify( GTK_WINDOW( m_widget ) ); - else - gtk_window_deiconify( GTK_WINDOW( m_widget ) ); -#else - if (iconize) - { - GdkWindow *window = m_widget->window; - - // you should do it later, for example from OnCreate() handler - wxCHECK_RET( window, _T("frame not created yet - can't iconize") ); - - XIconifyWindow( GDK_WINDOW_XDISPLAY( window ), - GDK_WINDOW_XWINDOW( window ), - DefaultScreen( GDK_DISPLAY() ) ); - } -#endif -} - -bool wxTopLevelWindowGTK::IsIconized() const -{ - return m_isIconized; -} - -void wxTopLevelWindowGTK::SetIconizeState(bool iconize) -{ - if ( iconize != m_isIconized ) - { - m_isIconized = iconize; - (void)SendIconizeEvent(iconize); - } -} - -void wxTopLevelWindowGTK::AddGrab() -{ - if (!m_grabbed) - { - m_grabbed = TRUE; - gtk_grab_add( m_widget ); - gtk_main(); - gtk_grab_remove( m_widget ); - } -} - -void wxTopLevelWindowGTK::RemoveGrab() -{ - if (m_grabbed) - { - gtk_main_quit(); - m_grabbed = FALSE; - } -} - - -// helper -static bool do_shape_combine_region(GdkWindow* window, const wxRegion& region) -{ - if (window) - { - if (region.IsEmpty()) - { - gdk_window_shape_combine_mask(window, NULL, 0, 0); - } - else - { -#ifdef __WXGTK20__ - gdk_window_shape_combine_region(window, region.GetRegion(), 0, 0); -#else - wxBitmap bmp = region.ConvertToBitmap(); - bmp.SetMask(new wxMask(bmp, *wxBLACK)); - GdkBitmap* mask = bmp.GetMask()->GetBitmap(); - gdk_window_shape_combine_mask(window, mask, 0, 0); -#endif - return TRUE; - } - } - return FALSE; -} - - -bool wxTopLevelWindowGTK::SetShape(const wxRegion& region) -{ - wxCHECK_MSG( HasFlag(wxFRAME_SHAPED), FALSE, - _T("Shaped windows must be created with the wxFRAME_SHAPED style.")); - - GdkWindow *window = NULL; - if (m_wxwindow) - { - window = GTK_PIZZA(m_wxwindow)->bin_window; - do_shape_combine_region(window, region); - } - window = m_widget->window; - return do_shape_combine_region(window, region); -} - -// vi:sts=4:sw=4:et diff --git a/src/gtk1/treegtk.cpp b/src/gtk1/treegtk.cpp deleted file mode 100644 index f5cfa9a852..0000000000 --- a/src/gtk1/treegtk.cpp +++ /dev/null @@ -1,930 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: treectrl.cpp -// Purpose: wxTreeCtrl -// Author: Denis Pershin -// Modified by: -// Created: 07/05/98 -// RCS-ID: $Id$ -// Copyright: (c) Denis Pershin -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ -#pragma hdrstop -#endif - -#ifndef WX_PRECOMP -#include "wx/wx.h" -#endif - -#include "wx/gtk/treectrl.h" -#include "wx/textctrl.h" -#include "wx/log.h" - -#include - -//static void wxConvertToGtkTreeItem(wxTreeCtrl *owner, wxTreeItem& info, GtkTreeItem **gtkItem); -//static void wxConvertFromGtkTreeItem(wxTreeItem& info, GtkTreeItem *gtkItem); - -static void gtk_treectrl_count_callback (GtkWidget *widget, gpointer data); -static void gtk_treectrl_first_selected_callback(GtkWidget *widget, gpointer data); -static void gtk_treectrl_first_visible_callback(GtkWidget *widget, gpointer data); - -// static void gtk_treectrl_next_callback (GtkWidget *widget, gpointer data); -// static void gtk_treectrl_next_visible_callback (GtkWidget *widget, gpointer data); -// static void gtk_treectrl_next_selected_callback (GtkWidget *widget, gpointer data); - -static void gtk_treeitem_expand_callback(GtkWidget *widget, wxTreeItemId *treeitem); -static void gtk_treeitem_collapse_callback(GtkWidget *widget, wxTreeItemId *treeitem); -static void gtk_treeitem_select_callback(GtkWidget *widget, wxTreeItemId *treeitem); - -static void gtk_treeitem_expand_callback(GtkWidget *widget, wxTreeItemId *treeitem) { - wxTreeCtrl *owner = (wxTreeCtrl *)gtk_object_get_data(GTK_OBJECT(widget), "owner"); - if (owner == NULL) - return; - -// long id = (long)gtk_object_get_data(GTK_OBJECT(widget), "id"); - owner->SendExpanding(GTK_TREE_ITEM(widget)); - owner->SendExpanded(GTK_TREE_ITEM(widget)); -}; - -static void gtk_treeitem_collapse_callback(GtkWidget *widget, wxTreeItemId *treeitem) { - wxTreeCtrl *owner = (wxTreeCtrl *)gtk_object_get_data(GTK_OBJECT(widget), "owner"); - if (owner == NULL) - return; - -// long id = (long)gtk_object_get_data(GTK_OBJECT(widget), "id"); - owner->SendCollapsing(GTK_TREE_ITEM(widget)); - owner->SendCollapsed(GTK_TREE_ITEM(widget)); -}; - -static void gtk_treeitem_select_callback(GtkWidget *widget, wxTreeItemId *treeitem) { - wxTreeCtrl *owner = (wxTreeCtrl *)gtk_object_get_data(GTK_OBJECT(widget), "owner"); - if (owner == NULL) - return; - -// long id = (long)gtk_object_get_data(GTK_OBJECT(widget), "id"); - owner->SendSelChanging(GTK_TREE_ITEM(widget)); - owner->SendSelChanged(GTK_TREE_ITEM(widget)); -} - -IMPLEMENT_DYNAMIC_CLASS(wxTreeCtrl, wxControl) - - -void wxTreeCtrl::Init() { - m_imageListNormal = NULL; - m_imageListState = NULL; - m_textCtrl = NULL; -} - -bool wxTreeCtrl::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, - const wxSize& size, long style, - const wxValidator& validator, const wxString& name) { - Init(); - - int x = pos.x; - int y = pos.y; - int width = size.x; - int height = size.y; - - m_windowStyle = style; - - SetParent(parent); - - if (width <= 0) - width = 100; - if (height <= 0) - height = 30; - if (x < 0) - x = 0; - if (y < 0) - y = 0; - - m_needParent = TRUE; - -printf("precreate\n"); - PreCreation( parent, id, pos, size, style, name ); - -printf("1\n"); - - m_widget = gtk_scrolled_window_new(NULL, NULL); -printf("2\n"); - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(m_widget), - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - -printf("3\n"); - m_tree = GTK_TREE(gtk_tree_new()); - -printf("4\n"); - gtk_container_add(GTK_CONTAINER(m_widget), GTK_WIDGET(m_tree)); -printf("5\n"); - gtk_widget_show(GTK_WIDGET(m_tree)); - - SetName(name); - SetValidator(validator); - -printf("Robert's new insertion code :-)\n"); - m_parent->DoAddChild( this ); -printf("postcreate\n"); - PostCreation(); - - gtk_widget_realize(GTK_WIDGET(m_tree)); - - Show(TRUE); - - return TRUE; -} - -wxTreeCtrl::~wxTreeCtrl(void) { - if (m_textCtrl) - delete m_textCtrl; -} - -// Attributes -static void gtk_treectrl_count_callback (GtkWidget *widget, gpointer data) { - int count = (*((int *)data)); - - count++; - if (GTK_IS_CONTAINER(widget)) - gtk_container_foreach(GTK_CONTAINER(widget), gtk_treectrl_count_callback, data); -} - -size_t wxTreeCtrl::GetCount() const { - int count = 0; - - if (m_anchor != NULL) - gtk_treectrl_count_callback(GTK_WIDGET(m_anchor), &count); - return count; -} - -unsigned int wxTreeCtrl::GetIndent() const { - return m_tree->indent_value; -} - -void wxTreeCtrl::SetIndent(unsigned int indent) { - m_tree->indent_value = indent; -} - -wxImageList *wxTreeCtrl::GetImageList() const { - return m_imageListNormal; -} - -wxImageList *wxTreeCtrl::GetStateImageList() const { - return m_imageListState; -} - -void wxTreeCtrl::SetImageList(wxImageList *imageList) { - m_imageListNormal = imageList; -} - -void wxTreeCtrl::SetStateImageList(wxImageList *imageList) { - m_imageListState = imageList; -} - -wxString wxTreeCtrl::GetItemText(const wxTreeItemId &item) const { - char *t; - - if (!item.IsOk()) - return wxString(""); - - GtkLabel *l = GTK_LABEL(gtk_object_get_data(GTK_OBJECT((GtkTreeItem *)item), "w_label")); - gtk_label_get(l, &t); - - return t; -} - -int wxTreeCtrl::GetItemImage(const wxTreeItemId& item) const { - if (!item.IsOk()) - return (-1); - - return (int)gtk_object_get_data(GTK_OBJECT((GtkTreeItem *)item), "image"); -} - -int wxTreeCtrl::GetItemSelectedImage(const wxTreeItemId& item) const { - if (!item.IsOk()) - return (-1); - - return (int)gtk_object_get_data(GTK_OBJECT((GtkTreeItem *)item), "selectedImage"); -} - -wxTreeItemData *wxTreeCtrl::GetItemData(const wxTreeItemId& item) const { - if (!item.IsOk()) - return NULL; - - return (wxTreeItemData *)gtk_object_get_data(GTK_OBJECT((GtkTreeItem *)item), "data"); -} - -void wxTreeCtrl::SetItemText(const wxTreeItemId& item, const wxString& text) { - if (!item.IsOk()) - return; - - GtkLabel *l = GTK_LABEL(gtk_object_get_data(GTK_OBJECT((GtkTreeItem *)item), "w_label")); - gtk_label_set(l, text); -} - -void wxTreeCtrl::SetItemImage(const wxTreeItemId& item, int image) { - if (!item.IsOk()) - return; - - gtk_object_set_data(GTK_OBJECT((GtkTreeItem *)item), "image", (void *)image); -} - -void wxTreeCtrl::SetItemSelectedImage(const wxTreeItemId& item, int image) { - if (!item.IsOk()) - return; - - gtk_object_set_data(GTK_OBJECT((GtkTreeItem *)item), "selectedImage", (void *)image); -} - -void wxTreeCtrl::SetItemData(const wxTreeItemId& item, wxTreeItemData *data) { - if (!item.IsOk()) - return; - - gtk_object_set_data(GTK_OBJECT((GtkTreeItem *)item), "data", data); -} - -bool wxTreeCtrl::IsVisible(const wxTreeItemId& item) const { - return GTK_WIDGET_VISIBLE(GTK_TREE_ITEM((GtkTreeItem *)item)); -} - -bool wxTreeCtrl::ItemHasChildren(const wxTreeItemId& item) const { - GtkTreeItem *p = (GtkTreeItem *)item; - - if (p->subtree == NULL) - return wxFalse; - - if (GTK_TREE(p->subtree)->children == NULL) - return wxFalse; - - if (g_list_length(GTK_TREE(p->subtree)->children) == 0) - return wxFalse; - - return wxTrue; -} - -bool wxTreeCtrl::IsExpanded(const wxTreeItemId& item) const { - return (((GtkTreeItem *)item)->expanded != 0); -} - -bool wxTreeCtrl::IsSelected(const wxTreeItemId& item) const { - GtkTreeItem *p = (GtkTreeItem *)item; - GtkWidget *parent = GTK_WIDGET(p)->parent; - - if (!GTK_IS_TREE(parent)) - return wxFalse; - - if (g_list_index(GTK_TREE(parent)->children, p) == -1) - return wxFalse; - - return wxTrue; -} - -wxTreeItemId wxTreeCtrl::GetRootItem() const { - return m_anchor; -} - -static void gtk_treectrl_first_selected_callback(GtkWidget *widget, gpointer data) { - GtkTreeItem *p = (*((GtkTreeItem **)data)); - - GtkTree *tree = GTK_TREE(GTK_TREE_ITEM(widget)->subtree); - - if (tree->selection != NULL) { - p = (GtkTreeItem *)tree->selection->data; - return; - } - - if (GTK_IS_CONTAINER(widget)) - gtk_container_foreach(GTK_CONTAINER(widget), gtk_treectrl_first_selected_callback, data); -} - -wxTreeItemId wxTreeCtrl::GetSelection() const { - GtkTreeItem *p = NULL; - - if (m_anchor == NULL) - return NULL; - - gtk_treectrl_first_selected_callback(GTK_WIDGET(m_anchor), &p); - - return p; -} - -wxTreeItemId wxTreeCtrl::GetItemParent(const wxTreeItemId& item) const { - if (item.IsOk()) - return (GtkTreeItem *)gtk_object_get_data(GTK_OBJECT((GtkTreeItem *)item), "parent"); - - return NULL; -} - -wxTreeItemId wxTreeCtrl::GetFirstChild(const wxTreeItemId& item, long& cookie) const { - GtkTreeItem *p = (GtkTreeItem *)item; - GtkWidget *parent = GTK_WIDGET(p)->parent; - - if (!GTK_IS_TREE(parent)) - return NULL; - - cookie = 0; - return GTK_TREE_ITEM(g_list_first(GTK_TREE(parent)->children)->data); -} - -wxTreeItemId wxTreeCtrl::GetNextChild(const wxTreeItemId& item, long& cookie) const { - GtkTreeItem *p = (GtkTreeItem *)item; - GtkWidget *parent = GTK_WIDGET(p)->parent; - - if (!GTK_IS_TREE(parent)) - return NULL; - - cookie++; - return GTK_TREE_ITEM(g_list_nth(GTK_TREE(parent)->children, cookie)->data); -} - -wxTreeItemId wxTreeCtrl::GetLastChild(const wxTreeItemId& item) const -{ - GtkTreeItem *p = (GtkTreeItem *)item; - GtkWidget *parent = GTK_WIDGET(p)->parent; - - wxCHECK_MSG( GTK_IS_TREE(parent), NULL, "invalid tree item" ); - - return GTK_TREE_ITEM(g_list_last(GTK_TREE(parent)->children)->data); -} - -wxTreeItemId wxTreeCtrl::GetNextSibling(const wxTreeItemId& item) const { - GtkTreeItem *p = (GtkTreeItem *)item; - GtkWidget *parent = GTK_WIDGET(p)->parent; - - if (!GTK_IS_TREE(parent)) - return NULL; - - if (g_list_index(GTK_TREE(parent)->children, p) == -1) - return NULL; - - return GTK_TREE_ITEM(g_list_next(g_list_find(GTK_TREE(parent)->children, p))->data); -} - -wxTreeItemId wxTreeCtrl::GetPrevSibling(const wxTreeItemId& item) const { - GtkTreeItem *p = (GtkTreeItem *)item; - GtkWidget *parent = GTK_WIDGET(p)->parent; - - if (!GTK_IS_TREE(parent)) - return NULL; - - if (g_list_index(GTK_TREE(parent)->children, p) == -1) - return NULL; - - return GTK_TREE_ITEM(g_list_previous(g_list_find(GTK_TREE(parent)->children, p))->data); -} - -static void gtk_treectrl_first_visible_callback(GtkWidget *widget, gpointer data) { - GtkTreeItem *p = (*((GtkTreeItem **)data)); - - GtkTree *tree = GTK_TREE(GTK_TREE_ITEM(widget)->subtree); - - if (tree->children != NULL) { - guint len = g_list_length(tree->children); - for (guint i=0; ichildren, i)->data)))) { - p = GTK_TREE_ITEM((GtkTreeItem *)g_list_nth(tree->children, i)->data); - return; - } - } - } - - if (GTK_IS_CONTAINER(widget)) - gtk_container_foreach(GTK_CONTAINER(widget), gtk_treectrl_first_visible_callback, data); -} - -wxTreeItemId wxTreeCtrl::GetFirstVisibleItem() const { - GtkTreeItem *p = NULL; - - if (m_anchor == NULL) - return NULL; - - gtk_treectrl_first_visible_callback(GTK_WIDGET(m_anchor), &p); - - return p; -} - -wxTreeItemId wxTreeCtrl::GetNextVisible(const wxTreeItemId& item) const { - GtkTreeItem *p = (GtkTreeItem *)item; - GtkTree *parent = GTK_TREE(GTK_WIDGET(p)->parent); - GtkTreeItem *q; - - if (!GTK_IS_TREE(parent)) - return NULL; - - if (parent->children == NULL) - return NULL; - - q = GTK_TREE_ITEM(g_list_next(g_list_find(GTK_TREE(parent)->children, p))->data); - - while (q != p) { - q = GTK_TREE_ITEM(g_list_next(g_list_find(GTK_TREE(parent)->children, q))->data); - if (GTK_WIDGET_VISIBLE(GTK_WIDGET(q))) - return q; - } - - return NULL; -} - -wxTreeItemId wxTreeCtrl::GetPrevVisible(const wxTreeItemId& item) const { - GtkTreeItem *p = (GtkTreeItem *)item; - GtkTree *parent = GTK_TREE(GTK_WIDGET(p)->parent); - GtkTreeItem *q; - - if (!GTK_IS_TREE(parent)) - return NULL; - - if (parent->children == NULL) - return NULL; - - q = GTK_TREE_ITEM(g_list_previous(g_list_find(GTK_TREE(parent)->children, p))->data); - - while (q != p) { - q = GTK_TREE_ITEM(g_list_previous(g_list_find(GTK_TREE(parent)->children, q))->data); - if (GTK_WIDGET_VISIBLE(GTK_WIDGET(q))) - return q; - } - - return NULL; -} - -wxTreeItemId wxTreeCtrl::AddRoot(const wxString& text, int image, - int selectedImage, wxTreeItemData *data) { - return p_InsertItem(0, text, image, selectedImage, data); -} - -wxTreeItemId wxTreeCtrl::PrependItem(const wxTreeItemId& parent, - const wxString& text, int image, int selectedImage, - wxTreeItemData *data) { -#warning "Need to implement PrependItem" - return NULL; -} - -wxTreeItemId wxTreeCtrl::InsertItem(const wxTreeItemId& parent, - const wxTreeItemId& idPrevious, const wxString& text, - int image, int selectedImage, wxTreeItemData *data) { -#warning "Need to implement InsertItem" - return NULL; -} - -wxTreeItemId wxTreeCtrl::AppendItem(const wxTreeItemId& parent, - const wxString& text, int image, int selectedImage, - wxTreeItemData *data) { - return p_InsertItem(parent, text, image, selectedImage, data); -} - -wxTreeItemId wxTreeCtrl::p_InsertItem(GtkTreeItem *p, - const wxString& text, int image, int selectedImage, - wxTreeItemData *data) { - GtkTreeItem *item; - -printf("begin insert\n"); - - item = GTK_TREE_ITEM(gtk_tree_item_new()); - - GtkHBox *m_box = GTK_HBOX(gtk_hbox_new(FALSE, 0)); - gtk_container_add (GTK_CONTAINER (item), GTK_WIDGET(m_box)); - - gtk_object_set_data(GTK_OBJECT(item), "w_box", m_box); - - const wxBitmap *bmp; - const wxImageList *list; - if ((list = GetImageList(wxIMAGE_LIST_NORMAL)) != NULL) - if ((bmp = list->GetBitmap(image)) != NULL) - if (bmp->Ok()) { - GdkBitmap *mask = NULL; - if (bmp->GetMask()) - mask = bmp->GetMask()->GetBitmap(); - GtkPixmap *m_image_widget = GTK_PIXMAP(gtk_pixmap_new(bmp->GetPixmap(), mask)); - gtk_misc_set_alignment (GTK_MISC (m_image_widget), 0.0, 0.5); - gtk_box_pack_start(GTK_BOX(m_box), GTK_WIDGET(m_image_widget), FALSE, FALSE, 0); - gtk_object_set_data(GTK_OBJECT(item), "w_image", (void *)m_image_widget); - gtk_object_set_data(GTK_OBJECT(item), "image", (void *)image); - gtk_widget_show (GTK_WIDGET(m_image_widget)); - } - GtkLabel *m_label_widget = GTK_LABEL(gtk_label_new ((char *)(const char *)text)); - gtk_misc_set_alignment (GTK_MISC (m_label_widget), 0.5, 0.5); - gtk_box_pack_start(GTK_BOX(m_box), GTK_WIDGET(m_label_widget), FALSE, FALSE, 0); - gtk_object_set_data(GTK_OBJECT(item), "w_label", m_label_widget); - gtk_widget_show (GTK_WIDGET(m_label_widget)); - - gtk_widget_show(GTK_WIDGET(m_box)); - - gtk_object_set_data(GTK_OBJECT(item), "owner", this); - gtk_object_set_data(GTK_OBJECT(item), "data", data); - gtk_object_set_data(GTK_OBJECT(item), "parent", p); - - if (p != 0) { - if (p->subtree == NULL) { - GtkTree *tree = GTK_TREE(gtk_tree_new()); - gtk_tree_item_set_subtree(GTK_TREE_ITEM(p), GTK_WIDGET(tree)); - gtk_widget_show(GTK_WIDGET(tree)); - p->expanded = 1; - } - - gtk_container_add(GTK_CONTAINER(p->subtree), GTK_WIDGET(item)); - } else { -printf("Adding root\n"); -printf("m_tree = %p\n", m_tree); - m_anchor = item; - gtk_container_add(GTK_CONTAINER(m_tree), GTK_WIDGET(item)); - } - - gtk_widget_show(GTK_WIDGET(item)); - - gtk_signal_connect(GTK_OBJECT(item), "select", - GTK_SIGNAL_FUNC(gtk_treeitem_select_callback), (gpointer)this ); - - gtk_signal_connect(GTK_OBJECT(item), "deselect", - GTK_SIGNAL_FUNC(gtk_treeitem_select_callback), (gpointer)this ); - - gtk_signal_connect(GTK_OBJECT(item), "expand", - GTK_SIGNAL_FUNC(gtk_treeitem_expand_callback), (gpointer)this ); - gtk_signal_connect(GTK_OBJECT(item), "collapse", - GTK_SIGNAL_FUNC(gtk_treeitem_collapse_callback), (gpointer)this ); - - return item; -} - -void wxTreeCtrl::Delete(const wxTreeItemId& item) { - if (!item.IsOk()) - return; - - GtkTreeItem *parent = GTK_TREE_ITEM(GTK_WIDGET((GtkTreeItem *)item)->parent); - if (parent == NULL) - return; - - gtk_container_remove(GTK_CONTAINER(parent), GTK_WIDGET((GtkTreeItem *)item)); - - return; -} - -void wxTreeCtrl::DeleteAllItems() { - gtk_tree_item_remove_subtree(m_anchor); -} - -void wxTreeCtrl::Expand(const wxTreeItemId& item) { - if (!item.IsOk()) - return; - - gtk_tree_item_expand(GTK_TREE_ITEM((GtkTreeItem *)item)); -} - -void wxTreeCtrl::Collapse(const wxTreeItemId& item) { - if (!item.IsOk()) - return; - - gtk_tree_item_collapse(GTK_TREE_ITEM((GtkTreeItem *)item)); -} - -void wxTreeCtrl::CollapseAndReset(const wxTreeItemId& item) { - if (!item.IsOk()) - return; - - gtk_tree_item_collapse(GTK_TREE_ITEM((GtkTreeItem *)item)); - gtk_tree_item_remove_subtree(GTK_TREE_ITEM((GtkTreeItem *)item)); -} - -void wxTreeCtrl::Toggle(const wxTreeItemId& item) { - if (!item.IsOk()) - return; - - if (((GtkTreeItem *)item)->expanded) - gtk_tree_item_collapse(GTK_TREE_ITEM((GtkTreeItem *)item)); - else - gtk_tree_item_expand(GTK_TREE_ITEM((GtkTreeItem *)item)); -} - -static void gtk_treectrl_unselect_callback(GtkWidget *widget, gpointer data) { - GtkTreeItem *p; - - GtkTree *tree = GTK_TREE(GTK_TREE_ITEM(widget)->subtree); - - if (tree->selection != NULL) { - guint len = g_list_length(tree->selection); - for (guint i=0; iselection, i)->data); - gtk_tree_unselect_child(tree, GTK_WIDGET(p)); - } - } - - if (GTK_IS_CONTAINER(widget)) - gtk_container_foreach(GTK_CONTAINER(widget), gtk_treectrl_unselect_callback, data); -} - -void wxTreeCtrl::Unselect() { - if (m_anchor == NULL) - return; - - gtk_treectrl_unselect_callback(GTK_WIDGET(m_anchor), NULL); -} - -void wxTreeCtrl::SelectItem(const wxTreeItemId& item) { - if (!item.IsOk()) - return; - - gtk_tree_item_select((GtkTreeItem *)item); -} - -void wxTreeCtrl::EnsureVisible(const wxTreeItemId& item) { -#warning "Need to implement EnsureVisible" -} - -void wxTreeCtrl::ScrollTo(const wxTreeItemId& item) { -#warning "Need to implement ScrollTo" -} - -wxTextCtrl* wxTreeCtrl::EditLabel(const wxTreeItemId& item, - wxClassInfo* textControlClass) { - wxASSERT( textControlClass->IsKindOf(CLASSINFO(wxTextCtrl)) ); -#warning "Need to implement EditLabel" -/* - char *s; - m_editItem = item; - - GtkLabel *m_label = (GtkLabel *)gtk_object_get_data(GTK_OBJECT((GtkTreeItem *)item), "w_label"); - gtk_label_get(m_label, &s); - - m_textCtrl = new wxTextCtrl(this, -1, s); -// m_textCtrl->SetValue(s); - - gtk_object_set_data(GTK_OBJECT((GtkTreeItem *)item), "w_edit", m_textCtrl->m_widget); - - gtk_container_remove(GTK_CONTAINER((GtkTreeItem *)item), GTK_WIDGET(m_label)); - gtk_container_add(GTK_CONTAINER((GtkTreeItem *)item), m_textCtrl->m_widget); - -*/ - return m_textCtrl; -} - -wxTextCtrl* wxTreeCtrl::GetEditControl() const { - return m_textCtrl; -} - -void wxTreeCtrl::EndEditLabel(const wxTreeItemId& item, bool discardChanges) { -#warning "Need to implement EndEditLabel" -/* - GtkLabel *m_label = (GtkLabel *)gtk_object_get_data(GTK_OBJECT((GtkTreeItem *)m_editItem), "w_label"); - gtk_label_set(m_label, m_textCtrl->GetValue()); - - gtk_object_remove_data(GTK_OBJECT((GtkTreeItem *)m_editItem), "w_edit"); - - gtk_container_remove(GTK_CONTAINER((GtkTreeItem *)m_editItem), m_textCtrl->m_widget); - gtk_container_add(GTK_CONTAINER((GtkTreeItem *)m_editItem), GTK_WIDGET(m_label)); - - delete m_textCtrl; - m_textCtrl = NULL; -*/ -} - -void wxTreeCtrl::ExpandItem(const wxTreeItemId& item, int action) { - switch (action) { - case wxTREE_EXPAND_EXPAND: - Expand(item); - break; - - case wxTREE_EXPAND_COLLAPSE: - Collapse(item); - break; - - case wxTREE_EXPAND_COLLAPSE_RESET: - CollapseAndReset(item); - break; - - case wxTREE_EXPAND_TOGGLE: - Toggle(item); - break; - - default: - wxFAIL_MSG("unknown action in wxTreeCtrl::ExpandItem"); - } -} - -wxTreeItemId wxTreeCtrl::InsertItem(const wxTreeItemId& parent, - const wxString& text, int image, int selImage, - long insertAfter) { -// InsertItem(parent, insertAfter, text, image, selImage); - #warning "Need to implement InsertItem" - return NULL; -} - -/* Old functions -long wxTreeCtrl::GetChild(long item) const { - GtkTreeItem *p; - GtkTreeItem *next = NULL; - - p = findGtkTreeItem(item); - GList *list = gtk_container_children(GTK_CONTAINER(p)); - next = GTK_TREE_ITEM(list->data);; - - if (next != NULL) - return (long)gtk_object_get_data(GTK_OBJECT(next), "id"); - - return (-1); -} - -long wxTreeCtrl::GetFirstVisibleItem(void) const { - GtkTreeItem *next = NULL; - - GList *list = gtk_container_children(GTK_CONTAINER(m_anchor)); - next = GTK_TREE_ITEM(list->data);; -// gtk_container_foreach(GTK_CONTAINER(m_anchor), gtk_treectrl_next_visible_callback, &next); - - if (next != NULL) - return (long)gtk_object_get_data(GTK_OBJECT(next), "id"); - - return (-1); -} - -long wxTreeCtrl::GetNextVisibleItem(long item) const { - GtkTreeItem *p; - GtkTreeItem *next = NULL; - - p = findGtkTreeItem(item); - GList *list = gtk_container_children(GTK_CONTAINER(p)); - next = GTK_TREE_ITEM(list->data);; -// gtk_container_foreach(GTK_CONTAINER(p), gtk_treectrl_next_visible_callback, &next); - - if (next != NULL) - return (long)gtk_object_get_data(GTK_OBJECT(next), "id"); - - return (-1); -} - -bool wxTreeCtrl::GetItem(wxTreeItem& info) const { - GtkTreeItem *p; - - p = findGtkTreeItem(info.m_itemId); - - if (p == NULL) { - wxLogSysError("TreeCtrl::GetItem failed"); - return FALSE; - } - - wxConvertFromGtkTreeItem(info, p); - - return TRUE; -} - -bool wxTreeCtrl::SetItem(wxTreeItem& info) { - GtkTreeItem *p; - - p = findGtkTreeItem(info.m_itemId); - - if (p == NULL) { - wxLogSysError("TreeCtrl::SetItem failed"); - return FALSE; - } - - wxConvertToGtkTreeItem(this, info, &p); - - return TRUE; -} - -int wxTreeCtrl::GetItemState(long item, long stateMask) const { - wxTreeItem info; - - info.m_mask = wxTREE_MASK_STATE ; - info.m_stateMask = stateMask; - info.m_itemId = item; - - if (!GetItem(info)) - return 0; - - return info.m_state; -} - -bool wxTreeCtrl::SetItemState(long item, long state, long stateMask) { - wxTreeItem info; - - info.m_mask = wxTREE_MASK_STATE ; - info.m_state = state; - info.m_stateMask = stateMask; - info.m_itemId = item; - - return SetItem(info); -} -*/ - -// Operations -/* -bool wxTreeCtrl::DeleteChildren(long item) { - GtkTreeItem *p; - - p = findGtkTreeItem(item); - if (p == NULL) - return FALSE; - - gtk_tree_item_remove_subtree(GTK_TREE_ITEM(p)); - - return TRUE; -} -*/ - -/* -long wxTreeCtrl::InsertItem(long parent, wxTreeItem& info, long insertAfter) { - GtkTreeItem *p; - GtkTreeItem *item = NULL; - - info.m_itemId = m_curitemId; - m_curitemId++; - - wxConvertToGtkTreeItem(this, info, &item); - - if (parent != 0) { - p = findGtkTreeItem(parent); - if (p->subtree == NULL) { - GtkTree *tree = GTK_TREE(gtk_tree_new()); - gtk_tree_item_set_subtree(GTK_TREE_ITEM(p), GTK_WIDGET(tree)); - gtk_widget_show(GTK_WIDGET(tree)); - p->expanded = 1; - } - - gtk_container_add(GTK_CONTAINER(p->subtree), GTK_WIDGET(item)); - } else { - m_anchor = item; - gtk_container_add(GTK_CONTAINER(m_tree), GTK_WIDGET(item)); - } - - if ((info.m_mask & wxTREE_MASK_CHILDREN) != 0) { - GtkTree *tree = GTK_TREE(gtk_tree_new()); - gtk_tree_item_set_subtree(GTK_TREE_ITEM(item), GTK_WIDGET(tree)); - gtk_widget_show(GTK_WIDGET(tree)); - } - - gtk_widget_show(GTK_WIDGET(item)); - - gtk_signal_connect(GTK_OBJECT(item), "select", - GTK_SIGNAL_FUNC(gtk_treeitem_select_callback), (gpointer)this ); - - gtk_signal_connect(GTK_OBJECT(item), "deselect", - GTK_SIGNAL_FUNC(gtk_treeitem_select_callback), (gpointer)this ); - - gtk_signal_connect(GTK_OBJECT(item), "expand", - GTK_SIGNAL_FUNC(gtk_treeitem_expand_callback), (gpointer)this ); - gtk_signal_connect(GTK_OBJECT(item), "collapse", - GTK_SIGNAL_FUNC(gtk_treeitem_collapse_callback), (gpointer)this ); - - return info.m_itemId; -} - -long wxTreeCtrl::InsertItem(long parent, const wxString& label, int image, - int selImage, long insertAfter) { - - wxTreeItem info; - info.m_text = label; - info.m_mask = wxTREE_MASK_TEXT; - if (image > -1) { - info.m_mask |= wxTREE_MASK_IMAGE | wxTREE_MASK_SELECTED_IMAGE; - info.m_image = image; - if (selImage == -1) - info.m_selectedImage = image; - else - info.m_selectedImage = selImage; - } - - return InsertItem(parent, info, insertAfter); -} -*/ - -void wxTreeCtrl::SendMessage(wxEventType command, const wxTreeItemId& item) { - wxTreeEvent event(command, GetId()); - event.SetEventObject(this); - event.m_item = item; - ProcessEvent(event); -} - -void wxTreeCtrl::SendExpanding(const wxTreeItemId& item) { - SendMessage(wxEVT_COMMAND_TREE_ITEM_EXPANDING, item); -} - -void wxTreeCtrl::SendExpanded(const wxTreeItemId& item) { - SendMessage(wxEVT_COMMAND_TREE_ITEM_EXPANDED, item); -} - -void wxTreeCtrl::SendCollapsing(const wxTreeItemId& item) { - SendMessage(wxEVT_COMMAND_TREE_ITEM_COLLAPSING, item); -} - -void wxTreeCtrl::SendCollapsed(const wxTreeItemId& item) { - SendMessage(wxEVT_COMMAND_TREE_ITEM_COLLAPSED, item); -} - -void wxTreeCtrl::SendSelChanging(const wxTreeItemId& item) { - SendMessage(wxEVT_COMMAND_TREE_SEL_CHANGED, item); -} - -void wxTreeCtrl::SendSelChanged(const wxTreeItemId& item) { - SendMessage(wxEVT_COMMAND_TREE_SEL_CHANGING, item); -} - -// Tree event -IMPLEMENT_DYNAMIC_CLASS(wxTreeEvent, wxCommandEvent) - -wxTreeEvent::wxTreeEvent(wxEventType commandType, int id): - wxCommandEvent(commandType, id) { - m_code = 0; - m_itemOld = 0; -} diff --git a/src/gtk1/utilsgtk.cpp b/src/gtk1/utilsgtk.cpp deleted file mode 100644 index 1bc1106f93..0000000000 --- a/src/gtk1/utilsgtk.cpp +++ /dev/null @@ -1,183 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: src/gtk/utilsgtk.cpp -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/utils.h" -#include "wx/string.h" - -#include "wx/intl.h" -#include "wx/log.h" - -#include "wx/process.h" - -#include "wx/unix/execute.h" - -#include -#include -#include -#include -#include // for WNOHANG -#include - -#include "glib.h" -#include "gdk/gdk.h" -#include "gtk/gtk.h" -#ifndef __WXGTK20__ -#include "gtk/gtkfeatures.h" -#endif -#include "gdk/gdkx.h" - -#ifdef HAVE_X11_XKBLIB_H - /* under HP-UX and Solaris 2.6, at least, XKBlib.h defines structures with - * field named "explicit" - which is, of course, an error for a C++ - * compiler. To be on the safe side, just redefine it everywhere. */ - #define explicit __wx_explicit - - #include "X11/XKBlib.h" - - #undef explicit -#endif // HAVE_X11_XKBLIB_H - -//----------------------------------------------------------------------------- -// data -//----------------------------------------------------------------------------- - -extern GtkWidget *wxGetRootWindow(); - -//---------------------------------------------------------------------------- -// misc. -//---------------------------------------------------------------------------- - -void wxBell() -{ - gdk_beep(); -} - -/* Don't synthesize KeyUp events holding down a key and producing - KeyDown events with autorepeat. */ -#ifdef HAVE_X11_XKBLIB_H -bool wxSetDetectableAutoRepeat( bool flag ) -{ - Bool result; - XkbSetDetectableAutoRepeat( GDK_DISPLAY(), flag, &result ); - return result; /* TRUE if keyboard hardware supports this mode */ -} -#else -bool wxSetDetectableAutoRepeat( bool WXUNUSED(flag) ) -{ - return FALSE; -} -#endif - -// ---------------------------------------------------------------------------- -// display characterstics -// ---------------------------------------------------------------------------- - -void *wxGetDisplay() -{ - return GDK_DISPLAY(); -} - -void wxDisplaySize( int *width, int *height ) -{ - if (width) *width = gdk_screen_width(); - if (height) *height = gdk_screen_height(); -} - -void wxDisplaySizeMM( int *width, int *height ) -{ - if (width) *width = gdk_screen_width_mm(); - if (height) *height = gdk_screen_height_mm(); -} - -void wxClientDisplayRect(int *x, int *y, int *width, int *height) -{ - // This is supposed to return desktop dimensions minus any window - // manager panels, menus, taskbars, etc. If there is a way to do that - // for this platform please fix this function, otherwise it defaults - // to the entire desktop. - if (x) *x = 0; - if (y) *y = 0; - wxDisplaySize(width, height); -} - -void wxGetMousePosition( int* x, int* y ) -{ - gdk_window_get_pointer( (GdkWindow*) NULL, x, y, (GdkModifierType*) NULL ); -} - -bool wxColourDisplay() -{ - return TRUE; -} - -int wxDisplayDepth() -{ - return gdk_window_get_visual( wxGetRootWindow()->window )->depth; -} - -int wxGetOsVersion(int *majorVsn, int *minorVsn) -{ - if (majorVsn) *majorVsn = GTK_MAJOR_VERSION; - if (minorVsn) *minorVsn = GTK_MINOR_VERSION; - - return wxGTK; -} - -wxWindow* wxFindWindowAtPoint(const wxPoint& pt) -{ - return wxGenericFindWindowAtPoint(pt); -} - - -// ---------------------------------------------------------------------------- -// subprocess routines -// ---------------------------------------------------------------------------- - -extern "C" -void GTK_EndProcessDetector(gpointer data, gint source, - GdkInputCondition WXUNUSED(condition) ) -{ - wxEndProcessData *proc_data = (wxEndProcessData *)data; - - // has the process really terminated? unfortunately GDK (or GLib) seem to - // generate G_IO_HUP notification even when it simply tries to read from a - // closed fd and hasn't terminated at all - int pid = (proc_data->pid > 0) ? proc_data->pid : -(proc_data->pid); - int status = 0; - int rc = waitpid(pid, &status, WNOHANG); - - if ( rc == 0 ) - { - // no, it didn't exit yet, continue waiting - return; - } - - // set exit code to -1 if something bad happened - proc_data->exitcode = rc != -1 && WIFEXITED(status) ? WEXITSTATUS(status) - : -1; - - // child exited, end waiting - close(source); - - // don't call us again! - gdk_input_remove(proc_data->tag); - - wxHandleProcessTermination(proc_data); -} - -int wxAddProcessCallback(wxEndProcessData *proc_data, int fd) -{ - int tag = gdk_input_add(fd, - GDK_INPUT_READ, - GTK_EndProcessDetector, - (gpointer)proc_data); - - return tag; -} - diff --git a/src/gtk1/utilsres.cpp b/src/gtk1/utilsres.cpp deleted file mode 100644 index aa94ba7582..0000000000 --- a/src/gtk1/utilsres.cpp +++ /dev/null @@ -1,119 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: utilres.cpp -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#include "wx/utils.h" -#include "wx/string.h" -#include "wx/list.h" -#include "wx/log.h" -#include "wx/config.h" -#include "wx/app.h" - -//----------------------------------------------------------------------------- -// resource functions -//----------------------------------------------------------------------------- - -bool wxWriteResource(const wxString& section, const wxString& entry, const wxString& value, const wxString& file ) -{ - wxString filename( file ); - if (filename.IsEmpty()) filename = wxT(".wxWindows"); - - wxFileConfig conf( wxTheApp->GetAppName(), wxTheApp->GetVendorName(), filename ); - - conf.SetPath( section ); - - return conf.Write( entry, value ); -} - -bool wxWriteResource(const wxString& section, const wxString& entry, float value, const wxString& file ) -{ - wxString buf; - buf.Printf(wxT("%.4f"), value); - - return wxWriteResource(section, entry, buf, file); -} - -bool wxWriteResource(const wxString& section, const wxString& entry, long value, const wxString& file ) -{ - wxString buf; - buf.Printf(wxT("%ld"), value); - - return wxWriteResource(section, entry, buf, file); -} - -bool wxWriteResource(const wxString& section, const wxString& entry, int value, const wxString& file ) -{ - wxString buf; - buf.Printf(wxT("%d"), value); - - return wxWriteResource(section, entry, buf, file); -} - -bool wxGetResource(const wxString& section, const wxString& entry, wxChar **value, const wxString& file ) -{ - wxString filename( file ); - if (filename.IsEmpty()) filename = wxT(".wxWindows"); - - wxFileConfig conf( wxTheApp->GetAppName(), wxTheApp->GetVendorName(), filename ); - - conf.SetPath( section ); - - wxString result; - if (conf.Read( entry, &result )) - { - if (!result.IsEmpty()) - { - wxChar *s = new wxChar[result.Len()+1]; - wxStrcpy( s, result.c_str() ); - *value = s; - return TRUE; - } - } - - return FALSE; -} - -bool wxGetResource(const wxString& section, const wxString& entry, float *value, const wxString& file ) -{ - wxChar *s = NULL; - bool succ = wxGetResource(section, entry, (wxChar **)&s, file); - if (succ) - { - *value = (float)wxStrtod(s, NULL); - delete[] s; - return TRUE; - } - else return FALSE; -} - -bool wxGetResource(const wxString& section, const wxString& entry, long *value, const wxString& file ) -{ - wxChar *s = NULL; - bool succ = wxGetResource(section, entry, (wxChar **)&s, file); - if (succ) - { - *value = wxStrtol(s, NULL, 10); - delete[] s; - return TRUE; - } - else return FALSE; -} - -bool wxGetResource(const wxString& section, const wxString& entry, int *value, const wxString& file ) -{ - wxChar *s = NULL; - bool succ = wxGetResource(section, entry, (wxChar **)&s, file); - if (succ) - { - *value = (int)wxStrtol(s, NULL, 10); - delete[] s; - return TRUE; - } - else return FALSE; -} - diff --git a/src/gtk1/verti.xbm b/src/gtk1/verti.xbm deleted file mode 100644 index 2dd9dc4c05..0000000000 --- a/src/gtk1/verti.xbm +++ /dev/null @@ -1,6 +0,0 @@ -#define verti_width 15 -#define verti_height 15 -static char verti_bits[] = { - 0x84, 0x10, 0x84, 0x10, 0x84, 0x10, 0x84, 0x10, 0x84, 0x10, 0x84, 0x10, - 0x84, 0x10, 0x84, 0x10, 0x84, 0x10, 0x84, 0x10, 0x84, 0x10, 0x84, 0x10, - 0x84, 0x10, 0x84, 0x10, 0x84, 0x10}; diff --git a/src/gtk1/wave.cpp b/src/gtk1/wave.cpp deleted file mode 100644 index c0ff26f3d1..0000000000 --- a/src/gtk1/wave.cpp +++ /dev/null @@ -1,224 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: wave.cpp -// Purpose: wxWave -// Author: Marcel Rasche -// Modified by: -// Created: 25/10/98 -// RCS-ID: $Id$ -// Copyright: (c) Julian Smart -// Licence: wxWindows license -///////////////////////////////////////////////////////////////////////////// - -#include "wx/setup.h" - -#if wxUSE_WAVE - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#if defined(__BORLANDC__) -#pragma hdrstop -#endif - -#include -#include -#include -#include -#include - -#ifndef WX_PRECOMP -#include "wx/wx.h" -#endif - -#include "wx/file.h" -#include "wx/wave.h" - -//----------------------------------------------------------------- -// wxWave -//----------------------------------------------------------------- - -wxWave::wxWave() - : m_waveData(NULL), m_waveLength(0), m_isResource(FALSE) -{ -} - -wxWave::wxWave(const wxString& sFileName, bool isResource) - : m_waveData(NULL), m_waveLength(0), m_isResource(isResource) -{ - Create(sFileName, isResource); -} - -wxWave::wxWave(int size, const wxByte* data) - : m_waveData(NULL), m_waveLength(0), m_isResource(FALSE) -{ - Create(size, data); -} - -wxWave::~wxWave() -{ - Free(); -} - -bool wxWave::Create(const wxString& fileName, bool isResource) -{ - Free(); - - if (isResource) - { - // todo - return (m_waveData ? TRUE : FALSE); - } - else - { - m_isResource = FALSE; - - wxFile fileWave; - if (!fileWave.Open(fileName, wxFile::read)) - { - return FALSE; - } - - m_waveLength = (int) fileWave.Length(); - - m_waveData = new wxByte[m_waveLength]; - if (!m_waveData) - { - return FALSE; - } - - fileWave.Read(m_waveData, m_waveLength); - - return TRUE; - } -} - -bool wxWave::Create(int size, const wxByte* data) -{ - Free(); - m_isResource = FALSE; - m_waveLength=size; - m_waveData = new wxByte[size]; - if (!m_waveData) - { - return FALSE; - } - - for (int i=0; i 65536) - return FALSE; - if ( ioctl(dev,SNDCTL_DSP_SAMPLESIZE,&iDataBits) < 0 ) - return FALSE; - if ( ioctl(dev,SNDCTL_DSP_STEREO,&iChannel) < 0 ) - return FALSE; - if ( ioctl(dev,SNDCTL_DSP_SPEED,&ulSamplingRate) < 0 ) - return FALSE; - - return TRUE; -} -#endif - diff --git a/src/gtk1/win_gtk.c b/src/gtk1/win_gtk.c deleted file mode 100644 index fecb23b7f5..0000000000 --- a/src/gtk1/win_gtk.c +++ /dev/null @@ -1,1270 +0,0 @@ -/* /////////////////////////////////////////////////////////////////////////// -// Name: win_gtk.c -// Purpose: Native GTK+ widget for wxWindows, based on GtkLayout and -// GtkFixed. It makes use of the gravity window property and -// therefore does not work with GTK 1.0. -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling -// Licence: wxWindows licence -/////////////////////////////////////////////////////////////////////////// */ - -#ifdef VMS -#define XCheckIfEvent XCHECKIFEVENT -#endif - -#include "wx/setup.h" -#include "wx/gtk/win_gtk.h" -#include "gtk/gtksignal.h" -#include "gtk/gtkprivate.h" -#include "gdk/gdkx.h" - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -#ifndef __WXGTK20__ - -#include -#include -#include - -#define IS_ONSCREEN(x,y) ((x >= G_MINSHORT) && (x <= G_MAXSHORT) && \ - (y >= G_MINSHORT) && (y <= G_MAXSHORT)) - -#endif - -typedef struct _GtkPizzaAdjData GtkPizzaAdjData; - -struct _GtkPizzaAdjData -{ - gint dx; - gint dy; -}; - -static void gtk_pizza_class_init (GtkPizzaClass *klass); -static void gtk_pizza_init (GtkPizza *pizza); - -static void gtk_pizza_realize (GtkWidget *widget); -static void gtk_pizza_unrealize (GtkWidget *widget); - -static void gtk_pizza_map (GtkWidget *widget); - -static void gtk_pizza_size_request (GtkWidget *widget, - GtkRequisition *requisition); -static void gtk_pizza_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); -#ifndef __WXGTK20__ -static void gtk_pizza_draw (GtkWidget *widget, - GdkRectangle *area); -#endif /* __WXGTK20__ */ -static gint gtk_pizza_expose (GtkWidget *widget, - GdkEventExpose *event); -static void gtk_pizza_add (GtkContainer *container, - GtkWidget *widget); -static void gtk_pizza_remove (GtkContainer *container, - GtkWidget *widget); -static void gtk_pizza_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data); - -static void gtk_pizza_allocate_child (GtkPizza *pizza, - GtkPizzaChild *child); -static void gtk_pizza_adjust_allocations_recurse (GtkWidget *widget, - gpointer cb_data); - -#ifndef __WXGTK20__ -static void gtk_pizza_position_child (GtkPizza *pizza, - GtkPizzaChild *child); -static void gtk_pizza_position_children (GtkPizza *pizza); - -static GdkFilterReturn gtk_pizza_filter (GdkXEvent *gdk_xevent, - GdkEvent *event, - gpointer data); -static GdkFilterReturn gtk_pizza_main_filter (GdkXEvent *gdk_xevent, - GdkEvent *event, - gpointer data); -#endif /* __WXGTK20__ */ - -static GtkType gtk_pizza_child_type (GtkContainer *container); - -static void gtk_pizza_scroll_set_adjustments (GtkPizza *pizza, - GtkAdjustment *hadj, - GtkAdjustment *vadj); - - -#ifdef __WXGTK20__ - GtkContainerClass *pizza_parent_class = NULL; -#else -static GtkContainerClass *pizza_parent_class = NULL; -#endif - -static gboolean gravity_works; - -guint -gtk_pizza_get_type () -{ - static guint pizza_type = 0; - - if (!pizza_type) - { - -#ifdef __WXGTK20__ - static const GTypeInfo pizza_info = - { - sizeof (GtkPizzaClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) gtk_pizza_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (GtkPizza), - 16, /* n_preallocs */ - (GInstanceInitFunc) gtk_pizza_init, - }; - pizza_type = g_type_register_static (GTK_TYPE_CONTAINER, "GtkPizza", &pizza_info, 0); -#else - GtkTypeInfo pizza_info = - { - "GtkPizza", - sizeof (GtkPizza), - sizeof (GtkPizzaClass), - (GtkClassInitFunc) gtk_pizza_class_init, - (GtkObjectInitFunc) gtk_pizza_init, - /* reserved_1 */ NULL, - /* reserved_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - pizza_type = gtk_type_unique (gtk_container_get_type (), &pizza_info); -#endif - } - - return pizza_type; -} - -static void -gtk_pizza_class_init (GtkPizzaClass *klass) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - GtkContainerClass *container_class; - - object_class = (GtkObjectClass*) klass; - widget_class = (GtkWidgetClass*) klass; - container_class = (GtkContainerClass*) klass; - pizza_parent_class = gtk_type_class (GTK_TYPE_CONTAINER); - - widget_class->map = gtk_pizza_map; - widget_class->realize = gtk_pizza_realize; - widget_class->unrealize = gtk_pizza_unrealize; - widget_class->size_request = gtk_pizza_size_request; - widget_class->size_allocate = gtk_pizza_size_allocate; -#ifndef __WXGTK20__ - widget_class->draw = gtk_pizza_draw; -#endif - widget_class->expose_event = gtk_pizza_expose; - - container_class->add = gtk_pizza_add; - container_class->remove = gtk_pizza_remove; - container_class->forall = gtk_pizza_forall; - - container_class->child_type = gtk_pizza_child_type; - - klass->set_scroll_adjustments = gtk_pizza_scroll_set_adjustments; - - widget_class->set_scroll_adjustments_signal = - gtk_signal_new ("set_scroll_adjustments", - GTK_RUN_LAST, -#ifdef __WXGTK20__ - GTK_CLASS_TYPE(object_class), -#else - object_class->type, -#endif - GTK_SIGNAL_OFFSET (GtkPizzaClass, set_scroll_adjustments), - gtk_marshal_NONE__POINTER_POINTER, - GTK_TYPE_NONE, 2, GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT); -} - -static GtkType -gtk_pizza_child_type (GtkContainer *container) -{ - return GTK_TYPE_WIDGET; -} - -static void -gtk_pizza_init (GtkPizza *pizza) -{ - GTK_WIDGET_UNSET_FLAGS (pizza, GTK_NO_WINDOW); - - pizza->shadow_type = GTK_MYSHADOW_NONE; - - pizza->children = NULL; - - pizza->width = 20; - pizza->height = 20; - - pizza->bin_window = NULL; - - pizza->xoffset = 0; - pizza->yoffset = 0; - - pizza->configure_serial = 0; - pizza->scroll_x = 0; - pizza->scroll_y = 0; - pizza->visibility = GDK_VISIBILITY_PARTIAL; - - pizza->clear_on_draw = TRUE; - pizza->use_filter = TRUE; - pizza->external_expose = FALSE; -} - -GtkWidget* -gtk_pizza_new () -{ - GtkPizza *pizza; - - pizza = gtk_type_new (gtk_pizza_get_type ()); - - return GTK_WIDGET (pizza); -} - -static void -gtk_pizza_scroll_set_adjustments (GtkPizza *pizza, - GtkAdjustment *hadj, - GtkAdjustment *vadj) -{ - /* We handle scrolling in the wxScrolledWindow, not here. */ -} - -void -gtk_pizza_set_shadow_type (GtkPizza *pizza, - GtkMyShadowType type) -{ - g_return_if_fail (pizza != NULL); - g_return_if_fail (GTK_IS_PIZZA (pizza)); - - if ((GtkMyShadowType) pizza->shadow_type != type) - { - pizza->shadow_type = type; - - if (GTK_WIDGET_VISIBLE (pizza)) - { - gtk_widget_size_allocate (GTK_WIDGET (pizza), &(GTK_WIDGET (pizza)->allocation)); - gtk_widget_queue_draw (GTK_WIDGET (pizza)); - } - } -} - -void -gtk_pizza_set_clear (GtkPizza *pizza, - gboolean clear) -{ - g_return_if_fail (pizza != NULL); - g_return_if_fail (GTK_IS_PIZZA (pizza)); - - pizza->clear_on_draw = clear; -} - -void -gtk_pizza_set_filter (GtkPizza *pizza, - gboolean use) -{ - g_return_if_fail (pizza != NULL); - g_return_if_fail (GTK_IS_PIZZA (pizza)); - - pizza->use_filter = use; -} - -void -gtk_pizza_set_external (GtkPizza *pizza, - gboolean expose) -{ - g_return_if_fail (pizza != NULL); - g_return_if_fail (GTK_IS_PIZZA (pizza)); - - pizza->external_expose = expose; -} - -void -gtk_pizza_put (GtkPizza *pizza, - GtkWidget *widget, - gint x, - gint y, - gint width, - gint height) -{ - GtkPizzaChild *child_info; - - g_return_if_fail (pizza != NULL); - g_return_if_fail (GTK_IS_PIZZA (pizza)); - g_return_if_fail (widget != NULL); - - child_info = g_new (GtkPizzaChild, 1); - - child_info->widget = widget; - child_info->x = x; - child_info->y = y; - child_info->width = width; - child_info->height = height; - - pizza->children = g_list_append (pizza->children, child_info); - - if (GTK_WIDGET_REALIZED (pizza)) - gtk_widget_set_parent_window (widget, pizza->bin_window); - - gtk_widget_set_parent (widget, GTK_WIDGET (pizza)); - -#ifndef __WXGTK20__ /* FIXME? */ - if (!IS_ONSCREEN (x, y)) - GTK_PRIVATE_SET_FLAG (widget, GTK_IS_OFFSCREEN); -#endif - - gtk_widget_set_usize (widget, width, height); -} - -void -gtk_pizza_move (GtkPizza *pizza, - GtkWidget *widget, - gint x, - gint y) -{ - GtkPizzaChild *child; - GList *children; - - g_return_if_fail (pizza != NULL); - g_return_if_fail (GTK_IS_PIZZA (pizza)); - g_return_if_fail (widget != NULL); - - children = pizza->children; - while (children) - { - child = children->data; - children = children->next; - - if (child->widget == widget) - { - if ((child->x == x) && (child->y == y)) - break; - - child->x = x; - child->y = y; - - if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_VISIBLE (pizza)) - gtk_widget_queue_resize (widget); - break; - } - } -} - -void -gtk_pizza_resize (GtkPizza *pizza, - GtkWidget *widget, - gint width, - gint height) -{ - GtkPizzaChild *child; - GList *children; - - g_return_if_fail (pizza != NULL); - g_return_if_fail (GTK_IS_PIZZA (pizza)); - g_return_if_fail (widget != NULL); - - children = pizza->children; - while (children) - { - child = children->data; - children = children->next; - - if (child->widget == widget) - { - if ((child->width == width) && (child->height == height)) - break; - - child->width = width; - child->height = height; - - gtk_widget_set_usize (widget, width, height); - - if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_VISIBLE (pizza)) - gtk_widget_queue_resize (widget); - break; - } - } -} - -void -gtk_pizza_set_size (GtkPizza *pizza, - GtkWidget *widget, - gint x, - gint y, - gint width, - gint height) -{ - GtkPizzaChild *child; - GList *children; - - g_return_if_fail (pizza != NULL); - g_return_if_fail (GTK_IS_PIZZA (pizza)); - g_return_if_fail (widget != NULL); - - children = pizza->children; - while (children) - { - child = children->data; - children = children->next; - - if (child->widget == widget) - { - if ((child->x == x) && - (child->y == y) && - (child->width == width) && - (child->height == height)) return; - - child->x = x; - child->y = y; - child->width = width; - child->height = height; - - gtk_widget_set_usize (widget, width, height); - - if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_VISIBLE (pizza)) - gtk_widget_queue_resize (widget); - - return; - } - } -} - -gint -gtk_pizza_child_resized (GtkPizza *pizza, - GtkWidget *widget) -{ - GtkPizzaChild *child; - GList *children; - - g_return_val_if_fail (pizza != NULL, FALSE); - g_return_val_if_fail (GTK_IS_PIZZA (pizza), FALSE); - g_return_val_if_fail (widget != NULL, FALSE); - - children = pizza->children; - while (children) - { - child = children->data; - children = children->next; - - if (child->widget == widget) - { - return ((child->width == widget->allocation.width) && - (child->height == widget->allocation.height)); - } - } - - return FALSE; -} - -static void -gtk_pizza_map (GtkWidget *widget) -{ - GtkPizza *pizza; - GtkPizzaChild *child; - GList *children; - - g_return_if_fail (widget != NULL); - g_return_if_fail (GTK_IS_PIZZA (widget)); - - GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED); - pizza = GTK_PIZZA (widget); - - children = pizza->children; - while (children) - { - child = children->data; - children = children->next; - - if ( GTK_WIDGET_VISIBLE (child->widget) && - !GTK_WIDGET_MAPPED (child->widget) && -#ifdef __WXGTK20__ - TRUE) -#else - !GTK_WIDGET_IS_OFFSCREEN (child->widget)) -#endif - { - gtk_widget_map (child->widget); - } - } - - gdk_window_show (widget->window); - gdk_window_show (pizza->bin_window); -} - -static void -gtk_pizza_realize (GtkWidget *widget) -{ - GtkPizza *pizza; - GdkWindowAttr attributes; - gint attributes_mask; - GtkPizzaChild *child; - GList *children; - - g_return_if_fail (widget != NULL); - g_return_if_fail (GTK_IS_PIZZA (widget)); - - pizza = GTK_PIZZA (widget); - GTK_WIDGET_SET_FLAGS (widget, GTK_REALIZED); - - attributes.window_type = GDK_WINDOW_CHILD; - - attributes.x = widget->allocation.x; - attributes.y = widget->allocation.y; - attributes.width = widget->allocation.width; - attributes.height = widget->allocation.height; - -#ifndef __WXUNIVERSAL__ - if (pizza->shadow_type == GTK_MYSHADOW_NONE) - { - /* no border, no changes to sizes */ - } - else if (pizza->shadow_type == GTK_MYSHADOW_THIN) - { - /* GTK_MYSHADOW_THIN == wxSIMPLE_BORDER */ - attributes.x += 1; - attributes.y += 1; - attributes.width -= 2; - attributes.height -= 2; - } - else - { - /* GTK_MYSHADOW_IN == wxSUNKEN_BORDER */ - /* GTK_MYSHADOW_OUT == wxRAISED_BORDER */ - attributes.x += 2; - attributes.y += 2; - attributes.width -= 4; - attributes.height -= 4; - } -#endif /* __WXUNIVERSAL__ */ - - /* minimal size */ - if (attributes.width < 2) attributes.width = 2; - if (attributes.height < 2) attributes.height = 2; - - attributes.wclass = GDK_INPUT_OUTPUT; - attributes.visual = gtk_widget_get_visual (widget); - attributes.colormap = gtk_widget_get_colormap (widget); - attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK; - attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; - - widget->window = gdk_window_new(gtk_widget_get_parent_window (widget), - &attributes, attributes_mask); - gdk_window_set_user_data (widget->window, widget); - - attributes.x = 0; - attributes.y = 0; - - attributes.event_mask = gtk_widget_get_events (widget); - attributes.event_mask |= GDK_EXPOSURE_MASK | -#ifdef __WXGTK20__ - GDK_SCROLL_MASK | -#endif - GDK_POINTER_MOTION_MASK | - GDK_POINTER_MOTION_HINT_MASK | - GDK_BUTTON_MOTION_MASK | - GDK_BUTTON1_MOTION_MASK | - GDK_BUTTON2_MOTION_MASK | - GDK_BUTTON3_MOTION_MASK | - GDK_BUTTON_PRESS_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_KEY_PRESS_MASK | - GDK_KEY_RELEASE_MASK | - GDK_ENTER_NOTIFY_MASK | - GDK_LEAVE_NOTIFY_MASK | - GDK_FOCUS_CHANGE_MASK; - - pizza->bin_window = gdk_window_new(widget->window, - &attributes, attributes_mask); - gdk_window_set_user_data (pizza->bin_window, widget); - - widget->style = gtk_style_attach (widget->style, widget->window); - gtk_style_set_background (widget->style, widget->window, GTK_STATE_NORMAL); - gtk_style_set_background (widget->style, pizza->bin_window, GTK_STATE_NORMAL ); - -/* - gdk_window_set_back_pixmap( widget->window, NULL, FALSE ); - gdk_window_set_back_pixmap( pizza->bin_window, NULL, FALSE ); -*/ - -#ifndef __WXGTK20__ - /* add filters for intercepting visibility and expose events */ - gdk_window_add_filter (widget->window, gtk_pizza_main_filter, pizza); - gdk_window_add_filter (pizza->bin_window, gtk_pizza_filter, pizza); -#endif - - /* we NEED gravity or we'll give up */ - gravity_works = gdk_window_set_static_gravities (pizza->bin_window, TRUE); - - /* cannot be done before realisation */ - children = pizza->children; - while (children) - { - child = children->data; - children = children->next; - - gtk_widget_set_parent_window (child->widget, pizza->bin_window); - } -} - -static void -gtk_pizza_unrealize (GtkWidget *widget) -{ - GtkPizza *pizza; - - g_return_if_fail (widget != NULL); - g_return_if_fail (GTK_IS_PIZZA (widget)); - - pizza = GTK_PIZZA (widget); - - gdk_window_set_user_data (pizza->bin_window, NULL); - gdk_window_destroy (pizza->bin_window); - pizza->bin_window = NULL; - - if (GTK_WIDGET_CLASS (pizza_parent_class)->unrealize) - (* GTK_WIDGET_CLASS (pizza_parent_class)->unrealize) (widget); -} - -static void -gtk_pizza_size_request (GtkWidget *widget, - GtkRequisition *requisition) -{ - GtkPizza *pizza; - GtkPizzaChild *child; - GList *children; - GtkRequisition child_requisition; - - g_return_if_fail (widget != NULL); - g_return_if_fail (GTK_IS_PIZZA (widget)); - g_return_if_fail (requisition != NULL); - - pizza = GTK_PIZZA (widget); - - children = pizza->children; - while (children) - { - child = children->data; - children = children->next; - - if (GTK_WIDGET_VISIBLE (child->widget)) - { - gtk_widget_size_request (child->widget, &child_requisition); - } - } - - /* request very little, I'm not sure if requesting nothing - will always have positive effects on stability... */ - requisition->width = 2; - requisition->height = 2; -} - -static void -gtk_pizza_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - GtkPizza *pizza; - gint border; - gint x,y,w,h; - GtkPizzaChild *child; - GList *children; - - g_return_if_fail (widget != NULL); - g_return_if_fail (GTK_IS_PIZZA(widget)); - g_return_if_fail (allocation != NULL); - - pizza = GTK_PIZZA (widget); - - widget->allocation = *allocation; - - if (pizza->shadow_type == GTK_MYSHADOW_NONE) - border = 0; - else - if (pizza->shadow_type == GTK_MYSHADOW_THIN) - border = 1; - else - border = 2; - - x = allocation->x + border; - y = allocation->y + border; - w = allocation->width - border*2; - h = allocation->height - border*2; - - if (GTK_WIDGET_REALIZED (widget)) - { - gdk_window_move_resize( widget->window, x, y, w, h ); - gdk_window_move_resize( pizza->bin_window, 0, 0, w, h ); - } - - children = pizza->children; - while (children) - { - child = children->data; - children = children->next; - -#ifndef __WXGTK20__ - gtk_pizza_position_child (pizza, child); -#endif - gtk_pizza_allocate_child (pizza, child); - } -} - -#ifndef __WXGTK20__ - -static void -gtk_pizza_draw (GtkWidget *widget, - GdkRectangle *area) -{ - GtkPizza *pizza; - GtkPizzaChild *child; - GdkRectangle child_area; - GList *children; - - g_return_if_fail (widget != NULL); - g_return_if_fail (GTK_IS_PIZZA (widget)); - - pizza = GTK_PIZZA (widget); - - /* Sometimes, We handle all expose events in window.cpp now. */ - if (pizza->external_expose) - return; - - children = pizza->children; - if ( !(GTK_WIDGET_APP_PAINTABLE (widget)) && - (pizza->clear_on_draw)) - { - gdk_window_clear_area( pizza->bin_window, - area->x, area->y, area->width, area->height); - } - - while (children) - { - child = children->data; - children = children->next; - - if (gtk_widget_intersect (child->widget, area, &child_area)) - gtk_widget_draw (child->widget, &child_area); - } -} - -#endif /* __WXGTK20__ */ - -static gint -gtk_pizza_expose (GtkWidget *widget, - GdkEventExpose *event) -{ - GtkPizza *pizza; -#ifndef __WXGTK20__ - GtkPizzaChild *child; - GdkEventExpose child_event; - GList *children; -#endif - - g_return_val_if_fail (widget != NULL, FALSE); - g_return_val_if_fail (GTK_IS_PIZZA (widget), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - pizza = GTK_PIZZA (widget); - - if (event->window != pizza->bin_window) - return FALSE; - - /* We handle all expose events in window.cpp now. */ - if (pizza->external_expose) - return FALSE; - -#ifdef __WXGTK20__ - - (* GTK_WIDGET_CLASS (pizza_parent_class)->expose_event) (widget, event); - - return FALSE; - -#else - - children = pizza->children; - while (children) - { - child = children->data; - children = children->next; - - child_event = *event; - - if (GTK_WIDGET_NO_WINDOW (child->widget) && - GTK_WIDGET_DRAWABLE (child->widget) && - gtk_widget_intersect (child->widget, &event->area, &child_event.area)) - { - gtk_widget_event (child->widget, (GdkEvent*) &child_event); - } - } - - return TRUE; - -#endif -} - -static void -gtk_pizza_add (GtkContainer *container, - GtkWidget *widget) -{ - g_return_if_fail (container != NULL); - g_return_if_fail (GTK_IS_PIZZA (container)); - g_return_if_fail (widget != NULL); - - gtk_pizza_put (GTK_PIZZA (container), widget, 0, 0, 20, 20 ); -} - -static void -gtk_pizza_remove (GtkContainer *container, - GtkWidget *widget) -{ - GtkPizza *pizza; - GtkPizzaChild *child; - GList *children; - - g_return_if_fail (container != NULL); - g_return_if_fail (GTK_IS_PIZZA (container)); - g_return_if_fail (widget != NULL); - - pizza = GTK_PIZZA (container); - - children = pizza->children; - while (children) - { - child = children->data; - - if (child->widget == widget) - { - gtk_widget_unparent (widget); - - /* security checks */ - g_return_if_fail (GTK_IS_WIDGET (widget)); - - pizza->children = g_list_remove_link (pizza->children, children); - g_list_free (children); - g_free (child); - - /* security checks */ - g_return_if_fail (GTK_IS_WIDGET (widget)); - -#ifndef __WXGTK20__ - GTK_PRIVATE_UNSET_FLAG (widget, GTK_IS_OFFSCREEN); -#endif - - break; - } - - children = children->next; - } -} - -static void -gtk_pizza_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data) -{ - GtkPizza *pizza; - GtkPizzaChild *child; - GList *children; - - g_return_if_fail (container != NULL); - g_return_if_fail (GTK_IS_PIZZA (container)); - g_return_if_fail (callback != (GtkCallback)NULL); - - pizza = GTK_PIZZA (container); - - children = pizza->children; - while (children) - { - child = children->data; - children = children->next; - - (* callback) (child->widget, callback_data); - } -} - -static void -gtk_pizza_allocate_child (GtkPizza *pizza, - GtkPizzaChild *child) -{ - GtkAllocation allocation; - GtkRequisition requisition; - - allocation.x = child->x - pizza->xoffset; - allocation.y = child->y - pizza->yoffset; - gtk_widget_get_child_requisition (child->widget, &requisition); - allocation.width = requisition.width; - allocation.height = requisition.height; - - gtk_widget_size_allocate (child->widget, &allocation); -} - -static void -gtk_pizza_adjust_allocations_recurse (GtkWidget *widget, - gpointer cb_data) -{ - GtkPizzaAdjData *data = cb_data; - - widget->allocation.x += data->dx; - widget->allocation.y += data->dy; - - if (GTK_WIDGET_NO_WINDOW (widget) && GTK_IS_CONTAINER (widget)) - { - gtk_container_forall (GTK_CONTAINER (widget), - gtk_pizza_adjust_allocations_recurse, - cb_data); - } -} - -static void -gtk_pizza_adjust_allocations (GtkPizza *pizza, - gint dx, - gint dy) -{ - GList *tmp_list; - GtkPizzaAdjData data; - - data.dx = dx; - data.dy = dy; - - tmp_list = pizza->children; - while (tmp_list) - { - GtkPizzaChild *child = tmp_list->data; - tmp_list = tmp_list->next; - - child->widget->allocation.x += dx; - child->widget->allocation.y += dy; - - if (GTK_WIDGET_NO_WINDOW (child->widget) && - GTK_IS_CONTAINER (child->widget)) - { - gtk_container_forall (GTK_CONTAINER (child->widget), - gtk_pizza_adjust_allocations_recurse, - &data); - } - } -} - -#ifndef __WXGTK20__ -static void -gtk_pizza_position_child (GtkPizza *pizza, - GtkPizzaChild *child) -{ - gint x; - gint y; - - x = child->x - pizza->xoffset; - y = child->y - pizza->yoffset; - - if (IS_ONSCREEN (x,y)) - { - if (GTK_WIDGET_MAPPED (pizza) && - GTK_WIDGET_VISIBLE (child->widget)) - { - if (!GTK_WIDGET_MAPPED (child->widget)) - gtk_widget_map (child->widget); - } - - if (GTK_WIDGET_IS_OFFSCREEN (child->widget)) - GTK_PRIVATE_UNSET_FLAG (child->widget, GTK_IS_OFFSCREEN); - } - else - { - if (!GTK_WIDGET_IS_OFFSCREEN (child->widget)) - GTK_PRIVATE_SET_FLAG (child->widget, GTK_IS_OFFSCREEN); - - if (GTK_WIDGET_MAPPED (child->widget)) - gtk_widget_unmap (child->widget); - } -} - -static void -gtk_pizza_position_children (GtkPizza *pizza) -{ - GList *tmp_list; - - tmp_list = pizza->children; - while (tmp_list) - { - GtkPizzaChild *child = tmp_list->data; - tmp_list = tmp_list->next; - - gtk_pizza_position_child (pizza, child); - } -} - -/* This function is used to find events to process while scrolling */ -static Bool -gtk_pizza_expose_predicate (Display *display, - XEvent *xevent, - XPointer arg) -{ - if ((xevent->type == Expose) || - ((xevent->xany.window == *(Window *)arg) && - (xevent->type == ConfigureNotify))) - return True; - else - return False; -} -#endif /* __WXGTK20__ */ - -/* This is the main routine to do the scrolling. Scrolling is - * done by "Guffaw" scrolling, as in the Mozilla XFE, with - * a few modifications. - * - * The main improvement is that we keep track of whether we - * are obscured or not. If not, we ignore the generated expose - * events and instead do the exposes ourself, without having - * to wait for a roundtrip to the server. This also provides - * a limited form of expose-event compression, since we do - * the affected area as one big chunk. - */ - -void -gtk_pizza_scroll (GtkPizza *pizza, gint dx, gint dy) -{ -#ifdef __WXGTK20__ - pizza->xoffset += dx; - pizza->yoffset += dy; - - gtk_pizza_adjust_allocations (pizza, -dx, -dy); - - if (pizza->bin_window) - gdk_window_scroll( pizza->bin_window, -dx, -dy ); -#else - GtkWidget *widget; - XEvent xevent; - XID win; - - gint x,y,w,h,border; - - widget = GTK_WIDGET (pizza); - - pizza->xoffset += dx; - pizza->yoffset += dy; - - if (!GTK_WIDGET_MAPPED (pizza)) - { - gtk_pizza_position_children (pizza); - return; - } - - gtk_pizza_adjust_allocations (pizza, -dx, -dy); - - if (pizza->shadow_type == GTK_MYSHADOW_NONE) - border = 0; - else - if (pizza->shadow_type == GTK_MYSHADOW_THIN) - border = 1; - else - border = 2; - - x = 0; - y = 0; - w = widget->allocation.width - 2*border; - h = widget->allocation.height - 2*border; - - if (dx > 0) - { - if (gravity_works) - { - gdk_window_resize (pizza->bin_window, - w + dx, - h); - gdk_window_move (pizza->bin_window, x-dx, y); - gdk_window_move_resize (pizza->bin_window, x, y, w, h ); - } - else - { - /* FIXME */ - } - } - else if (dx < 0) - { - if (gravity_works) - { - gdk_window_move_resize (pizza->bin_window, - x + dx, - y, - w - dx, - h); - gdk_window_move (pizza->bin_window, x, y); - gdk_window_resize (pizza->bin_window, w, h ); - } - else - { - /* FIXME */ - } - } - - if (dy > 0) - { - if (gravity_works) - { - gdk_window_resize (pizza->bin_window, w, h + dy); - gdk_window_move (pizza->bin_window, x, y-dy); - gdk_window_move_resize (pizza->bin_window, - x, y, w, h ); - } - else - { - /* FIXME */ - } - } - else if (dy < 0) - { - if (gravity_works) - { - gdk_window_move_resize (pizza->bin_window, - x, y+dy, w, h - dy ); - gdk_window_move (pizza->bin_window, x, y); - gdk_window_resize (pizza->bin_window, w, h ); - } - else - { - /* FIXME */ - } - } - - gtk_pizza_position_children (pizza); - - gdk_flush(); - - win = GDK_WINDOW_XWINDOW (pizza->bin_window); - while (XCheckIfEvent(GDK_WINDOW_XDISPLAY (pizza->bin_window), - &xevent, - gtk_pizza_expose_predicate, - (XPointer)&win)) - { - GdkEvent event; - GtkWidget *event_widget; - - if ((xevent.xany.window == GDK_WINDOW_XWINDOW (pizza->bin_window)) ) - gtk_pizza_filter (&xevent, &event, pizza); - - if (xevent.type == Expose) - { - event.expose.window = gdk_window_lookup (xevent.xany.window); - gdk_window_get_user_data (event.expose.window, - (gpointer *)&event_widget); - - if (event_widget) - { - event.expose.type = GDK_EXPOSE; - event.expose.area.x = xevent.xexpose.x; - event.expose.area.y = xevent.xexpose.y; - event.expose.area.width = xevent.xexpose.width; - event.expose.area.height = xevent.xexpose.height; - event.expose.count = xevent.xexpose.count; - - gdk_window_ref (event.expose.window); - gtk_widget_event (event_widget, &event); - gdk_window_unref (event.expose.window); - } - } - } -#endif /* __WXGTK20__ */ -} - - -#ifndef __WXGTK20__ -/* The main event filter. Actually, we probably don't really need - * to install this as a filter at all, since we are calling it - * directly above in the expose-handling hack. But in case scrollbars - * are fixed up in some manner... - * - * This routine identifies expose events that are generated when - * we've temporarily moved the bin_window_origin, and translates - * them or discards them, depending on whether we are obscured - * or not. - */ -static GdkFilterReturn -gtk_pizza_filter (GdkXEvent *gdk_xevent, - GdkEvent *event, - gpointer data) -{ - XEvent *xevent; - GtkPizza *pizza; - - xevent = (XEvent *)gdk_xevent; - - pizza = GTK_PIZZA (data); - - if (!pizza->use_filter) - return GDK_FILTER_CONTINUE; - - switch (xevent->type) - { - case Expose: - if (xevent->xexpose.serial == pizza->configure_serial) - { - xevent->xexpose.x += pizza->scroll_x; - xevent->xexpose.y += pizza->scroll_y; - } - break; - - case ConfigureNotify: - { - pizza->configure_serial = xevent->xconfigure.serial; - pizza->scroll_x = xevent->xconfigure.x; - pizza->scroll_y = xevent->xconfigure.y; - } - break; - } - - return GDK_FILTER_CONTINUE; -} - -/* Although GDK does have a GDK_VISIBILITY_NOTIFY event, - * there is no corresponding event in GTK, so we have - * to get the events from a filter - */ -static GdkFilterReturn -gtk_pizza_main_filter (GdkXEvent *gdk_xevent, - GdkEvent *event, - gpointer data) -{ - XEvent *xevent; - GtkPizza *pizza; - - xevent = (XEvent *)gdk_xevent; - pizza = GTK_PIZZA (data); - - if (!pizza->use_filter) - return GDK_FILTER_CONTINUE; - - if (xevent->type == VisibilityNotify) - { - switch (xevent->xvisibility.state) - { - case VisibilityFullyObscured: - pizza->visibility = GDK_VISIBILITY_FULLY_OBSCURED; - break; - - case VisibilityPartiallyObscured: - pizza->visibility = GDK_VISIBILITY_PARTIAL; - break; - - case VisibilityUnobscured: - pizza->visibility = GDK_VISIBILITY_UNOBSCURED; - break; - } - - return GDK_FILTER_REMOVE; - } - - return GDK_FILTER_CONTINUE; -} -#endif /* __WXGTK20__ */ - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp deleted file mode 100644 index cf20d2ff40..0000000000 --- a/src/gtk1/window.cpp +++ /dev/null @@ -1,4625 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: gtk/window.cpp -// Purpose: -// Author: Robert Roebling -// Id: $Id$ -// Copyright: (c) 1998 Robert Roebling, Julian Smart -// Licence: wxWindows licence -///////////////////////////////////////////////////////////////////////////// - -#ifdef __VMS -#define XWarpPointer XWARPPOINTER -#endif - -#include "wx/defs.h" -#include "wx/window.h" -#include "wx/dcclient.h" -#include "wx/frame.h" -#include "wx/app.h" -#include "wx/layout.h" -#include "wx/utils.h" -#include "wx/dialog.h" -#include "wx/msgdlg.h" -#include "wx/module.h" - -#if wxUSE_DRAG_AND_DROP - #include "wx/dnd.h" -#endif - -#if wxUSE_TOOLTIPS - #include "wx/tooltip.h" -#endif - -#if wxUSE_CARET - #include "wx/caret.h" -#endif // wxUSE_CARET - -#if wxUSE_TEXTCTRL - #include "wx/textctrl.h" -#endif - -#include "wx/menu.h" -#include "wx/statusbr.h" -#include "wx/intl.h" -#include "wx/settings.h" -#include "wx/log.h" -#include "wx/fontutil.h" - -#ifdef __WXDEBUG__ - #include "wx/thread.h" -#endif - -#include -#include - -#include "wx/gtk/private.h" -#include -#include -#include - -#include -#include - -#include "wx/gtk/win_gtk.h" - -#ifdef __WXGTK20__ -#include -#endif - -#ifdef __WXGTK20__ - #define SET_CONTAINER_FOCUS(w, d) gtk_widget_child_focus((w), (d)) -#else - #define SET_CONTAINER_FOCUS(w, d) gtk_container_focus(GTK_CONTAINER(w), (d)) -#endif - -#ifdef __WXGTK20__ - #ifdef HAVE_XIM - #undef HAVE_XIM - #endif -#endif - -#ifdef __WXGTK20__ -extern GtkContainerClass *pizza_parent_class; -#endif - -//----------------------------------------------------------------------------- -// documentation on internals -//----------------------------------------------------------------------------- - -/* - I have been asked several times about writing some documentation about - the GTK port of wxWindows, especially its internal structures. Obviously, - you cannot understand wxGTK without knowing a little about the GTK, but - some more information about what the wxWindow, which is the base class - for all other window classes, does seems required as well. - - I) - - What does wxWindow do? It contains the common interface for the following - jobs of its descendants: - - 1) Define the rudimentary behaviour common to all window classes, such as - resizing, intercepting user input (so as to make it possible to use these - events for special purposes in a derived class), window names etc. - - 2) Provide the possibility to contain and manage children, if the derived - class is allowed to contain children, which holds true for those window - classes which do not display a native GTK widget. To name them, these - classes are wxPanel, wxScrolledWindow, wxDialog, wxFrame. The MDI frame- - work classes are a special case and are handled a bit differently from - the rest. The same holds true for the wxNotebook class. - - 3) Provide the possibility to draw into a client area of a window. This, - too, only holds true for classes that do not display a native GTK widget - as above. - - 4) Provide the entire mechanism for scrolling widgets. This actual inter- - face for this is usually in wxScrolledWindow, but the GTK implementation - is in this class. - - 5) A multitude of helper or extra methods for special purposes, such as - Drag'n'Drop, managing validators etc. - - 6) Display a border (sunken, raised, simple or none). - - Normally one might expect, that one wxWindows window would always correspond - to one GTK widget. Under GTK, there is no such allround widget that has all - the functionality. Moreover, the GTK defines a client area as a different - widget from the actual widget you are handling. Last but not least some - special classes (e.g. wxFrame) handle different categories of widgets and - still have the possibility to draw something in the client area. - It was therefore required to write a special purpose GTK widget, that would - represent a client area in the sense of wxWindows capable to do the jobs - 2), 3) and 4). I have written this class and it resides in win_gtk.c of - this directory. - - All windows must have a widget, with which they interact with other under- - lying GTK widgets. It is this widget, e.g. that has to be resized etc and - thw wxWindow class has a member variable called m_widget which holds a - pointer to this widget. When the window class represents a GTK native widget, - this is (in most cases) the only GTK widget the class manages. E.g. the - wxStatitText class handles only a GtkLabel widget a pointer to which you - can find in m_widget (defined in wxWindow) - - When the class has a client area for drawing into and for containing children - it has to handle the client area widget (of the type GtkPizza, defined in - win_gtk.c), but there could be any number of widgets, handled by a class - The common rule for all windows is only, that the widget that interacts with - the rest of GTK must be referenced in m_widget and all other widgets must be - children of this widget on the GTK level. The top-most widget, which also - represents the client area, must be in the m_wxwindow field and must be of - the type GtkPizza. - - As I said, the window classes that display a GTK native widget only have - one widget, so in the case of e.g. the wxButton class m_widget holds a - pointer to a GtkButton widget. But windows with client areas (for drawing - and children) have a m_widget field that is a pointer to a GtkScrolled- - Window and a m_wxwindow field that is pointer to a GtkPizza and this - one is (in the GTK sense) a child of the GtkScrolledWindow. - - If the m_wxwindow field is set, then all input to this widget is inter- - cepted and sent to the wxWindows class. If not, all input to the widget - that gets pointed to by m_widget gets intercepted and sent to the class. - - II) - - The design of scrolling in wxWindows is markedly different from that offered - by the GTK itself and therefore we cannot simply take it as it is. In GTK, - clicking on a scrollbar belonging to scrolled window will inevitably move - the window. In wxWindows, the scrollbar will only emit an event, send this - to (normally) a wxScrolledWindow and that class will call ScrollWindow() - which actually moves the window and its subchildren. Note that GtkPizza - memorizes how much it has been scrolled but that wxWindows forgets this - so that the two coordinates systems have to be kept in synch. This is done - in various places using the pizza->xoffset and pizza->yoffset values. - - III) - - Singularily the most broken code in GTK is the code that is supposes to - inform subwindows (child windows) about new positions. Very often, duplicate - events are sent without changes in size or position, equally often no - events are sent at all (All this is due to a bug in the GtkContainer code - which got fixed in GTK 1.2.6). For that reason, wxGTK completely ignores - GTK's own system and it simply waits for size events for toplevel windows - and then iterates down the respective size events to all window. This has - the disadvantage, that windows might get size events before the GTK widget - actually has the reported size. This doesn't normally pose any problem, but - the OpenGl drawing routines rely on correct behaviour. Therefore, I have - added the m_nativeSizeEvents flag, which is true only for the OpenGL canvas, - i.e. the wxGLCanvas will emit a size event, when (and not before) the X11 - window that is used for OpenGl output really has that size (as reported by - GTK). - - IV) - - If someone at some point of time feels the immense desire to have a look at, - change or attempt to optimse the Refresh() logic, this person will need an - intimate understanding of what a "draw" and what an "expose" events are and - what there are used for, in particular when used in connection with GTK's - own windowless widgets. Beware. - - V) - - Cursors, too, have been a constant source of pleasure. The main difficulty - is that a GdkWindow inherits a cursor if the programmer sets a new cursor - for the parent. To prevent this from doing too much harm, I use idle time - to set the cursor over and over again, starting from the toplevel windows - and ending with the youngest generation (speaking of parent and child windows). - Also don't forget that cursors (like much else) are connected to GdkWindows, - not GtkWidgets and that the "window" field of a GtkWidget might very well - point to the GdkWindow of the parent widget (-> "window less widget") and - that the two obviously have very different meanings. - -*/ - -//----------------------------------------------------------------------------- -// data -//----------------------------------------------------------------------------- - -extern wxList wxPendingDelete; -extern bool g_blockEventsOnDrag; -extern bool g_blockEventsOnScroll; -extern wxCursor g_globalCursor; - -static GdkGC *g_eraseGC = NULL; - -// mouse capture state: the window which has it and if the mouse is currently -// inside it -static wxWindowGTK *g_captureWindow = (wxWindowGTK*) NULL; -static bool g_captureWindowHasMouse = FALSE; - -/* extern */ wxWindowGTK *g_focusWindow = (wxWindowGTK*) NULL; - -// the last window which had the focus - this is normally never NULL (except -// if we never had focus at all) as even when g_focusWindow is NULL it still -// keeps its previous value -static wxWindowGTK *g_focusWindowLast = (wxWindowGTK*) NULL; - -// the frame that is currently active (i.e. its child has focus). It is -// used to generate wxActivateEvents -static wxWindowGTK *g_activeFrame = (wxWindowGTK*) NULL; -static bool g_activeFrameLostFocus = FALSE; - -// If a window get the focus set but has not been realized -// yet, defer setting the focus to idle time. -wxWindowGTK *g_delayedFocus = (wxWindowGTK*) NULL; - -// if we detect that the app has got/lost the focus, we set this variable to -// either TRUE or FALSE and an activate event will be sent during the next -// OnIdle() call and it is reset to -1: this value means that we shouldn't -// send any activate events at all -static int g_sendActivateEvent = -1; - -// 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; - -extern bool g_mainThreadLocked; - -//----------------------------------------------------------------------------- -// debug -//----------------------------------------------------------------------------- - -#ifndef __WXGTK20__ -#define DISABLE_STYLE_IF_BROKEN_THEME 0 -#endif - -#ifdef __WXDEBUG__ - -#if wxUSE_THREADS -# define DEBUG_MAIN_THREAD if (wxThread::IsMain() && g_mainThreadLocked) printf("gui reentrance"); -#else -# define DEBUG_MAIN_THREAD -#endif -#else -#define DEBUG_MAIN_THREAD -#endif // Debug - -// the trace mask used for the focus debugging messages -#define TRACE_FOCUS _T("focus") - -//----------------------------------------------------------------------------- -// missing gdk functions -//----------------------------------------------------------------------------- - -void -gdk_window_warp_pointer (GdkWindow *window, - gint x, - gint y) -{ -#ifndef __WXGTK20__ - GdkWindowPrivate *priv; -#endif - - if (!window) - window = GDK_ROOT_PARENT(); - -#ifdef __WXGTK20__ - if (!GDK_WINDOW_DESTROYED(window)) - { - XWarpPointer (GDK_WINDOW_XDISPLAY(window), - None, /* not source window -> move from anywhere */ - GDK_WINDOW_XID(window), /* dest window */ - 0, 0, 0, 0, /* not source window -> move from anywhere */ - x, y ); - } -#else - priv = (GdkWindowPrivate*) window; - - if (!priv->destroyed) - { - XWarpPointer (priv->xdisplay, - None, /* not source window -> move from anywhere */ - priv->xwindow, /* dest window */ - 0, 0, 0, 0, /* not source window -> move from anywhere */ - x, y ); - } -#endif -} - -//----------------------------------------------------------------------------- -// idle system -//----------------------------------------------------------------------------- - -extern void wxapp_install_idle_handler(); -extern bool g_isIdle; - -//----------------------------------------------------------------------------- -// local code (see below) -//----------------------------------------------------------------------------- - -// returns the child of win which currently has focus or NULL if not found -// -// Note: can't be static, needed by textctrl.cpp. -wxWindow *wxFindFocusedChild(wxWindowGTK *win) -{ - wxWindow *winFocus = wxWindowGTK::FindFocus(); - if ( !winFocus ) - return (wxWindow *)NULL; - - if ( winFocus == win ) - return (wxWindow *)win; - - for ( wxWindowList::Node *node = win->GetChildren().GetFirst(); - node; - node = node->GetNext() ) - { - wxWindow *child = wxFindFocusedChild(node->GetData()); - if ( child ) - return child; - } - - return (wxWindow *)NULL; -} - -static void draw_frame( GtkWidget *widget, wxWindowGTK *win ) -{ - // wxUniversal widgets draw the borders and scrollbars themselves -#ifndef __WXUNIVERSAL__ - if (!win->m_hasVMT) - return; - - int dw = 0; - int dh = 0; - - if (win->m_hasScrolling) - { - GtkScrolledWindow *scroll_window = GTK_SCROLLED_WINDOW(widget); - - GtkRequisition vscroll_req; - vscroll_req.width = 2; - vscroll_req.height = 2; - (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(scroll_window->vscrollbar) )->size_request ) - (scroll_window->vscrollbar, &vscroll_req ); - - GtkRequisition hscroll_req; - hscroll_req.width = 2; - hscroll_req.height = 2; - (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(scroll_window->hscrollbar) )->size_request ) - (scroll_window->hscrollbar, &hscroll_req ); - - GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT_GET_CLASS(widget) ); - - if (scroll_window->vscrollbar_visible) - { - dw += vscroll_req.width; - dw += scroll_class->scrollbar_spacing; - } - - if (scroll_window->hscrollbar_visible) - { - dh += hscroll_req.height; - dh += scroll_class->scrollbar_spacing; - } -} - - int dx = 0; - int dy = 0; - if (GTK_WIDGET_NO_WINDOW (widget)) - { - dx += widget->allocation.x; - dy += widget->allocation.y; - } - - if (win->HasFlag(wxRAISED_BORDER)) - { - gtk_draw_shadow( widget->style, - widget->window, - GTK_STATE_NORMAL, - GTK_SHADOW_OUT, - dx, dy, - widget->allocation.width-dw, widget->allocation.height-dh ); - return; - } - - if (win->HasFlag(wxSUNKEN_BORDER)) - { - gtk_draw_shadow( widget->style, - widget->window, - GTK_STATE_NORMAL, - GTK_SHADOW_IN, - dx, dy, - widget->allocation.width-dw, widget->allocation.height-dh ); - return; - } - - if (win->HasFlag(wxSIMPLE_BORDER)) - { - GdkGC *gc; - gc = gdk_gc_new( widget->window ); - gdk_gc_set_foreground( gc, &widget->style->black ); - gdk_draw_rectangle( widget->window, gc, FALSE, - dx, dy, - widget->allocation.width-dw-1, widget->allocation.height-dh-1 ); - gdk_gc_unref( gc ); - return; - } -#endif // __WXUNIVERSAL__ -} - -//----------------------------------------------------------------------------- -// "expose_event" of m_widget -//----------------------------------------------------------------------------- - -gint gtk_window_own_expose_callback( GtkWidget *widget, GdkEventExpose *gdk_event, wxWindowGTK *win ) -{ - if (gdk_event->count > 0) return FALSE; - - draw_frame( widget, win ); - -#ifdef __WXGTK20__ - - (* GTK_WIDGET_CLASS (pizza_parent_class)->expose_event) (widget, gdk_event); - -#endif - return TRUE; -} - -//----------------------------------------------------------------------------- -// "draw" of m_widget -//----------------------------------------------------------------------------- - -#ifndef __WXGTK20__ - -static void gtk_window_own_draw_callback( GtkWidget *widget, GdkRectangle *WXUNUSED(rect), wxWindowGTK *win ) -{ - draw_frame( widget, win ); -} - -#endif // GTK+ < 2.0 - -//----------------------------------------------------------------------------- -// "size_request" of m_widget -//----------------------------------------------------------------------------- - -static void gtk_window_size_request_callback( GtkWidget *widget, GtkRequisition *requisition, wxWindow *win ) -{ - int w,h; - win->GetSize( &w, &h ); - if (w < 2) w = 2; - if (h < 2) h = 2; - - requisition->height = h; - requisition->width = w; -} - -//----------------------------------------------------------------------------- -// "expose_event" of m_wxwindow -//----------------------------------------------------------------------------- - -static int gtk_window_expose_callback( GtkWidget *widget, - GdkEventExpose *gdk_event, - wxWindow *win ) -{ - DEBUG_MAIN_THREAD - - if (g_isIdle) - wxapp_install_idle_handler(); - -#ifdef __WXGTK20__ - // This callback gets called in drawing-idle time under - // GTK 2.0, so we don't need to defer anything to idle - // time anymore. - - GtkPizza *pizza = GTK_PIZZA( widget ); - if (gdk_event->window != pizza->bin_window) return FALSE; - -#if 0 - if (win->GetName()) - { - wxPrintf( wxT("OnExpose from ") ); - if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) - wxPrintf( win->GetClassInfo()->GetClassName() ); - wxPrintf( wxT(" %d %d %d %d\n"), (int)gdk_event->area.x, - (int)gdk_event->area.y, - (int)gdk_event->area.width, - (int)gdk_event->area.height ); - } -#endif - - win->GetUpdateRegion() = wxRegion( gdk_event->region ); - - win->GtkSendPaintEvents(); - - - // Let parent window draw window less widgets - (* GTK_WIDGET_CLASS (pizza_parent_class)->expose_event) (widget, gdk_event); -#else - // This gets called immediately after an expose event - // under GTK 1.2 so we collect the calls and wait for - // the idle handler to pick things up. - - win->GetUpdateRegion().Union( gdk_event->area.x, - gdk_event->area.y, - gdk_event->area.width, - gdk_event->area.height ); - win->m_clearRegion.Union( gdk_event->area.x, - gdk_event->area.y, - gdk_event->area.width, - gdk_event->area.height ); - - // Actual redrawing takes place in idle time. - // win->GtkUpdate(); -#endif - - return FALSE; -} - -//----------------------------------------------------------------------------- -// "event" of m_wxwindow -//----------------------------------------------------------------------------- - -// GTK thinks it is clever and filters out a certain amount of "unneeded" -// expose events. We need them, of course, so we override the main event -// procedure in GtkWidget by giving our own handler for all system events. -// There, we look for expose events ourselves whereas all other events are -// handled normally. - -gint gtk_window_event_event_callback( GtkWidget *widget, - GdkEventExpose *event, - wxWindow *win ) -{ - if (event->type == GDK_EXPOSE) - { - gint ret = gtk_window_expose_callback( widget, event, win ); - return ret; - } - - return FALSE; -} - -//----------------------------------------------------------------------------- -// "draw" of m_wxwindow -//----------------------------------------------------------------------------- - -#ifndef __WXGTK20__ - -// This callback is a complete replacement of the gtk_pizza_draw() function, -// which is disabled. - -static void gtk_window_draw_callback( GtkWidget *widget, - GdkRectangle *rect, - wxWindow *win ) -{ - DEBUG_MAIN_THREAD - - if (g_isIdle) - wxapp_install_idle_handler(); - - // The wxNO_FULL_REPAINT_ON_RESIZE flag only works if - // there are no child windows. - if ((win->HasFlag(wxNO_FULL_REPAINT_ON_RESIZE)) && - (win->GetChildren().GetCount() == 0)) - { - return; - } - -#if 0 - if (win->GetName()) - { - wxPrintf( wxT("OnDraw from ") ); - if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) - wxPrintf( win->GetClassInfo()->GetClassName() ); - wxPrintf( wxT(" %d %d %d %d\n"), (int)rect->x, - (int)rect->y, - (int)rect->width, - (int)rect->height ); - } -#endif - -#ifndef __WXUNIVERSAL__ - GtkPizza *pizza = GTK_PIZZA (widget); - - if (win->GetThemeEnabled()) - { - wxWindow *parent = win->GetParent(); - while (parent && !parent->IsTopLevel()) - parent = parent->GetParent(); - if (!parent) - parent = win; - - gtk_paint_flat_box (parent->m_widget->style, - pizza->bin_window, - GTK_STATE_NORMAL, - GTK_SHADOW_NONE, - rect, - parent->m_widget, - (char *)"base", - 0, 0, -1, -1); - } -#endif - - win->m_clearRegion.Union( rect->x, rect->y, rect->width, rect->height ); - win->GetUpdateRegion().Union( rect->x, rect->y, rect->width, rect->height ); - - // Update immediately, not in idle time. - win->GtkUpdate(); - -#ifndef __WXUNIVERSAL__ - // Redraw child widgets - GList *children = pizza->children; - while (children) - { - GtkPizzaChild *child = (GtkPizzaChild*) children->data; - children = children->next; - - GdkRectangle child_area; - if (gtk_widget_intersect (child->widget, rect, &child_area)) - { - gtk_widget_draw (child->widget, &child_area /* (GdkRectangle*) NULL*/ ); - } - } -#endif -} - -#endif - -//----------------------------------------------------------------------------- -// "key_press_event" from any window -//----------------------------------------------------------------------------- - -// set WXTRACE to this to see the key event codes on the console -#define TRACE_KEYS _T("keyevent") - -// translates an X key symbol to WXK_XXX value -// -// if isChar is true it means that the value returned will be used for EVT_CHAR -// event and then we choose the logical WXK_XXX, i.e. '/' for GDK_KP_Divide, -// for example, while if it is false it means that the value is going to be -// used for KEY_DOWN/UP events and then we translate GDK_KP_Divide to -// WXK_NUMPAD_DIVIDE -static long wxTranslateKeySymToWXKey(KeySym keysym, bool isChar) -{ - long key_code; - - switch ( keysym ) - { - // Shift, Control and Alt don't generate the CHAR events at all - case GDK_Shift_L: - case GDK_Shift_R: - key_code = isChar ? 0 : WXK_SHIFT; - break; - case GDK_Control_L: - case GDK_Control_R: - key_code = isChar ? 0 : WXK_CONTROL; - break; - case GDK_Meta_L: - case GDK_Meta_R: - case GDK_Alt_L: - case GDK_Alt_R: - case GDK_Super_L: - case GDK_Super_R: - key_code = isChar ? 0 : WXK_ALT; - break; - - // neither do the toggle modifies - case GDK_Scroll_Lock: - key_code = isChar ? 0 : WXK_SCROLL; - break; - - case GDK_Caps_Lock: - key_code = isChar ? 0 : WXK_CAPITAL; - break; - - case GDK_Num_Lock: - key_code = isChar ? 0 : WXK_NUMLOCK; - break; - - - // various other special keys - case GDK_Menu: - key_code = WXK_MENU; - break; - - case GDK_Help: - key_code = WXK_HELP; - break; - - case GDK_BackSpace: - key_code = WXK_BACK; - break; - - case GDK_ISO_Left_Tab: - case GDK_Tab: - key_code = WXK_TAB; - break; - - case GDK_Linefeed: - case GDK_Return: - key_code = WXK_RETURN; - break; - - case GDK_Clear: - key_code = WXK_CLEAR; - break; - - case GDK_Pause: - key_code = WXK_PAUSE; - break; - - case GDK_Select: - key_code = WXK_SELECT; - break; - - case GDK_Print: - key_code = WXK_PRINT; - break; - - case GDK_Execute: - key_code = WXK_EXECUTE; - break; - - case GDK_Escape: - key_code = WXK_ESCAPE; - break; - - // cursor and other extended keyboard keys - case GDK_Delete: - key_code = WXK_DELETE; - break; - - case GDK_Home: - key_code = WXK_HOME; - break; - - case GDK_Left: - key_code = WXK_LEFT; - break; - - case GDK_Up: - key_code = WXK_UP; - break; - - case GDK_Right: - key_code = WXK_RIGHT; - break; - - case GDK_Down: - key_code = WXK_DOWN; - break; - - case GDK_Prior: // == GDK_Page_Up - key_code = WXK_PRIOR; - break; - - case GDK_Next: // == GDK_Page_Down - key_code = WXK_NEXT; - break; - - case GDK_End: - key_code = WXK_END; - break; - - case GDK_Begin: - key_code = WXK_HOME; - break; - - case GDK_Insert: - key_code = WXK_INSERT; - break; - - - // numpad keys - case GDK_KP_0: - case GDK_KP_1: - case GDK_KP_2: - case GDK_KP_3: - case GDK_KP_4: - case GDK_KP_5: - case GDK_KP_6: - case GDK_KP_7: - case GDK_KP_8: - case GDK_KP_9: - key_code = (isChar ? '0' : WXK_NUMPAD0) + keysym - GDK_KP_0; - break; - - case GDK_KP_Space: - key_code = isChar ? ' ' : WXK_NUMPAD_SPACE; - break; - - case GDK_KP_Tab: - key_code = isChar ? WXK_TAB : WXK_NUMPAD_TAB; - break; - - case GDK_KP_Enter: - key_code = isChar ? WXK_RETURN : WXK_NUMPAD_ENTER; - break; - - case GDK_KP_F1: - key_code = isChar ? WXK_F1 : WXK_NUMPAD_F1; - break; - - case GDK_KP_F2: - key_code = isChar ? WXK_F2 : WXK_NUMPAD_F2; - break; - - case GDK_KP_F3: - key_code = isChar ? WXK_F3 : WXK_NUMPAD_F3; - break; - - case GDK_KP_F4: - key_code = isChar ? WXK_F4 : WXK_NUMPAD_F4; - break; - - case GDK_KP_Home: - key_code = isChar ? WXK_HOME : WXK_NUMPAD_HOME; - break; - - case GDK_KP_Left: - // wxPrintf( wxT("Left\n") ); - key_code = isChar ? WXK_LEFT : WXK_NUMPAD_LEFT; - break; - - case GDK_KP_Up: - key_code = isChar ? WXK_UP : WXK_NUMPAD_UP; - break; - - case GDK_KP_Right: - key_code = isChar ? WXK_RIGHT : WXK_NUMPAD_RIGHT; - break; - - case GDK_KP_Down: - key_code = isChar ? WXK_DOWN : WXK_NUMPAD_DOWN; - break; - - case GDK_KP_Prior: // == GDK_KP_Page_Up - key_code = isChar ? WXK_PRIOR : WXK_NUMPAD_PRIOR; - break; - - case GDK_KP_Next: // == GDK_KP_Page_Down - key_code = isChar ? WXK_NEXT : WXK_NUMPAD_NEXT; - break; - - case GDK_KP_End: - key_code = isChar ? WXK_END : WXK_NUMPAD_END; - break; - - case GDK_KP_Begin: - key_code = isChar ? WXK_HOME : WXK_NUMPAD_BEGIN; - break; - - case GDK_KP_Insert: - key_code = isChar ? WXK_INSERT : WXK_NUMPAD_INSERT; - break; - - case GDK_KP_Delete: - key_code = isChar ? WXK_DELETE : WXK_NUMPAD_DELETE; - break; - - case GDK_KP_Equal: - key_code = isChar ? '=' : WXK_NUMPAD_EQUAL; - break; - - case GDK_KP_Multiply: - key_code = isChar ? '*' : WXK_NUMPAD_MULTIPLY; - break; - - case GDK_KP_Add: - key_code = isChar ? '+' : WXK_NUMPAD_ADD; - break; - - case GDK_KP_Separator: - // FIXME: what is this? - key_code = isChar ? '.' : WXK_NUMPAD_SEPARATOR; - break; - - case GDK_KP_Subtract: - key_code = isChar ? '-' : WXK_NUMPAD_SUBTRACT; - break; - - case GDK_KP_Decimal: - key_code = isChar ? '.' : WXK_NUMPAD_DECIMAL; - break; - - case GDK_KP_Divide: - key_code = isChar ? '/' : WXK_NUMPAD_DIVIDE; - break; - - - // function keys - case GDK_F1: - case GDK_F2: - case GDK_F3: - case GDK_F4: - case GDK_F5: - case GDK_F6: - case GDK_F7: - case GDK_F8: - case GDK_F9: - case GDK_F10: - case GDK_F11: - case GDK_F12: - key_code = WXK_F1 + keysym - GDK_F1; - break; - - default: - key_code = 0; - } - - return key_code; -} - -static inline bool wxIsAsciiKeysym(KeySym ks) -{ - return ks < 256; -} - -static bool -wxTranslateGTKKeyEventToWx(wxKeyEvent& event, - wxWindowGTK *win, - GdkEventKey *gdk_event) -{ - // VZ: it seems that GDK_KEY_RELEASE event doesn't set event->string - // but only event->keyval which is quite useless to us, so remember - // the last character from GDK_KEY_PRESS and reuse it as last resort - // - // NB: should be MT-safe as we're always called from the main thread only - static struct - { - KeySym keysym; - long keycode; - } s_lastKeyPress = { 0, 0 }; - - KeySym keysym = gdk_event->keyval; - - wxLogTrace(TRACE_KEYS, _T("Key %s event: keysym = %ld"), - event.GetEventType() == wxEVT_KEY_UP ? _T("release") - : _T("press"), - keysym); - - long key_code = wxTranslateKeySymToWXKey(keysym, FALSE /* !isChar */); - - if ( !key_code ) - { - // do we have the translation or is it a plain ASCII character? - if ( (gdk_event->length == 1) || wxIsAsciiKeysym(keysym) ) - { - // we should use keysym if it is ASCII as X does some translations - // like "I pressed while Control is down" => "Ctrl-I" == "TAB" - // which we don't want here (but which we do use for OnChar()) - if ( !wxIsAsciiKeysym(keysym) ) - { - keysym = (KeySym)gdk_event->string[0]; - } - - // we want to always get the same key code when the same key is - // pressed regardless of the state of the modifies, i.e. on a - // standard US keyboard pressing '5' or '%' ('5' key with - // Shift) should result in the same key code in OnKeyDown(): - // '5' (although OnChar() will get either '5' or '%'). - // - // to do it we first translate keysym to keycode (== scan code) - // and then back but always using the lower register - Display *dpy = (Display *)wxGetDisplay(); - KeyCode keycode = XKeysymToKeycode(dpy, keysym); - - wxLogTrace(TRACE_KEYS, _T("\t-> keycode %d"), keycode); - - KeySym keysymNormalized = XKeycodeToKeysym(dpy, keycode, 0); - - // use the normalized, i.e. lower register, keysym if we've - // got one - key_code = keysymNormalized ? keysymNormalized : keysym; - - // as explained above, we want to have lower register key codes - // normally but for the letter keys we want to have the upper ones - // - // NB: don't use XConvertCase() here, we want to do it for letters - // only - key_code = toupper(key_code); - } - else // non ASCII key, what to do? - { - // by default, ignore it - key_code = 0; - - // but if we have cached information from the last KEY_PRESS - if ( gdk_event->type == GDK_KEY_RELEASE ) - { - // then reuse it - if ( keysym == s_lastKeyPress.keysym ) - { - key_code = s_lastKeyPress.keycode; - } - } - } - - if ( gdk_event->type == GDK_KEY_PRESS ) - { - // remember it to be reused for KEY_UP event later - s_lastKeyPress.keysym = keysym; - s_lastKeyPress.keycode = key_code; - } - } - - wxLogTrace(TRACE_KEYS, _T("\t-> wxKeyCode %ld"), key_code); - - // sending unknown key events doesn't really make sense - if ( !key_code ) - return FALSE; - - // now fill all the other fields - int x = 0; - int y = 0; - GdkModifierType state; - if (gdk_event->window) - gdk_window_get_pointer(gdk_event->window, &x, &y, &state); - - event.SetTimestamp( gdk_event->time ); - event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK) != 0; - event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK) != 0; - event.m_altDown = (gdk_event->state & GDK_MOD1_MASK) != 0; - event.m_metaDown = (gdk_event->state & GDK_MOD2_MASK) != 0; - event.m_keyCode = key_code; - event.m_scanCode = gdk_event->keyval; - event.m_rawCode = (wxUint32) gdk_event->keyval; - event.m_rawFlags = 0; - event.m_x = x; - event.m_y = y; - event.SetEventObject( win ); - - return TRUE; -} - - -static gint gtk_window_key_press_callback( GtkWidget *widget, - GdkEventKey *gdk_event, - wxWindow *win ) -{ - DEBUG_MAIN_THREAD - - if (g_isIdle) - wxapp_install_idle_handler(); - - if (!win->m_hasVMT) - return FALSE; - if (g_blockEventsOnDrag) - return FALSE; - - - wxKeyEvent event( wxEVT_KEY_DOWN ); - if ( !wxTranslateGTKKeyEventToWx(event, win, gdk_event) ) - { - // unknown key pressed, ignore (the event would be useless anyhow) - return FALSE; - } - - // Emit KEY_DOWN event - bool ret = win->GetEventHandler()->ProcessEvent( event ); - -#if wxUSE_ACCEL - if (!ret) - { - wxWindowGTK *ancestor = win; - while (ancestor) - { - int command = ancestor->GetAcceleratorTable()->GetCommand( event ); - if (command != -1) - { - wxCommandEvent command_event( wxEVT_COMMAND_MENU_SELECTED, command ); - ret = ancestor->GetEventHandler()->ProcessEvent( command_event ); - break; - } - if (ancestor->IsTopLevel()) - break; - ancestor = ancestor->GetParent(); - } - } -#endif // wxUSE_ACCEL - - // Only send wxEVT_CHAR event if not processed yet. Thus, ALT-x - // will only be sent if it is not in an accelerator table. - if (!ret) - { - long key_code; - KeySym keysym = gdk_event->keyval; -#ifdef __WXGTK20__ - // In GTK 2.0, we need to hand over the key event to an input method - // and the IM will emit a "commit" event containing the actual utf8 - // character. In that case the EVT_CHAR events will be sent from - // there. But only do it this way for non-KeySym keys. - key_code = wxTranslateKeySymToWXKey(gdk_event->keyval, FALSE /* isChar */); - if ( !key_code && win->m_imContext ) - { - gtk_im_context_filter_keypress ( (GtkIMContext*) win->m_imContext, gdk_event ); - ret = TRUE; - } - else -#endif - { - // Find key code for EVT_CHAR and EVT_CHAR_HOOK events - key_code = wxTranslateKeySymToWXKey(keysym, TRUE /* isChar */); - if ( !key_code ) - { - if ( gdk_event->length == 1 ) - { - key_code = (unsigned char)gdk_event->string[0]; - } - else if ( wxIsAsciiKeysym(keysym) ) - { - // ASCII key - key_code = (unsigned char)keysym; - } - } - - if ( key_code ) - { - wxLogTrace(TRACE_KEYS, _T("Char event: %ld"), key_code); - - event.m_keyCode = key_code; - - // Implement OnCharHook by checking ancesteror top level windows - wxWindow *parent = win; - while (parent && !parent->IsTopLevel()) - parent = parent->GetParent(); - if (parent) - { - event.SetEventType( wxEVT_CHAR_HOOK ); - ret = parent->GetEventHandler()->ProcessEvent( event ); - } - - if (!ret) - { - event.SetEventType(wxEVT_CHAR); - ret = win->GetEventHandler()->ProcessEvent( event ); - } - } - } - } - - // win is a control: tab can be propagated up - if ( !ret && - ((gdk_event->keyval == GDK_Tab) || (gdk_event->keyval == GDK_ISO_Left_Tab)) && -// VZ: testing for wxTE_PROCESS_TAB shouldn't be done here the control may -// have this style, yet choose not to process this particular TAB in which -// case TAB must still work as a navigational character -#if 0 - !win->HasFlag(wxTE_PROCESS_TAB) && -#endif // 0 - win->GetParent() && (win->GetParent()->HasFlag( wxTAB_TRAVERSAL)) ) - { - wxNavigationKeyEvent new_event; - new_event.SetEventObject( win->GetParent() ); - // GDK reports GDK_ISO_Left_Tab for SHIFT-TAB - new_event.SetDirection( (gdk_event->keyval == GDK_Tab) ); - // CTRL-TAB changes the (parent) window, i.e. switch notebook page - new_event.SetWindowChange( (gdk_event->state & GDK_CONTROL_MASK) ); - new_event.SetCurrentFocus( win ); - ret = win->GetParent()->GetEventHandler()->ProcessEvent( new_event ); - } - - // generate wxID_CANCEL if has been pressed (typically in dialogs) - if ( !ret && - (gdk_event->keyval == GDK_Escape) ) - { - // however only do it if we have a Cancel button in the dialog, - // otherwise the user code may get confused by the events from a - // non-existing button and, worse, a wxButton might get button event - // from another button which is not really expected - wxWindow *winForCancel = win, - *btnCancel = NULL; - while ( winForCancel ) - { - btnCancel = winForCancel->FindWindow(wxID_CANCEL); - if ( btnCancel ) - { - // found a cancel button - break; - } - - if ( winForCancel->IsTopLevel() ) - { - // no need to look further - break; - } - - // maybe our parent has a cancel button? - winForCancel = winForCancel->GetParent(); - } - - if ( btnCancel ) - { - wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); - event.SetEventObject(btnCancel); - ret = btnCancel->GetEventHandler()->ProcessEvent(event); - } - } - - if (ret) - { - gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_press_event" ); - return TRUE; - } - - return FALSE; -} - -#ifdef __WXGTK20__ -static void gtk_wxwindow_commit_cb (GtkIMContext *context, - const gchar *str, - wxWindow *window) -{ - bool ret = FALSE; - - wxKeyEvent event( wxEVT_KEY_DOWN ); - -#if wxUSE_UNICODE - event.m_uniChar = g_utf8_get_char( str ); - - // Backward compatible for ISO-8859 - if (event.m_uniChar < 256) - event.m_keyCode = event.m_uniChar; -#else - gunichar uniChar = g_utf8_get_char( str ); - // We cannot handle Unicode in non-Unicode mode - if (uniChar > 255) return; - - event.m_keyCode = uniChar; -#endif - - - // TODO: We still need to set all the extra attributes of the - // event, modifiers and such... - - - // Implement OnCharHook by checking ancestor top level windows - wxWindow *parent = window; - while (parent && !parent->IsTopLevel()) - parent = parent->GetParent(); - if (parent) - { - event.SetEventType( wxEVT_CHAR_HOOK ); - ret = parent->GetEventHandler()->ProcessEvent( event ); - } - - if (!ret) - { - event.SetEventType(wxEVT_CHAR); - ret = window->GetEventHandler()->ProcessEvent( event ); - } -} -#endif - - -//----------------------------------------------------------------------------- -// "key_release_event" from any window -//----------------------------------------------------------------------------- - -static gint gtk_window_key_release_callback( GtkWidget *widget, - GdkEventKey *gdk_event, - wxWindowGTK *win ) -{ - DEBUG_MAIN_THREAD - - if (g_isIdle) - wxapp_install_idle_handler(); - - if (!win->m_hasVMT) - return FALSE; - - if (g_blockEventsOnDrag) - return FALSE; - - wxKeyEvent event( wxEVT_KEY_UP ); - if ( !wxTranslateGTKKeyEventToWx(event, win, gdk_event) ) - { - // unknown key pressed, ignore (the event would be useless anyhow - return FALSE; - } - - if ( !win->GetEventHandler()->ProcessEvent( event ) ) - return FALSE; - - gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "key_release_event" ); - return TRUE; -} - -// ============================================================================ -// the mouse events -// ============================================================================ - -// ---------------------------------------------------------------------------- -// mouse event processing helpers -// ---------------------------------------------------------------------------- - -// init wxMouseEvent with the info from gdk_event -// -// NB: this has to be a macro as gdk_event type is different for different -// events we're used with -#define InitMouseEvent(/* wxWindowGTK * */ win, \ - /* wxMouseEvent& */ event, \ - /* GdkEventXXX * */ gdk_event) \ -{ \ - event.SetTimestamp( gdk_event->time ); \ - event.m_shiftDown = (gdk_event->state & GDK_SHIFT_MASK); \ - event.m_controlDown = (gdk_event->state & GDK_CONTROL_MASK); \ - event.m_altDown = (gdk_event->state & GDK_MOD1_MASK); \ - event.m_metaDown = (gdk_event->state & GDK_MOD2_MASK); \ - event.m_leftDown = (gdk_event->state & GDK_BUTTON1_MASK); \ - event.m_middleDown = (gdk_event->state & GDK_BUTTON2_MASK); \ - event.m_rightDown = (gdk_event->state & GDK_BUTTON3_MASK); \ - if (event.GetEventType()==wxEVT_MOUSEWHEEL) \ - { \ - if (((GdkEventButton*)gdk_event)->button == 4) \ - event.m_wheelRotation = 120; \ - else if (((GdkEventButton*)gdk_event)->button == 5) \ - event.m_wheelRotation = -120; \ - } \ - \ - wxPoint pt = win->GetClientAreaOrigin(); \ - event.m_x = (wxCoord)gdk_event->x - pt.x; \ - event.m_y = (wxCoord)gdk_event->y - pt.y; \ - \ - event.SetEventObject( win ); \ - event.SetId( win->GetId() ); \ - event.SetTimestamp( gdk_event->time ); \ -} \ - -static void AdjustEventButtonState(wxMouseEvent& event) -{ - // GDK reports the old state of the button for a button press event, but - // for compatibility with MSW and common sense we want m_leftDown be TRUE - // for a LEFT_DOWN event, not FALSE, so we will invert - // left/right/middleDown for the corresponding click events - - if ((event.GetEventType() == wxEVT_LEFT_DOWN) || - (event.GetEventType() == wxEVT_LEFT_DCLICK) || - (event.GetEventType() == wxEVT_LEFT_UP)) - { - event.m_leftDown = !event.m_leftDown; - return; - } - - if ((event.GetEventType() == wxEVT_MIDDLE_DOWN) || - (event.GetEventType() == wxEVT_MIDDLE_DCLICK) || - (event.GetEventType() == wxEVT_MIDDLE_UP)) - { - event.m_middleDown = !event.m_middleDown; - return; - } - - if ((event.GetEventType() == wxEVT_RIGHT_DOWN) || - (event.GetEventType() == wxEVT_RIGHT_DCLICK) || - (event.GetEventType() == wxEVT_RIGHT_UP)) - { - event.m_rightDown = !event.m_rightDown; - return; - } -} - -// find the window to send the mouse event too -static -wxWindowGTK *FindWindowForMouseEvent(wxWindowGTK *win, wxCoord& x, wxCoord& y) -{ - wxCoord xx = x; - wxCoord yy = y; - - if (win->m_wxwindow) - { - GtkPizza *pizza = GTK_PIZZA(win->m_wxwindow); - xx += pizza->xoffset; - yy += pizza->yoffset; - } - - wxNode *node = win->GetChildren().First(); - while (node) - { - wxWindowGTK *child = (wxWindowGTK*)node->Data(); - - node = node->Next(); - if (!child->IsShown()) - continue; - - if (child->IsTransparentForMouse()) - { - // wxStaticBox is transparent in the box itself - int xx1 = child->m_x; - int yy1 = child->m_y; - int xx2 = child->m_x + child->m_width; - int yy2 = child->m_y + child->m_height; - - // left - if (((xx >= xx1) && (xx <= xx1+10) && (yy >= yy1) && (yy <= yy2)) || - // right - ((xx >= xx2-10) && (xx <= xx2) && (yy >= yy1) && (yy <= yy2)) || - // top - ((xx >= xx1) && (xx <= xx2) && (yy >= yy1) && (yy <= yy1+10)) || - // bottom - ((xx >= xx1) && (xx <= xx2) && (yy >= yy2-1) && (yy <= yy2))) - { - win = child; - x -= child->m_x; - y -= child->m_y; - break; - } - - } - else - { - if ((child->m_wxwindow == (GtkWidget*) NULL) && - (child->m_x <= xx) && - (child->m_y <= yy) && - (child->m_x+child->m_width >= xx) && - (child->m_y+child->m_height >= yy)) - { - win = child; - x -= child->m_x; - y -= child->m_y; - break; - } - } - } - - return win; -} - -//----------------------------------------------------------------------------- -// "button_press_event" -//----------------------------------------------------------------------------- - -static gint gtk_window_button_press_callback( GtkWidget *widget, - GdkEventButton *gdk_event, - wxWindowGTK *win ) -{ - DEBUG_MAIN_THREAD - - if (g_isIdle) - wxapp_install_idle_handler(); - -/* - wxPrintf( wxT("1) OnButtonPress from ") ); - if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) - wxPrintf( win->GetClassInfo()->GetClassName() ); - wxPrintf( wxT(".\n") ); -*/ - if (!win->m_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 && (g_focusWindow != win) && win->AcceptsFocus()) - { - gtk_widget_grab_focus( win->m_wxwindow ); -/* - wxPrintf( wxT("GrabFocus from ") ); - if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) - wxPrintf( win->GetClassInfo()->GetClassName() ); - wxPrintf( wxT(".\n") ); -*/ - } - - // GDK sends surplus button down event - // before a double click event. We - // need to filter these out. - if (gdk_event->type == GDK_BUTTON_PRESS) - { - GdkEvent *peek_event = gdk_event_peek(); - if (peek_event) - { - if ((peek_event->type == GDK_2BUTTON_PRESS) || - (peek_event->type == GDK_3BUTTON_PRESS)) - { - gdk_event_free( peek_event ); - return TRUE; - } - else - { - gdk_event_free( peek_event ); - } - } - } - - wxEventType event_type = wxEVT_NULL; - - if (gdk_event->button == 1) - { - switch (gdk_event->type) - { - case GDK_BUTTON_PRESS: event_type = wxEVT_LEFT_DOWN; break; - case GDK_2BUTTON_PRESS: event_type = wxEVT_LEFT_DCLICK; break; - case GDK_3BUTTON_PRESS: return FALSE; break; - default: break; - } - } - else if (gdk_event->button == 2) - { - switch (gdk_event->type) - { - case GDK_BUTTON_PRESS: event_type = wxEVT_MIDDLE_DOWN; break; - case GDK_2BUTTON_PRESS: event_type = wxEVT_MIDDLE_DCLICK; break; - default: break; - } - } - else if (gdk_event->button == 3) - { - switch (gdk_event->type) - { - case GDK_BUTTON_PRESS: event_type = wxEVT_RIGHT_DOWN; break; - case GDK_2BUTTON_PRESS: event_type = wxEVT_RIGHT_DCLICK; break; - default: break; - } - } - else if (gdk_event->button == 4) - { - switch (gdk_event->type) - { - case GDK_BUTTON_PRESS: event_type = wxEVT_MOUSEWHEEL; break; - default: break; - } - } - else if (gdk_event->button == 5) - { - switch (gdk_event->type) - { - case GDK_BUTTON_PRESS: event_type = wxEVT_MOUSEWHEEL; break; - default: break; - } - } - - if ( event_type == wxEVT_NULL ) - { - // unknown mouse button or click type - return FALSE; - } - - wxMouseEvent event( event_type ); - InitMouseEvent( win, event, gdk_event ); - - AdjustEventButtonState(event); - - // wxListBox actually get mouse events from the item, so we need to give it - // a chance to correct this - win->FixUpMouseEvent(widget, event.m_x, event.m_y); - - // find the correct window to send the event too: it may be a different one - // from the one which got it at GTK+ level because some control don't have - // their own X window and thus cannot get any events. - if ( !g_captureWindow ) - win = FindWindowForMouseEvent(win, event.m_x, event.m_y); - - gs_timeLastClick = gdk_event->time; - -/* - wxPrintf( wxT("2) OnButtonPress from ") ); - if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) - wxPrintf( win->GetClassInfo()->GetClassName() ); - wxPrintf( wxT(".\n") ); -*/ - -#ifndef __WXGTK20__ - if (event_type == wxEVT_LEFT_DCLICK) - { - // GTK 1.2 crashes when intercepting double - // click events from both wxSpinButton and - // wxSpinCtrl - if (GTK_IS_SPIN_BUTTON(win->m_widget)) - { - // Just disable this event for now. - return FALSE; - } - } -#endif - - if (win->GetEventHandler()->ProcessEvent( event )) - { - gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "button_press_event" ); - return TRUE; - } - - return FALSE; -} - -//----------------------------------------------------------------------------- -// "button_release_event" -//----------------------------------------------------------------------------- - -static gint gtk_window_button_release_callback( GtkWidget *widget, - GdkEventButton *gdk_event, - wxWindowGTK *win ) -{ - DEBUG_MAIN_THREAD - - if (g_isIdle) - wxapp_install_idle_handler(); - - if (!win->m_hasVMT) return FALSE; - if (g_blockEventsOnDrag) return FALSE; - if (g_blockEventsOnScroll) return FALSE; - - if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE; - - wxEventType event_type = wxEVT_NULL; - - switch (gdk_event->button) - { - case 1: - event_type = wxEVT_LEFT_UP; - break; - - case 2: - event_type = wxEVT_MIDDLE_UP; - break; - - case 3: - event_type = wxEVT_RIGHT_UP; - break; - - default: - // unknwon button, don't process - return FALSE; - } - - wxMouseEvent event( event_type ); - InitMouseEvent( win, event, gdk_event ); - - AdjustEventButtonState(event); - - // same wxListBox hack as above - win->FixUpMouseEvent(widget, event.m_x, event.m_y); - - if ( event_type == wxEVT_RIGHT_UP ) - { - // generate a "context menu" event: this is similar to wxEVT_RIGHT_UP - // except that: - // - // (a) it's a command event and so is propagated to the parent - // (b) under MSW it can be generated from kbd too - // (c) it uses screen coords (because of (a)) - wxContextMenuEvent evtCtx(wxEVT_CONTEXT_MENU, - win->GetId(), - win->ClientToScreen(event.GetPosition())); - (void)win->GetEventHandler()->ProcessEvent(evtCtx); - } - - if ( !g_captureWindow ) - win = FindWindowForMouseEvent(win, event.m_x, event.m_y); - - if (win->GetEventHandler()->ProcessEvent( event )) - { - gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "button_release_event" ); - return TRUE; - } - - return FALSE; -} - -//----------------------------------------------------------------------------- -// "motion_notify_event" -//----------------------------------------------------------------------------- - -static gint gtk_window_motion_notify_callback( GtkWidget *widget, - GdkEventMotion *gdk_event, - wxWindowGTK *win ) -{ - DEBUG_MAIN_THREAD - - if (g_isIdle) - wxapp_install_idle_handler(); - - if (!win->m_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; - int y = 0; - GdkModifierType state; - gdk_window_get_pointer(gdk_event->window, &x, &y, &state); - gdk_event->x = x; - gdk_event->y = y; - } - -/* - printf( "OnMotion from " ); - if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) - printf( win->GetClassInfo()->GetClassName() ); - printf( ".\n" ); -*/ - - wxMouseEvent event( wxEVT_MOTION ); - InitMouseEvent(win, event, gdk_event); - - if ( g_captureWindow ) - { - // synthetize a mouse enter or leave event if needed - GdkWindow *winUnderMouse = gdk_window_at_pointer(NULL, NULL); - // This seems to be necessary and actually been added to - // GDK itself in version 2.0.X - gdk_flush(); - - bool hasMouse = winUnderMouse == gdk_event->window; - if ( hasMouse != g_captureWindowHasMouse ) - { - // the mouse changed window - g_captureWindowHasMouse = hasMouse; - - wxMouseEvent event(g_captureWindowHasMouse ? wxEVT_ENTER_WINDOW - : wxEVT_LEAVE_WINDOW); - InitMouseEvent(win, event, gdk_event); - event.SetEventObject(win); - win->GetEventHandler()->ProcessEvent(event); - } - } - else // no capture - { - win = FindWindowForMouseEvent(win, event.m_x, event.m_y); - } - - if (win->GetEventHandler()->ProcessEvent( event )) - { - gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "motion_notify_event" ); - return TRUE; - } - - return FALSE; -} - -//----------------------------------------------------------------------------- -// "focus_in_event" -//----------------------------------------------------------------------------- - -// send the wxChildFocusEvent and wxFocusEvent, common code of -// gtk_window_focus_in_callback() and SetFocus() -static bool DoSendFocusEvents(wxWindow *win) -{ - // Notify the parent keeping track of focus for the kbd navigation - // purposes that we got it. - wxChildFocusEvent eventChildFocus(win); - (void)win->GetEventHandler()->ProcessEvent(eventChildFocus); - - wxFocusEvent eventFocus(wxEVT_SET_FOCUS, win->GetId()); - eventFocus.SetEventObject(win); - - return win->GetEventHandler()->ProcessEvent(eventFocus); -} - -static gint gtk_window_focus_in_callback( GtkWidget *widget, - GdkEvent *WXUNUSED(event), - wxWindow *win ) -{ - DEBUG_MAIN_THREAD - - if (g_isIdle) - wxapp_install_idle_handler(); - - if (!win->m_hasVMT) return FALSE; - if (g_blockEventsOnDrag) return FALSE; - - switch ( g_sendActivateEvent ) - { - case -1: - // we've got focus from outside, synthetize wxActivateEvent - g_sendActivateEvent = 1; - break; - - case 0: - // another our window just lost focus, it was already ours before - // - don't send any wxActivateEvent - g_sendActivateEvent = -1; - break; - } - - g_focusWindowLast = - g_focusWindow = win; - - wxLogTrace(TRACE_FOCUS, - _T("%s: focus in"), win->GetName().c_str()); - -#ifdef HAVE_XIM - if (win->m_ic) - gdk_im_begin(win->m_ic, win->m_wxwindow->window); -#endif - -#if wxUSE_CARET - // caret needs to be informed about focus change - wxCaret *caret = win->GetCaret(); - if ( caret ) - { - caret->OnSetFocus(); - } -#endif // wxUSE_CARET - - g_activeFrameLostFocus = FALSE; - - wxWindowGTK *active = wxGetTopLevelParent(win); - if ( active != g_activeFrame ) - { - if ( g_activeFrame ) - { - wxLogTrace(wxT("activate"), wxT("Deactivating frame %p (from focus_in)"), g_activeFrame); - wxActivateEvent event(wxEVT_ACTIVATE, FALSE, g_activeFrame->GetId()); - event.SetEventObject(g_activeFrame); - g_activeFrame->GetEventHandler()->ProcessEvent(event); - } - - wxLogTrace(wxT("activate"), wxT("Activating frame %p (from focus_in)"), active); - g_activeFrame = active; - wxActivateEvent event(wxEVT_ACTIVATE, TRUE, g_activeFrame->GetId()); - event.SetEventObject(g_activeFrame); - g_activeFrame->GetEventHandler()->ProcessEvent(event); - - // Don't send focus events in addition to activate - // if (win == g_activeFrame) - // return TRUE; - } - - // does the window itself think that it has the focus? - if ( !win->m_hasFocus ) - { - // not yet, notify it - win->m_hasFocus = TRUE; - - if ( DoSendFocusEvents(win) ) - { - gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "focus_in_event" ); - return TRUE; - } - } - - return FALSE; -} - -//----------------------------------------------------------------------------- -// "focus_out_event" -//----------------------------------------------------------------------------- - -static gint gtk_window_focus_out_callback( GtkWidget *widget, GdkEventFocus *gdk_event, wxWindowGTK *win ) -{ - DEBUG_MAIN_THREAD - - if (g_isIdle) - wxapp_install_idle_handler(); - - if (!win->m_hasVMT) return FALSE; - if (g_blockEventsOnDrag) return FALSE; - - wxLogTrace( TRACE_FOCUS, - _T("%s: focus out"), win->GetName().c_str() ); - - if ( !g_activeFrameLostFocus && g_activeFrame ) - { - // VZ: commenting this out because it does happen (although not easy - // to reproduce, I only see it when using wxMiniFrame and not - // always) and makes using Mahogany quite annoying -#if 0 - wxASSERT_MSG( wxGetTopLevelParent(win) == g_activeFrame, - wxT("unfocusing window that hasn't gained focus properly") ); -#endif // 0 - - g_activeFrameLostFocus = TRUE; - } - - // if the focus goes out of our app alltogether, OnIdle() will send - // wxActivateEvent, otherwise gtk_window_focus_in_callback() will reset - // g_sendActivateEvent to -1 - g_sendActivateEvent = 0; - - wxWindowGTK *winFocus = wxFindFocusedChild(win); - if ( winFocus ) - win = winFocus; - - g_focusWindow = (wxWindowGTK *)NULL; - -#ifdef HAVE_XIM - if (win->m_ic) - gdk_im_end(); -#endif - -#if wxUSE_CARET - // caret needs to be informed about focus change - wxCaret *caret = win->GetCaret(); - if ( caret ) - { - caret->OnKillFocus(); - } -#endif // wxUSE_CARET - - // don't send the window a kill focus event if it thinks that it doesn't - // have focus already - if ( win->m_hasFocus ) - { - win->m_hasFocus = FALSE; - - wxFocusEvent event( wxEVT_KILL_FOCUS, win->GetId() ); - event.SetEventObject( win ); - - if (win->GetEventHandler()->ProcessEvent( event )) - { - gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "focus_out_event" ); - return TRUE; - } - } - - return FALSE; -} - -//----------------------------------------------------------------------------- -// "enter_notify_event" -//----------------------------------------------------------------------------- - -static -gint gtk_window_enter_callback( GtkWidget *widget, - GdkEventCrossing *gdk_event, - wxWindowGTK *win ) -{ - DEBUG_MAIN_THREAD - - if (g_isIdle) - wxapp_install_idle_handler(); - - if (!win->m_hasVMT) return FALSE; - if (g_blockEventsOnDrag) return FALSE; - - // Event was emitted after a grab - if (gdk_event->mode != GDK_CROSSING_NORMAL) return FALSE; - - if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE; - - int x = 0; - int y = 0; - GdkModifierType state = (GdkModifierType)0; - - gdk_window_get_pointer( widget->window, &x, &y, &state ); - - wxMouseEvent event( wxEVT_ENTER_WINDOW ); - InitMouseEvent(win, event, gdk_event); - wxPoint pt = win->GetClientAreaOrigin(); - event.m_x = x + pt.x; - event.m_y = y + pt.y; - - if (win->GetEventHandler()->ProcessEvent( event )) - { - gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "enter_notify_event" ); - return TRUE; - } - - return FALSE; -} - -//----------------------------------------------------------------------------- -// "leave_notify_event" -//----------------------------------------------------------------------------- - -static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_event, wxWindowGTK *win ) -{ - DEBUG_MAIN_THREAD - - if (g_isIdle) - wxapp_install_idle_handler(); - - if (!win->m_hasVMT) return FALSE; - if (g_blockEventsOnDrag) return FALSE; - - // Event was emitted after an ungrab - if (gdk_event->mode != GDK_CROSSING_NORMAL) return FALSE; - - if (!win->IsOwnGtkWindow( gdk_event->window )) return FALSE; - - wxMouseEvent event( wxEVT_LEAVE_WINDOW ); - event.SetTimestamp( gdk_event->time ); - event.SetEventObject( win ); - - int x = 0; - int y = 0; - GdkModifierType state = (GdkModifierType)0; - - gdk_window_get_pointer( widget->window, &x, &y, &state ); - - event.m_shiftDown = (state & GDK_SHIFT_MASK) != 0; - event.m_controlDown = (state & GDK_CONTROL_MASK) != 0; - event.m_altDown = (state & GDK_MOD1_MASK) != 0; - event.m_metaDown = (state & GDK_MOD2_MASK) != 0; - event.m_leftDown = (state & GDK_BUTTON1_MASK) != 0; - event.m_middleDown = (state & GDK_BUTTON2_MASK) != 0; - event.m_rightDown = (state & GDK_BUTTON3_MASK) != 0; - - wxPoint pt = win->GetClientAreaOrigin(); - event.m_x = x + pt.x; - event.m_y = y + pt.y; - - if (win->GetEventHandler()->ProcessEvent( event )) - { - gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "leave_notify_event" ); - return TRUE; - } - - return FALSE; -} - -//----------------------------------------------------------------------------- -// "value_changed" from m_vAdjust -//----------------------------------------------------------------------------- - -static void gtk_window_vscroll_callback( GtkAdjustment *adjust, - SCROLLBAR_CBACK_ARG - wxWindowGTK *win ) -{ - DEBUG_MAIN_THREAD - - if (g_isIdle) - wxapp_install_idle_handler(); - - if (g_blockEventsOnDrag) return; - - if (!win->m_hasVMT) return; - - float diff = adjust->value - win->m_oldVerticalPos; - if (fabs(diff) < 0.2) return; - - win->m_oldVerticalPos = adjust->value; - -#ifndef __WXGTK20__ - GtkScrolledWindow *sw = GTK_SCROLLED_WINDOW(win->m_widget); -#endif - wxEventType command = GtkScrollWinTypeToWx(GET_SCROLL_TYPE(sw->vscrollbar)); - - int value = (int)(adjust->value+0.5); - - wxScrollWinEvent event( command, value, wxVERTICAL ); - event.SetEventObject( win ); - win->GetEventHandler()->ProcessEvent( event ); -} - -//----------------------------------------------------------------------------- -// "value_changed" from m_hAdjust -//----------------------------------------------------------------------------- - -static void gtk_window_hscroll_callback( GtkAdjustment *adjust, - SCROLLBAR_CBACK_ARG - wxWindowGTK *win ) -{ - DEBUG_MAIN_THREAD - - if (g_isIdle) - wxapp_install_idle_handler(); - - if (g_blockEventsOnDrag) return; - if (!win->m_hasVMT) return; - - float diff = adjust->value - win->m_oldHorizontalPos; - if (fabs(diff) < 0.2) return; - -#ifndef __WXGTK20__ - GtkScrolledWindow *sw = GTK_SCROLLED_WINDOW(win->m_widget); -#endif - wxEventType command = GtkScrollWinTypeToWx(GET_SCROLL_TYPE(sw->hscrollbar)); - - win->m_oldHorizontalPos = adjust->value; - - int value = (int)(adjust->value+0.5); - - wxScrollWinEvent event( command, value, wxHORIZONTAL ); - event.SetEventObject( win ); - win->GetEventHandler()->ProcessEvent( event ); -} - -//----------------------------------------------------------------------------- -// "button_press_event" from scrollbar -//----------------------------------------------------------------------------- - -static gint gtk_scrollbar_button_press_callback( GtkRange *widget, - GdkEventButton *gdk_event, - wxWindowGTK *win) -{ - DEBUG_MAIN_THREAD - - if (g_isIdle) - wxapp_install_idle_handler(); - - - g_blockEventsOnScroll = TRUE; - - // FIXME: there is no 'slider' field in GTK+ 2.0 any more -#ifndef __WXGTK20__ - win->m_isScrolling = (gdk_event->window == widget->slider); -#endif - - return FALSE; -} - -//----------------------------------------------------------------------------- -// "button_release_event" from scrollbar -//----------------------------------------------------------------------------- - -static gint gtk_scrollbar_button_release_callback( GtkRange *widget, - GdkEventButton *WXUNUSED(gdk_event), - wxWindowGTK *win) -{ - DEBUG_MAIN_THREAD - -// don't test here as we can release the mouse while being over -// a different window than the slider -// -// if (gdk_event->window != widget->slider) return FALSE; - - g_blockEventsOnScroll = FALSE; - - if (win->m_isScrolling) - { - wxEventType command = wxEVT_SCROLLWIN_THUMBRELEASE; - int value = -1; - int dir = -1; - - GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(win->m_widget); - if (widget == GTK_RANGE(scrolledWindow->hscrollbar)) - { - value = (int)(win->m_hAdjust->value+0.5); - dir = wxHORIZONTAL; - } - if (widget == GTK_RANGE(scrolledWindow->vscrollbar)) - { - value = (int)(win->m_vAdjust->value+0.5); - dir = wxVERTICAL; - } - - wxScrollWinEvent event( command, value, dir ); - event.SetEventObject( win ); - win->GetEventHandler()->ProcessEvent( event ); - } - - win->m_isScrolling = FALSE; - - return FALSE; -} - -// ---------------------------------------------------------------------------- -// this wxWindowBase function is implemented here (in platform-specific file) -// because it is static and so couldn't be made virtual -// ---------------------------------------------------------------------------- - -wxWindow *wxWindowBase::FindFocus() -{ - // the cast is necessary when we compile in wxUniversal mode - return (wxWindow *)g_focusWindow; -} - -//----------------------------------------------------------------------------- -// "destroy" event -//----------------------------------------------------------------------------- - -// VZ: Robert commented the code using out so it generates warnings: should -// be either fixed or removed completely -#if 0 - -static void gtk_window_destroy_callback( GtkWidget* widget, wxWindow *win ) -{ - wxWindowDestroyEvent event(win); - win->GetEventHandler()->ProcessEvent(event); -} - -#endif // 0 - -//----------------------------------------------------------------------------- -// "realize" from m_widget -//----------------------------------------------------------------------------- - -/* We cannot set colours and fonts before the widget has - been realized, so we do this directly after realization. */ - -static gint -gtk_window_realized_callback( GtkWidget *m_widget, wxWindow *win ) -{ - DEBUG_MAIN_THREAD - - if (g_isIdle) - wxapp_install_idle_handler(); - - if (win->m_delayedBackgroundColour && !win->GetThemeEnabled()) - win->GtkSetBackgroundColour( win->GetBackgroundColour() ); - - if (win->m_delayedForegroundColour && !win->GetThemeEnabled()) - win->GtkSetForegroundColour( win->GetForegroundColour() ); - -#ifdef __WXGTK20__ - if (win->m_imContext) - { - GtkPizza *pizza = GTK_PIZZA( m_widget ); - gtk_im_context_set_client_window( (GtkIMContext*) win->m_imContext, pizza->bin_window ); - } -#endif - - wxWindowCreateEvent event( win ); - event.SetEventObject( win ); - win->GetEventHandler()->ProcessEvent( event ); - - return FALSE; -} - -//----------------------------------------------------------------------------- -// "size_allocate" -//----------------------------------------------------------------------------- - -static -void gtk_window_size_callback( GtkWidget *WXUNUSED(widget), - GtkAllocation *WXUNUSED(alloc), - wxWindow *win ) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - - if (!win->m_hasScrolling) return; - - int client_width = 0; - int client_height = 0; - win->GetClientSize( &client_width, &client_height ); - if ((client_width == win->m_oldClientWidth) && (client_height == win->m_oldClientHeight)) - return; - - win->m_oldClientWidth = client_width; - win->m_oldClientHeight = client_height; - - if (!win->m_nativeSizeEvent) - { - wxSizeEvent event( win->GetSize(), win->GetId() ); - event.SetEventObject( win ); - win->GetEventHandler()->ProcessEvent( event ); - } -} - - -#ifdef HAVE_XIM - #define WXUNUSED_UNLESS_XIM(param) param -#else - #define WXUNUSED_UNLESS_XIM(param) WXUNUSED(param) -#endif - -/* Resize XIM window */ - -static -void gtk_wxwindow_size_callback( GtkWidget* WXUNUSED_UNLESS_XIM(widget), - GtkAllocation* WXUNUSED_UNLESS_XIM(alloc), - wxWindowGTK* WXUNUSED_UNLESS_XIM(win) ) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - -#ifdef HAVE_XIM - if (!win->m_ic) - return; - - if (gdk_ic_get_style (win->m_ic) & GDK_IM_PREEDIT_POSITION) - { - gint width, height; - - gdk_window_get_size (widget->window, &width, &height); - win->m_icattr->preedit_area.width = width; - win->m_icattr->preedit_area.height = height; - gdk_ic_set_attr (win->m_ic, win->m_icattr, GDK_IC_PREEDIT_AREA); - } -#endif // HAVE_XIM -} - -//----------------------------------------------------------------------------- -// "realize" from m_wxwindow -//----------------------------------------------------------------------------- - -/* Initialize XIM support */ - -static gint -gtk_wxwindow_realized_callback( GtkWidget * WXUNUSED_UNLESS_XIM(widget), - wxWindowGTK * WXUNUSED_UNLESS_XIM(win) ) -{ - if (g_isIdle) - wxapp_install_idle_handler(); - -#ifdef HAVE_XIM - if (win->m_ic) return FALSE; - if (!widget) return FALSE; - if (!gdk_im_ready()) return FALSE; - - win->m_icattr = gdk_ic_attr_new(); - if (!win->m_icattr) return FALSE; - - gint width, height; - GdkEventMask mask; - GdkColormap *colormap; - GdkICAttr *attr = win->m_icattr; - unsigned attrmask = GDK_IC_ALL_REQ; - GdkIMStyle style; - GdkIMStyle supported_style = (GdkIMStyle) - (GDK_IM_PREEDIT_NONE | - GDK_IM_PREEDIT_NOTHING | - GDK_IM_PREEDIT_POSITION | - GDK_IM_STATUS_NONE | - GDK_IM_STATUS_NOTHING); - - if (widget->style && widget->style->font->type != GDK_FONT_FONTSET) - supported_style = (GdkIMStyle)(supported_style & ~GDK_IM_PREEDIT_POSITION); - - attr->style = style = gdk_im_decide_style (supported_style); - attr->client_window = widget->window; - - if ((colormap = gtk_widget_get_colormap (widget)) != - gtk_widget_get_default_colormap ()) - { - attrmask |= GDK_IC_PREEDIT_COLORMAP; - attr->preedit_colormap = colormap; - } - - attrmask |= GDK_IC_PREEDIT_FOREGROUND; - attrmask |= GDK_IC_PREEDIT_BACKGROUND; - attr->preedit_foreground = widget->style->fg[GTK_STATE_NORMAL]; - attr->preedit_background = widget->style->base[GTK_STATE_NORMAL]; - - switch (style & GDK_IM_PREEDIT_MASK) - { - case GDK_IM_PREEDIT_POSITION: - if (widget->style && widget->style->font->type != GDK_FONT_FONTSET) - { - g_warning ("over-the-spot style requires fontset"); - break; - } - - gdk_window_get_size (widget->window, &width, &height); - - attrmask |= GDK_IC_PREEDIT_POSITION_REQ; - attr->spot_location.x = 0; - attr->spot_location.y = height; - attr->preedit_area.x = 0; - attr->preedit_area.y = 0; - attr->preedit_area.width = width; - attr->preedit_area.height = height; - attr->preedit_fontset = widget->style->font; - - break; - } - - win->m_ic = gdk_ic_new (attr, (GdkICAttributesType)attrmask); - - if (win->m_ic == NULL) - g_warning ("Can't create input context."); - else - { - mask = gdk_window_get_events (widget->window); - mask = (GdkEventMask)(mask | gdk_ic_get_events (win->m_ic)); - gdk_window_set_events (widget->window, mask); - - if (GTK_WIDGET_HAS_FOCUS(widget)) - gdk_im_begin (win->m_ic, widget->window); - } -#endif // HAVE_XIM - - return FALSE; -} - -//----------------------------------------------------------------------------- -// InsertChild for wxWindowGTK. -//----------------------------------------------------------------------------- - -/* Callback for wxWindowGTK. This very strange beast has to be used because - * C++ has no virtual methods in a constructor. We have to emulate a - * virtual function here as wxNotebook requires a different way to insert - * a child in it. I had opted for creating a wxNotebookPage window class - * which would have made this superfluous (such in the MDI window system), - * but no-one was listening to me... */ - -static void wxInsertChildInWindow( wxWindowGTK* parent, wxWindowGTK* child ) -{ - /* the window might have been scrolled already, do we - have to adapt the position */ - GtkPizza *pizza = GTK_PIZZA(parent->m_wxwindow); - child->m_x += pizza->xoffset; - child->m_y += pizza->yoffset; - - gtk_pizza_put( GTK_PIZZA(parent->m_wxwindow), - GTK_WIDGET(child->m_widget), - child->m_x, - child->m_y, - child->m_width, - child->m_height ); -} - -//----------------------------------------------------------------------------- -// global functions -//----------------------------------------------------------------------------- - -wxWindow *wxGetActiveWindow() -{ - return wxWindow::FindFocus(); -} - -//----------------------------------------------------------------------------- -// wxWindowGTK -//----------------------------------------------------------------------------- - -// in wxUniv/MSW this class is abstract because it doesn't have DoPopupMenu() -// method -#ifdef __WXUNIVERSAL__ - IMPLEMENT_ABSTRACT_CLASS(wxWindowGTK, wxWindowBase) -#else // __WXGTK__ - IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase) -#endif // __WXUNIVERSAL__/__WXGTK__ - -void wxWindowGTK::Init() -{ - // common init - InitBase(); - - // GTK specific - m_widget = (GtkWidget *) NULL; - m_wxwindow = (GtkWidget *) NULL; - m_focusWidget = (GtkWidget *) NULL; - - // position/size - m_x = 0; - m_y = 0; - m_width = 0; - m_height = 0; - - m_sizeSet = FALSE; - m_hasVMT = FALSE; - m_needParent = TRUE; - m_isBeingDeleted = FALSE; - - m_noExpose = FALSE; - m_nativeSizeEvent = FALSE; - - m_hasScrolling = FALSE; - m_isScrolling = FALSE; - - m_hAdjust = (GtkAdjustment*) NULL; - m_vAdjust = (GtkAdjustment*) NULL; - m_oldHorizontalPos = 0.0; - m_oldVerticalPos = 0.0; - - m_resizing = FALSE; - m_widgetStyle = (GtkStyle*) NULL; - - m_insertCallback = (wxInsertChildFunction) NULL; - - m_acceptsFocus = FALSE; - m_hasFocus = FALSE; - - m_clipPaintRegion = FALSE; - - m_cursor = *wxSTANDARD_CURSOR; - - m_delayedForegroundColour = FALSE; - m_delayedBackgroundColour = FALSE; - - m_oldClientWidth = 0; - m_oldClientHeight = 0; - -#ifdef __WXGTK20__ - m_imContext = NULL; - m_x11Context = NULL; -#else -#ifdef HAVE_XIM - m_ic = (GdkIC*) NULL; - m_icattr = (GdkICAttr*) NULL; -#endif -#endif -} - -wxWindowGTK::wxWindowGTK() -{ - Init(); -} - -wxWindowGTK::wxWindowGTK( wxWindow *parent, - wxWindowID id, - const wxPoint &pos, - const wxSize &size, - long style, - const wxString &name ) -{ - Init(); - - Create( parent, id, pos, size, style, name ); -} - -bool wxWindowGTK::Create( wxWindow *parent, - wxWindowID id, - const wxPoint &pos, - const wxSize &size, - long style, - const wxString &name ) -{ - if (!PreCreation( parent, pos, size ) || - !CreateBase( parent, id, pos, size, style, wxDefaultValidator, name )) - { - wxFAIL_MSG( wxT("wxWindowGTK creation failed") ); - return FALSE; - } - - m_insertCallback = wxInsertChildInWindow; - - // always needed for background clearing - m_delayedBackgroundColour = TRUE; - - m_widget = gtk_scrolled_window_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL ); - GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS ); - - GtkScrolledWindow *scrolledWindow = GTK_SCROLLED_WINDOW(m_widget); - - GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT_GET_CLASS(m_widget) ); - scroll_class->scrollbar_spacing = 0; - - gtk_scrolled_window_set_policy( scrolledWindow, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC ); - - m_hAdjust = gtk_range_get_adjustment( GTK_RANGE(scrolledWindow->hscrollbar) ); - m_vAdjust = gtk_range_get_adjustment( GTK_RANGE(scrolledWindow->vscrollbar) ); - - m_wxwindow = gtk_pizza_new(); - -#ifndef __WXUNIVERSAL__ - GtkPizza *pizza = GTK_PIZZA(m_wxwindow); - - if (HasFlag(wxRAISED_BORDER)) - { - gtk_pizza_set_shadow_type( pizza, GTK_MYSHADOW_OUT ); - } - else if (HasFlag(wxSUNKEN_BORDER)) - { - gtk_pizza_set_shadow_type( pizza, GTK_MYSHADOW_IN ); - } - else if (HasFlag(wxSIMPLE_BORDER)) - { - gtk_pizza_set_shadow_type( pizza, GTK_MYSHADOW_THIN ); - } - else - { - gtk_pizza_set_shadow_type( pizza, GTK_MYSHADOW_NONE ); - } -#endif // __WXUNIVERSAL__ - - gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow ); - - GTK_WIDGET_SET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); - m_acceptsFocus = TRUE; - - // I _really_ don't want scrollbars in the beginning - m_vAdjust->lower = 0.0; - m_vAdjust->upper = 1.0; - m_vAdjust->value = 0.0; - m_vAdjust->step_increment = 1.0; - m_vAdjust->page_increment = 1.0; - m_vAdjust->page_size = 5.0; - gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "changed" ); - m_hAdjust->lower = 0.0; - m_hAdjust->upper = 1.0; - m_hAdjust->value = 0.0; - m_hAdjust->step_increment = 1.0; - m_hAdjust->page_increment = 1.0; - m_hAdjust->page_size = 5.0; - gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "changed" ); - - // these handlers block mouse events to any window during scrolling such as - // motion events and prevent GTK and wxWindows from fighting over where the - // slider should be - - gtk_signal_connect( GTK_OBJECT(scrolledWindow->vscrollbar), "button_press_event", - (GtkSignalFunc)gtk_scrollbar_button_press_callback, (gpointer) this ); - - gtk_signal_connect( GTK_OBJECT(scrolledWindow->hscrollbar), "button_press_event", - (GtkSignalFunc)gtk_scrollbar_button_press_callback, (gpointer) this ); - - gtk_signal_connect( GTK_OBJECT(scrolledWindow->vscrollbar), "button_release_event", - (GtkSignalFunc)gtk_scrollbar_button_release_callback, (gpointer) this ); - - gtk_signal_connect( GTK_OBJECT(scrolledWindow->hscrollbar), "button_release_event", - (GtkSignalFunc)gtk_scrollbar_button_release_callback, (gpointer) this ); - - // these handlers get notified when screen updates are required either when - // scrolling or when the window size (and therefore scrollbar configuration) - // has changed - - gtk_signal_connect( GTK_OBJECT(m_hAdjust), "value_changed", - (GtkSignalFunc) gtk_window_hscroll_callback, (gpointer) this ); - gtk_signal_connect( GTK_OBJECT(m_vAdjust), "value_changed", - (GtkSignalFunc) gtk_window_vscroll_callback, (gpointer) this ); - -#ifdef __WXGTK20__ - // Create input method handler - m_imContext = (GtkIMMulticontext*) gtk_im_multicontext_new (); - - // Cannot handle drawing preedited text yet - gtk_im_context_set_use_preedit( (GtkIMContext*) m_imContext, FALSE ); - - g_signal_connect (G_OBJECT (m_imContext), "commit", - G_CALLBACK (gtk_wxwindow_commit_cb), this); -#endif - - gtk_widget_show( m_wxwindow ); - - if (m_parent) - m_parent->DoAddChild( this ); - - m_focusWidget = m_wxwindow; - - PostCreation(); - - Show( TRUE ); - - return TRUE; -} - -wxWindowGTK::~wxWindowGTK() -{ - // Send destroy event - wxWindowDestroyEvent destroyEvent((wxWindow*) this); - destroyEvent.SetId(GetId()); - GetEventHandler()->ProcessEvent(destroyEvent); - - if (g_focusWindow == this) - g_focusWindow = NULL; - - if (g_activeFrame == this) - g_activeFrame = NULL; - - if ( g_delayedFocus == this ) - g_delayedFocus = NULL; - - m_isBeingDeleted = TRUE; - m_hasVMT = FALSE; - - if (m_widget) - Show( FALSE ); - - DestroyChildren(); - - if (m_parent) - m_parent->RemoveChild( this ); - -#ifdef HAVE_XIM - if (m_ic) - gdk_ic_destroy (m_ic); - if (m_icattr) - gdk_ic_attr_destroy (m_icattr); -#endif - - if (m_widgetStyle) - { -#if DISABLE_STYLE_IF_BROKEN_THEME - // don't delete if it's a pixmap theme style - if (!m_widgetStyle->engine_data) - gtk_style_unref( m_widgetStyle ); -#endif - m_widgetStyle = (GtkStyle*) NULL; - } - - if (m_wxwindow) - { - gtk_widget_destroy( m_wxwindow ); - m_wxwindow = (GtkWidget*) NULL; - } - - if (m_widget) - { - gtk_widget_destroy( m_widget ); - m_widget = (GtkWidget*) NULL; - } -} - -bool wxWindowGTK::PreCreation( wxWindowGTK *parent, const wxPoint &pos, const wxSize &size ) -{ - wxCHECK_MSG( !m_needParent || parent, FALSE, wxT("Need complete parent.") ); - - // This turns -1 into 30 so that a minimal window is - // visible even although -1,-1 has been given as the - // size of the window. the same trick is used in other - // ports and should make debugging easier. - m_width = WidthDefault(size.x) ; - m_height = HeightDefault(size.y); - - m_x = (int)pos.x; - m_y = (int)pos.y; - - // some reasonable defaults - if (!parent) - { - if (m_x == -1) - { - m_x = (gdk_screen_width () - m_width) / 2; - if (m_x < 10) m_x = 10; - } - if (m_y == -1) - { - m_y = (gdk_screen_height () - m_height) / 2; - if (m_y < 10) m_y = 10; - } - } - - return TRUE; -} - -void wxWindowGTK::PostCreation() -{ - wxASSERT_MSG( (m_widget != NULL), wxT("invalid window") ); - - if (m_wxwindow) - { - if (!m_noExpose) - { - // these get reported to wxWindows -> wxPaintEvent - - gtk_pizza_set_external( GTK_PIZZA(m_wxwindow), TRUE ); - - gtk_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event", - GTK_SIGNAL_FUNC(gtk_window_expose_callback), (gpointer)this ); - -#ifndef __WXGTK20__ - gtk_signal_connect( GTK_OBJECT(m_wxwindow), "draw", - GTK_SIGNAL_FUNC(gtk_window_draw_callback), (gpointer)this ); - - if (HasFlag(wxNO_FULL_REPAINT_ON_RESIZE)) - { - gtk_signal_connect( GTK_OBJECT(m_wxwindow), "event", - GTK_SIGNAL_FUNC(gtk_window_event_event_callback), (gpointer)this ); - } -#else - // gtk_widget_set_redraw_on_allocate( GTK_WIDGET(m_wxwindow), HasFlag( wxNO_FULL_REPAINT_ON_RESIZE ) ); -#endif - -#ifdef __WXGTK20__ - // Create input method handler - m_imContext = (GtkIMMulticontext*) gtk_im_multicontext_new (); - - // Cannot handle drawing preedited text yet - gtk_im_context_set_use_preedit( (GtkIMContext*) m_imContext, FALSE ); - - g_signal_connect (G_OBJECT (m_imContext), "commit", - G_CALLBACK (gtk_wxwindow_commit_cb), this); -#endif - } - - // 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 ); - -#ifndef __WXGTK20__ - gtk_signal_connect( GTK_OBJECT(m_widget), "draw", - GTK_SIGNAL_FUNC(gtk_window_own_draw_callback), (gpointer)this ); -#endif - } - - // focus handling - - if (m_focusWidget == NULL) - m_focusWidget = m_widget; - - gtk_signal_connect( GTK_OBJECT(m_focusWidget), "focus_in_event", - GTK_SIGNAL_FUNC(gtk_window_focus_in_callback), (gpointer)this ); - - gtk_signal_connect( GTK_OBJECT(m_focusWidget), "focus_out_event", - GTK_SIGNAL_FUNC(gtk_window_focus_out_callback), (gpointer)this ); - - // connect to the various key and mouse handlers - - GtkWidget *connect_widget = GetConnectWidget(); - - ConnectWidget( connect_widget ); - - /* We cannot set colours, fonts and cursors before the widget has - been realized, so we do this directly after realization */ - gtk_signal_connect( GTK_OBJECT(connect_widget), "realize", - GTK_SIGNAL_FUNC(gtk_window_realized_callback), (gpointer) this ); - - if (m_wxwindow) - { - // Catch native resize events - gtk_signal_connect( GTK_OBJECT(m_wxwindow), "size_allocate", - GTK_SIGNAL_FUNC(gtk_window_size_callback), (gpointer)this ); - - // Initialize XIM support - gtk_signal_connect( GTK_OBJECT(m_wxwindow), "realize", - GTK_SIGNAL_FUNC(gtk_wxwindow_realized_callback), (gpointer) this ); - - // And resize XIM window - gtk_signal_connect( GTK_OBJECT(m_wxwindow), "size_allocate", - GTK_SIGNAL_FUNC(gtk_wxwindow_size_callback), (gpointer)this ); - } - - if (!GTK_IS_COMBO(m_widget)) - { - // This is needed if we want to add our windows into native - // GTK control, such as the toolbar. With this callback, the - // toolbar gets to know the correct size (the one set by the - // programmer). Sadly, it misbehaves for wxComboBox. FIXME - // when moving to GTK 2.0. - gtk_signal_connect( GTK_OBJECT(m_widget), "size_request", - GTK_SIGNAL_FUNC(gtk_window_size_request_callback), (gpointer) this ); - } - - m_hasVMT = TRUE; -} - -void wxWindowGTK::ConnectWidget( GtkWidget *widget ) -{ - gtk_signal_connect( GTK_OBJECT(widget), "key_press_event", - GTK_SIGNAL_FUNC(gtk_window_key_press_callback), (gpointer)this ); - - gtk_signal_connect( GTK_OBJECT(widget), "key_release_event", - GTK_SIGNAL_FUNC(gtk_window_key_release_callback), (gpointer)this ); - - gtk_signal_connect( GTK_OBJECT(widget), "button_press_event", - GTK_SIGNAL_FUNC(gtk_window_button_press_callback), (gpointer)this ); - - gtk_signal_connect( GTK_OBJECT(widget), "button_release_event", - GTK_SIGNAL_FUNC(gtk_window_button_release_callback), (gpointer)this ); - - gtk_signal_connect( GTK_OBJECT(widget), "motion_notify_event", - GTK_SIGNAL_FUNC(gtk_window_motion_notify_callback), (gpointer)this ); - - gtk_signal_connect( GTK_OBJECT(widget), "enter_notify_event", - GTK_SIGNAL_FUNC(gtk_window_enter_callback), (gpointer)this ); - - gtk_signal_connect( GTK_OBJECT(widget), "leave_notify_event", - GTK_SIGNAL_FUNC(gtk_window_leave_callback), (gpointer)this ); - - // This keeps crashing on me. RR. - // - // gtk_signal_connect( GTK_OBJECT(widget), "destroy", - // GTK_SIGNAL_FUNC(gtk_window_destroy_callback), (gpointer)this ); -} - -bool wxWindowGTK::Destroy() -{ - wxASSERT_MSG( (m_widget != NULL), wxT("invalid window") ); - - m_hasVMT = FALSE; - - return wxWindowBase::Destroy(); -} - -void wxWindowGTK::DoMoveWindow(int x, int y, int width, int height) -{ - gtk_pizza_set_size( GTK_PIZZA(m_parent->m_wxwindow), m_widget, x, y, width, height ); -} - -void wxWindowGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags ) -{ - wxASSERT_MSG( (m_widget != NULL), wxT("invalid window") ); - wxASSERT_MSG( (m_parent != NULL), wxT("wxWindowGTK::SetSize requires parent.\n") ); - -/* - printf( "DoSetSize: name %s, x,y,w,h: %d,%d,%d,%d \n", GetName().c_str(), x,y,width,height ); -*/ - - if (m_resizing) return; /* I don't like recursions */ - m_resizing = TRUE; - - int currentX, currentY; - GetPosition(¤tX, ¤tY); - if (x == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) - x = currentX; - if (y == -1 && !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) - y = currentY; - AdjustForParentClientOrigin(x, y, sizeFlags); - - if (m_parent->m_wxwindow == NULL) /* i.e. wxNotebook */ - { - /* don't set the size for children of wxNotebook, just take the values. */ - m_x = x; - m_y = y; - m_width = width; - m_height = height; - } - else - { - GtkPizza *pizza = GTK_PIZZA(m_parent->m_wxwindow); - if ((sizeFlags & wxSIZE_ALLOW_MINUS_ONE) == 0) - { - if (x != -1) m_x = x + pizza->xoffset; - if (y != -1) m_y = y + pizza->yoffset; - } - else - { - m_x = x + pizza->xoffset; - m_y = y + pizza->yoffset; - } - if (width != -1) m_width = width; - if (height != -1) m_height = height; - - if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH) - { - if (width == -1) m_width = 80; - } - - if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT) - { - if (height == -1) m_height = 26; - } - - int minWidth = GetMinWidth(), - minHeight = GetMinHeight(), - maxWidth = GetMaxWidth(), - maxHeight = GetMaxHeight(); - - if ((minWidth != -1) && (m_width < minWidth)) m_width = minWidth; - if ((minHeight != -1) && (m_height < minHeight)) m_height = minHeight; - if ((maxWidth != -1) && (m_width > maxWidth)) m_width = maxWidth; - if ((maxHeight != -1) && (m_height > maxHeight)) m_height = maxHeight; - - int border = 0; - int bottom_border = 0; - -#ifndef __WXGTK20__ - if (GTK_WIDGET_CAN_DEFAULT(m_widget)) - { - /* the default button has a border around it */ - border = 6; - bottom_border = 5; - } -#endif - - DoMoveWindow( m_x-border, - m_y-border, - m_width+2*border, - m_height+border+bottom_border ); - } - - if (m_hasScrolling) - { - /* Sometimes the client area changes size without the - whole windows's size changing, but if the whole - windows's size doesn't change, no wxSizeEvent will - normally be sent. Here we add an extra test if - the client test has been changed and this will - be used then. */ - GetClientSize( &m_oldClientWidth, &m_oldClientHeight ); - } - -/* - wxPrintf( "OnSize sent from " ); - if (GetClassInfo() && GetClassInfo()->GetClassName()) - wxPrintf( GetClassInfo()->GetClassName() ); - wxPrintf( " %d %d %d %d\n", (int)m_x, (int)m_y, (int)m_width, (int)m_height ); -*/ - - if (!m_nativeSizeEvent) - { - wxSizeEvent event( wxSize(m_width,m_height), GetId() ); - event.SetEventObject( this ); - GetEventHandler()->ProcessEvent( event ); - } - - m_resizing = FALSE; -} - -void wxWindowGTK::OnInternalIdle() -{ - // Update invalidated regions. - GtkUpdate(); - - // Synthetize activate events. - if ( g_sendActivateEvent != -1 ) - { - bool activate = g_sendActivateEvent != 0; - - // do it only once - g_sendActivateEvent = -1; - - wxTheApp->SetActive(activate, (wxWindow *)g_focusWindowLast); - } - - if ( g_activeFrameLostFocus ) - { - if ( g_activeFrame ) - { - wxLogTrace(wxT("activate"), wxT("Deactivating frame %p (from idle)"), g_activeFrame); - wxActivateEvent event(wxEVT_ACTIVATE, FALSE, g_activeFrame->GetId()); - event.SetEventObject(g_activeFrame); - g_activeFrame->GetEventHandler()->ProcessEvent(event); - g_activeFrame = NULL; - } - g_activeFrameLostFocus = FALSE; - } - - wxCursor cursor = m_cursor; - if (g_globalCursor.Ok()) cursor = g_globalCursor; - - if (cursor.Ok()) - { - // We now set the cursor anew in every OnInternalIdle call - // as setting the cursor in a parent window also effects the - // windows above so that checking for the current cursor is - // not possible. - - if (m_wxwindow) - { - GdkWindow *window = GTK_PIZZA(m_wxwindow)->bin_window; - if (window) - gdk_window_set_cursor( window, cursor.GetCursor() ); - - if (!g_globalCursor.Ok()) - cursor = *wxSTANDARD_CURSOR; - - window = m_widget->window; - if ((window) && !(GTK_WIDGET_NO_WINDOW(m_widget))) - gdk_window_set_cursor( window, cursor.GetCursor() ); - - } - else - { - - GdkWindow *window = m_widget->window; - if ((window) && !(GTK_WIDGET_NO_WINDOW(m_widget))) - gdk_window_set_cursor( window, cursor.GetCursor() ); - - } - } - - UpdateWindowUI(); -} - -void wxWindowGTK::DoGetSize( int *width, int *height ) const -{ - wxCHECK_RET( (m_widget != NULL), wxT("invalid window") ); - - if (width) (*width) = m_width; - if (height) (*height) = m_height; -} - -void wxWindowGTK::DoSetClientSize( int width, int height ) -{ - wxCHECK_RET( (m_widget != NULL), wxT("invalid window") ); - - if (!m_wxwindow) - { - SetSize( width, height ); - } - else - { - int dw = 0; - int dh = 0; - -#ifndef __WXUNIVERSAL__ - if (HasFlag(wxRAISED_BORDER) || HasFlag(wxSUNKEN_BORDER)) - { - /* when using GTK 1.2 we set the shadow border size to 2 */ - dw += 2 * 2; - dh += 2 * 2; - } - if (HasFlag(wxSIMPLE_BORDER)) - { - /* when using GTK 1.2 we set the simple border size to 1 */ - dw += 1 * 2; - dh += 1 * 2; - } -#endif // __WXUNIVERSAL__ - - if (m_hasScrolling) - { - GtkScrolledWindow *scroll_window = GTK_SCROLLED_WINDOW(m_widget); - - GtkRequisition vscroll_req; - vscroll_req.width = 2; - vscroll_req.height = 2; - (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(scroll_window->vscrollbar) )->size_request ) - (scroll_window->vscrollbar, &vscroll_req ); - - GtkRequisition hscroll_req; - hscroll_req.width = 2; - hscroll_req.height = 2; - (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(scroll_window->hscrollbar) )->size_request ) - (scroll_window->hscrollbar, &hscroll_req ); - - GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT_GET_CLASS(m_widget) ); - - if (scroll_window->vscrollbar_visible) - { - dw += vscroll_req.width; - dw += scroll_class->scrollbar_spacing; - } - - if (scroll_window->hscrollbar_visible) - { - dh += hscroll_req.height; - dh += scroll_class->scrollbar_spacing; - } - } - - SetSize( width+dw, height+dh ); - } -} - -void wxWindowGTK::DoGetClientSize( int *width, int *height ) const -{ - wxCHECK_RET( (m_widget != NULL), wxT("invalid window") ); - - if (!m_wxwindow) - { - if (width) (*width) = m_width; - if (height) (*height) = m_height; - } - else - { - int dw = 0; - int dh = 0; - -#ifndef __WXUNIVERSAL__ - if (HasFlag(wxRAISED_BORDER) || HasFlag(wxSUNKEN_BORDER)) - { - /* when using GTK 1.2 we set the shadow border size to 2 */ - dw += 2 * 2; - dh += 2 * 2; - } - if (HasFlag(wxSIMPLE_BORDER)) - { - /* when using GTK 1.2 we set the simple border size to 1 */ - dw += 1 * 2; - dh += 1 * 2; - } -#endif // __WXUNIVERSAL__ - - if (m_hasScrolling) - { - GtkScrolledWindow *scroll_window = GTK_SCROLLED_WINDOW(m_widget); - - GtkRequisition vscroll_req; - vscroll_req.width = 2; - vscroll_req.height = 2; - (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(scroll_window->vscrollbar) )->size_request ) - (scroll_window->vscrollbar, &vscroll_req ); - - GtkRequisition hscroll_req; - hscroll_req.width = 2; - hscroll_req.height = 2; - (* GTK_WIDGET_CLASS( GTK_OBJECT_GET_CLASS(scroll_window->hscrollbar) )->size_request ) - (scroll_window->hscrollbar, &hscroll_req ); - - GtkScrolledWindowClass *scroll_class = GTK_SCROLLED_WINDOW_CLASS( GTK_OBJECT_GET_CLASS(m_widget) ); - - if (scroll_window->vscrollbar_visible) - { - dw += vscroll_req.width; - dw += scroll_class->scrollbar_spacing; - } - - if (scroll_window->hscrollbar_visible) - { - dh += hscroll_req.height; - dh += scroll_class->scrollbar_spacing; - } - } - - if (width) (*width) = m_width - dw; - if (height) (*height) = m_height - dh; - } - -/* - printf( "GetClientSize, name %s ", GetName().c_str() ); - if (width) printf( " width = %d", (*width) ); - if (height) printf( " height = %d", (*height) ); - printf( "\n" ); -*/ -} - -void wxWindowGTK::DoGetPosition( int *x, int *y ) const -{ - wxCHECK_RET( (m_widget != NULL), wxT("invalid window") ); - - int dx = 0; - int dy = 0; - if (m_parent && m_parent->m_wxwindow) - { - GtkPizza *pizza = GTK_PIZZA(m_parent->m_wxwindow); - dx = pizza->xoffset; - dy = pizza->yoffset; - } - - if (x) (*x) = m_x - dx; - if (y) (*y) = m_y - dy; -} - -void wxWindowGTK::DoClientToScreen( int *x, int *y ) const -{ - wxCHECK_RET( (m_widget != NULL), wxT("invalid window") ); - - if (!m_widget->window) return; - - GdkWindow *source = (GdkWindow *) NULL; - if (m_wxwindow) - source = GTK_PIZZA(m_wxwindow)->bin_window; - else - source = m_widget->window; - - int org_x = 0; - int org_y = 0; - gdk_window_get_origin( source, &org_x, &org_y ); - - if (!m_wxwindow) - { - if (GTK_WIDGET_NO_WINDOW (m_widget)) - { - org_x += m_widget->allocation.x; - org_y += m_widget->allocation.y; - } - } - - if (x) *x += org_x; - if (y) *y += org_y; -} - -void wxWindowGTK::DoScreenToClient( int *x, int *y ) const -{ - wxCHECK_RET( (m_widget != NULL), wxT("invalid window") ); - - if (!m_widget->window) return; - - GdkWindow *source = (GdkWindow *) NULL; - if (m_wxwindow) - source = GTK_PIZZA(m_wxwindow)->bin_window; - else - source = m_widget->window; - - int org_x = 0; - int org_y = 0; - gdk_window_get_origin( source, &org_x, &org_y ); - - if (!m_wxwindow) - { - if (GTK_WIDGET_NO_WINDOW (m_widget)) - { - org_x += m_widget->allocation.x; - org_y += m_widget->allocation.y; - } - } - - if (x) *x -= org_x; - if (y) *y -= org_y; -} - -bool wxWindowGTK::Show( bool show ) -{ - wxCHECK_MSG( (m_widget != NULL), FALSE, wxT("invalid window") ); - - if (!wxWindowBase::Show(show)) - { - // nothing to do - return FALSE; - } - - if (show) - gtk_widget_show( m_widget ); - else - gtk_widget_hide( m_widget ); - - wxShowEvent eventShow(GetId(), show); - eventShow.m_eventObject = this; - - GetEventHandler()->ProcessEvent(eventShow); - - return TRUE; -} - -static void wxWindowNotifyEnable(wxWindowGTK* win, bool enable) -{ - win->OnParentEnable(enable); - - // Recurse, so that children have the opportunity to Do The Right Thing - // and reset colours that have been messed up by a parent's (really ancestor's) - // Enable call - for ( wxWindowList::Node *node = win->GetChildren().GetFirst(); - node; - node = node->GetNext() ) - { - wxWindow *child = node->GetData(); - if (!child->IsKindOf(CLASSINFO(wxDialog)) && !child->IsKindOf(CLASSINFO(wxFrame))) - wxWindowNotifyEnable(child, enable); - } -} - -bool wxWindowGTK::Enable( bool enable ) -{ - wxCHECK_MSG( (m_widget != NULL), FALSE, wxT("invalid window") ); - - if (!wxWindowBase::Enable(enable)) - { - // nothing to do - return FALSE; - } - - gtk_widget_set_sensitive( m_widget, enable ); - if ( m_wxwindow ) - gtk_widget_set_sensitive( m_wxwindow, enable ); - - wxWindowNotifyEnable(this, enable); - - return TRUE; -} - -int wxWindowGTK::GetCharHeight() const -{ - wxCHECK_MSG( (m_widget != NULL), 12, wxT("invalid window") ); - - wxCHECK_MSG( m_font.Ok(), 12, wxT("invalid font") ); - -#ifdef __WXGTK20__ - PangoContext *context = NULL; - if (m_widget) - context = gtk_widget_get_pango_context( m_widget ); - - if (!context) - return 0; - - PangoFontDescription *desc = m_font.GetNativeFontInfo()->description; - PangoLayout *layout = pango_layout_new(context); - pango_layout_set_font_description(layout, desc); - pango_layout_set_text(layout, "H", 1); - PangoLayoutLine *line = (PangoLayoutLine *)pango_layout_get_lines(layout)->data; - - PangoRectangle rect; - pango_layout_line_get_extents(line, NULL, &rect); - - g_object_unref( G_OBJECT( layout ) ); - - return (int) (rect.height / PANGO_SCALE); -#else - GdkFont *font = m_font.GetInternalFont( 1.0 ); - - return font->ascent + font->descent; -#endif -} - -int wxWindowGTK::GetCharWidth() const -{ - wxCHECK_MSG( (m_widget != NULL), 8, wxT("invalid window") ); - - wxCHECK_MSG( m_font.Ok(), 8, wxT("invalid font") ); - -#ifdef __WXGTK20__ - PangoContext *context = NULL; - if (m_widget) - context = gtk_widget_get_pango_context( m_widget ); - - if (!context) - return 0; - - PangoFontDescription *desc = m_font.GetNativeFontInfo()->description; - PangoLayout *layout = pango_layout_new(context); - pango_layout_set_font_description(layout, desc); - pango_layout_set_text(layout, "H", 1); - PangoLayoutLine *line = (PangoLayoutLine *)pango_layout_get_lines(layout)->data; - - PangoRectangle rect; - pango_layout_line_get_extents(line, NULL, &rect); - - g_object_unref( G_OBJECT( layout ) ); - - return (int) (rect.width / PANGO_SCALE); -#else - GdkFont *font = m_font.GetInternalFont( 1.0 ); - - return gdk_string_width( font, "H" ); -#endif -} - -void wxWindowGTK::GetTextExtent( const wxString& string, - int *x, - int *y, - int *descent, - int *externalLeading, - const wxFont *theFont ) const -{ - wxFont fontToUse = m_font; - if (theFont) fontToUse = *theFont; - - wxCHECK_RET( fontToUse.Ok(), wxT("invalid font") ); - - if (string.IsEmpty()) - { - if (x) (*x) = 0; - if (y) (*y) = 0; - return; - } - -#ifdef __WXGTK20__ - PangoContext *context = NULL; - if (m_widget) - context = gtk_widget_get_pango_context( m_widget ); - - if (!context) - { - if (x) (*x) = 0; - if (y) (*y) = 0; - return; - } - - PangoFontDescription *desc = fontToUse.GetNativeFontInfo()->description; - PangoLayout *layout = pango_layout_new(context); - pango_layout_set_font_description(layout, desc); - { -#if wxUSE_UNICODE - const wxCharBuffer data = wxConvUTF8.cWC2MB( string ); - pango_layout_set_text(layout, (const char*) data, strlen( (const char*) data )); -#else - const wxWCharBuffer wdata = wxConvLocal.cMB2WC( string ); - const wxCharBuffer data = wxConvUTF8.cWC2MB( wdata ); - pango_layout_set_text(layout, (const char*) data, strlen( (const char*) data )); -#endif - } - PangoLayoutLine *line = (PangoLayoutLine *)pango_layout_get_lines(layout)->data; - - PangoRectangle rect; - pango_layout_line_get_extents(line, NULL, &rect); - - if (x) (*x) = (wxCoord) (rect.width / PANGO_SCALE); - if (y) (*y) = (wxCoord) (rect.height / PANGO_SCALE); - if (descent) - { - // Do something about metrics here - (*descent) = 0; - } - if (externalLeading) (*externalLeading) = 0; // ?? - - g_object_unref( G_OBJECT( layout ) ); -#else - GdkFont *font = fontToUse.GetInternalFont( 1.0 ); - if (x) (*x) = gdk_string_width( font, wxGTK_CONV( string ) ); - if (y) (*y) = font->ascent + font->descent; - if (descent) (*descent) = font->descent; - if (externalLeading) (*externalLeading) = 0; // ?? -#endif -} - -void wxWindowGTK::SetFocus() -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid window") ); - - if ( m_hasFocus ) - { - // don't do anything if we already have focus - return; - } - - if (m_wxwindow) - { - if (!GTK_WIDGET_HAS_FOCUS (m_wxwindow)) - { - gtk_widget_grab_focus (m_wxwindow); - } - } - else if (m_widget) - { - if (GTK_WIDGET_CAN_FOCUS(m_widget) && !GTK_WIDGET_HAS_FOCUS (m_widget) ) - { - if (!GTK_WIDGET_REALIZED(m_widget)) - { - // we can't set the focus to the widget now so we remember that - // it should be focused and will do it later, during the idle - // time, as soon as we can - wxLogTrace(TRACE_FOCUS, - _T("Delaying setting focus to %s(%s)"), - GetClassInfo()->GetClassName(), GetLabel().c_str()); - - g_delayedFocus = this; - } - else - { - wxLogTrace(TRACE_FOCUS, - _T("Setting focus to %s(%s)"), - GetClassInfo()->GetClassName(), GetLabel().c_str()); - - gtk_widget_grab_focus (m_widget); - } - } - else if (GTK_IS_CONTAINER(m_widget)) - { - SET_CONTAINER_FOCUS( m_widget, GTK_DIR_TAB_FORWARD ); - } - else - { - wxLogTrace(TRACE_FOCUS, - _T("Can't set focus to %s(%s)"), - GetClassInfo()->GetClassName(), GetLabel().c_str()); - } - } -} - -bool wxWindowGTK::AcceptsFocus() const -{ - return m_acceptsFocus && wxWindowBase::AcceptsFocus(); -} - -bool wxWindowGTK::Reparent( wxWindowBase *newParentBase ) -{ - wxCHECK_MSG( (m_widget != NULL), FALSE, wxT("invalid window") ); - - wxWindowGTK *oldParent = m_parent, - *newParent = (wxWindowGTK *)newParentBase; - - wxASSERT( GTK_IS_WIDGET(m_widget) ); - - if ( !wxWindowBase::Reparent(newParent) ) - return FALSE; - - wxASSERT( GTK_IS_WIDGET(m_widget) ); - - /* prevent GTK from deleting the widget arbitrarily */ - gtk_widget_ref( m_widget ); - - if (oldParent) - { - gtk_container_remove( GTK_CONTAINER(m_widget->parent), m_widget ); - } - - wxASSERT( GTK_IS_WIDGET(m_widget) ); - - if (newParent) - { - /* insert GTK representation */ - (*(newParent->m_insertCallback))(newParent, this); - } - - /* reverse: prevent GTK from deleting the widget arbitrarily */ - gtk_widget_unref( m_widget ); - - return TRUE; -} - -void wxWindowGTK::DoAddChild(wxWindowGTK *child) -{ - wxASSERT_MSG( (m_widget != NULL), wxT("invalid window") ); - - wxASSERT_MSG( (child != NULL), wxT("invalid child window") ); - - wxASSERT_MSG( (m_insertCallback != NULL), wxT("invalid child insertion function") ); - - /* add to list */ - AddChild( child ); - - /* insert GTK representation */ - (*m_insertCallback)(this, child); -} - -void wxWindowGTK::Raise() -{ - wxCHECK_RET( (m_widget != NULL), wxT("invalid window") ); - - if (!m_widget->window) return; - - gdk_window_raise( m_widget->window ); -} - -void wxWindowGTK::Lower() -{ - wxCHECK_RET( (m_widget != NULL), wxT("invalid window") ); - - if (!m_widget->window) return; - - gdk_window_lower( m_widget->window ); -} - -bool wxWindowGTK::SetCursor( const wxCursor &cursor ) -{ - wxCHECK_MSG( (m_widget != NULL), FALSE, wxT("invalid window") ); - - if (cursor == m_cursor) - return FALSE; - - if (g_isIdle) - wxapp_install_idle_handler(); - - if (cursor == wxNullCursor) - return wxWindowBase::SetCursor( *wxSTANDARD_CURSOR ); - else - return wxWindowBase::SetCursor( cursor ); -} - -void wxWindowGTK::WarpPointer( int x, int y ) -{ - wxCHECK_RET( (m_widget != NULL), wxT("invalid window") ); - - // We provide this function ourselves as it is - // missing in GDK (top of this file). - - GdkWindow *window = (GdkWindow*) NULL; - if (m_wxwindow) - window = GTK_PIZZA(m_wxwindow)->bin_window; - else - window = GetConnectWidget()->window; - - if (window) - gdk_window_warp_pointer( window, x, y ); -} - - -void wxWindowGTK::Refresh( bool eraseBackground, const wxRect *rect ) -{ - if (!m_widget) return; - if (!m_widget->window) return; - -#ifndef __WXGTK20__ - if (g_isIdle) - wxapp_install_idle_handler(); - - wxRect myRect(0,0,0,0); - if (m_wxwindow && rect) - { - myRect.SetSize(wxSize( m_wxwindow->allocation.width, - m_wxwindow->allocation.height)); - myRect.Intersect(*rect); - if (!myRect.width || !myRect.height) - // nothing to do, rectangle is empty - return; - rect = &myRect; - } - - if (eraseBackground && m_wxwindow && m_wxwindow->window) - { - if (rect) - { - // Schedule for later Updating in ::Update() or ::OnInternalIdle(). - m_clearRegion.Union( rect->x, rect->y, rect->width, rect->height ); - } - else - { - // Schedule for later Updating in ::Update() or ::OnInternalIdle(). - m_clearRegion.Clear(); - m_clearRegion.Union( 0, 0, m_wxwindow->allocation.width, m_wxwindow->allocation.height ); - } - } - - if (rect) - { - if (m_wxwindow) - { - // Schedule for later Updating in ::Update() or ::OnInternalIdle(). - m_updateRegion.Union( rect->x, rect->y, rect->width, rect->height ); - } - else - { - GdkRectangle gdk_rect; - gdk_rect.x = rect->x; - gdk_rect.y = rect->y; - gdk_rect.width = rect->width; - gdk_rect.height = rect->height; - gtk_widget_draw( m_widget, &gdk_rect ); - } - } - else - { - if (m_wxwindow) - { - // Schedule for later Updating in ::Update() or ::OnInternalIdle(). - m_updateRegion.Clear(); - m_updateRegion.Union( 0, 0, m_wxwindow->allocation.width, m_wxwindow->allocation.height ); - } - else - { - gtk_widget_draw( m_widget, (GdkRectangle*) NULL ); - } - } -#else - if (m_wxwindow) - { - if (rect) - { - GdkRectangle gdk_rect; - gdk_rect.x = rect->x; - gdk_rect.y = rect->y; - gdk_rect.width = rect->width; - gdk_rect.height = rect->height; - gdk_window_invalidate_rect( GTK_PIZZA(m_wxwindow)->bin_window, &gdk_rect, TRUE ); - } - else - { - gdk_window_invalidate_rect( GTK_PIZZA(m_wxwindow)->bin_window, NULL, TRUE ); - } - } -#endif -} - -void wxWindowGTK::Update() -{ - GtkUpdate(); -} - -void wxWindowGTK::GtkUpdate() -{ -#ifdef __WXGTK20__ - if (m_wxwindow && GTK_PIZZA(m_wxwindow)->bin_window) - gdk_window_process_updates( GTK_PIZZA(m_wxwindow)->bin_window, FALSE ); -#else - if (!m_updateRegion.IsEmpty()) - GtkSendPaintEvents(); -#endif -} - -void wxWindowGTK::GtkSendPaintEvents() -{ - if (!m_wxwindow) - { -#ifndef __WXGTK20__ - m_clearRegion.Clear(); -#endif - m_updateRegion.Clear(); - return; - } - - // Clip to paint region in wxClientDC - m_clipPaintRegion = TRUE; - -#ifndef __WXGTK20__ - // widget to draw on - GtkPizza *pizza = GTK_PIZZA (m_wxwindow); - - // later for GTK 2.0, too. - if (GetThemeEnabled()) - { - // find ancestor from which to steal background - wxWindow *parent = GetParent(); - while (parent && !parent->IsTopLevel()) - parent = parent->GetParent(); - if (!parent) - parent = (wxWindow*)this; - - wxRegionIterator upd( m_updateRegion ); - while (upd) - { - GdkRectangle rect; - rect.x = upd.GetX(); - rect.y = upd.GetY(); - rect.width = upd.GetWidth(); - rect.height = upd.GetHeight(); - - gtk_paint_flat_box( parent->m_widget->style, - pizza->bin_window, - GTK_STATE_NORMAL, - GTK_SHADOW_NONE, - &rect, - parent->m_widget, - (char *)"base", - 0, 0, -1, -1 ); - - upd ++; - } - } - else -#endif - -#ifdef __WXGTK20__ - { - wxWindowDC dc( (wxWindow*)this ); - dc.SetClippingRegion( m_updateRegion ); - - wxEraseEvent erase_event( GetId(), &dc ); - erase_event.SetEventObject( this ); - - GetEventHandler()->ProcessEvent(erase_event); - } -#else - // if (!m_clearRegion.IsEmpty()) // Always send an erase event under GTK 1.2 - { - wxWindowDC dc( (wxWindow*)this ); - if (m_clearRegion.IsEmpty()) - dc.SetClippingRegion( m_updateRegion ); - else - dc.SetClippingRegion( m_clearRegion ); - - wxEraseEvent erase_event( GetId(), &dc ); - erase_event.SetEventObject( this ); - - if (!GetEventHandler()->ProcessEvent(erase_event)) - { - if (!g_eraseGC) - { - g_eraseGC = gdk_gc_new( pizza->bin_window ); - gdk_gc_set_fill( g_eraseGC, GDK_SOLID ); - } - gdk_gc_set_foreground( g_eraseGC, m_backgroundColour.GetColor() ); - - wxRegionIterator upd( m_clearRegion ); - while (upd) - { - gdk_draw_rectangle( pizza->bin_window, g_eraseGC, 1, - upd.GetX(), upd.GetY(), upd.GetWidth(), upd.GetHeight() ); - upd ++; - } - } - m_clearRegion.Clear(); - } -#endif - - wxNcPaintEvent nc_paint_event( GetId() ); - nc_paint_event.SetEventObject( this ); - GetEventHandler()->ProcessEvent( nc_paint_event ); - - wxPaintEvent paint_event( GetId() ); - paint_event.SetEventObject( this ); - GetEventHandler()->ProcessEvent( paint_event ); - - m_clipPaintRegion = FALSE; - -#ifndef __WXUNIVERSAL__ -#ifndef __WXGTK20__ - // The following code will result in all window-less widgets - // being redrawn because the wxWindows class is allowed to - // paint over the window-less widgets. - - GList *children = pizza->children; - while (children) - { - GtkPizzaChild *child = (GtkPizzaChild*) children->data; - children = children->next; - - if (GTK_WIDGET_NO_WINDOW (child->widget) && - GTK_WIDGET_DRAWABLE (child->widget)) - { - // Get intersection of widget area and update region - wxRegion region( m_updateRegion ); - - GdkEventExpose gdk_event; - gdk_event.type = GDK_EXPOSE; - gdk_event.window = pizza->bin_window; - gdk_event.count = 0; - - wxRegionIterator upd( m_updateRegion ); - while (upd) - { - GdkRectangle rect; - rect.x = upd.GetX(); - rect.y = upd.GetY(); - rect.width = upd.GetWidth(); - rect.height = upd.GetHeight(); - - if (gtk_widget_intersect (child->widget, &rect, &gdk_event.area)) - { - gtk_widget_event (child->widget, (GdkEvent*) &gdk_event); - } - - upd ++; - } - } - } -#endif -#endif - - m_updateRegion.Clear(); -} - -void wxWindowGTK::Clear() -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid window") ); - -#ifndef __WXGTK20__ - if (m_wxwindow && m_wxwindow->window) - { - m_clearRegion.Clear(); - wxSize size( GetClientSize() ); - m_clearRegion.Union( 0,0,size.x,size.y ); - - // Better do this in idle? - GtkUpdate(); - } -#endif -} - -#if wxUSE_TOOLTIPS -void wxWindowGTK::DoSetToolTip( wxToolTip *tip ) -{ - wxWindowBase::DoSetToolTip(tip); - - if (m_tooltip) - m_tooltip->Apply( (wxWindow *)this ); -} - -void wxWindowGTK::ApplyToolTip( GtkTooltips *tips, const wxChar *tip ) -{ - gtk_tooltips_set_tip( tips, GetConnectWidget(), wxConvCurrent->cWX2MB(tip), (gchar*) NULL ); -} -#endif // wxUSE_TOOLTIPS - -void wxWindowGTK::GtkSetBackgroundColour( const wxColour &colour ) -{ - GdkWindow *window = (GdkWindow*) NULL; - if (m_wxwindow) - window = GTK_PIZZA(m_wxwindow)->bin_window; - else - window = GetConnectWidget()->window; - - wxASSERT( window ); - - // We need the pixel value e.g. for background clearing. - m_backgroundColour.CalcPixel( gdk_window_get_colormap( window ) ); - - if (m_wxwindow) - { - // wxMSW doesn't clear the window here, either. - gdk_window_set_background( window, m_backgroundColour.GetColor() ); - } - - ApplyWidgetStyle(); -} - -bool wxWindowGTK::SetBackgroundColour( const wxColour &colour ) -{ - wxCHECK_MSG( m_widget != NULL, FALSE, wxT("invalid window") ); - - if (!wxWindowBase::SetBackgroundColour(colour)) - return FALSE; - - GdkWindow *window = (GdkWindow*) NULL; - if (m_wxwindow) - window = GTK_PIZZA(m_wxwindow)->bin_window; - else - window = GetConnectWidget()->window; - - if (!window) - { - // indicate that a new style has been set - // but it couldn't get applied as the - // widget hasn't been realized yet. - m_delayedBackgroundColour = TRUE; - return TRUE; - } - else - { - GtkSetBackgroundColour( colour ); - } - - return TRUE; -} - -void wxWindowGTK::GtkSetForegroundColour( const wxColour &colour ) -{ - GdkWindow *window = (GdkWindow*) NULL; - if (m_wxwindow) - window = GTK_PIZZA(m_wxwindow)->bin_window; - else - window = GetConnectWidget()->window; - - wxASSERT( window ); - - ApplyWidgetStyle(); -} - -bool wxWindowGTK::SetForegroundColour( const wxColour &colour ) -{ - wxCHECK_MSG( m_widget != NULL, FALSE, wxT("invalid window") ); - - if (!wxWindowBase::SetForegroundColour(colour)) - { - // don't leave if the GTK widget has just - // been realized - if (!m_delayedForegroundColour) return FALSE; - } - - GdkWindow *window = (GdkWindow*) NULL; - if (m_wxwindow) - window = GTK_PIZZA(m_wxwindow)->bin_window; - else - window = GetConnectWidget()->window; - - if (!window) - { - // indicate that a new style has been set - // but it couldn't get applied as the - // widget hasn't been realized yet. - m_delayedForegroundColour = TRUE; - } - else - { - GtkSetForegroundColour( colour ); - } - - return TRUE; -} - -#ifdef __WXGTK20__ -PangoContext *wxWindowGTK::GtkGetPangoDefaultContext() -{ - return gtk_widget_get_pango_context( m_widget ); -} - -// MR: Deprecated and now returns the same as GtkGetPangoDefaultContext to avoid libpangox dependancy -PangoContext *wxWindowGTK::GtkGetPangoX11Context() -{ - return gtk_widget_get_pango_context( m_widget ); -} -#endif - -GtkStyle *wxWindowGTK::GetWidgetStyle() -{ - if (m_widgetStyle) - { - GtkStyle *remake = gtk_style_copy( m_widgetStyle ); - - // FIXME: no more klass in 2.0 -#ifndef __WXGTK20__ - remake->klass = m_widgetStyle->klass; -#endif - - gtk_style_unref( m_widgetStyle ); - m_widgetStyle = remake; - } - else - { - GtkStyle *def = gtk_rc_get_style( m_widget ); - - if (!def) - def = gtk_widget_get_default_style(); - - m_widgetStyle = gtk_style_copy( def ); - - // FIXME: no more klass in 2.0 -#ifndef __WXGTK20__ - m_widgetStyle->klass = def->klass; -#endif - } - - return m_widgetStyle; -} - -void wxWindowGTK::SetWidgetStyle() -{ -#if DISABLE_STYLE_IF_BROKEN_THEME - if (m_widget->style->engine_data) - { - static bool s_warningPrinted = FALSE; - if (!s_warningPrinted) - { - printf( "wxWindows warning: Widget styles disabled due to buggy GTK theme.\n" ); - s_warningPrinted = TRUE; - } - m_widgetStyle = m_widget->style; - return; - } -#endif - - GtkStyle *style = GetWidgetStyle(); - - if (m_font != wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT )) - { -#ifdef __WXGTK20__ - pango_font_description_free( style->font_desc ); - style->font_desc = pango_font_description_copy( m_font.GetNativeFontInfo()->description ); -#else - gdk_font_unref( style->font ); - style->font = gdk_font_ref( m_font.GetInternalFont( 1.0 ) ); -#endif - } - - if (m_foregroundColour.Ok()) - { - m_foregroundColour.CalcPixel( gtk_widget_get_colormap( m_widget ) ); - if (m_foregroundColour != wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT)) - { - style->fg[GTK_STATE_NORMAL] = *m_foregroundColour.GetColor(); - style->fg[GTK_STATE_PRELIGHT] = *m_foregroundColour.GetColor(); - style->fg[GTK_STATE_ACTIVE] = *m_foregroundColour.GetColor(); - } - else - { - // Try to restore the gtk default style. This is still a little - // oversimplified for what is probably really needed here for controls - // other than buttons, but is better than not being able to (re)set a - // control's foreground colour to *wxBLACK -- RL - GtkStyle *def = gtk_rc_get_style( m_widget ); - - if (!def) - def = gtk_widget_get_default_style(); - - style->fg[GTK_STATE_NORMAL] = def->fg[GTK_STATE_NORMAL]; - style->fg[GTK_STATE_PRELIGHT] = def->fg[GTK_STATE_PRELIGHT]; - style->fg[GTK_STATE_ACTIVE] = def->fg[GTK_STATE_ACTIVE]; - } - } - - if (m_backgroundColour.Ok()) - { - m_backgroundColour.CalcPixel( gtk_widget_get_colormap( m_widget ) ); - if (m_backgroundColour != wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)) - { - style->bg[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor(); - style->base[GTK_STATE_NORMAL] = *m_backgroundColour.GetColor(); - style->bg[GTK_STATE_PRELIGHT] = *m_backgroundColour.GetColor(); - style->base[GTK_STATE_PRELIGHT] = *m_backgroundColour.GetColor(); - style->bg[GTK_STATE_ACTIVE] = *m_backgroundColour.GetColor(); - style->base[GTK_STATE_ACTIVE] = *m_backgroundColour.GetColor(); - style->bg[GTK_STATE_INSENSITIVE] = *m_backgroundColour.GetColor(); - style->base[GTK_STATE_INSENSITIVE] = *m_backgroundColour.GetColor(); - } - else - { - // Try to restore the gtk default style. This is still a little - // oversimplified for what is probably really needed here for controls - // other than buttons, but is better than not being able to (re)set a - // control's background colour to default grey and means resetting a - // button to wxSYS_COLOUR_BTNFACE will restore its usual highlighting - // behavior -- RL - GtkStyle *def = gtk_rc_get_style( m_widget ); - - if (!def) - def = gtk_widget_get_default_style(); - - style->bg[GTK_STATE_NORMAL] = def->bg[GTK_STATE_NORMAL]; - style->base[GTK_STATE_NORMAL] = def->base[GTK_STATE_NORMAL]; - style->bg[GTK_STATE_PRELIGHT] = def->bg[GTK_STATE_PRELIGHT]; - style->base[GTK_STATE_PRELIGHT] = def->base[GTK_STATE_PRELIGHT]; - style->bg[GTK_STATE_ACTIVE] = def->bg[GTK_STATE_ACTIVE]; - style->base[GTK_STATE_ACTIVE] = def->base[GTK_STATE_ACTIVE]; - style->bg[GTK_STATE_INSENSITIVE] = def->bg[GTK_STATE_INSENSITIVE]; - style->base[GTK_STATE_INSENSITIVE] = def->base[GTK_STATE_INSENSITIVE]; - } - } -} - -void wxWindowGTK::ApplyWidgetStyle() -{ -} - -//----------------------------------------------------------------------------- -// Pop-up menu stuff -//----------------------------------------------------------------------------- - -#if wxUSE_MENUS_NATIVE - -extern "C" -void gtk_pop_hide_callback( GtkWidget *WXUNUSED(widget), bool* is_waiting ) -{ - *is_waiting = FALSE; -} - -static void SetInvokingWindow( wxMenu *menu, wxWindowGTK *win ) -{ - menu->SetInvokingWindow( win ); - wxMenuItemList::Node *node = menu->GetMenuItems().GetFirst(); - while (node) - { - wxMenuItem *menuitem = node->GetData(); - if (menuitem->IsSubMenu()) - { - SetInvokingWindow( menuitem->GetSubMenu(), win ); - } - - node = node->GetNext(); - } -} - -// used to pass the coordinates from wxWindowGTK::DoPopupMenu() to -// wxPopupMenuPositionCallback() -// -// should be safe even in the MT case as the user can hardly popup 2 menus -// simultaneously, can he? -static gint gs_pop_x = 0; -static gint gs_pop_y = 0; - -extern "C" void wxPopupMenuPositionCallback( GtkMenu *menu, - gint *x, gint *y, -#ifdef __WXGTK20__ - gboolean * WXUNUSED(whatever), -#endif - gpointer WXUNUSED(user_data) ) -{ - // ensure that the menu appears entirely on screen - GtkRequisition req; - gtk_widget_get_child_requisition(GTK_WIDGET(menu), &req); - - wxSize sizeScreen = wxGetDisplaySize(); - - gint xmax = sizeScreen.x - req.width, - ymax = sizeScreen.y - req.height; - - *x = gs_pop_x < xmax ? gs_pop_x : xmax; - *y = gs_pop_y < ymax ? gs_pop_y : ymax; -} - -bool wxWindowGTK::DoPopupMenu( wxMenu *menu, int x, int y ) -{ - wxCHECK_MSG( m_widget != NULL, FALSE, wxT("invalid window") ); - - wxCHECK_MSG( menu != NULL, FALSE, wxT("invalid popup-menu") ); - - SetInvokingWindow( menu, this ); - - menu->UpdateUI(); - - gs_pop_x = x; - gs_pop_y = y; - ClientToScreen( &gs_pop_x, &gs_pop_y ); - - bool is_waiting = TRUE; - - gtk_signal_connect( GTK_OBJECT(menu->m_menu), - "hide", - GTK_SIGNAL_FUNC(gtk_pop_hide_callback), - (gpointer)&is_waiting ); - - gtk_menu_popup( - GTK_MENU(menu->m_menu), - (GtkWidget *) NULL, // parent menu shell - (GtkWidget *) NULL, // parent menu item - wxPopupMenuPositionCallback, // function to position it - NULL, // client data - 0, // button used to activate it -#ifdef __WXGTK20__ - gtk_get_current_event_time() -#else - gs_timeLastClick // the time of activation -#endif - ); - - while (is_waiting) - { - gtk_main_iteration(); - } - - return TRUE; -} - -#endif // wxUSE_MENUS_NATIVE - -#if wxUSE_DRAG_AND_DROP - -void wxWindowGTK::SetDropTarget( wxDropTarget *dropTarget ) -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid window") ); - - GtkWidget *dnd_widget = GetConnectWidget(); - - if (m_dropTarget) m_dropTarget->UnregisterWidget( dnd_widget ); - - if (m_dropTarget) delete m_dropTarget; - m_dropTarget = dropTarget; - - if (m_dropTarget) m_dropTarget->RegisterWidget( dnd_widget ); -} - -#endif // wxUSE_DRAG_AND_DROP - -GtkWidget* wxWindowGTK::GetConnectWidget() -{ - GtkWidget *connect_widget = m_widget; - if (m_wxwindow) connect_widget = m_wxwindow; - - return connect_widget; -} - -bool wxWindowGTK::IsOwnGtkWindow( GdkWindow *window ) -{ - if (m_wxwindow) - return (window == GTK_PIZZA(m_wxwindow)->bin_window); - - return (window == m_widget->window); -} - -bool wxWindowGTK::SetFont( const wxFont &font ) -{ - if (!wxWindowBase::SetFont(font) || !m_widget) - { - return FALSE; - } - - wxColour sysbg = wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ); - if ( sysbg == m_backgroundColour ) - { - m_backgroundColour = wxNullColour; - ApplyWidgetStyle(); - m_backgroundColour = sysbg; - } - else - { - ApplyWidgetStyle(); - } - - return TRUE; -} - -void wxWindowGTK::DoCaptureMouse() -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid window") ); - - GdkWindow *window = (GdkWindow*) NULL; - if (m_wxwindow) - window = GTK_PIZZA(m_wxwindow)->bin_window; - else - window = GetConnectWidget()->window; - - wxCHECK_RET( window, _T("CaptureMouse() failed") ); - - wxCursor* cursor = & m_cursor; - if (!cursor->Ok()) - cursor = wxSTANDARD_CURSOR; - - gdk_pointer_grab( window, FALSE, - (GdkEventMask) - (GDK_BUTTON_PRESS_MASK | - GDK_BUTTON_RELEASE_MASK | - GDK_POINTER_MOTION_HINT_MASK | - GDK_POINTER_MOTION_MASK), - (GdkWindow *) NULL, - cursor->GetCursor(), - (guint32)GDK_CURRENT_TIME ); - g_captureWindow = this; - g_captureWindowHasMouse = TRUE; -} - -void wxWindowGTK::DoReleaseMouse() -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid window") ); - - wxCHECK_RET( g_captureWindow, wxT("can't release mouse - not captured") ); - - g_captureWindow = (wxWindowGTK*) NULL; - - GdkWindow *window = (GdkWindow*) NULL; - if (m_wxwindow) - window = GTK_PIZZA(m_wxwindow)->bin_window; - else - window = GetConnectWidget()->window; - - if (!window) - return; - - gdk_pointer_ungrab ( (guint32)GDK_CURRENT_TIME ); -} - -/* static */ -wxWindow *wxWindowBase::GetCapture() -{ - return (wxWindow *)g_captureWindow; -} - -bool wxWindowGTK::IsRetained() const -{ - return FALSE; -} - -void wxWindowGTK::SetScrollbar( int orient, int pos, int thumbVisible, - int range, bool refresh ) -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid window") ); - - wxCHECK_RET( m_wxwindow != NULL, wxT("window needs client area for scrolling") ); - - m_hasScrolling = TRUE; - - if (orient == wxHORIZONTAL) - { - float fpos = (float)pos; - float frange = (float)range; - float fthumb = (float)thumbVisible; - if (fpos > frange-fthumb) fpos = frange-fthumb; - if (fpos < 0.0) fpos = 0.0; - - if ((fabs(frange-m_hAdjust->upper) < 0.2) && - (fabs(fthumb-m_hAdjust->page_size) < 0.2)) - { - SetScrollPos( orient, pos, refresh ); - return; - } - - m_oldHorizontalPos = fpos; - - m_hAdjust->lower = 0.0; - m_hAdjust->upper = frange; - m_hAdjust->value = fpos; - m_hAdjust->step_increment = 1.0; - m_hAdjust->page_increment = (float)(wxMax(fthumb,0)); - m_hAdjust->page_size = fthumb; - } - else - { - float fpos = (float)pos; - float frange = (float)range; - float fthumb = (float)thumbVisible; - if (fpos > frange-fthumb) fpos = frange-fthumb; - if (fpos < 0.0) fpos = 0.0; - - if ((fabs(frange-m_vAdjust->upper) < 0.2) && - (fabs(fthumb-m_vAdjust->page_size) < 0.2)) - { - SetScrollPos( orient, pos, refresh ); - return; - } - - m_oldVerticalPos = fpos; - - m_vAdjust->lower = 0.0; - m_vAdjust->upper = frange; - m_vAdjust->value = fpos; - m_vAdjust->step_increment = 1.0; - m_vAdjust->page_increment = (float)(wxMax(fthumb,0)); - m_vAdjust->page_size = fthumb; - } - - if (orient == wxHORIZONTAL) - gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "changed" ); - else - gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "changed" ); -} - -void wxWindowGTK::SetScrollPos( int orient, int pos, bool WXUNUSED(refresh) ) -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid window") ); - - wxCHECK_RET( m_wxwindow != NULL, wxT("window needs client area for scrolling") ); - - if (orient == wxHORIZONTAL) - { - float fpos = (float)pos; - if (fpos > m_hAdjust->upper - m_hAdjust->page_size) fpos = m_hAdjust->upper - m_hAdjust->page_size; - if (fpos < 0.0) fpos = 0.0; - m_oldHorizontalPos = fpos; - - if (fabs(fpos-m_hAdjust->value) < 0.2) return; - m_hAdjust->value = fpos; - } - else - { - float fpos = (float)pos; - if (fpos > m_vAdjust->upper - m_vAdjust->page_size) fpos = m_vAdjust->upper - m_vAdjust->page_size; - if (fpos < 0.0) fpos = 0.0; - m_oldVerticalPos = fpos; - - if (fabs(fpos-m_vAdjust->value) < 0.2) return; - m_vAdjust->value = fpos; - } - - if (m_wxwindow->window) - { - if (orient == wxHORIZONTAL) - { - gtk_signal_disconnect_by_func( GTK_OBJECT(m_hAdjust), - (GtkSignalFunc) gtk_window_hscroll_callback, (gpointer) this ); - - gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "value_changed" ); - - gtk_signal_connect( GTK_OBJECT(m_hAdjust), "value_changed", - (GtkSignalFunc) gtk_window_hscroll_callback, (gpointer) this ); - } - else - { - gtk_signal_disconnect_by_func( GTK_OBJECT(m_vAdjust), - (GtkSignalFunc) gtk_window_vscroll_callback, (gpointer) this ); - - gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "value_changed" ); - - gtk_signal_connect( GTK_OBJECT(m_vAdjust), "value_changed", - (GtkSignalFunc) gtk_window_vscroll_callback, (gpointer) this ); - } - } -} - -int wxWindowGTK::GetScrollThumb( int orient ) const -{ - wxCHECK_MSG( m_widget != NULL, 0, wxT("invalid window") ); - - wxCHECK_MSG( m_wxwindow != NULL, 0, wxT("window needs client area for scrolling") ); - - if (orient == wxHORIZONTAL) - return (int)(m_hAdjust->page_size+0.5); - else - return (int)(m_vAdjust->page_size+0.5); -} - -int wxWindowGTK::GetScrollPos( int orient ) const -{ - wxCHECK_MSG( m_widget != NULL, 0, wxT("invalid window") ); - - wxCHECK_MSG( m_wxwindow != NULL, 0, wxT("window needs client area for scrolling") ); - - if (orient == wxHORIZONTAL) - return (int)(m_hAdjust->value+0.5); - else - return (int)(m_vAdjust->value+0.5); -} - -int wxWindowGTK::GetScrollRange( int orient ) const -{ - wxCHECK_MSG( m_widget != NULL, 0, wxT("invalid window") ); - - wxCHECK_MSG( m_wxwindow != NULL, 0, wxT("window needs client area for scrolling") ); - - if (orient == wxHORIZONTAL) - return (int)(m_hAdjust->upper+0.5); - else - return (int)(m_vAdjust->upper+0.5); -} - -void wxWindowGTK::ScrollWindow( int dx, int dy, const wxRect* WXUNUSED(rect) ) -{ - wxCHECK_RET( m_widget != NULL, wxT("invalid window") ); - - wxCHECK_RET( m_wxwindow != NULL, wxT("window needs client area for scrolling") ); - - // No scrolling requested. - if ((dx == 0) && (dy == 0)) return; - -#ifndef __WXGTK20__ - if (!m_updateRegion.IsEmpty()) - { - m_updateRegion.Offset( dx, dy ); - - int cw = 0; - int ch = 0; - GetClientSize( &cw, &ch ); - m_updateRegion.Intersect( 0, 0, cw, ch ); - } - - if (!m_clearRegion.IsEmpty()) - { - m_clearRegion.Offset( dx, dy ); - - int cw = 0; - int ch = 0; - GetClientSize( &cw, &ch ); - m_clearRegion.Intersect( 0, 0, cw, ch ); - } -#endif - - m_clipPaintRegion = TRUE; - - gtk_pizza_scroll( GTK_PIZZA(m_wxwindow), -dx, -dy ); - - m_clipPaintRegion = FALSE; -} - - -// Find the wxWindow at the current mouse position, also returning the mouse -// position. -wxWindow* wxFindWindowAtPointer(wxPoint& pt) -{ - pt = wxGetMousePosition(); - wxWindow* found = wxFindWindowAtPoint(pt); - return found; -} - -// Get the current mouse position. -wxPoint wxGetMousePosition() -{ - /* This crashes when used within wxHelpContext, - so we have to use the X-specific implementation below. - gint x, y; - GdkModifierType *mask; - (void) gdk_window_get_pointer(NULL, &x, &y, mask); - - return wxPoint(x, y); - */ - - int x, y; - GdkWindow* windowAtPtr = gdk_window_at_pointer(& x, & y); - - Display *display = windowAtPtr ? GDK_WINDOW_XDISPLAY(windowAtPtr) : GDK_DISPLAY(); - Window rootWindow = RootWindowOfScreen (DefaultScreenOfDisplay(display)); - Window rootReturn, childReturn; - int rootX, rootY, winX, winY; - unsigned int maskReturn; - - XQueryPointer (display, - rootWindow, - &rootReturn, - &childReturn, - &rootX, &rootY, &winX, &winY, &maskReturn); - return wxPoint(rootX, rootY); - -} - -// ---------------------------------------------------------------------------- -// wxDCModule -// ---------------------------------------------------------------------------- - -class wxWinModule : public wxModule -{ -public: - bool OnInit(); - void OnExit(); - -private: - DECLARE_DYNAMIC_CLASS(wxWinModule) -}; - -IMPLEMENT_DYNAMIC_CLASS(wxWinModule, wxModule) - -bool wxWinModule::OnInit() -{ - // g_eraseGC = gdk_gc_new( GDK_ROOT_PARENT() ); - // gdk_gc_set_fill( g_eraseGC, GDK_SOLID ); - - return TRUE; -} - -void wxWinModule::OnExit() -{ - if (g_eraseGC) - gdk_gc_unref( g_eraseGC ); -} - -// vi:sts=4:sw=4:et diff --git a/src/gtk1/wx_gtk_vmsjackets.c b/src/gtk1/wx_gtk_vmsjackets.c deleted file mode 100644 index 20b1ec70cd..0000000000 --- a/src/gtk1/wx_gtk_vmsjackets.c +++ /dev/null @@ -1,2578 +0,0 @@ -/* Jackets for VMS only */ - -#include - -#include -#include -#include -#include -#include - -void GDK_BEEP (void) -{ - gdk_beep(); -} - -GdkBitmap* GDK_BITMAP_CREATE_FROM_DATA (GdkWindow *window, - const gchar *data, - gint width, - gint height) -{ - return gdk_bitmap_create_from_data (window, - data, - width, - height); -} - -void GDK_BITMAP_UNREF (GdkBitmap *pixmap) -{ - gdk_bitmap_unref (pixmap); -} - -gint GDK_CHAR_HEIGHT (GdkFont *font, - gchar character) -{ - return gdk_char_height (font, - character); -} - -GdkColormap* GDK_COLORMAP_GET_SYSTEM (void) -{ - return gdk_colormap_get_system(); -} - -GdkVisual* GDK_COLORMAP_GET_VISUAL (GdkColormap *colormap) -{ - return gdk_colormap_get_visual (colormap); -} - -GdkColormap* GDK_COLORMAP_NEW (GdkVisual *visual, - gboolean allocate) -{ - return gdk_colormap_new (visual, - allocate); -} - -void GDK_COLORMAP_UNREF (GdkColormap *cmap) -{ - gdk_colormap_unref (cmap); -} - -gboolean GDK_COLOR_ALLOC (GdkColormap *colormap, - GdkColor *color) -{ - return gdk_color_alloc (colormap, - color); -} - -gboolean GDK_COLOR_PARSE (const gchar *spec, - GdkColor *color) -{ - return gdk_color_parse (spec, - color); -} - -void GDK_CURSOR_DESTROY (GdkCursor *cursor) -{ - gdk_cursor_destroy (cursor); -} - -GdkCursor* GDK_CURSOR_NEW (GdkCursorType cursor_type) -{ - return gdk_cursor_new (cursor_type); -} - -void GDK_DRAW_ARC (GdkDrawable *drawable, - GdkGC *gc, - gint filled, - gint x, - gint y, - gint width, - gint height, - gint angle1, - gint angle2) -{ - gdk_draw_arc (drawable, - gc, - filled, - x, - y, - width, - height, - angle1, - angle2); -} - -void GDK_DRAW_IMAGE (GdkDrawable *drawable, - GdkGC *gc, - GdkImage *image, - gint xsrc, - gint ysrc, - gint xdest, - gint ydest, - gint width, - gint height) -{ - gdk_draw_image (drawable, - gc, - image, - xsrc, - ysrc, - xdest, - ydest, - width, - height); -} - -void GDK_DRAW_LINE (GdkDrawable *drawable, - GdkGC *gc, - gint x1, - gint y1, - gint x2, - gint y2) -{ - gdk_draw_line (drawable, - gc, - x1, - y1, - x2, - y2); -} - -void GDK_DRAW_PIXMAP (GdkDrawable *drawable, - GdkGC *gc, - GdkDrawable *src, - gint xsrc, - gint ysrc, - gint xdest, - gint ydest, - gint width, - gint height) -{ - gdk_draw_pixmap (drawable, - gc, - src, - xsrc, - ysrc, - xdest, - ydest, - width, - height); -} - -void GDK_DRAW_POINT (GdkDrawable *drawable, - GdkGC *gc, - gint x, - gint y) -{ - gdk_draw_point (drawable, - gc, - x, - y); -} - -void GDK_DRAW_POLYGON (GdkDrawable *drawable, - GdkGC *gc, - gint filled, - GdkPoint *points, - gint npoints) -{ - gdk_draw_polygon (drawable, - gc, - filled, - points, - npoints); -} - -void GDK_DRAW_RECTANGLE (GdkDrawable *drawable, - GdkGC *gc, - gint filled, - gint x, - gint y, - gint width, - gint height) -{ - gdk_draw_rectangle (drawable, - gc, - filled, - x, - y, - width, - height); -} - -void GDK_DRAW_STRING (GdkDrawable *drawable, - GdkFont *font, - GdkGC *gc, - gint x, - gint y, - const gchar *string) -{ - gdk_draw_string (drawable, - font, - gc, - x, - y, - string); -} - -void GDK_FLUSH (void) -{ - gdk_flush (); -} - -GdkFont* GDK_FONT_LOAD (const gchar *font_name) -{ - return gdk_font_load (font_name); -} - -GdkFont* GDK_FONT_REF (GdkFont *font) -{ - return gdk_font_ref (font); -} - -void GDK_FONT_UNREF (GdkFont *font) -{ - gdk_font_unref (font); -} - -void GDK_GC_DESTROY (GdkGC *gc) -{ - gdk_gc_destroy (gc); -} - -GdkGC* GDK_GC_NEW (GdkWindow *window) -{ - return gdk_gc_new (window); -} - -void GDK_GC_SET_BACKGROUND (GdkGC *gc, - GdkColor *color) -{ - gdk_gc_set_background (gc, - color); -} - -void GDK_GC_SET_CLIP_MASK (GdkGC *gc, - GdkBitmap *mask) -{ - gdk_gc_set_clip_mask (gc, - mask); -} - -void GDK_GC_SET_CLIP_ORIGIN (GdkGC *gc, - gint x, - gint y) -{ - gdk_gc_set_clip_origin (gc, - x, - y); -} - -void GDK_GC_SET_CLIP_RECTANGLE (GdkGC *gc, - GdkRectangle *rectangle) -{ - gdk_gc_set_clip_rectangle (gc, - rectangle); -} - -void GDK_GC_SET_CLIP_REGION (GdkGC *gc, - GdkRegion *region) -{ - gdk_gc_set_clip_region (gc, - region); -} - -void GDK_GC_SET_DASHES (GdkGC *gc, - gint dash_offset, - gint8 dash_list[], - gint n) -{ - gdk_gc_set_dashes (gc, - dash_offset, - dash_list, - n); -} - -void GDK_GC_SET_EXPOSURES (GdkGC *gc, - gboolean exposures) -{ - gdk_gc_set_exposures (gc, - exposures); -} - -void GDK_GC_SET_FILL (GdkGC *gc, - GdkFill fill) -{ - gdk_gc_set_fill (gc, - fill); -} - -void GDK_GC_SET_FOREGROUND (GdkGC *gc, - GdkColor *color) -{ - gdk_gc_set_foreground (gc, - color); -} - -void GDK_GC_SET_FUNCTION (GdkGC *gc, - GdkFunction function) -{ - gdk_gc_set_function (gc, - function); -} - -void GDK_GC_SET_LINE_ATTRIBUTES (GdkGC *gc, - gint line_width, - GdkLineStyle line_style, - GdkCapStyle cap_style, - GdkJoinStyle join_style) -{ - gdk_gc_set_line_attributes (gc, - line_width, - line_style, - cap_style, - join_style); -} - -void GDK_GC_SET_STIPPLE (GdkGC *gc, - GdkPixmap *stipple) -{ - gdk_gc_set_stipple (gc, - stipple); -} - -void GDK_GC_SET_SUBWINDOW (GdkGC *gc, - GdkSubwindowMode mode) -{ - gdk_gc_set_subwindow (gc, - mode); -} - -void GDK_GC_SET_TILE (GdkGC *gc, - GdkPixmap *tile) -{ - gdk_gc_set_tile (gc, - tile); -} - -void GDK_GC_SET_TS_ORIGIN (GdkGC *gc, - gint x, - gint y) -{ - gdk_gc_set_ts_origin (gc, - x, - y); -} - -void GDK_GC_UNREF (GdkGC *gc) -{ - gdk_gc_unref (gc); -} - -void GDK_IMAGE_DESTROY (GdkImage *image) -{ - gdk_image_destroy (image); -} - -GdkImage* GDK_IMAGE_GET (GdkWindow *window, - gint x, - gint y, - gint width, - gint height) -{ - return gdk_image_get (window, - x, - y, - width, - height); -} - -guint32 GDK_IMAGE_GET_PIXEL (GdkImage *image, - gint x, - gint y) -{ - return gdk_image_get_pixel (image, - x, - y); -} - -GdkImage* GDK_IMAGE_NEW (GdkImageType type, - GdkVisual *visual, - gint width, - gint height) -{ - return gdk_image_new (type, - visual, - width, - height); -} - -GdkImage* GDK_IMAGE_NEW_BITMAP(GdkVisual *visual, - gpointer data, - gint width, - gint height) -{ - return gdk_image_new_bitmap(visual, - data, - width, - height); -} - -void GDK_IMAGE_PUT_PIXEL (GdkImage *image, - gint x, - gint y, - guint32 pixel) -{ - gdk_image_put_pixel (image, - x, - y, - pixel); - -} - -gint GDK_INPUT_ADD_FULL (gint source, - GdkInputCondition condition, - GdkInputFunction function, - gpointer data, - GdkDestroyNotify destroy) -{ - return gdk_input_add_full (source, - condition, - function, - data, - destroy); -} - -void GDK_INPUT_REMOVE (gint tag) -{ - gdk_input_remove (tag); -} - -guint GDK_KEYVAL_TO_UPPER (guint keyval) -{ - return gdk_keyval_to_upper (keyval); -} - -GdkPixmap* GDK_PIXMAP_CREATE_FROM_XPM (GdkWindow *window, - GdkBitmap **mask, - GdkColor *transparent_color, - const gchar *filename) -{ - return gdk_pixmap_create_from_xpm (window, - mask, - transparent_color, - filename); -} - -GdkPixmap* GDK_PIXMAP_CREATE_FROM_XPM_D (GdkWindow *window, - GdkBitmap **mask, - GdkColor *transparent_color, - gchar **data) -{ - return gdk_pixmap_create_from_xpm_d (window, - mask, - transparent_color, - data); -} - -GdkPixmap* GDK_PIXMAP_NEW (GdkWindow *window, - gint width, - gint height, - gint depth) -{ - return gdk_pixmap_new (window, - width, - height, - depth); -} - -void GDK_PIXMAP_UNREF (GdkPixmap *pixmap) -{ - gdk_pixmap_unref (pixmap); -} - -gint GDK_POINTER_GRAB (GdkWindow *window, - gint owner_events, - GdkEventMask event_mask, - GdkWindow *confine_to, - GdkCursor *cursor, - guint32 time) -{ - return gdk_pointer_grab (window, - owner_events, - event_mask, - confine_to, - cursor, - time); -} - -void GDK_POINTER_UNGRAB (guint32 time) -{ - gdk_pointer_ungrab (time); -} - -GdkRegion* GDK_REGIONS_INTERSECT (GdkRegion *source1, - GdkRegion *source2) -{ - return gdk_regions_intersect (source1, - source2); - -} - -GdkRegion* GDK_REGIONS_SUBTRACT (GdkRegion *source1, - GdkRegion *source2) -{ - return gdk_regions_subtract (source1, - source2); -} - -GdkRegion* GDK_REGIONS_UNION (GdkRegion *source1, - GdkRegion *source2) -{ - return gdk_regions_union (source1, - source2); -} - -GdkRegion* GDK_REGIONS_XOR (GdkRegion *source1, - GdkRegion *source2) -{ - return gdk_regions_xor (source1, - source2); -} - -void GDK_REGION_DESTROY (GdkRegion *region) -{ - gdk_region_destroy (region); -} - -gboolean GDK_REGION_EMPTY (GdkRegion *region) -{ - return gdk_region_empty (region); -} - -void GDK_REGION_GET_CLIPBOX(GdkRegion *region, - GdkRectangle *rectangle) -{ - gdk_region_get_clipbox(region, - rectangle); -} - -GdkRegion* GDK_REGION_NEW (void) -{ - return gdk_region_new (); -} - -gboolean GDK_REGION_POINT_IN (GdkRegion *region, - int x, - int y) -{ - return gdk_region_point_in (region, - x, - y); -} - -GdkOverlapType GDK_REGION_RECT_IN (GdkRegion *region, - GdkRectangle *rect) -{ - return gdk_region_rect_in (region, - rect); -} - -GdkRegion* GDK_REGION_UNION_WITH_RECT (GdkRegion *region, - GdkRectangle *rect) -{ - return gdk_region_union_with_rect (region, - rect); -} - -gint GDK_SCREEN_HEIGHT (void) -{ - return gdk_screen_height (); -} - -gint GDK_SCREEN_WIDTH (void) -{ - return gdk_screen_width (); -} - -gint GDK_STRING_WIDTH (GdkFont *font, - const gchar *string) -{ - return gdk_string_width (font, - string); -} - -void gdk_threads_enter1 (void) -{ - gdk_threads_enter (); -} - -void gdk_threads_leave1 (void) -{ - gdk_threads_leave (); -} - -GdkVisual* GDK_VISUAL_GET_BEST (void) -{ - return gdk_visual_get_best (); -} - -GdkVisual* GDK_VISUAL_GET_SYSTEM (void) -{ - return gdk_visual_get_system (); -} - -void GDK_WINDOW_ADD_FILTER (GdkWindow *window, - GdkFilterFunc function, - gpointer data) -{ - gdk_window_add_filter (window, - function, - data); -} - -void GDK_WINDOW_CLEAR (GdkWindow *window) -{ - gdk_window_clear (window); -} - -void GDK_WINDOW_CLEAR_AREA (GdkWindow *window, - gint x, - gint y, - gint width, - gint height) -{ - gdk_window_clear_area (window, - x, - y, - width, - height); -} - -void GDK_WINDOW_COPY_AREA (GdkWindow *window, - GdkGC *gc, - gint x, - gint y, - GdkWindow *source_window, - gint source_x, - gint source_y, - gint width, - gint height) -{ - gdk_window_copy_area (window, - gc, - x, - y, - source_window, - source_x, - source_y, - width, - height); -} - -void GDK_WINDOW_DESTROY (GdkWindow *window) -{ - gdk_window_destroy (window); -} - -GdkColormap* GDK_WINDOW_GET_COLORMAP (GdkWindow *window) -{ - return gdk_window_get_colormap (window); -} - -gint GDK_WINDOW_GET_ORIGIN (GdkWindow *window, - gint *x, - gint *y) -{ - return gdk_window_get_origin (window, - x, - y); -} - -GdkWindow* GDK_WINDOW_GET_POINTER (GdkWindow *window, - gint *x, - gint *y, - GdkModifierType *mask) -{ - return gdk_window_get_pointer (window, - x, - y, - mask); -} - -void GDK_WINDOW_GET_ROOT_ORIGIN (GdkWindow *window, - gint *x, - gint *y) -{ - gdk_window_get_root_origin (window, - x, - y); -} - -void GDK_WINDOW_GET_SIZE (GdkWindow *window, - gint *width, - gint *height) -{ - gdk_window_get_size (window, - width, - height); -} - -void GDK_WINDOW_GET_USER_DATA (GdkWindow *window, - gpointer *data) -{ - gdk_window_get_user_data (window, - data); -} - -GdkVisual* GDK_WINDOW_GET_VISUAL (GdkWindow *window) -{ - return gdk_window_get_visual (window); -} - -void GDK_WINDOW_LOWER (GdkWindow *window) -{ - gdk_window_lower (window); -} - -void GDK_WINDOW_MOVE (GdkWindow *window, - gint x, - gint y) -{ - gdk_window_move (window, - x, - y); -} - -void GDK_WINDOW_MOVE_RESIZE (GdkWindow *window, - gint x, - gint y, - gint width, - gint height) -{ - gdk_window_move_resize (window, - x, - y, - width, - height); -} - -GdkWindow* GDK_WINDOW_NEW (GdkWindow *parent, - GdkWindowAttr *attributes, - gint attributes_mask) -{ - return gdk_window_new (parent, - attributes, - attributes_mask); -} - -void GDK_WINDOW_RAISE (GdkWindow *window) -{ - gdk_window_raise (window); -} - -GdkWindow* GDK_WINDOW_REF (GdkWindow *window) -{ - return gdk_window_ref (window); -} - -void GDK_WINDOW_RESIZE (GdkWindow *window, - gint width, - gint height) -{ - gdk_window_resize (window, - width, - height); -} - -void GDK_WINDOW_SET_BACKGROUND (GdkWindow *window, - GdkColor *color) -{ - gdk_window_set_background (window, - color); -} - -void GDK_WINDOW_SET_CURSOR (GdkWindow *window, - GdkCursor *cursor) -{ - gdk_window_set_cursor (window, - cursor); -} - -void GDK_WINDOW_SET_DECORATIONS (GdkWindow *window, - GdkWMDecoration decorations) -{ - gdk_window_set_decorations (window, - decorations); -} - -void GDK_WINDOW_SET_FUNCTIONS (GdkWindow *window, - GdkWMFunction functions) -{ - gdk_window_set_functions (window, - functions); -} - -void GDK_WINDOW_SET_HINTS (GdkWindow *window, - gint x, - gint y, - gint min_width, - gint min_height, - gint max_width, - gint max_height, - gint flags) -{ - gdk_window_set_hints (window, - x, - y, - min_width, - min_height, - max_width, - max_height, - flags); -} - -void GDK_WINDOW_SET_ICON (GdkWindow *window, - GdkWindow *icon_window, - GdkPixmap *pixmap, - GdkBitmap *mask) -{ - gdk_window_set_icon (window, - icon_window, - pixmap, - mask); -} - -gboolean GDK_WINDOW_SET_STATIC_GRAVITIES (GdkWindow *window, - gboolean use_static) -{ - return gdk_window_set_static_gravities (window, - use_static); -} - -void GDK_WINDOW_SET_USER_DATA (GdkWindow *window, - gpointer user_data) -{ - gdk_window_set_user_data (window, - user_data); -} - -void GDK_WINDOW_SHOW (GdkWindow *window) -{ - gdk_window_show (window); -} - -void GDK_WINDOW_UNREF (GdkWindow *window) -{ - gdk_window_unref (window); -} - -void -GDK_DRAW_RGB_IMAGE (GdkDrawable *drawable, - GdkGC *gc, - gint x, - gint y, - gint width, - gint height, - GdkRgbDither dith, - guchar *rgb_buf, - gint rowstride) -{ -gdk_draw_rgb_image (drawable, - gc, - x, - y, - width, - height, - dith, - rgb_buf, - rowstride); -} - -void -GDK_RGB_INIT (void) -{ -gdk_rgb_init (); -} - -gpointer GDK_XID_TABLE_LOOKUP (XID xid) -{ - return gdk_xid_table_lookup (xid); -} - - -Display* GDK_DISPLAY0( void ) -{ - return gdk_display; -} - -gint GDK_INPUT_ADD (gint source, - GdkInputCondition condition, - GdkInputFunction function, - gpointer data) -{ - return gdk_input_add (source, - condition, - function, - data); -} - -GdkWindow* GDK_ROOT_PARENT0( void ) -{ - return ((GdkWindow *)&gdk_root_parent); -} - -void GTK_ACCEL_GROUP_ATTACH (GtkAccelGroup *accel_group, - GtkObject *object) -{ - gtk_accel_group_attach (accel_group, - object); -} - -void GTK_ACCEL_GROUP_DETACH (GtkAccelGroup *accel_group, - GtkObject *object) -{ - gtk_accel_group_detach (accel_group, - object); -} - -GtkAccelGroup* GTK_ACCEL_GROUP_NEW (void) -{ - return gtk_accel_group_new (); -} - -GtkType GTK_ACCEL_LABEL_GET_TYPE (void) -{ - return gtk_accel_label_get_type (); -} - -gboolean GTK_ACCEL_LABEL_REFETCH (GtkAccelLabel *accel_label) -{ - return gtk_accel_label_refetch (accel_label); -} - -GtkType GTK_ADJUSTMENT_GET_TYPE (void) -{ - return gtk_adjustment_get_type (); -} - -GtkType GTK_BIN_GET_TYPE (void) -{ - return gtk_bin_get_type (); -} - -GtkType GTK_BOX_GET_TYPE (void) -{ - return gtk_box_get_type (); -} - -void GTK_BOX_PACK_START (GtkBox *box, - GtkWidget *child, - gboolean expand, - gboolean fill, - guint padding) -{ - gtk_box_pack_start (box, - child, - expand, - fill, - padding); -} - -GtkType GTK_BUTTON_GET_TYPE (void) -{ - return gtk_button_get_type (); -} - -GtkWidget* GTK_BUTTON_NEW (void) -{ - return gtk_button_new (); -} - -GtkWidget* GTK_BUTTON_NEW_WITH_LABEL (const gchar *label) -{ - return gtk_button_new_with_label (label); -} - -void GTK_BUTTON_SET_RELIEF (GtkButton *button, - GtkReliefStyle newstyle) -{ - gtk_button_set_relief (button, - newstyle); -} - -GtkWidget* GTK_CHECK_BUTTON_NEW (void) -{ - return gtk_check_button_new (); -} - -GtkWidget* GTK_CHECK_BUTTON_NEW_WITH_LABEL (const gchar *label) -{ - return gtk_check_button_new_with_label (label); -} - -void GTK_CHECK_MENU_ITEM_SET_ACTIVE (GtkCheckMenuItem *check_menu_item, - gboolean is_active) -{ - gtk_check_menu_item_set_active (check_menu_item, - is_active); -} - -guint GTK_COMBO_GET_TYPE (void) -{ - return gtk_combo_get_type (); -} - -GtkWidget *GTK_COMBO_NEW (void) -{ - return gtk_combo_new (); -} - -void GTK_COMBO_SET_USE_ARROWS_ALWAYS (GtkCombo* combo, - gint val) -{ - gtk_combo_set_use_arrows_always (combo, - val); -} - -void GTK_CONTAINER_ADD (GtkContainer *container, - GtkWidget *widget) -{ - gtk_container_add (container, - widget); -} - -gint GTK_CONTAINER_FOCUS (GtkContainer *container, - GtkDirectionType direction) -{ - return gtk_container_focus (container, - direction); -} - -void GTK_CONTAINER_FORALL (GtkContainer *container, - GtkCallback callback, - gpointer callback_data) -{ - gtk_container_forall (container, - callback, - callback_data); -} - -GtkType GTK_CONTAINER_GET_TYPE (void) -{ - return gtk_container_get_type (); -} - -void GTK_CONTAINER_REMOVE (GtkContainer *container, - GtkWidget *widget) -{ - gtk_container_remove (container, - widget); -} - -void GTK_CONTAINER_SET_FOCUS_VADJUST (GtkContainer *container, - GtkAdjustment *adjustment) -{ - gtk_container_set_focus_vadjustment (container, - adjustment); -} - -void GTK_DRAW_SHADOW (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type, - GtkShadowType shadow_type, - gint x, - gint y, - gint width, - gint height) -{ - gtk_draw_shadow (style, - window, - state_type, - shadow_type, - x, - y, - width, - height); -} - -void GTK_EDITABLE_COPY_CLIPBOARD (GtkEditable *editable) -{ - gtk_editable_copy_clipboard (editable); -} - -void GTK_EDITABLE_CUT_CLIPBOARD (GtkEditable *editable) -{ - gtk_editable_cut_clipboard (editable); -} - -void GTK_EDITABLE_DELETE_TEXT (GtkEditable *editable, - gint start_pos, - gint end_pos) -{ - gtk_editable_delete_text (editable, - start_pos, - end_pos); -} - -gchar* GTK_EDITABLE_GET_CHARS (GtkEditable *editable, - gint start_pos, - gint end_pos) -{ - return gtk_editable_get_chars (editable, - start_pos, - end_pos); -} - -GtkType GTK_EDITABLE_GET_TYPE (void) -{ - return gtk_editable_get_type (); -} - -void GTK_EDITABLE_INSERT_TEXT (GtkEditable *editable, - const gchar *new_text, - gint new_text_length, - gint *position) -{ - gtk_editable_insert_text (editable, - new_text, - new_text_length, - position); -} - -void GTK_EDITABLE_PASTE_CLIPBOARD (GtkEditable *editable) -{ - gtk_editable_paste_clipboard (editable); -} - -void GTK_EDITABLE_SELECT_REGION (GtkEditable *editable, - gint start, - gint end) -{ - gtk_editable_select_region (editable, - start, - end); -} - -void GTK_ENTRY_APPEND_TEXT (GtkEntry *entry, - const gchar *text) -{ - gtk_entry_append_text (entry, - text); -} - -gchar* GTK_ENTRY_GET_TEXT (GtkEntry *entry) -{ - return gtk_entry_get_text (entry); -} - -GtkType GTK_ENTRY_GET_TYPE (void) -{ - return gtk_entry_get_type (); -} - -GtkWidget* GTK_ENTRY_NEW (void) -{ - return gtk_entry_new (); -} - -void GTK_ENTRY_SET_EDITABLE (GtkEntry *entry, - gboolean editable) -{ - gtk_entry_set_editable (entry, - editable); -} - -void GTK_ENTRY_SET_POSITION (GtkEntry *entry, - gint position) -{ - gtk_entry_set_position (entry, - position); -} - -void GTK_ENTRY_SET_TEXT (GtkEntry *entry, - const gchar *text) -{ - gtk_entry_set_text (entry, - text); -} - -void GTK_ENTRY_SET_VISIBILITY (GtkEntry *entry, - gboolean visible) -{ - gtk_entry_set_visibility (entry, - visible); -} - -gint GTK_EVENTS_PENDING (void) -{ - return gtk_events_pending (); -} - -gchar* GTK_FILE_SELECTION_GET_FILENAME (GtkFileSelection *filesel) -{ - return gtk_file_selection_get_filename (filesel); -} - -GtkType GTK_FILE_SELECTION_GET_TYPE (void) -{ - return gtk_file_selection_get_type (); -} - -void GTK_FILE_SELECTION_HIDE_FILEOP_ (GtkFileSelection *filesel) -{ - gtk_file_selection_hide_fileop_buttons (filesel); -} - -GtkWidget* GTK_FILE_SELECTION_NEW (const gchar *title) -{ - return gtk_file_selection_new (title); -} - -void GTK_FILE_SELECTION_SET_FILENAME (GtkFileSelection *filesel, - const gchar *filename) -{ - gtk_file_selection_set_filename (filesel, - filename); -} - -gchar* GTK_FONT_SELECTION_DIALOG_GETNF (GtkFontSelectionDialog *fsd) -{ - return gtk_font_selection_dialog_get_font_name (fsd); -} - -GdkFont* GTK_FONT_SELECTION_DIALOG_GET_F (GtkFontSelectionDialog *fsd) -{ - return gtk_font_selection_dialog_get_font (fsd); -} - -GtkType GTK_FONT_SELECTION_DIALOG_GET_T (void) -{ - return gtk_font_selection_dialog_get_type (); -} - -GtkWidget* GTK_FONT_SELECTION_DIALOG_NEW (const gchar *title) -{ - return gtk_font_selection_dialog_new (title); -} - -GtkType GTK_FRAME_GET_TYPE (void) -{ - return gtk_frame_get_type (); -} - -GtkWidget* GTK_FRAME_NEW (const gchar *label) -{ - return gtk_frame_new (label); -} - -void GTK_FRAME_SET_LABEL (GtkFrame *frame, - const gchar *label) -{ - gtk_frame_set_label (frame, - label); -} - -void GTK_GRAB_ADD (GtkWidget *widget) -{ - gtk_grab_add (widget); -} - -void GTK_GRAB_REMOVE (GtkWidget *widget) -{ - gtk_grab_remove (widget); -} - -GtkType GTK_HANDLE_BOX_GET_TYPE (void) -{ - return gtk_handle_box_get_type (); -} - -GtkWidget* GTK_HANDLE_BOX_NEW (void) -{ - return gtk_handle_box_new (); -} - -void GTK_HANDLE_BOX_SET_SHADOW_TYPE (GtkHandleBox *handle_box, - GtkShadowType type) -{ - gtk_handle_box_set_shadow_type (handle_box, - type); -} - -GtkWidget* GTK_HBOX_NEW (gboolean homogeneous, - gint spacing) -{ - return gtk_hbox_new (homogeneous, - spacing); -} - -GtkWidget* GTK_HSCALE_NEW (GtkAdjustment *adjustment) -{ - return gtk_hscale_new (adjustment); -} - -GtkWidget* GTK_HSCROLLBAR_NEW (GtkAdjustment *adjustment) -{ - return gtk_hscrollbar_new (adjustment); -} - -GtkWidget* GTK_HSEPARATOR_NEW (void) -{ - return gtk_hseparator_new (); -} - -guint GTK_IDLE_ADD (GtkFunction function, - gpointer data) -{ - return gtk_idle_add (function, - data); -} - -void GTK_IDLE_REMOVE (guint idle_handler_id) -{ - gtk_idle_remove (idle_handler_id); -} - -void GTK_INIT (int *argc, - char ***argv) -{ - gtk_init (argc, - argv); -} - -void GTK_ITEM_FACTORY_CREATE_ITEM (GtkItemFactory *ifactory, - GtkItemFactoryEntry *entry, - gpointer callback_data, - guint callback_type) -{ - gtk_item_factory_create_item (ifactory, - entry, - callback_data, - callback_type); -} - -GtkWidget* GTK_ITEM_FACTORY_GET_ITEM (GtkItemFactory *ifactory, - const gchar *path) -{ - return gtk_item_factory_get_item (ifactory, - path); -} - -GtkWidget* GTK_ITEM_FACTORY_GET_WIDGET (GtkItemFactory *ifactory, - const gchar *path) -{ - return gtk_item_factory_get_widget (ifactory, - path); -} - -GtkItemFactory* GTK_ITEM_FACTORY_NEW (GtkType container_type, - const gchar *path, - GtkAccelGroup *accel_group) -{ - return gtk_item_factory_new (container_type, - path, - accel_group); -} - -void GTK_LABEL_GET (GtkLabel *label, - gchar **str) -{ - gtk_label_get (label, - str); -} - -GtkType GTK_LABEL_GET_TYPE (void) -{ - return gtk_label_get_type (); -} - -GtkWidget* GTK_LABEL_NEW (const gchar *str) -{ - return gtk_label_new (str); -} - -guint GTK_LABEL_PARSE_ULINE (GtkLabel *label, - const gchar *string) -{ - return gtk_label_parse_uline (label, - string); -} - -void GTK_LABEL_SET_JUSTIFY (GtkLabel *label, - GtkJustification jtype) -{ - gtk_label_set_justify (label, - jtype); -} - -void GTK_LABEL_SET_LINE_WRAP (GtkLabel *label, - gboolean wrap) -{ - gtk_label_set_line_wrap (label, - wrap); -} - -void GTK_LABEL_SET_TEXT (GtkLabel *label, - const gchar *str) -{ - gtk_label_set_text (label, - str); -} - -void GTK_LIST_APPEND_ITEMS (GtkList *list, - GList *items) -{ - gtk_list_append_items (list, - items); -} - -void GTK_LIST_CLEAR_ITEMS (GtkList *list, - gint start, - gint end) -{ - gtk_list_clear_items (list, - start, - end); -} - -GtkType GTK_LIST_GET_TYPE (void) -{ - return gtk_list_get_type (); -} - -void GTK_LIST_INSERT_ITEMS (GtkList *list, - GList *items, - gint position) -{ - gtk_list_insert_items (list, - items, - position); -} - -GtkWidget* GTK_LIST_ITEM_NEW_WITH_LABEL (const gchar *label) -{ - return gtk_list_item_new_with_label (label); -} - -GtkWidget* GTK_LIST_NEW (void) -{ - return gtk_list_new (); -} - -void GTK_LIST_REMOVE_ITEMS (GtkList *list, - GList *items) -{ - gtk_list_remove_items (list, - items); -} - -void GTK_LIST_SELECT_ITEM (GtkList *list, - gint item) -{ - gtk_list_select_item (list, - item); -} - -void GTK_LIST_SET_SELECTION_MODE (GtkList *list, - GtkSelectionMode mode) -{ - gtk_list_set_selection_mode (list, - mode); -} - -void GTK_LIST_UNSELECT_ITEM (GtkList *list, - gint item) -{ - gtk_list_unselect_item (list, - item); -} - -void GTK_MAIN (void) -{ - gtk_main (); -} - -gint GTK_MAIN_ITERATION (void) -{ - return gtk_main_iteration (); -} - -guint GTK_MAIN_LEVEL (void) -{ - return gtk_main_level (); -} - -void GTK_MAIN_QUIT (void) -{ - gtk_main_quit (); -} - -GdkEventMask GDK_WINDOW_GET_EVENTS (GdkWindow *window) -{ - return gdk_window_get_events (window); -} - -void GDK_WINDOW_SET_EVENTS (GdkWindow *window, - GdkEventMask event_mask) -{ - gdk_window_set_events (window, - event_mask); -} - -guint GTK_IDLE_ADD_PRIORITY (gint priority, - GtkFunction function, - gpointer data) -{ - return gtk_idle_add_priority (priority, - function, - data); -} - -guint VMS_GTK_MAJOR_VERSION( void ) -{ - return gtk_major_version; -} - -guint VMS_GTK_MINOR_VERSION( void ) -{ - return gtk_minor_version; -} - -guint VMS_GTK_MICRO_VERSION( void ) -{ - return gtk_micro_version; -} - -GtkWidget* -gtk_item_factory_get_item (GtkItemFactory *ifactory, - const gchar *path) -{ - GtkWidget *widget; - - g_return_val_if_fail (GTK_IS_ITEM_FACTORY (ifactory), NULL); - g_return_val_if_fail (path != NULL, NULL); - - widget = gtk_item_factory_get_widget (ifactory, path); - - if (GTK_IS_MENU (widget)) - widget = gtk_menu_get_attach_widget (GTK_MENU (widget)); - - return GTK_IS_ITEM (widget) ? widget : NULL; -} - -void GTK_MARSHAL_NONE__POINTER_POINT (GtkObject * object, - GtkSignalFunc func, - gpointer func_data, GtkArg * args) -{ - gtk_marshal_NONE__POINTER_POINTER (object, - func, - func_data, args); -} - -void GTK_MENU_APPEND (GtkMenu *menu, - GtkWidget *child) -{ - gtk_menu_append (menu, - child); -} - -GtkType GTK_MENU_BAR_GET_TYPE (void) -{ - return gtk_menu_bar_get_type (); -} - -GtkType GTK_MENU_GET_TYPE (void) -{ - return gtk_menu_get_type (); -} - -void GTK_MENU_INSERT (GtkMenu *menu, - GtkWidget *child, - gint position) -{ - gtk_menu_insert (menu, - child, - position); -} - -GtkType GTK_MENU_ITEM_GET_TYPE (void) -{ - return gtk_menu_item_get_type (); -} - -GtkWidget* GTK_MENU_ITEM_NEW_WITH_LABEL (const gchar *label) -{ - return gtk_menu_item_new_with_label (label); -} - -void GTK_MENU_ITEM_SET_SUBMENU (GtkMenuItem *menu_item, - GtkWidget *submenu) -{ - gtk_menu_item_set_submenu (menu_item, - submenu); -} - -GtkWidget* GTK_MENU_NEW (void) -{ - return gtk_menu_new (); -} - -void GTK_MENU_POPUP (GtkMenu *menu, - GtkWidget *parent_menu_shell, - GtkWidget *parent_menu_item, - GtkMenuPositionFunc func, - gpointer data, - guint button, - guint32 activate_time) -{ - gtk_menu_popup (menu, - parent_menu_shell, - parent_menu_item, - func, - data, - button, - activate_time); -} - -GtkType GTK_MENU_SHELL_GET_TYPE (void) -{ - return gtk_menu_shell_get_type (); -} - -GtkType GTK_MISC_GET_TYPE (void) -{ - return gtk_misc_get_type (); -} - -void GTK_MISC_SET_ALIGNMENT (GtkMisc *misc, - gfloat xalign, - gfloat yalign) -{ - gtk_misc_set_alignment (misc, - xalign, - yalign); -} - -void GTK_OBJECT_UNREF (GtkObject *object) -{ - gtk_object_unref (object); -} - -GtkWidget* GTK_OPTION_MENU_GET_MENU (GtkOptionMenu *option_menu) -{ - return gtk_option_menu_get_menu (option_menu); -} - -GtkType GTK_OPTION_MENU_GET_TYPE (void) -{ - return gtk_option_menu_get_type (); -} - -GtkWidget* GTK_OPTION_MENU_NEW (void) -{ - return gtk_option_menu_new (); -} - -void GTK_OPTION_MENU_REMOVE_MENU (GtkOptionMenu *option_menu) -{ - gtk_option_menu_remove_menu (option_menu); -} - -void GTK_OPTION_MENU_SET_HISTORY (GtkOptionMenu *option_menu, - guint index) -{ - gtk_option_menu_set_history (option_menu, - index); -} - -void GTK_OPTION_MENU_SET_MENU (GtkOptionMenu *option_menu, - GtkWidget *menu) -{ - gtk_option_menu_set_menu (option_menu, - menu); -} - -GtkType GTK_PIXMAP_GET_TYPE (void) -{ - return gtk_pixmap_get_type (); -} - -GtkWidget* GTK_PIXMAP_NEW (GdkPixmap *pixmap, - GdkBitmap *mask) -{ - return gtk_pixmap_new (pixmap, - mask); -} - -void GTK_PIXMAP_SET (GtkPixmap *pixmap, - GdkPixmap *val, - GdkBitmap *mask) -{ - gtk_pixmap_set (pixmap, - val, - mask); -} - -void GTK_PIXMAP_SET_BUILD_INSENSITIV (GtkPixmap *pixmap, - guint build) -{ - gtk_pixmap_set_build_insensitive (pixmap, - build); -} - -GtkType GTK_PROGRESS_BAR_GET_TYPE (void) -{ - return gtk_progress_bar_get_type (); -} - -GtkWidget* GTK_PROGRESS_BAR_NEW (void) -{ - return gtk_progress_bar_new (); -} - -void GTK_PROGRESS_BAR_UPDATE (GtkProgressBar *pbar, - gfloat percentage) -{ - gtk_progress_bar_update (pbar, - percentage); -} - -GtkType GTK_RADIO_BUTTON_GET_TYPE (void) -{ - return gtk_radio_button_get_type (); -} - -GSList* GTK_RADIO_BUTTON_GROUP (GtkRadioButton *radio_button) -{ - return gtk_radio_button_group (radio_button); -} - -GtkWidget* GTK_RADIO_BUTTON_NEW_WITH_LABEL (GSList *group, - const gchar *label) -{ - return gtk_radio_button_new_with_label (group, - label); -} - -GtkAdjustment* GTK_RANGE_GET_ADJUSTMENT (GtkRange *range) -{ - return gtk_range_get_adjustment (range); -} - -GtkType GTK_RANGE_GET_TYPE (void) -{ - return gtk_range_get_type (); -} - -GtkStyle* GTK_RC_GET_STYLE (GtkWidget *widget) -{ - return gtk_rc_get_style (widget); -} - -GtkType GTK_SCALE_GET_TYPE (void) -{ - return gtk_scale_get_type (); -} - -void GTK_SCALE_SET_DIGITS (GtkScale *scale, - gint digits) -{ - gtk_scale_set_digits (scale, - digits); -} - -void GTK_SCALE_SET_DRAW_VALUE (GtkScale *scale, - gboolean draw_value) -{ - gtk_scale_set_draw_value (scale, - draw_value); -} - -void GTK_SCROLLED_WINDOW_ADD_WITH_VI (GtkScrolledWindow *scrolled_window, - GtkWidget *child) -{ - gtk_scrolled_window_add_with_viewport (scrolled_window, - child); -} - -GtkType GTK_SCROLLED_WINDOW_GET_TYPE (void) -{ - return gtk_scrolled_window_get_type (); -} - -GtkAdjustment* GTK_SCROLLED_WINDOW_GET_VADJUST (GtkScrolledWindow *scrolled_window) -{ - return gtk_scrolled_window_get_vadjustment (scrolled_window); -} - -GtkWidget* GTK_SCROLLED_WINDOW_NEW (GtkAdjustment *hadjustment, - GtkAdjustment *vadjustment) -{ - return gtk_scrolled_window_new (hadjustment, - vadjustment); -} - -void GTK_SCROLLED_WINDOW_SET_POLICY (GtkScrolledWindow *scrolled_window, - GtkPolicyType hscrollbar_policy, - GtkPolicyType vscrollbar_policy) -{ - gtk_scrolled_window_set_policy (scrolled_window, - hscrollbar_policy, - vscrollbar_policy); -} - -gchar* GTK_SET_LOCALE (void) -{ - return gtk_set_locale (); -} - -guint GTK_SIGNAL_CONNECT (GtkObject *object, - const gchar *name, - GtkSignalFunc func, - gpointer func_data) -{ - return gtk_signal_connect (object, - name, - func, - func_data); -} - -guint GTK_SIGNAL_CONNECT_AFTER (GtkObject *object, - const gchar *name, - GtkSignalFunc func, - gpointer func_data) -{ - return gtk_signal_connect_after (object, - name, - func, - func_data); -} - -void GTK_SIGNAL_DISCONNECT_BY_FUNC (GtkObject *object, - GtkSignalFunc func, - gpointer data) -{ - gtk_signal_disconnect_by_func (object, - func, - data); -} - -void GTK_SIGNAL_EMIT_BY_NAME (GtkObject *object, - const gchar *name - ) -{ - gtk_signal_emit_by_name (object, - name - ); - -} - -void GTK_SIGNAL_EMIT_STOP_BY_NAME (GtkObject *object, - const gchar *name) -{ - gtk_signal_emit_stop_by_name (object, - name); -} - -#define MAX_SIGNAL_PARAMS (31) - -guint GTK_SIGNAL_NEW (const gchar *name, - GtkSignalRunType signal_flags, - GtkType object_type, - guint function_offset, - GtkSignalMarshaller marshaller, - GtkType return_val, - guint nparams, - ...) -{ - GtkType *params; - guint i; - va_list args; - guint signal_id; - - g_return_val_if_fail (nparams < MAX_SIGNAL_PARAMS, 0); - - if (nparams > 0) - { - params = g_new (GtkType, nparams); - - va_start (args, nparams); - - for (i = 0; i < nparams; i++) - params[i] = va_arg (args, GtkType); - - va_end (args); - } - else - params = NULL; - - signal_id = gtk_signal_newv (name, - signal_flags, - object_type, - function_offset, - marshaller, - return_val, - nparams, - params); - - g_free (params); - - return signal_id; -} - -GtkStyle* GTK_STYLE_ATTACH (GtkStyle *style, - GdkWindow *window) -{ - return gtk_style_attach (style, - window); -} - -GtkStyle* GTK_STYLE_COPY (GtkStyle *style) -{ - return gtk_style_copy (style); -} - -void GTK_STYLE_SET_BACKGROUND (GtkStyle *style, - GdkWindow *window, - GtkStateType state_type) -{ - gtk_style_set_background (style, - window, - state_type); -} - -void GTK_STYLE_UNREF (GtkStyle *style) -{ - gtk_style_unref (style); -} - -void GTK_TABLE_ATTACH (GtkTable *table, - GtkWidget *child, - guint left_attach, - guint right_attach, - guint top_attach, - guint bottom_attach, - GtkAttachOptions xoptions, - GtkAttachOptions yoptions, - guint xpadding, - guint ypadding) -{ - gtk_table_attach (table, - child, - left_attach, - right_attach, - top_attach, - bottom_attach, - xoptions, - yoptions, - xpadding, - ypadding); -} - -GtkType GTK_TABLE_GET_TYPE (void) -{ - return gtk_table_get_type (); -} - -GtkWidget* GTK_TABLE_NEW (guint rows, - guint columns, - gboolean homogeneous) -{ - return gtk_table_new (rows, - columns, - homogeneous); -} - -guint GTK_TEXT_GET_LENGTH (GtkText *text) -{ - return gtk_text_get_length (text); -} - -guint GTK_TEXT_GET_POINT (GtkText *text) -{ - return gtk_text_get_point (text); -} - -GtkType GTK_TEXT_GET_TYPE (void) -{ - return gtk_text_get_type (); -} - -void GTK_TEXT_INSERT (GtkText *text, - GdkFont *font, - GdkColor *fore, - GdkColor *back, - const char *chars, - gint length) -{ - gtk_text_insert (text, - font, - fore, - back, - chars, - length); -} - -GtkWidget* GTK_TEXT_NEW (GtkAdjustment *hadj, - GtkAdjustment *vadj) -{ - return gtk_text_new (hadj, - vadj); -} - -void GTK_TEXT_SET_EDITABLE (GtkText *text, - gboolean editable) -{ - gtk_text_set_editable (text, - editable); -} - -void GTK_TEXT_SET_WORD_WRAP (GtkText *text, - gint word_wrap) -{ - gtk_text_set_word_wrap (text, - word_wrap); -} - -guint GTK_TIMEOUT_ADD (guint32 interval, - GtkFunction function, - gpointer data) -{ - return gtk_timeout_add (interval, - function, - data); -} - -void GTK_TIMEOUT_REMOVE (guint timeout_handler_id) -{ - gtk_timeout_remove (timeout_handler_id); -} - -GtkType GTK_TOGGLE_BUTTON_GET_TYPE (void) -{ - return gtk_toggle_button_get_type (); -} - -void GTK_TOGGLE_BUTTON_SET_ACTIVE (GtkToggleButton *toggle_button, - gboolean is_active) -{ - gtk_toggle_button_set_active (toggle_button, - is_active); -} - -void GTK_TOOLBAR_APPEND_SPACE (GtkToolbar *toolbar) -{ - gtk_toolbar_append_space (toolbar); -} - -GtkType GTK_TOOLBAR_GET_TYPE (void) -{ - return gtk_toolbar_get_type (); -} - -GtkWidget* GTK_TOOLBAR_INSERT_ELEMENT (GtkToolbar *toolbar, - GtkToolbarChildType type, - GtkWidget *widget, - const char *text, - const char *tooltip_text, - const char *tooltip_private_text, - GtkWidget *icon, - GtkSignalFunc callback, - gpointer user_data, - gint position) -{ - return gtk_toolbar_insert_element (toolbar, - type, - widget, - text, - tooltip_text, - tooltip_private_text, - icon, - callback, - user_data, - position); -} - -void GTK_TOOLBAR_INSERT_WIDGET (GtkToolbar *toolbar, - GtkWidget *widget, - const char *tooltip_text, - const char *tooltip_private_text, - gint position) -{ - gtk_toolbar_insert_widget (toolbar, - widget, - tooltip_text, - tooltip_private_text, - position); - - -} - -GtkWidget* GTK_TOOLBAR_NEW (GtkOrientation orientation, - GtkToolbarStyle style) -{ - return gtk_toolbar_new (orientation, - style); -} - -void GTK_TOOLBAR_SET_BUTTON_RELIEF (GtkToolbar *toolbar, - GtkReliefStyle relief) -{ - gtk_toolbar_set_button_relief (toolbar, - relief); -} - -void GTK_TOOLBAR_SET_SPACE_SIZE (GtkToolbar *toolbar, - gint space_size) -{ - gtk_toolbar_set_space_size (toolbar, - space_size); -} - -void GTK_TOOLBAR_SET_TOOLTIPS (GtkToolbar *toolbar, - gint enable) -{ - gtk_toolbar_set_tooltips (toolbar, - enable); -} - -void GTK_TOOLTIPS_FORCE_WINDOW (GtkTooltips *tooltips) -{ - gtk_tooltips_force_window (tooltips); -} - -GtkTypeClass* GTK_TYPE_CHECK_CLASS_CAST (GtkTypeClass *klass, - GtkType cast_type) -{ - return gtk_type_check_class_cast (klass, - cast_type); -} - -GtkTypeObject* GTK_TYPE_CHECK_OBJECT_CAST (GtkTypeObject *type_object, - GtkType cast_type) -{ - return gtk_type_check_object_cast (type_object, - cast_type); -} - -gpointer GTK_TYPE_CLASS (GtkType type) -{ - return gtk_type_class (type); -} - -gboolean GTK_TYPE_IS_A (GtkType type, - GtkType is_a_type) -{ - return gtk_type_is_a (type, - is_a_type); -} - -gpointer GTK_TYPE_NEW (GtkType type) -{ - return gtk_type_new (type); -} - -GtkType GTK_TYPE_UNIQUE (GtkType parent_type, - const GtkTypeInfo *type_info) -{ - return gtk_type_unique (parent_type, - type_info); -} - -GtkWidget* GTK_VSCALE_NEW (GtkAdjustment *adjustment) -{ - return gtk_vscale_new (adjustment); -} - -GtkWidget* GTK_VSCROLLBAR_NEW (GtkAdjustment *adjustment) -{ - return gtk_vscrollbar_new (adjustment); -} - -GtkWidget* GTK_VSEPARATOR_NEW (void) -{ - return gtk_vseparator_new (); -} - -gboolean GTK_WIDGET_ACTIVATE (GtkWidget *widget) -{ - return gtk_widget_activate (widget); -} - -void GTK_WIDGET_DESTROY (GtkWidget *widget) -{ - gtk_widget_destroy (widget); -} - -void GTK_WIDGET_DRAW (GtkWidget *widget, - GdkRectangle *area) -{ - gtk_widget_draw (widget, - area); -} - -gint GTK_WIDGET_EVENT (GtkWidget *widget, - GdkEvent *event) -{ - return gtk_widget_event (widget, - event); -} - -void GTK_WIDGET_GET_CHILD_REQUISITIO (GtkWidget *widget, - GtkRequisition *requisition) -{ - gtk_widget_get_child_requisition (widget, - requisition); -} - -GdkColormap* GTK_WIDGET_GET_COLORMAP (GtkWidget *widget) -{ - return gtk_widget_get_colormap (widget); -} - -GdkColormap* GTK_WIDGET_GET_DEFAULT_COLORMAP (void) -{ - return gtk_widget_get_default_colormap (); -} - -GtkStyle* GTK_WIDGET_GET_DEFAULT_STYLE (void) -{ - return gtk_widget_get_default_style (); -} - -gint GTK_WIDGET_GET_EVENTS (GtkWidget *widget) -{ - return gtk_widget_get_events (widget); -} - -GdkWindow *GTK_WIDGET_GET_PARENT_WINDOW (GtkWidget *widget) -{ - return gtk_widget_get_parent_window (widget); -} - -GtkStyle* GTK_WIDGET_GET_STYLE (GtkWidget *widget) -{ - return gtk_widget_get_style (widget); -} - -GtkType GTK_WIDGET_GET_TYPE (void) -{ - return gtk_widget_get_type (); -} - -GdkVisual* GTK_WIDGET_GET_VISUAL (GtkWidget *widget) -{ - return gtk_widget_get_visual (widget); -} - -void GTK_WIDGET_GRAB_DEFAULT (GtkWidget *widget) -{ - gtk_widget_grab_default (widget); -} - -void GTK_WIDGET_GRAB_FOCUS (GtkWidget *widget) -{ - gtk_widget_grab_focus (widget); -} - -void GTK_WIDGET_HIDE (GtkWidget *widget) -{ - gtk_widget_hide (widget); -} - -gint GTK_WIDGET_INTERSECT (GtkWidget *widget, - GdkRectangle *area, - GdkRectangle *intersection) -{ - return gtk_widget_intersect (widget, - area, - intersection); -} - -void GTK_WIDGET_MAP (GtkWidget *widget) -{ - gtk_widget_map (widget); -} - -void GTK_WIDGET_QUEUE_DRAW (GtkWidget *widget) -{ - gtk_widget_queue_draw (widget); -} - -void GTK_WIDGET_QUEUE_RESIZE (GtkWidget *widget) -{ - gtk_widget_queue_resize (widget); -} - -void GTK_WIDGET_REALIZE (GtkWidget *widget) -{ - gtk_widget_realize (widget); -} - -void GTK_WIDGET_REF (GtkWidget *widget) -{ - gtk_widget_ref (widget); -} - -void GTK_WIDGET_REPARENT (GtkWidget *widget, - GtkWidget *new_parent) -{ - gtk_widget_reparent (widget, - new_parent); -} - -void GTK_WIDGET_SET_DEFAULT_COLORMAP (GdkColormap *colormap) -{ - gtk_widget_set_default_colormap (colormap); -} - -void GTK_WIDGET_SET_DEFAULT_VISUAL (GdkVisual *visual) -{ - gtk_widget_set_default_visual (visual); -} - -void GTK_WIDGET_SET_PARENT (GtkWidget *widget, - GtkWidget *parent) -{ - gtk_widget_set_parent (widget, - parent); -} - -void GTK_WIDGET_SET_PARENT_WINDOW (GtkWidget *widget, - GdkWindow *parent_window) -{ - gtk_widget_set_parent_window (widget, - parent_window); -} - -void GTK_WIDGET_SET_SENSITIVE (GtkWidget *widget, - gboolean sensitive) -{ - gtk_widget_set_sensitive (widget, - sensitive); -} - -void GTK_WIDGET_SET_STYLE (GtkWidget *widget, - GtkStyle *style) -{ - gtk_widget_set_style (widget, - style); -} - -void GTK_WIDGET_SET_UPOSITION (GtkWidget *widget, - gint x, - gint y) -{ - gtk_widget_set_uposition (widget, - x, - y); -} - -void GTK_WIDGET_SET_USIZE (GtkWidget *widget, - gint width, - gint height) -{ - gtk_widget_set_usize (widget, - width, - height); -} - -void GTK_WIDGET_SHOW (GtkWidget *widget) -{ - gtk_widget_show (widget); -} - -void GTK_WIDGET_SIZE_ALLOCATE (GtkWidget *widget, - GtkAllocation *allocation) -{ - gtk_widget_size_allocate (widget, - allocation); -} - -void GTK_WIDGET_SIZE_REQUEST (GtkWidget *widget, - GtkRequisition *requisition) -{ - gtk_widget_size_request (widget, - requisition); -} - -void GTK_WIDGET_UNMAP (GtkWidget *widget) -{ - gtk_widget_unmap (widget); -} - -void GTK_WIDGET_UNPARENT (GtkWidget *widget) -{ - gtk_widget_unparent (widget); -} - -void GTK_WIDGET_UNREF (GtkWidget *widget) -{ - gtk_widget_unref (widget); -} - -GtkType GTK_WINDOW_GET_TYPE (void) -{ - return gtk_window_get_type (); -} - -GtkWidget* GTK_WINDOW_NEW (GtkWindowType type) -{ - return gtk_window_new (type); -} - -void GTK_WINDOW_SET_POLICY (GtkWindow *window, - gint allow_shrink, - gint allow_grow, - gint auto_shrink) -{ - gtk_window_set_policy (window, - allow_shrink, - allow_grow, - auto_shrink); -} - -void GTK_WINDOW_SET_TITLE (GtkWindow *window, - const gchar *title) -{ - gtk_window_set_title (window, - title); -} - -void GTK_WINDOW_SET_TRANSIENT_FOR (GtkWindow *window, - GtkWindow *parent) -{ - gtk_window_set_transient_for (window, - parent); -} - -void GTK_WINDOW_SET_WMCLASS (GtkWindow *window, - const gchar *wmclass_name, - const gchar *wmclass_class) -{ - gtk_window_set_wmclass (window, - wmclass_name, - wmclass_class); -} - -void G_FREE (gpointer mem) -{ - g_free (mem); -} - -GList* G_LIST_ALLOC (void) -{ - return g_list_alloc (); -} - -GList* G_LIST_APPEND (GList *list, - gpointer data) -{ - return g_list_append (list, - data); -} - -void G_LIST_FREE (GList *list) -{ - g_list_free (list); -} - -GList* G_LIST_INSERT (GList *list, - gpointer data, - gint position) -{ - return g_list_insert (list, - data, - position); -} - -GList* G_LIST_LAST (GList *list) -{ - return g_list_last (list); -} - -guint G_LIST_LENGTH (GList *list) -{ - return g_list_length (list); -} - -GList* G_LIST_NTH (GList *list, - guint n) -{ - return g_list_nth (list, - n); -} - -GList* G_LIST_REMOVE (GList *list, - gpointer data) -{ - return g_list_remove (list, - data); -} - -GList* G_LIST_REMOVE_LINK (GList *list, - GList *llink) -{ - return g_list_remove_link (list, - llink); -} - -void G_LOG (const gchar *log_domain, - GLogLevelFlags log_level, - const gchar *format, - ...) -{ - va_list args; - - va_start (args, format); - g_logv (log_domain, log_level, format, args); - va_end (args); -} - -void G_LOGV (const gchar *log_domain, - GLogLevelFlags log_level, - const gchar *format, - va_list args) -{ - g_logv (log_domain, - log_level, - format, - args); -} - -gpointer G_MALLOC (gulong size) -{ - return g_malloc (size); -} - -GSList* G_SLIST_FIND (GSList *list, - gpointer data) -{ - return g_slist_find (list, - data); -} - -void GTK_WINDOW_SET_GEOMETRY_HINTS (GtkWindow *window, - GtkWidget *geometry_widget, - GdkGeometry *geometry, - GdkWindowHints geom_mask) -{ - gtk_window_set_geometry_hints (window, - geometry_widget, - geometry, - geom_mask); -} - -#undef GDK_THREADS_ENTER -void GDK_THREADS_ENTER (void) -{ - gdk_threads_enter1 (); -} - -#undef GDK_THREADS_LEAVE -void GDK_THREADS_LEAVE (void) -{ - gdk_threads_leave1 (); -}