Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members  

MapWidget Class Reference

A widget to show a map. More...

#include <map_widget.h>

Inheritance diagram for MapWidget::

List of all members.

Public Slots

void setKeeperDirection (AtomicMove::AtomicMoveType direction)
void setArrows (std::vector< Move > const &arrows)
void updateDisplay ()
void setVirtualKeeper (const QPoint &position)
void configChanged ()
void switchToBetterScaling ()
void mouseRepeat ()
void cursorVisible (bool stop_autohide)
void cursorHidden ()

Signals

void fieldClicked (QPoint point)
void gemMoved (QPoint from, QPoint to)
void keeperMoved (QPoint from, QPoint to)
void undo ()
void redo ()

Public Methods

 MapWidget (Map const *map, PixmapProvider *pixmap_provider, Theme const *theme, bool disable_auto_hide, QWidget *parent=0, char const *name=0)
virtual ~MapWidget ()
void setMap (Map const *map)
void setPixmapProvider (PixmapProvider *pixmap_provider, Theme const *theme)
AtomicMove::AtomicMoveType keeperDirection ()
QPoint const & virtualKeeper () const

Protected Methods

virtual void resizeEvent (QResizeEvent *event)
virtual void contentsMousePressEvent (QMouseEvent *event)
virtual void contentsMouseMoveEvent (QMouseEvent *event)
virtual void contentsMouseReleaseEvent (QMouseEvent *event)

Private Methods

void deleteItems (std::vector< QCanvasSprite *> &items) const
void createItems (std::vector< QCanvasSprite *> &items, int type, QPoint const &position, int x, int y, int z) const
void createItems (std::vector< QCanvasSprite *> &items, QPoint const &position, int x, int y, int z) const
void createItems (std::vector< QCanvasSprite *> &items, std::vector< int > image_indices, int x, int y, int z) const
void placeItems (std::vector< QCanvasSprite *> &items, int x, int y, int z)
void updateGeometry ()
void deletePixmaps ()
void deleteArrows ()
void addArrow (QPoint from, QPoint to)
void deleteItems ()
void newItems ()
bool isValidPosition (QPoint position) const
QPoint getFieldFromPosition (QPoint position) const
void moveMovingItemPosition (QPoint const &offset)
QCanvasPixmapArray * createPixmapArray (QPixmap const &pixmap) const

Private Attributes

QCanvas m_canvas
PixmapProviderm_pixmap_provider
Theme const * m_theme
Map const * m_map
std::vector< int > m_pieces
int m_x_offset
int m_y_offset
int m_square_size
int m_map_width
int m_map_height
int m_size
bool m_force_update
bool m_valid_click
bool m_in_drag
bool m_is_keeper_drag
AtomicMove::AtomicMoveType m_keeper_direction
QPoint m_click_position
QPoint m_click_field
QPoint m_click_offset
QPoint m_last_mouse_position
QPoint m_virtual_keeper_pos
std::vector< QCanvasSprite *> m_virtual_keeper_item
std::vector< QCanvasSprite *> m_moving_item
std::vector< std::vector<
QCanvasSprite *> > 
m_arrow_items
std::vector< std::vector<
QCanvasSprite *> > 
m_items
std::vector< QCanvasPixmapArray *> m_pixmaps
std::vector< Movem_arrows
QTimer * m_timer
QTimer * m_repeat_timer
int m_mouse_repeat_state
int m_mouse_repeat_delay
int m_mouse_repeat_rate
int m_scaling_mode
int m_switch_time
int m_min_square_size
bool m_has_scrollbars
bool m_cursor_hidden
bool m_auto_hide_cursor
bool m_disable_auto_hide
int m_cursor_hide_delay
QTimer * m_cursor_timer
int m_virtual_keeper_direction

Detailed Description

A widget to show a map.

Author:
Ralf Schmelter (ralfs@pc2a.chemie.uni-dortmund.de).
Version:
0.1


Constructor & Destructor Documentation

MapWidget::MapWidget Map const * map,
PixmapProvider * pixmap_provider,
Theme const * theme,
bool disable_auto_hide,
QWidget * parent = 0,
char const * name = 0
 

Creates the widget with the given map.

The widget does not takes ownership of the map or the pixmap provider.

Parameters:
map   The map to display (or 0, if you don't want to display something).
pixmap_provider   The pixmap provider to use.
theme   The theme of the pixmap provider.
disable_auto_hide   If true, the auto hide feature of the map is disabled.
parent   The parent widget.
name   The internal widget name.

virtual MapWidget::~MapWidget [virtual]
 

Releasy all resources.


Member Function Documentation

void MapWidget::addArrow QPoint from,
QPoint to
[private]
 

Adds a new arrow.

Parameters:
from   The source of the arrow.
to   The destination of the arrow.

void MapWidget::configChanged [slot]
 

Call this, when the configuration file was changed.

virtual void MapWidget::contentsMouseMoveEvent QMouseEvent * event [protected, virtual]
 

Used to let the used move keeper and gems with the mouse.

virtual void MapWidget::contentsMousePressEvent QMouseEvent * event [protected, virtual]
 

Used to let the used move keeper and gems with the mouse.

virtual void MapWidget::contentsMouseReleaseEvent QMouseEvent * event [protected, virtual]
 

Used to let the used move keeper and gems with the mouse.

void MapWidget::createItems std::vector< QCanvasSprite *> & items,
std::vector< int > image_indices,
int x,
int y,
int z
const [private]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void MapWidget::createItems std::vector< QCanvasSprite *> & items,
QPoint const & position,
int x,
int y,
int z
const [private]
 

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void MapWidget::createItems std::vector< QCanvasSprite *> & items,
int type,
QPoint const & position,
int x,
int y,
int z
const [private]
 

Fills the given vector of items.

If the vector is not empty, it will be cleared before.

Parameters:
items   The vector with the items to create.
type   The type of the image
direction   The direction of the keeper.
position   The position of the field in the map.
x   The x-coordinate.
x   The y-coordinate.
x   The z-coordinate.

QCanvasPixmapArray* MapWidget::createPixmapArray QPixmap const & pixmap const [private]
 

Creates a QCanvasPixmapArray from a QPixmap.

Parameters:
pixmap   The pixmap.

void MapWidget::cursorHidden [slot]
 

This is called, if the mouse cursor hide delay expired.

void MapWidget::cursorVisible bool stop_autohide [slot]
 

This is called, if the mouse cursor should be displayed.

Parameters:
stop_autohide   If true, the auto hide feature is stopped.

void MapWidget::deleteArrows [private]
 

Deletes the currently used arrows.

void MapWidget::deleteItems [private]
 

Deletes the items.

void MapWidget::deleteItems std::vector< QCanvasSprite *> & items const [private]
 

Deletes the given vector of items.

Parameters:
items   The vector with the items to delete;

void MapWidget::deletePixmaps [private]
 

Deletes the currently used pixmaps.

void MapWidget::fieldClicked QPoint point [signal]
 

This is emitted, whener the user clicks on an field in the map.

Parameters:
point   The point where the user clicked.

void MapWidget::gemMoved QPoint from,
QPoint to
[signal]
 

This is emitted if a gem was dragged.

Parameters:
from   The original position of the gem.
The   end position of the gem.

QPoint MapWidget::getFieldFromPosition QPoint position const [private]
 

Converts mouse coordinates to field coordinates.

Parameters:
position   The mouse coordinates.

bool MapWidget::isValidPosition QPoint position const [private]
 

Returns true, if the given mouse position is valid.

Parameters:
position   The position.

AtomicMove::AtomicMoveType MapWidget::keeperDirection
 

Returns the current direction of the keeper.

void MapWidget::keeperMoved QPoint from,
QPoint to
[signal]
 

This is emitted if a keeper was dragged.

Parameters:
from   The original position of the keeper.
to   The original position of the keeper.

void MapWidget::mouseRepeat [slot]
 

This is called for mouse repeat.

void MapWidget::moveMovingItemPosition QPoint const & offset [private]
 

Moves the moving item.

Parameters:
offsets   The offset to move.

void MapWidget::newItems [private]
 

Make new items.

void MapWidget::placeItems std::vector< QCanvasSprite *> & items,
int x,
int y,
int z
[private]
 

Places the items at the given position taking the offset into account and making them visible.

Parameters:
items   The vector with the items to create.
x   The x-coordinate.
x   The y-coordinate.
x   The z-coordinate.

void MapWidget::redo [signal]
 

This is emitted when redo was requested.

virtual void MapWidget::resizeEvent QResizeEvent * event [protected, virtual]
 

Adjustes the size of the pixmaps.

void MapWidget::setArrows std::vector< Move > const & arrows [slot]
 

Sets a vector with arrows for atomic moves.

Call updateDisplay() afterwards.

Parameters:
arrows   A vector of moves for which arrorws are drawn.

void MapWidget::setKeeperDirection AtomicMove::AtomicMoveType direction [slot]
 

Sets the direction of the keeper.

Parameters:
direction   The direction of the keeper.

void MapWidget::setMap Map const * map
 

Sets a map to display.

Note that you have to call updateDisplay() to update the display.

All arrows and the virtual keeper will be hidden.

Parameters:
map   The map to display.

void MapWidget::setPixmapProvider PixmapProvider * pixmap_provider,
Theme const * theme
 

Sets the pixmap provider to use.

The old pixmap provider will be deleted!

Parameters:
pixmap_provider   The pixmap provider to use.
theme   The theme of the pixmap provider.

void MapWidget::setVirtualKeeper const QPoint & position [slot]
 

Sets the virtual keeper.

QPoint(-1,-1) means to hide the virtual keeper.

Parameters:
position   The position of the virtual keeper.

void MapWidget::switchToBetterScaling [slot]
 

This is called, when we should switch to better scaling.

void MapWidget::undo [signal]
 

This is emitted when undo was requested.

void MapWidget::updateDisplay [slot]
 

Call to update the display.

void MapWidget::updateGeometry [private]
 

Updates the square size, offsets and so on.

QPoint const& MapWidget::virtualKeeper const
 

Returns the position of the virtual keeper (QPoint(-1, -1) means hidden).


Member Data Documentation

std::vector<std::vector<QCanvasSprite *> > MapWidget::m_arrow_items [private]
 

Here we store the arrow items.

std::vector<Move> MapWidget::m_arrows [private]
 

The arrows.

bool MapWidget::m_auto_hide_cursor [private]
 

If true, we automartically hide the cursor.

QCanvas MapWidget::m_canvas [private]
 

The current canvas.

QPoint MapWidget::m_click_field [private]
 

The field, where the mouse was clicked.

QPoint MapWidget::m_click_offset [private]
 

The offset between the click point and the position of the clicked item.

QPoint MapWidget::m_click_position [private]
 

The mouse position when we clicked.

bool MapWidget::m_cursor_hidden [private]
 

If true, we hide the mouse cursor.

int MapWidget::m_cursor_hide_delay [private]
 

The cursor hide delay.

QTimer* MapWidget::m_cursor_timer [private]
 

The timer used for mouse cursor hiding.

bool MapWidget::m_disable_auto_hide [private]
 

If true, we disable auto hide forever.

bool MapWidget::m_force_update [private]
 

This is true, if we force an update.

bool MapWidget::m_has_scrollbars [private]
 

If true, we have scrollbars.

bool MapWidget::m_in_drag [private]
 

If true, we are in a drag operation.

bool MapWidget::m_is_keeper_drag [private]
 

If true, we are in a keeper drag operation and else in a gem drag operation.

std::vector<std::vector<QCanvasSprite *> > MapWidget::m_items [private]
 

The currently used canvas items.

AtomicMove::AtomicMoveType MapWidget::m_keeper_direction [private]
 

Here we store the keeper direction.

QPoint MapWidget::m_last_mouse_position [private]
 

The last mouse position.

Map const* MapWidget::m_map [private]
 

The current map.

int MapWidget::m_map_height [private]
 

The height of the map.

int MapWidget::m_map_width [private]
 

The width of the map.

int MapWidget::m_min_square_size [private]
 

The minimum size of a field.

int MapWidget::m_mouse_repeat_delay [private]
 

The mouse repeat delay in ms.

int MapWidget::m_mouse_repeat_rate [private]
 

The mouse repeat rate.

int MapWidget::m_mouse_repeat_state [private]
 

The button state for the mouse repeat.

std::vector<QCanvasSprite *> MapWidget::m_moving_item [private]
 

The item for the moving keeper or gem.

std::vector<int> MapWidget::m_pieces [private]
 

The currently used piece type.

PixmapProvider* MapWidget::m_pixmap_provider [private]
 

The current pixmap provider.

std::vector<QCanvasPixmapArray *> MapWidget::m_pixmaps [private]
 

The pixmaps.

QTimer* MapWidget::m_repeat_timer [private]
 

The timer used for mouse repeat.

int MapWidget::m_scaling_mode [private]
 

The scaling mode (0 = fast, 1 = good, 2 = timed good).

int MapWidget::m_size [private]
 

m_map_height * m_map_width.

int MapWidget::m_square_size [private]
 

The size of the squares.

int MapWidget::m_switch_time [private]
 

The time to switch between fast and good scaling.

Theme const* MapWidget::m_theme [private]
 

The current theme.

QTimer* MapWidget::m_timer [private]
 

The timer used.

bool MapWidget::m_valid_click [private]
 

If true, the click position was valid.

int MapWidget::m_virtual_keeper_direction [private]
 

The current direction of the virtual keeper.

std::vector<QCanvasSprite *> MapWidget::m_virtual_keeper_item [private]
 

The item for the virtual keeper.

QPoint MapWidget::m_virtual_keeper_pos [private]
 

The position of the virtual keeper.

int MapWidget::m_x_offset [private]
 

The x-offset.

int MapWidget::m_y_offset [private]
 

The y-offset.


The documentation for this class was generated from the following file:
Generated at Sun Jan 6 18:49:12 2002 for EasySok by doxygen1.2.9.1 written by Dimitri van Heesch, © 1997-2001