class KRuler

A ruler widget. More...

Definition#include <kruler.h>
InheritsQFrame (qt) [public ]
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Types

Public Methods

Public Slots


Detailed Description

A ruler widget.

The vertical ruler looks similar to this:


    meters                       inches

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


There are tiny marks, little marks, medium marks, and big marks along the ruler.

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

For performance reasons, the public methods don't call QWidget::repaint(). (Slots do, see documentation below.) 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 QWidget::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 MetricStyle { Custom=0, Pixel, Inch, Millimetres, Centimetres, Metres }; }

MetricStyle

The types of units used.

 KRuler (QWidget *parent=0, const char *name=0)

KRuler

Constructs a horizontal ruler.

 KRuler (Orientation orient, QWidget *parent=0, const char *name=0, WFlags f=0)

KRuler

Constructs a ruler with orientation orient.

parent, name and f are passed to QFrame. The default look is a raised widget but may be changed with the inherited QFrame methods.

Parameters:
orientOrientation 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 (Orientation orient, int widgetWidth, QWidget *parent=0, const char *name=0, WFlags f=0)

KRuler

Constructs a ruler with orientation orient and initial width widgetWidth.

The width sets the fixed width of the widget. This is useful 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 and f are passed to QFrame.

Parameters:
orientOrientation 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 ()

~KRuler

Destructor.

void  setMinValue (int)

setMinValue

Set the minimal value of the ruler pointer (default is 0).

This method calls update() so that the widget is painted after leaving to the main event loop.

inline int  minValue ()

minValue

[const]

Retrieve the minimal value of the ruler pointer.

void  setMaxValue (int)

setMaxValue

Set the maximum value of the ruler pointer (default is 100).

This method calls update() so that the widget is painted after leaving to the main event loop.

inline int  maxValue ()

maxValue

[const]

returns the maximal value of the ruler pointer.

void  setRange (int min, int max)

setRange

Set minimum and maxmimum values of the ruler pointer.

This method calls update() so that the widget is painted after leaving to the main event loop.

void  setValue (int)

setValue

Set the value of the ruler pointer.

The value is indicated by painting the ruler pointer at the corresponding position. This method calls update() so that the widget is painted after leaving to the main event loop.

inline int  value ()

value

[const]

void  setTinyMarkDistance (int)

setTinyMarkDistance

Set distance between tiny marks.

This is mostly used in the English system (inches) with distance of 1.

inline int  tinyMarkDistance ()

tinyMarkDistance

[const]

Retrieve the distance between tiny marks.

void  setLittleMarkDistance (int)

setLittleMarkDistance

Set the distance between little marks.

The default value is 1 in the metric system and 2 in the English (inches) system.

inline int  littleMarkDistance ()

littleMarkDistance

[const]

Retrieve the distance between little marks.

void  setMediumMarkDistance (int)

setMediumMarkDistance

Set the distance between medium marks.

For English (inches) styles it defaults to twice the little mark distance. For metric styles it defaults to five times the little mark distance.

inline int  mediumMarkDistance ()

mediumMarkDistance

[const]

void  setBigMarkDistance (int)

setBigMarkDistance

Set distance between big marks.

For English (inches) or metric styles it is twice the medium mark distance.

inline int  bigMarkDistance ()

bigMarkDistance

[const]

Retrieve the distance between big marks.

void  setShowTinyMarks (bool)

setShowTinyMarks

Show/hide tiny marks.

bool  showTinyMarks ()

showTinyMarks

[const]

void  setShowLittleMarks (bool)

setShowLittleMarks

Show/hide little marks.

bool  showLittleMarks ()

showLittleMarks

[const]

void  setShowMediumMarks (bool)

setShowMediumMarks

Show/hide medium marks.

bool  showMediumMarks ()

showMediumMarks

[const]

void  setShowBigMarks (bool)

setShowBigMarks

Show/hide big marks.

bool  showBigMarks ()

showBigMarks

[const]

void  setShowEndMarks (bool)

setShowEndMarks

Show/hide end marks.

bool  showEndMarks ()

showEndMarks

[const]

void  setShowPointer (bool)

setShowPointer

Show/hide the pointer.

bool  showPointer ()

showPointer

[const]

void  setValuePerLittleMark (int)

setValuePerLittleMark

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 according to the the values set in the setXXMarkDistance(int) methods.

void  setValuePerMediumMark (int)

setValuePerMediumMark

Sets the value that is shown per medium mark.

For metric systems this is 5. Display of little marks is automatically disabled and big marks are updated according to the values set in the setBigMarkDistance() method.

void  setValuePerBigMark (int)

setValuePerBigMark

Sets the value that is shown per big mark.

For metric systems this is 1 Display of little and medium marks marks is disabled.

void  setShowEndLabel (bool)

setShowEndLabel

Show/hide number values of the end marks.

Default is false.

bool  showEndLabel ()

showEndLabel

[const]

void  setEndLabel (const QString&)

setEndLabel

Set the label this is drawn at the beginning of the visible part of the ruler.

QString  endLabel ()

endLabel

[const]

void  setRulerMetricStyle (KRuler::MetricStyle)

setRulerMetricStyle

Set up the necessary tasks for the provided styles.

A convenience method.

void  setPixelPerMark (double)

setPixelPerMark

Set the number of pixels between two base marks.

Calling this method stretches or shrinks your ruler.

For pixel display (metric_style) the value is 10.0 marks per pixel ;-) For English (inches) it is 9.0, and for centimetres ~2.835 -> 3.0 . If you want to magnify your part of display, you have to adjust the mark distance here. Notice: The double type is only supported to give the possibility of having some double 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  pixelPerMark ()

pixelPerMark

[const]

Retrieve the number of pixels between two base marks.

void  setLength (int)

setLength

sets the length of the ruler, i.e. the difference between the begin mark and the end mark of the ruler.

Same as (width() - offset())

when the length is not locked, it gets adjusted with the length of the widget.

int  length ()

length

[const]

void  setLengthFixed (bool fix)

setLengthFixed

locks the length of the ruler, i.e. the difference between the two end marks doesn't change when the widget is resized.

Parameters:
fixfixes the length, if true

bool  lengthFixed ()

lengthFixed

[const]

void  slideUp (int count = 1)

slideUp

Set the number of pixels by which the ruler may slide up or left. The number of pixels moved is realive to the previous position. The Method makes sense for updating a ruler, which is working with a scrollbar.

This doesn't affect the position of the ruler pointer. Only the visible part of the ruler is moved.

Parameters:
countNumber of pixel moving up or left relative to the previous position

void  slideDown (int count = 1)

slideDown

Set the number of pixels by which the ruler may slide down or right. The number of pixels moved is realive to the previous position. The Method makes sense for updating a ruler, which is working with a scrollbar.

This doesn't affect the position of the ruler pointer. Only the visible part of the ruler is moved.

Parameters:
countNumber of pixel moving up or left relative to the previous position

void  setOffset (int offset)

setOffset

Set ruler slide offset.

This is like slideup() or slidedown() with an absolute offset from the start of the ruler.

Parameters:
offsetNumber of pixel to move the ruler up or left from the beginning

inline int  offset ()

offset

[const]

Get the current ruler offset.

int  endOffset ()

endOffset

[const]

void  slotNewValue (int)

slotNewValue

[slot]

Sets the pointer to a new position.

The offset is NOT updated. QWidget::repaint() is called afterwards.

void  slotNewOffset (int)

slotNewOffset

[slot]

Sets the ruler marks to a new position.

The pointer is NOT updated. QWidget::repaint() is called afterwards.

void  slotEndOffset (int)

slotEndOffset

[slot]

void  drawContents (QPainter *)

drawContents

[protected: virtual]

Reimplemented from QFrame for internal purposes..