home *** CD-ROM | disk | FTP | other *** search
- /**********************************************************
-
- GraphDlg.cpp
- Copyright TransEra Corporation 1999.
-
- ***********************************************************/
- #include "stdafx.h"
- #include "HTBgraph.h"
- #include "GraphDlg.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- #define TIMERVAL 100
- #define INITIAL_SIZE_WIDTH 210
- #define INITIAL_SIZE_HEIGHT 270
- #define COLOR_MAX 255
- #define COLOR_MIN 0
- #define BOX_PERIMETER 200
- #define TEXT_BOX_BOUNDS 240
- #define ORIGIN 0
- #define BASE_LINE 210
- #define GRAPH_ONE 1
- #define GRAPH_TWO 2
- #define GRAPH_THREE 3
- #define SCALE 60
- #define BAR_GRAPH_WIDTH 10
- #define GRAPH_BASE_START 20
-
- GraphDlg::GraphDlg(CWnd* pParent /*=NULL*/)
- : CDialog(GraphDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(GraphDlg)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- }
-
-
- void GraphDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(GraphDlg)
- // NOTE: the ClassWizard will add DDX and DDV calls here
- //}}AFX_DATA_MAP
- }
-
-
- BEGIN_MESSAGE_MAP(GraphDlg, CDialog)
- //{{AFX_MSG_MAP(GraphDlg)
- ON_WM_PAINT()
- ON_WM_TIMER()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- /////////////////////////////////////////////////////////////////////////////
- /*
- Function: GraphDlg::OnInitDialog
-
- Description: Starts Timer and initializes Dialog Box.
-
- Return type: BOOL
-
- Notes: This funtion will initialize the Dialog Window,
- Set it's starting positions and other Dialog
- options, this function will also start the timer.
- */
- BOOL GraphDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
- SetWindowPos(FromHandle(m_hWnd), g_XPos, g_YPos,
- INITIAL_SIZE_WIDTH, INITIAL_SIZE_HEIGHT, SWP_NOZORDER);
- SetTimer(1,TIMERVAL,NULL);
- return TRUE;
- }
-
- /////////////////////////////////////////////////////////////////////////////
- /*
- Function: GraphDlg::OnPaint
-
- Description: Draws lines, boxes, colors.
-
- Return type: void
-
- Notes: This function will do the actual "drawing" on the
- dialog box through the use of a CPaintDC
- structure. The pointers coming into this function
- represent data coming from HTBasic and is thus
- graphically displayed.
- */
- void GraphDlg::OnPaint()
- {
- static int iGraphDataInput0, iGraphDataInput1, iGraphDataInput2; // Integer containing bar height
- CString sOutPutString0, sOutPutString1, sOutPutString2; // Strings containing text of height
-
- CPaintDC dc(this);
- CBrush brush0 (RGB(COLOR_MAX, COLOR_MIN, COLOR_MIN)); // Red Brush Definition
- CBrush brush1 (RGB(COLOR_MIN, COLOR_MAX, COLOR_MIN)); // Green Brush Definition
- CBrush brush2 (RGB(COLOR_MIN, COLOR_MIN, COLOR_MAX)); // Blue Brush Definition
-
- iGraphDataInput0 = (*pBasicVar0); // Generate some Y values
- iGraphDataInput1 = (*pBasicVar1);
- iGraphDataInput2 = (*pBasicVar2);
-
- // Draw the box around the bar graphs
- dc.MoveTo(ORIGIN,ORIGIN);
- dc.LineTo(BOX_PERIMETER, ORIGIN);
- dc.LineTo(BOX_PERIMETER, BOX_PERIMETER);
- dc.LineTo(ORIGIN, BOX_PERIMETER);
- dc.LineTo(ORIGIN,ORIGIN);
- // Draw box around box containing text
- dc.MoveTo(BOX_PERIMETER,BOX_PERIMETER);
- dc.LineTo(BOX_PERIMETER,TEXT_BOX_BOUNDS);
- dc.LineTo(ORIGIN, TEXT_BOX_BOUNDS);
- dc.LineTo(ORIGIN, BOX_PERIMETER);
- dc.SelectObject(&brush0); // Assign Red Color
- // draw bar graphs
- dc.Rectangle(GRAPH_BASE_START, (BOX_PERIMETER - iGraphDataInput0),
- (SCALE * GRAPH_ONE), BOX_PERIMETER); // Draw Red Graph
- sOutPutString0.Format("%d", iGraphDataInput0);
- dc.TextOut((GRAPH_BASE_START + BAR_GRAPH_WIDTH), BASE_LINE, sOutPutString0);
- dc.SelectObject(&brush1); // Assign Green Color
- dc.Rectangle((GRAPH_BASE_START +SCALE), (BOX_PERIMETER - iGraphDataInput1),
- (SCALE * GRAPH_TWO), BOX_PERIMETER); // Draw Green Graph
- sOutPutString1.Format("%d", iGraphDataInput1);
- dc.TextOut((GRAPH_BASE_START + SCALE + BAR_GRAPH_WIDTH), BASE_LINE, sOutPutString1);
- dc.SelectObject(&brush2); // Assign Blue Color
- dc.Rectangle(((GRAPH_TWO * SCALE) + GRAPH_BASE_START), (BOX_PERIMETER - iGraphDataInput2),
- (SCALE * GRAPH_THREE), BOX_PERIMETER); // Draw Blue Graph
- sOutPutString2.Format("%d", iGraphDataInput2);
- dc.TextOut(((GRAPH_TWO * SCALE) + GRAPH_BASE_START + BAR_GRAPH_WIDTH),
- BASE_LINE, sOutPutString2);
- }
-
- /////////////////////////////////////////////////////////////////////////////
- /*
- Function: GraphDlg::OnTimer
-
- Description: Strobes Timer for update with invalidate function.
-
- Return type: void
- Argument: UINT nIDEvent
-
- Notes: This function simply invalidates the dialog box,
- this causes it to be updated every time it is
- invalidated, this is what "creates" the animation
- or motion effects.
- */
- void GraphDlg::OnTimer(UINT nIDEvent)
- {
- Invalidate();
- CDialog::OnTimer(nIDEvent);
- }
-