#if wxUSE_METAFILES
#include "wx/metafile.h"
#endif // wxUSE_METAFILES
#if defined(__WXGTK__) || defined(__WXX11__) || defined(__WXMOTIF__) || defined(__WXMAC__)
#if wxUSE_METAFILES
#include "wx/metafile.h"
#endif // wxUSE_METAFILES
#if defined(__WXGTK__) || defined(__WXX11__) || defined(__WXMOTIF__) || defined(__WXMAC__)
{
// of course, a real program would do something more useful here...
wxMessageBox(text, _T("wxDnD sample: got URL"),
{
// of course, a real program would do something more useful here...
wxMessageBox(text, _T("wxDnD sample: got URL"),
// URLs can't be moved, only copied
virtual wxDragResult OnDragOver(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y),
// URLs can't be moved, only copied
virtual wxDragResult OnDragOver(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y),
{
return wxDragLink; // At least IE 5.x needs wxDragLink, the
// other browsers on MSW seem okay with it too.
{
return wxDragLink; // At least IE 5.x needs wxDragLink, the
// other browsers on MSW seem okay with it too.
// ----------------------------------------------------------------------------
// Define canvas class to show a bitmap
// ----------------------------------------------------------------------------
// Define canvas class to show a bitmap
void OnDragMoveAllow(wxCommandEvent& event);
void OnNewFrame(wxCommandEvent& event);
void OnHelp (wxCommandEvent& event);
void OnDragMoveAllow(wxCommandEvent& event);
void OnNewFrame(wxCommandEvent& event);
void OnHelp (wxCommandEvent& event);
// shapes, each one with its own colour and position
// ----------------------------------------------------------------------------
// shapes, each one with its own colour and position
// ----------------------------------------------------------------------------
{
wxCHECK_MSG( format == m_formatShape, false,
wxT( "unsupported format") );
{
wxCHECK_MSG( format == m_formatShape, false,
wxT( "unsupported format") );
// override base class (pure) virtuals
virtual wxDragResult OnEnter(wxCoord x, wxCoord y, wxDragResult def)
// override base class (pure) virtuals
virtual wxDragResult OnEnter(wxCoord x, wxCoord y, wxDragResult def)
- { m_frame->SetStatusText(_T("Mouse entered the frame")); return OnDragOver(x, y, def); }
+ {
+#if wxUSE_STATUSBAR
+ m_frame->SetStatusText(_T("Mouse entered the frame"));
+#endif // wxUSE_STATUSBAR
+ return OnDragOver(x, y, def);
+ }
// ----------------------------------------------------------------------------
// functions prototypes
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// functions prototypes
// ----------------------------------------------------------------------------
EVT_MENU(Menu_DragMoveAllow,DnDFrame::OnDragMoveAllow)
EVT_MENU(Menu_NewFrame, DnDFrame::OnNewFrame)
EVT_MENU(Menu_Help, DnDFrame::OnHelp)
EVT_MENU(Menu_DragMoveAllow,DnDFrame::OnDragMoveAllow)
EVT_MENU(Menu_NewFrame, DnDFrame::OnNewFrame)
EVT_MENU(Menu_Help, DnDFrame::OnHelp)
EVT_MENU(Menu_Copy, DnDFrame::OnCopy)
EVT_MENU(Menu_Paste, DnDFrame::OnPaste)
EVT_MENU(Menu_CopyBitmap, DnDFrame::OnCopyBitmap)
EVT_MENU(Menu_Copy, DnDFrame::OnCopy)
EVT_MENU(Menu_Paste, DnDFrame::OnPaste)
EVT_MENU(Menu_CopyBitmap, DnDFrame::OnCopyBitmap)
BEGIN_EVENT_TABLE(DnDShapeFrame, wxFrame)
EVT_MENU(Menu_Shape_New, DnDShapeFrame::OnNewShape)
EVT_MENU(Menu_Shape_Edit, DnDShapeFrame::OnEditShape)
BEGIN_EVENT_TABLE(DnDShapeFrame, wxFrame)
EVT_MENU(Menu_Shape_New, DnDShapeFrame::OnNewShape)
EVT_MENU(Menu_Shape_Edit, DnDShapeFrame::OnEditShape)
BEGIN_EVENT_TABLE(DnDCanvasBitmap, wxScrolledWindow)
EVT_PAINT(DnDCanvasBitmap::OnPaint)
END_EVENT_TABLE()
BEGIN_EVENT_TABLE(DnDCanvasBitmap, wxScrolledWindow)
EVT_PAINT(DnDCanvasBitmap::OnPaint)
END_EVENT_TABLE()
// create the main frame window
DnDFrame *frame = new DnDFrame((wxFrame *) NULL,
// create the main frame window
DnDFrame *frame = new DnDFrame((wxFrame *) NULL,
DnDFrame::DnDFrame(wxFrame *frame, wxChar *title, int x, int y, int w, int h)
: wxFrame(frame, wxID_ANY, title, wxPoint(x, y), wxSize(w, h)),
DnDFrame::DnDFrame(wxFrame *frame, wxChar *title, int x, int y, int w, int h)
: wxFrame(frame, wxID_ANY, title, wxPoint(x, y), wxSize(w, h)),
file_menu->AppendSeparator();
file_menu->Append(Menu_Quit, _T("E&xit\tCtrl-Q"));
file_menu->AppendSeparator();
file_menu->Append(Menu_Quit, _T("E&xit\tCtrl-Q"));
wxMenu *log_menu = new wxMenu;
log_menu->Append(Menu_Clear, _T("Clear\tCtrl-L"));
wxMenu *log_menu = new wxMenu;
log_menu->Append(Menu_Clear, _T("Clear\tCtrl-L"));
wxMenu *help_menu = new wxMenu;
help_menu->Append(Menu_Help, _T("&Help..."));
wxMenu *help_menu = new wxMenu;
help_menu->Append(Menu_Help, _T("&Help..."));
wxMenuBar *menu_bar = new wxMenuBar;
menu_bar->Append(file_menu, _T("&File"));
wxMenuBar *menu_bar = new wxMenuBar;
menu_bar->Append(file_menu, _T("&File"));
menu_bar->Append(clip_menu, _T("&Clipboard"));
menu_bar->Append(help_menu, _T("&Help"));
menu_bar->Append(clip_menu, _T("&Clipboard"));
menu_bar->Append(help_menu, _T("&Help"));
m_ctrlText = new wxListBox(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 1, &strText,
wxLB_HSCROLL | wxLB_ALWAYS_SB );
m_ctrlText = new wxListBox(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 1, &strText,
wxLB_HSCROLL | wxLB_ALWAYS_SB );
m_ctrlLog = new wxTextCtrl(this, wxID_ANY, _T(""), wxDefaultPosition, wxDefaultSize,
wxTE_MULTILINE | wxTE_READONLY |
wxSUNKEN_BORDER );
m_ctrlLog = new wxTextCtrl(this, wxID_ANY, _T(""), wxDefaultPosition, wxDefaultSize,
wxTE_MULTILINE | wxTE_READONLY |
wxSUNKEN_BORDER );
// redirect log messages to the text window
m_pLog = new wxLogTextCtrl(m_ctrlLog);
m_pLogPrev = wxLog::SetActiveTarget(m_pLog);
// redirect log messages to the text window
m_pLog = new wxLogTextCtrl(m_ctrlLog);
m_pLogPrev = wxLog::SetActiveTarget(m_pLog);
// associate drop targets with the controls
m_ctrlFile->SetDropTarget(new DnDFile(m_ctrlFile));
m_ctrlText->SetDropTarget(new DnDText(m_ctrlText));
// associate drop targets with the controls
m_ctrlFile->SetDropTarget(new DnDFile(m_ctrlFile));
m_ctrlText->SetDropTarget(new DnDText(m_ctrlText));
- wxBoxSizer *m_sizer_top = new wxBoxSizer( wxHORIZONTAL );
- m_sizer_top->Add(m_ctrlFile, 1, wxEXPAND );
- m_sizer_top->Add(m_ctrlText, 1, wxEXPAND );
+ wxBoxSizer *sizer_top = new wxBoxSizer( wxHORIZONTAL );
+ sizer_top->Add(m_ctrlFile, 1, wxEXPAND );
+ sizer_top->Add(m_ctrlText, 1, wxEXPAND );
- wxBoxSizer *m_sizer = new wxBoxSizer( wxVERTICAL );
- m_sizer->Add(m_sizer_top, 1, wxEXPAND );
- m_sizer->Add(m_ctrlLog, 1, wxEXPAND | wxBOTTOM, 50);
+ wxBoxSizer *sizer = new wxBoxSizer( wxVERTICAL );
+ sizer->Add(sizer_top, 1, wxEXPAND );
+#if wxUSE_LOG
+ sizer->Add(m_ctrlLog, 2, wxEXPAND);
+ sizer->SetItemMinSize(m_ctrlLog, 450, 0);
+#endif // wxUSE_LOG
+ sizer->AddSpacer(50);
(new DnDShapeFrame(this))->Show(true);
wxLogStatus(this, wxT("Double click the new frame to select a shape for it"));
(new DnDShapeFrame(this))->Show(true);
wxLogStatus(this, wxT("Double click the new frame to select a shape for it"));
wxString strText = wxGetTextFromUser
(
_T("After you enter text in this dialog, press any mouse\n")
wxString strText = wxGetTextFromUser
(
_T("After you enter text in this dialog, press any mouse\n")
void DnDFrame::OnHelp(wxCommandEvent& /* event */)
{
wxMessageDialog dialog(this,
void DnDFrame::OnHelp(wxCommandEvent& /* event */)
{
wxMessageDialog dialog(this,
_T("consists of 3 parts: the bottom pane is for debug messages, so that you can see what's\n")
_T("going on inside. The top part is split into 2 listboxes, the left one accepts files\n")
_T("and the right one accepts text.\n")
_T("consists of 3 parts: the bottom pane is for debug messages, so that you can see what's\n")
_T("going on inside. The top part is split into 2 listboxes, the left one accepts files\n")
_T("and the right one accepts text.\n")
// ----------------------------------------------------------------------------
// Notifications called by the base class
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// Notifications called by the base class
// ----------------------------------------------------------------------------
DnDShapeFrame *DnDShapeFrame::ms_lastDropTarget = NULL;
DnDShapeFrame::DnDShapeFrame(wxFrame *parent)
DnDShapeFrame *DnDShapeFrame::ms_lastDropTarget = NULL;
DnDShapeFrame::DnDShapeFrame(wxFrame *parent)
- : wxFrame(parent, wxID_ANY, _T("Shape Frame"),
- wxDefaultPosition, wxSize(250, 150))
+ : wxFrame(parent, wxID_ANY, _T("Shape Frame"))
wxMenu *menuShape = new wxMenu;
menuShape->Append(Menu_Shape_New, _T("&New default shape\tCtrl-S"));
wxMenu *menuShape = new wxMenu;
menuShape->Append(Menu_Shape_New, _T("&New default shape\tCtrl-S"));
wxString s;
s.Printf(wxT("Shape dropped at (%d, %d)"), pt.x, pt.y);
SetStatusText(s);
wxString s;
s.Printf(wxT("Shape dropped at (%d, %d)"), pt.x, pt.y);
SetStatusText(s);
{
SetShape(new DnDEllipticShape(wxPoint(10, 10), wxSize(80, 60), *wxRED));
{
SetShape(new DnDEllipticShape(wxPoint(10, 10), wxSize(80, 60), *wxRED));
// ----------------------------------------------------------------------------
// global functions
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// global functions
// ----------------------------------------------------------------------------
static void ShowBitmap(const wxBitmap& bitmap)
{
wxFrame *frame = new wxFrame(NULL, wxID_ANY, _T("Bitmap view"));
static void ShowBitmap(const wxBitmap& bitmap)
{
wxFrame *frame = new wxFrame(NULL, wxID_ANY, _T("Bitmap view"));
DnDCanvasBitmap *canvas = new DnDCanvasBitmap(frame);
canvas->SetBitmap(bitmap);
int w = bitmap.GetWidth(),
h = bitmap.GetHeight();
DnDCanvasBitmap *canvas = new DnDCanvasBitmap(frame);
canvas->SetBitmap(bitmap);
int w = bitmap.GetWidth(),
h = bitmap.GetHeight();