>>>>>>>>>>>>>>>>>> LINEDEM1.CPP [03/25/98 13:17:12] <<<<<<<<<<<<<<<<<<<< #include #include #include #include //#include class TMyWindow : public TWindow { public: TMyWindow(TWindow *parent = 0); protected: void Paint(TDC &, bool, TRect &); }; class TMyApp : public TApplication { public: TMyApp() : TApplication() {} void InitMainWindow() { SetMainWindow(new TFrameWindow( 0, "LINEDEM1.CPP", new TMyWindow )); } }; TMyWindow::TMyWindow(TWindow *parent) { Init(parent, 0, 0); } void TMyWindow::Paint(TDC &dc, bool /*erase*/, TRect &/*rect*/) { dc.MoveTo(0, 0); dc.LineTo(100, 100); dc.MoveTo(200, 100); dc.LineTo(200, 0); dc.LineTo(100, 100); } int OwlMain(int, char *[]) { return TMyApp().Run(); } >>>>>>>>>>>>>>>>>> LINEDEM2.CPP [03/25/98 13:17:54] <<<<<<<<<<<<<<<<<<<< #include #include #include #include #include #include const MAX_LINES = 10; class TMyWindow : public TWindow { public: TMyWindow(TWindow *parent = 0); protected: void Paint(TDC &, bool, TRect &); }; class TMyApp : public TApplication { public: TMyApp() : TApplication() {} void InitMainWindow() { SetMainWindow(new TFrameWindow(0,"Final Window", new TMyWindow )); } }; TMyWindow::TMyWindow(TWindow *parent) { Init(parent, 0, 0); } TPoint xform(float x, float y) { const int scr_org_x = 30; const int scr_org_y = 180; const int scr_x_per_x = 1; const int scr_y_per_y = -150; TPoint scr_loc; scr_loc.x = scr_org_x + x * scr_x_per_x; scr_loc.y = scr_org_y + y * scr_y_per_y; return scr_loc; } void TMyWindow::Paint(TDC &dc, bool /*erase*/, TRect &/*rect*/) { int d; float y; dc.MoveTo(xform(0,0)); dc.LineTo(xform(360,0)); dc.MoveTo(xform(0,1)); dc.LineTo(xform(0,-1)); for (d = 0; d <= 360; d+=45) { dc.MoveTo(xform(d,0.03)); dc.LineTo(xform(d,-0.03)); } for (y = -1; y <= 1; y += 0.2) { dc.MoveTo(xform(-4,y)); dc.LineTo(xform(4,y)); } dc.MoveTo(xform(0,0)); for (d = 0; d <= 360; d++) { dc.LineTo(xform(d, sin(d*3.14159/180))); } } int OwlMain(int, char *[]) { return TMyApp().Run(); } >>>>>>>>>>>>>>>>>> LINEDEM3.CPP [08/06/97 19:46:12] <<<<<<<<<<<<<<<<<<<< #include #include #include #include #include #include #include class TMyWindow : public TWindow { public: TMyWindow(TWindow *parent = 0); protected: void Paint(TDC &, bool, TRect &); }; class TMyApp : public TApplication { public: TMyApp() : TApplication() {} void InitMainWindow() { SetMainWindow(new TFrameWindow( 0, "Linedem3", new TMyWindow )); GetMainWindow()->AssignMenu("EXITMENU"); } }; TMyWindow::TMyWindow(TWindow *parent) { Init(parent, 0, 0); } void TMyWindow::Paint(TDC &dc, bool /*erase*/, TRect &/*rect*/) { char s[81]; bool ok = TRUE; int y = 0; TBrush bluebrush(TColor::LtBlue); TBrush greenbrush(TColor::LtGreen); TBrush redbrush(TColor::LtRed); dc.FrameRect(0, 0, 350, 250, redbrush); dc.FrameRect(50, 50, 300, 200, greenbrush); dc.FrameRect(100, 100, 250, 150, bluebrush); dc.SelectObject(redbrush); dc.Rectangle(360,60,400,200); dc.RestoreBrush(); /* itoa(TColor::LtRed.Red(), s,10); MessageBox(s,"Red"); itoa(TColor::LtRed.Green(), s,10); MessageBox(s,"Green"); itoa(TColor::LtRed.Blue(), s,10); MessageBox(s,"Blue"); */ dc.SetTextColor(TColor(255,255,255)); dc.TextOut(0, y, "255,255,255"); y += dc.GetTextExtent("A", 1).cy; dc.SetTextColor(TColor(255,0,0)); dc.TextOut(0, y, "TColor(255,0,0)"); y += dc.GetTextExtent("A", 1).cy; dc.SetTextColor(TColor(0,255,0)); dc.TextOut(0, y, "TColor(0,255,0)"); y += dc.GetTextExtent("A", 1).cy; dc.SetTextColor(TColor(0,0,255)); dc.TextOut(0, y, "TColor(0,0,255)"); y += dc.GetTextExtent("A", 1).cy; dc.SetTextColor(TColor(12,55,177)); dc.TextOut(0, y, "TColor(12,55,177)"); y += dc.GetTextExtent("A", 1).cy; TPen BrushPen(TColor(255,0,0), PS_SOLID); dc.SelectObject(BrushPen); for (int i = 0; i < 10 && ok; ++i) { dc.LineTo(TPoint(10*i, 10*i*(i%2))); } } int OwlMain(int, char *[]) { return TMyApp().Run(); }