Back to index

plt-scheme  4.2.1
Window.h
Go to the documentation of this file.
00001 /*                                                      -*- C++ -*-
00002  *
00003  * Purpose: base class for all windows
00004  *
00005  * Authors: Markus Holzem and Julian Smart
00006  *
00007  * Copyright: (C) 2004-2009 PLT Scheme Inc.
00008  * Copyright: (C) 1995, AIAI, University of Edinburgh (Julian)
00009  * Copyright: (C) 1995, GNU (Markus)
00010  *
00011  * This program is free software; you can redistribute it and/or modify
00012  * it under the terms of the GNU General Public License as published by
00013  * the Free Software Foundation; either version 2 of the License, or
00014  * (at your option) any later version.
00015  *
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00024  * 02110-1301 USA.
00025  */
00026 
00027 #ifndef Window_h
00028 #define Window_h
00029 
00030 #ifdef __GNUG__
00031 #pragma interface
00032 #endif
00033 
00034 #ifdef Have_Xt_Types
00035 class wxWindow_Xintern : public gc {
00036 public:
00037     Widget      frame;                    // frame widgets
00038     Widget      scroll;                   // optional scrollable widget
00039     Widget      handle;                   // X implementation of functionality
00040     Widget        extra;
00041     Region      expose_region;            // exposed region
00042     XEvent*     expose_event;                    // expose event 
00043     EventMask   translations_eventmask;   // events selected by widget-translations
00044     unsigned long last_clicktime;         // last time and button to compute
00045     unsigned int  last_clickbutton;              //   if a double click has arrived
00046 #ifndef NO_XMB_LOOKUP_STRING
00047     XIC ic;
00048     XIC us_ic;
00049     XIM im;
00050 #endif
00051 };
00052 #else
00053 class wxWindow_Xintern;
00054 #endif
00055 
00056 class wxBitmap;
00057 class wxColour;
00058 class wxColourMap;
00059 class wxCommandEvent;
00060 class wxCursor;
00061 class wxFont;
00062 class wxKeyEvent;
00063 class wxLayoutConstraints;
00064 class wxList;
00065 class wxMenu;
00066 class wxMouseEvent;
00067 class wxPanel;
00068 
00069 class wxWindow : public wxEvtHandler {
00070 public:
00071     wxWindow(void);
00072     ~wxWindow(void);
00073 
00074     // access to X private data
00075     wxWindow_Xintern *GetHandle(void) { return X; }
00076     // child - parent relationships
00077     wxChildList *GetChildren(void) { return children; }
00078     wxWindow  *GetGrandParent(void);
00079     wxWindow  *GetParent(void) { return parent; }
00080     void      AddChild(wxWindow *child);
00081     void      DestroyChildren(void);
00082     void      RemoveChild(wxWindow *child);
00083     // label, name, title of wxWindow
00084     virtual char  *GetLabel(void);
00085     virtual char  *GetName(void);
00086     virtual char  *GetTitle(void);
00087     virtual void  SetLabel(char *label);
00088     virtual void  SetName(char *name);
00089     virtual void  SetTitle(char *title);
00090     // set & query size and position of wxWindow
00091     virtual void  Centre(int direction = wxBOTH);
00092     virtual void  ClientToScreen(int *x, int *y);
00093     virtual void  Configure(int x, int y, int width, int height, int flags);
00094     virtual void  GetClientSize(int *width, int *height);
00095     virtual void  GetPosition(int *x, int *y);
00096     virtual void  GetSize(int *width, int *height);
00097     virtual void  GetRefreshSize(int *w, int *h);
00098     virtual void  Move(int x, int y)
00099        { SetSize(x, y, -1, -1, wxSIZE_USE_EXISTING | wxPOS_USE_MINUS_ONE); }
00100     virtual void  ScreenToClient(int *x, int *y);
00101     virtual void  SetClientSize(int width, int height)
00102        { SetSize(width, height); }
00103     virtual void  SetSize(int x, int y, int width, int height, int flags=wxSIZE_AUTO);
00104     virtual void  SetSize(int width, int height)
00105        { SetSize(-1, -1, width, height, wxSIZE_USE_EXISTING); }
00106     // GDI (colours, colourmap, font, cursor)
00107     virtual void      GetTextExtent(const char *string, double *x, double *y,
00108                                 double *descent = NULL,
00109                                 double *externalLeading = NULL,
00110                                 wxFont *theFont = NULL, Bool use16bit=FALSE);
00111     virtual wxCursor  *SetCursor(wxCursor *cursor);
00112     // Caret
00113     virtual void  CreateCaret(int WXUNUSED(w), int WXUNUSED(h)) {};
00114     virtual void  CreateCaret(wxBitmap *WXUNUSED(bitmap)) {};
00115     virtual void  DestroyCaret(void) {};
00116     virtual void  ShowCaret(Bool WXUNUSED(show)) {};
00117     virtual void  SetCaretPos(int WXUNUSED(x), int WXUNUSED(y)) {};
00118     virtual void  GetCaretPos(int *WXUNUSED(x), int *WXUNUSED(y)) {};
00119     // Scrolling
00120     virtual void  EnableScrolling(Bool x, Bool y);
00121     virtual int   GetScrollPos(int orient);
00122     virtual int   GetScrollRange(int orient);
00123     virtual int   GetScrollPage(int orient);
00124     virtual void  Scroll(int x_pos, int y_pos);
00125     virtual void  SetScrollArea(int hsize, int vsize);
00126     virtual void  SetScrollPos(int orient, int pos);
00127     virtual void  SetScrollRange(int orient, int range);
00128     virtual void  SetScrollPage(int orient, int range);
00129     // layout
00130     virtual wxLayoutConstraints *GetConstraints(void)
00131         { return constraints; }
00132     virtual void SetConstraints(wxLayoutConstraints *constr);
00133     virtual void Layout(void);
00134     // miscellaneous
00135     virtual void  AllowDoubleClick(Bool allow) { allow_dclicks = allow; }
00136     virtual void  CaptureMouse(void);
00137     virtual void  DragAcceptFiles(Bool accept);
00138     virtual void  Enable(Bool enable);
00139     virtual void  EnablePainting(Bool enable) { painting_enabled = enable; }
00140     virtual void  Fit(void) {}
00141     virtual Bool  GetUserEditMode(void) { return user_edit_mode; }
00142     virtual long  GetWindowStyleFlag(void) { return style; }
00143     virtual void  Paint(void) { OnPaint(); }
00144     virtual Bool  PopupMenu(wxMenu *menu, double x, double y, Bool for_choice = 0, int top_extra = 0);
00145     virtual void  Refresh(void);
00146     virtual void  ReleaseMouse(void);
00147     virtual void  SetFocus(void);
00148     virtual Bool  WantsFocus(void);
00149     virtual void  SetUserEditMode(Bool edit) { user_edit_mode = edit; }
00150     virtual Bool  Show(Bool show);
00151     // event handling
00152     virtual void OnChar(wxKeyEvent* event);
00153     virtual void OnCommand(wxWindow* win, wxCommandEvent* event);
00154     virtual void OnEvent(wxMouseEvent* event);
00155     virtual void OnPaint(void);
00156     virtual void OnScroll(wxScrollEvent* event);
00157     virtual Bool PreOnChar(wxWindow *, wxKeyEvent *);
00158     virtual Bool PreOnEvent(wxWindow *, wxMouseEvent *);
00159     // get the associated device context
00160     wxWindowDC* GetDC(void);
00161 
00162     void MakeModal(int on);
00163     void InternalEnable(Bool enable, Bool gray = FALSE);
00164     virtual void ChangeToGray(Bool gray);
00165     void ReleaseFocus();
00166     virtual void ReleaseAllFocus();
00167     Bool IsGray(void);
00168 
00169     Bool IsShown(void);
00170     void SetShown(Bool shown);
00171 
00172     void      ForEach(void (*foreach)(wxWindow *w, void *data), void *data);
00173 
00174     Bool GetsFocus(void) { return TRUE; }
00175 
00176     wxWindow **GetWinSafeRef() { return saferef; }
00177 
00178     wxFont *GetFont() { return font; }
00179 
00180     long GetWindowHandle();
00181 
00182 protected:
00183     // create and destroy associated device context
00184     void CreateDC(void);
00185     void DestroyDC(void);
00186     // applies event handlers to window
00187     void AddEventHandlers(void);
00188     Bool CallPreOnChar(wxWindow *, wxKeyEvent *);
00189     Bool CallPreOnEvent(wxWindow *, wxMouseEvent *);
00190 #   ifdef Have_Xt_Types
00191     // event handlers to care for incoming events
00192     static void ExposeEventHandler(Widget w, wxWindow **win, XtPointer p_XfwfExposeInfo);
00193     static void FrameEventHandler(Widget w,   wxWindow **win,
00194                               XEvent *ev, Boolean *continue_to_dispatch_return);
00195     static void WindowEventHandler(Widget w,   wxWindow **win,
00196                                XEvent *ev, Boolean *continue_to_dispatch_return);
00197     static void ScrollEventHandler(Widget w, wxWindow **win, XtPointer p_XfwfScrollInfo);
00198     static Status LookupKey(int unshifted, int unalted, int caps_mode,
00199                             Widget w, wxWindow *win, XEvent *xev, KeySym *_keysym, char *s, int *_len);
00200     void RegisterAll(Widget ww);
00201     wxWindow *FindChildByWidget(Widget w);
00202 #   endif
00203 protected:
00204     friend void wxXSetBusyCursor(wxWindow *, wxCursor *);
00205     friend void wxXSetNoCursor(wxWindow *, wxCursor *);
00206     // X representation
00207     wxWindow_Xintern *X;
00208     // device context
00209     wxWindowDC *dc;
00210     // child <-> parent relationsship
00211     wxWindow *parent;
00212     wxChildList   *children;
00213     // GDI objects
00214     wxColourMap *cmap;
00215     wxCursor    *cursor;
00216     wxFont      *font;
00217     // layout information
00218     wxLayoutConstraints  *constraints;
00219     int                  xoff, yoff;
00220     // misc info
00221     Bool  allow_dclicks;
00222     Bool  captured;
00223     Bool  drag_accept;
00224     Bool  painting_enabled;
00225     Bool  user_edit_mode;
00226     long  style;
00227 
00228     wxWindow **saferef; /* indirection for safety in callbacks */
00229 
00230   wxWindow *dndTarget; /* set between XdndPosition and XdndDrop/XdndLeave */
00231 
00232     long misc_flags;
00233 
00234     unsigned long current_state;
00235 
00236     short internal_disabled;
00237     short internal_gray_disabled;
00238 
00239     /* For scrolling with explicit control: */ 
00240     long hs_pos, vs_pos, hs_page, vs_page, hs_width, vs_width;
00241 
00242     static void FocusChangeCallback(void *, wxWindow **winp, void *on);
00243 };
00244 
00245 #endif // Window_h