home *** CD-ROM | disk | FTP | other *** search
- //---------------------------------------------------------------------------
- #include <vcl\vcl.h>
- #pragma hdrstop
-
- #include "dragitem.h"
- #include "math.h"
- //---------------------------------------------------------------------------
- #pragma link "RChart"
- #pragma resource "*.dfm"
- TForm1 *Form1;
- bool MarkedMove = false;
- bool FirstMove = true;
- int LastPosX, LastPosY;
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::SbMarkClick(TObject *Sender)
- {
- double xLo, YLo, XHi, YHi;
-
- PnlStat->Caption = "Select the data to move";
- MarkedMove = SBDrag->Down;
- if (RChart1->MouseBox (xLo, YLo, XHi, YHi) == true)
- {
- RChart1->MarkItemsInWindow (xLo, YLo, XHi, YHi, tkMarkAt, 99);
- RChart1->NewColorOfClassItems (clBlue, 99);
- RChart1->ShowGraf();
- }
- SbMark->Down = False;
- SBDrag->Down = True;
- MarkedMove = SBDrag->Down;
- PnlStat->Caption = "Drag the data by clicking the chart and draging the mouse";
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::SBDragClick(TObject *Sender)
- {
- MarkedMove = SBDrag->Down;
- if (MarkedMove == true)
- {
- PnlStat->Caption = "Drag the data by clicking the chart and draging the mouse";
- }
- else
- {
- PnlStat->Caption = "";
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::SBClearMarksClick(TObject *Sender)
- {
- SBDrag->Down = False;
- RChart1->MarkAllItems (tkEverything, 0);
- RChart1->NewColorOfClassItems (clRed, 0);
- RChart1->ShowGraf();
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::BBtDoneClick(TObject *Sender)
- {
- Close();
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::FormActivate(TObject *Sender)
- {
- const int Numval = 200;
- int i;
-
- RChart1->RangeHiX = Numval;
- RChart1->RangeLoX = 0;
- RChart1->RangeHiY = 10;
- RChart1->RangeLoY = -10;
- RChart1->DataColor = clRed;
- for (i=1; i<=Numval; i++)
- RChart1->MarkAt (i,i/20.0*sin(i*0.15)*cos(i*0.062),4);
- RChart1->MoveTo (0,0); // dummy token for FindNext-example
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::RChart1MouseMove(TObject *Sender, TShiftState Shift,
- int X, int Y)
- {
- double rx, ry, rx2, ry2;
-
- if (Shift.Contains(ssLeft) && (MarkedMove == true))
- {
- if (FirstMove == true)
- {
- FirstMove = false;
- LastPosX = X;
- LastPosY = Y;
- }
- else
- {
- RChart1->M2R (X,Y,rx,ry);
- RChart1->M2R (LastPosX,LastPosY,rx2,ry2);
- RChart1->ScaleSelectedItems (1,rx-rx2,1,ry-ry2,99);
- RChart1->ShowGraf();
- LastPosX = X;
- LastPosY = Y;
- }
- }
- else
- {
- FirstMove = True;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::FormMouseMove(TObject *Sender, TShiftState Shift, int X,
- int Y)
- {
- Screen->Cursor = crDefault;
- }
- //---------------------------------------------------------------------------