Hasty Badger
Small UI library (a branch of Turbo Badger)
 All Classes Namespaces Functions Variables Enumerations Enumerator Friends Groups Pages
tb::TBDimensionConverter Class Reference

TBDimensionConverter converts device independant points to pixels, based on two DPI values. More...

#include <tb_dimension.h>

Public Member Functions

void SetDPI (int src_dpi, int dst_dpi)
 Set the source and destination DPI that will affect the conversion. More...
 
int GetSrcDPI () const
 Get the source DPI. More...
 
int GetDstDPI () const
 Get the destination DPI. More...
 
const TBStrGetDstDPIStr () const
 Get the file name suffix that should be used to load bitmaps in the destination DPI. More...
 
void GetDstDPIFilename (const char *filename, TBTempBuffer *tempbuf) const
 Get the file name with destination DPI suffix (F.ex "foo.png" becomes "foo@192.png"). More...
 
bool NeedConversion () const
 Return true if the source and destinatin DPI are different. More...
 
int DpToPx (int dp) const
 Convert device independant point to pixel. More...
 
int MmToPx (int mm) const
 Convert millimeter to pixel. More...
 
int GetPxFromString (const TBStr &str, int def_value) const
 Get a pixel value from string in any of the following formats: str may be nullptr. More...
 
int GetPxFromValue (TBValue *value, int def_value) const
 Get a pixel value from TBValue. More...
 

Detailed Description

TBDimensionConverter converts device independant points to pixels, based on two DPI values.

Dimensions in Turbo Badger are normally in pixels (if not specified differently) and conversion normally take place when loading skin.

Member Function Documentation

int tb::TBDimensionConverter::DpToPx ( int  dp) const

Convert device independant point to pixel.

int tb::TBDimensionConverter::GetDstDPI ( ) const
inline

Get the destination DPI.

void tb::TBDimensionConverter::GetDstDPIFilename ( const char *  filename,
TBTempBuffer tempbuf 
) const

Get the file name with destination DPI suffix (F.ex "foo.png" becomes "foo@192.png").

The temp buffer will contain the resulting file name.

const TBStr& tb::TBDimensionConverter::GetDstDPIStr ( ) const
inline

Get the file name suffix that should be used to load bitmaps in the destination DPI.

Examples: "@96", "@196"

int tb::TBDimensionConverter::GetPxFromString ( const TBStr str,
int  def_value 
) const

Get a pixel value from string in any of the following formats: str may be nullptr.

def_value is returned on fail.

Device independent point: "1", "1dp" Pixel value: "1px"

int tb::TBDimensionConverter::GetPxFromValue ( TBValue value,
int  def_value 
) const

Get a pixel value from TBValue.

value may be nullptr. def_value is returned on fail.

Number formats are treated as dp. String format is treated like for GetPxFromString.

int tb::TBDimensionConverter::GetSrcDPI ( ) const
inline

Get the source DPI.

int tb::TBDimensionConverter::MmToPx ( int  mm) const

Convert millimeter to pixel.

bool tb::TBDimensionConverter::NeedConversion ( ) const
inline

Return true if the source and destinatin DPI are different.

void tb::TBDimensionConverter::SetDPI ( int  src_dpi,
int  dst_dpi 
)

Set the source and destination DPI that will affect the conversion.


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