//#pragma interface #ifndef DIAWXGTK #define DIAWXGTK #define STRETCH_NONE 0 #define STRETCH_LOOK 1 // Accept to stretch itself #define STRETCH_INFO 2 // Has stretchable information #include #include #include #include #include using namespace std; class MFORM; class BOOK; class wxBOOK; class wxTREE; class MAINFORM; class DCNAME; class HLINE: public wxPanel{ const char *s; int pref_width,pref_height; /*~PROTOBEG~ HLINE */ public: HLINE (MFORM *_parent, const char *_s); void OnPaint (void); private: void draw3dline (wxDC&dc, int x, int y, int end); public: ~HLINE (void); /*~PROTOEND~ HLINE */ }; #define MFORM_OPTFLAT 1 #define MFORM_OPT3D 2 class FORMBASE; class MFORM_C{ public: bool is_hcontrib; // Contribue ŕ la disposition horizontale bool homemade; // This is not a real widget but manage // by hand using the wxDC drawing context char h_align; // Alignement ŕ l'intérieur de la cellule // l=left, c=center, r=right char v_align; // Alignement ŕ l'intérieur de la cellule // t=top, c=center, b=bottom int h_cells; // Number of cells used horizontally (colspan) int v_cells; // Number of cells used vertically (rowspan) char *s; // Input buffer is needed or label char *id; // Widget identifier wxWindow *c; int weightx; // relative weight of the component for int weighty; // dialog resizing. 0 for fixed elements int x; // Position for T_LABEL int y; int type; int pref_width; // Initial (preferred) size of the item int pref_height; int width; // Current width (for some homemade widget such // as buttonfill) int height; class CHECKBOX_RADIO *radio; DCNAME *dcn; // Optional DC settings to use (maybe NULL) int options; wxBitmap *bitmap; /*~PROTOBEG~ MFORM_C */ public: MFORM_C (const char *_id); FORMBASE *getformbase (void)const; void sets (const char *str); ~MFORM_C (void); /*~PROTOEND~ MFORM_C */ }; class wxText: public wxTextCtrl{ }; class wxHTML; class SETVAL_INFO{ public: wxHTML *thtml; wxTextCtrl *tarea; // Buffer to collect the new value of a text area char *tarea_buf; int tarea_size; int tarea_pos; class COMBO *combo; /*~PROTOBEG~ SETVAL_INFO */ public: SETVAL_INFO (void); void append (const char *s); void freebuf (void); void initbuf (void); /*~PROTOEND~ SETVAL_INFO */ }; struct INPUTGRID{ char *id; // Button ID int x,y; int cellwidth,cellheight; int nbcellh,nbcellv; bool track; // Send report to the application when the user // move from one cell to the other int lastcellx,lastcelly; }; class wxFORMBASE; class FORMBASE{ public: int revlayout; MFORM_C **tbc; int nbc; int maxtbc; // Current allocation size for tbc char *id; FORMBASE *f_parent; wxWindow *wx_parent; // wxxt has already a parent field bool modified; int stretch_mode; int pref_width; int pref_height; bool logicaltop; // This form is a logical mainform // used in dump() and getabspath() struct { int x,y; int w,h; } fixed; // Requested position and dimensions or -1 int max_height; // Maximum height before enabling vertical scroll int max_width; // Maximum width before enabling horizontal scroll int doc_width; // Document size, used when drawing stuff int doc_height; // the layout engine can't compute the document size. int voffset; int hoffset; bool layout_once; // dolayout() was called once for this form wxScrollBar *vscroll; wxScrollBar *hscroll; struct { // Drawing context used to clear the form wxPen *pen; wxBrush *brush; } background; /*~PROTOBEG~ FORMBASE */ public: FORMBASE (FORMBASE *_f_parent, wxWindow *_wx_parent, const char *_id); FORMBASE (const char *_id); MFORM_C *alloc_mf (const char *_id); MFORM_C *alloc_mf (void); void delall (void); void delchild (void); virtual void delform (wxWindow *fl); virtual bool doalllayout (void); virtual void dump (void); wxFrame *getframe (void); FORMBASE *getlogicaltop (void); FORMBASE *getparent (void)const; int getrevlayout (void)const; MAINFORM *gettop (void); virtual void getweight (int &w, int &h); wxWindow *getwxparent (void)const; private: void init (FORMBASE *_f_parent, wxWindow *_wx_parent, const char *_id); public: bool istop (void); int locate (const char *id, MFORM *&form, wxBOOK *&book); virtual bool may_stretch (void); void processradio (MFORM_C *csel); void resetlayout (void); virtual void resizeitems (int , int); virtual void set_modified (void); virtual int setcurfield (const char *, wxWindow *[], int &); virtual void setval (const char *id, const char *vals[], SETVAL_INFO&info); virtual void setvalid (int i, MFORM_C *c, const char *vals[], SETVAL_INFO&info); virtual void stretch (int , int); bool was_modified (void); virtual ~FORMBASE (void); /*~PROTOEND~ FORMBASE */ }; class wxFORMBASE: public wxPanel, public FORMBASE{ /*~PROTOBEG~ wxFORMBASE */ public: void Fit (void); protected: void drawbutfill (int nobut, wxPen *pentop, wxPen *penbot, bool clear, bool anim); public: void drawitems (int start, int end, bool clear); protected: void drawitems (wxDC&dc, int start, int end, bool clear); public: void drawradio_but (MFORM_C *c); void fit2top (void); void report_button (const char *button_id, bool dodump, wxMouseEvent *event, const char *extra); void report_button (const char *button_id, bool dodump, wxMouseEvent *event, const char *extra, int cheaty); void richtext_draw (const char *s, int x, int y); private: void richtext_draweval (const char *s); public: void richtext_extent (const char *s, int &sw, int &sh); void sethscroll (void); void setvalid (int i, MFORM_C *c, const char *vals[], SETVAL_INFO&info); void setvscroll (void); wxFORMBASE (FORMBASE *_f_parent, wxWindow *_wx_parent, const char *_id); wxFORMBASE (const char *_id); wxFORMBASE (wxFORMBASE *_parent, const char *_id); /*~PROTOEND~ wxFORMBASE */ }; #define T_UNKNOWN 0 #define T_STRING 1 #define T_BUTTON 2 #define T_FORM 3 #define T_CHECKBOX 4 #define T_RADIO 5 #define T_CHOICE 6 #define T_HLINE 7 #define T_VLINE 8 #define T_SKIP 9 #define T_NEWLINE 10 #define T_COMBO 11 #define T_LIST 12 #define T_ICON 13 #define T_FILL 14 #define T_TEXT 15 #define T_LABEL 16 #define T_RICHTEXT 17 #define T_BUTTONFILL 18 #define T_CLIST 19 #define T_SHEET 20 #define T_SLIDER 21 #define T_GAUGE 22 #define T_BOOK 23 #define T_BUTTONXPM 24 #define T_TREE 25 #define T_HTML 26 class COMBO; class BOOK; class FORMBUTTON; class CLIST; class SHEET; class CHECKBOX_RADIO{ public: int instance; bool state; /*~PROTOBEG~ CHECKBOX_RADIO */ public: CHECKBOX_RADIO (int _instance, bool _state); /*~PROTOEND~ CHECKBOX_RADIO */ }; class MFORM_TIMER; class MFORM_DRAW; #define MAX_COL 20 class MFORM: public wxFORMBASE{ public: char *dispstr; int marge_haut; int marge_bas; int marge_gauche; int marge_droite; int min_width; char *sidetitle; int mincols[MAX_COL]; // Required minimal width of each columns int colwidth[MAX_COL]; // Current width of each columns of the dialog MFORM_TIMER *timer; MFORM_DRAW *draw; // Primitive to draw INPUTGRID *grids; int nbgrid; /*~PROTOBEG~ MFORM */ public: void Dispolast (char h_align, int h_cells, char v_align, int v_cells); private: wxSize DoGetVirtualSize (void)const; void DoMoveWindow (int x, int y, int w, int h); void DoSetClientSize (int w, int h); void DoSetSize (int x, int y, int w, int h, int flags); public: void Event_OnPaint (wxPaintEvent&); virtual void Fill (void); protected: void FitStrategie_marge (int gauche, int droit, int haut, int bas, bool use_cur_size, int maxw, int maxh, bool force, wxSize&give); public: void Inputgrid (const char *id, int x, int y, int cellwidth, int cellheight, int nbcellh, int nbcellv); MFORM (FORMBASE *_f_parent, wxWindow *_wx_parent, const char *_id); protected: MFORM (const char *_id); public: MFORM (wxFORMBASE *_parent, const char *_id); virtual void New_book (wxBOOK *sub); virtual void New_book (wxFORMBASE *sub); virtual wxButton *New_button (const char *_id, bool dodump, const char *str); virtual wxButton *New_button (const char *_id, wxBitmap *bitmap); virtual wxButton *New_button (const char *str); virtual void New_buttonfill (const char *_id, const char *str, int options, DCNAME *dc); virtual wxCheckBox *New_checkbox (const char *_id, bool state, const char *str); virtual COMBO *New_choice (const char *_id, const char *val); virtual void New_choice_item (const char *_id, int no, const char *val1, const char *val2); virtual CLIST *New_clist (const char *_listid, int nbcol, const char *cols[]); virtual void New_clist_item (const char *_listid, const char *_itemid, const char *vals[]); virtual COMBO *New_combo (const char *_id, int len, const char *val); virtual void New_combo_item (const char *_id, int no, const char *val1, const char *val2); void New_component (wxWindow *comp); virtual MFORM *New_form (const char *_id); virtual void New_form (wxFORMBASE *sub); virtual FORMBUTTON *New_formbutton (const char *_id); virtual FORMBUTTON *New_formbutton (void); virtual wxGauge *New_gauge (const char *_id, int width, int range, int val); virtual void New_hline (const char *s); virtual void New_hline (void); virtual wxHTML *New_html (const char *_id, int cols, int rows); virtual void New_icon_xpm (wxBitmap *bitmap); virtual void New_label (const char *str); virtual wxListBox *New_list (const char *_id, int , const char *val); virtual void New_list_item (const char *_id, const char *val); virtual wxTextCtrl *New_password (const char *_id, int len); void New_radio (const char *_id, int instance, bool state, const char *str); virtual void New_richtext (const char *str); virtual SHEET *New_sheet (const char *_sheetid, int nbcol, const char *cols[]); virtual void New_sheet_item (const char *_sheetid, int row, int column, const char *val); virtual wxSlider *New_slider (const char *_id, int width, int minval, int maxval, int val); virtual wxTextCtrl *New_string (const char *_id, int len, const char *initval); virtual wxTextCtrl *New_string (int len, const char *initval); virtual wxTextCtrl *New_text (const char *_id, int cols, int rows); virtual wxTREE *New_tree (const char *_id); virtual void New_vline (void); virtual void Newline (void); void OnPaint (void); virtual void Real_OnPaint (wxDC&dc); void Setweightlast (int wx, int wy); virtual void Skip (int n); void animatebut (int it, bool down); void blit (int from_x0, int from_y0, int from_x1, int from_y1, int to_x, int to_y); private: void distribute (int start, int end, int nbfill, int diffx); public: void do_drawing (void); protected: void do_drawing (wxDC&dc); public: virtual void dolayout (int maxw, int maxh, bool force, wxSize&give); void drawclip (int x0, int y0, int x1, int y1); MFORM_C *getitem (int n)const; private: MFORM_C *getlastc (void); public: void getweight (int &w, int &h); virtual void hmoveitems (int newpos); void hscroll_func (wxScrollEvent&ev); private: void init (void); void initsizer (void); protected: void keyevent (wxKeyEvent&event); public: int locate_butfill (wxMouseEvent&event); int locate_click (wxMouseEvent&event, int type); void mouseevent (wxMouseEvent&event); void record_draw (int command, int arg0, int arg1, const char *s); void record_draw (int command, int arg0, int arg1, int arg2, int arg3); void record_draw (int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5); void record_draw (int command, int arg0, int arg1, int arg2, int arg3, int arg4, int arg5, int arg6, int arg7); void record_draw (int command, int tb[], int nbarg); void reset (void); void resizeitems (int diffx, int diffy); int setcurfield (const char *id_suffix, wxWindow *tbfocus[], int &nbfocus); void setsidetitle (const char *s); void stretch (int new_width, int); void vmoveitems (int newpos); void vscroll_func (wxScrollEvent&ev); ~MFORM (void); /*~PROTOEND~ MFORM */ DECLARE_EVENT_TABLE() }; class MAINFORM: public MFORM{ public: char *enteraction; class mywxFrame *fram; bool nopopup; // Delay the popup until an explicit show /*~PROTOBEG~ MAINFORM */ public: void Fit (void); MAINFORM (const char *_id); MAINFORM (const char *_id, const char *_titre, const char *type); MAINFORM (wxFrame *_parent, const char *_id, int x, int y, long style); void Popup (void); virtual void dispose (void); void dopopup (wxCommandEvent&ev); void escape (void); const char *getenteraction (void); wxFrame *getframe (void); void hide (void); private: void init (const char *type); void init (wxFrame *_parent, int x, int y, long style); public: void mainlayout (void); void popupmenu (wxMenu *mn, int x, int y); void record_onpaint (MFORM *f); void reset (void); void setTitle (const char *title); void setcursor (const wxCursor *cur); void setenteraction (const char *str); void show (void); void waitpopup (void); bool was_resized (void); ~MAINFORM (void); /*~PROTOEND~ MAINFORM */ DECLARE_EVENT_TABLE() }; class FORMBUTTON: public MFORM{ wxBrush *brush; wxPen *pen; bool docolor; /*~PROTOBEG~ FORMBUTTON */ public: FORMBUTTON (wxFORMBASE *_parent, const char *_id, int _back); FORMBUTTON (wxFORMBASE *_parent, const char *_id); wxButton *New_button (const char *_id, bool dodump, const char *str); void OnPaint (void); ~FORMBUTTON (void); /*~PROTOEND~ FORMBUTTON */ }; class GROUP: public MFORM{ const char *title; /*~PROTOBEG~ GROUP */ public: void Event_OnPaint (wxPaintEvent&e); GROUP (MFORM *_parent, const char *_id, const char *_title); GROUP (MFORM *_parent, const char *_id); void drawgroup (wxDC&dc); ~GROUP (void); /*~PROTOEND~ GROUP */ DECLARE_EVENT_TABLE() }; class GROUP_FIT: public GROUP{ /*~PROTOBEG~ GROUP_FIT */ public: GROUP_FIT (MFORM *_parent, const char *_id, const char *_title); GROUP_FIT (MFORM *_parent, const char *_id); void stretch (int new_width, int new_height); /*~PROTOEND~ GROUP_FIT */ DECLARE_EVENT_TABLE() }; class CLIST: public MFORM{ MFORM *sub; int nbcol; char **cols; char *hdispo; // Horizontal disposition, LaTeX like (lrllrrcll) char *hsign; // One letter per heading button to specify // the little sign/icon to put at end. // Generally used to present the sort order. DCNAME **dcs; // Drawing context to use for each column char *hid; // Id used to send event when the user click // in the header area int heady; // Height the heading section class CLIST_MAP *lookup; /*~PROTOBEG~ CLIST */ public: CLIST (wxFORMBASE *_parent, const char *_id, int _nbcol, const char *_cols[]); void Event_OnPaint (wxPaintEvent&); void Fit (void); void New_item (const char *id, const char *items[]); void Set_item (const char *id, const char *items[]); void drawhead (wxDC&dc); private: void freecols (void); public: void mouseevent (wxMouseEvent&event); void redolayout (void); void resizeitems (int diffx, int diffy); int setcurfield (const char *id_suffix, wxWindow *tbfocus[], int &nbfocus); void sethead (int _nbcol, const char *_cols[]); void setval (const char *id, const char *vals[], SETVAL_INFO&info); void stretch (int new_width, int new_height); ~CLIST (void); /*~PROTOEND~ CLIST */ DECLARE_EVENT_TABLE() }; class SHEET: public MFORM{ MFORM *sub; int nbcol; char **cols; /*~PROTOBEG~ SHEET */ public: void New_item (int row, int column, const char *val); void OnPaint (void); SHEET (wxFORMBASE *_parent, const char *_id, int _nbcol, const char *_cols[]); void drawhead (void); void dump (void); ~SHEET (void); /*~PROTOEND~ SHEET */ }; class PAGEPAD{ public: const char *title; int start; // Horizontal coordinate of the pad int stop; // End of the pad /*~PROTOBEG~ PAGEPAD */ public: PAGEPAD (const char *_title); ~PAGEPAD (void); /*~PROTOEND~ PAGEPAD */ }; class BOOK: public wxFORMBASE{ int nbpage; int nopage; int offsetx,offsety,b_offsety; class PAGEPAD *pads[30]; bool scrollpad; // Is there a button to scroll the pads horizontally int offpad; // First visible pad to the left char *focusid; // ID use to report page visibility change /*~PROTOBEG~ BOOK */ public: BOOK (wxFORMBASE *_parent, const char *_id); void Event_OnPaint (wxPaintEvent&); MFORM *New_form (const char *s); void New_page (wxFORMBASE *sub, const char *s); void OnPaint (void); private: void Real_OnPaint (wxDC&dc); public: void delform (MFORM *fl); bool doalllayout (void); void dolayout (int , int , bool, wxSize&give); private: void drawsel (wxDC&dc, int no, bool select, int offsetx, int maxx); public: void fitstrategie (int left, int top, bool use_cur_dim, wxSize&give); private: int getpadwidth (int no); public: void getweight (int &w, int &h); private: void initsizer (void); bool locatepad (int x, wxMouseEvent *ev); public: bool may_stretch (void); void mouseevent (wxMouseEvent&event); void resizeitems (int diffx, int diffy); void selpage (FORMBASE *f); void selpage (int no, wxMouseEvent *ev); private: void sendfocus (wxMouseEvent *ev); public: int setcurfield (const char *id_suffix, wxWindow *tbfocus[], int &nbfocus); private: void setpadvisible (int no); public: void stretch (int new_width, int new_height); ~BOOK (void); /*~PROTOEND~ BOOK */ DECLARE_EVENT_TABLE() }; class wxBOOK: public wxNotebook, public FORMBASE{ wxMouseEvent lastev; int lastsel; char *focusid; // ID use to report page visibility change /*~PROTOBEG~ wxBOOK */ public: MFORM *New_form (const char *s); void New_page (wxFORMBASE *sub, const char *s); void changed (wxNotebookEvent&ev); void changing (wxNotebookEvent&ev); void delform (wxWindow *fl); void fit2top (void); void getweight (int &w, int &h); bool may_stretch (void); void mouseev (wxMouseEvent&ev); void mouseev_up (wxMouseEvent&ev); void selpage (wxFORMBASE *f); private: void sendfocus (wxMouseEvent *ev); public: wxBOOK (wxFORMBASE *_parent, const char *_id); ~wxBOOK (void); /*~PROTOEND~ wxBOOK */ DECLARE_EVENT_TABLE() }; class wxTREE: public wxTreeCtrl, public FORMBASE{ public: int curlevel; wxTreeItemId tbids[100]; bool statopen[100]; /*~PROTOBEG~ wxTREE */ public: void Set_item (const char *id, const char *vals[]); void addelm (wxBitmap *icon, const char *title); void addsub (bool isopen, wxBitmap *icon, const char *title); void dump (void); private: void dump (wxTreeItemId&parentid, const char *path, int &ref); public: void endsub (void); void getweight (int &w, int &h); void mouseevent (wxMouseEvent&event); private: bool set_add (wxTreeItemId&parentid, const char *key, int lenkey, const char *items[]); void setdc (wxTreeItemId&id); void setkeys (void); void setkeys (wxTreeItemId parentid, char keypath[], int keylen); public: wxTREE (wxFORMBASE *_parent, const char *_id); ~wxTREE (void); /*~PROTOEND~ wxTREE */ DECLARE_EVENT_TABLE() }; class COMBO: public wxComboBox { public: int maxlen; /*~PROTOBEG~ COMBO */ public: COMBO (MFORM *_parent, const char *initval, int cols, bool listonly); void addItem (const char *val1, const char *val2); const char *getText (void); void select (int no); void setItem (int no, const char *val1, const char *val2); void setText (const char *val); ~COMBO (void); /*~PROTOEND~ COMBO */ }; class TREEMENU: public MFORM { struct TREEELM *tb; int maxtb; int nbtb; bool *statopen,*terminal; int *level; int curlevel; bool full; // Operation mode. The application need full control // over the tree operation /*~PROTOBEG~ TREEMENU */ public: void Event_OnPaint (wxPaintEvent&); protected: bool OnCharHook (wxKeyEvent&event); private: void Real_OnPaint (wxDC&dc); public: TREEMENU (wxFORMBASE *_parent, const char *_id); void addelm (wxBitmap *icon, const char *title); void addsub (bool isopen, wxBitmap *icon, const char *title); private: void alloc (void); void dispose (int total_width, int total_height); public: void dolayout (int , int , bool); private: void draw (wxDC&dc, int no, bool highlit); void drawone (wxDC&dc, int no, int y, bool highlit); public: void dump (void); void endsub (void); private: int getskipy (void); int getviewlength (void); public: void getweight (int &w, int &h); void mouseevent (wxMouseEvent&event); private: void refresh (void); public: void resizeitems (int diffx, int diffy); void setscroll (int newpos); private: int setup (void); public: void stretch (int new_width, int new_height); void vscroll_func (wxScrollEvent&ev); ~TREEMENU (void); /*~PROTOEND~ TREEMENU */ DECLARE_EVENT_TABLE() }; class TEXTAREA: public wxTextCtrl{ /*~PROTOBEG~ TEXTAREA */ protected: void OnChar (wxKeyEvent&event); public: TEXTAREA (wxFORMBASE *_parent, int cols, int rows); /*~PROTOEND~ TEXTAREA */ }; class wxHTML: public wxHtmlWindow{ /*~PROTOBEG~ wxHTML */ public: wxHtmlOpeningStatus OnOpeningURL (wxHtmlURLType type, const wxString&url, wxString *redirect); wxHTML (wxFORMBASE *_parent, int width, int height); /*~PROTOEND~ wxHTML */ }; class POPUPMENU: public wxMenu{ string popupid; bool event_sent; /*~PROTOBEG~ POPUPMENU */ public: POPUPMENU (const char *id, const char *title); void closefunc (wxMenuEvent&c); void done (void); private: void funcgen (wxEvent&c); public: void menufunc (wxCommandEvent&c); /*~PROTOEND~ POPUPMENU */ DECLARE_EVENT_TABLE() }; extern wxPen *pen_white; extern wxPen *pen_black; extern wxPen *pen_light; extern wxPen *pen_dark; extern wxPen *pen_back; extern wxBrush *brush_lightgray; extern wxBrush *brush_white; extern wxBrush *brush_black; extern wxBrush *brush_back; extern wxFont *font_normal; extern wxFont *font_prop; extern wxCursor *cursor_normal; extern wxCursor *cursor_wait; extern wxCursor *cursor_locked; extern FILE *mform_fout; #include "diawxgtk.p" #endif