home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / dlged002.zip / dlgedit.h < prev    next >
C/C++ Source or Header  |  1995-11-24  |  7KB  |  287 lines

  1. /* 
  2.  
  3.  
  4.     dlgedit.h (emx+gcc) 
  5.  
  6.     1994,95 Giovanni Iachello
  7.     This is freeware software. You can use or modify it as you wish,
  8.     provided that the part of code that I wrote remains freeware.
  9.     Freeware means that the source code must be available on request 
  10.     to anyone.
  11.     You must also include this notice in all files derived from this
  12.     file.
  13.  
  14.  
  15. */
  16. #ifndef _DLGEDIT_H_
  17. #define _DLGEDIT_H_
  18.  
  19.  
  20. #define PMPTR_1         10
  21. #define IDM_POPUPMENU    40
  22. #define IDM_PU_PROP        41
  23. #define IDM_PU_FLAGS    42
  24. #define IDM_PU_DELETE    43
  25.  
  26.  
  27. #define ID_DLGEDIT         1
  28.  
  29. #define IDM_NEWCTRL     10
  30. #define IDM_STATICTEXT  11
  31. #define IDM_ENTRYFIELD  12
  32. #define IDM_LISTBOX     13
  33. #define IDM_COMBOBOX    14
  34. #define IDM_BUTTON      15
  35. #define IDM_SPINBUTTON  16
  36. #define IDM_SLIDER      17
  37. #define IDM_VALUESET     18
  38. #define IDM_CHECKBOX    19
  39. #define IDM_RADIOBUTTON 20
  40. #define IDM_3STATE      21
  41. #define IDM_GROUPBOX    22
  42.  
  43. #define IDM_PREF           30
  44. #define IDM_FONTS       31
  45. #define IDM_SIZE        32
  46. #define IDM_FLAGS       34
  47. #define IDM_TEXT        33
  48. #define IDM_CTRLLIST    35
  49.  
  50. #define IDM_COMPILE     50
  51.  
  52. #define DLG_SIZE        2
  53. #define DSIZE_EF_SX        200
  54. #define DSIZE_EF_SY        201
  55.  
  56. #define DLG_TEXT        6
  57. #define DTEXT_EF_LB        600
  58. #define DTEXT_EF_TI        601
  59.  
  60. #define DLG_FLAGS                    3
  61. #define DFLAGS_CB_FCF_TITLEBAR        300
  62. #define DFLAGS_CB_FCF_SYSMENU        301
  63. #define DFLAGS_CB_FCF_MENU            302    
  64. #define DFLAGS_CB_FCF_SIZEBORDER    303
  65. #define DFLAGS_CB_FCF_MINBUTTON        304
  66. #define DFLAGS_CB_FCF_MAXBUTTON        305
  67. #define DFLAGS_CB_FCF_VERTSCROLL    306    
  68. #define DFLAGS_CB_FCF_HORZSCROLL    307    
  69. #define DFLAGS_CB_FCF_DLGBORDER        308
  70. #define DFLAGS_CB_FCF_BORDER        309
  71. #define DFLAGS_CB_FCF_SHELLPOSITION    310
  72. #define DFLAGS_CB_FCF_TASKLIST        311
  73. #define DFLAGS_CB_FCF_NOBYTEALIGN    312    
  74. #define DFLAGS_CB_FCF_NOMOVEWITHOWNER     313    
  75. #define DFLAGS_CB_FCF_ICON            314
  76. #define DFLAGS_CB_FCF_ACCELTABLE    315    
  77. #define DFLAGS_CB_FCF_SYSMODAL        316
  78. #define DFLAGS_CB_FCF_SCREENALIGN    317    
  79. #define DFLAGS_CB_FCF_MOUSEALIGN    318    
  80. #define DFLAGS_CB_FCF_PALETTE_NORMAL 319    
  81. #define DFLAGS_CB_FCF_PALETTE_HELP    320
  82. #define DFLAGS_CB_FCF_PALETTE_POPUPODD    321
  83. #define DFLAGS_CB_FCF_PALETTE_POPUPEVEN    322
  84. #define DFLAGS_CB_FCF_HIDEBUTTON    323
  85. #define DFLAGS_CB_FCF_HIDEMAX        324
  86. #define DFLAGS_CB_FCF_AUTOICON        325
  87.  
  88. #define DLG_CTRLPROP    4
  89. #define DCP_EF_X        400
  90. #define DCP_EF_Y        401
  91. #define DCP_EF_CX        402
  92. #define DCP_EF_CY        403
  93. #define DCP_EF_TEXT        404
  94. #define DCP_EF_LABEL    405
  95.  
  96. #define DLG_CTRLFLAGS                5
  97. #define DCF_WS_VISIBLE                500
  98. #define DCF_WS_DISABLED                501
  99. #define DCF_WS_CLIPCHILDREN            502    
  100. #define DCF_WS_CLIPSIBLINGS          503
  101. #define DCF_WS_PARENTCLIP              504
  102. #define DCF_WS_SAVEBITS                505
  103. #define DCF_WS_SYNCPAINT            506    
  104. #define DCF_WS_MINIMIZED            507    
  105. #define DCF_WS_MAXIMIZED               508
  106. #define DCF_WS_ANIMATE              509
  107. #define DCF_WS_GROUP                   510
  108. #define DCF_WS_TABSTOP                511
  109. #define DCF_WS_MULTISELECT           512    
  110. #define DCF_1     513    
  111. #define DCF_2    514
  112. #define DCF_3    515    
  113. #define DCF_4    516
  114. #define DCF_5    517    
  115. #define DCF_6    518    
  116. #define DCF_7     519    
  117. #define DCF_8    520
  118. #define DCF_9    521
  119. #define DCF_A    522
  120. #define DCF_B    523
  121. #define DCF_C    524
  122. #define DCF_D    525
  123. #define DCF_E    526
  124. #define DCF_F    527
  125.  
  126.  
  127. #define DLG_CTRLLIST 7
  128. #define DCTRLLIST_LB_CTRLLIST 700
  129. #define DCTRLLIST_PB_DELETE 701
  130. #define DCTRLLIST_PB_FLAGS  702
  131. #define DCTRLLIST_PB_PROP 703
  132.  
  133. #ifndef RC_INVOKED
  134.  
  135. #include "pmwin.h"
  136. #include "pmdlg.h"
  137. #include "dlgdata.h"
  138.  
  139. ////////////////////////////////////////////////////////////////////////////
  140.  
  141. #define WM_NEWCTRL ( WM_USER + 0 )              // mandato da DlgEdit a WorkWindow per creare un nuovo controllo
  142. #define WM_CTRLMENU ( WM_USER + 1 )              // mandato a WorkWindow per tirare fuori il menu' popup
  143. #define WM_REFRESH ( WM_USER + 2 )              // mandato da DlgEdit a CtrlListDialog per comandare di rifare la lista dei controlli
  144. #define WM_MODIFIED ( WM_USER + 3 )              // mandato da Workwindow a DlgEdit per informare che il dialog e' stato modificato
  145. #define WM_CLOSECTRLLIST ( WM_USER + 4 )        // mandato da CtrlList a DlgEdit per informare che ctrllist e' stata chiusa
  146.  
  147. ////////////////////////////////////////////////////////////////////////////
  148.  
  149. #ifndef min
  150. #define min(a,b) ((a) < (b) ? (a) : (b))
  151. #endif
  152. #ifndef max
  153. #define max(a,b) ((a) > (b) ? (a) : (b))
  154. #endif
  155.  
  156. // real 2 dialog , servono numeri magici per mantenere il ratio!
  157. #define r2dx(a) ((a)*4*32/aveCharX/25)
  158. #define r2dy(a) ((a)*8*59/aveCharY/75)
  159.  
  160. // dialog 2 real 
  161. #define d2rx(a) ((a)*25*aveCharX/4/32)
  162. #define d2ry(a) ((a)*75*aveCharY/8/59)
  163.  
  164. extern PMApp* App;
  165.  
  166. extern LONG aveCharX,aveCharY;
  167.  
  168. /////////////////////////////////////////////////////////////////////////////
  169. // strutture che servono anche a dlgcomr.cpp:
  170.  
  171. class ControlWin : public PMSubclassWin {
  172.     PMWin* owner;
  173. public:
  174.     ControlWin(PMWin* iowner, PCSZ pszClass, PCSZ pszName,
  175.         ULONG flStyle, LONG x, LONG y, LONG cx, LONG cy, 
  176.         HWND hwndInsertBehind, ULONG id, PVOID pCtlData=NULL, PVOID pPresParams=NULL) ;
  177.     BOOL other(PMEvent &event);    
  178.     BOOL destroyWin() ;
  179. };
  180.  
  181.  
  182. struct _dlgcontrol {
  183.     CHAR text[80];
  184.     ULONG flags;
  185.     ULONG x,y,cx,cy;
  186.     CHAR idc[80];
  187.     ULONG idl;
  188.     int classidx;
  189.     ControlWin *win;
  190.     _dlgcontrol *next;
  191. };
  192.  
  193. struct _dlginfo {
  194.     _dlginfo() {
  195.         sx=100;
  196.         sy=100;
  197.         title[0]='\0';
  198.         label[0]='\0';
  199.         for (int i=0; i<26; i++) fl[i]=0;
  200.         fl[8]=1; // DLGBORDER
  201.         dlgctrl=NULL;
  202.     }
  203.     int sx;
  204.     int sy;
  205.     int fl[26];
  206.     char title[100];
  207.     char label[100];
  208.     ULONG flags;
  209.     _dlgcontrol* dlgctrl;
  210.     void makeflags() {
  211.         flags=0L;
  212.         for (int i=0; i<26; i++) if (fl[i]) flags|=winflvalues[i];
  213.     }
  214. } ;
  215.  
  216. /////////////////////////////////////////////////////////////////////////////
  217.  
  218. extern BOOL compile(const char* file,_dlginfo*);
  219. extern BOOL savedl(const char* file,_dlginfo*);
  220. extern BOOL loaddl(const char* file,_dlginfo*);
  221.  
  222. /////////////////////////////////////////////////////////////////////////////
  223.  
  224. class CtrlFlagsDialog : public PMModalDialog {
  225.     struct _dlgflags {
  226.         int fl[32];
  227.     } dlgflags;
  228.     static PMControlMap ctrlmap[];
  229.     _dlgcontrol *dc;
  230. public:
  231.     CtrlFlagsDialog(HWND hwnd,_dlgcontrol *idc) : PMModalDialog(HWND_DESKTOP,hwnd,DLG_CTRLFLAGS,ctrlmap,&dlgflags) 
  232.     { 
  233.         dc=idc;
  234.     }
  235.     BOOL createWin();
  236.     BOOL initdlg();
  237.  
  238. };
  239.  
  240.  
  241. class WorkWindow : public PMWin {
  242.     _dlginfo* dlginfo;
  243.     PMWin* editor;
  244.     PMPoint start,end;        // per intercettare il posizionamento
  245.     BOOL mouseCaptured;
  246.     int newControl;
  247.     _dlgcontrol* edctrl;
  248.     PMPointer *ptr1; // selezione
  249.     PMPopupMenu *popup;    // popupmenu
  250. public:
  251.     friend class CtrlListDialog;
  252.     WorkWindow(HAB ab,_dlginfo* idlginfo,PMWin* ieditor);
  253.     ~WorkWindow();
  254.     BOOL createWin();
  255.     BOOL paint();
  256.     void drawOutline();
  257.     void addControl();
  258.     BOOL mouse(PMEvent &event);
  259.     BOOL other(PMEvent& evt) ;
  260.     BOOL command(USHORT id,USHORT cmddev);
  261. };
  262.  
  263. class CtrlListDialog : public PMModelessDialog {
  264.     WorkWindow *ww;
  265.     PMWin* editor;
  266.     static PMControlMap ctrlmap[];
  267.     struct _dlginfo {
  268.         int selctrl;
  269.     } dlginfo;    
  270. public:
  271.     CtrlListDialog(HWND parent,HWND owner,WorkWindow *iww,PMWin* ieditor);
  272.     BOOL initdlg() ;
  273.     BOOL command(USHORT id,USHORT cmddev) ;
  274.     BOOL other(PMEvent& evt) ;
  275. };
  276.  
  277. struct _windowflags {
  278.     int fl[26];
  279. };
  280.  
  281. extern PMControlMap windowflagsctrlmap[];
  282.  
  283. #endif
  284.  
  285. #endif
  286.  
  287.