Pebble Foundation Classes
0.2.0
C++ for Pebble
|
Public Member Functions | |
GContext (::GContext *ctx) | |
Wraps an existing graphics context. | |
operator::GContext * () const | |
Instances of this class can be automatically converted to Pebble GContext pointer. | |
void | SetStrokeColor (GColor color) const |
void | SetFillColor (GColor color) const |
void | SetTextColor (GColor color) const |
void | SetCompositingMode (GCompOp mode) const |
void | SetAntialiased (bool enable) const |
void | SetStrokeWidth (uint8_t stroke_width) const |
void | DrawText (const char *text, GFont const font, const GRect box, const GTextOverflowMode overflow_mode=GTextOverflowModeWordWrap, const GTextAlignment alignment=GTextAlignmentLeft) const |
void | DrawText (const char *text, GFont const font, const GRect box, const GTextOverflowMode overflow_mode, const GTextAlignment alignment, const GTextAttributes &text_attributes) const |
void | DrawText (const std::string &text, GFont const font, const GRect box, const GTextOverflowMode overflow_mode=GTextOverflowModeWordWrap, const GTextAlignment alignment=GTextAlignmentLeft) const |
void | DrawText (const std::string &text, GFont const font, const GRect box, const GTextOverflowMode overflow_mode, const GTextAlignment alignment, const GTextAttributes &text_attributes) const |
void | DrawPixel (GPoint point) const |
void | DrawLine (GPoint p0, GPoint p1) const |
void | DrawRect (GRect rect) const |
void | FillRect (GRect rect, uint16_t corner_radius, GCornerMask corner_mask) const |
void | DrawCircle (GPoint p, uint16_t radius) const |
void | FillCircle (GPoint p, uint16_t radius) const |
void | DrawRoundRect (GRect rect, uint16_t radius) const |
void | DrawBitmapInRect (const GBitmap &bitmap, GRect rect) const |
GBitmap | CaptureFrameBuffer () |
A shortcut to capture the framebuffer in the native format of the watch. | |
GBitmap | CaptureFrameBuffer (GBitmapFormat format) |
bool | ReleaseFrameBuffer (const GBitmap &buffer) |
bool | FrameBufferIsCaptured () |
void | DrawRotatedBitmap (const GBitmap &src, GPoint src_ic, int rotation, GPoint dest_ic) const |
void | DrawArc (GRect rect, GOvalScaleMode scale_mode, int32_t angle_start, int32_t angle_end) const |
void | FillRadial (GRect rect, GOvalScaleMode scale_mode, uint16_t inset_thickness, int32_t angle_start, int32_t angle_end) const |
Static Public Member Functions | |
static GSize | GetContentSize (const char *text, GFont const font, const GRect box, const GTextOverflowMode overflow_mode=GTextOverflowModeWordWrap, const GTextAlignment alignment=GTextAlignmentLeft) |
static GSize | GetContentSize (const char *text, GFont const font, const GRect box, const GTextOverflowMode overflow_mode, const GTextAlignment alignment, const GTextAttributes &text_attributes) |
static GSize | GetContentSize (const std::string &text, GFont const font, const GRect box, const GTextOverflowMode overflow_mode=GTextOverflowModeWordWrap, const GTextAlignment alignment=GTextAlignmentLeft) |
static GSize | GetContentSize (const std::string &text, GFont const font, const GRect box, const GTextOverflowMode overflow_mode, const GTextAlignment alignment, const GTextAttributes &text_attributes) |
Protected Attributes | |
::GContext * | gcontext_ |
|
inline |
Captures the frame buffer for direct access, using the given format. Graphics functions will not affect the frame buffer while it is captured. The frame buffer is released when ReleaseFrameBuffer is called. The frame buffer must be released before the end of a layer's .update_proc
for the layer to be drawn properly.
While the frame buffer is captured calling CaptureFrameBuffer will fail and return and invalid GBitmap
ctx | The graphics context providing the frame buffer |
format | The format in which the framebuffer should be captured. Supported formats are GBitmapFormat1Bit and GBitmapFormat8Bit. |
|
inline |
Draws a line arc clockwise between angle_start
and angle_end
, where 0° is the top of the circle. If the difference between angle_start
and angle_end
is greater than 360°, a full circle will be drawn.
rect | The reference rectangle to derive the center point and radius (see scale_mode). |
scale_mode | Determines how rect will be used to derive the center point and radius. |
angle_start | Radial starting angle. Use DEG_TO_TRIGANGLE to easily convert degrees to the appropriate value. |
angle_end | Radial finishing angle. If smaller than angle_start , nothing will be drawn. |
Draws a bitmap into the graphics context, inside the specified rectangle
bitmap | The bitmap to draw |
rect | The rectangle in which to draw the bitmap |
rect
is smaller than the size of the bitmap, the bitmap will be clipped on right and bottom edges. If the size of rect
is larger than the size of the bitmap, the bitmap will be tiled automatically in both horizontal and vertical directions, effectively drawing a repeating pattern.
|
inline |
Draws the outline of a circle in the current stroke color
p | The center point of the circle |
radius | The radius in pixels |
Draws line in the current stroke color, current stroke width and AA flag
p0 | The starting point of the line |
p1 | The ending point of the line |
|
inline |
Draws a pixel at given point in the current stroke color
point | The point at which to draw the pixel |
|
inline |
Draws a 1-pixel wide rectangle outline in the current stroke color
rect | The rectangle for which to draw the outline |
|
inline |
Draws a rotated bitmap with a memory-sensitive 2x anti-aliasing technique (using ray-finding instead of super-sampling), which is thresholded into a b/w bitmap for 1-bit and color blended for 8-bit.
src | The source bitmap to draw |
src_ic | Instance center (single point unaffected by rotation) relative to source bitmap |
rotation | Angle of rotation. Rotation is an integer between 0 (no rotation) and TRIG_MAX_ANGLE (360 degree rotation). Use DEG_TO_TRIGANGLE to easily convert degrees to the appropriate value. |
dest_ic | Where to draw the instance center of the rotated bitmap in the context. |
|
inline |
Draws the outline of a rounded rectangle in the current stroke color
rect | The rectangle defining the dimensions of the rounded rectangle to draw |
radius | The corner radius in pixels |
|
inline |
Draw text into the current graphics context, using the context's current text color. The text will be drawn inside a box with the specified dimensions and configuration, with clipping occuring automatically.
text | The zero terminated UTF-8 string to draw |
font | The font in which the text should be set |
box | The bounding box in which to draw the text. The first line of text will be drawn against the top of the box. |
overflow_mode | The overflow behavior, in case the text is larger than what fits inside the box. |
alignment | The horizontal alignment of the text |
text_attributes | Optional text attributes to describe the characteristics of the text |
|
inline |
Draw text into the current graphics context, using the context's current text color. The text will be drawn inside a box with the specified dimensions and configuration, with clipping occuring automatically.
text | The zero terminated UTF-8 string to draw |
font | The font in which the text should be set |
box | The bounding box in which to draw the text. The first line of text will be drawn against the top of the box. |
overflow_mode | The overflow behavior, in case the text is larger than what fits inside the box. |
alignment | The horizontal alignment of the text |
|
inline |
Draw text into the current graphics context, using the context's current text color. The text will be drawn inside a box with the specified dimensions and configuration, with clipping occuring automatically.
text | The zero terminated UTF-8 string to draw |
font | The font in which the text should be set |
box | The bounding box in which to draw the text. The first line of text will be drawn against the top of the box. |
overflow_mode | The overflow behavior, in case the text is larger than what fits inside the box. |
alignment | The horizontal alignment of the text |
text_attributes | Optional text attributes to describe the characteristics of the text |
|
inline |
Draw text into the current graphics context, using the context's current text color. The text will be drawn inside a box with the specified dimensions and configuration, with clipping occuring automatically.
text | The zero terminated UTF-8 string to draw |
font | The font in which the text should be set |
box | The bounding box in which to draw the text. The first line of text will be drawn against the top of the box. |
overflow_mode | The overflow behavior, in case the text is larger than what fits inside the box. |
alignment | The horizontal alignment of the text |
|
inline |
Fills a circle in the current fill color
p | The center point of the circle |
radius | The radius in pixels |
|
inline |
Fills a circle clockwise between angle_start
and angle_end
, where 0° is the top of the circle. If the difference between angle_start
and angle_end
is greater than 360°, a full circle will be drawn and filled. If angle_start
is greater than angle_end
nothing will be drawn.
inset_thickness
to a non-zero value (such as 30) this example will produce the letter C. rect | The reference rectangle to derive the center point and radius (see scale). |
scale_mode | Determines how rect will be used to derive the center point and radius. |
inset_thickness | Describes how thick in pixels the radial will be drawn towards its center measured from the outside. |
angle_start | Radial starting angle. Use DEG_TO_TRIGANGLE to easily convert degrees to the appropriate value. |
angle_end | Radial finishing angle. If smaller than angle_start , nothing will be drawn. |
|
inline |
Fills a rectangle with the current fill color, optionally rounding all or a selection of its corners.
ctx | The destination graphics context in which to draw |
rect | The rectangle to fill |
corner_radius | The rounding radius of the corners in pixels (maximum is 8 pixels) |
corner_mask | Bitmask of the corners that need to be rounded. |
|
inline |
Whether or not the frame buffer has been captured by graphics_capture_frame_buffer. Graphics functions will not affect the frame buffer until it has been released by graphics_release_frame_buffer.
|
inlinestatic |
Obtain the maximum size that a text with given font, overflow mode and alignment occupies within a given rectangular constraint.
text | The zero terminated UTF-8 string for which to calculate the size |
font | The font in which the text should be set while calculating the size |
box | The bounding box in which the text should be constrained |
overflow_mode | The overflow behavior, in case the text is larger than what fits inside the box. |
alignment | The horizontal alignment of the text |
text_attributes | Optional text attributes to describe the characteristics of the text |
|
inlinestatic |
Obtain the maximum size that a text with given font, overflow mode and alignment occupies within a given rectangular constraint.
text | The zero terminated UTF-8 string for which to calculate the size |
font | The font in which the text should be set while calculating the size |
box | The bounding box in which the text should be constrained |
overflow_mode | The overflow behavior, in case the text is larger than what fits inside the box. |
alignment | The horizontal alignment of the text |
|
inlinestatic |
Obtain the maximum size that a text with given font, overflow mode and alignment occupies within a given rectangular constraint.
text | The zero terminated UTF-8 string for which to calculate the size |
font | The font in which the text should be set while calculating the size |
box | The bounding box in which the text should be constrained |
overflow_mode | The overflow behavior, in case the text is larger than what fits inside the box. |
alignment | The horizontal alignment of the text |
text_attributes | Optional text attributes to describe the characteristics of the text |
|
inlinestatic |
Obtain the maximum size that a text with given font, overflow mode and alignment occupies within a given rectangular constraint.
text | The zero terminated UTF-8 string for which to calculate the size |
font | The font in which the text should be set while calculating the size |
box | The bounding box in which the text should be constrained |
overflow_mode | The overflow behavior, in case the text is larger than what fits inside the box. |
alignment | The horizontal alignment of the text |
|
inline |
Releases the frame buffer. Must be called before the end of a layer's .update_proc
for the layer to be drawn properly.
If buffer
does not point to the address previously returned by graphics_capture_frame_buffer the frame buffer will not be released.
buffer | The frame buffer bitmap |
|
inline |
Sets whether antialiasing is applied to stroke drawing
enable | True = antialiasing enabled, False = antialiasing disabled |
|
inline |
Sets the current bitmap compositing mode of the graphics context.
mode | The new compositing mode |
|
inline |
Sets the current fill color of the graphics context.
color | The new fill color |
|
inline |
Sets the current stroke color of the graphics context.
color | The new stroke color |
|
inline |
Sets the width of the stroke for drawing routines
stroke_width | Width in pixels of the stroke. |
|
inline |
Sets the current text color of the graphics context.
color | The new text color |