view.h revision 690d37ddd3470e494dde1e3ee20b942736e734d2
905N/A#ifndef INKSCAPE_UI_VIEW_VIEW_H
905N/A#define INKSCAPE_UI_VIEW_VIEW_H
905N/A
905N/A/** \file
905N/A * Abstract base class for all SVG document views
905N/A *
905N/A * Authors:
905N/A * Lauris Kaplinski <lauris@kaplinski.com>
905N/A * Ralf Stephan <ralf@ark.in-berlin.de>
905N/A *
905N/A * Copyright (C) 2001-2002 Lauris Kaplinski
905N/A * Copyright (C) 2001 Ximian, Inc.
905N/A *
905N/A * Released under GNU GPL, read the file 'COPYING' for more information
905N/A */
905N/A
905N/A#include <gdk/gdktypes.h>
905N/A#include <sigc++/connection.h>
905N/A#include "message.h"
905N/A#include "gc-managed.h"
3996N/A#include "gc-finalized.h"
905N/A#include "gc-anchored.h"
905N/A#include <libnr/nr-forward.h>
905N/A#include <2geom/forward.h>
905N/A
905N/A/**
905N/A * Iterates until true or returns false.
905N/A * When used as signal accumulator, stops emission if one slot returns true.
905N/A */
905N/Astruct StopOnTrue {
905N/A typedef bool result_type;
1273N/A
905N/A template<typename T_iterator>
3661N/A result_type operator()(T_iterator first, T_iterator last) const{
3661N/A for (; first != last; ++first)
3996N/A if (*first) return true;
3996N/A return false;
3996N/A }
905N/A};
905N/A
905N/A/**
905N/A * Iterates until nonzero or returns 0.
905N/A * When used as signal accumulator, stops emission if one slot returns nonzero.
905N/A */
905N/Astruct StopOnNonZero {
905N/A typedef int result_type;
905N/A
905N/A template<typename T_iterator>
905N/A result_type operator()(T_iterator first, T_iterator last) const{
905N/A for (; first != last; ++first)
905N/A if (*first) return *first;
905N/A return 0;
905N/A }
3996N/A};
3996N/A
class SPDocument;
namespace Inkscape {
class MessageContext;
class MessageStack;
namespace UI {
namespace View {
/**
* View is an abstract base class of all UI document views. This
* includes both the editing window and the SVG preview, but does not
* include the non-UI RGBA buffer-based NRArena nor the XML editor or
* similar views. The View base class has very little functionality of
* its own.
*/
class View : public GC::Managed<>,
public GC::Finalized,
public GC::Anchored
{
public:
View();
virtual ~View();
void close() { _close(); }
/// Returns a pointer to the view's document.
SPDocument *doc() const
{ return _doc; }
/// Returns a pointer to the view's message stack.
Inkscape::MessageStack *messageStack() const
{ return _message_stack; }
/// Returns a pointer to the view's tipsMessageContext.
Inkscape::MessageContext *tipsMessageContext() const
{ return _tips_message_context; }
void setPosition(gdouble x, gdouble y);
void setPosition(Geom::Point const &p);
void emitResized(gdouble width, gdouble height);
void requestRedraw();
// view subclasses must give implementations of these methods
virtual bool shutdown() = 0;
virtual void mouseover() = 0;
virtual void mouseout() = 0;
virtual void onPositionSet (double, double) = 0;
virtual void onResized (double, double) = 0;
virtual void onRedrawRequested() = 0;
virtual void onStatusMessage (Inkscape::MessageType type, gchar const *message) = 0;
virtual void onDocumentURISet (gchar const* uri) = 0;
virtual void onDocumentResized (double, double) = 0;
protected:
SPDocument *_doc;
Inkscape::MessageStack *_message_stack;
Inkscape::MessageContext *_tips_message_context;
virtual void _close();
virtual void setDocument(SPDocument *doc);
sigc::signal<void,double,double> _position_set_signal;
sigc::signal<void,double,double> _resized_signal;
sigc::signal<void,gchar const*> _document_uri_set_signal;
sigc::signal<void> _redraw_requested_signal;
private:
sigc::connection _position_set_connection;
sigc::connection _resized_connection;
sigc::connection _redraw_requested_connection;
sigc::connection _message_changed_connection; // foreign
sigc::connection _document_uri_set_connection; // foreign
sigc::connection _document_resized_connection; // foreign
};
}}}
#endif // INKSCAPE_UI_VIEW_VIEW_H
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :