Removed the gtk1 (deep) copy dirs from WX_2_4_BRANCH.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@37269 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Ron Lee
2006-02-03 16:21:16 +00:00
parent 293ccea4ed
commit 211acbb674
141 changed files with 0 additions and 44770 deletions

View File

@@ -1,2 +0,0 @@
setup.h
Makefile.in

View File

@@ -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"

View File

@@ -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__

View File

@@ -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__

View File

@@ -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__

View File

@@ -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__

View File

@@ -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__

View File

@@ -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__

View File

@@ -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__

View File

@@ -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__

View File

@@ -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__

View File

@@ -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__

View File

@@ -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__

View File

@@ -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__

View File

@@ -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__

View File

@@ -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 <zeitlin@dptmaths.ens-cachan.fr>
// 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

View File

@@ -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_

View File

@@ -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_

View File

@@ -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__

View File

@@ -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 &region );
// 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__

View File

@@ -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__

View File

@@ -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__

View File

@@ -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__

View File

@@ -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 &copy = wxNullIcon,
const wxIcon &move = wxNullIcon,
const wxIcon &none = wxNullIcon);
// constructor for setting one data object
wxDropSource( wxDataObject& data,
wxWindow *win,
const wxIcon &copy = 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__

View File

@@ -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__

View File

@@ -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__

View File

@@ -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

View File

@@ -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__

View File

@@ -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__

View File

@@ -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__

View File

@@ -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 <GL/gl.h>
#include <GL/glx.h>
#include <GL/glu.h>
}
//---------------------------------------------------------------------------
// 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_

View File

@@ -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__

View File

@@ -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__

View File

@@ -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__

View File

@@ -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__

View File

@@ -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__

View File

@@ -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__

View File

@@ -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__

View File

@@ -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__

View File

@@ -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__

View File

@@ -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__

View File

@@ -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 <vadim@wxwindows.org>
// Licence: wxWindows license
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GTK_PRIVATE_H_
#define _WX_GTK_PRIVATE_H_
#include <gdk/gdk.h>
#include <gtk/gtk.h>
#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_

View File

@@ -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__

View File

@@ -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__

View File

@@ -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_

View File

@@ -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__

View File

@@ -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

View File

@@ -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__

View File

@@ -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_

View File

@@ -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__

View File

@@ -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__

View File

@@ -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__

View File

@@ -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__

View File

@@ -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__

View File

@@ -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_

View File

@@ -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__

View File

@@ -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_

View File

@@ -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__

View File

@@ -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__

View File

@@ -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__

View File

@@ -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 <gtk/gtk.h>
// 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_

View File

@@ -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

View File

@@ -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 <gdk/gdk.h>
#include <gdk/gdkx.h>
#include <gtk/gtkcontainer.h>
#include <gtk/gtkadjustment.h>
#ifndef __WXGTK20__
#include <gtk/gtkfeatures.h>
#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__ */

View File

@@ -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__

View File

@@ -1,3 +0,0 @@
Makefile.in
*.lo
*.la

View File

@@ -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 <vms_jackets.h>
#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 <unistd.h>
#ifdef HAVE_POLL
#if defined(__VMS)
#include <poll.h>
#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 <sys/poll.h>
#ifdef __OPENBSD__
};
#endif
#endif // platform
#else // !HAVE_POLL
// we implement poll() ourselves using select() which is supposed exist in
// all modern Unices
#include <sys/types.h>
#include <sys/time.h>
#include <unistd.h>
#endif // HAVE_POLL/!HAVE_POLL
#include "wx/gtk/win_gtk.h"
#include <gtk/gtk.h>
//-----------------------------------------------------------------------------
// 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__

View File

@@ -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};

File diff suppressed because it is too large Load Diff

View File

@@ -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

View File

@@ -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 <gdk/gdk.h>
//-----------------------------------------------------------------------------
// 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;
}
}

View File

@@ -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

View File

@@ -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};

View File

@@ -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

View File

@@ -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 <gdk/gdk.h>
#include <gtk/gtk.h>
//-----------------------------------------------------------------------------
// 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

View File

@@ -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<wxObject>
// and not wxList<wxClientData> 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

View File

@@ -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 <glib.h>
#include <gdk/gdk.h>
#include <gtk/gtk.h>
//-----------------------------------------------------------------------------
// 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; i<selection_data->length/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

View File

@@ -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 <gdk/gdk.h>
#include <gdk/gdkx.h>
#include <gdk/gdkprivate.h>
//-----------------------------------------------------------------------------
// 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;
}

View File

@@ -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

View File

@@ -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 <gtk/gtk.h>
//-----------------------------------------------------------------------------
// 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

View File

@@ -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};

View File

@@ -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 <gdk/gdk.h>
#include <gtk/gtk.h>
//-----------------------------------------------------------------------------
// 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<imagebitcount; i++)
{
bits[i] = 0;
i8 = i * 8;
cMask = 1;
for (j=0; j<8; j++)
{
// possible overflow if we do the summation first ?
c = rgbBits[(i8+j)*3]/3 + rgbBits[(i8+j)*3+1]/3 + rgbBits[(i8+j)*3+2]/3;
//if average value is > 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; i<imagebitcount; i++)
{
maskBits[i] = 0x0;
i8 = i * 8;
cMask = 1;
for (j=0; j<8; j++)
{
if (rgbBits[(i8+j)*3] != r || rgbBits[(i8+j)*3+1] != g || rgbBits[(i8+j)*3+2] != b)
maskBits[i] = maskBits[i] | cMask;
cMask = cMask * 2;
}
}
keyMaskColor = (r << 16) | (g << 8) | b;
}
else // no mask
{
for (i=0; i<imagebitcount; i++)
maskBits[i] = 0xFF;
// init it to avoid compiler warnings
keyMaskColor = 0;
}
// find the most frequent color(s)
wxImageHistogram histogram;
image.ComputeHistogram(histogram);
// colors as rrggbb
unsigned long key;
unsigned long value;
long colMostFreq = 0;
unsigned long nMost = 0;
long colNextMostFreq = 0;
unsigned long nNext = 0;
for ( wxImageHistogram::iterator entry = histogram.begin();
entry != histogram.end();
++entry )
{
value = entry->second.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;
}

View File

@@ -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);

View File

@@ -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 <gdk/gdk.h>
//-------------------------------------------------------------------------
// 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);
}

View File

@@ -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 <gdk/gdk.h>
#include <gtk/gtk.h>
//-----------------------------------------------------------------------------
// 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);
}

File diff suppressed because it is too large Load Diff

View File

@@ -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 <gdk/gdk.h>
#include <gtk/gtk.h>
//-----------------------------------------------------------------------------
// 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;
}
}

View File

@@ -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 <gdk/gdk.h>
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
//-----------------------------------------------------------------------------
// 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);
}

View File

@@ -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

View File

@@ -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 <gdk/gdk.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#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 );
}

View File

@@ -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 <gdk/gdkprivate.h>
#include <gtk/gtkdnd.h>
#include <gtk/gtkselection.h>
//-----------------------------------------------------------------------------
// 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<<<<t;O ",
" e0yyrqq9642%&*=to ",
" e00yyrqq9642%&*=o ",
" eu0wwwwwww777<&*X ",
" euu00yyrqq9642%&X ",
" eiuu00yyrqq9642%X ",
" eiiwwwwwwwwww742$ ",
" eiiiuu00yyrqq964$ ",
" eiiiiuu00yyrqq96$ ",
" eiiiiiuu00yyrqq95 ",
" eiiiiiiuu00yyrqq5 ",
" eeeeeeeeeeeeee55e ",
" ",
" ",
" ",
" ",
" "
};
// ============================================================================
// private functions
// ============================================================================
// ----------------------------------------------------------------------------
// convert between GTK+ and wxWindows DND constants
// ----------------------------------------------------------------------------
static wxDragResult ConvertFromGTK(long action)
{
switch ( action )
{
case GDK_ACTION_COPY:
return wxDragCopy;
case GDK_ACTION_LINK:
return wxDragLink;
case GDK_ACTION_MOVE:
return wxDragMove;
}
return wxDragNone;
}
// ----------------------------------------------------------------------------
// "drag_leave"
// ----------------------------------------------------------------------------
static void target_drag_leave( GtkWidget *WXUNUSED(widget),
GdkDragContext *context,
guint WXUNUSED(time),
wxDropTarget *drop_target )
{
if (g_isIdle) wxapp_install_idle_handler();
/* inform the wxDropTarget about the current GdkDragContext.
this is only valid for the duration of this call */
drop_target->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

View File

@@ -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 <zeitlin@dptmaths.ens-cachan.fr>
// 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 <gtk/gtk.h>
// ----------------------------------------------------------------------------
// 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;
}

View File

@@ -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};

View File

@@ -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 <gtk/gtk.h>
//-----------------------------------------------------------------------------
// 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);
}

View File

@@ -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

View File

@@ -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 <strings.h>
#include "wx/gtk/private.h"
#include <gdk/gdkprivate.h>
// ----------------------------------------------------------------------------
// 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;
}

View File

@@ -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

View File

@@ -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 <glib.h>
#include "wx/gtk/private.h"
#include <gdk/gdkkeysyms.h>
#include <gdk/gdkx.h>
#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

View File

@@ -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 <gtk/gtk.h>
//-----------------------------------------------------------------------------
// 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

View File

@@ -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)

View File

@@ -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

Some files were not shown because too many files have changed in this diff Show More