/* Sun-$Revision: 23.3 $ */
/* Copyright 1998-9 Sun Microsystems, Inc.
See the LICENSE file for license information. */
// Contains platform-specific declarations for PlatformWindow.
// This file is included into middle of class declaration.
protected:
// State:
WindowPtr _mac_window; // MacOS window pointer
bool _is_open;
FontInfo* _font_info;
short _font_family_id;
short _font_size;
// For saving/restoring state across pre_/post_ redraw
// These may not be strictly necessary
WindowPtr _old_port;
short _old_font_family_id;
short _old_font_size;
public:
// On Mac, can get fiont info before opening a window.
// Returns true if succeeds.
static bool get_font_info(
/* in params: */ char* font_name, int font_size,
/* out params: */ FontInfo* font_info, short& font_family);
// Mac-specific open call:
// values for behind parameter in platform-specific open below
static WindowPtr behind_all() { return NULL; }
static WindowPtr front() { return (WindowPtr)-1; }
/*
* ProcID's:
documentProc = 0; {standard document }
{ window, no zoom box}
dBoxProc = 1; {alert box or modal }
{ dialog box}
plainDBox = 2; {plain box}
altDBoxProc = 3; {plain box with shadow}
noGrowDocProc = 4; {movable window, }
{ no size box or zoom box}
movableDBoxProc = 5; {movable modal dialog box}
zoomDocProc = 8; {standard document window}
zoomNoGrow = 12; {zoomable, nonresizable }
{ window}
rDocProc = 16; {rounded-corner window}
*/
virtual bool open(
short procID = 0,
int left = 100,
int top = 100,
int right = 200,
int bottom = 200,
char* title = "",
bool visible = true,
void* behind = front(), /* void* is really WindowPtr*/
bool has_close_box = true,
char* font_name = "Monaco",
int font_size = 10 );
// Accessors:
GDHandle screen();
GDPtr screen_pointer(); // not the handle, but the pointer
WindowPtr mac_window() { return _mac_window; }
// Event helpers: convert from WindowPtr or events to my address
static PlatformWindow* as_win(const WindowPtr);
static PlatformWindow* as_win(const EventRecord*);
// Events: (sent from os_mac.c)
virtual void handle_update_event( EventRecord*);
virtual void handle_activate_event( EventRecord*);
virtual void handle_misc_event( EventRecord*);
virtual void mouse_down_in_content_region( EventRecord*);
virtual void mouse_down_in_drag_bar( EventRecord*);
virtual void mouse_down_in_grow_box( EventRecord*);
virtual void zoom(int winPart);
protected:
// Drawing helpers:
void set_port(), reset_port();
// Layout helpers:
static const int min_doc_size = 64, max_doc_size = (1 << 15) - 1, control_size = 15, scroll_bar_width = 16;
int inset_border(); // window border thickness
Rect global_portRect();
// Event helpers:
virtual void get_growth_limit(Rect*);
virtual void calculate_zoom_out_rect(Rect*);
// Must track all window pointers because can get events for other windows;
// So, implement a window set:
class WindowSet /* AllStatic */ {
static const int _max_windows = 100;
static WindowPtr _my_windows[_max_windows];
static int _num_windows;
public:
static void add_window(WindowPtr);
static void rm_window(WindowPtr);
static bool includes_window(WindowPtr);
};
public:
int events_pending(void* FH);
EventRecord* next_event(void* FH);
EventRecord* peek_event(void* FH);
void put_event(EventRecord* e);
protected:
EventQueue* _evtQ;