home *** CD-ROM | disk | FTP | other *** search
/ Borland Programmer's Resource / Borland_Programmers_Resource_CD_1995.iso / code / wxwin140 / include / wx_win.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-19  |  5.4 KB  |  145 lines

  1. /*
  2.  * File:     wx_win.h
  3.  * Purpose:  wxWindow class declaration. Base class for all windows and
  4.  *           panel items.
  5.  *
  6.  *                       wxWindows 1.40
  7.  * Copyright (c) 1993 Artificial Intelligence Applications Institute,
  8.  *                   The University of Edinburgh
  9.  *
  10.  *                     Author: Julian Smart
  11.  *                       Date: 18-4-93
  12.  *
  13.  * Permission to use, copy, modify, and distribute this software and its
  14.  * documentation for any purpose is hereby granted without fee, provided
  15.  * that the above copyright notice, author statement and this permission
  16.  * notice appear in all copies of this software and related documentation.
  17.  *
  18.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS,
  19.  * IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
  20.  * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
  21.  *
  22.  * IN NO EVENT SHALL THE ARTIFICIAL INTELLIGENCE APPLICATIONS INSTITUTE OR THE
  23.  * UNIVERSITY OF EDINBURGH BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR
  24.  * CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM
  25.  * LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF THE POSSIBILITY OF
  26.  * DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH
  27.  * THE USE OR PERFORMANCE OF THIS SOFTWARE.
  28.  */
  29.  
  30. #ifndef wx_winh
  31. #define wx_winh
  32.  
  33. #include "common.h"
  34. #include "wx_obj.h"
  35. #include "wx_event.h"
  36. #include "wx_list.h"
  37. #include "wx_gdi.h"
  38.  
  39. #ifdef wx_msw
  40. #include <windows.h>
  41. #endif
  42.  
  43. // Callback function type definition
  44. typedef void (*wxFunction) (wxObject&, wxEvent&);
  45.  
  46. class wxMenu;
  47.  
  48. /*
  49.  * Base class for frame, panel, canvas, panel items, dialog box.
  50.  *
  51.  */
  52.  
  53. class wxWindow: public wxObject
  54. {
  55.  
  56.  public:
  57.   // Font - created on demand, not deleted with window
  58.   wxFont *font;                               // Window's font
  59.   wxCursor *wx_cursor;                        // Window's cursor
  60.  
  61.   char *wx_client_data;                       // Any user client data
  62.   wxList *children;                           // Window's children
  63.  
  64. #ifdef wx_msw
  65.   HANDLE ms_handle;                           // For menus and hwnds: using 'handle'
  66.                                               // causes too many compiler messages
  67.   int wxWinType;                              // For knowing how to delete the object
  68.   int cxChar;
  69.   int cyChar;
  70.   int windows_id;
  71.   virtual BOOL Command(UINT param);
  72.   wxWindow *FindItem(int id);
  73.   virtual void PreDelete(HDC dc);              // Allows system cleanup
  74. #endif
  75.   wxWindow *window_parent;                     // Each window always knows its parent
  76.   char *handle;                                // Pointer to real window
  77.  
  78.   wxFunction callback;                         // Callback associated with the window
  79.   virtual void Callback(wxFunction);           // Adds callback
  80.  
  81.   // Constructors/Destructors
  82.   wxWindow(void);
  83.   virtual ~wxWindow(void);
  84.  
  85.   virtual void OnPaint(void);                 // Called when needs painting
  86.   virtual void OnSize(int width, int height); // Called on resize
  87.   virtual void OnEvent(wxEvent& event);       // Called on mouse event
  88.   virtual void OnChar(int ch);                // Called on character event
  89.   virtual Bool OnClose(void);                 // Delete window if returns TRUE
  90.   virtual void OnMenuCommand(int Id);         // Called on frame menu command
  91.   virtual void OnMenuSelect(int Id);          // Called on menu select (MSW)
  92.   virtual void OnActivate(Bool active);       // Called on window activation (MSW)
  93.   virtual void OnSetFocus(void) {}            // Called on setting focus
  94.   virtual void OnKillFocus(void) {}           // Called on killing focus
  95.  
  96.   virtual void GetSize(int *width, int *height);
  97.   virtual void GetPosition(int *x, int *y);
  98.   virtual void GetClientSize(int *width, int *height); // Size client can use
  99.   virtual void SetSize(int x, int y, int width, int height);
  100.   virtual void SetClientSize(int width, int size);
  101.   virtual void SetFocus(void);
  102.  
  103.   virtual char *GetHandle(void);
  104.   virtual char *GetClientData(void);
  105.   virtual wxWindow *GetParent(void);
  106.   virtual wxWindow *GetGrandParent(void);
  107.   virtual wxList *GetChildren() { return children; }
  108.  
  109.  
  110.   virtual int XChar(int pixels);              // Convert pixels to character positions
  111.   virtual int YChar(int pixels);
  112.  
  113.   virtual void SetClientData(char *);
  114.   virtual void Show(Bool show);
  115.   virtual wxCursor *SetCursor(wxCursor *cursor);
  116.  
  117.   virtual int GetTextFamily(void);
  118.   virtual int GetTextStyle(void);
  119.   virtual int GetTextWeight(void);
  120.   virtual float GetTextHeight(void);
  121.   virtual float GetTextWidth(void);
  122.   virtual void GetTextExtent(char *string, float *x, float *y);
  123.   void SetTitle(char *title);                  // Set window title
  124.   virtual void Fit(void);                      // Size window to fit contents
  125.   virtual void Centre(int direction);          // Centre item on panel,
  126.                                                // or frame on screen
  127.  
  128.   // A concession to our friends across the pond
  129.   inline void Center(int direction) { Centre(direction); }
  130.  
  131.   // INTERNAL FUNCTIONS
  132.   void AddChild(wxObject *child);      // Adds reference to the child object
  133.   void RemoveChild(wxObject *child);   // Removes reference to child
  134.                                        // (but doesn't delete the child object)
  135.   virtual void DestroyChildren(void);  // Removes and destroys all children
  136.  
  137. #ifdef wx_motif
  138.   virtual void PreResize(void);
  139.   void PostDestroyChildren(void);
  140.   int wxType;
  141. #endif
  142. };
  143.  
  144. #endif
  145.