51#include <mcp/syscalls.h>
59#define WIN_DEFAULT_WIDTH 512
60#define WIN_DEFAULT_HEIGHT 342
61#define WIN_DEFAULT_MIN_WIDTH 90
62#define WIN_DEFAULT_MIN_HEIGHT 60
63#define WIN_DEFAULT_MAX_WIDTH 800
64#define WIN_DEFAULT_MAX_HEIGHT 600
66#define WIN_DEFAULT_DRAG_ZONE_SIZE 3
68#define WIN_DEFAULT_X 50
69#define WIN_DEFAULT_Y 25
70#define WIN_STAGGER_X 14
71#define WIN_STAGGER_Y 14
73#define WINDOW_MAX_WINTITLE_SIZE 128
75#define WIN_MAX_CLIP_RECTS 10
76#define WIN_MENU_MAX_GROUPS 4
78#define WIN_PARAM_OPEN_AS_BACKDROP true
79#define WIN_PARAM_DO_NOT_OPEN_AS_BACKDROP false
81#define WIN_PARAM_FORCE_CONTROL_REDRAW true
82#define WIN_PARAM_ONLY_REDRAW_INVAL_CONTROLS false
84#define WIN_PARAM_UPDATE_NORM_SIZE_TO_MATCH true
85#define WIN_PARAM_DO_NOT_UPDATE_NORM_SIZE false
92typedef enum window_type
100typedef enum window_state
109typedef enum window_base_control_id
112 MINIMIZE_WIDGET_ID = 1,
113 NORM_SIZE_WIDGET_ID = 2,
114 MAXIMIZE_WIDGET_ID = 3,
115 MAX_BUILT_IN_WIDGET = 4,
116} window_base_control_id;
137 int8_t display_order_;
166 bool changes_to_save_;
169 bool titlebar_invalidated_;
180 int16_t norm_height_;
185 int16_t inner_width_;
186 int16_t inner_height_;
187 int16_t avail_title_width_;
188 int16_t content_left_;
189 int16_t content_top_;
190 int16_t required_inner_width_;
191 int16_t required_inner_height_;
192 bool h_scroller_visible_;
193 bool v_scroller_visible_;
199 Rectangle clip_rect_[WIN_MAX_CLIP_RECTS];
202 int16_t damage_count_;
204 Menu* menu_[WIN_MENU_MAX_GROUPS];
205 int16_t current_menu_level_;
359Control*
Window_AddNewControl(
Window* the_window,
control_type the_type, int16_t width, int16_t height, int16_t x_offset, int16_t y_offset, h_align_type the_h_align, v_align_type the_v_align,
char* the_caption, int16_t the_id, int16_t group_id);
626bool Window_Blit(
Window* the_window,
Bitmap* src_bm, int16_t src_x, int16_t src_y, int16_t width, int16_t height);
658bool Window_DrawLine(
Window* the_window, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint8_t the_color);
698bool Window_DrawBox(
Window* the_window, int16_t width, int16_t height, uint8_t the_color,
bool do_fill);
708bool Window_DrawRoundBox(
Window* the_window, int16_t width, int16_t height, int16_t radius, uint8_t the_color,
bool do_fill);
722bool Window_DrawString(
Window* the_window,
char* the_string, int16_t max_chars);
735char*
Window_DrawStringInBox(
Window* the_window, int16_t width, int16_t height,
char* the_string, int16_t num_chars,
char** wrap_buffer,
bool (* continue_function)(
void));
745void Window_PrintBrief(
void* the_payload);
control_type
Definition: control.h:83
This structure describes an instantiated control on a window.
Definition: control.h:130
A structure that can be used to instantiate a ControlTemplate object instance in a window The Control...
Definition: control_template.h:69
This Font object is essentially the Mac "fontRecord" struct, with added pointers for the data tables.
Definition: font.h:71
Definition: a2560k.h:1369
bool Window_SetPixel(Window *the_window, uint8_t the_color)
Set the color of the pixel at the current pen location.
Definition: window.c:2813
char * Window_GetTitle(Window *the_window)
Get a pointer to the current window title Note: It is not guaranteed that every window will have a ti...
Definition: window.c:2321
void Window_Invalidate(Window *the_window)
Mark entire window as invalidated This will cause it to be redrawn and fully reblitted in the next re...
Definition: window.c:1885
window_type Window_GetType(Window *the_window)
Get the window's type (normal, backdrop, dialog, etc.)
Definition: window.c:2360
bool Window_AddClipRect(Window *the_window, Rectangle *new_rect)
Copy the passed rectangle to the window's clip rect collection If the window already has the maximum ...
Definition: window.c:1088
window_state Window_GetState(Window *the_window)
Get the window's state (maximized, minimized, etc.)
Definition: window.c:2379
bool Window_DrawBox(Window *the_window, int16_t width, int16_t height, uint8_t the_color, bool do_fill)
Draws a rectangle based on start coords and width/height, and optionally fills the rectangle.
Definition: window.c:2971
bool Window_DrawRoundBox(Window *the_window, int16_t width, int16_t height, int16_t radius, uint8_t the_color, bool do_fill)
Draws a rounded rectangle from the current pen location, with the specified size and radius,...
Definition: window.c:2995
bool Window_IsActive(Window *the_window)
Get the active/inactive condition of the window.
Definition: window.c:2533
Control * Window_GetLastControl(Window *the_window)
Find and return the last control in the window's chain of controls This corresponds to the first cont...
Definition: window.c:1589
int16_t Window_GetControlID(Window *the_window, Control *the_control)
Return the ID of the control passed, if the window actually owns that control NOTE: Control IDs 0-3 a...
Definition: window.c:1659
bool Window_SetPenXY(Window *the_window, int16_t x, int16_t y)
Set the "pen" position within the content area This also sets the pen position of the window's bitmap...
Definition: window.c:2690
NewWinTemplate * Window_GetNewWinTemplate(char *the_win_title)
Allocate and populate a new window template object Assigns (but does not copy) the passed title strin...
Definition: window.c:1038
bool Window_FillBox(Window *the_window, int16_t width, int16_t height, uint8_t the_color)
Fill a rectangle drawn from the current pen location, for the passed width/height.
Definition: window.c:2761
Control * Window_AddNewControlFromTemplate(Window *the_window, ControlTemplate *the_template, int16_t the_id, int16_t group_id)
Instantiate a new control from the passed template, and add it to the window's list of controls.
Definition: window.c:1433
bool Window_GenerateDamageRects(Window *the_window, Rectangle *the_old_rect)
Calculate damage rects, if any, caused by window moving or being resized NOTE: it is not necessarily ...
Definition: window.c:1213
bool Window_SetFont(Window *the_window, Font *the_font)
Set the font This is the font that will be used for any subsequent font drawing in this Window This a...
Definition: window.c:2602
bool Window_FillBoxRect(Window *the_window, Rectangle *the_coords, uint8_t the_color)
Fill pixel values for the passed Rectangle object, using the specified LUT value.
Definition: window.c:2782
Control * Window_GetControl(Window *the_window, int16_t the_control_id)
Return a pointer to the control owned by the window that matches the specified ID NOTE: Control IDs 0...
Definition: window.c:1624
bool Window_MergeClipRects(Window *the_window)
Merge and de-duplicate clip rects Consolidating the clip rects will happen reduce unnecessary reblitt...
Definition: window.c:1137
void Window_SetState(Window *the_window, window_state the_state)
Set the window's state (maximized, minimized, etc.) NOTE: This does not immediately cause the window ...
Definition: window.c:2022
bool Window_IsBackdrop(Window *the_window)
Check if a window is a backdrop window or a regular window.
Definition: window.c:2494
void Window_ClearContent(Window *the_window)
Clears the content area rect by filling it with the theme's backcolor.
Definition: window.c:1861
bool Window_IsVisible(Window *the_window)
Check if a window should be visible or not NOTE: this does not necessarily mean the window isn't curr...
Definition: window.c:2514
void Window_SetActive(Window *the_window, bool is_active)
Set the passed window's active flag.
Definition: window.c:1995
void Window_EvaluateWindowChange(Window *the_window, int16_t *x, int16_t *y, int16_t *width, int16_t *height)
Evaluate potential change to window position or size, and correct if out of allowed limits Negative v...
Definition: window.c:2050
Bitmap * Window_GetBitmap(Window *the_window)
Get the bitmap object used as the offscreen buffer for the window NOTE: this is not a pointer into VR...
Definition: window.c:2399
bool Window_SetPenXYFromGlobal(Window *the_window, int16_t x, int16_t y)
Set the local "pen" position within the window, based on global coordinates This also sets the pen po...
Definition: window.c:2660
MouseMode Window_CheckForDragZone(Window *the_window, int16_t x, int16_t y)
Checks if the passed coordinate is within one of the draggable event zones Draggable event zones incl...
Definition: window.c:1301
void Window_SetVisible(Window *the_window, bool is_visible)
Set the window's visibility flag.
Definition: window.c:1950
bool Window_DrawBoxCoords(Window *the_window, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint8_t the_color)
Draws a rectangle based on 2 sets of coords, using the specified LUT value.
Definition: window.c:2942
void Window_NormSize(Window *the_window)
Set the window to normal size (window-size mode) Sets window's x, y, width, height parameters to thos...
Definition: window.c:2229
bool Window_SetColor(Window *the_window, uint8_t the_color)
Set the "pen" color This is the color that the next pen-based graphics function will use This also se...
Definition: window.c:2634
bool Window_BlitClipRects(Window *the_window)
Blit each clip rect to the screen, and clear all clip rects when done This is the actual mechanics of...
Definition: window.c:1157
bool Window_DrawHLine(Window *the_window, int16_t the_line_len, uint8_t the_color)
Draws a horizontal line from the current pen location, for n pixels, using the specified pixel value.
Definition: window.c:2865
bool Window_DrawBoxRect(Window *the_window, Rectangle *the_coords, uint8_t the_color)
Draws a rectangle based on the passed Rectangle object, using the specified LUT value.
Definition: window.c:2907
bool Window_Destroy(Window **the_window)
Definition: window.c:999
int16_t Window_GetHeight(Window *the_window)
Get the height of the window.
Definition: window.c:2475
bool Window_DrawCircle(Window *the_window, int16_t radius, uint8_t the_color)
Draw a circle centered on the current pen location Based on http://rosettacode.org/wiki/Bitmap/Midpoi...
Definition: window.c:3016
bool Window_AddControl(Window *the_window, Control *the_control)
Adds the passed control to the window's list of controls.
Definition: window.c:1392
void Window_InvalidateControlByID(Window *the_window, uint16_t the_control_id)
Invalidate the control matching the ID passed.
void Window_UpdateTheme(Window *the_window)
Updates the current window controls, etc., to match the current system theme.
Definition: window.c:1829
void Window_SetDisplayOrder(Window *the_window, int8_t the_display_order)
Set the display order of the window NOTE: This does not immediately re-render or change the display o...
Definition: window.c:1973
int16_t Window_GetX(Window *the_window)
Get the global horizontal coordinate of the window.
Definition: window.c:2418
Control * Window_GetControlAtXY(Window *the_window, int16_t x, int16_t y)
Find the control, if any, located at the specified local coordinates Transparency is not taken into a...
Definition: window.c:1695
bool Window_Blit(Window *the_window, Bitmap *src_bm, int16_t src_x, int16_t src_y, int16_t width, int16_t height)
Blit from source bitmap to the window's content area, at the window's current pen coordinate The sour...
Definition: window.c:2739
void Window_Minimize(Window *the_window)
Hides the window (minimize mode) Does not change the window's x, y, width, height parameters,...
Definition: window.c:2259
int16_t Window_GetY(Window *the_window)
Get the global vertical coordinate of the window.
Definition: window.c:2437
void Window_InvalidateTitlebar(Window *the_window)
Invalidate the title bar and the controls in the title bar Call when switching from inactive to activ...
Definition: window.c:1535
void Window_Render(Window *the_window)
Draw/re-draw any necessary components, and blit the window (or parts of it, via cliprects) to the scr...
Definition: window.c:1741
Control * Window_AddNewControl(Window *the_window, control_type the_type, int16_t width, int16_t height, int16_t x_offset, int16_t y_offset, h_align_type the_h_align, v_align_type the_v_align, char *the_caption, int16_t the_id, int16_t group_id)
Instantiate a new control of the type specified, and add it to the window's list of controls.
Definition: window.c:1480
int16_t Window_GetWidth(Window *the_window)
Get the width of the window.
Definition: window.c:2456
bool Window_AcceptDamageRect(Window *the_window, Rectangle *damage_rect)
Copy the passed rectangle to the window's clip rect collection, translating to local coordinates as i...
Definition: window.c:1239
bool Window_SetSelectedControl(Window *the_window, Control *the_control)
Sets the passed control as the currently selected control and unselects any previously selected contr...
Definition: window.c:1364
void Window_SetTitle(Window *the_window, char *the_title)
Replace the current window title with the passed string Note: the passed string will be copied into s...
Definition: window.c:1916
uint32_t Window_GetUserData(Window *the_window)
Get the value stored in the user data field of the window.
Definition: window.c:2341
void Window_ChangeWindow(Window *the_window, int16_t x, int16_t y, int16_t width, int16_t height, bool update_norm)
Change position and/or size of window NOTE: passed x, y will be checked against the window's min/max ...
Definition: window.c:2099
char * Window_DrawStringInBox(Window *the_window, int16_t width, int16_t height, char *the_string, int16_t num_chars, char **wrap_buffer, bool(*continue_function)(void))
Draw a string in a rectangular block on the window, with wrap.
Definition: window.c:3064
void Window_Maximize(Window *the_window)
Set the window to full-screen size (maximize mode) Sets window's x, y, width, height parameters to ma...
Definition: window.c:2197
bool Window_DrawVLine(Window *the_window, int16_t the_line_len, uint8_t the_color)
Draws a vertical line from specified coords, for n pixels.
Definition: window.c:2886
void Window_GlobalToLocal(Window *the_window, int16_t *x, int16_t *y)
Convert the passed x, y global coordinates to local (to window) coordinates.
Definition: window.c:2556
void Window_Print(Window *the_window)
Definition: window.c:752
bool Window_DrawLine(Window *the_window, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint8_t the_color)
Draws a line between 2 passed coordinates.
Definition: window.c:2838
Window * Window_New(NewWinTemplate *the_win_template, void(*event_handler)(EventRecord *))
Allocate a Window object the_win_template->width_: cannot be smaller than WIN_DEFAULT_MIN_WIDTH,...
Definition: window.c:827
Control * Window_GetSelectedControl(Window *the_window)
Get the control listed as the currently selected control.
Definition: window.c:1571
void Window_LocalToGlobal(Window *the_window, int16_t *x, int16_t *y)
Convert the passed x, y local coordinates to global coordinates.
Definition: window.c:2576