|
|
Inside drawers
Any drawer (TCustomDrawer descendant), has several virtual methods wich are called from associated TImageEditor. This events support all drawing and editing functionality, because TImageEditor itself just shows, saves and loads edited image. TImageEditor translates all user input into assiciated drawers' methods calls. For instance, when user moves mouse over TImageEditor, TImageEditor calls Move method, when user presses the mouse button, TImageEditor calls StartDraw method and when mouse moving calls Draw method with Move method till user releases button, and TImageEditor calls StopDraw method. There are several groups of drawers' methods:
- User input (keyboard, mouse and special events, like Enter, Esc and double-click)
- KeyDown, KeyUp, KeyPress, MouseEnter, MouseLeave, Move, StartDraw, Draw, StopDraw, CancelChanges, ApplyChanges
- Notification (drawing context, image, undo, display, etc. changing)
- ToolChanging, ToolChange, SettingsChange, ColorsChange, FontChange, ImageChange, UndoChange
- Painting (methods for direct painting)
- BeforePaintEditor, AfterPaintEditor
- Selection (selection and clip operations)
- DeleteClip, CopyClipToClipboard, PasteClipFromClipboard, LoadClipFromFile, SaveClipToFile, CropBySelection
- Other (service functions)
- SetCursor, GetToolName
Of course, most important part is drawing, and, of course, there are many useful things which simplify coding. For instance, TImageEditor has many useful properties which save both last and previous points of each mouse events: OldStart, NewStart, OldMove, NewMove, OldStop, NewsStop, so you don't need to save them yourself. All you need, for example, the drawing line between last two mouse click point looks like this:
MoveTo(OldStop.X,OldStop.Y);
LineTo(NewStop.X,NewStop.Y);
There are another good news: TImageEditor supports scaling and scrolling itself, so in these properties you always have coordinates within edited image, independently from current scale and scroll position. All you need is to draw on the TImageEditor's Canvas property inside image (see ImageWidth and ImageHeight properties of TImageEditor) in 1:1 scale - TImageEditor will do the rest!
|
|