Main Page | Class List | Directories | File List | Class Members | File Members | Related Pages

ColorCircle Class Reference

#include <colorcircle.h>

List of all members.

Signals

void colorChanged (const rColor &)

Public Member Functions

 ColorCircle (QWidget *parent=0, const char *name=0, WFlags f=0)
 ~ColorCircle ()
void setColor (const rColor &)

Protected Member Functions

void drawContents (QPainter *)
void mouseReleaseEvent (QMouseEvent *)

Private Member Functions

void makeCircle ()
void makeTriangle (int)
double arcTan (double, double)
void calcVertices (int, int *, int *, int *, int *, int *, int *)
bool isInTriangle (int, int)
void calcSV (int, int, int *, int *)
void calcCoords (int *, int *)

Private Attributes

QWMatrix wm
QSize palSize
QSize frameSize
QPixmap cpm
QPixmap tpm
QPixmap bg
double innerRadius
double outerRadius
double center
int icenter
int irad
int orad
int currentHue
int currentSat
int currentVal
int currentAlpha
double circleWidth


Detailed Description

The basic selection of a color is achieved through the chromatic color circle. Clicking at a random position will turn the color triangle to point to the chosen hue, showing the possible shades of that hue. Clicking inside the triangle will select the corresponding saturation und value. Code for the painting of the triangle and some helper functions and macros are adopted from gtk+2.0 - 2.6.4 sources. Similar code should exist for Qt, but that lives in the ( non free ) Qt-Solutions download area at Trolltech.


Constructor & Destructor Documentation

ColorCircle::ColorCircle QWidget *  parent = 0,
const char *  name = 0,
WFlags  f = 0
 

The c'tor sets up the geometry for a fixed size of 160 pixels square. It sets up a default color with hue = 0, saturation = 255, and value = 255;

Todo:
It should - and could easily - be made resizable.

Here is the call graph for this function:

ColorCircle::~ColorCircle  ) 
 


Member Function Documentation

double ColorCircle::arcTan double  x,
double  y
[private]
 

Returns the arcus tangent for x, y in the range of 0 <= retVal < 2π. Is not much used though, as it turns out.

void ColorCircle::calcCoords int *  x,
int *  y
[private]
 

Calculate adequate coordinates for the currently seleced color. Sometimes the results are a bit unexpected, as can be seen when selecting a color in the triangle. This is later displayed - a circle is shown - using this function.

Here is the call graph for this function:

void ColorCircle::calcSV int  ix,
int  iy,
int *  is,
int *  iv
[private]
 

Calculate values for Saturation and Value based on coords in the triangle. Adopted from gtk.

Here is the call graph for this function:

void ColorCircle::calcVertices int  hue,
int *  hx,
int *  hy,
int *  sx,
int *  sy,
int *  vx,
int *  vy
[private]
 

Calculates the vertices of the triangle for a given hue.

void ColorCircle::colorChanged const rColor  )  [signal]
 

void ColorCircle::drawContents QPainter *  p  )  [protected]
 

Reimplemented to draw the two small circles whenever the widget needs updating. The triangle and the circle are already defined as background image.

Here is the call graph for this function:

bool ColorCircle::isInTriangle int  x,
int  y
[private]
 

Check if a given coord can be found inside the triangle.

Here is the call graph for this function:

void ColorCircle::makeCircle  )  [private]
 

Creates the chromatic circle on a grey background. The circle is rotated so that the color red ( hue = 0 ) is at the top.

Here is the call graph for this function:

void ColorCircle::makeTriangle int  hue  )  [private]
 

Draw the triangle with the correct shadings for the current hue. This code was adopted from gtk and adapted to fit in the general philosphy of the color dialog.

Here is the call graph for this function:

void ColorCircle::mouseReleaseEvent QMouseEvent *  e  )  [protected]
 

We check the mouseReleaseEvent, assuming something has been clicked. If the event took place in the circle, we adjust the current hue. In the triangle we adjust Saturation and Value.

Here is the call graph for this function:

void ColorCircle::setColor const rColor col  ) 
 

Sets the currently displayed rColor to col.

Here is the call graph for this function:


Member Data Documentation

QPixmap ColorCircle::bg [private]
 

double ColorCircle::center [private]
 

double ColorCircle::circleWidth [private]
 

QPixmap ColorCircle::cpm [private]
 

int ColorCircle::currentAlpha [private]
 

int ColorCircle::currentHue [private]
 

int ColorCircle::currentSat [private]
 

int ColorCircle::currentVal [private]
 

QSize ColorCircle::frameSize [private]
 

int ColorCircle::icenter [private]
 

double ColorCircle::innerRadius [private]
 

int ColorCircle::irad [private]
 

int ColorCircle::orad [private]
 

double ColorCircle::outerRadius [private]
 

QSize ColorCircle::palSize [private]
 

QPixmap ColorCircle::tpm [private]
 

QWMatrix ColorCircle::wm [private]
 


The documentation for this class was generated from the following files:
Go back to rwm - the window manager's - Home page.
created 13 Jun 2005 for colordlg $Revision:1.1$ by Rolf C. Rönnau using doxygen 1.4.2