// Don't do parent client adjustments (for implementation only)
#define wxSIZE_NO_ADJUSTMENTS 0x0008
-// Clipboard formats
-// Numbers as per winuser.h
-# define wxCF_TEXT 1 /* CF_TEXT */
-# define wxCF_BITMAP 2 /* CF_BITMAP */
-# define wxCF_METAFILE 3 /* CF_METAFILEPICT */
-# define wxCF_DIB 8 /* CF_DIB */
-# define wxCF_OEMTEXT 7 /* CF_OEMTEXT */
+
+// Data format for drag & drop and clipboard operations
+// numbers as per winuser.h
+
+enum wxDataFormat
+{
+ wxDF_TEXT = 1, /* CF_TEXT */
+ wxDF_BITMAP = 2, /* CF_BITMAP */
+ wxDF_METAFILE = 3, /* CF_METAFILEPICT */
+ wxDF_DIB = 8, /* CF_DIB */
+ wxDF_OEMTEXT = 7, /* CF_OEMTEXT */
+ wxDF_FILENAME = 15 /* CF_HDROP */
+};
// Virtual keycodes
+
enum _Virtual_keycodes {
WXK_BACK = 8,
WXK_TAB = 9,
#endif
-// for drag & drop and clipboard operations
-typedef unsigned short wxDataFormat;
-
#endif
// __WXDEFSH__
bool m_renameAccept;
wxString m_renameRes;
bool m_isCreated;
- bool m_isDragging;
+ int m_dragCount;
public:
wxListMainWindow(void);
int GetItemState( long item, long stateMask );
int GetItemCount( void );
void GetItemRect( long index, wxRectangle &rect );
+ bool GetItemPosition(long item, wxPoint& pos);
int GetSelectedItemCount( void );
void SetMode( long mode );
long GetMode( void ) const;
void SetItemText( long item, const wxString& str );
long GetItemData( long item );
bool SetItemData( long item, long data );
- bool GetItemRect( long item, wxRectangle& rect, int code = wxLIST_RECT_BOUNDS ); // not supported in wxGLC
- bool GetItemPosition( long item, wxPoint& pos ) const; // not supported in wxGLC
+ bool GetItemRect( long item, wxRectangle& rect, int code = wxLIST_RECT_BOUNDS );
+ bool GetItemPosition( long item, wxPoint& pos );
bool SetItemPosition( long item, const wxPoint& pos ); // not supported in wxGLC
int GetItemCount(void);
void SetItemSpacing( int spacing, bool isSmall = FALSE );
class wxWindow;
+class wxDataObject;
+class wxTextDataObject;
+class wxFileDataObject;
+
class wxDropTarget;
class wxTextDropTarget;
-class wxDragSource;
-class wxTextDragSource;
+class wxFileDropTarget;
+
+class wxDropSource;
+
+//-------------------------------------------------------------------------
+// wxDataObject
+//-------------------------------------------------------------------------
+
+class wxDataObject: public wxObject
+{
+public:
+ // all data formats (values are the same as in windows.h, do not change!)
+ enum StdFormat
+ {
+ Invalid,
+ Text,
+ Bitmap,
+ MetafilePict,
+ Sylk,
+ Dif,
+ Tiff,
+ OemText,
+ Dib,
+ Palette,
+ Pendata,
+ Riff,
+ Wave,
+ UnicodeText,
+ EnhMetafile,
+ Hdrop,
+ Locale,
+ Max
+ };
+
+ // function to return symbolic name of clipboard format (debug messages)
+ static const char *GetFormatName(wxDataFormat format);
+
+ // ctor & dtor
+ wxDataObject() {};
+ ~wxDataObject() {};
+
+ // pure virtuals to override
+ // get the best suited format for our data
+ virtual wxDataFormat GetPreferredFormat() const = 0;
+ // decide if we support this format (should be one of values of
+ // StdFormat enumerations or a user-defined format)
+ virtual bool IsSupportedFormat(wxDataFormat format) const = 0;
+ // get the (total) size of data
+ virtual uint GetDataSize() const = 0;
+ // copy raw data to provided pointer
+ virtual void GetDataHere(void *pBuf) const = 0;
+
+};
+
+// ----------------------------------------------------------------------------
+// wxTextDataObject is a specialization of wxDataObject for text data
+// ----------------------------------------------------------------------------
+
+class wxTextDataObject : public wxDataObject
+{
+public:
+ // ctors
+ wxTextDataObject() { }
+ wxTextDataObject(const wxString& strText) : m_strText(strText) { }
+ void Init(const wxString& strText) { m_strText = strText; }
+
+ // implement base class pure virtuals
+ virtual wxDataFormat GetPreferredFormat() const
+ { return wxDF_TEXT; }
+ virtual bool IsSupportedFormat(wxDataFormat format) const
+ { return format == wxDF_TEXT; }
+ virtual uint GetDataSize() const
+ { return m_strText.Len() + 1; } // +1 for trailing '\0'of course
+ virtual void GetDataHere(void *pBuf) const
+ { memcpy(pBuf, m_strText.c_str(), GetDataSize()); }
+
+private:
+ wxString m_strText;
+
+};
+// ----------------------------------------------------------------------------
+// wxFileDataObject is a specialization of wxDataObject for file names
+// ----------------------------------------------------------------------------
+
+class wxFileDataObject : public wxDataObject
+{
+public:
+
+ wxFileDataObject(void) { }
+ void AddFile( const wxString &file )
+ { m_files += file; m_files += ";"; }
+
+ // implement base class pure virtuals
+ virtual wxDataFormat GetPreferredFormat() const
+ { return wxDF_FILENAME; }
+ virtual bool IsSupportedFormat(wxDataFormat format) const
+ { return format == wxDF_FILENAME; }
+ virtual uint GetDataSize() const
+ { return m_files.Len() + 1; } // +1 for trailing '\0'of course
+ virtual void GetDataHere(void *pBuf) const
+ { memcpy(pBuf, m_files.c_str(), GetDataSize()); }
+
+private:
+ wxString m_files;
+
+};
//-------------------------------------------------------------------------
// wxDropTarget
//-------------------------------------------------------------------------
wxDropTarget();
~wxDropTarget();
+
virtual void OnEnter() { }
virtual void OnLeave() { }
virtual bool OnDrop( long x, long y, const void *pData ) = 0;
- public:
-
+// protected:
+
+ friend wxWindow;
+
+ // Override these to indicate what kind of data you support:
+
+ virtual size_t GetFormatCount() const = 0;
+ virtual wxDataFormat GetFormat(size_t n) const = 0;
+
void Drop( GdkEvent *event, int x, int y );
- virtual void RegisterWidget( GtkWidget *widget ) = 0;
+ void RegisterWidget( GtkWidget *widget );
void UnregisterWidget( GtkWidget *widget );
};
wxTextDropTarget() {};
virtual bool OnDrop( long x, long y, const void *pData );
virtual bool OnDropText( long x, long y, const char *psz );
- virtual void RegisterWidget( GtkWidget *widget );
+
+ protected:
+
+ virtual size_t GetFormatCount() const;
+ virtual wxDataFormat GetFormat(size_t n) const;
};
-//-------------------------------------------------------------------------
-// wxDragSource
-//-------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
+// A drop target which accepts files (dragged from File Manager or Explorer)
+// ----------------------------------------------------------------------------
-class wxDragSource: public wxObject
+class wxFileDropTarget: public wxDropTarget
{
public:
+
+ wxFileDropTarget() {};
+
+ virtual bool OnDrop(long x, long y, const void *pData);
+ virtual bool OnDropFiles( long x, long y,
+ size_t nFiles, const char * const aszFiles[]);
- wxDragSource( wxWindow *win );
- ~wxDragSource(void);
- void SetData( char *data, long size );
- void Start( int x, int y );
-
- public:
-
- void ConnectWindow(void);
- void UnconnectWindow(void);
- virtual void RegisterWindow(void) = 0;
- void UnregisterWindow(void);
+ protected:
- GtkWidget *m_widget;
- wxWindow *m_window;
- char *m_data;
- long m_size;
- wxCursor m_defaultCursor;
- wxCursor m_goaheadCursor;
+ virtual size_t GetFormatCount() const;
+ virtual wxDataFormat GetFormat(size_t n) const;
};
//-------------------------------------------------------------------------
-// wxTextDragSource
+// wxDropSource
//-------------------------------------------------------------------------
-class wxTextDragSource: public wxDragSource
+class wxDropSource: public wxObject
{
public:
- wxTextDragSource( wxWindow *win ) : wxDragSource(win) {};
- void SetTextData( const wxString &text );
- void RegisterWindow(void);
+ enum DragResult
+ {
+ Error, // error prevented the d&d operation from completing
+ None, // drag target didn't accept the data
+ Copy, // the data was successfully copied
+ Move, // the data was successfully moved
+ Cancel // the operation was cancelled by user (not an error)
+ };
+
+ wxDropSource( wxWindow *win );
+ wxDropSource( wxDataObject &data, wxWindow *win );
+
+ ~wxDropSource(void);
- private:
+ void SetData( wxDataObject &data );
+ DragResult DoDragDrop( bool bAllowMove = FALSE );
+
+ virtual bool GiveFeedback( DragResult WXUNUSED(effect), bool WXUNUSED(bScrolling) ) { return TRUE; };
+
+ protected:
- wxString m_tmp;
+ void RegisterWindow(void);
+ void UnregisterWindow(void);
+
+ GtkWidget *m_widget;
+ wxWindow *m_window;
+
+ wxDataObject *m_data;
+
+ wxCursor m_defaultCursor;
+ wxCursor m_goaheadCursor;
};
#endif
// set minimal/maxmimal size for the frame
virtual void SetSizeHints( int minW, int minH, int maxW, int maxH, int incW = -1 );
- virtual bool CreateStatusBar( int number = 1 );
+ virtual wxStatusBar* CreateStatusBar(int number=1, long style = wxST_SIZEGRIP, wxWindowID id = 0,
+ const wxString& name = "statusBar");
virtual wxStatusBar *GetStatusBar();
virtual void SetStatusText( const wxString &text, int number = 0 );
virtual void SetStatusWidths( int n, int *width );
- virtual wxToolBar *CreateToolBar( int style = 0,
- int orientation = wxHORIZONTAL, int rowsOrColumns = 1 );
+ virtual wxToolBar* CreateToolBar( long style = wxNO_BORDER|wxTB_HORIZONTAL, wxWindowID id = -1,
+ const wxString& name = wxToolBarNameStr);
virtual wxToolBar *GetToolBar();
virtual void SetMenuBar( wxMenuBar *menuBar );
void SetString( int n, const wxString &string );
void SetStringSelection( const wxString &string, bool select = TRUE );
+ virtual GtkWidget *GetDropTargetWidget(void);
+
private:
GtkList *m_list;
bool Destroy(void);
void OnCloseWindow( wxCloseEvent& event );
+ void OnSize( wxSizeEvent &event );
public:
uint m_idHandler; // the change page handler id
DECLARE_DYNAMIC_CLASS(wxNotebook)
- DECLARE_EVENT_TABLE()
};
// ----------------------------------------------------------------------------
virtual void AddSeparator(void);
virtual void ClearTools(void);
- virtual void Layout(void);
+ virtual void Realize(void);
virtual void EnableTool(int toolIndex, bool enable);
virtual void ToggleTool(int toolIndex, bool toggle); // toggle is TRUE if toggled on
wxTextCtrl& operator<<(double d);
wxTextCtrl& operator<<(const char c);
+ virtual GtkWidget* GetDropTargetWidget(void);
+
private:
bool m_modified;
virtual void SetDropTarget( wxDropTarget *dropTarget );
virtual wxDropTarget *GetDropTarget() const;
-
+private:
+ virtual GtkWidget* GetDropTargetWidget(void);
+
+public:
virtual void SetScrollbar( int orient, int pos, int thumbVisible,
int range, bool refresh = TRUE );
virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE );
// update the UI state (called from OnIdle)
void UpdateWindowUI();
+
public: // cannot get private going yet
void PreCreation( wxWindow *parent, wxWindowID id, const wxPoint &pos,
class wxWindow;
+class wxDataObject;
+class wxTextDataObject;
+class wxFileDataObject;
+
class wxDropTarget;
class wxTextDropTarget;
-class wxDragSource;
-class wxTextDragSource;
+class wxFileDropTarget;
+
+class wxDropSource;
+
+//-------------------------------------------------------------------------
+// wxDataObject
+//-------------------------------------------------------------------------
+
+class wxDataObject: public wxObject
+{
+public:
+ // all data formats (values are the same as in windows.h, do not change!)
+ enum StdFormat
+ {
+ Invalid,
+ Text,
+ Bitmap,
+ MetafilePict,
+ Sylk,
+ Dif,
+ Tiff,
+ OemText,
+ Dib,
+ Palette,
+ Pendata,
+ Riff,
+ Wave,
+ UnicodeText,
+ EnhMetafile,
+ Hdrop,
+ Locale,
+ Max
+ };
+
+ // function to return symbolic name of clipboard format (debug messages)
+ static const char *GetFormatName(wxDataFormat format);
+
+ // ctor & dtor
+ wxDataObject() {};
+ ~wxDataObject() {};
+
+ // pure virtuals to override
+ // get the best suited format for our data
+ virtual wxDataFormat GetPreferredFormat() const = 0;
+ // decide if we support this format (should be one of values of
+ // StdFormat enumerations or a user-defined format)
+ virtual bool IsSupportedFormat(wxDataFormat format) const = 0;
+ // get the (total) size of data
+ virtual uint GetDataSize() const = 0;
+ // copy raw data to provided pointer
+ virtual void GetDataHere(void *pBuf) const = 0;
+
+};
+
+// ----------------------------------------------------------------------------
+// wxTextDataObject is a specialization of wxDataObject for text data
+// ----------------------------------------------------------------------------
+
+class wxTextDataObject : public wxDataObject
+{
+public:
+ // ctors
+ wxTextDataObject() { }
+ wxTextDataObject(const wxString& strText) : m_strText(strText) { }
+ void Init(const wxString& strText) { m_strText = strText; }
+
+ // implement base class pure virtuals
+ virtual wxDataFormat GetPreferredFormat() const
+ { return wxDF_TEXT; }
+ virtual bool IsSupportedFormat(wxDataFormat format) const
+ { return format == wxDF_TEXT; }
+ virtual uint GetDataSize() const
+ { return m_strText.Len() + 1; } // +1 for trailing '\0'of course
+ virtual void GetDataHere(void *pBuf) const
+ { memcpy(pBuf, m_strText.c_str(), GetDataSize()); }
+
+private:
+ wxString m_strText;
+
+};
+// ----------------------------------------------------------------------------
+// wxFileDataObject is a specialization of wxDataObject for file names
+// ----------------------------------------------------------------------------
+
+class wxFileDataObject : public wxDataObject
+{
+public:
+
+ wxFileDataObject(void) { }
+ void AddFile( const wxString &file )
+ { m_files += file; m_files += ";"; }
+
+ // implement base class pure virtuals
+ virtual wxDataFormat GetPreferredFormat() const
+ { return wxDF_FILENAME; }
+ virtual bool IsSupportedFormat(wxDataFormat format) const
+ { return format == wxDF_FILENAME; }
+ virtual uint GetDataSize() const
+ { return m_files.Len() + 1; } // +1 for trailing '\0'of course
+ virtual void GetDataHere(void *pBuf) const
+ { memcpy(pBuf, m_files.c_str(), GetDataSize()); }
+
+private:
+ wxString m_files;
+
+};
//-------------------------------------------------------------------------
// wxDropTarget
//-------------------------------------------------------------------------
wxDropTarget();
~wxDropTarget();
+
virtual void OnEnter() { }
virtual void OnLeave() { }
virtual bool OnDrop( long x, long y, const void *pData ) = 0;
- public:
-
+// protected:
+
+ friend wxWindow;
+
+ // Override these to indicate what kind of data you support:
+
+ virtual size_t GetFormatCount() const = 0;
+ virtual wxDataFormat GetFormat(size_t n) const = 0;
+
void Drop( GdkEvent *event, int x, int y );
- virtual void RegisterWidget( GtkWidget *widget ) = 0;
+ void RegisterWidget( GtkWidget *widget );
void UnregisterWidget( GtkWidget *widget );
};
wxTextDropTarget() {};
virtual bool OnDrop( long x, long y, const void *pData );
virtual bool OnDropText( long x, long y, const char *psz );
- virtual void RegisterWidget( GtkWidget *widget );
+
+ protected:
+
+ virtual size_t GetFormatCount() const;
+ virtual wxDataFormat GetFormat(size_t n) const;
};
-//-------------------------------------------------------------------------
-// wxDragSource
-//-------------------------------------------------------------------------
+// ----------------------------------------------------------------------------
+// A drop target which accepts files (dragged from File Manager or Explorer)
+// ----------------------------------------------------------------------------
-class wxDragSource: public wxObject
+class wxFileDropTarget: public wxDropTarget
{
public:
+
+ wxFileDropTarget() {};
+
+ virtual bool OnDrop(long x, long y, const void *pData);
+ virtual bool OnDropFiles( long x, long y,
+ size_t nFiles, const char * const aszFiles[]);
- wxDragSource( wxWindow *win );
- ~wxDragSource(void);
- void SetData( char *data, long size );
- void Start( int x, int y );
-
- public:
-
- void ConnectWindow(void);
- void UnconnectWindow(void);
- virtual void RegisterWindow(void) = 0;
- void UnregisterWindow(void);
+ protected:
- GtkWidget *m_widget;
- wxWindow *m_window;
- char *m_data;
- long m_size;
- wxCursor m_defaultCursor;
- wxCursor m_goaheadCursor;
+ virtual size_t GetFormatCount() const;
+ virtual wxDataFormat GetFormat(size_t n) const;
};
//-------------------------------------------------------------------------
-// wxTextDragSource
+// wxDropSource
//-------------------------------------------------------------------------
-class wxTextDragSource: public wxDragSource
+class wxDropSource: public wxObject
{
public:
- wxTextDragSource( wxWindow *win ) : wxDragSource(win) {};
- void SetTextData( const wxString &text );
- void RegisterWindow(void);
+ enum DragResult
+ {
+ Error, // error prevented the d&d operation from completing
+ None, // drag target didn't accept the data
+ Copy, // the data was successfully copied
+ Move, // the data was successfully moved
+ Cancel // the operation was cancelled by user (not an error)
+ };
+
+ wxDropSource( wxWindow *win );
+ wxDropSource( wxDataObject &data, wxWindow *win );
+
+ ~wxDropSource(void);
- private:
+ void SetData( wxDataObject &data );
+ DragResult DoDragDrop( bool bAllowMove = FALSE );
+
+ virtual bool GiveFeedback( DragResult WXUNUSED(effect), bool WXUNUSED(bScrolling) ) { return TRUE; };
+
+ protected:
- wxString m_tmp;
+ void RegisterWindow(void);
+ void UnregisterWindow(void);
+
+ GtkWidget *m_widget;
+ wxWindow *m_window;
+
+ wxDataObject *m_data;
+
+ wxCursor m_defaultCursor;
+ wxCursor m_goaheadCursor;
};
#endif
// set minimal/maxmimal size for the frame
virtual void SetSizeHints( int minW, int minH, int maxW, int maxH, int incW = -1 );
- virtual bool CreateStatusBar( int number = 1 );
+ virtual wxStatusBar* CreateStatusBar(int number=1, long style = wxST_SIZEGRIP, wxWindowID id = 0,
+ const wxString& name = "statusBar");
virtual wxStatusBar *GetStatusBar();
virtual void SetStatusText( const wxString &text, int number = 0 );
virtual void SetStatusWidths( int n, int *width );
- virtual wxToolBar *CreateToolBar( int style = 0,
- int orientation = wxHORIZONTAL, int rowsOrColumns = 1 );
+ virtual wxToolBar* CreateToolBar( long style = wxNO_BORDER|wxTB_HORIZONTAL, wxWindowID id = -1,
+ const wxString& name = wxToolBarNameStr);
virtual wxToolBar *GetToolBar();
virtual void SetMenuBar( wxMenuBar *menuBar );
void SetString( int n, const wxString &string );
void SetStringSelection( const wxString &string, bool select = TRUE );
+ virtual GtkWidget *GetDropTargetWidget(void);
+
private:
GtkList *m_list;
bool Destroy(void);
void OnCloseWindow( wxCloseEvent& event );
+ void OnSize( wxSizeEvent &event );
public:
uint m_idHandler; // the change page handler id
DECLARE_DYNAMIC_CLASS(wxNotebook)
- DECLARE_EVENT_TABLE()
};
// ----------------------------------------------------------------------------
virtual void AddSeparator(void);
virtual void ClearTools(void);
- virtual void Layout(void);
+ virtual void Realize(void);
virtual void EnableTool(int toolIndex, bool enable);
virtual void ToggleTool(int toolIndex, bool toggle); // toggle is TRUE if toggled on
wxTextCtrl& operator<<(double d);
wxTextCtrl& operator<<(const char c);
+ virtual GtkWidget* GetDropTargetWidget(void);
+
private:
bool m_modified;
virtual void SetDropTarget( wxDropTarget *dropTarget );
virtual wxDropTarget *GetDropTarget() const;
-
+private:
+ virtual GtkWidget* GetDropTargetWidget(void);
+
+public:
virtual void SetScrollbar( int orient, int pos, int thumbVisible,
int range, bool refresh = TRUE );
virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE );
// update the UI state (called from OnIdle)
void UpdateWindowUI();
+
public: // cannot get private going yet
void PreCreation( wxWindow *parent, wxWindowID id, const wxPoint &pos,
inline ~wxConnectionBase(void) {}
// Calls that CLIENT can make
- virtual bool Execute(char *data, int size = -1, int format = wxCF_TEXT) = 0;
- virtual bool Execute(const wxString& str) { return Execute((char *)(const char *)str, -1, wxCF_TEXT); }
- virtual char *Request(const wxString& item, int *size = NULL, int format = wxCF_TEXT) = 0;
- virtual bool Poke(const wxString& item, char *data, int size = -1, int format = wxCF_TEXT) = 0;
+ virtual bool Execute(char *data, int size = -1, wxDataFormat format = wxDF_TEXT ) = 0;
+ virtual bool Execute(const wxString& str) { return Execute((char *)(const char *)str, -1, wxDF_TEXT); }
+ virtual char *Request(const wxString& item, int *size = NULL, wxDataFormat format = wxDF_TEXT) = 0;
+ virtual bool Poke(const wxString& item, char *data, int size = -1, wxDataFormat format = wxDF_TEXT) = 0;
virtual bool StartAdvise(const wxString& item) = 0;
virtual bool StopAdvise(const wxString& item) = 0;
// Calls that SERVER can make
- virtual bool Advise(const wxString& item, char *data, int size = -1, int format = wxCF_TEXT) = 0;
+ virtual bool Advise(const wxString& item, char *data, int size = -1, wxDataFormat format = wxDF_TEXT) = 0;
// Calls that both can make
virtual bool Disconnect(void) = 0;
#endif
-#define IS_KIND_OF(obj, className) obj->IsKindOf(&className::class##name)
+#define IS_KIND_OF(obj, className) obj->IsKindOf(&className::class##className)
// Unfortunately Borland seems to need this include.
#ifdef __BORLANDC__
# The file that contains palette entries for a global palette for all Imlib
# based programs.
# options: full path to palette file
-PaletteFile /etc/im_palette.pal
+PaletteFile ~/im_palette.pal
# This defines if when the display is greater than 8 bit, that it still remaps
# the images to the palette defined, rather than using "perfect" rendering
# options: yes/no
--- /dev/null
+include ../../src/gtk/setup/general/makeapp
--- /dev/null
+# WXXT base directory
+WXBASEDIR=@WXBASEDIR@
+
+# set the OS type for compilation
+OS=@OS@
+# compile a library only
+RULE=bin
+
+# define library name
+BIN_TARGET=dnd
+# define library sources
+BIN_SRC=\
+dnd.cpp
+
+#define library objects
+BIN_OBJ=\
+dnd.o
+
+# additional things needed to link
+BIN_LINK=
+
+# additional things needed to compile
+ADD_COMPILE=
+
+# include the definitions now
+include ../../../template.mak
m_strText("wxWindows drag & drop works :-)")
{
+
+#ifdef __WXMSW__
// frame icon and status bar
SetIcon(wxIcon("mondrian"));
+#endif
+
const int widths[] = { -1 };
CreateStatusBar();
m_ctrlFile = new wxListBox(this, -1, pos, size, 1, &strFile, wxLB_HSCROLL);
m_ctrlText = new wxListBox(this, -1, pos, size, 1, &strText, wxLB_HSCROLL);
+
m_ctrlLog = new wxTextCtrl(this, -1, "", pos, size,
wxTE_MULTILINE | wxTE_READONLY |
wxSUNKEN_BORDER| wxHSCROLL);
m_pLogPrev = wxLog::SetActiveTarget(m_pLog);
// associate drop targets with 2 text controls
- m_ctrlFile->SetDropTarget(new DnDFile(m_ctrlFile));
- m_ctrlText->SetDropTarget(new DnDText(m_ctrlText));
+// m_ctrlFile->SetDropTarget(new DnDFile(m_ctrlFile));
+ m_ctrlText->SetDropTarget(new DnDText(m_ctrlText));
- wxLayoutConstraints *c;
+ wxLayoutConstraints *c;
// Top-left listbox
c = new wxLayoutConstraints;
dialog.ShowModal();
}
-void DnDFrame::OnLogClear(wxCommandEvent& event)
+void DnDFrame::OnLogClear(wxCommandEvent& /* event */ )
{
m_ctrlLog->Clear();
}
return TRUE;
}
-void DnDFrame::OnMouseBtnDown(wxMouseEvent& event)
+void DnDFrame::OnMouseBtnDown(wxMouseEvent& /* event */ )
{
if ( !m_strText.IsEmpty() ) {
// start drag operation
wxTextDataObject data(m_strText);
- wxDropSource dragSource(data);
+ wxDropSource dragSource(data, this);
const char *pc;
switch ( dragSource.DoDragDrop(TRUE) ) {
editMenu = NULL;
}
-void MyFrame::OnAbout(wxCommandEvent& event)
+void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event) )
{
(void)wxMessageBox("DocView Demo\nAuthor: Julian Smart julian.smart@ukonline.co.uk\nUsage: docview.exe [-single]", "About DocView");
}
// What to do when a view is created. Creates actual
// windows for displaying the view.
-bool DrawingView::OnCreate(wxDocument *doc, long flags)
+bool DrawingView::OnCreate(wxDocument *doc, long WXUNUSED(flags) )
{
if (!singleWindowMode)
{
}
}
-void DrawingView::OnUpdate(wxView *sender, wxObject *hint)
+void DrawingView::OnUpdate(wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint))
{
if (canvas)
canvas->Refresh();
return TRUE;
}
-void DrawingView::OnCut(wxCommandEvent& event)
+void DrawingView::OnCut(wxCommandEvent& WXUNUSED(event) )
{
DrawingDocument *doc = (DrawingDocument *)GetDocument();
doc->GetCommandProcessor()->Submit(new DrawingCommand("Cut Last Segment", DOODLE_CUT, doc, NULL));
IMPLEMENT_DYNAMIC_CLASS(TextEditView, wxView)
-bool TextEditView::OnCreate(wxDocument *doc, long flags)
+bool TextEditView::OnCreate(wxDocument *doc, long WXUNUSED(flags) )
{
frame = wxGetApp().CreateChildFrame(doc, this, FALSE);
}
// Handled by wxTextWindow
-void TextEditView::OnDraw(wxDC *dc)
+void TextEditView::OnDraw(wxDC *WXUNUSED(dc) )
{
}
-void TextEditView::OnUpdate(wxView *sender, wxObject *hint)
+void TextEditView::OnUpdate(wxView *WXUNUSED(sender), wxObject *WXUNUSED(hint) )
{
}
currentSegment = new DoodleSegment;
DoodleLine *newLine = new DoodleLine;
- newLine->x1 = xpos; newLine->y1 = ypos;
- newLine->x2 = pt.x; newLine->y2 = pt.y;
+ newLine->x1 = (long)xpos;
+ newLine->y1 = (long)ypos;
+ newLine->x2 = pt.x;
+ newLine->y2 = pt.y;
currentSegment->lines.Append(newLine);
- dc.DrawLine(xpos, ypos, pt.x, pt.y);
+ dc.DrawLine( (long)xpos, (long)ypos, pt.x, pt.y);
}
xpos = pt.x;
ypos = pt.y;
// Make a panel with a message
wxPanel *panel = new wxPanel(frame, -1, wxPoint(0, 0), wxSize(400, 200), wxTAB_TRAVERSAL);
- wxStaticText *msg = new wxStaticText(panel, 311, "Hello!", wxPoint(10, 10), wxSize(-1, -1),
- 0);
+ (void)new wxStaticText(panel, 311, "Hello!", wxPoint(10, 10), wxSize(-1, -1), 0);
// Show the frame
frame->Show(TRUE);
m_game->DisplayScore(dc);
delete m_playerDialog;
m_playerDialog = 0;
+ Refresh();
}
else
{
// Last modified: 22nd July 1998 - ported to wxWindows 2.0
/////////////////////////////////////////////////////////////////////////////
//+-------------------------------------------------------------+
-//| Description: |
-//| A class for drawing playing cards. |
-//| Currently assumes that the card symbols have been |
-//| loaded into hbmap_symbols and the pictures for the |
-//| Jack, Queen and King have been loaded into |
-//| hbmap_pictures. |
+//| Description
+//| A class for drawing playing cards.
+//| Currently assumes that the card symbols have been
+//| loaded into hbmap_symbols and the pictures for the
+//| Jack, Queen and King have been loaded into
+//| hbmap_pictures.
//+-------------------------------------------------------------+
#ifdef __GNUG__
#include "card.h"
#include "pile.h"
+#include "wx/app.h"
//+-------------------------------------------------------------+
//| Pile::Pile() |
//| at the origin of the pile, shifting each subsequent |
//| card by the pile's x and y offsets. |
//+-------------------------------------------------------------+
-void Pile::Redraw(wxDC& dc)
+void Pile::Redraw(wxDC& dc )
{
+ wxWindow *frame = wxTheApp->GetTopWindow();
+ wxWindow *canvas = NULL;
+ if (frame)
+ {
+ wxNode *node = frame->GetChildren()->First();
+ if (node) canvas = (wxWindow*)node->Data();
+ }
+
if (m_topCard >= 0)
{
if (m_dx == 0 && m_dy == 0)
{
- m_cards[m_topCard]->Draw(dc, m_x, m_y);
+ if ((canvas) && (canvas->IsExposed(m_x,m_y,60,200)))
+ m_cards[m_topCard]->Draw(dc, m_x, m_y);
}
else
{
int y = m_y;
for (int i = 0; i <= m_topCard; i++)
{
- m_cards[i]->Draw(dc, x, y);
- x += m_dx;
- y += m_dy;
+ if ((canvas) && (canvas->IsExposed(x,y,60,200)))
+ m_cards[i]->Draw(dc, x, y);
+ x += m_dx;
+ y += m_dy;
}
}
}
else
{
+ if ((canvas) && (canvas->IsExposed(m_x,m_y,60,200)))
Card::DrawNullCard(dc, m_x, m_y);
}
}
InitToolBar(GetToolBar());
}
-void MyFrame::OnQuit(wxCommandEvent& event)
+void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event) )
{
Close(TRUE);
}
-void MyFrame::OnAbout(wxCommandEvent& event)
+void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event) )
{
(void)wxMessageBox("wxWindows 2.0 MDI Demo\nAuthor: Julian Smart (c) 1997\nUsage: mdi.exe", "About MDI Demo");
}
-void MyFrame::OnNewWindow(wxCommandEvent& event)
+void MyFrame::OnNewWindow(wxCommandEvent& WXUNUSED(event) )
{
// Make another frame, containing a canvas
- MyChild *subframe = new MyChild(frame, "Canvas Frame", wxPoint(10, 10), wxSize(300, 300),
+ MyChild *subframe = new MyChild(frame, "Canvas Frame", wxPoint(4, 4), wxSize(100, 100),
wxDEFAULT_FRAME);
char titleBuf[100];
return TRUE;
}
-void MyFrame::OnSize(wxSizeEvent& event)
+void MyFrame::OnSize(wxSizeEvent& WXUNUSED(event) )
{
int w, h;
GetClientSize(&w, &h);
- int tw = 0;
- int th = 0;
textWindow->SetSize(0, 0, 200, h);
GetClientWindow()->SetSize(200, 0, w - 200, h);
#else
int width = 16;
#endif
- int offX = 5;
int currentX = 5;
toolBar->AddTool(0, *bitmaps[0], wxNullBitmap, FALSE, currentX, -1, NULL, "New file");
#include "wx/date.h"
#if !WXDEBUG
-#error You must set WXDEBUG to 1 on the 'make' command line or make.env.
+#error You must set WXDEBUG to 1 on the 'make' command line (MSW) or with configure (GTK)
#endif
// #define new WXDEBUG_NEW
// Make a panel with a message
wxPanel *panel = new wxPanel(frame, -1, wxPoint(0, 0), wxSize(400, 200), wxTAB_TRAVERSAL);
- wxStaticText *msg = new wxStaticText(panel, 311, "Hello!", wxPoint(10, 10), wxSize(-1, -1),
- 0);
+ (void)new wxStaticText(panel, 311, "Hello!", wxPoint(10, 10), wxSize(-1, -1), 0);
// Show the frame
frame->Show(TRUE);
canvas = NULL;
}
-void MyFrame::OnQuit(wxCommandEvent& event)
+void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}
-void MyFrame::OnAbout(wxCommandEvent& event)
+void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
{
(void)wxMessageBox("PNG demo\nJulian Smart (c) 1998",
"About PNG Demo", wxOK);
}
-void MyFrame::OnLoadFile(wxCommandEvent& event)
+void MyFrame::OnLoadFile(wxCommandEvent& WXUNUSED(event))
{
// Show file selector.
char *f = wxFileSelector("Open Image", NULL, NULL,"png",
}
// Define the repainting behaviour
-void MyCanvas::OnPaint(wxPaintEvent& event)
+void MyCanvas::OnPaint(wxPaintEvent& WXUNUSED(event))
{
wxPaintDC dc(this);
dc.SetPen(wxRED_PEN);
canvas = NULL;
}
-void MyFrame::OnExit(wxCommandEvent& event)
+void MyFrame::OnExit(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}
-void MyFrame::OnPrint(wxCommandEvent& event)
+void MyFrame::OnPrint(wxCommandEvent& WXUNUSED(event))
{
#ifdef __WXMSW__
wxGetApp().SetPrintMode(wxPRINT_WINDOWS);
wxMessageBox("There was a problem printing.\nPerhaps your current printer is not set correctly?", "Printing", wxOK);
}
-void MyFrame::OnPrintPS(wxCommandEvent& event)
+void MyFrame::OnPrintPS(wxCommandEvent& WXUNUSED(event))
{
wxGetApp().SetPrintMode(wxPRINT_POSTSCRIPT);
printer.Print(this, &printout, TRUE);
}
-void MyFrame::OnPrintPreview(wxCommandEvent& event)
+void MyFrame::OnPrintPreview(wxCommandEvent& WXUNUSED(event))
{
#ifdef __WXMSW__
wxGetApp().SetPrintMode(wxPRINT_WINDOWS);
frame->Show(TRUE);
}
-void MyFrame::OnPrintPreviewPS(wxCommandEvent& event)
+void MyFrame::OnPrintPreviewPS(wxCommandEvent& WXUNUSED(event))
{
wxGetApp().SetPrintMode(wxPRINT_POSTSCRIPT);
frame->Show(TRUE);
}
-void MyFrame::OnPrintSetup(wxCommandEvent& event)
+void MyFrame::OnPrintSetup(wxCommandEvent& WXUNUSED(event))
{
#ifdef __WXMSW__
wxGetApp().SetPrintMode(wxPRINT_WINDOWS);
orientation = printerDialog.GetPrintData().GetOrientation();
}
-void MyFrame::OnPageSetup(wxCommandEvent& event)
+void MyFrame::OnPageSetup(wxCommandEvent& WXUNUSED(event))
{
#ifdef __WXMSW__
wxGetApp().SetPrintMode(wxPRINT_WINDOWS);
orientation = data.GetOrientation();
}
-void MyFrame::OnPrintSetupPS(wxCommandEvent& event)
+void MyFrame::OnPrintSetupPS(wxCommandEvent& WXUNUSED(event))
{
wxGetApp().SetPrintMode(wxPRINT_POSTSCRIPT);
orientation = printerDialog.GetPrintData().GetOrientation();
}
-void MyFrame::OnPageSetupPS(wxCommandEvent& event)
+void MyFrame::OnPageSetupPS(wxCommandEvent& WXUNUSED(event))
{
wxGetApp().SetPrintMode(wxPRINT_POSTSCRIPT);
orientation = pageSetupDialog.GetPageSetupData().GetOrientation();
}
-void MyFrame::OnPrintAbout(wxCommandEvent& event)
+void MyFrame::OnPrintAbout(wxCommandEvent& WXUNUSED(event))
{
(void)wxMessageBox("wxWindows printing demo\nAuthor: Julian Smart julian.smart@ukonline.co.uk",
"About wxWindows printing demo", wxOK|wxCENTRE);
dc.SetBrush(wxCYAN_BRUSH);
dc.SetPen(wxRED_PEN);
- dc.DrawRectangle(0.0, 30.0, 200.0, 100.0);
- dc.DrawText("Rectangle 200 by 100", 40.0, 40.0);
+ dc.DrawRectangle(0, 30, 200, 100);
+ dc.DrawText("Rectangle 200 by 100", 40, 40);
- dc.DrawEllipse(50.0, 140.0, 100.0, 50.0);
+ dc.DrawEllipse(50, 140, 100, 50);
- dc.DrawText("Test message: this is in 11 point text", 10.0, 180.0);
+ dc.DrawText("Test message: this is in 11 point text", 10, 180);
dc.SetPen(wxBLACK_PEN);
- dc.DrawLine(0.0, 0.0, 200.0, 200.0);
- dc.DrawLine(200.0, 0.0, 0.0, 200.0);
+ dc.DrawLine(0, 0, 200, 200);
+ dc.DrawLine(200, 0, 0, 200);
}
-void MyFrame::OnSize(wxSizeEvent& event)
+void MyFrame::OnSize(wxSizeEvent& event )
{
wxFrame::OnSize(event);
}
frame->Draw(dc);
}
-void MyCanvas::OnEvent(wxMouseEvent& event)
+void MyCanvas::OnEvent(wxMouseEvent& WXUNUSED(event))
{
}
char buf[200];
sprintf(buf, "PAGE %d", page);
- dc->DrawText(buf, 10.0, 10.0);
+ dc->DrawText(buf, 10, 10);
return TRUE;
}
// Set the scale and origin
dc->SetUserScale(actualScale, actualScale);
- dc->SetDeviceOrigin(posX, posY);
+ dc->SetDeviceOrigin( (long)posX, (long)posY );
frame->Draw(*dc);
}
float logUnitsFactor = (float)(ppiPrinterX/(scale*25.1));
float logUnits = (float)(50*logUnitsFactor);
dc->SetPen(wxBLACK_PEN);
- dc->DrawLine(50.0, 50.0, (float)(50.0 + logUnits), 50.0);
- dc->DrawLine(50.0, 50.0, 50.0, (float)(50.0 + logUnits));
+ dc->DrawLine(50, 50, (long)(50.0 + logUnits), 50);
+ dc->DrawLine(50, 50, 50, (long)(50.0 + logUnits));
dc->SetFont(itemFont);
dc->SetBackgroundMode(wxTRANSPARENT);
- dc->DrawText("Some test text", 200.0, 200.0);
+ dc->DrawText("Some test text", 200, 200 );
// TESTING
float rightMarginLogical = (float)(logUnitsFactor*(pageWidthMM - rightMargin));
dc->SetPen(wxBLACK_PEN);
- dc->DrawLine(leftMarginLogical, topMarginLogical, rightMarginLogical, topMarginLogical);
- dc->DrawLine(leftMarginLogical, bottomMarginLogical, rightMarginLogical, bottomMarginLogical);
+ dc->DrawLine( (long)leftMarginLogical, (long)topMarginLogical,
+ (long)rightMarginLogical, (long)topMarginLogical);
+ dc->DrawLine( (long)leftMarginLogical, (long)bottomMarginLogical,
+ (long)rightMarginLogical, (long)bottomMarginLogical);
WritePageHeader(this, dc, "A header", logUnitsFactor);
}
long xExtent, yExtent;
dc->GetTextExtent(text, &xExtent, &yExtent);
float xPos = (float)(((((pageWidthMM - leftMargin - rightMargin)/2.0)+leftMargin)*mmToLogical) - (xExtent/2.0));
- dc->DrawText(text, (long)xPos, topMarginLogical);
+ dc->DrawText(text, (long)xPos, (long)topMarginLogical);
dc->SetPen(wxBLACK_PEN);
- dc->DrawLine(leftMarginLogical, topMarginLogical+yExtent, rightMarginLogical, topMarginLogical+yExtent);
+ dc->DrawLine( (long)leftMarginLogical, (long)(topMarginLogical+yExtent),
+ (long)rightMarginLogical, (long)topMarginLogical+yExtent );
return TRUE;
}
return TRUE;
}
-void MyFrame::Quit(wxCommandEvent& event)
+void MyFrame::Quit(wxCommandEvent& WXUNUSED(event) )
{
Close(TRUE);
}
-void MyFrame::SplitHorizontal(wxCommandEvent& event)
+void MyFrame::SplitHorizontal(wxCommandEvent& WXUNUSED(event) )
{
if ( splitter->IsSplit() )
splitter->Unsplit();
splitter->SplitHorizontally( leftCanvas, rightCanvas );
}
-void MyFrame::SplitVertical(wxCommandEvent& event)
+void MyFrame::SplitVertical(wxCommandEvent& WXUNUSED(event) )
{
if ( splitter->IsSplit() )
splitter->Unsplit();
splitter->SplitVertically( leftCanvas, rightCanvas );
}
-void MyFrame::Unsplit(wxCommandEvent& event)
+void MyFrame::Unsplit(wxCommandEvent& WXUNUSED(event) )
{
if ( splitter->IsSplit() )
splitter->Unsplit();
Init();
}
-void MyDialog::OnOK(wxCommandEvent& event)
+void MyDialog::OnOK(wxCommandEvent& WXUNUSED(event) )
{
EndModal(wxID_OK);
}
-void MyDialog::OnCloseWindow(wxCloseEvent& event)
+void MyDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event) )
{
EndModal(wxID_CANCEL);
}
int dialogHeight = 390;
wxButton *okButton = new wxButton(this, wxID_OK, "Close", wxPoint(100, 330), wxSize(80, 25));
- wxButton *cancelButton = new wxButton(this, wxID_CANCEL, "Cancel", wxPoint(185, 330), wxSize(80, 25));
- wxButton *HelpButton = new wxButton(this, wxID_HELP, "Help", wxPoint(270, 330), wxSize(80, 25));
+ (void)new wxButton(this, wxID_CANCEL, "Cancel", wxPoint(185, 330), wxSize(80, 25));
+ (void)new wxButton(this, wxID_HELP, "Help", wxPoint(270, 330), wxSize(80, 25));
okButton->SetDefault();
// Note, omit the wxTAB_STYLE_COLOUR_INTERIOR, so we will guarantee a match
view->AddTabWindow(TEST_TAB_DOG, panel2);
// Don't know why this is necessary under Motif...
-#ifdef wx_motif
+#ifndef __WXMSW__
this->SetSize(dialogWidth, dialogHeight-20);
#endif
wxFrame(frame, -1, title, wxPoint(x, y), wxSize(w, h))
{}
-void MyFrame::OnStartThread(wxCommandEvent& event)
+void MyFrame::OnStartThread(wxCommandEvent& WXUNUSED(event) )
{
MyThread *thread = new MyThread(this);
m_threads.Add(thread);
}
-void MyFrame::OnStopThread(wxCommandEvent& event)
+void MyFrame::OnStopThread(wxCommandEvent& WXUNUSED(event) )
{
- uint no_thrd = m_threads.Count()-1;
+ int no_thrd = m_threads.Count()-1;
if (no_thrd < 0)
return;
m_threads.Remove(no_thrd);
}
-void MyFrame::OnPauseThread(wxCommandEvent& event)
+void MyFrame::OnPauseThread(wxCommandEvent& WXUNUSED(event) )
{}
-void MyFrame::OnQuit(wxCommandEvent& event)
+void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event) )
{
uint i;
for (i=0;i<m_threads.Count();i++)
Close(TRUE);
}
-void MyFrame::OnAbout(wxCommandEvent& event)
+void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event) )
{
wxMessageDialog dialog(this, "wxThread sample (based on minimal)\nJulian Smart and Guilhem Lavaux",
"About wxThread sample", wxYES_NO|wxCANCEL);
--- /dev/null
+include ../../src/gtk/setup/general/makeapp
--- /dev/null
+# WXXT base directory
+WXBASEDIR=@WXBASEDIR@
+
+# set the OS type for compilation
+OS=@OS@
+# compile a library only
+RULE=bin
+
+# define library name
+BIN_TARGET=test
+# define library sources
+BIN_SRC=\
+test.cpp
+
+#define library objects
+BIN_OBJ=\
+test.o
+
+# additional things needed to link
+BIN_LINK=
+
+# additional things needed to compile
+ADD_COMPILE=
+
+# include the definitions now
+include ../../../template.mak
delete wxGetApp().m_imageListNormal;
}
-void MyFrame::OnQuit(wxCommandEvent& event)
+void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event) )
{
Close(TRUE);
}
-void MyFrame::OnAbout(wxCommandEvent& event)
+void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event) )
{
wxMessageDialog dialog(this, "Tree test sample\nJulian Smart (c) 1997",
"About tree test", wxOK|wxCANCEL);
// MyTreeCtrl
-void MyTreeCtrl::OnBeginDrag(wxTreeEvent& event)
+void MyTreeCtrl::OnBeginDrag(wxTreeEvent& WXUNUSED(event) )
{
if ( !wxGetApp().GetTopWindow() )
return;
#endif
}
-void MyTreeCtrl::OnBeginRDrag(wxTreeEvent& event)
+void MyTreeCtrl::OnBeginRDrag(wxTreeEvent& WXUNUSED(event) )
{
if ( !wxGetApp().GetTopWindow() )
return;
#endif
}
-void MyTreeCtrl::OnBeginLabelEdit(wxTreeEvent& event)
+void MyTreeCtrl::OnBeginLabelEdit(wxTreeEvent& WXUNUSED(event) )
{
if ( !wxGetApp().GetTopWindow() )
return;
#endif
}
-void MyTreeCtrl::OnEndLabelEdit(wxTreeEvent& event)
+void MyTreeCtrl::OnEndLabelEdit(wxTreeEvent& WXUNUSED(event) )
{
if ( !wxGetApp().GetTopWindow() )
return;
#endif
}
-void MyTreeCtrl::OnDeleteItem(wxTreeEvent& event)
+void MyTreeCtrl::OnDeleteItem(wxTreeEvent& WXUNUSED(event) )
{
if ( !wxGetApp().GetTopWindow() )
return;
#endif
}
-void MyTreeCtrl::OnGetInfo(wxTreeEvent& event)
+void MyTreeCtrl::OnGetInfo(wxTreeEvent& WXUNUSED(event) )
{
if ( !wxGetApp().GetTopWindow() )
return;
#endif
}
-void MyTreeCtrl::OnSetInfo(wxTreeEvent& event)
+void MyTreeCtrl::OnSetInfo(wxTreeEvent& WXUNUSED(event) )
{
if ( !wxGetApp().GetTopWindow() )
return;
#endif
}
-void MyTreeCtrl::OnItemExpanded(wxTreeEvent& event)
+void MyTreeCtrl::OnItemExpanded(wxTreeEvent& WXUNUSED(event) )
{
if ( !wxGetApp().GetTopWindow() )
return;
#endif
}
-void MyTreeCtrl::OnItemExpanding(wxTreeEvent& event)
+void MyTreeCtrl::OnItemExpanding(wxTreeEvent& WXUNUSED(event) )
{
if ( !wxGetApp().GetTopWindow() )
return;
#endif
}
-void MyTreeCtrl::OnSelChanged(wxTreeEvent& event)
+void MyTreeCtrl::OnSelChanged(wxTreeEvent& WXUNUSED(event) )
{
if ( !wxGetApp().GetTopWindow() )
return;
#endif
}
-void MyTreeCtrl::OnSelChanging(wxTreeEvent& event)
+void MyTreeCtrl::OnSelChanging(wxTreeEvent& WXUNUSED(event) )
{
if ( !wxGetApp().GetTopWindow() )
return;
#endif
}
-void MyTreeCtrl::OnKeyDown(wxTreeEvent& event)
+void MyTreeCtrl::OnKeyDown(wxTreeEvent& WXUNUSED(event) )
{
if ( !wxGetApp().GetTopWindow() )
return;
#include <wx/stream.h>
#include <wx/zstream.h>
#include <wx/utils.h>
-#include "zlib.h"
+#include "../zlib/zlib.h" // don't change this, Robert
#ifdef __BORLANDC__
#pragma hdrstop
// Erase (some of) the background.
// Currently, a Windows-only optimisation.
-void wxGenericGrid::OnEraseBackground(wxEraseEvent& event)
+void wxGenericGrid::OnEraseBackground(wxEraseEvent& WXUNUSED(event) )
{
wxClientDC dc(this);
dc.BeginDrawing();
wxListItemData *item = (wxListItemData*)node->Data();
if (item->HasImage() && IsInRect( x, y, m_bound_icon )) return wxLIST_HITTEST_ONITEMICON;
if (item->HasText() && IsInRect( x, y, m_bound_label )) return wxLIST_HITTEST_ONITEMLABEL;
- if (!(item->HasImage() || item->HasText())) return 0;
+// if (!(item->HasImage() || item->HasText())) return 0;
};
// if there is no icon or text = empty
if (IsInRect( x, y, m_bound_all )) return wxLIST_HITTEST_ONITEMICON;
m_lastOnSame = FALSE;
// m_renameTimer = new wxRenameTimer( this );
m_isCreated = FALSE;
- m_isDragging = FALSE;
+ m_dragCount = 0;
};
wxListMainWindow::wxListMainWindow( wxWindow *parent, wxWindowID id,
// AllowDoubleClick( TRUE );
m_myFont = wxNORMAL_FONT;
m_hasFocus = FALSE;
- m_isDragging = FALSE;
+ m_dragCount = 0;
m_isCreated = FALSE;
wxSize sz = size;
sz.y = 25;
void wxListMainWindow::OnMouse( wxMouseEvent &event )
{
+ if (m_parent->ProcessEvent( event)) return;
+
if (!m_current) return;
if (m_dirty) return;
-// wxDragCanvas::OnEvent( event );
wxClientDC dc(this);
PrepareDC(dc);
node = node->Next();
};
- if (!event.Dragging()) m_isDragging = FALSE;
+ if (!event.Dragging())
+ m_dragCount = 0;
+ else
+ m_dragCount++;
- if (event.Dragging() && (!m_isDragging))
+ if (event.Dragging() && (m_dragCount > 3))
{
- m_isDragging = TRUE;
+ m_dragCount = 0;
wxListEvent le( wxEVT_COMMAND_LIST_BEGIN_DRAG, m_parent->GetId() );
le.SetEventObject( this );
le.m_code = 0;
};
};
+bool wxListMainWindow::GetItemPosition(long item, wxPoint& pos)
+{
+ wxNode *node = m_lines.Nth( item );
+ if (node)
+ {
+ wxRectangle rect;
+ wxListLineData *line = (wxListLineData*)node->Data();
+ line->GetRect( rect );
+ pos.x = rect.x;
+ pos.y = rect.y;
+ }
+ else
+ {
+ pos.x = 0;
+ pos.y = 0;
+ };
+ return TRUE;
+};
+
int wxListMainWindow::GetSelectedItemCount( void )
{
int ret = 0;
return TRUE;
};
-bool wxListCtrl::GetItemPosition( long WXUNUSED(item), wxPoint& WXUNUSED(pos) ) const
+bool wxListCtrl::GetItemPosition( long item, wxPoint& pos )
{
- return 0;
+ m_mainWin->GetItemPosition( item, pos );
+ return TRUE;
};
bool wxListCtrl::SetItemPosition( long WXUNUSED(item), const wxPoint& WXUNUSED(pos) )
return TRUE;
};
-void wxListCtrl::OnIdle( wxIdleEvent &event )
+void wxListCtrl::OnIdle( wxIdleEvent &WXUNUSED(event) )
{
if (!m_mainWin->m_dirty) return;
wxPaintDC::wxPaintDC(void)
{
+ m_penGC = NULL;
+ m_brushGC = NULL;
+ m_textGC = NULL;
+ m_bgGC = NULL;
+ m_cmap = NULL;
};
wxPaintDC::wxPaintDC( wxWindow *window )
{
+ m_penGC = NULL;
+ m_brushGC = NULL;
+ m_textGC = NULL;
+ m_bgGC = NULL;
+ m_cmap = NULL;
+
if (!window) return;
GtkWidget *widget = window->m_wxwindow;
if (!widget) return;
{
m_ok = TRUE;
m_logicalFunction = wxCOPY;
+ if (m_penGC) gdk_gc_unref( m_penGC );
m_penGC = gdk_gc_new( m_window );
+ if (m_brushGC) gdk_gc_unref( m_brushGC );
m_brushGC = gdk_gc_new( m_window );
+ if (m_textGC) gdk_gc_unref( m_textGC );
m_textGC = gdk_gc_new( m_window );
+ if (m_bgGC) gdk_gc_unref( m_bgGC );
m_bgGC = gdk_gc_new( m_window );
SetTextForeground( m_textForegroundColour );
SetTextBackground( m_textBackgroundColour );
void wxDropTarget::UnregisterWidget( GtkWidget *widget )
{
+ if (!widget) return;
+
gtk_widget_dnd_drop_set( widget, FALSE, NULL, 0, FALSE );
};
+void wxDropTarget::RegisterWidget( GtkWidget *widget )
+{
+ wxString formats;
+ int valid = 0;
+
+ for ( uint i = 0; i < GetFormatCount(); i++ )
+ {
+ wxDataFormat df = GetFormat( i );
+ switch (df)
+ {
+ case wxDF_TEXT:
+ if (i > 0) formats += ";";
+ formats += "text/plain";
+ valid++;
+ break;
+ case wxDF_FILENAME:
+ if (i > 0) formats += ";";
+ formats += "url:any";
+ valid++;
+ break;
+ default:
+ break;
+ };
+ }
+
+ char *str = WXSTRINGCAST formats;
+
+ gtk_widget_dnd_drop_set( widget, TRUE, &str, valid, FALSE );
+};
+
// ----------------------------------------------------------------------------
// wxTextDropTarget
// ----------------------------------------------------------------------------
return TRUE;
};
-void wxTextDropTarget::RegisterWidget( GtkWidget *widget )
+size_t wxTextDropTarget::GetFormatCount() const
{
- char *accepted_drop_types[] = { "text/plain" };
- gtk_widget_dnd_drop_set( widget, TRUE, accepted_drop_types, 1, FALSE );
-};
+ return 1;
+}
+
+wxDataFormat wxTextDropTarget::GetFormat(size_t WXUNUSED(n)) const
+{
+ return wxDF_TEXT;
+}
+
+// ----------------------------------------------------------------------------
+// wxFileDropTarget
+// ----------------------------------------------------------------------------
+
+bool wxFileDropTarget::OnDropFiles( long x, long y, size_t nFiles, const char * const WXUNUSED(aszFiles)[] )
+{
+ printf( "Got %d dropped files.\n", (int)nFiles );
+ printf( "At x: %d, y: %d.\n", (int)x, (int)y );
+ return TRUE;
+}
+
+bool wxFileDropTarget::OnDrop(long x, long y, const void *WXUNUSED(pData) )
+{
+ char *str = "/this/is/a/path.txt";
+
+ return OnDropFiles(x, y, 1, &str );
+}
+
+size_t wxFileDropTarget::GetFormatCount() const
+{
+ return 1;
+}
+
+wxDataFormat wxFileDropTarget::GetFormat(size_t WXUNUSED(n)) const
+{
+ return wxDF_FILENAME;
+}
//-------------------------------------------------------------------------
-// wxDragSource
+// wxDropSource
//-------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// drag request
-void gtk_drag_callback( GtkWidget *widget, GdkEvent *event, wxDragSource *drag )
+void gtk_drag_callback( GtkWidget *widget, GdkEvent *event, wxDataObject *data )
{
- printf( "OnDragRequest.\n" );
+ printf( "Data requested for dropping.\n" );
+
+ uint size = data->GetDataSize();
+ char *ptr = new char[size];
+ data->GetDataHere( ptr );
+
+ gtk_widget_dnd_data_set( widget, event, ptr, size );
- gtk_widget_dnd_data_set( widget, event, drag->m_data, drag->m_size );
+ delete ptr;
};
-wxDragSource::wxDragSource( wxWindow *win )
+wxDropSource::wxDropSource( wxWindow *win )
{
g_blockEventsOnDrag = TRUE;
-
+
m_window = win;
m_widget = win->m_widget;
if (win->m_wxwindow) m_widget = win->m_wxwindow;
-
- m_data = NULL;
- m_size = 0;
+ m_data = NULL;
+
m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
m_goaheadCursor = wxCursor( wxCURSOR_HAND );
};
-wxDragSource::~wxDragSource(void)
+wxDropSource::wxDropSource( wxDataObject &data, wxWindow *win )
{
- g_blockEventsOnDrag = FALSE;
+ g_blockEventsOnDrag = TRUE;
+
+ m_window = win;
+ m_widget = win->m_widget;
+ if (win->m_wxwindow) m_widget = win->m_wxwindow;
+
+ m_data = &data;
+
+ m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
+ m_goaheadCursor = wxCursor( wxCURSOR_HAND );
};
-
-void wxDragSource::SetData( char *data, long size )
+
+void wxDropSource::SetData( wxDataObject &data )
{
- m_size = size;
- m_data = data;
+ m_data = &data;
};
-void wxDragSource::Start( int x, int y )
+wxDropSource::~wxDropSource(void)
{
- if (gdk_dnd.dnd_grabbed) return;
- if (gdk_dnd.drag_really) return;
- if (m_size == 0) return;
- if (!m_data) return;
+// if (m_data) delete m_data;
+
+ g_blockEventsOnDrag = FALSE;
+};
+
+wxDropSource::DragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
+{
+ if (gdk_dnd.dnd_grabbed) return None;
+ if (gdk_dnd.drag_really) return None;
+
+ if (!m_data) return None;
+ if (m_data->GetDataSize() == 0) return None;
GdkWindowPrivate *wp = (GdkWindowPrivate*) m_widget->window;
RegisterWindow();
- ConnectWindow();
gdk_dnd.drag_perhaps = TRUE;
gdk_dnd.dnd_grabbed = TRUE;
gdk_dnd.drag_really = 1;
+
+ int x = 0;
+ int y = 0;
+ gdk_window_get_pointer( m_widget->window, &x, &y, NULL );
+
gdk_dnd_display_drag_cursor( x, y, FALSE, TRUE );
while (gdk_dnd.drag_really || gdk_dnd.drag_perhaps) wxYield();
- UnconnectWindow();
UnregisterWindow();
+
+ return Copy;
};
-void wxDragSource::ConnectWindow(void)
+void wxDropSource::RegisterWindow(void)
{
- gtk_signal_connect( GTK_OBJECT(m_widget), "drag_request_event",
- GTK_SIGNAL_FUNC(gtk_drag_callback), (gpointer)this );
-};
+ if (!m_data) return;
-void wxDragSource::UnconnectWindow(void)
-{
- if (!m_widget) return;
+ wxString formats;
+
+ wxDataFormat df = m_data->GetPreferredFormat();
- gtk_signal_disconnect_by_data( GTK_OBJECT(m_widget), (gpointer)this );
-};
-
-void wxDragSource::UnregisterWindow(void)
-{
- if (!m_widget) return;
+ switch (df)
+ {
+ case wxDF_TEXT:
+ formats += "text/plain";
+ break;
+ case wxDF_FILENAME:
+ formats += "url:any";
+ break;
+ default:
+ break;
+ }
- gtk_widget_dnd_drag_set( m_widget, FALSE, NULL, 0 );
-};
+ char *str = WXSTRINGCAST formats;
-//-------------------------------------------------------------------------
-// wxTextDragSource
-//-------------------------------------------------------------------------
+ gtk_widget_dnd_drag_set( m_widget, TRUE, &str, 1 );
-void wxTextDragSource::SetTextData( const wxString &text )
-{
- m_tmp = text;
- SetData( WXSTRINGCAST(m_tmp), m_tmp.Length()+1 );
+ gtk_signal_connect( GTK_OBJECT(m_widget), "drag_request_event",
+ GTK_SIGNAL_FUNC(gtk_drag_callback), (gpointer)m_data );
};
-void wxTextDragSource::RegisterWindow(void)
+void wxDropSource::UnregisterWindow(void)
{
if (!m_widget) return;
- char *accepted_drop_types[] = { "text/plain" };
- gtk_widget_dnd_drag_set( m_widget, TRUE, accepted_drop_types, 1 );
+ gtk_widget_dnd_drag_set( m_widget, FALSE, NULL, 0 );
+
+ gtk_signal_disconnect_by_data( GTK_OBJECT(m_widget), (gpointer)m_data );
};
-
for(wxNode *node = GetChildren()->First(); node; node = node->Next())
{
wxWindow *win = (wxWindow *)node->Data();
- if (!win->IsKindOf(CLASSINFO(wxFrame)) &&
- !win->IsKindOf(CLASSINFO(wxDialog))
+ if (!IS_KIND_OF(win,wxFrame) && !IS_KIND_OF(win,wxDialog)
#if 0 // not in m_children anyway
&& (win != m_frameMenuBar) &&
(win != m_frameToolBar) &&
void wxFrame::AddChild( wxWindow *child )
{
+ // wxFrame and wxDialog as children aren't placed into the parents
+
+ if (child->IsKindOf(CLASSINFO(wxFrame)) || child->IsKindOf(CLASSINFO(wxDialog)))
+ {
+ m_children.Append( child );
+
+ if ((child->m_x != -1) && (child->m_y != -1))
+ gtk_widget_set_uposition( child->m_widget, child->m_x, child->m_y );
+
+ return;
+ }
+
if (m_addPrivateChild)
{
gtk_myfixed_put( GTK_MYFIXED(m_mainWindow), child->m_widget, child->m_x, child->m_y );
return m_frameMenuBar;
};
-wxToolBar *wxFrame::CreateToolBar( int style, int WXUNUSED(orientation), int WXUNUSED(rowsOrColumns) )
+wxToolBar *wxFrame::CreateToolBar( long style , wxWindowID id, const wxString& name )
{
m_addPrivateChild = TRUE;
- m_frameToolBar = new wxToolBar( this, -1, wxDefaultPosition, wxDefaultSize, style );
+ m_frameToolBar = new wxToolBar( this, id, wxDefaultPosition, wxDefaultSize, style, name );
m_addPrivateChild = FALSE;
return m_frameToolBar;
};
-bool wxFrame::CreateStatusBar( int number )
+wxStatusBar* wxFrame::CreateStatusBar( int number, long style, wxWindowID id, const wxString& name )
{
if (m_frameStatusBar)
delete m_frameStatusBar;
- m_frameStatusBar = new wxStatusBar( this, -1, wxPoint(0,0), wxSize(100,20) );
+ m_frameStatusBar = new wxStatusBar( this, id, wxPoint(0,0), wxSize(100,20), style, name );
m_frameStatusBar->SetFieldsCount( number );
- return TRUE;
+
+ return m_frameStatusBar;
};
void wxFrame::SetStatusText( const wxString &text, int number )
{
m_needParent = TRUE;
- wxSize newSize = size;
-
PreCreation( parent, id, pos, size, style, name );
m_rangeMax = range;
PostCreation();
+ gtk_widget_realize( GTK_WIDGET(m_list) );
+
Show( TRUE );
return TRUE;
return -1;
};
+GtkWidget *wxListBox::GetDropTargetWidget(void)
+{
+ return GTK_WIDGET(m_list);
+};
+
+
#endif
#include "wx/mdi.h"
+#include "wx/dialog.h"
#include "wx/gtk/win_gtk.h"
//-----------------------------------------------------------------------------
BEGIN_EVENT_TABLE(wxMDIChildFrame, wxPanel)
EVT_CLOSE(wxMDIChildFrame::OnCloseWindow)
+ EVT_SIZE(wxMDIChildFrame::OnSize)
END_EVENT_TABLE()
wxMDIChildFrame::wxMDIChildFrame(void)
}
};
+void wxMDIChildFrame::OnSize( wxSizeEvent &WXUNUSED(event) )
+{
+ if ( GetAutoLayout() )
+ Layout();
+ else {
+ // no child: go out !
+ if (!GetChildren()->First())
+ return;
+
+ // do we have exactly one child?
+ wxWindow *child = NULL;
+ for(wxNode *node = GetChildren()->First(); node; node = node->Next())
+ {
+ wxWindow *win = (wxWindow *)node->Data();
+ if (!IS_KIND_OF(win,wxFrame) && !IS_KIND_OF(win,wxDialog))
+ {
+ if ( child ) // it's the second one: do nothing
+ return;
+
+ child = win;
+ };
+ };
+
+ // yes: set it's size to fill all the frame
+ int client_x, client_y;
+ GetClientSize(&client_x, &client_y);
+ child->SetSize( 1, 1, client_x-2, client_y);
+ }
+};
bool wxMDIChildFrame::Destroy(void)
{
if (!wxPendingDelete.Member(this))
// wxNotebook
//-----------------------------------------------------------------------------
-BEGIN_EVENT_TABLE(wxNotebook, wxControl)
- EVT_SIZE(wxNotebook::OnSize)
-END_EVENT_TABLE()
-
IMPLEMENT_DYNAMIC_CLASS(wxNotebook,wxControl)
void wxNotebook::Init()
void wxNotebook::AddChild( wxWindow *win )
{
- // @@@ normally done in wxWindow::AddChild but for some reason wxNotebook
- // case is special there (Robert?)
- // Robert: Don't you think the code below looks different from the one
- // in wxWindow::AddChild :-)
-
m_children.Append(win);
wxNotebookPage *page = new wxNotebookPage();
};
// override these 2 functions to do nothing: everything is done in OnSize
-void wxNotebook::SetConstraintSizes(bool /* recurse */)
+void wxNotebook::SetConstraintSizes( bool WXUNUSED(recurse) )
{
// don't set the sizes of the pages - their correct size is not yet known
wxControl::SetConstraintSizes(FALSE);
}
-bool wxNotebook::DoPhase(int /* nPhase */)
+bool wxNotebook::DoPhase( int WXUNUSED(nPhase) )
{
return TRUE;
}
{
};
-void wxToolBar::Layout(void)
+void wxToolBar::Realize(void)
{
m_x = 0;
m_y = 0;
return *this;
}
+GtkWidget* wxTextCtrl::GetDropTargetWidget(void)
+{
+ return GTK_WIDGET(m_text);
+};
+
+
+
+
} wxEndProcessData;
static void GTK_EndProcessDetector(gpointer data, gint source,
- GdkInputCondition condition)
+ GdkInputCondition WXUNUSED(condition) )
{
wxEndProcessData *proc_data = (wxEndProcessData *)data;
int pid;
gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win )
{
- if (widget->window != gdk_event->window) return FALSE;
- if (g_blockEventsOnDrag) return FALSE;
+ if (widget->window != gdk_event->window) return TRUE;
+ if (g_blockEventsOnDrag) return TRUE;
if (win->m_wxwindow)
{
};
};
- if (!win->HasVMT()) return FALSE;
+ if (!win->HasVMT()) return TRUE;
/*
printf( "OnButtonPress from " );
{
if (widget->window != gdk_event->window) return TRUE;
- if (g_blockEventsOnDrag) return FALSE;
+ if (g_blockEventsOnDrag) return TRUE;
- if (!win->HasVMT()) return FALSE;
+ if (!win->HasVMT()) return TRUE;
/*
printf( "OnButtonRelease from " );
event.m_y = (long)gdk_event->y;
event.SetEventObject( win );
- return win->ProcessEvent( event );
+ win->ProcessEvent( event );
+
+ return TRUE;
};
//-----------------------------------------------------------------------------
{
if (widget->window != gdk_event->window) return TRUE;
- if (g_blockEventsOnDrag) return FALSE;
+ if (g_blockEventsOnDrag) return TRUE;
- if (!win->HasVMT()) return FALSE;
+ if (!win->HasVMT()) return TRUE;
/*
printf( "OnMotion from " );
win->ProcessEvent( event );
- return FALSE;
+ return TRUE;
};
//-----------------------------------------------------------------------------
gint gtk_window_focus_in_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxWindow *win )
{
- if (g_blockEventsOnDrag) return FALSE;
+ if (g_blockEventsOnDrag) return TRUE;
if (win->m_wxwindow)
{
if (GTK_WIDGET_CAN_FOCUS(win->m_wxwindow))
};
};
- if (!win->HasVMT()) return FALSE;
+ if (!win->HasVMT()) return TRUE;
/*
printf( "OnSetFocus from " );
wxFocusEvent event( wxEVT_SET_FOCUS, win->GetId() );
event.SetEventObject( win );
- return win->ProcessEvent( event );
+ win->ProcessEvent( event );
+
+ return TRUE;
};
//-----------------------------------------------------------------------------
gint gtk_window_focus_out_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxWindow *win )
{
- if (g_blockEventsOnDrag) return FALSE;
+ if (g_blockEventsOnDrag) return TRUE;
if (win->m_wxwindow)
{
if (GTK_WIDGET_CAN_FOCUS(win->m_wxwindow))
GTK_WIDGET_UNSET_FLAGS (win->m_wxwindow, GTK_HAS_FOCUS);
};
- if (!win->HasVMT()) return FALSE;
+ if (!win->HasVMT()) return TRUE;
/*
printf( "OnKillFocus from " );
wxFocusEvent event( wxEVT_KILL_FOCUS, win->GetId() );
event.SetEventObject( win );
- return win->ProcessEvent( event );
+ win->ProcessEvent( event );
+
+ return TRUE;
};
//-----------------------------------------------------------------------------
void gtk_window_drop_callback( GtkWidget *widget, GdkEvent *event, wxWindow *win )
{
- printf( "OnDrop.\n" );
-
if (win->GetDropTarget())
{
int x = 0;
gtk_signal_connect( GTK_OBJECT(connect_widget), "focus_out_event",
GTK_SIGNAL_FUNC(gtk_window_focus_out_callback), (gpointer)this );
- gtk_signal_connect( GTK_OBJECT(connect_widget), "drop_data_available_event",
- GTK_SIGNAL_FUNC(gtk_window_drop_callback), (gpointer)this );
-
// Only for cursor handling
gtk_signal_connect( GTK_OBJECT(m_widget), "enter_notify_event",
m_children.Append( child );
if (m_wxwindow) gtk_myfixed_put( GTK_MYFIXED(m_wxwindow), child->m_widget, child->m_x, child->m_y );
+
gtk_widget_set_usize( child->m_widget, child->m_width, child->m_height );
};
void wxWindow::SetDropTarget( wxDropTarget *dropTarget )
{
- GtkWidget *connect_widget = m_widget;
- if (m_wxwindow) connect_widget = m_wxwindow;
+ GtkWidget *dnd_widget = GetDropTargetWidget();
+
if (m_pDropTarget)
{
- m_pDropTarget->UnregisterWidget( connect_widget );
+ gtk_signal_disconnect_by_func( GTK_OBJECT(dnd_widget),
+ GTK_SIGNAL_FUNC(gtk_window_drop_callback), (gpointer)this );
+
+ m_pDropTarget->UnregisterWidget( dnd_widget );
delete m_pDropTarget;
};
m_pDropTarget = dropTarget;
if (m_pDropTarget)
{
- m_pDropTarget->RegisterWidget( connect_widget );
+ m_pDropTarget->RegisterWidget( dnd_widget );
+
+ gtk_signal_connect( GTK_OBJECT(dnd_widget), "drop_data_available_event",
+ GTK_SIGNAL_FUNC(gtk_window_drop_callback), (gpointer)this );
};
};
return m_pDropTarget;
};
+GtkWidget* wxWindow::GetDropTargetWidget(void)
+{
+ GtkWidget *connect_widget = m_widget;
+ if (m_wxwindow) connect_widget = m_wxwindow;
+
+ return connect_widget;
+}
+
void wxWindow::SetFont( const wxFont &font )
{
m_font = font;
return IsEnabled() && IsShown();
}
-void wxWindow::OnIdle(wxIdleEvent& event)
+void wxWindow::OnIdle(wxIdleEvent& WXUNUSED(event) )
{
UpdateWindowUI();
}
wxPaintDC::wxPaintDC(void)
{
+ m_penGC = NULL;
+ m_brushGC = NULL;
+ m_textGC = NULL;
+ m_bgGC = NULL;
+ m_cmap = NULL;
};
wxPaintDC::wxPaintDC( wxWindow *window )
{
+ m_penGC = NULL;
+ m_brushGC = NULL;
+ m_textGC = NULL;
+ m_bgGC = NULL;
+ m_cmap = NULL;
+
if (!window) return;
GtkWidget *widget = window->m_wxwindow;
if (!widget) return;
{
m_ok = TRUE;
m_logicalFunction = wxCOPY;
+ if (m_penGC) gdk_gc_unref( m_penGC );
m_penGC = gdk_gc_new( m_window );
+ if (m_brushGC) gdk_gc_unref( m_brushGC );
m_brushGC = gdk_gc_new( m_window );
+ if (m_textGC) gdk_gc_unref( m_textGC );
m_textGC = gdk_gc_new( m_window );
+ if (m_bgGC) gdk_gc_unref( m_bgGC );
m_bgGC = gdk_gc_new( m_window );
SetTextForeground( m_textForegroundColour );
SetTextBackground( m_textBackgroundColour );
void wxDropTarget::UnregisterWidget( GtkWidget *widget )
{
+ if (!widget) return;
+
gtk_widget_dnd_drop_set( widget, FALSE, NULL, 0, FALSE );
};
+void wxDropTarget::RegisterWidget( GtkWidget *widget )
+{
+ wxString formats;
+ int valid = 0;
+
+ for ( uint i = 0; i < GetFormatCount(); i++ )
+ {
+ wxDataFormat df = GetFormat( i );
+ switch (df)
+ {
+ case wxDF_TEXT:
+ if (i > 0) formats += ";";
+ formats += "text/plain";
+ valid++;
+ break;
+ case wxDF_FILENAME:
+ if (i > 0) formats += ";";
+ formats += "url:any";
+ valid++;
+ break;
+ default:
+ break;
+ };
+ }
+
+ char *str = WXSTRINGCAST formats;
+
+ gtk_widget_dnd_drop_set( widget, TRUE, &str, valid, FALSE );
+};
+
// ----------------------------------------------------------------------------
// wxTextDropTarget
// ----------------------------------------------------------------------------
return TRUE;
};
-void wxTextDropTarget::RegisterWidget( GtkWidget *widget )
+size_t wxTextDropTarget::GetFormatCount() const
{
- char *accepted_drop_types[] = { "text/plain" };
- gtk_widget_dnd_drop_set( widget, TRUE, accepted_drop_types, 1, FALSE );
-};
+ return 1;
+}
+
+wxDataFormat wxTextDropTarget::GetFormat(size_t WXUNUSED(n)) const
+{
+ return wxDF_TEXT;
+}
+
+// ----------------------------------------------------------------------------
+// wxFileDropTarget
+// ----------------------------------------------------------------------------
+
+bool wxFileDropTarget::OnDropFiles( long x, long y, size_t nFiles, const char * const WXUNUSED(aszFiles)[] )
+{
+ printf( "Got %d dropped files.\n", (int)nFiles );
+ printf( "At x: %d, y: %d.\n", (int)x, (int)y );
+ return TRUE;
+}
+
+bool wxFileDropTarget::OnDrop(long x, long y, const void *WXUNUSED(pData) )
+{
+ char *str = "/this/is/a/path.txt";
+
+ return OnDropFiles(x, y, 1, &str );
+}
+
+size_t wxFileDropTarget::GetFormatCount() const
+{
+ return 1;
+}
+
+wxDataFormat wxFileDropTarget::GetFormat(size_t WXUNUSED(n)) const
+{
+ return wxDF_FILENAME;
+}
//-------------------------------------------------------------------------
-// wxDragSource
+// wxDropSource
//-------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// drag request
-void gtk_drag_callback( GtkWidget *widget, GdkEvent *event, wxDragSource *drag )
+void gtk_drag_callback( GtkWidget *widget, GdkEvent *event, wxDataObject *data )
{
- printf( "OnDragRequest.\n" );
+ printf( "Data requested for dropping.\n" );
+
+ uint size = data->GetDataSize();
+ char *ptr = new char[size];
+ data->GetDataHere( ptr );
+
+ gtk_widget_dnd_data_set( widget, event, ptr, size );
- gtk_widget_dnd_data_set( widget, event, drag->m_data, drag->m_size );
+ delete ptr;
};
-wxDragSource::wxDragSource( wxWindow *win )
+wxDropSource::wxDropSource( wxWindow *win )
{
g_blockEventsOnDrag = TRUE;
-
+
m_window = win;
m_widget = win->m_widget;
if (win->m_wxwindow) m_widget = win->m_wxwindow;
-
- m_data = NULL;
- m_size = 0;
+ m_data = NULL;
+
m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
m_goaheadCursor = wxCursor( wxCURSOR_HAND );
};
-wxDragSource::~wxDragSource(void)
+wxDropSource::wxDropSource( wxDataObject &data, wxWindow *win )
{
- g_blockEventsOnDrag = FALSE;
+ g_blockEventsOnDrag = TRUE;
+
+ m_window = win;
+ m_widget = win->m_widget;
+ if (win->m_wxwindow) m_widget = win->m_wxwindow;
+
+ m_data = &data;
+
+ m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
+ m_goaheadCursor = wxCursor( wxCURSOR_HAND );
};
-
-void wxDragSource::SetData( char *data, long size )
+
+void wxDropSource::SetData( wxDataObject &data )
{
- m_size = size;
- m_data = data;
+ m_data = &data;
};
-void wxDragSource::Start( int x, int y )
+wxDropSource::~wxDropSource(void)
{
- if (gdk_dnd.dnd_grabbed) return;
- if (gdk_dnd.drag_really) return;
- if (m_size == 0) return;
- if (!m_data) return;
+// if (m_data) delete m_data;
+
+ g_blockEventsOnDrag = FALSE;
+};
+
+wxDropSource::DragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
+{
+ if (gdk_dnd.dnd_grabbed) return None;
+ if (gdk_dnd.drag_really) return None;
+
+ if (!m_data) return None;
+ if (m_data->GetDataSize() == 0) return None;
GdkWindowPrivate *wp = (GdkWindowPrivate*) m_widget->window;
RegisterWindow();
- ConnectWindow();
gdk_dnd.drag_perhaps = TRUE;
gdk_dnd.dnd_grabbed = TRUE;
gdk_dnd.drag_really = 1;
+
+ int x = 0;
+ int y = 0;
+ gdk_window_get_pointer( m_widget->window, &x, &y, NULL );
+
gdk_dnd_display_drag_cursor( x, y, FALSE, TRUE );
while (gdk_dnd.drag_really || gdk_dnd.drag_perhaps) wxYield();
- UnconnectWindow();
UnregisterWindow();
+
+ return Copy;
};
-void wxDragSource::ConnectWindow(void)
+void wxDropSource::RegisterWindow(void)
{
- gtk_signal_connect( GTK_OBJECT(m_widget), "drag_request_event",
- GTK_SIGNAL_FUNC(gtk_drag_callback), (gpointer)this );
-};
+ if (!m_data) return;
-void wxDragSource::UnconnectWindow(void)
-{
- if (!m_widget) return;
+ wxString formats;
+
+ wxDataFormat df = m_data->GetPreferredFormat();
- gtk_signal_disconnect_by_data( GTK_OBJECT(m_widget), (gpointer)this );
-};
-
-void wxDragSource::UnregisterWindow(void)
-{
- if (!m_widget) return;
+ switch (df)
+ {
+ case wxDF_TEXT:
+ formats += "text/plain";
+ break;
+ case wxDF_FILENAME:
+ formats += "url:any";
+ break;
+ default:
+ break;
+ }
- gtk_widget_dnd_drag_set( m_widget, FALSE, NULL, 0 );
-};
+ char *str = WXSTRINGCAST formats;
-//-------------------------------------------------------------------------
-// wxTextDragSource
-//-------------------------------------------------------------------------
+ gtk_widget_dnd_drag_set( m_widget, TRUE, &str, 1 );
-void wxTextDragSource::SetTextData( const wxString &text )
-{
- m_tmp = text;
- SetData( WXSTRINGCAST(m_tmp), m_tmp.Length()+1 );
+ gtk_signal_connect( GTK_OBJECT(m_widget), "drag_request_event",
+ GTK_SIGNAL_FUNC(gtk_drag_callback), (gpointer)m_data );
};
-void wxTextDragSource::RegisterWindow(void)
+void wxDropSource::UnregisterWindow(void)
{
if (!m_widget) return;
- char *accepted_drop_types[] = { "text/plain" };
- gtk_widget_dnd_drag_set( m_widget, TRUE, accepted_drop_types, 1 );
+ gtk_widget_dnd_drag_set( m_widget, FALSE, NULL, 0 );
+
+ gtk_signal_disconnect_by_data( GTK_OBJECT(m_widget), (gpointer)m_data );
};
-
for(wxNode *node = GetChildren()->First(); node; node = node->Next())
{
wxWindow *win = (wxWindow *)node->Data();
- if (!win->IsKindOf(CLASSINFO(wxFrame)) &&
- !win->IsKindOf(CLASSINFO(wxDialog))
+ if (!IS_KIND_OF(win,wxFrame) && !IS_KIND_OF(win,wxDialog)
#if 0 // not in m_children anyway
&& (win != m_frameMenuBar) &&
(win != m_frameToolBar) &&
void wxFrame::AddChild( wxWindow *child )
{
+ // wxFrame and wxDialog as children aren't placed into the parents
+
+ if (child->IsKindOf(CLASSINFO(wxFrame)) || child->IsKindOf(CLASSINFO(wxDialog)))
+ {
+ m_children.Append( child );
+
+ if ((child->m_x != -1) && (child->m_y != -1))
+ gtk_widget_set_uposition( child->m_widget, child->m_x, child->m_y );
+
+ return;
+ }
+
if (m_addPrivateChild)
{
gtk_myfixed_put( GTK_MYFIXED(m_mainWindow), child->m_widget, child->m_x, child->m_y );
return m_frameMenuBar;
};
-wxToolBar *wxFrame::CreateToolBar( int style, int WXUNUSED(orientation), int WXUNUSED(rowsOrColumns) )
+wxToolBar *wxFrame::CreateToolBar( long style , wxWindowID id, const wxString& name )
{
m_addPrivateChild = TRUE;
- m_frameToolBar = new wxToolBar( this, -1, wxDefaultPosition, wxDefaultSize, style );
+ m_frameToolBar = new wxToolBar( this, id, wxDefaultPosition, wxDefaultSize, style, name );
m_addPrivateChild = FALSE;
return m_frameToolBar;
};
-bool wxFrame::CreateStatusBar( int number )
+wxStatusBar* wxFrame::CreateStatusBar( int number, long style, wxWindowID id, const wxString& name )
{
if (m_frameStatusBar)
delete m_frameStatusBar;
- m_frameStatusBar = new wxStatusBar( this, -1, wxPoint(0,0), wxSize(100,20) );
+ m_frameStatusBar = new wxStatusBar( this, id, wxPoint(0,0), wxSize(100,20), style, name );
m_frameStatusBar->SetFieldsCount( number );
- return TRUE;
+
+ return m_frameStatusBar;
};
void wxFrame::SetStatusText( const wxString &text, int number )
{
m_needParent = TRUE;
- wxSize newSize = size;
-
PreCreation( parent, id, pos, size, style, name );
m_rangeMax = range;
PostCreation();
+ gtk_widget_realize( GTK_WIDGET(m_list) );
+
Show( TRUE );
return TRUE;
return -1;
};
+GtkWidget *wxListBox::GetDropTargetWidget(void)
+{
+ return GTK_WIDGET(m_list);
+};
+
+
#endif
#include "wx/mdi.h"
+#include "wx/dialog.h"
#include "wx/gtk/win_gtk.h"
//-----------------------------------------------------------------------------
BEGIN_EVENT_TABLE(wxMDIChildFrame, wxPanel)
EVT_CLOSE(wxMDIChildFrame::OnCloseWindow)
+ EVT_SIZE(wxMDIChildFrame::OnSize)
END_EVENT_TABLE()
wxMDIChildFrame::wxMDIChildFrame(void)
}
};
+void wxMDIChildFrame::OnSize( wxSizeEvent &WXUNUSED(event) )
+{
+ if ( GetAutoLayout() )
+ Layout();
+ else {
+ // no child: go out !
+ if (!GetChildren()->First())
+ return;
+
+ // do we have exactly one child?
+ wxWindow *child = NULL;
+ for(wxNode *node = GetChildren()->First(); node; node = node->Next())
+ {
+ wxWindow *win = (wxWindow *)node->Data();
+ if (!IS_KIND_OF(win,wxFrame) && !IS_KIND_OF(win,wxDialog))
+ {
+ if ( child ) // it's the second one: do nothing
+ return;
+
+ child = win;
+ };
+ };
+
+ // yes: set it's size to fill all the frame
+ int client_x, client_y;
+ GetClientSize(&client_x, &client_y);
+ child->SetSize( 1, 1, client_x-2, client_y);
+ }
+};
bool wxMDIChildFrame::Destroy(void)
{
if (!wxPendingDelete.Member(this))
// wxNotebook
//-----------------------------------------------------------------------------
-BEGIN_EVENT_TABLE(wxNotebook, wxControl)
- EVT_SIZE(wxNotebook::OnSize)
-END_EVENT_TABLE()
-
IMPLEMENT_DYNAMIC_CLASS(wxNotebook,wxControl)
void wxNotebook::Init()
void wxNotebook::AddChild( wxWindow *win )
{
- // @@@ normally done in wxWindow::AddChild but for some reason wxNotebook
- // case is special there (Robert?)
- // Robert: Don't you think the code below looks different from the one
- // in wxWindow::AddChild :-)
-
m_children.Append(win);
wxNotebookPage *page = new wxNotebookPage();
};
// override these 2 functions to do nothing: everything is done in OnSize
-void wxNotebook::SetConstraintSizes(bool /* recurse */)
+void wxNotebook::SetConstraintSizes( bool WXUNUSED(recurse) )
{
// don't set the sizes of the pages - their correct size is not yet known
wxControl::SetConstraintSizes(FALSE);
}
-bool wxNotebook::DoPhase(int /* nPhase */)
+bool wxNotebook::DoPhase( int WXUNUSED(nPhase) )
{
return TRUE;
}
{
};
-void wxToolBar::Layout(void)
+void wxToolBar::Realize(void)
{
m_x = 0;
m_y = 0;
return *this;
}
+GtkWidget* wxTextCtrl::GetDropTargetWidget(void)
+{
+ return GTK_WIDGET(m_text);
+};
+
+
+
+
} wxEndProcessData;
static void GTK_EndProcessDetector(gpointer data, gint source,
- GdkInputCondition condition)
+ GdkInputCondition WXUNUSED(condition) )
{
wxEndProcessData *proc_data = (wxEndProcessData *)data;
int pid;
gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win )
{
- if (widget->window != gdk_event->window) return FALSE;
- if (g_blockEventsOnDrag) return FALSE;
+ if (widget->window != gdk_event->window) return TRUE;
+ if (g_blockEventsOnDrag) return TRUE;
if (win->m_wxwindow)
{
};
};
- if (!win->HasVMT()) return FALSE;
+ if (!win->HasVMT()) return TRUE;
/*
printf( "OnButtonPress from " );
{
if (widget->window != gdk_event->window) return TRUE;
- if (g_blockEventsOnDrag) return FALSE;
+ if (g_blockEventsOnDrag) return TRUE;
- if (!win->HasVMT()) return FALSE;
+ if (!win->HasVMT()) return TRUE;
/*
printf( "OnButtonRelease from " );
event.m_y = (long)gdk_event->y;
event.SetEventObject( win );
- return win->ProcessEvent( event );
+ win->ProcessEvent( event );
+
+ return TRUE;
};
//-----------------------------------------------------------------------------
{
if (widget->window != gdk_event->window) return TRUE;
- if (g_blockEventsOnDrag) return FALSE;
+ if (g_blockEventsOnDrag) return TRUE;
- if (!win->HasVMT()) return FALSE;
+ if (!win->HasVMT()) return TRUE;
/*
printf( "OnMotion from " );
win->ProcessEvent( event );
- return FALSE;
+ return TRUE;
};
//-----------------------------------------------------------------------------
gint gtk_window_focus_in_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxWindow *win )
{
- if (g_blockEventsOnDrag) return FALSE;
+ if (g_blockEventsOnDrag) return TRUE;
if (win->m_wxwindow)
{
if (GTK_WIDGET_CAN_FOCUS(win->m_wxwindow))
};
};
- if (!win->HasVMT()) return FALSE;
+ if (!win->HasVMT()) return TRUE;
/*
printf( "OnSetFocus from " );
wxFocusEvent event( wxEVT_SET_FOCUS, win->GetId() );
event.SetEventObject( win );
- return win->ProcessEvent( event );
+ win->ProcessEvent( event );
+
+ return TRUE;
};
//-----------------------------------------------------------------------------
gint gtk_window_focus_out_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxWindow *win )
{
- if (g_blockEventsOnDrag) return FALSE;
+ if (g_blockEventsOnDrag) return TRUE;
if (win->m_wxwindow)
{
if (GTK_WIDGET_CAN_FOCUS(win->m_wxwindow))
GTK_WIDGET_UNSET_FLAGS (win->m_wxwindow, GTK_HAS_FOCUS);
};
- if (!win->HasVMT()) return FALSE;
+ if (!win->HasVMT()) return TRUE;
/*
printf( "OnKillFocus from " );
wxFocusEvent event( wxEVT_KILL_FOCUS, win->GetId() );
event.SetEventObject( win );
- return win->ProcessEvent( event );
+ win->ProcessEvent( event );
+
+ return TRUE;
};
//-----------------------------------------------------------------------------
void gtk_window_drop_callback( GtkWidget *widget, GdkEvent *event, wxWindow *win )
{
- printf( "OnDrop.\n" );
-
if (win->GetDropTarget())
{
int x = 0;
gtk_signal_connect( GTK_OBJECT(connect_widget), "focus_out_event",
GTK_SIGNAL_FUNC(gtk_window_focus_out_callback), (gpointer)this );
- gtk_signal_connect( GTK_OBJECT(connect_widget), "drop_data_available_event",
- GTK_SIGNAL_FUNC(gtk_window_drop_callback), (gpointer)this );
-
// Only for cursor handling
gtk_signal_connect( GTK_OBJECT(m_widget), "enter_notify_event",
m_children.Append( child );
if (m_wxwindow) gtk_myfixed_put( GTK_MYFIXED(m_wxwindow), child->m_widget, child->m_x, child->m_y );
+
gtk_widget_set_usize( child->m_widget, child->m_width, child->m_height );
};
void wxWindow::SetDropTarget( wxDropTarget *dropTarget )
{
- GtkWidget *connect_widget = m_widget;
- if (m_wxwindow) connect_widget = m_wxwindow;
+ GtkWidget *dnd_widget = GetDropTargetWidget();
+
if (m_pDropTarget)
{
- m_pDropTarget->UnregisterWidget( connect_widget );
+ gtk_signal_disconnect_by_func( GTK_OBJECT(dnd_widget),
+ GTK_SIGNAL_FUNC(gtk_window_drop_callback), (gpointer)this );
+
+ m_pDropTarget->UnregisterWidget( dnd_widget );
delete m_pDropTarget;
};
m_pDropTarget = dropTarget;
if (m_pDropTarget)
{
- m_pDropTarget->RegisterWidget( connect_widget );
+ m_pDropTarget->RegisterWidget( dnd_widget );
+
+ gtk_signal_connect( GTK_OBJECT(dnd_widget), "drop_data_available_event",
+ GTK_SIGNAL_FUNC(gtk_window_drop_callback), (gpointer)this );
};
};
return m_pDropTarget;
};
+GtkWidget* wxWindow::GetDropTargetWidget(void)
+{
+ GtkWidget *connect_widget = m_widget;
+ if (m_wxwindow) connect_widget = m_wxwindow;
+
+ return connect_widget;
+}
+
void wxWindow::SetFont( const wxFont &font )
{
m_font = font;
return IsEnabled() && IsShown();
}
-void wxWindow::OnIdle(wxIdleEvent& event)
+void wxWindow::OnIdle(wxIdleEvent& WXUNUSED(event) )
{
UpdateWindowUI();
}
#include <../iodbc/itrace.h>
#include <stdio.h>
+extern RETCODE _iodbcdm_driverunload();
+
RETCODE SQL_API SQLAllocConnect(
HENV henv,
HDBC FAR* phdbc )
UWORD fOption,
UDWORD vParam )
{
- GENV_t FAR* genv;
+/* GENV_t FAR* genv; */
DBC_t FAR* pdbc = (DBC_t FAR*)hdbc;
STMT_t FAR* pstmt;
HPROC hproc = SQL_NULL_HPROC;
UWORD fOption,
PTR pvParam )
{
- GENV_t FAR* genv;
+/* GENV_t FAR* genv; */
DBC_t FAR* pdbc = (DBC_t FAR*)hdbc;
int sqlstat = en_00000;
HPROC hproc = SQL_NULL_HPROC;
GENV_t FAR* genv = (GENV_t FAR*)henv;
DBC_t FAR* pdbc = (DBC_t FAR*)hdbc;
HERR herr;
- RETCODE retcode;
+ RETCODE retcode = 0;
if( hdbc != SQL_NULL_HDBC )
{
UWORD fOption )
{
STMT_t FAR* pstmt = (STMT_t FAR*)hstmt;
- STMT_t FAR* tpstmt;
+/* STMT_t FAR* tpstmt; */
DBC_t FAR* pdbc;
HPROC hproc = SQL_NULL_HPROC;
--- /dev/null
+/*
+ * Program: FMJobs.cpp
+ *
+ * Author: Robert Roebling
+ *
+ * Copyright: (C) 1997, GNU (Robert Roebling)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifdef __GNUG__
+#pragma implementation "FMJobs.h"
+#endif
+
+#include "FMJobs.h"
+#include "wx/utils.h"
+#include "wx/filefn.h"
+#include "wx/msgdlg.h"
+
+//-----------------------------------------------------------------------------
+// wxCopyStatusDia
+//-----------------------------------------------------------------------------
+
+IMPLEMENT_DYNAMIC_CLASS(wxCopyStatusDia,wxDialog);
+
+const ID_CANCEL_COPY = 1000;
+
+BEGIN_EVENT_TABLE(wxCopyStatusDia,wxDialog)
+ EVT_BUTTON (ID_CANCEL_COPY, wxCopyStatusDia::OnCommand)
+END_EVENT_TABLE()
+
+wxCopyStatusDia::wxCopyStatusDia( wxFrame *parent, const wxString &dest, wxArrayString *files ) :
+ wxDialog( parent, -1, "FileMaker copy job control", wxPoint(180,180), wxSize(500,200) )
+{
+ int w = 0;
+ int h = 0;
+ GetSize( &w, &h );
+
+ m_dest = dest;
+ m_files = files;
+ m_stop = FALSE;
+
+ (void)new wxStaticText( this, -1, "Copying files", wxPoint(10,10) );
+ (void)new wxStaticText( this, -1, "from:", wxPoint(30,40) );
+ m_sourceMsg = new wxStaticText( this, -1, "", wxPoint(80,40), wxSize(200,-1) );
+ (void)new wxStaticText( this, -1, " to:", wxPoint(30,70) );
+ m_destMsg = new wxStaticText( this, -1, "", wxPoint(80,70), wxSize(200,-1) );
+ (void)new wxStaticText( this, -1, " Kb copied:", wxPoint(30,100) );
+ m_statusMsg = new wxStaticText( this, -1, "0", wxPoint(120,100), wxSize(100,-1) );
+
+ m_cancelButton = new wxButton( this, ID_CANCEL_COPY, "Return", wxPoint(w-130,h-50), wxSize(85,30) );
+
+ Centre( wxVERTICAL | wxHORIZONTAL );
+
+ m_timer = new wxCopyTimer( this );
+ m_timer->Start( 300, TRUE );
+
+ Show( TRUE );
+};
+
+wxCopyStatusDia::~wxCopyStatusDia()
+{
+ delete m_timer;
+};
+
+void wxCopyStatusDia::OnCommand( wxCommandEvent &WXUNUSED(event) )
+{
+ if (m_stop) EndModal(wxID_CANCEL);
+ m_stop = TRUE;
+};
+
+void wxCopyStatusDia::DoCopy(void)
+{
+ wxYield();
+
+ if (!wxDirExists(m_dest))
+ {
+ wxMessageBox( "Target is not a directory or it doesn`t exist. Can`t copy.", "FileMaker" );
+ return;
+ };
+
+ for (uint i = 0; i < m_files->Count(); i++)
+ {
+ wxString src = (*m_files)[i];
+ if (wxDirExists( src ))
+ CopyDir( src, m_dest );
+ else
+ CopyFile( src, m_dest );
+ if (m_stop) return;
+ };
+ m_stop = TRUE;
+};
+
+void wxCopyStatusDia::CopyDir( wxString &srcDir, wxString &destDir )
+{
+ wxString src = srcDir;
+ wxString dest = destDir;
+ dest += "/";
+ dest += wxFileNameFromPath( src );
+ if (!wxMkdir( dest ))
+ {
+ wxMessageBox( "Could not create target directory.", "FileMaker" );
+ return;
+ };
+
+ wxArrayString list;
+ src += "/*";
+ char *f = wxFindFirstFile( src, wxDIR );
+ while (f)
+ {
+ list.Add( f );
+ f = wxFindNextFile();
+ };
+
+ for (uint i = 0; i < list.Count(); i++)
+ {
+ wxString filename = list[i];
+ if (wxDirExists( filename ))
+ CopyDir( filename, dest );
+ else
+ CopyFile( filename, dest );
+ if (m_stop) return;
+ };
+};
+
+void wxCopyStatusDia::CopyFile( wxString &src, wxString &destDir )
+{
+ m_sourceMsg->SetLabel( src );
+ wxString dest = destDir;
+ dest += "/";
+ dest += wxFileNameFromPath( src );
+ m_destMsg->SetLabel( dest );
+
+ wxYield();
+
+ if (wxFileExists(dest))
+ {
+ wxString s = "Target file ";
+ s += dest;
+ s += " exists already. Overwrite?";
+ int ret = wxMessageBox( s, "FileMaker", wxYES_NO );
+ if (ret == wxNO) return;
+ };
+
+ FILE *fs = NULL, *fd = NULL;
+ if (!(fs = fopen(src, "rb")))
+ {
+ wxString s = "Cannot open source file ";
+ s += src;
+ s += ".";
+ wxMessageBox( s, "FileMaker" );
+ return;
+ }
+ else
+ if (!(fd = fopen(dest, "wb")))
+ {
+ fclose(fs);
+ wxString s = "Cannot open target file ";
+ s += dest;
+ s += ".";
+ wxMessageBox( s, "FileMaker" );
+ return;
+ };
+ int ch;
+ long kcounter = 0;
+ while (!m_stop)
+ {
+ int counter = 0;
+ while ((ch = getc( fs )) != EOF)
+ {
+ putc( ch, fd );
+ counter++;
+ if (counter == 1000) break;
+ };
+ kcounter++;
+ m_statusMsg->SetLabel( IntToString( kcounter) );
+ wxYield();
+ if (ch == EOF) break;
+ };
+ fclose( fs );
+ fclose( fd );
+};
+
+
+//-----------------------------------------------------------------------------
+// wxDeleteStatusDia
+//-----------------------------------------------------------------------------
+
+/*
+
+IMPLEMENT_DYNAMIC_CLASS(wxDeleteStatusDia,wxDialogBox);
+
+wxDeleteStatusDia::wxDeleteStatusDia( wxFrame *parent, wxStringList *files ) :
+ wxDialogBox( parent, "FileMaker delete job control", TRUE,
+ 180, 180, 500, 200, wxCAPTION | wxTRANSIENT )
+{
+ int w = 0;
+ int h = 0;
+ GetSize( &w, &h );
+
+ m_files = files;
+ m_stop = FALSE;
+ m_countFiles = 0;
+ m_countDirs = 0;
+
+ wxFont *myFont = wxTheFontList->FindOrCreateFont( 12, wxROMAN, wxNORMAL, wxNORMAL );
+ SetLabelFont( myFont );
+ SetButtonFont( myFont );
+
+ wxStaticText *msg = new wxStaticText( this, "Deleting file or directory:", 10, 10 );
+ m_targetMsg = new wxStaticText( this, "", 80, 40, 300 );
+ msg = new wxStaticText( this, " Directories deleted:", 10, 80 );
+ m_dirsMsg = new wxStaticText( this, "0", 120, 80, 80 );
+ msg = new wxStaticText( this, " Files deleted:", 10, 110 );
+ m_filesMsg = new wxStaticText( this, "0", 120, 110, 100 );
+
+ m_cancelButton = new wxButton( this, NULL, "Return", w-130, h-50, 85, 30 );
+
+ Centre( wxVERTICAL | wxHORIZONTAL );
+
+ m_timer = new wxDeleteTimer( this );
+ m_timer->Start( 300, TRUE );
+
+ Show( TRUE );
+};
+
+wxDeleteStatusDia::~wxDeleteStatusDia()
+{
+ delete m_timer;
+};
+
+void wxDeleteStatusDia::OnCommand( wxWindow &win, wxCommandEvent &WXUNUSED(event) )
+{
+ if (&win == m_cancelButton)
+ {
+ if (m_stop) Show( FALSE );
+ m_stop = TRUE;
+ return;
+ };
+};
+
+void wxDeleteStatusDia::DoDelete(void)
+{
+ while (wxTheApp->Pending()) wxTheApp->Dispatch();
+ wxNode *node = m_files->First();
+ while (node)
+ {
+ char *target = (char*)node->Data();
+ if (wxDirExists( target ))
+ DeleteDir( target );
+ else
+ DeleteFile( target );
+ if (m_stop) return;
+ node = node->Next();
+ };
+ m_stop = TRUE;
+};
+
+void wxDeleteStatusDia::DeleteDir( char *target )
+{
+ wxString s = target;
+ s += "// *";
+ wxStringList list;
+ char *f = wxFindFirstFile( s );
+ while (f)
+ {
+ list.Add( f );
+ f = wxFindNextFile();
+ };
+ wxNode *node = list.First();
+ while (node)
+ {
+ f = (char*)node->Data();
+ if (wxDirExists( f ))
+ DeleteDir( f );
+ else
+ DeleteFile( f );
+ if (m_stop) return;
+ node = node->Next();
+ };
+ if (!wxRmdir( target ))
+ {
+ s = "Could not remove directory ";
+ s += target;
+ s += ".";
+ wxMessageBox( s, "FileMaker" );
+ return;
+ }
+ else
+ {
+ m_countDirs++;
+ m_dirsMsg->SetLabel( wxIntToString( m_countDirs) );
+ };
+};
+
+void wxDeleteStatusDia::DeleteFile( char *target )
+{
+ m_targetMsg->SetLabel( target );
+ while (wxTheApp->Pending()) wxTheApp->Dispatch();
+ if (!wxRemoveFile( target ))
+ {
+ wxString s = "Could not delete file ";
+ s += target;
+ s += ".";
+ wxMessageBox( s, "FileMaker" );
+ }
+ else
+ {
+ m_countFiles++;
+ m_filesMsg->SetLabel( wxIntToString( m_countFiles) );
+ };
+};
+
+*/
--- /dev/null
+/*
+ * File: FMJobs.h
+ *
+ * Author: Robert Roebling
+ *
+ * Copyright: (C) 1997, GNU (Robert Roebling)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef FMJobs_h
+#define FMJobs_h
+
+#ifdef __GNUG__
+#pragma interface
+#endif
+
+#include "wx/defs.h"
+#include "wx/dialog.h"
+#include "wx/frame.h"
+#include "wx/button.h"
+#include "wx/stattext.h"
+#include "wx/timer.h"
+
+//-----------------------------------------------------------------------------
+// derived classes
+//-----------------------------------------------------------------------------
+
+class wxCopyStatusDia;
+class wxDeleteStatusDia;
+class wxCopyTimer;
+class wxDeleteTimer;
+
+//-----------------------------------------------------------------------------
+// wxCopyStatusDia
+//-----------------------------------------------------------------------------
+
+class wxCopyStatusDia: public wxDialog
+{
+ DECLARE_DYNAMIC_CLASS( wxCopyStatusDia );
+
+ private:
+
+ wxString m_dest;
+ wxArrayString *m_files;
+ wxButton *m_cancelButton;
+ wxStaticText *m_sourceMsg;
+ wxStaticText *m_destMsg;
+ wxStaticText *m_statusMsg;
+ bool m_stop;
+ wxTimer *m_timer;
+
+ public:
+
+ wxCopyStatusDia(void) : wxDialog() {};
+ wxCopyStatusDia( wxFrame *parent, const wxString &dest, wxArrayString *files );
+ ~wxCopyStatusDia();
+ void OnCommand( wxCommandEvent &event );
+ void DoCopy(void);
+
+ private:
+ void CopyDir( wxString &srcDir, wxString &destDir );
+ void CopyFile( wxString &src, wxString &destDir );
+
+ DECLARE_EVENT_TABLE();
+};
+
+//-----------------------------------------------------------------------------
+// wxDeleteStatusDia
+//-----------------------------------------------------------------------------
+
+/*
+class wxDeleteStatusDia: public wxDialog
+{
+ DECLARE_DYNAMIC_CLASS( wxDeleteStatusDia );
+
+ private:
+
+ wxArrayString *m_files;
+ wxButton *m_cancelButton;
+ wxStaticText *m_targetMsg;
+ wxStaticText *m_filesMsg,*m_dirsMsg;
+ bool m_stop;
+ wxTimer *m_timer;
+ int m_countFiles,m_countDirs;
+
+ public:
+
+ wxDeleteStatusDia(void) : wxDialog() {};
+ wxDeleteStatusDia( wxFrame *parent, wxArrayString *files );
+ ~wxDeleteStatusDia();
+ void OnCommand( wxCommandEvent &event );
+ void DoDelete(void);
+
+ private:
+ void DeleteDir( wxString &target );
+ void DeleteFile( wxString &target );
+
+ DECLARE_EVENT_TABLE();
+};
+*/
+
+//-----------------------------------------------------------------------------
+// wxTimer
+//-----------------------------------------------------------------------------
+
+class wxCopyTimer: public wxTimer
+{
+ private:
+ wxCopyStatusDia *m_owner;
+
+ public:
+ wxCopyTimer( wxCopyStatusDia *owner ) { m_owner = owner; };
+ void Notify() { m_owner->DoCopy(); };
+};
+
+/*
+class wxDeleteTimer: public wxTimer
+{
+ private:
+ wxDeleteStatusDia *m_owner;
+
+ public:
+ wxDeleteTimer( wxDeleteStatusDia *owner ) { m_owner = owner; };
+ void Notify() { m_owner->DoDelete(); };
+};
+*/
+
+#endif // FMJobs_h
+
+
BIN_TARGET=wxFile
# define library sources
BIN_SRC=\
-wxFile.cpp filectrl.cpp dirctrl.cpp
+wxFile.cpp filectrl.cpp dirctrl.cpp FMJobs.cpp
#define library objects
BIN_OBJ=\
-wxFile.o filectrl.o dirctrl.o
+wxFile.o filectrl.o dirctrl.o FMJobs.o
# additional things needed to link
BIN_LINK=
#include "dirctrl.h"
#include "wx/gdicmn.h"
#include "wx/utils.h"
+#include "wx/dnd.h"
//-----------------------------------------------------------------------------
// wxDirInfo
EVT_TREE_ITEM_EXPANDED (-1, wxDirCtrl::OnExpandItem)
EVT_TREE_ITEM_COLLAPSED (-1, wxDirCtrl::OnCollapseItem)
EVT_TREE_DELETE_ITEM (-1, wxDirCtrl::OnDeleteItem)
- EVT_MOUSE_EVENTS (wxDirCtrl::OnMouse)
END_EVENT_TABLE()
wxDirCtrl::wxDirCtrl(void)
item.m_mask = wxTREE_MASK_TEXT | wxTREE_MASK_CHILDREN | wxTREE_MASK_DATA;
item.m_text = "Sections";
item.m_children = 1;
-/*
- wxDirInfo *info = new wxDirInfo( dir );
- item.m_data = (long)info;
-*/
m_rootId = InsertItem( 0, item );
+
+ SetDropTarget( new wxFileDropTarget() );
};
void wxDirCtrl::OnExpandItem( const wxTreeEvent &event )
(path != "/proc") &&
(path != "/mnt")
)
- slist.Add( path ); // ref counting in action !
+
+ slist.Add( path ); // ref counting in action !
};
path = wxFindNextFile();
};
wxDirInfo *info = (wxDirInfo *)event.m_item.m_data;
if (info) delete info;
};
-
-void wxDirCtrl::OnMouse( wxMouseEvent &event )
-{
- event.Skip(TRUE);
-
- if (event.LeftDown())
- {
- m_dragX = event.GetX();
- m_dragY = event.GetY();
- return;
- };
-
- if (event.Dragging())
- {
- if ((abs(m_dragX-event.GetX()) < 2) &&
- (abs(m_dragY-event.GetY()) < 2)) return;
-
- wxTextDragSource drag( this );
- drag.SetTextData( "Oh, what a drag." );
- drag.Start( event.GetX(), event.GetY() );
- };
-};
-
void OnExpandItem( const wxTreeEvent &event );
void OnCollapseItem( const wxTreeEvent &event );
void OnDeleteItem( const wxTreeEvent &event );
- void OnMouse( wxMouseEvent &event );
DECLARE_EVENT_TABLE()
};
IMPLEMENT_DYNAMIC_CLASS(wxFileCtrl,wxListCtrl);
BEGIN_EVENT_TABLE(wxFileCtrl,wxListCtrl)
- EVT_SET_FOCUS (wxFileCtrl::OnSetFocus)
+ EVT_SET_FOCUS (wxFileCtrl::OnSetFocus)
END_EVENT_TABLE()
wxFileCtrl *wxFileCtrl::m_lastFocus = NULL;
const long style, const wxString &name ) :
wxListCtrl( win, id, pos, size, style, name )
{
- SetItemSpacing( 20 );
- wxImageList *imageList = new wxImageList( 18, 18 );
+ SetItemSpacing( 40 );
+ wxImageList *imageList = new wxImageList( 30, 30 );
imageList->Add( wxBitmap( folder_xpm ) );
imageList->Add( wxBitmap( txt_xpm ) );
imageList->Add( wxBitmap( list_xpm ) );
Update();
m_lastFocus = this;
-
- SetDropTarget( new wxTextDropTarget() );
+
+ m_dragStartX = 0;
+ m_dragStartY = 0;
+ m_dragCount = 0;
+
+ SetDropTarget( new wxFileDropTarget() );
};
void wxFileCtrl::ChangeToListMode()
event.Skip();
};
-
private:
wxString m_dirName;
bool m_showHidden;
+ int m_dragStartX;
+ int m_dragStartY;
+ int m_dragCount;
public:
wxFileCtrl( void );
void MyFrame::OnListDrag( wxListEvent &event )
{
- printf( "OnDrag.\n" );
- return;
+ wxFileDataObject data;
+ data.AddFile( "/home/karl/test.txt" );
+
+ wxDropSource drag( data, m_leftFile->m_lastFocus );
+ drag.DoDragDrop();
};
void MyFrame::OnTreeSelected( wxTreeEvent &event )