PageObject Class Reference

[libkorigin Index] [libkorigin Heirarchy]


Something that can be on a page More...

#include </home/mh/korigin/korigin/doc/tmp/pageobject.h>

Inherits: QObject

Public Members

Protected Members

Signals


Detailed Description

Something that can be on a page.

A PageObject is an object (a QObject, to be precise) that is on a page. (Thus the name.) Examples for a PageObject are Plots or (yet to be implemented) Arrows and Texts.

The PageObject class defines the interface of all objects that can be on a page, plus it defines some common properties, e.g. the area an object covers on the page.


PageObject()

Construct a page object. Set all values to zero.

~PageObject()

Destruct the page object. This deletes the tree item.

virtual QObject* object()

The PageObject´s QObject. Usually, this will just return a "this" pointer, and this is the default implementation. This is unlikely to change.

virtual QWidget* widget()

The PageObject´s QWidget. Every PageObject must have a QWidget in order to paint itself.

However, not every PageObject *is* a QWidget. A Plot, for example, can *not* be a QWidget, because QWidgets cannot be constructed before the QApplication has started. But the Plot prototypes are constructed when they register themself to the Plots() list, before main(). Thus, I´ve separated the object from the widget. See the Plot implementation for the details.

PageObjects that *are* QWidgets may of course return "this" as in object().

See Also:
PageObject::Plot

virtual void paint(QPainter*)

Paint yourself on a QPainter. Every PageObject must be able to paint itself on a given QPainter. This may be the page window as well as a printer.

virtual void mousePressEvent(QMouseEvent*)

A mouse press event in the PageObject. When a mouse button is pressed in a page, the page checks if there is a PageObject at the click position, and if there is, passes on the QMouseEvent (after a transformation to the widget´s coordiates).

virtual TreeItem* treeitem()

Tree entry for the PageObject. Since PageObjects show up in the tree list, they must provide a TreeItem entry.

When first invoked, the default implementation creates a TreeItem and sets the pixmap to icon() and the text to description(). This tree item is then returned. When you don´t like this, you can redefine treeitem() or you can change the tree item in your constructor:

treeitem()->setPixmap(myPixmap); treeitem()->setText("Hello World");

virtual void activate()

Called when the PageObject is about to become "active". Some PageObjects, like Plots, have an activePlot pointer which points to the "active" Plot. This is used to update the main menu "Plot" entry.

The default implementation of this function just does nothing. If your PageObject subclass has something like an activePlot, you will have to reimplement it. If it doesn´t, just leave this implementation.

See Also:
deactivate

virtual void deactivate()

Called when the PageObject is about to become "inactive". See activate() for detailed description.

See Also:
activate

virtual QPixmap* icon()

Icon for the PageObject. Every PageObject must provide one or two icon(s). Depending on the type of the PageObject, you might want separate icons for the active object and for the inactive objects (Plots for example).

See Also:
changedTreeItem

virtual const char* description()

Gives a short description of the PageObject. Every PageObject must provide a short description of itself.

virtual bool store(QFile&)

Store the PageObject to an already open QFile. Every PageObject must be able to store itself to a file, as well as to restore itself from a QFile.

The rules for storing/restoring are the following: Your PageObject reads from the already opened QFile until it hits a selfdefined end mark. You must make sure that the complete entry of your PageObject is read, since the QFile might contain multiple objects. When you store a PageObject, you must make sure that you set a unique end mark that your restore() function recognizes.

When Korigin writes objects to a file, it first writes the class name, className(), to the file and then invokes the class´s store() function. Then it writes the next object´s className(), then invokes store() etc. Now when it comes to read a file, Korigin reads the first line, interprets it as the class name, instantiates the corresponding class and lets the new instance restore() itself from the file. Then it reads the next line and again interprets it as a class name... You see, if your restore() function stops reading at the right place, everything gets messed up. So be careful!

See Also:
restore

virtual bool restore(QFile&)

Store the PageObject to an already open QFile. Every PageObject must be able to store itself to a file, as well as to restore itself from a QFile.

See store for a detailed description of store/restore mechanism.

See Also:
store

Page* page()

Returns the page the plot is on. This is already implemented for you.

See Also:
setPage

void setPage(Page* p)

Set the page the plot is on. This is already implemented for you.

See Also:
page

void position(float& x, float& y)

Get the PageObject´s position on the page. This is already implemented for you.

See Also:
setPosition

void setPosition(float x, float y)

Set the PageObject´s position on the page. This is already implemented for you.

See Also:
position

QRect pixel_area()

Return the rectangle the PageObject occupies, in screen pixels. This returns the area of the PageObject in real, screen pixels, relative to the Page widget. This is needed when checking whether a mouse click was in a PageObject or not. (Mouse positions are in screen pixels, of course.) The physical area depends on the size of the Page window.

There is also a virtual page resolution, independent of the Page window size.

See Also:
virtual_area

QRect virtual_area()

Return the rectangle the PageObject occupies, in virtual units. These virtual units do not depend on the size of the Page window, as the physical area, pixel_area(), does. The virtual size is determinated by the page´s paper size (A4, Legal etc.), and the assumed printer resolution. (Currently fixed to 300 dpi.)

See Also:
pixel_area

TreeItem* the_treeitem

The PageObject´s tree item. Usually, you won´t have to touch this directly. Specifically, you shouldn´t delete it!

void changedTreeItem()

Emitted when the page object changed its tree item. For instance, when the icon is toggled from active to inactive or vice versa. It is your concrete PageObject subclass which must emit this signal.

This signal is connected to the tree view via the PageObject´s page.


  • Author: Patrick Schemitz
  • Documentation generated by mh@jeff_clever on Thu Feb 5 14:15:25 MET 1998
Kdoc