home *** CD-ROM | disk | FTP | other *** search
- Object Graphics Update
- Received from Whitewater 06-Sep-91
-
- ===============================================================================
-
- 1) replace TMathRect.Contains and TGraphic.MarkCorners as shown
- below to allow the selection of a graphic will no width and/or
- no height (including horizontal and vertical lines).
-
- {------------------------------------------------------------------
- Returns True if Self contains the specified point. Normalizes a
- copy of Self, and returns the result of a call to the WhatSide
- method of the normalized copy.
- ------------------------------------------------------------------
- }
- function TMathRect.Contains(APoint: PGPoint): Boolean;
- var
- AMathRect: TMathRect;
- begin
- AMathRect.Init(Left, Top, Right, Bottom);
- AMathRect.Normalize;
- Contains := AMathRect.WhatSide(APoint) = 0;
- AMathRect.Done;
- end;
-
- modified TGraphic.MarkCorners as follows:
-
- {------------------------------------------------------------------
- Marks the corners of a TLine. Adds markers centered at Self's
- corners to the specified polymark. Adds 4 markers when Self
- has non-zero width and height, adds 2 markers when Self has
- width but not height or vice-versa, adds 1 marker when Self
- has neither width nor height. These checks are made to prevent
- markers from being positioned on top of eachother - when two
- markers with cb_NXor combination are drawn on top of eachother
- they become invisible).
- ------------------------------------------------------------------
- }
- procedure TGraphic.MarkCorners(NewMarker: PPolymark);
- var
- BRect : TMathRect;
- APoint: TGPoint;
- begin
- BRect.InitDefault;
- GetBoundsRect(BRect);
- BRect.Normalize;
- NewMarker^.AddMark(BRect.Origin);
- if BRect.Width <> 0 then
- begin
- APoint.Init(BRect.Right, BRect.Top);
- NewMarker^.AddMark(@APoint);
- end;
- if BRect.Height <> 0 then
- begin
- APoint.Init(BRect.Left, BRect.Bottom);
- NewMarker^.AddMark(@APoint);
- if BRect.Width <> 0 then
- NewMarker^.AddMark(BRect.Corner);
- end;
- BRect.Done;
- end;
-
- ================================================================================
-
- 2) replace EndSelectDrag in DRAWWIN.PAS below to allow the scaling of
- selected graphics when the selected graphics (as a group) have no
- width and/or no height (including horizontal and vertical lines).
-
- procedure EndSelectDrag;
- var
- TempChosen : PSubPicture;
- XScale, YScale: Integer;
- begin
- if (TheChosen^.Count > 0) and ((KeyStates and mk_Shift) = 0) then
- begin
- if Cursor <> cs_User1 then
- begin
- TheMarks^.GetBoundsRect(BRect);
- BRect.Invalidate(Port);
- TheChosen^.PositionAt(AGraphic^.Origin);
- Picture^.FindBounds; { In case TheChosen moved outside them }
- TheMarks^.SetMark(nil); { Set to standard marker in case it was changed }
- TheMarks^.FreeAll;
- TheChosen^.MarkCorners(TheMarks);
- TheMarks^.GetBoundsRect(BRect);
- BRect.Invalidate(Port);
- end
- else
- begin
- if TheChosen^.Width > 0 then
- XScale := Integer(((LongInt(AGraphic^.Width) * 100) + 50)
- div TheChosen^.Width)
- else XScale := 0;
- if TheChosen^.Height > 0 then
- YScale := Integer(((LongInt(AGraphic^.Height) * 100) + 50)
- div TheChosen^.Height)
- else YScale := 0;
- TheChosen^.MarkCorners(TheMarks); { Needed by ScaleChosen }
- ScaleChosen(XScale, YScale);
- end;
- Dispose(HitPt, Done);
- end
- else
- begin
- TempChosen := TheChosen^.Copy;
- TheChosen^.FreeAll;
- if (TempChosen^.Count > 0) and ((KeyStates and mk_Shift) <> 0) then
- PChooser(AGraphic)^.ChooseNext(Picture, TempChosen^.At(0), TheChosen^)
- else
- PChooser(AGraphic)^.Choose(Picture, TheChosen^);
- Dispose(TempChosen, Done);
-
- if TheChosen^.Count > 0 then
- begin
- TheChosen^.MarkCorners(TheMarks);
- TheMarks^.Draw(Port);
- end;
- end;
- PGWindow(Parent)^.SetPicture(TheChosen); {Indicate what was chosen}
- end;
-
- ===============================================================================
-
- 3) replace TDrawWindow.MouseMove to prevent cursor flicker when the mouse
- is positioned over a marker of a selected graphic.
-
- {------------------------------------------------------------------
- Tracks movement of the mouse when not dragging. Changes the
- cursor when the mouse is positioned over a selection marker.
- ------------------------------------------------------------------
- }
- procedure TDrawWindow.MouseMove(MousePt: PGPoint; KeyStates: Word);
- begin
- if TheChosen^.Count > 0 then
- if TheMarks^.Contains(MousePt) then
- begin
- if Cursor <> cs_User1 then
- SavedCursor := Cursor;
- SetGCursor(cs_User1);
- end
- else
- SetGCursor(SavedCursor)
- end;
-
- ===============================================================================
-
- 4) replace TMainWindow.CMFileOpen so that rulers are automatically turned
- off when a OGL file is opened which contains a graph space with
- device units.
-
- procedure TMainWindow.CMFileOpen(var Msg: TMessage);
- var
- TmpFile : array [0..fsPathName] of Char;
- APicture : PPicture;
- ASpace : PGraphSpace;
- FileStream: TGStream;
- Header : TFileHeader;
- begin
- if Application^.ExecDialog(New(PFileDialog, Init(@Self,
- PChar(sd_FileOpen), StrCopy(TmpFile, '*.ogl')))) = id_Ok
- then
- begin
- StrCopy(FileName, TmpFile);
- FileStream.Init(FileName, stOpen, 10000);
- if ReadOGLHeader(FileStream, Header) then
- begin
- ASpace := PGraphSpace(FileStream.Get);
- APicture:= PPicture(FileStream.Get);
- end;
- FileStream.Done;
-
- DrawWindow^.SetSpace(ASpace);
- if (ASpace^.Units = gs_Device) and ViewRulers then
- CMToggleRulers(Msg);
- DrawWindow^.SetPicture(APicture);
- SetKidSpaces;
- SetCaption;
- end;
- end;
-
- ================================================================================
-
-