|
|
1.1 root 1: //==========================================================================//
2: // Includes //
3: //==========================================================================//
4:
5: #include <stdio.h>
6:
7: #include "perfmon.h" // included by all source
8: #include "timefrm.h" // external declarations for this file
9:
10: #include "alert.h" // for PlaybackAlert
11: #include "grafdata.h" // for PlaybackChart
12: #include "perfmops.h" // for PerfmonViewWindow
13: #include "playback.h" // for PlaybackIndexN
14: #include "report.h" // for PlaybackReport
15: #include "timeline.h" // for TL_INTERVAL
16: #include "utils.h"
17: #include "pmhelpid.h" // for Help IDs
18:
19: //==========================================================================//
20: // Local Data //
21: //==========================================================================//
22:
23:
24:
25: static RECT TFrameRectWindow ;
26:
27: //==========================================================================//
28: // Local Functions //
29: //==========================================================================//
30:
31:
32: void ClearSystemTime (SYSTEMTIME *pSystemTime)
33: { // ClearSystemTime
34: pSystemTime->wYear = 0 ;
35: pSystemTime->wMonth = 0 ;
36: pSystemTime->wDayOfWeek = 0 ;
37: pSystemTime->wDay = 0 ;
38: pSystemTime->wHour = 0 ;
39: pSystemTime->wMinute = 0 ;
40: pSystemTime->wSecond = 0 ;
41: pSystemTime->wMilliseconds = 0 ;
42: } // ClearSystemTime
43:
44:
45: //==========================================================================//
46: // Message Handlers //
47: //==========================================================================//
48:
49:
50: void static OnInitDialog (HDLG hDlg)
51: { // OnInitDialog
52: PBOOKMARK pBookmark ;
53: int iIndex ;
54: TCHAR szText [20+20+BookmarkCommentLen] ;
55: TCHAR szDate [20] ;
56: TCHAR szTime [20] ;
57: int iBookmarksNum ;
58: HWND hWndTLine ;
59: HWND hWndBookmarks ;
60: int currentTextExtent = 0 ;
61: int maxTextExtent = 0 ;
62: HDC hDC = 0 ;
63: HFONT hFont ;
64:
65: hWndTLine = DialogControl (hDlg, IDD_TIMEFRAMETIMELINE) ;
66: hWndBookmarks = DialogControl (hDlg, IDD_TIMEFRAMEBOOKMARKS) ;
67: SetFont (hWndBookmarks, hFontScales) ;
68: LBSetHorzExtent (hWndBookmarks, 0) ;
69:
70: TLineSetRange (hWndTLine, 0, PlaybackLog.iTotalTics - 1) ;
71: TLineSetStart (hWndTLine, PlaybackLog.StartIndexPos.iPosition) ;
72: TLineSetStop (hWndTLine, PlaybackLog.StopIndexPos.iPosition) ;
73:
74: iBookmarksNum = 0 ;
75: pBookmark = PlaybackLog.pBookmarkFirst ;
76:
77: if (pBookmark)
78: {
79: hDC = GetDC (hWndBookmarks) ;
80: if (hDC)
81: {
82: hFont = (HFONT)SendMessage(hWndBookmarks, WM_GETFONT, 0, 0L);
83: if (hFont)
84: SelectObject(hDC, hFont);
85: }
86:
87: while (pBookmark)
88: {
89: SystemTimeDateString (&(pBookmark->SystemTime), szDate) ;
90: SystemTimeTimeString (&(pBookmark->SystemTime), szTime) ;
91: TSPRINTF (szText, TEXT(" %s %s %s"),
92: szDate, szTime,
93: pBookmark->szComment) ;
94: iIndex = LBAdd (hWndBookmarks, szText) ;
95: LBSetData (hWndBookmarks, iIndex, pBookmark->iTic) ;
96:
97: // get the biggest text width
98: if (hDC)
99: {
100: currentTextExtent = TextWidth (hDC, szText) + xScrollWidth / 2 ;
101: if (currentTextExtent > maxTextExtent)
102: {
103: maxTextExtent = currentTextExtent ;
104: }
105: }
106:
107: pBookmark = pBookmark->pBookmarkNext ;
108: }
109:
110: LBSetSelection (hWndBookmarks, 0) ;
111:
112: iBookmarksNum = LBNumItems (hWndBookmarks) ;
113: }
114:
115: if (iBookmarksNum == 0)
116: {
117: DialogEnable (hDlg, IDD_TIMEFRAMEBOOKMARKS, FALSE) ;
118: DialogEnable (hDlg, IDD_TIMEFRAMEBOOKMARKGRP, FALSE) ;
119: DialogEnable (hDlg, IDD_TIMEFRAMESETSTART, FALSE) ;
120: DialogEnable (hDlg, IDD_TIMEFRAMESETSTOP, FALSE) ;
121: }
122: else
123: {
124: LBSetHorzExtent (hWndBookmarks, maxTextExtent) ;
125: }
126:
127: if (hDC)
128: {
129: ReleaseDC (hWndBookmarks, hDC) ;
130: }
131:
132: if (TFrameRectWindow.right == TFrameRectWindow.left)
133: {
134: // we have not initialize this data yet.
135: // will get init. after the first time frame window invoke
136: WindowCenter (hDlg) ;
137: }
138: else
139: {
140: // show it in its previous position
141: MoveWindow (hDlg,
142: TFrameRectWindow.left,
143: TFrameRectWindow.top,
144: TFrameRectWindow.right - TFrameRectWindow.left,
145: TFrameRectWindow.bottom - TFrameRectWindow.top,
146: TRUE) ;
147: }
148:
149: dwCurrentDlgID = HC_PM_idDlgEditTimeFrame ;
150:
151: } // OnInitDialog
152:
153:
154: void static OnTLineInterval (HDLG hDlg,
155: int iInterval,
156: SYSTEMTIME *pSystemTime)
157: { // OnTLineInterval
158: PLOGINDEX pIndex ;
159:
160:
161: pIndex = PlaybackIndexN (iInterval) ;
162:
163: if (pIndex)
164: *pSystemTime = pIndex->SystemTime ;
165: else
166: ClearSystemTime (pSystemTime) ;
167: } // OnTLineInterval
168:
169:
170: void static OnOK (HDLG hDlg)
171: { // OnOK
172: LOGPOSITION lp ;
173: int iIndex ;
174: HWND hWndTLine = DialogControl (hDlg, IDD_TIMEFRAMETIMELINE) ;
175:
176: iIndex = TLineStart (hWndTLine) ;
177: if (LogPositionN (iIndex, &lp)) ;
178: PlaybackLog.StartIndexPos = lp ;
179:
180: iIndex = TLineStop (hWndTLine) ;
181: if (LogPositionN (iIndex, &lp))
182: PlaybackLog.StopIndexPos = lp ;
183:
184:
185: PlaybackLog.iSelectedTics =
186: PlaybackLog.StopIndexPos.iPosition -
187: PlaybackLog.StartIndexPos.iPosition + 1 ;
188:
189: PlaybackChart (hWndGraph) ;
190: PlaybackAlert (hWndAlert, 0) ;
191: PlaybackReport (hWndReport) ;
192:
193: WindowInvalidate (PerfmonViewWindow ()) ;
194:
195: GetWindowRect (hDlg, &TFrameRectWindow) ;
196:
197: dwCurrentDlgID = 0 ;
198: } // OnOK
199:
200: void static OnCancel (HWND hWnd)
201: {
202: HDC hGraphDC ;
203: PGRAPHSTRUCT pGraph ;
204:
205: pGraph = GraphData (hWndGraph) ;
206: hGraphDC = GetDC (hWndGraph) ;
207: if (!hGraphDC || !pGraph)
208: {
209: return ;
210: }
211:
212: TLineRedraw (hGraphDC, pGraph) ;
213:
214: GetWindowRect (hWnd, &TFrameRectWindow) ;
215:
216: dwCurrentDlgID = 0 ;
217: }
218:
219:
220: void OnSetStartStop (HWND hDlg, BOOL bSetStart)
221: {
222: int iTic ;
223: int iStopTic ;
224: int iStartTic ;
225: HWND hWndTLine = DialogControl (hDlg, IDD_TIMEFRAMETIMELINE) ;
226: HWND hWndBookmarks = DialogControl (hDlg, IDD_TIMEFRAMEBOOKMARKS) ;
227:
228: iStartTic = TLineStart (hWndTLine) ;
229: iStopTic = TLineStop (hWndTLine) ;
230:
231: iTic = LBData (hWndBookmarks, LBSelection (hWndBookmarks)) ;
232: if ((bSetStart && iStopTic <= iTic) ||
233: (!bSetStart && iStartTic >= iTic))
234: {
235: DlgErrorBox (hDlg, ERR_STOPBEFORESTART) ;
236: }
237: else
238: {
239: if (bSetStart)
240: {
241: TLineSetStart (hWndTLine, iTic) ;
242: }
243: else
244: {
245: TLineSetStop (hWndTLine, iTic) ;
246: }
247: WindowInvalidate (hWndTLine) ;
248: }
249: } // OnSetStartStop
250:
251:
252: //==========================================================================//
253: // Exported Functions //
254: //==========================================================================//
255:
256:
257: int FAR WINAPI TimeframeDlgProc (HWND hDlg,
258: unsigned iMessage,
259: WPARAM wParam,
260: LONG lParam)
261: {
262: BOOL bHandled ;
263:
264: bHandled = TRUE ;
265: switch (iMessage)
266: {
267: case TL_INTERVAL:
268: OnTLineInterval (hDlg, wParam, (SYSTEMTIME *) lParam) ;
269: break ;
270:
271: case WM_INITDIALOG:
272: OnInitDialog (hDlg) ;
273: return (TRUE) ;
274:
275: case WM_CLOSE:
276: OnCancel (hDlg) ;
277: EndDialog (hDlg, 0) ;
278: break ;
279:
280: case WM_COMMAND:
281: switch(wParam)
282: {
283: case IDD_OK:
284: SetHourglassCursor() ;
285: OnOK (hDlg) ;
286: SetArrowCursor() ;
287: EndDialog (hDlg, 1) ;
288: break ;
289:
290: case IDD_TIMEFRAMESETSTART:
291: case IDD_TIMEFRAMESETSTOP:
292: OnSetStartStop (hDlg, wParam == IDD_TIMEFRAMESETSTART) ;
293: break ;
294:
295: case IDD_CANCEL:
296: OnCancel (hDlg) ;
297: GetWindowRect (hDlg, &TFrameRectWindow) ;
298: EndDialog (hDlg, 0) ;
299: break ;
300:
301: case IDD_TIMEFRAMEHELP:
302: CallWinHelp (dwCurrentDlgID) ;
303: break ;
304:
305: default:
306: bHandled = FALSE ;
307: break;
308: }
309: break;
310:
311:
312: default:
313: bHandled = FALSE ;
314: break ;
315: } // switch
316:
317: return (bHandled) ;
318: } // TimeframeDlgProc
319:
320:
321:
322: BOOL SetTimeframe (HWND hWndParent)
323: { // SetTimeframe
324: if (DialogBox (hInstance, idDlgTimeframe,
325: hWndParent, (DLGPROC) TimeframeDlgProc))
326: {
327: return (TRUE) ;
328: }
329: return (FALSE) ;
330: }
331:
332:
333:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.