Main Page   Modules   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   Related Pages  

KRuler Class Reference

A ruler widget. More...

#include <kruler.h>

List of all members.

Public Types

enum  MetricStyle

Public Slots

void slotNewValue (int)
void slotNewOffset (int)

Public Methods

 KRuler (QWidget *parent=0, const char *name=0)
 KRuler (Orientation orient, QWidget *parent=0, const char *name=0, WFlags f=0)
 KRuler (Orientation orient, int widgetWidth, QWidget *parent=0, const char *name=0, WFlags f=0)
 ~KRuler ()
void setMinValue (int)
int minValue () const
void setMaxValue (int)
int maxValue () const
void setRange (int min, int max)
void setValue (int)
void setTinyMarkDistance (int)
int tinyMarkDistance () const
void setLittleMarkDistance (int)
int littleMarkDistance () const
void setMediumMarkDistance (int)
void setBigMarkDistance (int)
int bigMarkDistance () const
void setShowTinyMarks (bool)
void setShowLittleMarks (bool)
void setShowMediumMarks (bool)
void setShowBigMarks (bool)
void setShowEndMarks (bool)
void setShowPointer (bool)
void setValuePerLittleMark (int)
void setValuePerMediumMark (int)
void setValuePerBigMark (int)
void setShowEndLabel (bool)
void setEndLabel (const QString &)
void setRulerMetricStyle (KRuler::MetricStyle)
void setPixelPerMark (double rate)
double pixelPerMark () const
void setLength (int)
void setLengthFixed (bool fix)
void slideUp (int count=1)
void slideDown (int count=1)
void setOffset (int offset)
int offset () const

Protected Methods

virtual void drawContents (QPainter *)


Detailed Description

A ruler widget.

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.

Author:
Jörg Habenicht

Definition at line 70 of file kruler.h.


Member Enumeration Documentation

enum KRuler::MetricStyle
 

The types of units used.

Definition at line 103 of file kruler.h.


Constructor & Destructor Documentation

KRuler::KRuler QWidget *    parent = 0,
const char *    name = 0
 

Constructs a horizontal ruler.

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

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:
orient  Orientation of the ruler.
parent  Will be handed over to QFrame.
name  Will be handed over to QFrame.
f  Will be handed over to QFrame.
allowLines  Will be handed over to QFrame.

KRuler::KRuler Orientation    orient,
int    widgetWidth,
QWidget *    parent = 0,
const char *    name = 0,
WFlags    f = 0
 

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:
orient  Orientation of the ruler.
widgetWidth  Fixed width of the widget.
parent  Will be handed over to QFrame.
name  Will be handed over to QFrame.
f  Will be handed over to QFrame.
allowLines  Will be handed over to QFrame.

KRuler::~KRuler  
 

Destructor.


Member Function Documentation

int KRuler::bigMarkDistance   [inline]
 

Returns the distance between big marks.

Definition at line 514 of file kruler.h.

virtual void KRuler::drawContents QPainter *    [protected, virtual]
 

@reimplemented

int KRuler::littleMarkDistance   [inline]
 

Returns the distance between little marks.

Definition at line 506 of file kruler.h.

int KRuler::maxValue   [inline]
 

Returns the maximal value of the ruler pointer.

Definition at line 494 of file kruler.h.

int KRuler::minValue   [inline]
 

Returns the minimal value of the ruler pointer.

Definition at line 490 of file kruler.h.

int KRuler::offset   [inline]
 

Returns the current ruler offset.

Definition at line 522 of file kruler.h.

double KRuler::pixelPerMark   [inline]
 

Returns the number of pixels between two base marks.

Definition at line 518 of file kruler.h.

void KRuler::setBigMarkDistance int   
 

Sets distance between big marks.

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

void KRuler::setEndLabel const QString &   
 

Sets the label this is drawn at the beginning of the visible part of the ruler to label

void KRuler::setLength int   
 

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.

void KRuler::setLengthFixed bool    fix
 

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

Parameters:
fix  fixes the length, if true

void KRuler::setLittleMarkDistance int   
 

Sets the distance between little marks.

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

void KRuler::setMaxValue int   
 

Sets 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.

void KRuler::setMediumMarkDistance int   
 

Sets 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.

void KRuler::setMinValue int   
 

Sets 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.

void KRuler::setOffset int    offset
 

Sets the ruler slide offset.

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

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

void KRuler::setPixelPerMark double    rate
 

Sets the number of pixels between two base marks.

Calling this method stretches or shrinks your ruler.

For pixel display (MetricStyle) 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

void KRuler::setRange int    min,
int    max
 

Sets minimum and maximum values of the ruler pointer.

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

void KRuler::setRulerMetricStyle KRuler::MetricStyle   
 

Sets up the necessary tasks for the provided styles.

A convenience method.

void KRuler::setShowBigMarks bool   
 

Shows/hides big marks.

void KRuler::setShowEndLabel bool   
 

Show/hide number values of the end marks.

Default is false.

void KRuler::setShowEndMarks bool   
 

Shows/hides end marks.

void KRuler::setShowLittleMarks bool   
 

Shows/hides little marks.

void KRuler::setShowMediumMarks bool   
 

Shows/hides medium marks.

void KRuler::setShowPointer bool   
 

Shows/hides the pointer.

void KRuler::setShowTinyMarks bool   
 

Shows/hides tiny marks.

void KRuler::setTinyMarkDistance int   
 

Sets the distance between tiny marks.

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

void KRuler::setValue int   
 

Sets 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.

void KRuler::setValuePerBigMark int   
 

Deprecated:
This method has no effect other than an update. Do not use.

void KRuler::setValuePerLittleMark int   
 

Deprecated:
This method has no effect other than an update. Do not use.

void KRuler::setValuePerMediumMark int   
 

Deprecated:
This method has no effect other than an update. Do not use.

void KRuler::slideDown int    count = 1
 

Sets 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:
count  Number of pixel moving up or left relative to the previous position

void KRuler::slideUp int    count = 1
 

Sets 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:
count  Number of pixel moving up or left relative to the previous position

void KRuler::slotNewOffset int    [slot]
 

Sets the ruler marks to a new position.

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

void KRuler::slotNewValue int    [slot]
 

Sets the pointer to a new position.

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

int KRuler::tinyMarkDistance   [inline]
 

Returns the distance between tiny marks.

Definition at line 502 of file kruler.h.


The documentation for this class was generated from the following file:
Generated on Wed Aug 13 23:30:22 2003 for kdelibs by doxygen1.2.18