Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

# background_wnd Class Reference

background_wnd is a pluggable class which manages the drawing of the background . More...

List of all members.

## Public Types
typedef bg_wnd::general_exception< background_wnd, 0 > | index_invalid
typedef bg_wnd::general_exception< background_wnd, 1 > | invalid_painter_cast
## Public Member Functions
unsigned | add_painter (const painter_base &painter)
void | delete_painter (unsigned idx)
void | delete_all_painters ()
painter_base & | get_painter (unsigned idx) const
std::vector< unsigned > | get_indices () const
void | drawing_rect (unsigned idx, const rectangle &rc)
rectangle | drawing_rect (unsigned idx) const
bool | is_painter_visible (unsigned idx) const
void | show_painter (unsigned idx, bool bVisible)
void | transparency (unsigned idx, unsigned transparency)
unsigned | transparency (unsigned idx) const
void | redraw_on_changes (bool bRedraw)
bool | redraw_on_changes () const
void | redraw_painters ()
void | zorder_to_front (unsigned idx)
void | zorder_to_back (unsigned idx)
void | zorder_forward (unsigned idx)
void | zorder_backward (unsigned idx)
void | bk_color (COLORREF cr)
COLORREF | bk_color () const
template<class Painter>
unsigned | add_painter ()
template<class Painter>
unsigned | add_painter (typename Painter::param0 param)
template<class Painter>
unsigned | add_painter (typename Painter::param0 param0, typename Painter::param1 param1)
template<class Painter>
Painter & | get_painter (unsigned idx) const
## Protected Member Functions
bg_wnd::memory_dc & | get_mem_dc ()
const bg_wnd::memory_dc & | get_mem_dc () const
## Friends
struct | background_wnd_handler

## Detailed Description

background_wnd is a pluggable class which manages the drawing of the background .

background_wnd is a pluggable class which manages the drawing of the background. It maintains a list of so-called "painters". A painter must be derived from painter_base and does the actual drawing. If you want a special painting behaviour follow the steps described here. You can add painters to the background_wnd and you can change the Z-Order and painting area of the painters so they can overlap. With the painter-concept a separation of the drawing logic and the window is achieved. Imagine some common drawing operations - load an image and draw it to the window. This can be done by a painter and added to every window extending background_wnd ;-)

When you add a painter you get an unique index. If you want to manipulate a painter you can do this by passing the index of the painter to the specific member-function. If you pass an invalid index to a function a `background_wnd::index_invalid`-exception will be thrown. You can get a reference to a painter by calling `get_painter()`. There is one template version of this member-function so you can pass the type of the painter and get a reference to the passed type. If the painter is not of this type a `background_wnd::invalid_painter_cast`-exception is thrown.

background_wnd uses a memory DC which is available to the derived classes.

See also:
  ipicture_painter

  tile_ipicture_painter

  color_painter

  resource_painter

  tile_resource_painter

  gradient_painter

  text_painter

  layout_painter

  transparent_painter

## Member Function Documentation

unsigned add_painter | ( | typename Painter::param0 | param0,
|  | typename Painter::param1 | param1
| ) | `[inline]`

  | Adds a painter of type Painter and returns the index of this new painter. Parameters:
  | param0,param1 | Arguments which are passed to the c'tor of the painter

unsigned add_painter | ( | typename Painter::param0 | param | ) | `[inline]`

  | Adds a painter of type Painter and returns the index of this new painter. Parameters:
  | param | Argument which is passed to the c'tor of the painter

unsigned add_painter | ( |  | ) | `[inline]`

| Adds a painter of type Painter and returns the index of this new painter.

unsigned add_painter | ( | const painter_base & | painter | ) |

| Adds a copy of painter.

COLORREF bk_color | ( |  | ) | const

| Returns the background color of the window.

void bk_color | ( | COLORREF | cr | ) |

| Sets the background color of the window.

void delete_all_painters | ( |  | ) |

| Removes all painters.

void delete_painter | ( | unsigned | idx | ) |

  | Removes a painter Exceptions:
  | background_wnd::index_invalid | if no painter with the passed index exists.

rectangle drawing_rect | ( | unsigned | idx | ) | const

  | Gets the drawing rectangle of a painter. Returns: Drawing rectangle Exceptions:
  | background_wnd::index_invalid | if no painter with the passed index exists
See also: drawing_rect()

void drawing_rect | ( | unsigned | idx,
|  | const rectangle & | rc
| ) |

  | Sets the drawing rectangle of a painter . The Painter will only be drawin inside this rectangle. So this is a clipping rectangle Parameters:
  | rc | New drawing rectangle
  Exceptions:
  | background_wnd::index_invalid | if no painter with the passed index exists
See also: drawing_rect()

std::vector< unsigned > get_indices | ( |  | ) | const

| Returns a vector with all the indices available . The indices are sorted by Z-Order of the painters, ascending from background to foreground

const bg_wnd::memory_dc & get_mem_dc | ( |  | ) | const`[protected]`

| Returns the memory DC used by the background_wnd. Returns: Memory DC

bg_wnd::memory_dc & get_mem_dc | ( |  | ) | `[protected]`

| Returns the memory DC used by the background_wnd. Returns: Memory DC

Painter& get_painter | ( | unsigned | idx | ) | const`[inline]`

  | Returns the painter at index idx . The painter will be automatically cast to the passed type Painter Exceptions:
  | background_wnd::index_invalid | if no painter with the passed index exists
  | background_wnd::invalid_painter_cast | if the painter can't be casted to Painter (means dynamic type is NOT a Painter)

painter_base & get_painter | ( | unsigned | idx | ) | const

  | Returns a painter Exceptions:
  | background_wnd::index_invalid | if no painter with the passed index exists.

bool is_painter_visible | ( | unsigned | idx | ) | const

  | Returns true if a painter is visible Exceptions:
  | background_wnd::index_invalid | if no painter with the passed index exists.

bool redraw_on_changes | ( |  | ) | const

| Returns true if the window is redrawn when a change happens.

void redraw_on_changes | ( | bool | bRedraw | ) |

| Specifies if the window is redrawn when a change happens . Specifies if the window is redrawn when a change happens (painter is added, removed, transparency changed, ...)

void redraw_painters | ( |  | ) |

| Redraws the painters.

void show_painter | ( | unsigned | idx,
|  | bool | bVisible
| ) |

  | Shows or hides a painter Exceptions:
  | background_wnd::index_invalid | if no painter with the passed index exists.

unsigned transparency | ( | unsigned | idx | ) | const

  | Returns the current transparency of a painter Exceptions:
  | background_wnd::index_invalid | if no painter with the passed index exists.

void transparency | ( | unsigned | idx,
|  | unsigned | transparency
| ) |

  | Sets the transparency of a painter . Sets the transparency of a painter. A value of 0 means totally transparent; a value of 255 means opaque Exceptions:
  | background_wnd::index_invalid | if no painter with the passed index exists

void zorder_backward | ( | unsigned | idx | ) |

  | Brings a painter one step to the background Exceptions:
  | background_wnd::index_invalid | if no painter with the passed index exists.
See also: zorder_to_front() zorder_to_back() zorder_forward()

void zorder_forward | ( | unsigned | idx | ) |

  | Brings a painter one step to the front Exceptions:
  | background_wnd::index_invalid | if no painter with the passed index exists.
See also: zorder_to_front() zorder_to_back() zorder_backward()

void zorder_to_back | ( | unsigned | idx | ) |

  | Brings a painter to the background Exceptions:
  | background_wnd::index_invalid | if no painter with the passed index exists.
See also: zorder_to_front() zorder_forward() zorder_backward()

void zorder_to_front | ( | unsigned | idx | ) |

  | Brings a painter to the front Exceptions:
  | background_wnd::index_invalid | if no painter with the passed index exists.
See also: zorder_to_back() zorder_forward() zorder_backward()

| by Steven Weiss. You can contact me at steven11@gmx.de.