kstars
InfoBoxes Class Reference
Infoboxes manages the three infobox objects which are drawn on the Skymap. More...
#include <infoboxes.h>
Public Slots | |
void | checkBorders (bool resetToDefault=true) |
bool | focusCoordChanged (const SkyPoint *p) |
bool | focusObjChanged (const QString &n) |
bool | geoChanged (const GeoLocation *geo) |
void | setVisible (bool t) |
void | showFocusBox (bool t) |
void | showGeoBox (bool t) |
void | showTimeBox (bool t) |
bool | timeChanged (const KStarsDateTime &ut, const KStarsDateTime <, dms *lst) |
Public Member Functions | |
bool | dragBox (QMouseEvent *e) |
void | drawBoxes (QPainter &p, QColor FGColor=QColor("white"), QColor grabColor=QColor("red"), QColor BGColor=QColor("black"), unsigned int BGMode=0) |
bool | fixCollisions (InfoBox *target) |
InfoBox * | focusBox () |
InfoBox * | geoBox () |
bool | grabBox (QMouseEvent *e) |
int | height () const |
InfoBoxes (int w, int h, QPoint tp, bool tshade, QPoint gp, bool gshade, QPoint fp, bool fshade, QColor colorText=QColor("white"), QColor colorGrab=QColor("red"), QColor colorBG=QColor("black")) | |
InfoBoxes (int w, int h, int tx=0, int ty=0, bool tshade=false, int gx=0, int gy=600, bool gshade=false, int fx=600, int fy=0, bool fshade=false, QColor colorText=QColor("white"), QColor colorGrab=QColor("red"), QColor colorBG=QColor("black")) | |
bool | isVisible () |
void | resize (int w, int h) |
bool | shadeBox (QMouseEvent *e) |
InfoBox * | timeBox () |
bool | unGrabBox () |
int | width () const |
~InfoBoxes () |
Detailed Description
Infoboxes manages the three infobox objects which are drawn on the Skymap.Each Infobox is a member variable in Infoboxes. Infoboxes handles user interactions with the boxes, and makes sure they do not overlap each other or move outside the bounds of the SkyMap. Infoboxes encapsulates and manages the three Infobox objects
- Version:
- 1.0
Definition at line 46 of file infoboxes.h.
Constructor & Destructor Documentation
InfoBoxes::InfoBoxes | ( | int | w, | |
int | h, | |||
int | tx = 0 , |
|||
int | ty = 0 , |
|||
bool | tshade = false , |
|||
int | gx = 0 , |
|||
int | gy = 600 , |
|||
bool | gshade = false , |
|||
int | fx = 600 , |
|||
int | fy = 0 , |
|||
bool | fshade = false , |
|||
QColor | colorText = QColor("white") , |
|||
QColor | colorGrab = QColor("red") , |
|||
QColor | colorBG = QColor("black") | |||
) |
Constructor.
Create three infoboxes and place them in the skymap.
- Parameters:
-
w The width of the region in which the boxes can be drawn (typically the width of the SkyMap) h The height of the region in which the boxes can be drawn (typically the height of the SkyMap) tx the x-position of the Time infobox ty the y-position of the Time infobox tshade if TRUE, apply text shading to the Time infobox gx the x-position of the Geographic infobox gy the y-position of the Geographic infobox gshade if TRUE, apply text shading to the Geographic infobox fx the x-position of the Focus-object infobox fy the y-position of the Focus-object infobox fshade if TRUE, apply text shading to the Focus-object infobox colorText The foreground color for infoboxes colorGrab The foreground color for infoboxes, while they are "grabbed" by the user colorBG The background color for infoboxes
- Todo:
- Use Qt::white as default color instead of QColor("white"), for default values of colorText, colorGrab and colorBG, since that's considerably faster.
Definition at line 61 of file infoboxes.cpp.
InfoBoxes::InfoBoxes | ( | int | w, | |
int | h, | |||
QPoint | tp, | |||
bool | tshade, | |||
QPoint | gp, | |||
bool | gshade, | |||
QPoint | fp, | |||
bool | fshade, | |||
QColor | colorText = QColor("white") , |
|||
QColor | colorGrab = QColor("red") , |
|||
QColor | colorBG = QColor("black") | |||
) |
Constructor.
Create three infoboxes and place them in the skymap. Differs from the above function only in the types of its arguments.
- Parameters:
-
w The width of the region in which the boxes can be drawn (typically the width of the SkyMap) h The height of the region in which the boxes can be drawn (typically the height of the SkyMap) tp the position of the Time infobox tshade if TRUE, apply text shading to the Time infobox gp the position of the Geographic infobox gshade if TRUE, apply text shading to the Geographic infobox fp the position of the Focus-object infobox fshade if TRUE, apply text shading to the Focus-object infobox colorText The foreground color for infoboxes colorGrab The foreground color for infoboxes, while they are "grabbed" by the user colorBG The background color for infoboxes
Definition at line 29 of file infoboxes.cpp.
InfoBoxes::~InfoBoxes | ( | ) |
Member Function Documentation
void InfoBoxes::checkBorders | ( | bool | resetToDefault = true |
) | [slot] |
Check if boxes are anchored with bottom or right border.
- Parameters:
-
resetToDefault reset all borders of boxes to false before checking borders.
Definition at line 418 of file infoboxes.cpp.
bool InfoBoxes::dragBox | ( | QMouseEvent * | e | ) |
Move the Grabbed box around by keeping the relative position of the mouse cursor to the box position equal to GrabPos.
(this is called by SkyMap::mouseMoveEvent() ). Once the box has been moved, we call fixCollisions() to make sure the boxes don't overlap or exceed the SkyMap boundaries.
- Parameters:
-
e The mouse event which contains the new mouse cursor position
- Returns:
- false if no box is grabbed; otherwise, moves the grabbed box and returns true.
Definition at line 160 of file infoboxes.cpp.
void InfoBoxes::drawBoxes | ( | QPainter & | p, | |
QColor | FGColor = QColor("white") , |
|||
QColor | grabColor = QColor("red") , |
|||
QColor | BGColor = QColor("black") , |
|||
unsigned int | BGMode = 0 | |||
) |
Draw the boxes on a Qpainter object (representing the SkyMap).
- Parameters:
-
p The QPainter on which to draw the boxes. FGColor The foreground color (Pen color) to use when drawing boxes. grabColor The foreground color to use if the box is "grabbed" by the user. BGColor The background color (brush color) to use BGMode,: 0=no BG fill; 1=transparent BG fill; 2=Opaque BG fill.
Definition at line 96 of file infoboxes.cpp.
bool InfoBoxes::fixCollisions | ( | InfoBox * | target | ) |
Make sure the target Infobox lies within the SkyMap boundaries, and that it does not overlap with the other two Infoboxes.
If an overlap is detected, the target box does a test-displacement each direction until there is no overlap (or the SkyMap boundary is reached). The target box is then moved in the direction that required the smallest displacement to remove the overlap.
- Parameters:
-
target the infobox which should be tested for collisions.
- Returns:
- false if the box collisions could not be resolved; otherwise, returns true.
Definition at line 214 of file infoboxes.cpp.
InfoBox* InfoBoxes::focusBox | ( | ) | [inline] |
bool InfoBoxes::focusCoordChanged | ( | const SkyPoint * | p | ) | [slot] |
Update the FocusBox coordinates strings according to the argument.
- Parameters:
-
p the SkyPoint object from which we get the coordinates.
- Returns:
- true if values have changed
Definition at line 401 of file infoboxes.cpp.
bool InfoBoxes::focusObjChanged | ( | const QString & | n | ) | [slot] |
Update the FocusBox name string according to the argument.
- Parameters:
-
n The object name
- Returns:
- true if values have changed
Definition at line 390 of file infoboxes.cpp.
InfoBox* InfoBoxes::geoBox | ( | ) | [inline] |
bool InfoBoxes::geoChanged | ( | const GeoLocation * | geo | ) | [slot] |
Update the GeoBox strings according to the argument.
- Parameters:
-
geo The Geographic Location (we get the name, longitude and latitude from this)
- Returns:
- true if values have changed
Definition at line 368 of file infoboxes.cpp.
bool InfoBoxes::grabBox | ( | QMouseEvent * | e | ) |
Determine whether a mouse click occurred inside one of the infoboxes.
Also, set the internal variable GrabBox to indicate which box was grabbed. Finally, set the internal variable GrabPos to record the relative position of the mouse cursor inside the box (we hold this position constant while dragging).
- Parameters:
-
e The mouse event to check (it's a mousePressEvent)
- Returns:
- true if the mouse press occurred inside one of the infoboxes.
Definition at line 128 of file infoboxes.cpp.
int InfoBoxes::height | ( | ) | const [inline] |
- Returns:
- the height of the region containing the infoboxes (usually the height of the Skymap)
Definition at line 132 of file infoboxes.h.
bool InfoBoxes::isVisible | ( | ) | [inline] |
- Returns:
- true if the collection of infoboxes is visible (i.e., not hidden).
Definition at line 191 of file infoboxes.h.
void InfoBoxes::resize | ( | int | w, | |
int | h | |||
) |
Resets the width and height parameters.
These usually reflect the size of the Skymap widget (Skymap::resizeEvent() calls this function). Will also reposition the infoboxes to fit the new size. Infoboxes that were along an edge will remain along the edge.
- Parameters:
-
w The new width h The new height
Definition at line 90 of file infoboxes.cpp.
void InfoBoxes::setVisible | ( | bool | t | ) | [inline, slot] |
Set whether the Infoboxes should be drawn, according to the bool argument.
This is the visibility setting for all three boxes. Each individual box also has its own Visible parameter. A box is only drawn if both Infoboxes::Visible /and/ Infobox::Visible are true.
- Parameters:
-
t If true, the Infoboxes will be drawn.
Definition at line 200 of file infoboxes.h.
bool InfoBoxes::shadeBox | ( | QMouseEvent * | e | ) |
Toggle the shade-state of the infobox in which the user double-clicked.
After shading the box, call fixCollisions() on the other two boxes. (This is called by SkyMap::mouseDoubleClickEvent() )
- Parameters:
-
e the mouse event containing the position of the double-click.
- Returns:
- false if the double-click was not inside any box; otherwise shade the target box and return true.
Definition at line 182 of file infoboxes.cpp.
void InfoBoxes::showFocusBox | ( | bool | t | ) | [inline, slot] |
Call the FocusBox's setVisible() function.
- Parameters:
-
t The bool parameter to send
Definition at line 215 of file infoboxes.h.
void InfoBoxes::showGeoBox | ( | bool | t | ) | [inline, slot] |
Call the GeoBox's setVisible() function.
- Parameters:
-
t The bool parameter to send
Definition at line 210 of file infoboxes.h.
void InfoBoxes::showTimeBox | ( | bool | t | ) | [inline, slot] |
Call the TimeBox's setVisible() function.
- Parameters:
-
t The bool parameter to send
Definition at line 205 of file infoboxes.h.
InfoBox* InfoBoxes::timeBox | ( | ) | [inline] |
bool InfoBoxes::timeChanged | ( | const KStarsDateTime & | ut, | |
const KStarsDateTime & | lt, | |||
dms * | lst | |||
) | [slot] |
Update the TimeBox strings according to the arguments.
The arguments are date/time objects; this function converts them to strings and displays them in the TimeBox.
- Parameters:
-
ut The Universal Time date/time object lt The Local Time date/time object lst The Sidereal Time object
- Returns:
- true if values have changed
Definition at line 338 of file infoboxes.cpp.
bool InfoBoxes::unGrabBox | ( | void | ) |
Set the internal variable GrabBox to 0, indicating that no box is currently grabbed.
Also determine if any box should be anchored to an edge. (This is called by SkyMap::mouseReleaseEvent() )
- Returns:
- true if a box was grabbed in the first place; otherwise, return false.
Definition at line 150 of file infoboxes.cpp.
int InfoBoxes::width | ( | ) | const [inline] |
- Returns:
- the width of the region containing the infoboxes (usually the width of the Skymap)
Definition at line 127 of file infoboxes.h.
The documentation for this class was generated from the following files: