Added wxWindow::DoMoveWindow(..)
Changed dnd and clipboard overviews. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5138 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
c76dd5a121
commit
23efdd028e
@ -5,6 +5,8 @@ clipboard class from wxWindows 1.xx, which has the same name but a different imp
|
||||
|
||||
To use the clipboard, you call member functions of the global {\bf wxTheClipboard} object.
|
||||
|
||||
See also the \helpref{wxDataObject overview}{wxdataobjectoverview} for further information.
|
||||
|
||||
Call \helpref{wxClipboard::Open}{wxclipboardopen} to get ownership of the clipboard. If this operation returns TRUE, you
|
||||
now own the clipboard. Call \helpref{wxClipboard::SetData}{wxclipboardsetdata} to put data
|
||||
on the clipboard, or \helpref{wxClipboard::GetData}{wxclipboardgetdata} to
|
||||
|
@ -1,9 +1,10 @@
|
||||
\section{\class{wxDropSource}}\label{wxdropsource}
|
||||
|
||||
\overview{Overview}{wxdndoverview}
|
||||
|
||||
This class represents a source for a drag and drop operation.
|
||||
|
||||
See \helpref{Drag'n'Drop overview}{wxdndoverview} and \helpref{wxDataObject overview}{wxdataobjectoverview}
|
||||
for more information.
|
||||
|
||||
\wxheading{Derived from}
|
||||
|
||||
None
|
||||
@ -30,7 +31,7 @@ enum wxDragResult
|
||||
|
||||
\wxheading{See also}
|
||||
|
||||
\helpref{Drag and drop overview}{wxdndoverview}, \helpref{wxDropTarget}{wxdroptarget},
|
||||
\helpref{wxDropTarget}{wxdroptarget},
|
||||
\helpref{wxTextDropTarget}{wxtextdroptarget}, \helpref{wxFileDropTarget}{wxfiledroptarget}
|
||||
|
||||
\latexignore{\rtfignore{\wxheading{Members}}}
|
||||
|
@ -1,7 +1,5 @@
|
||||
\section{\class{wxDropTarget}}\label{wxdroptarget}
|
||||
|
||||
\overview{Overview}{wxdndoverview}
|
||||
|
||||
This class represents a target for a drag and drop operation. A \helpref{wxDataObject}{wxdataobject}
|
||||
can be associated with it and by default, this object will be filled with the data from the
|
||||
drag source, if the data formats supported by the data object match the drag source data
|
||||
@ -13,6 +11,9 @@ the whole window area, but only a small portion of it. The normal sequence of ca
|
||||
\helpref{OnEnter}{wxdroptargetonenter}, possibly many times \helpref{OnDragOver}{wxdroptargetondragover},
|
||||
\helpref{OnDrop}{wxdroptargetondrop} and finally \helpref{OnData}{wxdroptargetondata}.
|
||||
|
||||
See \helpref{Drag'n'Drop overview}{wxdndoverview} and \helpref{wxDataObject overview}{wxdataobjectoverview}
|
||||
for more information.
|
||||
|
||||
\wxheading{Derived from}
|
||||
|
||||
None
|
||||
@ -39,7 +40,7 @@ enum wxDragResult
|
||||
|
||||
\wxheading{See also}
|
||||
|
||||
\helpref{Drag and drop overview}{wxdndoverview}, \helpref{wxDropSource}{wxdropsource},
|
||||
\helpref{wxDropSource}{wxdropsource},
|
||||
\helpref{wxTextDropTarget}{wxtextdroptarget}, \helpref{wxFileDropTarget}{wxfiledroptarget},
|
||||
\helpref{wxDataFormat}{wxdataformat}, \helpref{wxDataObject}{wxdataobject}
|
||||
|
||||
|
@ -1,15 +1,4 @@
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
%% Name: tclipbrd.tex
|
||||
%% Purpose: Data transfer (clipboard and drag and drop) overview
|
||||
%% Author: Vadim Zeitlin
|
||||
%% Modified by:
|
||||
%% Created: 18.10.99
|
||||
%% RCS-ID: $Id$
|
||||
%% Copyright: (c) Vadim Zeitlin
|
||||
%% Licence: wxWindows licence
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
\section{Clipboard and drag and drop overview}\label{wxdndoverview}
|
||||
\section{wxDataObject overview}\label{wxdataobjectoverview}
|
||||
|
||||
Classes: \helpref{wxDataObject}{wxdataobject},
|
||||
\helpref{wxClipboard}{wxclipboard},
|
||||
@ -17,8 +6,6 @@ Classes: \helpref{wxDataObject}{wxdataobject},
|
||||
\helpref{wxDropSource}{wxdropsource},
|
||||
\helpref{wxDropTarget}{wxdroptarget}
|
||||
|
||||
See also: \helpref{DnD sample}{samplednd}
|
||||
|
||||
This overview discusses data transfer through clipboard or drag and drop. In
|
||||
wxWindows, these two ways to transfer data (either between different
|
||||
applications or inside one and the same) are very similar which allows to
|
||||
|
@ -1,4 +1,4 @@
|
||||
\section{Drag-and-drop and clipboard overview}\label{wxdndoverview}
|
||||
\section{Drag'n'Drop overview}\label{wxdndoverview}
|
||||
|
||||
Classes: \helpref{wxDataObject}{wxdataobject},
|
||||
\helpref{wxTextDataObject}{wxtextdataobject},
|
||||
@ -10,53 +10,51 @@ Classes: \helpref{wxDataObject}{wxdataobject},
|
||||
Note that wxUSE\_DRAG\_AND\_DROP must be defined in setup.h in order
|
||||
to use Drag'n'Drop in wxWindows.
|
||||
|
||||
This overview describes wxWindows support for drag and drop and clipboard
|
||||
operations. Both of these topics are discussed here because, in fact, they're
|
||||
quite related. Drag and drop and clipboard are just two ways of passing the
|
||||
data around and so the code required to implement both types of the operations
|
||||
is almost the same.
|
||||
See also: \helpref{wxDataObject overview}{wxdataobjectoverview} and \helpref{DnD sample}{samplednd}
|
||||
|
||||
Both operations involve passing some data from one program to another,
|
||||
although the data can be received in the same program as the source. In the case
|
||||
of clipboard transfer, the data is first placed on the clipboard and then
|
||||
pasted into the destination program, while for a drag-and-drop operation the
|
||||
data object is not stored anywhere but is created when the user starts
|
||||
dragging and is destroyed as soon as he ends it, whether the operation was
|
||||
ended successfully or cancelled.
|
||||
It may be noted that data transfer to and from the clipboard is quite
|
||||
similar to data transfer with Drag'n'Drop and the code to implement
|
||||
these two types is almost the same. In particular, both data transfer
|
||||
mechanisms store data in some kind of \helpref{wxDataObject}{wxdataobject}
|
||||
and identify its format(s) using the \helpref{wxDataFormat}{wxdataformat}
|
||||
class.
|
||||
|
||||
To be a {\it drag source}, i.e. to provide the data which may be dragged by
|
||||
user elsewhere, you should implement the following steps:
|
||||
|
||||
\begin{itemize}\itemsep=0pt
|
||||
\item {\bf Preparation:} First of all, the data object must be created and
|
||||
\item {\bf Preparation:} First of all, a data object must be created and
|
||||
initialized with the data you wish to drag. For example:
|
||||
|
||||
\begin{verbatim}
|
||||
wxDataObject *my_data = new wxTextDataObject data("This string will be dragged.");
|
||||
wxTextDataObject my_data("This text will be dragged.");
|
||||
\end{verbatim}
|
||||
\item{\bf Drag start:} To start dragging process (typically in response to a
|
||||
mouse click) you must call \helpref{DoDragDrop}{wxdropsourcedodragdrop} function
|
||||
of wxDropSource object which should be constructed like this:
|
||||
mouse click) you must call \helpref{wxDropSource::DoDragDrop}{wxdropsourcedodragdrop}
|
||||
like this:
|
||||
|
||||
\begin{verbatim}
|
||||
wxDropSource dragSource( this );
|
||||
dragSource.SetData( my_data );
|
||||
wxDragResult result = dragSource.DoDragDrop( TRUE );
|
||||
\end{verbatim}
|
||||
\item {\bf Dragging:} The call to DoDragDrop() blocks until the user release the
|
||||
\item {\bf Dragging:} The call to DoDragDrop() blocks the program until the user release the
|
||||
mouse button (unless you override \helpref{GiveFeedback}{wxdropsourcegivefeedback} function
|
||||
to do something special). When the mouse moves in a window of a program which understands the
|
||||
same drag-and-drop protocol (any program under Windows or any program supporting the
|
||||
XDnD protocol under X Windows), the corresponding \helpref{wxDropTarget}{wxdroptarget} methods
|
||||
are called - see below.
|
||||
\item {\bf Processing the result:} DoDragDrop() returns an {\it effect code} which
|
||||
is one of the values of \helpref{wxDragResult}{wxdropsource} enum. Codes
|
||||
of wxDragError, wxDragNone and wxDragCancel have the obvious meaning and mean
|
||||
that there is nothing to do on the sending end (except of possibly logging the
|
||||
error in the first case). wxDragCopy means that the data has been successfully
|
||||
copied and doesn't require any specific actions neither. But wxDragMove is
|
||||
special because it means that the data must be deleted from where it was
|
||||
copied. If it doesn't make sense (dragging selected text from a read-only
|
||||
file) you should pass FALSE as parameter to DoDragDrop() in the previous step.
|
||||
is one of the values of {\tt wxDragResult} enum (explained \helpref{here}{wxdroptarget}):
|
||||
|
||||
\begin{verbatim}
|
||||
switch (result)
|
||||
{
|
||||
case wxDragCopy: /* copy the data */ break;
|
||||
case wxDragMove: /* move the data */ break;
|
||||
default: /* do nothing */ break;
|
||||
}
|
||||
\end{verbatim}
|
||||
\end{itemize}
|
||||
|
||||
To be a {\it drop target}, i.e. to receive the data dropped by user you should
|
||||
|
@ -86,7 +86,12 @@ public:
|
||||
virtual bool IsTopLevel() const { return TRUE; }
|
||||
|
||||
// implementation
|
||||
// --------------
|
||||
|
||||
// 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);
|
||||
|
||||
virtual void GtkOnSize( int x, int y, int width, int height );
|
||||
virtual void OnInternalIdle();
|
||||
|
||||
|
@ -93,6 +93,10 @@ public:
|
||||
// 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);
|
||||
|
||||
// GTK callbacks
|
||||
virtual void GtkOnSize( int x, int y, int width, int height );
|
||||
virtual void OnInternalIdle();
|
||||
|
@ -104,6 +104,10 @@ public:
|
||||
// implementation
|
||||
// --------------
|
||||
|
||||
// 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);
|
||||
|
||||
virtual WXWidget GetHandle() const { return m_widget; }
|
||||
|
||||
// also sets the global flag
|
||||
|
@ -86,7 +86,12 @@ public:
|
||||
virtual bool IsTopLevel() const { return TRUE; }
|
||||
|
||||
// implementation
|
||||
// --------------
|
||||
|
||||
// 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);
|
||||
|
||||
virtual void GtkOnSize( int x, int y, int width, int height );
|
||||
virtual void OnInternalIdle();
|
||||
|
||||
|
@ -93,6 +93,10 @@ public:
|
||||
// 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);
|
||||
|
||||
// GTK callbacks
|
||||
virtual void GtkOnSize( int x, int y, int width, int height );
|
||||
virtual void OnInternalIdle();
|
||||
|
@ -104,6 +104,10 @@ public:
|
||||
// implementation
|
||||
// --------------
|
||||
|
||||
// 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);
|
||||
|
||||
virtual WXWidget GetHandle() const { return m_widget; }
|
||||
|
||||
// also sets the global flag
|
||||
|
@ -470,6 +470,11 @@ void wxDialog::OnSize( wxSizeEvent &WXUNUSED(event) )
|
||||
}
|
||||
}
|
||||
|
||||
void wxDialog::DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y), int WXUNUSED(width), int WXUNUSED(height) )
|
||||
{
|
||||
wxFAIL_MSG( wxT("DoMoveWindow called for wxDialog") );
|
||||
}
|
||||
|
||||
void wxDialog::DoSetSize( int x, int y, int width, int height, int sizeFlags )
|
||||
{
|
||||
wxASSERT_MSG( (m_widget != NULL), wxT("invalid dialog") );
|
||||
|
@ -532,6 +532,11 @@ bool wxFrame::Show( bool show )
|
||||
return wxWindow::Show( show );
|
||||
}
|
||||
|
||||
void wxFrame::DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y), int WXUNUSED(width), int WXUNUSED(height) )
|
||||
{
|
||||
wxFAIL_MSG( wxT("DoMoveWindow called for wxFrame") );
|
||||
}
|
||||
|
||||
void wxFrame::DoSetSize( int x, int y, int width, int height, int sizeFlags )
|
||||
{
|
||||
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
|
||||
|
@ -2203,6 +2203,11 @@ bool wxWindow::Destroy()
|
||||
return wxWindowBase::Destroy();
|
||||
}
|
||||
|
||||
void wxWindow::DoMoveWindow(int x, int y, int width, int height)
|
||||
{
|
||||
gtk_pizza_set_size( GTK_PIZZA(m_parent->m_wxwindow), m_widget, x, y, width, height );
|
||||
}
|
||||
|
||||
void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags )
|
||||
{
|
||||
wxASSERT_MSG( (m_widget != NULL), wxT("invalid window") );
|
||||
@ -2263,12 +2268,10 @@ void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags )
|
||||
bottom_border = 5;
|
||||
}
|
||||
|
||||
gtk_pizza_set_size( GTK_PIZZA(m_parent->m_wxwindow),
|
||||
m_widget,
|
||||
m_x-border,
|
||||
m_y-border,
|
||||
m_width+2*border,
|
||||
m_height+border+bottom_border );
|
||||
DoMoveWindow( m_x-border,
|
||||
m_y-border,
|
||||
m_width+2*border,
|
||||
m_height+border+bottom_border );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -470,6 +470,11 @@ void wxDialog::OnSize( wxSizeEvent &WXUNUSED(event) )
|
||||
}
|
||||
}
|
||||
|
||||
void wxDialog::DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y), int WXUNUSED(width), int WXUNUSED(height) )
|
||||
{
|
||||
wxFAIL_MSG( wxT("DoMoveWindow called for wxDialog") );
|
||||
}
|
||||
|
||||
void wxDialog::DoSetSize( int x, int y, int width, int height, int sizeFlags )
|
||||
{
|
||||
wxASSERT_MSG( (m_widget != NULL), wxT("invalid dialog") );
|
||||
|
@ -532,6 +532,11 @@ bool wxFrame::Show( bool show )
|
||||
return wxWindow::Show( show );
|
||||
}
|
||||
|
||||
void wxFrame::DoMoveWindow(int WXUNUSED(x), int WXUNUSED(y), int WXUNUSED(width), int WXUNUSED(height) )
|
||||
{
|
||||
wxFAIL_MSG( wxT("DoMoveWindow called for wxFrame") );
|
||||
}
|
||||
|
||||
void wxFrame::DoSetSize( int x, int y, int width, int height, int sizeFlags )
|
||||
{
|
||||
wxASSERT_MSG( (m_widget != NULL), wxT("invalid frame") );
|
||||
|
@ -2203,6 +2203,11 @@ bool wxWindow::Destroy()
|
||||
return wxWindowBase::Destroy();
|
||||
}
|
||||
|
||||
void wxWindow::DoMoveWindow(int x, int y, int width, int height)
|
||||
{
|
||||
gtk_pizza_set_size( GTK_PIZZA(m_parent->m_wxwindow), m_widget, x, y, width, height );
|
||||
}
|
||||
|
||||
void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags )
|
||||
{
|
||||
wxASSERT_MSG( (m_widget != NULL), wxT("invalid window") );
|
||||
@ -2263,12 +2268,10 @@ void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags )
|
||||
bottom_border = 5;
|
||||
}
|
||||
|
||||
gtk_pizza_set_size( GTK_PIZZA(m_parent->m_wxwindow),
|
||||
m_widget,
|
||||
m_x-border,
|
||||
m_y-border,
|
||||
m_width+2*border,
|
||||
m_height+border+bottom_border );
|
||||
DoMoveWindow( m_x-border,
|
||||
m_y-border,
|
||||
m_width+2*border,
|
||||
m_height+border+bottom_border );
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user