MoSync 3.3
MAUI::WidgetSkin Class Reference

A customizable skin for widgets. More...

#include <MAUI/WidgetSkin.h>

List of all members.

Classes

struct  CacheElement
 Cache element for skins. More...
struct  CacheKey
 Key to cache element for skins. More...

Public Types

enum  eType { SELECTED = 0, UNSELECTED = 1 }

Public Member Functions

 WidgetSkin ()
 WidgetSkin (MAHandle selectedImage, MAHandle unselectedImage, int x1, int x2, int y1, int y2, bool selectedTransparent=true, bool unselectedTransparent=true)
void setStartX (int x)
void setEndX (int x)
void setStartY (int y)
void setEndY (int y)
int getStartX () const
int getStartY () const
int getEndX () const
int getEndY () const
MAHandle getUnselectedImage () const
MAHandle getSelectedImage () const
void setSelectedImage (MAHandle image)
void setUnselectedImage (MAHandle image)
void draw (int x, int y, int width, int height, eType type)
void drawDirect (int x, int y, int width, int height, eType type)
void drawToData (int *data, int x, int y, int width, int height, eType type)
int calculateNumTiles (int width, int height)
void drawRegion (MAHandle image, int *data, int scanLength, const MARect *srcRect, const MAPoint2d *dstPoint)
int getImageHeight () const
int getImageWidth () const
bool isSelectedTransparent () const
bool isUnselectedTransparent () const

Static Public Member Functions

static void setMaxCacheSize (int c)
static void setCacheEnabled (bool e=true)
static void flushCache ()
static void flushCacheUntilNewImageFits (int numPixels)
static void addToCache (const CacheKey &key, const CacheElement &elem)
static MAHandle getFromCache (const CacheKey &key)

Detailed Description

A customizable skin for widgets.

A WidgetSkin is a class used to define the visual appearance of a widget. It is instantiated by passing an image for the selected and unselected mode, and two coordinates telling how to divide the image into 9 segments. These segments are then used as information of how to tile the skin to different widget sizes. The constructor also takes parameters telling if the selected or unselected images are transparent or not, used to optimize MAUI drawing.


Member Enumeration Documentation

Enumerator for the different drawing states of a WidgetSkin.

Enumerator:
SELECTED 
UNSELECTED 

Constructor & Destructor Documentation

The default constructor.

MAUI::WidgetSkin::WidgetSkin ( MAHandle  selectedImage,
MAHandle  unselectedImage,
int  x1,
int  x2,
int  y1,
int  y2,
bool  selectedTransparent = true,
bool  unselectedTransparent = true 
)

The WidgetSkin constructor takes two images (selected and unselected) and 2 coordinate pairs, defining the 9 segments of the images. Finally it takes two bools that specifies if the images are transparent or not (default true).


Member Function Documentation

void MAUI::WidgetSkin::setStartX ( int  x)

Set the start x coordinate of the WidgetSkin rect.

void MAUI::WidgetSkin::setEndX ( int  x)

Set the end x coordinate of the WidgetSkin rect.

void MAUI::WidgetSkin::setStartY ( int  y)

Set the start y coordinate of the WidgetSkin rect.

void MAUI::WidgetSkin::setEndY ( int  y)

Set the end y coordinate of the WidgetSkin rect.

Get the start x coordinate of the WidgetSkin rect.

Get the start y coordinate of the WidgetSkin rect.

Get the end x coordinate of the WidgetSkin rect.

Get the end y coordinate of the WidgetSkin rect.

Get the image used to display an unselected state.

Get the image used to display a selected state.

Set the selected image, returns false if there is an unselected image and the dimensions of the selected image does not equal the unselected image.

Set the unselected image, returns false if there is a selected image and the dimensions of the unselected image does not equal the selected image.

void MAUI::WidgetSkin::draw ( int  x,
int  y,
int  width,
int  height,
eType  type 
)

Use this to draw the WidgetSkin. The upper-left corner is placed at 'x' and 'y' and the skin is automatically resized to 'width' and 'height. 'type' specifies which drawing state should be used when drawing the widget skin.

void MAUI::WidgetSkin::drawDirect ( int  x,
int  y,
int  width,
int  height,
eType  type 
)
void MAUI::WidgetSkin::drawToData ( int *  data,
int  x,
int  y,
int  width,
int  height,
eType  type 
)
int MAUI::WidgetSkin::calculateNumTiles ( int  width,
int  height 
)
void MAUI::WidgetSkin::drawRegion ( MAHandle  image,
int *  data,
int  scanLength,
const MARect srcRect,
const MAPoint2d dstPoint 
)

Get the image height.

Get the image width.

Returns whether the selected image is transparent or not.

Returns whether the unselected image is transparent or not.

static void MAUI::WidgetSkin::setMaxCacheSize ( int  c) [static]
static void MAUI::WidgetSkin::setCacheEnabled ( bool  e = true) [static]
static void MAUI::WidgetSkin::flushCache ( ) [static]
static void MAUI::WidgetSkin::flushCacheUntilNewImageFits ( int  numPixels) [static]
static void MAUI::WidgetSkin::addToCache ( const CacheKey key,
const CacheElement elem 
) [static]
static MAHandle MAUI::WidgetSkin::getFromCache ( const CacheKey key) [static]
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines