kdeui Library API Documentation

KRuler Class Reference

A ruler widget. A ruler widget. More...

#include <kruler.h>

Inheritance diagram for KRuler:

QFrame List of all members.

Public Types

enum  MetricStyle {
  Custom = 0, Pixel, Inch, Millimetres,
  Centimetres, Metres
}
 The types of units used. More...


Public Slots

void slotNewValue (int)
 Sets the pointer to a new position.

void slotNewOffset (int)
 Sets the ruler marks to a new position.

void slotEndOffset (int)

Public Member Functions

 KRuler (QWidget *parent=0, const char *name=0)
 Constructs a horizontal ruler.

 KRuler (Orientation orient, QWidget *parent=0, const char *name=0, WFlags f=0)
 Constructs a ruler with orientation orient.

 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.

 ~KRuler ()
 Destructor.

void setMinValue (int)
 Sets the minimal value of the ruler pointer (default is 0).

int minValue () const
 Returns the minimal value of the ruler pointer.

void setMaxValue (int)
 Sets the maximum value of the ruler pointer (default is 100).

int maxValue () const
 Returns the maximal value of the ruler pointer.

void setRange (int min, int max)
 Sets minimum and maximum values of the ruler pointer.

void setValue (int)
 Sets the value of the ruler pointer.

int value () const
void setTinyMarkDistance (int)
 Sets the distance between tiny marks.

int tinyMarkDistance () const
 Returns the distance between tiny marks.

void setLittleMarkDistance (int)
 Sets the distance between little marks.

int littleMarkDistance () const
 Returns the distance between little marks.

void setMediumMarkDistance (int)
 Sets the distance between medium marks.

int mediumMarkDistance () const
void setBigMarkDistance (int)
 Sets distance between big marks.

int bigMarkDistance () const
 Returns the distance between big marks.

void setShowTinyMarks (bool)
 Shows/hides tiny marks.

bool showTinyMarks () const
void setShowLittleMarks (bool)
 Shows/hides little marks.

bool showLittleMarks () const
void setShowMediumMarks (bool)
 Shows/hides medium marks.

bool showMediumMarks () const
void setShowBigMarks (bool)
 Shows/hides big marks.

bool showBigMarks () const
void setShowEndMarks (bool)
 Shows/hides end marks.

bool showEndMarks () const
void setShowPointer (bool)
 Shows/hides the pointer.

bool showPointer () const
void setValuePerLittleMark (int)
 This class or method is obsolete, it is provided for compatibility only. This method has no effect other than an update.

void setValuePerMediumMark (int)
 This class or method is obsolete, it is provided for compatibility only. This method has no effect other than an update.

void setValuePerBigMark (int)
 This class or method is obsolete, it is provided for compatibility only. This method has no effect other than an update.

void setShowEndLabel (bool)
 Show/hide number values of the end marks.

bool showEndLabel () const
void setEndLabel (const QString &)
 Sets the label this is drawn at the beginning of the visible part of the ruler to label.

QString endLabel () const
void setRulerMetricStyle (KRuler::MetricStyle)
 Sets up the necessary tasks for the provided styles.

void setPixelPerMark (double rate)
 Sets the number of pixels between two base marks.

double pixelPerMark () const
 Returns the number of pixels between two base marks.

void setLength (int)
 Sets the length of the ruler, i.e.

int length () const
void setLengthFixed (bool fix)
 Locks the length of the ruler, i.e.

bool lengthFixed () const
void slideUp (int count=1)
 Sets the number of pixels by which the ruler may slide up or left.

void slideDown (int count=1)
 Sets the number of pixels by which the ruler may slide down or right.

void setOffset (int offset)
 Sets the ruler slide offset.

int offset () const
 Returns the current ruler offset.

int endOffset () const

Protected Member Functions

virtual void drawContents (QPainter *)
virtual void virtual_hook (int id, void *data)

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.

Definition at line 146 of file kruler.cpp.

References KStdAccel::name().

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.

Definition at line 156 of file kruler.cpp.

References KStdAccel::name().

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.

Definition at line 170 of file kruler.cpp.

References KStdAccel::name().

KRuler::~KRuler  ) 
 

Destructor.

Definition at line 209 of file kruler.cpp.


Member Function Documentation

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.

Definition at line 215 of file kruler.cpp.

References QFrame::contentsRect(), QRangeControl::maxValue(), QRangeControl::minValue(), and QRangeControl::setRange().

int KRuler::minValue  )  const [inline]
 

Returns the minimal value of the ruler pointer.

Definition at line 490 of file kruler.h.

References QRangeControl::minValue().

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.

Definition at line 224 of file kruler.cpp.

References QFrame::contentsRect(), QRangeControl::maxValue(), QRangeControl::minValue(), and QRangeControl::setRange().

int KRuler::maxValue  )  const [inline]
 

Returns the maximal value of the ruler pointer.

Definition at line 494 of file kruler.h.

References QRangeControl::maxValue().

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.

Definition at line 233 of file kruler.cpp.

References QFrame::contentsRect(), QRangeControl::maxValue(), QRangeControl::minValue(), and QRangeControl::setRange().

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.

Definition at line 242 of file kruler.cpp.

References QFrame::contentsRect(), and QRangeControl::setValue().

void KRuler::setTinyMarkDistance int   ) 
 

Sets the distance between tiny marks.

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

Definition at line 249 of file kruler.cpp.

References QFrame::contentsRect().

Referenced by setRulerMetricStyle().

int KRuler::tinyMarkDistance  )  const [inline]
 

Returns the distance between tiny marks.

Definition at line 502 of file kruler.h.

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.

Definition at line 258 of file kruler.cpp.

References QFrame::contentsRect().

Referenced by setRulerMetricStyle().

int KRuler::littleMarkDistance  )  const [inline]
 

Returns the distance between little marks.

Definition at line 506 of file kruler.h.

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.

Definition at line 267 of file kruler.cpp.

References QFrame::contentsRect().

Referenced by setRulerMetricStyle().

void KRuler::setBigMarkDistance int   ) 
 

Sets distance between big marks.

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

Definition at line 276 of file kruler.cpp.

References QFrame::contentsRect().

Referenced by setRulerMetricStyle().

int KRuler::bigMarkDistance  )  const [inline]
 

Returns the distance between big marks.

Definition at line 514 of file kruler.h.

void KRuler::setShowTinyMarks bool   ) 
 

Shows/hides tiny marks.

Definition at line 285 of file kruler.cpp.

References QFrame::contentsRect().

Referenced by setRulerMetricStyle().

void KRuler::setShowLittleMarks bool   ) 
 

Shows/hides little marks.

Definition at line 300 of file kruler.cpp.

References QFrame::contentsRect().

Referenced by setRulerMetricStyle().

void KRuler::setShowMediumMarks bool   ) 
 

Shows/hides medium marks.

Definition at line 315 of file kruler.cpp.

References QFrame::contentsRect().

Referenced by setRulerMetricStyle().

void KRuler::setShowBigMarks bool   ) 
 

Shows/hides big marks.

Definition at line 330 of file kruler.cpp.

References QFrame::contentsRect().

Referenced by setRulerMetricStyle().

void KRuler::setShowEndMarks bool   ) 
 

Shows/hides end marks.

Definition at line 346 of file kruler.cpp.

References QFrame::contentsRect().

Referenced by setRulerMetricStyle().

void KRuler::setShowPointer bool   ) 
 

Shows/hides the pointer.

Definition at line 361 of file kruler.cpp.

References QFrame::contentsRect().

void KRuler::setValuePerLittleMark int   ) 
 

This class or method is obsolete, it is provided for compatibility only. This method has no effect other than an update.

Do not use.

Definition at line 377 of file kruler.cpp.

References QFrame::contentsRect().

void KRuler::setValuePerMediumMark int   ) 
 

This class or method is obsolete, it is provided for compatibility only. This method has no effect other than an update.

Do not use.

Definition at line 383 of file kruler.cpp.

References QFrame::contentsRect().

Referenced by setRulerMetricStyle().

void KRuler::setValuePerBigMark int   ) 
 

This class or method is obsolete, it is provided for compatibility only. This method has no effect other than an update.

Do not use.

Definition at line 389 of file kruler.cpp.

References QFrame::contentsRect().

Referenced by setRulerMetricStyle().

void KRuler::setShowEndLabel bool   ) 
 

Show/hide number values of the end marks.

Default is false.

Definition at line 395 of file kruler.cpp.

References QFrame::contentsRect().

void KRuler::setEndLabel const QString  ) 
 

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

Definition at line 412 of file kruler.cpp.

References QFrame::contentsRect(), KStdAccel::label(), QFont::setPointSize(), and QFontMetrics::width().

Referenced by setRulerMetricStyle().

void KRuler::setRulerMetricStyle KRuler::MetricStyle   ) 
 

Sets up the necessary tasks for the provided styles.

A convenience method.

Definition at line 432 of file kruler.cpp.

References QString::fromLatin1(), setBigMarkDistance(), setEndLabel(), setLittleMarkDistance(), setMediumMarkDistance(), setPixelPerMark(), setShowBigMarks(), setShowEndMarks(), setShowLittleMarks(), setShowMediumMarks(), setShowTinyMarks(), setTinyMarkDistance(), setValuePerBigMark(), and setValuePerMediumMark().

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

Definition at line 509 of file kruler.cpp.

References QFrame::contentsRect().

Referenced by setRulerMetricStyle().

double KRuler::pixelPerMark  )  const [inline]
 

Returns the number of pixels between two base marks.

Definition at line 518 of file kruler.h.

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.

Definition at line 517 of file kruler.cpp.

References QFrame::contentsRect().

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

Definition at line 543 of file kruler.cpp.

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

Definition at line 574 of file kruler.cpp.

References QFrame::contentsRect().

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

Definition at line 583 of file kruler.cpp.

References QFrame::contentsRect().

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

Definition at line 555 of file kruler.cpp.

References QFrame::contentsRect().

int KRuler::offset  )  const [inline]
 

Returns the current ruler offset.

Definition at line 522 of file kruler.h.

void KRuler::slotNewValue int   )  [slot]
 

Sets the pointer to a new position.

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

Definition at line 593 of file kruler.cpp.

References QRangeControl::setValue(), QRect::unite(), and QRangeControl::value().

void KRuler::slotNewOffset int   )  [slot]
 

Sets the ruler marks to a new position.

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

Definition at line 619 of file kruler.cpp.

References QFrame::contentsRect().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.4.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sun Feb 27 22:15:10 2005 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001