1998-05-22 15:57:05 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2008-10-03 11:16:01 -04:00
|
|
|
// Name: samples/docview/view.h
|
1998-05-22 15:57:05 -04:00
|
|
|
// Purpose: View classes
|
|
|
|
// Author: Julian Smart
|
2008-10-03 11:16:01 -04:00
|
|
|
// Modified by: Vadim Zeitlin: merge with the MDI version and general cleanup
|
1998-05-22 15:57:05 -04:00
|
|
|
// Created: 04/01/98
|
|
|
|
// RCS-ID: $Id$
|
2008-10-03 11:16:01 -04:00
|
|
|
// Copyright: (c) 1998 Julian Smart
|
|
|
|
// (c) 2008 Vadim Zeitlin
|
2010-07-13 09:29:13 -04:00
|
|
|
// Licence: wxWindows licence
|
1998-05-22 15:57:05 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
#ifndef _WX_SAMPLES_DOCVIEW_VIEW_H_
|
|
|
|
#define _WX_SAMPLES_DOCVIEW_VIEW_H_
|
1998-05-22 15:57:05 -04:00
|
|
|
|
|
|
|
#include "wx/docview.h"
|
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// Drawing view classes
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// The window showing the drawing itself
|
2008-04-06 09:57:23 -04:00
|
|
|
class MyCanvas : public wxScrolledWindow
|
1998-05-22 15:57:05 -04:00
|
|
|
{
|
2000-07-15 15:51:35 -04:00
|
|
|
public:
|
2008-10-03 11:16:01 -04:00
|
|
|
// view may be NULL if we're not associated with one yet, but parent must
|
|
|
|
// be a valid pointer
|
|
|
|
MyCanvas(wxView *view, wxWindow *parent);
|
|
|
|
virtual ~MyCanvas();
|
2008-04-06 09:57:23 -04:00
|
|
|
|
1998-05-22 15:57:05 -04:00
|
|
|
virtual void OnDraw(wxDC& dc);
|
2008-04-06 09:57:23 -04:00
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
// in a normal multiple document application a canvas is associated with
|
|
|
|
// one view from the beginning until the end, but to support the single
|
|
|
|
// document mode in which all documents reuse the same MyApp::GetCanvas()
|
|
|
|
// we need to allow switching the canvas from one view to another one
|
|
|
|
|
|
|
|
void SetView(wxView *view)
|
|
|
|
{
|
|
|
|
wxASSERT_MSG( !m_view, "shouldn't be already associated with a view" );
|
|
|
|
|
|
|
|
m_view = view;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ResetView()
|
|
|
|
{
|
|
|
|
wxASSERT_MSG( m_view, "should be associated with a view" );
|
|
|
|
|
|
|
|
m_view = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
1998-05-22 15:57:05 -04:00
|
|
|
void OnMouseEvent(wxMouseEvent& event);
|
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
wxView *m_view;
|
|
|
|
|
|
|
|
// the segment being currently drawn or NULL if none
|
|
|
|
DoodleSegment *m_currentSegment;
|
2008-04-06 09:57:23 -04:00
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
// the last mouse press position
|
|
|
|
wxPoint m_lastMousePos;
|
|
|
|
|
|
|
|
DECLARE_EVENT_TABLE()
|
1998-05-22 15:57:05 -04:00
|
|
|
};
|
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
// The view using MyCanvas to show its contents
|
2008-04-06 09:57:23 -04:00
|
|
|
class DrawingView : public wxView
|
1998-05-22 15:57:05 -04:00
|
|
|
{
|
2000-07-15 15:51:35 -04:00
|
|
|
public:
|
2008-10-03 11:16:01 -04:00
|
|
|
DrawingView() { m_canvas = NULL; m_frame = NULL; }
|
2008-04-06 09:57:23 -04:00
|
|
|
|
|
|
|
virtual bool OnCreate(wxDocument *doc, long flags);
|
|
|
|
virtual void OnDraw(wxDC *dc);
|
|
|
|
virtual void OnUpdate(wxView *sender, wxObject *hint = NULL);
|
|
|
|
virtual bool OnClose(bool deleteWindow = true);
|
|
|
|
|
|
|
|
DrawingDocument* GetDocument();
|
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
private:
|
2000-07-15 15:51:35 -04:00
|
|
|
void OnCut(wxCommandEvent& event);
|
2008-04-06 09:57:23 -04:00
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
wxFrame *m_frame;
|
|
|
|
MyCanvas *m_canvas;
|
|
|
|
|
2000-07-15 15:51:35 -04:00
|
|
|
DECLARE_EVENT_TABLE()
|
2008-04-06 09:57:23 -04:00
|
|
|
DECLARE_DYNAMIC_CLASS(DrawingView)
|
1998-05-22 15:57:05 -04:00
|
|
|
};
|
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// Text view classes
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
// The view using a standard wxTextCtrl to show its contents
|
2008-04-06 09:57:23 -04:00
|
|
|
class TextEditView : public wxView
|
1998-05-22 15:57:05 -04:00
|
|
|
{
|
2000-07-15 15:51:35 -04:00
|
|
|
public:
|
2008-10-03 11:16:01 -04:00
|
|
|
TextEditView() : wxView() { m_frame = NULL; m_text = NULL; }
|
2008-04-06 09:57:23 -04:00
|
|
|
|
|
|
|
virtual bool OnCreate(wxDocument *doc, long flags);
|
|
|
|
virtual void OnDraw(wxDC *dc);
|
|
|
|
virtual bool OnClose(bool deleteWindow = true);
|
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
wxTextCtrl *GetText() const { return m_text; }
|
|
|
|
|
2008-04-06 09:57:23 -04:00
|
|
|
private:
|
2008-10-03 11:16:01 -04:00
|
|
|
void OnCopy(wxCommandEvent& WXUNUSED(event)) { m_text->Copy(); }
|
|
|
|
void OnPaste(wxCommandEvent& WXUNUSED(event)) { m_text->Paste(); }
|
|
|
|
void OnSelectAll(wxCommandEvent& WXUNUSED(event)) { m_text->SelectAll(); }
|
|
|
|
|
|
|
|
wxFrame *m_frame;
|
|
|
|
wxTextCtrl *m_text;
|
2008-04-06 13:02:25 -04:00
|
|
|
|
|
|
|
DECLARE_EVENT_TABLE()
|
2008-04-06 09:57:23 -04:00
|
|
|
DECLARE_DYNAMIC_CLASS(TextEditView)
|
1998-05-22 15:57:05 -04:00
|
|
|
};
|
|
|
|
|
2009-09-24 12:04:06 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
2010-05-13 10:37:06 -04:00
|
|
|
// ImageCanvas
|
2009-09-24 12:04:06 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2010-05-13 10:37:06 -04:00
|
|
|
class ImageCanvas : public wxScrolledWindow
|
2009-09-24 12:04:06 -04:00
|
|
|
{
|
|
|
|
public:
|
2010-05-13 10:37:06 -04:00
|
|
|
ImageCanvas(wxView*, wxWindow* parent);
|
2009-09-24 12:04:06 -04:00
|
|
|
|
|
|
|
virtual void OnDraw(wxDC& dc);
|
|
|
|
|
|
|
|
// in a normal multiple document application a canvas is associated with
|
|
|
|
// one view from the beginning until the end, but to support the single
|
|
|
|
// document mode in which all documents reuse the same MyApp::GetCanvas()
|
|
|
|
// we need to allow switching the canvas from one view to another one
|
|
|
|
|
|
|
|
void SetView(wxView* view)
|
|
|
|
{
|
|
|
|
wxASSERT_MSG( !m_view, "shouldn't be already associated with a view" );
|
|
|
|
|
|
|
|
m_view = view;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ResetView()
|
|
|
|
{
|
|
|
|
wxASSERT_MSG( m_view, "should be associated with a view" );
|
|
|
|
|
|
|
|
m_view = NULL;
|
|
|
|
}
|
|
|
|
|
2010-05-13 10:37:06 -04:00
|
|
|
private:
|
2009-09-24 12:04:06 -04:00
|
|
|
wxView *m_view;
|
|
|
|
};
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2010-05-13 10:37:06 -04:00
|
|
|
// ImageView
|
2009-09-24 12:04:06 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2010-05-13 10:37:06 -04:00
|
|
|
class ImageView : public wxView
|
2009-09-24 12:04:06 -04:00
|
|
|
{
|
|
|
|
public:
|
2010-05-13 10:37:06 -04:00
|
|
|
ImageView() : wxView(), m_frame(NULL) {}
|
2009-09-24 12:04:06 -04:00
|
|
|
|
|
|
|
virtual bool OnCreate(wxDocument*, long flags);
|
|
|
|
virtual void OnDraw(wxDC*);
|
|
|
|
virtual bool OnClose(bool deleteWindow = true);
|
|
|
|
virtual void OnUpdate(wxView *sender, wxObject *hint = NULL);
|
|
|
|
|
2010-05-13 10:37:06 -04:00
|
|
|
ImageDocument* GetDocument();
|
2009-09-24 12:04:06 -04:00
|
|
|
|
2010-05-13 10:37:06 -04:00
|
|
|
private:
|
2009-09-24 12:04:06 -04:00
|
|
|
wxFrame* m_frame;
|
2010-05-13 10:37:06 -04:00
|
|
|
ImageCanvas* m_canvas;
|
2009-09-24 12:04:06 -04:00
|
|
|
|
2010-05-13 10:37:06 -04:00
|
|
|
DECLARE_DYNAMIC_CLASS(ImageView)
|
2009-09-24 12:04:06 -04:00
|
|
|
};
|
|
|
|
|
2008-10-03 11:16:01 -04:00
|
|
|
#endif // _WX_SAMPLES_DOCVIEW_VIEW_H_
|