class KRuler

A ruler widget. More...

Definition#include <kruler.h>
InheritsQFrame
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Types

Public Methods

Public Slots

Protected Methods


Detailed Description

The vertical ruler looks similar to this:


    meters                       inches

    ------   <----end mark-----> ------
        --                            -
        --   <---little mark--->     --
        --                            -
        --                          ---
       ---   <---medium mark          -
        --                           --
        --        tiny mark---->      -
        --                         ----
        --                            -
      ----   <-----big mark          --
        --                            -
      |>--   <--ruler pointer-->   |>--


To receive mouse clicks or mouse moves, the class has to be overloaded.

For performance reasons, the public methods doesn't call repaint(), than update except the public slot methods as described. so all the changed settings will be painted once after leaving to the main event loop. For performance painting the slot methods should be used, they do a fast repaint(..) call after changing the values. For setting multiple values like minValue(), maxValue(), offset() etc. using the public methods is recommended, so the widget will be painted only once when entering the main event loop.

enum direction {horizontal, vertical }

direction of the ruler. Has to be defined when constructing the widget. see KRuler();

enum metric_style {custom=0, pixel, inch, millimetres, centimetres, metres }

enum paint_style {flat, raised, sunken }

 KRuler (direction dir, QWidget *parent=0, const char *name=0, WFlags f=0, bool allowLines=TRUE)

Constructor, requires the direction to paint to. parent, name, f and allowLines are handed through to QFrame. The default look is a raised widget, but may be changed with the QFrame methods.

Parameters:
dirdirection of the ruler
parentwill be handed over to QFrame
namewill be handed over to QFrame
fwill be handed over to QFrame
allowLineswill be handed over to QFrame

 KRuler (direction dir, int widgetWidth, QWidget *parent=0, const char *name=0, WFlags f=0, bool allowLines=TRUE)

Constructor, requires the direction to paint to and an initial width. The width sets the fixed width of the widget. This is usefull, if you want to draw the ruler bigger or smaller than the default size. Note: The size of the marks doesn't change. parent, name, f and allowLines are handed through to QFrame

Parameters:
dirdirection of the ruler
widgetWidthfixed width of the widget
parentwill be handed over to QFrame
namewill be handed over to QFrame
fwill be handed over to QFrame
allowLineswill be handed over to QFrame

KRuler ()

Destructor.

void  setMinValue (int)

minimum value reachable, default: 0 calls update(), so the widget is painted after leaving the main event loop

inline int  getMinValue ()

[const]

returns the minimal value of the ruler pointer

void  setMaxValue (int)

maximum value of the ruler pointer, default: 100 . calls update(), so the widget is painted after leaving the main event loop

inline int  getMaxValue ()

[const]

returns the maximal value of the ruler pointer.

void  setRange (int min, int max)

sets minimal and maxmal values of the ruler pointer. calls update(), so the widget is painted after leaving to the main event loop.

void  setValue (int)

set the value of the ruler pointer, the value is shown with ruler pointer painted. calls update(), the widget is painted after leaving to the main event loop.

inline int  getValue ()

[const]

void  setTinyMarkDistance (int)

distance of tiny marks. mostly used in inch system with distance of 1.

inline int  getTinyMarkDistance ()

[const]

void  setLittleMarkDistance (int)

set the paint distance of the little marks. value is 1 in metric system and 2 in inch system.

inline int  getLittleMarkDistance ()

[const]

void  setMediumMarkDistance (int)

set the paint distance of the medium marks. for inch styles it is twice the little mark distance, for metric styles it is five times. default: 5

inline int  getMediumMarkDistance ()

[const]

void  setBigMarkDistance (int)

set the paint distance of the big marks. for inch or metric styles it is twice the medium mark distance. default: 10

inline int  getBigMarkDistance ()

[const]

void  showTinyMarks (bool)

void  showLittleMarks (bool)

void  showMediumMarks (bool)

void  showBigMarks (bool)

void  showEndMarks (bool)

void  setValuePerLittleMark (int)

sets the value that is shown per little mark. for metric systems this is 1 per mark. Note: If you set the value for little marks the values for medium and big marks are updated accordingly in respect to the values set in "setXXMarkDistance(int)"

void  setValuePerMediumMark (int)

sets the value that is shown per little mark. for metric systems this is 5 display of little marks is disabled, big marks are updated

void  setValuePerBigMark (int)

sets the value that is shown per little mark. for metric systems this is 1 display of little and medium marks marks is disabled,

void  showLittleMarkLabel (bool)

paint number values of the little marks. default: false

void  showMediumMarkLabel (bool)

paint number values of the medium marks. default: false

void  showBigMarkLabel (bool)

paint number values of the big marks. default: true

void  showEndLabel (bool)

paint number values of the little marks. default: true

void  setEndLabel (const char *)

label which is drawn at the beginning of the visible part of the ruler

void  setRulerStyle (metric_style)

convenience method: sets up the necessary tasks for the provided styles

inline metric_style  getMetricRulerStyle ()

[const]

void  setRulerStyle (paint_style)

currently not implemented

inline paint_style  getPaintRulerStyle ()

[const]

currently not implemented

void  setTickStyle (paint_style)

currently not implemented

inline paint_style  getTickStyle ()

[const]

currently not implemented

void  setPixelPerMark (double)

Set the amount of pixel between two base marks. Calling this method your are able to stretch or shrink your ruler.

For pixel display the value is 10.0 marks per pixel ;-) for inches it is 9.0, and for centimetres ~2,835 -> 3.0 . If you like to magnify your part of display, you have to adjust HERE your markdistance. Notice: the floatingpoint type is only supported to give the possibility of having some floatingpoint values. It should be used with care, using values below 10.0 shows visible jumps of markpositions (e.g. 2.345). Using whole numbers is highly recommended. To use int values use setPixelPerMark((int)your_int_value); default: 1 mark per 10 pixels

inline double  getPixelPerMark ()

[const]

void  slideup (int count = 1)

the ruler may slide up and down "count" pixels this doesn't affect the position of the ruler pointer, only the visual part of the ruler is moved

void  slidedown (int count = 1)

void  setOffset (int)

set ruler slide to "offset" from beginning. like "slideup" or "slidedown" with an absolute offset

inline int  getOffset ()

[const]

void  slotNewValue (int)

[slot]

sets the pointer to a new position. the offset is NOT updated. repaint() is called afterwards

void  slotNewOffset (int)

[slot]

sets the ruler marks to a new position. the pointer is NOT updated. repaint() is called afterwards

void  drawContents (QPainter *)

[protected virtual]