• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KDEUI

Public Types | Public Slots | Public Member Functions | Protected Member Functions | Properties | List of all members
KRuler Class Reference

#include <kruler.h>

Inherits QAbstractSlider.

Public Types

enum  MetricStyle {
  Custom =0, Pixel, Inch, Millimetres,
  Centimetres, Metres
}
 

Public Slots

void slotEndOffset (int)
 
void slotNewOffset (int)
 
void slotNewValue (int)
 

Public Member Functions

 KRuler (QWidget *parent=0)
 
 KRuler (Qt::Orientation orient, QWidget *parent=0, Qt::WindowFlags f=0)
 
 KRuler (Qt::Orientation orient, int widgetWidth, QWidget *parent=0, Qt::WindowFlags f=0)
 
 ~KRuler ()
 
int bigMarkDistance () const
 
QString endLabel () const
 
int endOffset () const
 
int length () const
 
bool lengthFixed () const
 
int littleMarkDistance () const
 
int maxValue () const
 
int mediumMarkDistance () const
 
int minValue () const
 
int offset () const
 
double pixelPerMark () const
 
void setBigMarkDistance (int)
 
void setEndLabel (const QString &)
 
void setFrameStyle (int)
 
void setLength (int)
 
void setLengthFixed (bool fix)
 
void setLittleMarkDistance (int)
 
void setMaxValue (int)
 
void setMediumMarkDistance (int)
 
void setMinValue (int)
 
void setOffset (int offset)
 
void setPixelPerMark (double rate)
 
void setRulerMetricStyle (KRuler::MetricStyle)
 
void setShowBigMarks (bool)
 
void setShowEndLabel (bool)
 
void setShowEndMarks (bool)
 
void setShowLittleMarks (bool)
 
void setShowMediumMarks (bool)
 
void setShowPointer (bool)
 
void setShowTinyMarks (bool)
 
void setTinyMarkDistance (int)
 
bool showBigMarks () const
 
bool showEndLabel () const
 
bool showEndMarks () const
 
bool showLittleMarks () const
 
bool showMediumMarks () const
 
bool showPointer () const
 
bool showTinyMarks () const
 
void slideDown (int count=1)
 
void slideUp (int count=1)
 
int tinyMarkDistance () const
 

Protected Member Functions

virtual void paintEvent (QPaintEvent *)
 

Properties

int bigMarkDistance
 
QString endLabel
 
int endOffset
 
int length
 
bool lengthFixed
 
int littleMarkDistance
 
int mediumMarkDistance
 
int offset
 
double pixelPerMark
 
bool showBigMarks
 
bool showEndLabel
 
bool showLittleMarks
 
bool showMediumMarks
 
bool showPointer
 
bool showTinyMarks
 
int tinyMarkDistance
 

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.

kruler.png
KDE Ruler Widget

A ruler widget.

Author
Jörg Habenicht

Definition at line 73 of file kruler.h.

Member Enumeration Documentation

enum KRuler::MetricStyle

The types of units used.

Enumerator
Custom 
Pixel 
Inch 
Millimetres 
Centimetres 
Metres 

Definition at line 108 of file kruler.h.

Constructor & Destructor Documentation

KRuler::KRuler ( QWidget *  parent = 0)
explicit

The style (or look) of the ruler.

Constructs a horizontal ruler.

Definition at line 113 of file kruler.cpp.

KRuler::KRuler ( Qt::Orientation  orient,
QWidget *  parent = 0,
Qt::WindowFlags  f = 0 
)
explicit

Constructs a ruler with orientation orient.

parent 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.
fWill be handed over to QFrame.

Definition at line 125 of file kruler.cpp.

KRuler::KRuler ( Qt::Orientation  orient,
int  widgetWidth,
QWidget *  parent = 0,
Qt::WindowFlags  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 and f are passed to QFrame.

Parameters
orientOrientation of the ruler.
widgetWidthFixed width of the widget.
parentWill be handed over to QFrame.
fWill be handed over to QFrame.

Definition at line 142 of file kruler.cpp.

KRuler::~KRuler ( )

Destructor.

Definition at line 185 of file kruler.cpp.

Member Function Documentation

int KRuler::bigMarkDistance ( ) const

Returns the distance between big marks.

QString KRuler::endLabel ( ) const
int KRuler::endOffset ( ) const
int KRuler::length ( ) const
bool KRuler::lengthFixed ( ) const
int KRuler::littleMarkDistance ( ) const

Returns the distance between little marks.

int KRuler::maxValue ( ) const

Returns the maximal value of the ruler pointer.

Definition at line 214 of file kruler.cpp.

int KRuler::mediumMarkDistance ( ) const
int KRuler::minValue ( ) const

Returns the minimal value of the ruler pointer.

Definition at line 200 of file kruler.cpp.

int KRuler::offset ( ) const

Returns the current ruler offset.

void KRuler::paintEvent ( QPaintEvent *  )
protectedvirtual

Definition at line 629 of file kruler.cpp.

double KRuler::pixelPerMark ( ) const

Returns the number of pixels between two base marks.

void KRuler::setBigMarkDistance ( int  dist)

Sets distance between big marks.

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

Definition at line 258 of file kruler.cpp.

void KRuler::setEndLabel ( const QString &  label)

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

Definition at line 388 of file kruler.cpp.

void KRuler::setFrameStyle ( int  )

Definition at line 363 of file kruler.cpp.

void KRuler::setLength ( int  length)

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 496 of file kruler.cpp.

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
fixfixes the length, if true

Definition at line 522 of file kruler.cpp.

void KRuler::setLittleMarkDistance ( int  dist)

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 232 of file kruler.cpp.

void KRuler::setMaxValue ( int  value)

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 206 of file kruler.cpp.

void KRuler::setMediumMarkDistance ( int  dist)

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 245 of file kruler.cpp.

void KRuler::setMinValue ( int  value)

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 192 of file kruler.cpp.

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
offsetNumber of pixel to move the ruler up or left from the beginning

Definition at line 534 of file kruler.cpp.

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 485 of file kruler.cpp.

void KRuler::setRulerMetricStyle ( KRuler::MetricStyle  style)

Sets up the necessary tasks for the provided styles.

A convenience method.

Definition at line 408 of file kruler.cpp.

void KRuler::setShowBigMarks ( bool  show)

Shows/hides big marks.

Definition at line 316 of file kruler.cpp.

void KRuler::setShowEndLabel ( bool  show)

Show/hide number values of the little marks.

Default is false. Show/hide number values of the medium marks.

Default is false. Show/hide number values of the big marks.

Default is false. Show/hide number values of the end marks.

Default is false.

Definition at line 371 of file kruler.cpp.

void KRuler::setShowEndMarks ( bool  show)

Shows/hides end marks.

Definition at line 332 of file kruler.cpp.

void KRuler::setShowLittleMarks ( bool  show)

Shows/hides little marks.

Definition at line 286 of file kruler.cpp.

void KRuler::setShowMediumMarks ( bool  show)

Shows/hides medium marks.

Definition at line 301 of file kruler.cpp.

void KRuler::setShowPointer ( bool  show)

Shows/hides the pointer.

Definition at line 347 of file kruler.cpp.

void KRuler::setShowTinyMarks ( bool  show)

Shows/hides tiny marks.

Definition at line 271 of file kruler.cpp.

void KRuler::setTinyMarkDistance ( int  dist)

Sets the distance between tiny marks.

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

Definition at line 219 of file kruler.cpp.

bool KRuler::showBigMarks ( ) const
bool KRuler::showEndLabel ( ) const
bool KRuler::showEndMarks ( ) const

Definition at line 341 of file kruler.cpp.

bool KRuler::showLittleMarks ( ) const
bool KRuler::showMediumMarks ( ) const
bool KRuler::showPointer ( ) const
bool KRuler::showTinyMarks ( ) const
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
countNumber of pixel moving up or left relative to the previous position

Definition at line 566 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
countNumber of pixel moving up or left relative to the previous position

Definition at line 557 of file kruler.cpp.

void KRuler::slotEndOffset ( int  offset)
slot

Definition at line 613 of file kruler.cpp.

void KRuler::slotNewOffset ( int  _offset)
slot

Sets the ruler marks to a new position.

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

Definition at line 602 of file kruler.cpp.

void KRuler::slotNewValue ( int  _value)
slot

Sets the pointer to a new position.

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

Definition at line 576 of file kruler.cpp.

int KRuler::tinyMarkDistance ( ) const

Returns the distance between tiny marks.

Property Documentation

int KRuler::bigMarkDistance
readwrite

Definition at line 85 of file kruler.h.

QString KRuler::endLabel
readwrite

Definition at line 88 of file kruler.h.

int KRuler::endOffset
read

Definition at line 92 of file kruler.h.

int KRuler::length
readwrite

Definition at line 90 of file kruler.h.

bool KRuler::lengthFixed
readwrite

Definition at line 87 of file kruler.h.

int KRuler::littleMarkDistance
readwrite

Definition at line 83 of file kruler.h.

int KRuler::mediumMarkDistance
readwrite

Definition at line 84 of file kruler.h.

int KRuler::offset
read

Definition at line 91 of file kruler.h.

double KRuler::pixelPerMark
readwrite

Definition at line 86 of file kruler.h.

bool KRuler::showBigMarks
readwrite

Definition at line 79 of file kruler.h.

bool KRuler::showEndLabel
readwrite

Definition at line 81 of file kruler.h.

bool KRuler::showLittleMarks
readwrite

Definition at line 77 of file kruler.h.

bool KRuler::showMediumMarks
readwrite

Definition at line 78 of file kruler.h.

bool KRuler::showPointer
readwrite

Definition at line 80 of file kruler.h.

bool KRuler::showTinyMarks
readwrite

Definition at line 76 of file kruler.h.

int KRuler::tinyMarkDistance
readwrite

Definition at line 82 of file kruler.h.


The documentation for this class was generated from the following files:
  • kruler.h
  • kruler.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:49:18 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal