changes to fix top-window center method under Mac OS X

svn: r5226
This commit is contained in:
Matthew Flatt 2007-01-05 02:56:23 +00:00
parent 5db137cf05
commit cf4fd433c6
15 changed files with 55 additions and 26 deletions

View File

@ -113,6 +113,15 @@ static long wxWindowGetHandle(wxWindow *w)
#endif
}
static void CenterWParent(wxWindow *w, int direction, wxWindow *parent)
{
#ifdef wx_mac
w->Centre(direction, parent);
#else
w->Centre(direction);
#endif
}
static Scheme_Object *sizeMode_wxSIZE_AUTO_sym = NULL;
static Scheme_Object *sizeMode_wxSIZE_USE_EXISTING_sym = NULL;
static Scheme_Object *sizeMode_wxPOS_USE_MINUS_ONE_sym = NULL;
@ -803,24 +812,30 @@ static Scheme_Object *os_wxWindowPopupMenu(int n, Scheme_Object *p[])
return scheme_void;
}
static Scheme_Object *os_wxWindowCenter(int n, Scheme_Object *p[])
static Scheme_Object *os_wxWindowCenterWParent(int n, Scheme_Object *p[])
{
WXS_USE_ARGUMENT(n) WXS_USE_ARGUMENT(p)
REMEMBER_VAR_STACK();
objscheme_check_valid(os_wxWindow_class, "center in window%", n, p);
int x0;
class wxWindow* x1 INIT_NULLED_OUT;
SETUP_VAR_STACK_REMEMBERED(1);
SETUP_VAR_STACK_REMEMBERED(2);
VAR_STACK_PUSH(0, p);
VAR_STACK_PUSH(1, x1);
if (n > (POFFSET+0)) {
x0 = WITH_VAR_STACK(unbundle_symset_direction(p[POFFSET+0], "center in window%"));
} else
x0 = wxBOTH;
if (n > (POFFSET+1)) {
x1 = WITH_VAR_STACK(objscheme_unbundle_wxWindow(p[POFFSET+1], "center in window%", 1));
} else
x1 = NULL;
WITH_VAR_STACK(((wxWindow *)((Scheme_Class_Object *)p[0])->primdata)->Center(x0));
WITH_VAR_STACK(CenterWParent(((wxWindow *)((Scheme_Class_Object *)p[0])->primdata), x0, x1));
@ -1369,7 +1384,7 @@ void objscheme_setup_wxWindow(Scheme_Env *env)
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxWindow_class, "get-width" " method", (Scheme_Method_Prim *)os_wxWindowwxSchemeWindowGetWidth, 0, 0));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxWindow_class, "get-height" " method", (Scheme_Method_Prim *)os_wxWindowwxSchemeWindowGetHeight, 0, 0));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxWindow_class, "popup-menu" " method", (Scheme_Method_Prim *)os_wxWindowPopupMenu, 3, 3));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxWindow_class, "center" " method", (Scheme_Method_Prim *)os_wxWindowCenter, 0, 1));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxWindow_class, "center" " method", (Scheme_Method_Prim *)os_wxWindowCenterWParent, 0, 2));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxWindow_class, "get-text-extent" " method", (Scheme_Method_Prim *)os_wxWindowGetTextExtent, 3, 7));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxWindow_class, "get-parent" " method", (Scheme_Method_Prim *)os_wxWindowGetParent, 0, 0));
WITH_VAR_STACK(scheme_add_method_w_arity(os_wxWindow_class, "refresh" " method", (Scheme_Method_Prim *)os_wxWindowRefresh, 0, 0));

View File

@ -8,6 +8,7 @@ extern class wxMouseEvent *objscheme_unbundle_wxMouseEvent(Scheme_Object *, cons
extern class wxWindow *objscheme_unbundle_wxWindow(Scheme_Object *, const char *, int);
extern class wxKeyEvent *objscheme_unbundle_wxKeyEvent(Scheme_Object *, const char *, int);
extern class wxMenu *objscheme_unbundle_wxMenu(Scheme_Object *, const char *, int);
extern class wxWindow *objscheme_unbundle_wxWindow(Scheme_Object *, const char *, int);
extern class wxFont *objscheme_unbundle_wxFont(Scheme_Object *, const char *, int);
extern Scheme_Object *objscheme_bundle_wxWindow(class wxWindow *);
extern class wxCursor *objscheme_unbundle_wxCursor(Scheme_Object *, const char *, int);

View File

@ -87,6 +87,15 @@ static long wxWindowGetHandle(wxWindow *w)
#endif
}
static void CenterWParent(wxWindow *w, int direction, wxWindow *parent)
{
#ifdef wx_mac
w->Centre(direction, parent);
#else
w->Centre(direction);
#endif
}
@BEGINSYMBOLS sizeMode > ONE > PRED BUNDLE
@SYM "auto" : wxSIZE_AUTO
@SYM "use-exsiting" : wxSIZE_USE_EXISTING
@ -128,7 +137,7 @@ static long wxWindowGetHandle(wxWindow *w)
@ "refresh" : void Refresh();
@ "get-parent" : wxWindow^ GetParent();
@ "get-text-extent" : void GetTextExtent(string,double*,double*,double?=NULL,double?=NULL,wxFont^=NULL,bool=FALSE);
@ "center" : void Center(SYM[direction]=wxBOTH);
@ m "center" : void CenterWParent(SYM[direction]=wxBOTH, wxWindow^=NULL);
@ "popup-menu" : void PopupMenu(wxMenu!, rint[0|10000], rint[0|10000]);

View File

@ -38,7 +38,7 @@ class wxbDialogBox: public wxFrame
virtual void Iconize(Bool iconize) = 0;
virtual Bool Iconized(void) = 0;
void Centre(int direction = wxBOTH);
void Centre(int direction = wxBOTH, wxWindow *parent = NULL);
};
#define wxOPEN 1

View File

@ -75,7 +75,7 @@ class wxbFrame: public wxWindow
virtual void SetStatusText(char *text, int number = 0) = 0;
virtual Bool StatusLineExists(void);
void Centre(int direction = wxBOTH);
void Centre(int direction = wxBOTH, wxWindow *parent = NULL);
// Iconize
virtual void Iconize(Bool iconize) = 0;

View File

@ -48,7 +48,7 @@ class wxbItem: public wxWindow
virtual void ProcessCommand(wxCommandEvent *event); // Calls the callback and
// Places item in centre of panel - so can't be used BEFORE panel->Fit()
void Centre(int direction = wxHORIZONTAL);
void Centre(int direction = wxHORIZONTAL, wxWindow *p = NULL);
};
#endif // IN_CPROTO

View File

@ -126,13 +126,10 @@ class wxbWindow: public wxObject
virtual void SetName(char *name);
inline virtual void Fit(void) {}; // Size window to fit contents
inline virtual void Centre(int direction) {}; // Centre item on panel,
// or frame on screen
inline virtual void Centre(int direction = wxBOTH, wxWindow *parent = NULL) {};
// Renamed from GetWindowStyle since it clashed with a
// macro in windowsx.h.
inline long GetWindowStyleFlag(void) { return windowStyle; }
// A concession to our friends across the pond
inline void Center(int direction = wxHORIZONTAL) { Centre(direction); }
inline virtual void EnablePainting(Bool enable) { paintingEnabled = enable; }

View File

@ -65,7 +65,7 @@ public:
Bool OnClose(void);
virtual void Fit(void);
virtual void Centre(int d) { cFrame->Centre(d); }
virtual void Centre(int d = wxBOTH, wxWindow *p = NULL) { cFrame->Centre(d, p); }
void SetIcon(wxBitmap* icon) { cFrame->SetIcon(icon); }
void Iconize(Bool iconize) { cFrame->Iconize(iconize); }

View File

@ -116,7 +116,7 @@ public:
// Sizing methods
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
void DoSetSize(int x, int y, int width, int height);
void Centre(int direction);
void Centre(int direction = wxBOTH, wxWindow *p = NULL);
void Fit(void);
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

View File

@ -84,8 +84,8 @@ wxbDialogBox::~wxbDialogBox()
tlw->DeleteObject(this);
}
void wxbDialogBox::Centre(int direction)
void wxbDialogBox::Centre(int direction, wxWindow *p)
{
((wxDialogBox *)this)->cFrame->Centre(direction);
((wxDialogBox *)this)->cFrame->Centre(direction, p);
}

View File

@ -133,20 +133,27 @@ Bool wxbFrame::StatusLineExists(void)
return status_line_exists;
}
void wxbFrame::Centre(int direction)
void wxbFrame::Centre(int direction, wxWindow *parent)
{
int display_width, display_height, width, height, x, y;
wxDisplaySize(&display_width, &display_height);
int display_width, display_height, width, height, x, y, offset_x, offset_y;
if (parent) {
parent->GetSize(&display_width, &display_height);
parent->GetPosition(&offset_x, &offset_y);
} else {
wxDisplaySize(&display_width, &display_height);
offset_x = offset_y = 0;
}
GetSize(&width, &height);
GetPosition(&x, &y);
if (direction & wxHORIZONTAL)
x = (int)((display_width - width)/2);
if (direction & wxVERTICAL)
y = (int)((display_height - height)/2);
SetSize(x, y, width, height, wxPOS_USE_MINUS_ONE);
SetSize(x + offset_x, y + offset_y, width, height, wxPOS_USE_MINUS_ONE);
}
// Call this to simulate a menu command

View File

@ -170,7 +170,7 @@ wxbItem::~wxbItem (void)
}
}
void wxbItem::Centre (int direction)
void wxbItem::Centre (int direction, wxWindow *)
{
int x, y, width, height, panel_width, panel_height, new_x, new_y;
wxPanel *panel;

View File

@ -180,7 +180,7 @@ static wxFrame *make_dlog_frame(wxWindow *parentFrame, char *windowTitle, int x,
//-----------------------------------------------------------------------------
wxDialogBox::wxDialogBox // Constructor (for dialog window)
(
wxWindow* parentFrame, // this is ignored, used to be wxFrame*
wxWindow* parentFrame,
char* windowTitle,
Bool modal,
int x,

View File

@ -60,7 +60,7 @@ static ControlUserPaneDrawUPP userPaneDrawFunctionUPP = NewControlUserPaneDrawUP
//-----------------------------------------------------------------------------
wxFrame::wxFrame // Constructor (for frame window)
(
wxFrame* parentFrame, // this is ignored
wxFrame* parentFrame,
char* windowTitle,
int x,
int y,

View File

@ -264,7 +264,7 @@ void wxPanel::DoSetSize(int x, int y, int width, int height)
//-----------------------------------------------------------------------------
void wxPanel::Centre(int direction)
void wxPanel::Centre(int direction, wxWindow *)
{
int width, height, panel_width, panel_height, new_x, new_y;
wxPanel* father;