Multimedia Framework – Interactive Designer
Writing what I’m working-on sounds nice to keep track in the future, so here’s:
unit DECoreIntf; { This unit contains graphical core, framework & resource manager interfaces Author: Indra Gunawan Date: 06-11-2007 Modified: 06-14-2007 } interface { enable this Compiler Directive if you're an 3rd party class writer } {$DEFINE EXPORT_HEADER} uses Windows, Classes {$IFDEF EXPORT_HEADER}, DECoreTypes {$ENDIF}; type {$IFDEF EXPORT_HEADER} {PColor32 = ^TColor32; TColor32 = type Cardinal; PColor32Array = ^TColor32Array; TColor32Array = array [0..0] of TColor32; TArrayOfColor32 = array of TColor32; PFloat = ^TFloat; TFloat = Single; PFloatPoint = ^TFloatPoint; TFloatPoint = record X, Y: TFloat; end; PFloatRect = ^TFloatRect; TFloatRect = packed record case Integer of 0: (Left, Top, Right, Bottom: TFloat); 1: (TopLeft, BottomRight: TFloatPoint); end;} TDragState = (dsNone, dsLock, dsMove, dsSizeL, dsSizeT, dsSizeR, dsSizeB, dsSizeTL, dsSizeTR, dsSizeBL, dsSizeBR); TRBHandles = set of (rhCenter, rhSides, rhCorners, rhFrame, rhNotLeftSide, rhNotRightSide, rhNotTopSide, rhNotBottomSide, rhNotTLCorner, rhNotTRCorner, rhNotBLCorner, rhNotBRCorner); {$ENDIF} { Interface Declarations } PResourceEntry = ^TResourceEntry; TResourceEntry = packed record IID: TGUID; Instance: IInterface; { instance need maintenance the list dynamicly so we use semi circular double-linked-list rather than fixed array. indexing also supported by HashedList or TList } Prev: PResourceEntry; // if entry is root, Prev may linked to it self or nil Next: PResourceEntry; end; {PResourceTable = ^TResourceTable; TResourceTable = packed record EntryCount: Integer; Entries: array[0..9999] of PResourceEntry; end;} { forward declarations } IDEGraphicLayer = interface; IDEProxyDispatcher = interface; IDEClassRegistry = interface; { ----- resource manager interfaces ----- } { IDECachedResources only accept unique TGUID resource } IDECachedResource = interface ['{0E55234C-1E19-4D1E-B6E7-088C6CF5B23A}'] function GetResourceEntry(IID: TGUID; out Entry: PResourceEntry): HRESULT; stdcall; function AddResource(IID: TGUID; Res: IInterface): HRESULT; stdcall; function GetResource(Res: TGUID; out Intf): HRESULT; stdcall; function GetFirstResourceEntry(out Entry: PResourceEntry): HRESULT; stdcall; function GetLastResourceEntry(out Entry: PResourceEntry): HRESULT; stdcall; function RemoveResource(Res: TGUID): HRESULT; stdcall; function Clear: HRESULT; stdcall; function ResourceExist(Res: TGUID): HRESULT; stdcall; { indexing supports } function GetCount: Integer; stdcall; function GetResourceEntryByIndex(Index: Integer; out Entry: PResourceEntry): HRESULT; stdcall; function GetResourceByIndex(Index: Integer; out Intf): HRESULT; stdcall; function RemoveResourceByIndex(Index: Integer): HRESULT; stdcall; { persistent supports } function WriteToStream(Dest: TStream): HRESULT; stdcall; function ReadFromStream(Source: TStream): HRESULT; stdcall; end; IDESystemResource = interface ['{95B022AB-0ECF-4CC9-93CF-BBA176C28822}'] { Opens/creates a file. 'FileName' parameter must contain full path. Folders are created automatically. 'Mode' parameter is the same as in the TFileStream.Create. fmCreate: Creates/overwrites a file. fmOpenRead, fmOpenWrite, fmOpenReadWrite: Opens existing file in read-write mode. Read-only mode is not supported (but is automatically enforced if underlying storage is open read-only. @param fileName Absolute path of the file to be created/open. Must start with a folder delimiter (\ or /) and can contain any ascii character except #0, \ and /. @returns Nil if file does not exist and mode is not fmCreate; an object representing the file otherwise. Caller is responsible for destroying this object. } function OpenFile(const FileName: WideString; Mode: Word): TStream; stdcall; procedure CreateFolder(const FolderName: WideString); stdcall; { Moves a file or folder. } procedure Move(const ObjectName, NewName: WideString); stdcall; { Deletes a file or folder. When deleting folder, all subfolders and files are automatically deleted. } procedure Delete(const ObjectName: WideString); stdcall; function FileExists(const FileName: WideString): Boolean; stdcall; function FolderExists(const FolderName: WideString): Boolean; stdcall; procedure FileNames(const FolderName: WideString; Files: TStrings); stdcall; { Returns list of folders in folder 'FolderName'. } procedure FolderNames(const FolderName: WideString; Folders: TStrings); stdcall; { Fast way to check if folder is empty. } function IsFolderEmpty(const FolderName: WideString): Boolean; stdcall; end; TDECreateProc = function: TObject; stdcall; PClassEntry = ^TClassEntry; TClassEntry = packed record CreateProc: TDECreateProc; HLibModule: Longword; Icon: Pointer; IconSize: Longword; Name: Widestring; Description: Widestring; Author: Widestring; Version: Longint; // Hi word & Lo word { advance object hook, Garbage Collector related } AfterConstruction: Pointer; BeforeDestruction: Pointer; end; { External module library methods } { Host application / framework will be first check is TExtLibProxyDispatcherSignature method avaliable in a DLL, then check the signature is compatible or not } TExtLibProxyDispatcherSignature = function (out Signature: TGUID): HRESULT; stdcall; { After signature match, next, system initiate call to a register process (IDEClassRegistry). Be aware for 2nd, 3rd, ... class, set HLibModule to 0 (zero), assign HLibModule value that come from caller only for the 1st register process, duplicate HLibModule will cause error on FreeLibrary call } TExtLibProxyDispatcherRegister = function (Registry: IDEClassRegistry; HLibModule: Longword; out ClassCount: Integer): HRESULT; stdcall; { Base interface rights for IDEClassRegistry } TDENotifyEvent = procedure (Sender: TObject; Action, WParam, LParam: Longint) of object; stdcall; PNotifyEventEntry = ^TNotifyEventEntry; TNotifyEventEntry = packed record Proc: TDENotifyEvent; RefCount: Integer; end; IDENotifier = interface ['{A85D46B7-7C68-400C-857E-B37A0853F9E8}'] function RegisterNotification(ANotify: TDENotifyEvent): HRESULT; stdcall; function UnregisterNotification(ANotify: TDENotifyEvent): HRESULT; stdcall; function Notify(Sender: TObject; Action, WParam, LParam: Longint): HRESULT; stdcall; end; IDEClassRegistryEntry = interface ['{30AFB9F4-60CB-40E7-A41B-24AEA79A7DB5}'] end; IDEClassRegistry = interface(IDENotifier) ['{2C58AC7B-B19B-4226-9454-3947D45511F1}'] function RegisterClass(AClass: TClass; CreateProc: TDECreateProc; HLibModule: Longword; const IconData: Pointer; IconDataSize: Longword; Name, Description, Author: Widestring; Version: Longint): HRESULT; stdcall; function CreateObject(AClassName: WideString; out Intf): TObject; stdcall; end; { Visual supports - Menus, Toolbar & ToolWindow } IDEUserInterface = interface(IDEClassRegistryEntry) ['{93269A85-8ADA-424D-B734-2924F09ADF5A}'] function RegisterImageListIcon(const IconData: Pointer; DataSize: Longint): Integer; stdcall; function GetText(UIHandle: Longword): Widestring; stdcall; procedure SetText(UIHandle: Longword; Value: Widestring); stdcall; function GetValues(UIHandle: Longword; Dest: TStrings): HRESULT; stdcall; function SetValues(UIHandle: Longword; Value: TStrings): HRESULT; stdcall; function GetVisiblity(UIHandle: Longword): Boolean; stdcall; procedure SetVisiblity(UIHandle: Longword; Value: Boolean); stdcall; property Text[UIHandle: Longword]: Widestring read GetText write SetText; property Visibility[UIHandle: Longword]: Boolean read GetVisiblity write SetVisiblity; end; TDEUserInterfaceEvent = procedure (Sender: IDEUserInterface; UIHandle: Longword) of object; stdcall; IDEToolbar = interface(IDEUserInterface) ['{3ED33565-1FFE-414E-A34E-DFD9DD53ED70}'] { For each, return the handle of user interface } function Add(const Index, ImageIndex: Integer; const Title, Hint: Widestring; const OnClick: TDEUserInterfaceEvent): Longword; stdcall; function AddEdit(const Index: Integer; const Hint: Widestring; const OnChange: TDEUserInterfaceEvent): Longword; stdcall; function AddCombo(const Index: Integer; const Hint: Widestring; const OnChange: TDEUserInterfaceEvent): Longword; stdcall; function AddSpinEdit(const Index: Integer; const Hint: Widestring; const OnChange: TDEUserInterfaceEvent): Longword; stdcall; function AddSeparator(const Index: Integer): Longword; stdcall; function GetDockHandle: Longword; stdcall; procedure SetDockHandle(Value: Longword); stdcall; function GetVisible: Boolean; stdcall; procedure SetVisible(Value: Boolean); stdcall; property DockHandle: Longword read GetDockHandle write SetDockHandle; property Visible: Boolean read GetVisible write SetVisible; end; IDEFrameworkEnv = interface ['{3A5809FF-91C3-41A1-B54F-2CA688AEF36D}'] { SystemResource contains global resources (image, video, audio, text, binary etc.) related to a project. storage structure virtualy using FAT architecture, equal with physical FAT, you can create/delete/read/write folder or file } function GetSystemResource: IDESystemResource; stdcall; { ProxyDispatcherRegistry contains registered implementation classes of IDEProxyDispatcher interface, you may register your own/3rd party class to be able to communicate with the framework. Registering from external library DLL/Obj also supported using specified rule(s) } function GetProxyDispatcherRegistry: IDEClassRegistry; stdcall; { CachedResource may contains any required cache of IInterface descendant, ex. you may add your own themmed thumbnails border to share with other. For default, system doesn't save these contents to project file, but optionaly you may save your self inside your structure stream format or write it in SystemResource. } function GetCachedResource: IDECachedResource; stdcall; { External module loader supports } function LoadExternalModule(ModulePath, FileExt: WideString; Dest: IDEClassRegistry): HRESULT; stdcall; function LoadExternalProxyDispatcher(ModulePath, FileExt: WideString): HRESULT; stdcall; { Project control } function NewProject: HRESULT; stdcall; function OpenProject(const AFileName: WideString): HRESULT; stdcall; function CloseProject: HRESULT; stdcall; function SaveAs(const AFileName: WideString): HRESULT; stdcall; function Save: HRESULT; stdcall; function GetModified: Boolean; stdcall; function GetFileName: WideString; stdcall; procedure Changed; stdcall; { System } function Uninstall: HRESULT; stdcall; { Visual User Interface } function DeInitializeVisualControls: HRESULT; stdcall; function GetToolPalette: IDEToolbar; stdcall; property SystemResource: IDESystemResource read GetSystemResource; property ProxyDispatcherRegistry: IDEClassRegistry read GetProxyDispatcherRegistry; property CachedResource: IDECachedResource read GetCachedResource; property FileName: WideString read GetFileName; property Modified: Boolean read GetModified; property ToolPalette: IDEToolbar read GetToolPalette; end; { graphical interfaces } IDEBitmap = interface ['{AD2A0F91-2820-4C6C-BC58-1611C02038A8}'] function GetWidth: Integer; stdcall; procedure SetWidth(Value: Integer); stdcall; function GetHeight: Integer; stdcall; procedure SetHeight(Value: Integer); stdcall; function SetSize(NewWidth, NewHeight: Integer): Boolean; stdcall; function GetEmpty: Boolean; stdcall; function GetMeasuringMode: Boolean; stdcall; function GetBitmapHandle: HBITMAP; stdcall; function GetBitmapInfo: TBitmapInfo; stdcall; function GetHandle: HDC; stdcall; function GetBits: PColor32Array; stdcall; function GetPixelPtr(X, Y: Integer): PColor32; stdcall; function GetScanLine(Y: Integer): PColor32Array; stdcall; function GetPixel(X, Y: Integer): TColor32; stdcall; procedure SetPixel(X, Y: Integer; Value: TColor32); stdcall; procedure Changed; stdcall; procedure Clear; stdcall; procedure Reset(FillColor: TColor32); stdcall; procedure ResetAlpha; stdcall; procedure ResetAlphaValue(const AlphaValue: Byte); stdcall; { properties } property BitmapHandle: HBITMAP read GetBitmapHandle; property BitmapInfo: TBitmapInfo read GetBitmapInfo; property Handle: HDC read GetHandle; property Bits: PColor32Array read GetBits; property PixelPtr[X, Y: Integer]: PColor32 read GetPixelPtr; property ScanLine[Y: Integer]: PColor32Array read GetScanLine; property Pixel[X, Y: Integer]: TColor32 read GetPixel write SetPixel; property Width: Integer read GetWidth write SetWidth; property Height: Integer read GetHeight write SetHeight; property Empty: Boolean read GetEmpty; property MeasuringMode: Boolean read GetMeasuringMode; end; IDEGraphicLayer = interface ['{19267F9A-51DF-4982-B628-AE6F99157FE6}'] function DoHitTest(X, Y: Integer): Boolean; stdcall; function GetLocation: TFloatRect; stdcall; procedure SetLocation(Value: TFloatRect); stdcall; function GetAdjustedLocation: TFloatRect; stdcall; function GetScaled: Boolean; stdcall; procedure SetScaled(Value: Boolean); stdcall; function GetProxyDispatcher: IDEProxyDispatcher; stdcall; function Paint(Buffer: IDEBitmap): HRESULT; stdcall; property Location: TFloatRect read GetLocation write SetLocation; property Scaled: Boolean read GetScaled write SetScaled; property ProxyDispatcher: IDEProxyDispatcher read GetProxyDispatcher; end; { TODO: } IDEGraphicFilter = interface ['{02470323-C5B5-4435-8D03-8FF4F3BE3286}'] function ApplyFilter: Boolean; stdcall; end; { InteractiveStyler used to create different behavior for drag and drop & mouse operations } IDEInteractiveStyler = interface ['{E4D9B94B-77A4-4D69-9535-D252C47A10C7}'] function ApplyStyle(Target: IDEGraphicLayer; Shift: TShiftState; MousePos: TPoint; OldLocation: TFloatRect; var L, T, R, B: Single; Mx, My, W, H, MoveDirX, MoveDirY: Single): Boolean; stdcall; end; { This proxy dispatcher present to the class writer } IDEProxyDispatcher = interface(IDEClassRegistryEntry) ['{B08AF04B-6AF0-45D6-A11A-C0F96CD3E7C5}'] { interactive supports } procedure MouseDown(Button: Word; Shift: TShiftState; X, Y: Integer); stdcall; procedure MouseMove(Shift: TShiftState; X, Y: Integer); stdcall; procedure MouseUp(Button: Word; Shift: TShiftState; X, Y: Integer); stdcall; function GetDragState(X, Y: Integer): TDragState; stdcall; function GetRubberbandHandler: TRBHandles; stdcall; function GetInteractiveStyler: IDEInteractiveStyler; stdcall; { drawing supports } function DoPaint(Layer: IDEGraphicLayer; Buffer: IDEBitmap): HRESULT; stdcall; { persistent supports } function WriteToStream(Dest: TStream): HRESULT; stdcall; function ReadFromStream(Source: TStream): HRESULT; stdcall; {function WriteData(Dest: IXMLNode): HRESULT; stdcall; function ReadData(Source: IXMLNode): HRESULT; stdcall;} property RubberbandHandler: TRBHandles read GetRubberbandHandler; property InteractiveStyler: IDEInteractiveStyler read GetInteractiveStyler; end; { Base abstract class used by 3rd party class, you should create proxy/descendants using this class or do it your self with refer to IDEProxyDispatcher interface } TDEProxyDispatcher = class(TInterfacedObject, IDEClassRegistryEntry, IDEProxyDispatcher) protected procedure MouseDown(Button: Word; Shift: TShiftState; X, Y: Integer); virtual; stdcall; abstract; procedure MouseMove(Shift: TShiftState; X, Y: Integer); virtual; stdcall; abstract; procedure MouseUp(Button: Word; Shift: TShiftState; X, Y: Integer); virtual; stdcall; abstract; function GetDragState(X, Y: Integer): TDragState; virtual; stdcall; abstract; function GetRubberbandHandler: TRBHandles; virtual; stdcall; abstract; function GetInteractiveStyler: IDEInteractiveStyler; virtual; stdcall; abstract; function DoPaint(Layer: IDEGraphicLayer; Buffer: IDEBitmap): HRESULT; virtual; stdcall; abstract; function WriteToStream(Dest: TStream): HRESULT; virtual; stdcall; abstract; function ReadFromStream(Source: TStream): HRESULT; virtual; stdcall; abstract; end; implementation end.
June 13, 2007 at 8:33 am
Source-codenya harus di blok dulu biar kelihatan…
Warna theme bertolak-belakang ama Pas2HTML xixixi
June 13, 2007 at 11:36 am
Good Good Good, Gwe makin cinta am DE, huahahhahaha
June 14, 2007 at 4:44 am
Hi Indra!
Black text on black background is incredible hard to read ;o)
Stefan
June 14, 2007 at 5:09 am
Hi Stef!
I make it white just as yours
July 5, 2007 at 1:59 pm
Mas Indra itu buat apaan? dijelasin dikit yachhhh….
July 31, 2007 at 11:42 am
let’s go make delphi live
November 4, 2008 at 10:57 pm
hi.. teman-teman…
ada yang bisa minta tolong caranya deteksi pixel di image ngak…
makaasih
November 5, 2008 at 5:20 am
>> ada yang bisa minta tolong caranya deteksi pixel di image ngakā¦
http://delphi-id.org/dpr/index.php?name=PNphpBB2&file=viewtopic&t=5945