SavvyUI C++ UI Library
Loading...
Searching...
No Matches
Graphics Class Reference

#include <Graphics.h>

Public Member Functions

 Graphics (WinHandle hWnd, DCHandle hDC)
virtual ~Graphics ()
DCHandle getHDC ()
COLORREF setTextColor (COLORREF newColor)
COLORREF getTextColor ()
COLORREF setBackgroundColor (COLORREF newColor)
COLORREF getBackgroundColor ()
int setBackgroundMode (int bkMode)
int getTextHeight (int defaultHeight)
 Calculates the height of text for a given window.
int getTextWidth (const wstring &text)
 Calculates the width of the specified text for a given window.
void setPen (int width, COLORREF color)
void restorePen ()
void setFont (const wstring &fontName, int fontSize, BOOL isBold=FALSE, BOOL isItalic=FALSE, BOOL isUnderlined=FALSE)
void restoreFont ()
void drawLine (long x1, long y1, long x2, long y2, COLORREF color=Theme::LineColor)
 Draws a line on the device context.
void drawBorder (Bounds rect, COLORREF color=Theme::LineColor)
 Draws a border around the specified rectangle.
void drawRaisedBorder (Bounds rect)
 Draws a raised (3D) border around the rectangle.
void drawSunkenBorder (Bounds rect)
 Draws a sunken (3D) border around the rectangle.
void drawButton (Bounds rect, const wstring &text, const ButtonType &btnType=ButtonType::DEFAULT, BOOL isPressed=FALSE, BOOL isDisabled=FALSE, const IconSource &iconSource=IconSource(), const Direction &iconPosition=Direction::LEFT, BOOL isRounded=FALSE, BOOL hasShadow=TRUE, BOOL hasBorder=TRUE, BOOL isGradient=FALSE, COLORREF bkColor=Theme::ButtonBackgroundStartColor, COLORREF fgColor=Theme::ButtonForegroundColor)
 Draws a button with the specified text and style.
void fillGradient (Bounds rect, COLORREF bkStartColor, COLORREF bkEndColor)
 Fills a rectangle with a vertical gradient.
void fillRect (Bounds rect, COLORREF color)
 Fills a rectangle with the specified color.
void drawText (Bounds rect, const wstring &text, int alignment, BOOL bold=FALSE, BOOL italic=FALSE, BOOL underlined=FALSE)
 Draws text within the specified rectangle with formatting.
void paintHeader (Bounds rect, const wstring &text)
 Paints a header area with text.
void paintCheckBox (Bounds rect, BOOL checked)
 Paints a checkbox.
void paintRadioButton (Bounds rect, BOOL checked)
 Paints a radio button.
void paintSortIndicator (Bounds rect, const SortType &sortDirection, COLORREF color)
 Paints a sort direction indicator.
void polygon (const POINT *pts, int ptCount, COLORREF fillColor=Theme::BackgroundColor)
void ellipse (Bounds rect, COLORREF fillColor=Theme::BackgroundColor)
void rectangle (Bounds rect, COLORREF fillColor=Theme::BackgroundColor)
void roundRect (Bounds rect, int xRadius, int yRadius, COLORREF bkColor=Theme::BackgroundColor, COLORREF color=Theme::LineColor)
void setClipRegion (int x1, int y1, int x2, int y2)
void clearClipRegion ()
void drawDownArrow (Bounds rect, COLORREF color=Theme::ForegroundColor)
void drawUpArrow (Bounds rect, COLORREF color=Theme::ForegroundColor)
void drawLeftArrow (Bounds rect, COLORREF color=Theme::ForegroundColor)
void drawRightArrow (Bounds rect, COLORREF color=Theme::ForegroundColor)
void drawCheckMark (Bounds rect, COLORREF color=Theme::ForegroundColor)

Constructor & Destructor Documentation

◆ Graphics()

Graphics::Graphics ( WinHandle hWnd,
DCHandle hDC )

◆ ~Graphics()

virtual Graphics::~Graphics ( )
virtual

Member Function Documentation

◆ clearClipRegion()

void Graphics::clearClipRegion ( )

◆ drawBorder()

void Graphics::drawBorder ( Bounds rect,
COLORREF color = Theme::LineColor )

Draws a border around the specified rectangle.

Parameters
rectRectangle area.
colorBorder color (default is Theme::LineColor).

◆ drawButton()

void Graphics::drawButton ( Bounds rect,
const wstring & text,
const ButtonType & btnType = ButtonType::DEFAULT,
BOOL isPressed = FALSE,
BOOL isDisabled = FALSE,
const IconSource & iconSource = IconSource(),
const Direction & iconPosition = Direction::LEFT,
BOOL isRounded = FALSE,
BOOL hasShadow = TRUE,
BOOL hasBorder = TRUE,
BOOL isGradient = FALSE,
COLORREF bkColor = Theme::ButtonBackgroundStartColor,
COLORREF fgColor = Theme::ButtonForegroundColor )

Draws a button with the specified text and style.

Parameters
rectRectangle area of the button.
textButton label text.
btnTypeButton style/type (e.g., L"primary"|L"default"|L"danger"|L"success").
isPressedButton pressed state.
isDisabledButton disabled state.
iconFileIcon File Path - Optional (e.g., L"images/filename.png").
iconPositionIcon orientation (e.g., L"left"|L"top"|L"bottom"|L"right").
isRoundedButton rounded border state.
hasShadowButton shadow state.
isGradientButton gradient paint.

◆ drawCheckMark()

void Graphics::drawCheckMark ( Bounds rect,
COLORREF color = Theme::ForegroundColor )

◆ drawDownArrow()

void Graphics::drawDownArrow ( Bounds rect,
COLORREF color = Theme::ForegroundColor )

◆ drawLeftArrow()

void Graphics::drawLeftArrow ( Bounds rect,
COLORREF color = Theme::ForegroundColor )

◆ drawLine()

void Graphics::drawLine ( long x1,
long y1,
long x2,
long y2,
COLORREF color = Theme::LineColor )

Draws a line on the device context.

Parameters
x1Starting X coordinate.
y1Starting Y coordinate.
x2Ending X coordinate.
y2Ending Y coordinate.
colorLine color (default is Theme::LineColor).

◆ drawRaisedBorder()

void Graphics::drawRaisedBorder ( Bounds rect)

Draws a raised (3D) border around the rectangle.

Parameters
rectRectangle area.

◆ drawRightArrow()

void Graphics::drawRightArrow ( Bounds rect,
COLORREF color = Theme::ForegroundColor )

◆ drawSunkenBorder()

void Graphics::drawSunkenBorder ( Bounds rect)

Draws a sunken (3D) border around the rectangle.

Parameters
rectRectangle area.

◆ drawText()

void Graphics::drawText ( Bounds rect,
const wstring & text,
int alignment,
BOOL bold = FALSE,
BOOL italic = FALSE,
BOOL underlined = FALSE )

Draws text within the specified rectangle with formatting.

Parameters
rectRectangle area.
textText to draw.
alignmentText alignment (-1 = left, 0 = center, 1 = right).
boldWhether the text is bold.
italicWhether the text is italic.
underlinedWhether the text is underlined.

◆ drawUpArrow()

void Graphics::drawUpArrow ( Bounds rect,
COLORREF color = Theme::ForegroundColor )

◆ ellipse()

void Graphics::ellipse ( Bounds rect,
COLORREF fillColor = Theme::BackgroundColor )

◆ fillGradient()

void Graphics::fillGradient ( Bounds rect,
COLORREF bkStartColor,
COLORREF bkEndColor )

Fills a rectangle with a vertical gradient.

Parameters
rectRectangle area to fill.
bkStartColorStarting color of the gradient.
bkEndColorEnding color of the gradient.

◆ fillRect()

void Graphics::fillRect ( Bounds rect,
COLORREF color )

Fills a rectangle with the specified color.

Parameters
rectRectangle area to fill.
colorfill color.

◆ getBackgroundColor()

COLORREF Graphics::getBackgroundColor ( )

◆ getHDC()

DCHandle Graphics::getHDC ( )

◆ getTextColor()

COLORREF Graphics::getTextColor ( )

◆ getTextHeight()

int Graphics::getTextHeight ( int defaultHeight)

Calculates the height of text for a given window.

Parameters
defaultHeightDefault height if calculation fails.
Returns
Calculated text height.

◆ getTextWidth()

int Graphics::getTextWidth ( const wstring & text)

Calculates the width of the specified text for a given window.

Parameters
textText string to measure.
Returns
Calculated text width in pixels.

◆ paintCheckBox()

void Graphics::paintCheckBox ( Bounds rect,
BOOL checked )

Paints a checkbox.

Parameters
rectRectangle area of the checkbox.
checkedThe checked state.

◆ paintHeader()

void Graphics::paintHeader ( Bounds rect,
const wstring & text )

Paints a header area with text.

Parameters
rectRectangle area of the header.
textHeader text.

◆ paintRadioButton()

void Graphics::paintRadioButton ( Bounds rect,
BOOL checked )

Paints a radio button.

Parameters
rectRectangle area of the radio button.
checkedThe checked state.

◆ paintSortIndicator()

void Graphics::paintSortIndicator ( Bounds rect,
const SortType & sortDirection,
COLORREF color )

Paints a sort direction indicator.

Parameters
rectRectangle area of the sort indicator.
sortDirectionThe direction of the sort.

◆ polygon()

void Graphics::polygon ( const POINT * pts,
int ptCount,
COLORREF fillColor = Theme::BackgroundColor )

◆ rectangle()

void Graphics::rectangle ( Bounds rect,
COLORREF fillColor = Theme::BackgroundColor )

◆ restoreFont()

void Graphics::restoreFont ( )

◆ restorePen()

void Graphics::restorePen ( )

◆ roundRect()

void Graphics::roundRect ( Bounds rect,
int xRadius,
int yRadius,
COLORREF bkColor = Theme::BackgroundColor,
COLORREF color = Theme::LineColor )

◆ setBackgroundColor()

COLORREF Graphics::setBackgroundColor ( COLORREF newColor)

◆ setBackgroundMode()

int Graphics::setBackgroundMode ( int bkMode)

◆ setClipRegion()

void Graphics::setClipRegion ( int x1,
int y1,
int x2,
int y2 )

◆ setFont()

void Graphics::setFont ( const wstring & fontName,
int fontSize,
BOOL isBold = FALSE,
BOOL isItalic = FALSE,
BOOL isUnderlined = FALSE )

◆ setPen()

void Graphics::setPen ( int width,
COLORREF color )

◆ setTextColor()

COLORREF Graphics::setTextColor ( COLORREF newColor)

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