- Timestamp:
- Jul 1, 2008, 4:56:49 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/watcom_ant17_java141/src/plugins/org.eclipse.swt/Eclipse SWT PI/pm/library/editcol.c
r14 r126 1 / /=========================================================================\1 /*=========================================================================\ 2 2 // editcol.c : color wheel dlg procedure | 3 3 // version 1.1 | 4 //========================================================================= /4 //=========================================================================*/ 5 5 6 6 #pragma strings(readonly) … … 14 14 15 15 16 / /=========================================================================\16 /*=========================================================================\ 17 17 // WinEditColorDlg(): | 18 18 // parameters: ----------------------------------------------------------- | … … 23 23 // returned value: ------------------------------------------------------- | 24 24 // LONG lColor : RGB color (success), CLR_ERROR (failure) | 25 //========================================================================= /25 //=========================================================================*/ 26 26 27 27 … … 33 33 ULONG i; 34 34 35 / / allocate storage for application data35 /* allocate storage for application data */ 36 36 if (DosAllocMem((PPVOID)&pad, sizeof(APPDATA), 37 37 PAG_READ | PAG_WRITE | PAG_COMMIT)) 38 38 return CLR_ERROR; 39 / / initialize APPDATA structure (size)39 /* initialize APPDATA structure (size) */ 40 40 pad->cbSize = sizeof(APPDATA); 41 / / anchor block41 /* anchor block */ 42 42 pad->hab = WinQueryAnchorBlock(hwndOwner); 43 / / window handles43 /* window handles */ 44 44 pad->hwndParent = hwndParent; 45 45 pad->hwndOwner = hwndOwner; 46 / / query the OS version46 /* query the OS version */ 47 47 DosQuerySysInfo(QSV_VERSION_MINOR, QSV_VERSION_MINOR, 48 48 &pad->ulVer, sizeof(ULONG)); 49 / / sets msg value according to OS version50 if (pad->ulVer > 30) { / / warp 449 /* sets msg value according to OS version */ 50 if (pad->ulVer > 30) { /* warp 4 */ 51 51 pad->cwChangedMsg = WM_COLORWHEELCHANGED; 52 52 pad->cwSetMsg = CWM_COLORWHEELSETVAL; 53 } else { / / warp 3 (warp 2?)53 } else { /* warp 3 (warp 2?) */ 54 54 pad->cwChangedMsg = WM_COLORWHEELCHANGED3; 55 55 pad->cwSetMsg = CWM_COLORWHEELSETVAL3; 56 56 } /* endif */ 57 / / register the color wheel control57 /* register the color wheel control */ 58 58 if (NULLHANDLE == (pad->hlib = WinLoadLibrary(pad->hab, "WPCONFIG.DLL"))) 59 59 return CLR_ERROR; 60 / / get the module handle to load the dialog from the DLL60 /* get the module handle to load the dialog from the DLL */ 61 61 if (DosQueryModuleHandle(SZ_MODULE, &pad->hDlgMod)) 62 62 return CLR_ERROR; 63 / / copy the start color63 /* copy the start color */ 64 64 pad->clrCurr.lClr = pad->clrUndo.lClr = color; 65 / / gets the dialog title, if pszTitle is NULL set the default65 /* gets the dialog title, if pszTitle is NULL set the default */ 66 66 if (!pszTitle) pszTitle = SZ_DEFTITLE; 67 / / code equivalent to strncpy to make DLL smaller67 /* code equivalent to strncpy to make DLL smaller */ 68 68 for (i = 0; 69 69 pad->achDlgTitle[i++] = *pszTitle++; … … 78 78 79 79 80 / /=========================================================================\80 /*=========================================================================\ 81 81 // EditColorDlgProc(): color wheel dlg procedure | 82 82 // processed messages: - WM_INITDLG | … … 86 86 // - WM_CLOSE | 87 87 // - WM_DESTROY | 88 //========================================================================= /88 //=========================================================================*/ 89 89 90 90 MRESULT EXPENTRY EditColorDlgProc(HWND hwnd, … … 93 93 MPARAM mp2) { 94 94 switch (msg) { 95 / / init -----------------------------------------------------------------95 /* init ----------------------------------------------------------------- */ 96 96 case WM_INITDLG: { 97 97 PAPPDATA pad = (PAPPDATA)mp2; 98 98 WinSetWindowPtr(hwnd, 0L, (PVOID)mp2); 99 99 WinSetWindowText(hwnd, pad->achDlgTitle); 100 SetSpins(hwnd, pad->clrUndo); / / initialize spinbutton101 / / initialize the color wheel control100 SetSpins(hwnd, pad->clrUndo); /* initialize spinbutton */ 101 /* initialize the color wheel control */ 102 102 WinSendDlgItemMsg(hwnd, CWHEEL, pad->cwSetMsg, 103 103 (MPARAM)pad->clrUndo.lClr, MPVOID); 104 pad->flUpd = TRUE; / / sets the update flag105 / / show the dialog in the middle of the parent window104 pad->flUpd = TRUE; /* sets the update flag */ 105 /* show the dialog in the middle of the parent window */ 106 106 WinQueryWindowRect(pad->hwndParent, &pad->rclPar); 107 107 WinQueryWindowRect(hwnd, &pad->rcl); … … 111 111 0, 0, SWP_MOVE | SWP_SHOW); 112 112 break; 113 } / / end case WM_INITDLG114 / / a new color has been set through the color wheel ---------------------113 } /* end case WM_INITDLG */ 114 /* a new color has been set through the color wheel --------------------- */ 115 115 case WM_COLORWHEELCHANGED3: 116 116 case WM_COLORWHEELCHANGED: { 117 117 PAPPDATA pad = WinQueryWindowPtr(hwnd, 0L); 118 118 pad->clrCurr.lClr = (LONG)mp1; 119 pad->flUpd = FALSE; / / reset update flag119 pad->flUpd = FALSE; /* reset update flag */ 120 120 SetSpins(hwnd, pad->clrCurr); 121 pad->flUpd = TRUE; / / set update flag122 / / notify new color to owner121 pad->flUpd = TRUE; /* set update flag */ 122 /* notify new color to owner */ 123 123 WinSendMsg(pad->hwndOwner, msg, mp1, mp2); 124 124 break; 125 } / / end case WM_COLORWHEELCHANGED126 / / spinbutton value has changed -----------------------------------------125 } /* end case WM_COLORWHEELCHANGED */ 126 /* spinbutton value has changed ----------------------------------------- */ 127 127 case WM_CONTROL: 128 if ((SHORT1FROMMP(mp1) == SPN_RED || / / if a spin button129 SHORT1FROMMP(mp1) == SPN_GREEN || / / originated SPBN_CHANGE130 SHORT1FROMMP(mp1) == SPN_BLUE) && / / or SPBN_ENDSPIN128 if ((SHORT1FROMMP(mp1) == SPN_RED || /* if a spin button */ 129 SHORT1FROMMP(mp1) == SPN_GREEN || /* originated SPBN_CHANGE */ 130 SHORT1FROMMP(mp1) == SPN_BLUE) && /* or SPBN_ENDSPIN */ 131 131 (SHORT2FROMMP(mp1) == SPBN_CHANGE || 132 132 SHORT2FROMMP(mp1) == SPBN_ENDSPIN)) { 133 133 PAPPDATA pad = WinQueryWindowPtr(hwnd, 0L); 134 134 ULONG ulVal; 135 if (!pad->flUpd) break; / / value changed on init or by colorwheel136 / / query new spinbutton value135 if (!pad->flUpd) break; /* value changed on init or by colorwheel */ 136 /* query new spinbutton value */ 137 137 WinSendMsg(HWNDFROMMP(mp2), SPBM_QUERYVALUE, 138 138 (MPARAM)&ulVal, MPFROM2SHORT(0, SPBQ_ALWAYSUPDATE)); … … 146 146 WinSendMsg(pad->hwndOwner, pad->cwChangedMsg, // notify owner 147 147 (MPARAM)pad->clrCurr.lClr, MPVOID); 148 } / / end if149 break; 150 / / user clicked on a PUSHBUTTON -----------------------------------------148 } /* end if */ 149 break; 150 /* user clicked on a PUSHBUTTON ----------------------------------------- */ 151 151 case WM_COMMAND: { 152 152 PAPPDATA pad = WinQueryWindowPtr(hwnd, 0L); 153 153 switch ((USHORT)mp1) { 154 case BTN_OK: / / OK: return current color154 case BTN_OK: /* OK: return current color */ 155 155 WinDismissDlg(hwnd, pad->clrCurr.lClr); 156 156 break; 157 case BTN_UNDO: / / UNDO: restore start color157 case BTN_UNDO: /* UNDO: restore start color */ 158 158 SetSpins(hwnd, pad->clrUndo); 159 159 WinSendDlgItemMsg(hwnd, CWHEEL, pad->cwSetMsg, 160 160 (MPARAM)pad->clrUndo.lClr, MPVOID); 161 161 break; 162 default: / / CANCEL: return start color162 default: /* CANCEL: return start color */ 163 163 WinDismissDlg(hwnd, pad->clrUndo.lClr); 164 164 break; 165 165 } /* endswitch */ 166 166 break; 167 } / / end case WM_COMMAND168 / / user closed the "edit color" dialog window ---------------------------169 case WM_CLOSE: { / / return start color167 } /* end case WM_COMMAND */ 168 /* user closed the "edit color" dialog window --------------------------- */ 169 case WM_CLOSE: { /* return start color */ 170 170 PAPPDATA pad = WinQueryWindowPtr(hwnd, 0L); 171 171 WinDismissDlg(hwnd, pad->clrUndo.lClr); 172 172 break; 173 } / / end case WM_CLOSE173 } /* end case WM_CLOSE */ 174 174 case WM_DESTROY: { 175 175 PAPPDATA pad = WinQueryWindowPtr(hwnd, 0L); … … 177 177 DosFreeMem(pad); 178 178 break; 179 } / / end case WM_DESTROY179 } /* end case WM_DESTROY */ 180 180 default: 181 181 return WinDefDlgProc(hwnd, msg, mp1, mp2); … … 185 185 186 186 187 / /=========================================================================\187 /*=========================================================================\ 188 188 // SetSpins() : sets the spinbutton values on initialization and when a | 189 189 // new color is set through the Color Wheel control | … … 193 193 // returned value: ------------------------------------------------------- | 194 194 // VOID | 195 //========================================================================= /195 //=========================================================================*/ 196 196 197 197
Note:
See TracChangeset
for help on using the changeset viewer.