Guiliani  Version 2.5 revision 7293 (documentation build 13)
CGUINinePatch Class Reference

Helper class to for storing Nine-Patch images. More...

#include <GUINinePatch.h>

Public Member Functions

 CGUINinePatch ()
 
 CGUINinePatch (const eC_UInt &uiTop, const eC_UInt &uiBottom, const eC_UInt &uiLeft, const eC_UInt &uiRight)
 
void Assign (const CGUINinePatch &kOther)
 
void Assign (const eC_UInt &uiTop, const eC_UInt &uiBottom, const eC_UInt &uiLeft, const eC_UInt &uiRight)
 
eC_UInt GetBottom () const
 
eC_UInt GetLeft () const
 
eC_UInt GetRight () const
 
eC_UInt GetTop () const
 
void ReadFromStream ()
 
void WriteToStream ()
 

Protected Attributes

eC_UInt m_uiBottomBorder
 Nine Patch Bottom Border size in pixels.
 
eC_UInt m_uiLeftBorder
 Nine Patch Left Border size in pixels.
 
eC_UInt m_uiRightBorder
 Nine Patch Right Border size in pixels.
 
eC_UInt m_uiTopBorder
 Nine Patch Top Border size in pixels.
 

Detailed Description

Helper class to for storing Nine-Patch images.

A Nine Patch is a smart way of scaling up bitmaps without the usual quality losses by subdividing the source image into nine sections and blitting the border sections unstretched, while only stretching the center section. This is particularly useful for mostly rectangular images in use-cases such as a scaled button, a progressbar or a scrollbar knob.

The Nine Patch is defined by the width/height of its top, bottom, left and right borders. These are given in pixels and relative to the image's top/left, and bottom/right corners. Typically, you will wish to set these values so that they encapsulate the areas of your source-image which shall remain in their original size, such as the edges or drop shadows of a button. The following image illustrates this concept.

These examples show how the original image appears when being stretched, with regard to different Nine Patch borders. You can clearly see how much the appearance of the stretched button has improved.

Please note that this comes at a slight performance cost, since a total of 9 blit operations has to be performed. Therefore, if you wish to avoid this, either blit the source image in its original size, or set all border widths to zero, which will result in one simple stretch-blit for the entire image.

Supplying the Nine Patch with illegal values, such as border sizes which exceed the original image's dimensions, will result in a visual output as shown in the two examples at the bottom. Also, make sure, that you leave a center section of at least 1 pixel, so that the center area will be filled and not remain empty.

Constructor & Destructor Documentation

◆ CGUINinePatch() [1/2]

CGUINinePatch::CGUINinePatch ( )

Standard constructor. Initializes all Borders with 0.

◆ CGUINinePatch() [2/2]

CGUINinePatch::CGUINinePatch ( const eC_UInt &  uiTop,
const eC_UInt &  uiBottom,
const eC_UInt &  uiLeft,
const eC_UInt &  uiRight 
)

Constructor.

Parameters
uiTopWidth of top border in pixels
uiBottomWidth of uiBottom border in pixels
uiLeftWidth of uiLeft border in pixels
uiRightWidth of uiRight border in pixels

Member Function Documentation

◆ Assign() [1/2]

void CGUINinePatch::Assign ( const CGUINinePatch kOther)
inline

Assign from other NinePatch

Parameters
kOtherthe other ninepatch

◆ Assign() [2/2]

void CGUINinePatch::Assign ( const eC_UInt &  uiTop,
const eC_UInt &  uiBottom,
const eC_UInt &  uiLeft,
const eC_UInt &  uiRight 
)
inline

Assign values for all four borders to this Nine Patch.

Parameters
uiTopWidth of top border in pixels
uiBottomWidth of uiBottom border in pixels
uiLeftWidth of uiLeft border in pixels
uiRightWidth of uiRight border in pixels

◆ GetBottom()

eC_UInt CGUINinePatch::GetBottom ( ) const
inline
Returns
The current bottom border in pixels

◆ GetLeft()

eC_UInt CGUINinePatch::GetLeft ( ) const
inline
Returns
The current left border in pixels

◆ GetRight()

eC_UInt CGUINinePatch::GetRight ( ) const
inline
Returns
The current right border in pixels

◆ GetTop()

eC_UInt CGUINinePatch::GetTop ( ) const
inline
Returns
The current top border in pixels

◆ ReadFromStream()

void CGUINinePatch::ReadFromStream ( )

Please refer to the description of classes using this class, i.e. CGUIButton.

See also
CGUIFactory, CGUIButton::ReadFromStream().

◆ WriteToStream()

void CGUINinePatch::WriteToStream ( )

Please refer to the description of classes using this class, i.e. CGUIButton.

See also
CGUIStreamWriter, CGUIButton::WriteToStream().

The documentation for this class was generated from the following file: