First commit 19/07/1998
This commit is contained in:
BIN
CDopping/CoolForm/Cool.res
Normal file
BIN
CDopping/CoolForm/Cool.res
Normal file
Binary file not shown.
BIN
CDopping/CoolForm/CoolButton.OBJ
Normal file
BIN
CDopping/CoolForm/CoolButton.OBJ
Normal file
Binary file not shown.
BIN
CDopping/CoolForm/CoolButton.dcu
Normal file
BIN
CDopping/CoolForm/CoolButton.dcu
Normal file
Binary file not shown.
123
CDopping/CoolForm/CoolButton.hpp
Normal file
123
CDopping/CoolForm/CoolButton.hpp
Normal file
@ -0,0 +1,123 @@
|
||||
// Borland C++ Builder
|
||||
// Copyright (c) 1995, 1998 by Borland International
|
||||
// All rights reserved
|
||||
|
||||
// (DO NOT EDIT: machine generated header) 'CoolButton.pas' rev: 3.00
|
||||
|
||||
#ifndef CoolButtonHPP
|
||||
#define CoolButtonHPP
|
||||
#include <Commctrl.hpp>
|
||||
#include <ExtCtrls.hpp>
|
||||
#include <StdCtrls.hpp>
|
||||
#include <Graphics.hpp>
|
||||
#include <Forms.hpp>
|
||||
#include <Controls.hpp>
|
||||
#include <Classes.hpp>
|
||||
#include <Messages.hpp>
|
||||
#include <Windows.hpp>
|
||||
#include <SysInit.hpp>
|
||||
#include <System.hpp>
|
||||
|
||||
//-- user supplied -----------------------------------------------------------
|
||||
|
||||
namespace Coolbutton
|
||||
{
|
||||
//-- type declarations -------------------------------------------------------
|
||||
enum TButtonLayout { blGlyphLeft, blGlyphRight, blGlyphTop, blGlyphBottom };
|
||||
|
||||
enum TButtonState { bsUp, bsDisabled, bsDown, bsExclusive };
|
||||
|
||||
enum TButtonStyle { bsAutoDetect, bsWin31, bsNew };
|
||||
|
||||
typedef Shortint TNumGlyphs;
|
||||
|
||||
class DELPHICLASS TCoolButton;
|
||||
class PASCALIMPLEMENTATION TCoolButton : public Controls::TGraphicControl
|
||||
{
|
||||
typedef Controls::TGraphicControl inherited;
|
||||
|
||||
private:
|
||||
int FGroupIndex;
|
||||
void *FGlyph;
|
||||
bool FDown;
|
||||
bool FDragging;
|
||||
bool FAllowAllUp;
|
||||
TButtonLayout FLayout;
|
||||
int FSpacing;
|
||||
int FMargin;
|
||||
bool FMouseInControl;
|
||||
void __fastcall GlyphChanged(System::TObject* Sender);
|
||||
void __fastcall UpdateExclusive(void);
|
||||
Graphics::TBitmap* __fastcall GetGlyph(void);
|
||||
void __fastcall SetGlyph(Graphics::TBitmap* Value);
|
||||
TNumGlyphs __fastcall GetNumGlyphs(void);
|
||||
void __fastcall SetNumGlyphs(TNumGlyphs Value);
|
||||
void __fastcall SetDown(bool Value);
|
||||
void __fastcall SetAllowAllUp(bool Value);
|
||||
void __fastcall SetGroupIndex(int Value);
|
||||
void __fastcall SetLayout(TButtonLayout Value);
|
||||
void __fastcall SetSpacing(int Value);
|
||||
void __fastcall SetMargin(int Value);
|
||||
void __fastcall UpdateTracking(void);
|
||||
HIDESBASE MESSAGE void __fastcall WMLButtonDblClk(Messages::TWMMouse &Message);
|
||||
HIDESBASE MESSAGE void __fastcall CMEnabledChanged(Messages::TMessage &Message);
|
||||
MESSAGE void __fastcall CMButtonPressed(Messages::TMessage &Message);
|
||||
MESSAGE void __fastcall CMDialogChar(Messages::TWMKey &Message);
|
||||
HIDESBASE MESSAGE void __fastcall CMFontChanged(Messages::TMessage &Message);
|
||||
MESSAGE void __fastcall CMTextChanged(Messages::TMessage &Message);
|
||||
MESSAGE void __fastcall CMSysColorChange(Messages::TMessage &Message);
|
||||
HIDESBASE MESSAGE void __fastcall CMMouseLeave(Messages::TMessage &Message);
|
||||
MESSAGE void __fastcall WMEraseBkgnd(Messages::TWMEraseBkgnd &message);
|
||||
HIDESBASE MESSAGE void __fastcall WMPaint(Messages::TWMPaint &message);
|
||||
MESSAGE void __fastcall WMNCPaint(Messages::TWMNoParams &message);
|
||||
|
||||
protected:
|
||||
TButtonState FState;
|
||||
DYNAMIC HPALETTE __fastcall GetPalette(void);
|
||||
virtual void __fastcall Loaded(void);
|
||||
DYNAMIC void __fastcall MouseDown(Controls::TMouseButton Button, Classes::TShiftState Shift, int X,
|
||||
int Y);
|
||||
DYNAMIC void __fastcall MouseMove(Classes::TShiftState Shift, int X, int Y);
|
||||
DYNAMIC void __fastcall MouseUp(Controls::TMouseButton Button, Classes::TShiftState Shift, int X, int
|
||||
Y);
|
||||
virtual void __fastcall Paint(void);
|
||||
|
||||
public:
|
||||
__fastcall virtual TCoolButton(Classes::TComponent* AOwner);
|
||||
__fastcall virtual ~TCoolButton(void);
|
||||
DYNAMIC void __fastcall Click(void);
|
||||
|
||||
__published:
|
||||
__property bool AllowAllUp = {read=FAllowAllUp, write=SetAllowAllUp, default=0};
|
||||
__property int GroupIndex = {read=FGroupIndex, write=SetGroupIndex, default=0};
|
||||
__property bool Down = {read=FDown, write=SetDown, default=0};
|
||||
__property Caption ;
|
||||
__property Enabled ;
|
||||
__property Font ;
|
||||
__property Graphics::TBitmap* Glyph = {read=GetGlyph, write=SetGlyph};
|
||||
__property TButtonLayout Layout = {read=FLayout, write=SetLayout, default=0};
|
||||
__property int Margin = {read=FMargin, write=SetMargin, default=-1};
|
||||
__property TNumGlyphs NumGlyphs = {read=GetNumGlyphs, write=SetNumGlyphs, default=4};
|
||||
__property ParentFont ;
|
||||
__property ParentShowHint ;
|
||||
__property ShowHint ;
|
||||
__property int Spacing = {read=FSpacing, write=SetSpacing, default=4};
|
||||
__property Visible ;
|
||||
__property OnClick ;
|
||||
__property OnDblClick ;
|
||||
__property OnMouseDown ;
|
||||
__property OnMouseMove ;
|
||||
__property OnMouseUp ;
|
||||
};
|
||||
|
||||
//-- var, const, procedure ---------------------------------------------------
|
||||
extern PACKAGE void __fastcall Register(void);
|
||||
extern PACKAGE Windows::TRect __fastcall DrawButtonFace(Graphics::TCanvas* Canvas, const Windows::TRect
|
||||
&Client, int BevelWidth, TButtonStyle Style, bool IsRounded, bool IsDown, bool IsFocused);
|
||||
|
||||
} /* namespace Coolbutton */
|
||||
#if !defined(NO_IMPLICIT_NAMESPACE_USE)
|
||||
using namespace Coolbutton;
|
||||
#endif
|
||||
//-- end unit ----------------------------------------------------------------
|
||||
#endif // CoolButton
|
1133
CDopping/CoolForm/CoolButton.pas
Normal file
1133
CDopping/CoolForm/CoolButton.pas
Normal file
File diff suppressed because it is too large
Load Diff
BIN
CDopping/CoolForm/CoolForm.OBJ
Normal file
BIN
CDopping/CoolForm/CoolForm.OBJ
Normal file
Binary file not shown.
BIN
CDopping/CoolForm/CoolForm.dcu
Normal file
BIN
CDopping/CoolForm/CoolForm.dcu
Normal file
Binary file not shown.
96
CDopping/CoolForm/CoolForm.hpp
Normal file
96
CDopping/CoolForm/CoolForm.hpp
Normal file
@ -0,0 +1,96 @@
|
||||
// Borland C++ Builder
|
||||
// Copyright (c) 1995, 1998 by Borland International
|
||||
// All rights reserved
|
||||
|
||||
// (DO NOT EDIT: machine generated header) 'CoolForm.pas' rev: 3.00
|
||||
|
||||
#ifndef CoolFormHPP
|
||||
#define CoolFormHPP
|
||||
#include <DsgnIntf.hpp>
|
||||
#include <ExtCtrls.hpp>
|
||||
#include <Dialogs.hpp>
|
||||
#include <Forms.hpp>
|
||||
#include <Controls.hpp>
|
||||
#include <Graphics.hpp>
|
||||
#include <Classes.hpp>
|
||||
#include <SysUtils.hpp>
|
||||
#include <Messages.hpp>
|
||||
#include <Windows.hpp>
|
||||
#include <SysInit.hpp>
|
||||
#include <System.hpp>
|
||||
|
||||
//-- user supplied -----------------------------------------------------------
|
||||
|
||||
namespace Coolform
|
||||
{
|
||||
//-- type declarations -------------------------------------------------------
|
||||
class DELPHICLASS TRegionType;
|
||||
class DELPHICLASS TCoolForm;
|
||||
class PASCALIMPLEMENTATION TCoolForm : public Extctrls::TImage
|
||||
{
|
||||
typedef Extctrls::TImage inherited;
|
||||
|
||||
private:
|
||||
TRegionType* Fregion;
|
||||
_RGNDATA *FOrgRgn;
|
||||
int FOrgSize;
|
||||
TRegionType* Dummy;
|
||||
bool FDraggable;
|
||||
HIDESBASE void __fastcall PictureChanged(System::TObject* Sender);
|
||||
void __fastcall ReadMask(Classes::TStream* Reader);
|
||||
void __fastcall WriteMask(Classes::TStream* Writer);
|
||||
DYNAMIC void __fastcall MouseDown(Controls::TMouseButton Button, Classes::TShiftState Shift, int X,
|
||||
int Y);
|
||||
virtual void __fastcall DefineProperties(Classes::TFiler* Filer);
|
||||
MESSAGE void __fastcall WMEraseBkgnd(Messages::TWMEraseBkgnd &Message);
|
||||
|
||||
protected:
|
||||
void __fastcall SetRegion(TRegionType* Value);
|
||||
virtual void __fastcall SetParent(Controls::TWinControl* Value);
|
||||
HIDESBASE virtual void __fastcall SetTop(int Value);
|
||||
HIDESBASE virtual void __fastcall SetLeft(int Value);
|
||||
HIDESBASE virtual void __fastcall Setwidth(int Value);
|
||||
HIDESBASE virtual void __fastcall SetHeight(int Value);
|
||||
TRegionType* __fastcall GetRegion(void);
|
||||
void __fastcall size(void);
|
||||
|
||||
public:
|
||||
__fastcall virtual TCoolForm(Classes::TComponent* Aowner);
|
||||
__fastcall virtual ~TCoolForm(void);
|
||||
__property TRegionType* Mask2 = {read=Dummy, write=Dummy};
|
||||
bool __fastcall LoadMaskFromFile(System::AnsiString FileName);
|
||||
void __fastcall RefreshRegion(void);
|
||||
|
||||
__published:
|
||||
__property TRegionType* Mask = {read=GetRegion, write=SetRegion};
|
||||
__property bool Draggable = {read=FDraggable, write=FDraggable, default=1};
|
||||
__property int top = {write=SetTop};
|
||||
__property int left = {write=SetLeft};
|
||||
__property int width = {write=Setwidth};
|
||||
__property int height = {write=SetHeight};
|
||||
};
|
||||
|
||||
class PASCALIMPLEMENTATION TRegionType : public Classes::TPersistent
|
||||
{
|
||||
typedef Classes::TPersistent inherited;
|
||||
|
||||
public:
|
||||
HRGN Fregion;
|
||||
TCoolForm* owner;
|
||||
public:
|
||||
/* TPersistent.Destroy */ __fastcall virtual ~TRegionType(void) { }
|
||||
|
||||
public:
|
||||
/* TObject.Create */ __fastcall TRegionType(void) : Classes::TPersistent() { }
|
||||
|
||||
};
|
||||
|
||||
//-- var, const, procedure ---------------------------------------------------
|
||||
extern PACKAGE void __fastcall Register(void);
|
||||
|
||||
} /* namespace Coolform */
|
||||
#if !defined(NO_IMPLICIT_NAMESPACE_USE)
|
||||
using namespace Coolform;
|
||||
#endif
|
||||
//-- end unit ----------------------------------------------------------------
|
||||
#endif // CoolForm
|
314
CDopping/CoolForm/CoolForm.pas
Normal file
314
CDopping/CoolForm/CoolForm.pas
Normal file
@ -0,0 +1,314 @@
|
||||
unit CoolForm;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
||||
ExtCtrls ,dsgnintf;
|
||||
|
||||
type
|
||||
TCoolForm = class;
|
||||
|
||||
TRegionType = class(TPersistent)
|
||||
public
|
||||
Fregion:hrgn;
|
||||
owner:TCoolForm;
|
||||
end;
|
||||
|
||||
TCoolForm = class(TImage)
|
||||
private
|
||||
Fregion : TRegionType;
|
||||
FOrgRgn : PRgnData;
|
||||
FOrgSize : Integer;
|
||||
// the dummy is necessary (or maybe not) as a public property for the writing of the
|
||||
// mask into a stream (btter leyve it as it is, never touch a running system)
|
||||
Dummy:TRegionType;
|
||||
FDraggable:boolean;
|
||||
procedure PictureChanged(Sender:TObject);
|
||||
procedure ReadMask(Reader: TStream);
|
||||
procedure WriteMask(Writer: TStream);
|
||||
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);override;
|
||||
procedure DefineProperties(Filer: TFiler);override;
|
||||
procedure WMEraseBkgnd(var Message: TWMEraseBkgnd); message WM_ERASEBKGND;
|
||||
protected
|
||||
procedure SetRegion(Value:TRegionType);
|
||||
procedure SetParent(Value:TWinControl); override;
|
||||
procedure SetTop(Value:integer); virtual;
|
||||
procedure SetLeft(Value:integer); virtual;
|
||||
procedure Setwidth(Value:integer); virtual;
|
||||
procedure SetHeight(Value:integer); virtual;
|
||||
function GetRegion:TRegionType;
|
||||
procedure size;
|
||||
public
|
||||
constructor Create(Aowner:TComponent); override;
|
||||
destructor Destroy; override;
|
||||
property Mask2:TRegionType read Dummy write Dummy;
|
||||
function LoadMaskFromFile (FileName: String): Boolean;
|
||||
procedure RefreshRegion;
|
||||
published
|
||||
property Mask:TRegionType read GetRegion write SetRegion;
|
||||
property Draggable:boolean read FDraggable write FDraggable default true;
|
||||
property top write settop;
|
||||
property left write setleft;
|
||||
property width write setwidth;
|
||||
property height write setheight;
|
||||
end;
|
||||
|
||||
procedure Register;
|
||||
|
||||
implementation
|
||||
uses
|
||||
MaskEditor;
|
||||
|
||||
procedure Register;
|
||||
begin
|
||||
RegisterComponents ('Cool!', [TCoolForm]);
|
||||
RegisterPropertyEditor (TypeInfo(TRegionType), TCoolForm, 'Mask', TCoolMaskEditor);
|
||||
end;
|
||||
|
||||
|
||||
// The next two procedures are there to ensure hat the component always sits in the top left edge of the window
|
||||
procedure TCoolForm.SetTop(Value:integer);
|
||||
begin
|
||||
inherited top := 0;
|
||||
end;
|
||||
|
||||
procedure TCoolForm.SetLeft(Value:integer);
|
||||
begin
|
||||
inherited left := 0;
|
||||
end;
|
||||
|
||||
procedure TCoolForm.RefreshRegion;
|
||||
begin
|
||||
FRegion.FRegion := ExtCreateRegion (nil, FOrgSize, FOrgRgn^);
|
||||
SetWindowRgn (parent.handle, FRegion.Fregion, true);
|
||||
end;
|
||||
|
||||
|
||||
|
||||
destructor TCoolForm.destroy;
|
||||
begin
|
||||
If FOrgRgn <> Nil then
|
||||
FreeMem (FOrgRgn, FOrgSize);
|
||||
|
||||
if fregion.fregion <> 0 then deleteobject (fregion.fregion);
|
||||
Dummy.Free;
|
||||
FRegion.free;
|
||||
inherited;
|
||||
end;
|
||||
|
||||
constructor TCoolForm.create(Aowner:TComponent);
|
||||
begin
|
||||
inherited;
|
||||
// make it occupy all of the form
|
||||
Align := alClient;
|
||||
Fregion := TRegionType.Create;
|
||||
Dummy := TRegionType.Create;
|
||||
Fregion.Fregion := 0;
|
||||
Fregion.owner := self;
|
||||
Picture.OnChange := PictureChanged;
|
||||
// if draggable is false, it will be overwritten later by delphi`s runtime component loader
|
||||
Draggable := true;
|
||||
end;
|
||||
|
||||
procedure TCoolForm.PictureChanged(Sender:TObject);
|
||||
begin
|
||||
if (parent <> nil) and (picture.bitmap <> nil) then
|
||||
begin
|
||||
// resize the form to fit the bitmap
|
||||
{ width:=picture.bitmap.Width;
|
||||
height:=picture.bitmap.height;
|
||||
parent.clientwidth:=picture.bitmap.Width;
|
||||
parent.clientheight:=picture.bitmap.height;
|
||||
} end;
|
||||
if Fregion.FRegion<>0 then
|
||||
begin
|
||||
// if somehow there`s a region already, delete it
|
||||
deleteObject (FRegion.FRegion);
|
||||
FRegion.Fregion := 0;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TCoolForm.GetRegion:TRegionType;
|
||||
begin
|
||||
result := FRegion;
|
||||
end;
|
||||
|
||||
procedure TCoolForm.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
|
||||
begin
|
||||
// if dragging is on, start the dragging process
|
||||
If button = mbleft then
|
||||
begin
|
||||
releasecapture;
|
||||
TWincontrol (Parent).perform (WM_syscommand, $F012, 0);
|
||||
end;
|
||||
end;
|
||||
|
||||
// This is used by delphi`s component streaming system
|
||||
// it is called whenever delphi reads the componnt from the .dfm
|
||||
procedure TCoolForm.ReadMask(Reader: TStream);
|
||||
begin
|
||||
// read the size of the region data to come
|
||||
reader.read (FOrgSize, 4);
|
||||
if FOrgSize <> 0 then
|
||||
begin
|
||||
// if we have region data, allocate memory for it
|
||||
getmem (FOrgRgn, FOrgSize);
|
||||
// read the data
|
||||
reader.read (FOrgRgn^, FOrgSize);
|
||||
// create the region
|
||||
FRegion.FRegion := ExtCreateRegion (nil, FOrgSize, FOrgRgn^);
|
||||
if not (csDesigning in ComponentState) and (FRegion.FRegion <> 0) then
|
||||
SetWindowRgn (parent.handle, FRegion.Fregion, true);
|
||||
// dispose of the memory
|
||||
end else fregion.fregion := 0;
|
||||
end;
|
||||
|
||||
|
||||
// This is pretty much the same stuff as above. Only it`s written this time
|
||||
procedure TCoolForm.WriteMask(Writer: TStream);
|
||||
var
|
||||
size : integer;
|
||||
rgndata : pRGNData;
|
||||
|
||||
begin
|
||||
if (fregion.fregion<>0) then
|
||||
begin
|
||||
// get the region data`s size
|
||||
size:=getregiondata (FRegion.FRegion, 0, nil);
|
||||
getmem (rgndata,size);
|
||||
// get the data itself
|
||||
getregiondata (FRegion.FRegion, size, rgndata);
|
||||
// write it
|
||||
writer.write (size,sizeof (size));
|
||||
writer.write (rgndata^, size);
|
||||
freemem (rgndata, size);
|
||||
end else
|
||||
begin
|
||||
// if there`s no region yet (from the mask editor), then write a size of zero
|
||||
size := 0;
|
||||
writer.write (size, sizeof (size));
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
// This tells Delphi to read the public property `Mask 2` from the stream,
|
||||
// That`s what we need the dummy for.
|
||||
procedure TCoolForm.DefineProperties(Filer: TFiler);
|
||||
begin
|
||||
inherited DefineProperties(Filer);
|
||||
// tell Delphi which methods to call when reading the property data from the stream
|
||||
Filer.DefineBinaryProperty ('Mask2', ReadMask, WriteMask, true);
|
||||
end;
|
||||
|
||||
|
||||
|
||||
procedure TCoolForm.SetRegion(Value:TRegionType);
|
||||
begin
|
||||
if Value <> nil then
|
||||
begin
|
||||
FRegion := Value;
|
||||
// The owner is for the property editor to find the component
|
||||
FRegion.owner := self;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure TCoolForm.SetParent(Value:TWinControl);
|
||||
begin
|
||||
inherited;
|
||||
if Value <> nil then
|
||||
if not (Value is TWinControl) then
|
||||
begin
|
||||
raise Exception.Create ('Drop the CoolForm on a FORM!');
|
||||
end else
|
||||
with TWincontrol (Value) do
|
||||
begin
|
||||
if Value is TForm then TForm (Value).borderstyle := bsNone;
|
||||
end;
|
||||
top := 0;
|
||||
left := 0;
|
||||
end;
|
||||
|
||||
procedure TCoolForm.WMEraseBkgnd(var Message: TWMEraseBkgnd);
|
||||
begin
|
||||
message.Result := 1;
|
||||
end;
|
||||
|
||||
function TCoolForm.LoadMaskFromFile (FileName: String): Boolean;
|
||||
var
|
||||
reader : TFileStream;
|
||||
|
||||
begin
|
||||
// read the size of the region data to come
|
||||
|
||||
try
|
||||
reader := TFileStream.Create (FileName, fmOpenRead);
|
||||
reader.read (FOrgSize, 4);
|
||||
if FOrgSize <> 0 then
|
||||
begin
|
||||
If ForgRgn <> Nil then
|
||||
FreeMem (FOrgRgn, FOrgSize);
|
||||
// if we have region data, allocate memory for it
|
||||
getmem(FOrgRgn, FOrgSize);
|
||||
// read the data
|
||||
reader.read (FOrgRgn^, FOrgSize);
|
||||
// create the region
|
||||
FRegion.FRegion:=ExtCreateRegion(nil,FOrgSize,FOrgRgn^);
|
||||
// if runtime, set the region for the window... Tadaaa
|
||||
if not (csDesigning in ComponentState) and (FRegion.FRegion <> 0) then
|
||||
begin
|
||||
SetWindowRgn (parent.handle, FRegion.Fregion, true);
|
||||
end;
|
||||
// dispose of the memory
|
||||
end else fregion.fregion := 0;
|
||||
reader.free;
|
||||
Result := True;
|
||||
except
|
||||
Result := False;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
procedure TCoolForm.size;
|
||||
var
|
||||
size : integer;
|
||||
rgndata : pRGNData;
|
||||
xf : TXform;
|
||||
|
||||
begin
|
||||
if (fregion.fregion<>0) then
|
||||
begin
|
||||
// get the region data`s size
|
||||
size := getregiondata (FRegion.FRegion, 0, nil);
|
||||
getmem (rgndata, size);
|
||||
// get the data itself
|
||||
getregiondata (FRegion.FRegion, size, rgndata);
|
||||
// write it
|
||||
|
||||
xf.eM11 := 1;//Width / Picture.Bitmap.Width;
|
||||
xf.eM12 := 0;
|
||||
xf.eM21 := 0;
|
||||
xf.eM22 := 1;//Height / Picture.Bitmap.Height;
|
||||
xf.eDx := 0;
|
||||
xf.eDy := 0;
|
||||
FRegion.FRegion := ExtCreateRegion (nil, size, rgndata^);
|
||||
|
||||
if not (csDesigning in ComponentState) and (FRegion.FRegion <> 0) then
|
||||
SetWindowRgn (parent.handle, FRegion.Fregion, true);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCoolForm.Setwidth(Value:integer);
|
||||
begin
|
||||
inherited Width := Value;
|
||||
// Size;
|
||||
end;
|
||||
|
||||
procedure TCoolForm.SetHeight(Value:integer);
|
||||
begin
|
||||
inherited Height := Value;
|
||||
// Size;
|
||||
end;
|
||||
|
||||
end.
|
BIN
CDopping/CoolForm/CoolForm.rar
Normal file
BIN
CDopping/CoolForm/CoolForm.rar
Normal file
Binary file not shown.
BIN
CDopping/CoolForm/MaskEditor.OBJ
Normal file
BIN
CDopping/CoolForm/MaskEditor.OBJ
Normal file
Binary file not shown.
BIN
CDopping/CoolForm/MaskEditor.dcu
Normal file
BIN
CDopping/CoolForm/MaskEditor.dcu
Normal file
Binary file not shown.
58
CDopping/CoolForm/MaskEditor.hpp
Normal file
58
CDopping/CoolForm/MaskEditor.hpp
Normal file
@ -0,0 +1,58 @@
|
||||
// Borland C++ Builder
|
||||
// Copyright (c) 1995, 1998 by Borland International
|
||||
// All rights reserved
|
||||
|
||||
// (DO NOT EDIT: machine generated header) 'MaskEditor.pas' rev: 3.00
|
||||
|
||||
#ifndef MaskEditorHPP
|
||||
#define MaskEditorHPP
|
||||
#include <DsgnIntf.hpp>
|
||||
#include <maskgenerator.hpp>
|
||||
#include <ExtCtrls.hpp>
|
||||
#include <Dialogs.hpp>
|
||||
#include <Forms.hpp>
|
||||
#include <Controls.hpp>
|
||||
#include <Graphics.hpp>
|
||||
#include <Classes.hpp>
|
||||
#include <SysUtils.hpp>
|
||||
#include <Messages.hpp>
|
||||
#include <Windows.hpp>
|
||||
#include <SysInit.hpp>
|
||||
#include <System.hpp>
|
||||
|
||||
//-- user supplied -----------------------------------------------------------
|
||||
|
||||
namespace Maskeditor
|
||||
{
|
||||
//-- type declarations -------------------------------------------------------
|
||||
class DELPHICLASS TCoolMaskEditor;
|
||||
class PASCALIMPLEMENTATION TCoolMaskEditor : public Dsgnintf::TPropertyEditor
|
||||
{
|
||||
typedef Dsgnintf::TPropertyEditor inherited;
|
||||
|
||||
private:
|
||||
System::AnsiString FValue;
|
||||
|
||||
public:
|
||||
__fastcall virtual ~TCoolMaskEditor(void);
|
||||
virtual void __fastcall Edit(void);
|
||||
virtual Dsgnintf::TPropertyAttributes __fastcall GetAttributes(void);
|
||||
virtual System::AnsiString __fastcall getname();
|
||||
virtual System::AnsiString __fastcall getValue();
|
||||
|
||||
__published:
|
||||
__property System::AnsiString Value = {read=FValue, write=FValue};
|
||||
public:
|
||||
/* TObject.Create */ __fastcall TCoolMaskEditor(void) : Dsgnintf::TPropertyEditor() { }
|
||||
|
||||
};
|
||||
|
||||
//-- var, const, procedure ---------------------------------------------------
|
||||
extern PACKAGE bool FormCreated;
|
||||
|
||||
} /* namespace Maskeditor */
|
||||
#if !defined(NO_IMPLICIT_NAMESPACE_USE)
|
||||
using namespace Maskeditor;
|
||||
#endif
|
||||
//-- end unit ----------------------------------------------------------------
|
||||
#endif // MaskEditor
|
90
CDopping/CoolForm/MaskEditor.pas
Normal file
90
CDopping/CoolForm/MaskEditor.pas
Normal file
@ -0,0 +1,90 @@
|
||||
unit MaskEditor;
|
||||
|
||||
interface
|
||||
uses
|
||||
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
||||
ExtCtrls, maskgenerator, dsgnintf;
|
||||
|
||||
|
||||
type
|
||||
TCoolMaskEditor = class(TPropertyEditor)
|
||||
private
|
||||
FValue:string;
|
||||
public
|
||||
destructor destroy;override;
|
||||
procedure Edit;override;
|
||||
function GetAttributes: TPropertyAttributes;override;
|
||||
function getname:string; override;
|
||||
function getValue:string; override;
|
||||
published
|
||||
property Value:string read FValue write FValue;
|
||||
end;
|
||||
|
||||
var
|
||||
FormCreated:boolean=false;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
CoolForm;
|
||||
|
||||
function TCoolMaskEditor.getname:string;
|
||||
begin
|
||||
result:='Mask';
|
||||
end;
|
||||
|
||||
|
||||
function TCoolMaskEditor.getValue:string;
|
||||
begin
|
||||
result:='Mask';
|
||||
end;
|
||||
|
||||
|
||||
|
||||
destructor TCoolMaskEditor.Destroy;
|
||||
begin
|
||||
if Formmaskgenerator<>nil then
|
||||
begin
|
||||
FormMaskGenerator.Free;
|
||||
FormMaskGenerator:=nil;
|
||||
FormCreated:=false;
|
||||
end;
|
||||
inherited;
|
||||
end;
|
||||
|
||||
function TCoolMaskEditor.GetAttributes: TPropertyAttributes;
|
||||
begin
|
||||
// Make Delphi display the (...) button in the objectinspector
|
||||
Result := [paDialog];
|
||||
end;
|
||||
|
||||
|
||||
procedure TCoolMaskEditor.Edit;
|
||||
//******************* Unknown *************************
|
||||
begin
|
||||
// Create the maskeditorform if it doesn`t exist yet
|
||||
if not assigned(FormMaskGenerator) then
|
||||
begin
|
||||
formMaskGenerator:=TFormMaskGenerator.Create(nil);
|
||||
formMaskGenerator.OriginalRegionData:=nil;
|
||||
formMaskGenerator.SaveOriginalRegionData;
|
||||
FormCreated:=true;
|
||||
end;
|
||||
with formMaskGenerator do
|
||||
begin
|
||||
// Set the existing mask in the editor
|
||||
formMaskGenerator.Rgn1:=hrgn(TRegionType(GetOrdValue).Fregion);
|
||||
// copy the bitmap into the editor
|
||||
Image1.picture.bitmap.Assign(TRegionType(GetOrdValue).owner.picture.bitmap);
|
||||
opendialog1.filename:='';
|
||||
Showmodal;
|
||||
// get the new region from the editor
|
||||
hrgn(TRegionType(GetOrdValue).Fregion):=formMaskGenerator.Rgn1;
|
||||
// note: the editorform must not be freed here
|
||||
// if done, delphi eats lines of the sourcecode of the form in which coolform is used
|
||||
// (every line where a visible component is defined) ... rather strange
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
end.
|
133
CDopping/CoolForm/ReadMe.txt
Normal file
133
CDopping/CoolForm/ReadMe.txt
Normal file
@ -0,0 +1,133 @@
|
||||
CoolForm 1.5 component for Delphi 3 AND 4
|
||||
|
||||
|
||||
IMPORTANT
|
||||
|
||||
You can download new versions directly at http://www.lawrenz.com/coolform/
|
||||
|
||||
VERY IMPORTANT!!!!!!!!!!!!
|
||||
As we haven't received ANY beer yet, we would strongly advise you to get in gear and send some brew. Or else!
|
||||
|
||||
|
||||
|
||||
|
||||
New Features:
|
||||
|
||||
15.9.1998
|
||||
Coolform1.5 compatible with Delphi 4
|
||||
Included unit ExtMaskgenerator (see below)
|
||||
Fixed several bugs
|
||||
had to buy some beer
|
||||
14.9.1998
|
||||
got very thirsty
|
||||
13.9.1998
|
||||
got thirsty
|
||||
3.5.1998
|
||||
Added loading of masks at runtime.
|
||||
Added 0.9 to the version number.
|
||||
(That's what most of you've been asking for, ain't it?)
|
||||
2.5.1998
|
||||
Fixed the IDE Hangups when black is selected as transparent color
|
||||
Replaced the OpenDialog with OpenPictureDialog
|
||||
(Thanks, Garth!)
|
||||
1.3.1998
|
||||
CoolButton included
|
||||
25.2.1998
|
||||
Fixed the Access Violation Problem
|
||||
Fixed the 'Canvas does not allow drawing' Problem
|
||||
Improved the performance of the mask generator
|
||||
|
||||
|
||||
|
||||
Authors:
|
||||
|
||||
Tim Lawrenz
|
||||
tim@lawrenz.com
|
||||
|
||||
Max Muermann
|
||||
muermann@stud.uni-frankfurt.de
|
||||
|
||||
|
||||
Legal Notice:
|
||||
|
||||
This component is BeerWare for personal use. No responsibilities taken whatsoever.
|
||||
BeerWare means:
|
||||
|
||||
1) If you want to use this component for commercial use or
|
||||
2) if you want to use this component for personal use and think that this
|
||||
component is worth to do it,
|
||||
|
||||
you have to send us 20 bottles of beer (or the money for it) (or for german developers:
|
||||
'nen Kasten Bier).
|
||||
|
||||
|
||||
Installation:
|
||||
|
||||
From the Delphi IDE, choose Components/install packages from the menu, Select
|
||||
'Add' (or something like that, only german version available here). Find Component\Cool.dpl,
|
||||
Click OK. There should be a new tab in the component palette named 'Cool'.
|
||||
|
||||
Usage:
|
||||
|
||||
ExtMaskgenerator
|
||||
|
||||
The unit ExtMaskGenerator.pas contains one function: ExtGenerateMask(TBitmap, TColor, String);
|
||||
You call the function with the bitmap you want to use as the mask, the color that will be transparent
|
||||
and the filename where you want to store the mask data. You can then load the mask into a TCoolForm
|
||||
with LoadMaskFromFile.
|
||||
See XDollDemo.zip for some source and a nice picture.
|
||||
|
||||
CoolForm 1.5
|
||||
|
||||
Just drop the CoolForm component directly on a Form.
|
||||
Load a bitmap, just like with any TImage component.
|
||||
Double-click the Mask property. (the cool-looking mask editor appears)
|
||||
You can use the image you just loaded as a source for the mask, or you can load an
|
||||
external bmp to use as mask source.
|
||||
Clicking anywhere on the image selects the transparent color. This color is
|
||||
shown in the upper right corner of the window.
|
||||
The Ok-Button (checkmark) starts the mask generation (takes some time, no optimizations yet),
|
||||
but you'll have to do it only once.
|
||||
Compile and start your program and marvel at the wonders to behold.
|
||||
If you want your form to be draggable, set the Draggable property to true, otherwise don't.
|
||||
You can place any standard delphi component on the CoolForm, just bear in mind that components
|
||||
outside the masked area don't show. We suggest using BitButtons with Flat set to true.
|
||||
Look at the demo.
|
||||
|
||||
|
||||
Runtime loading: In the maskeditor, hit the 'save mask' AFTER having created a mask (you'll have
|
||||
to bring up the maskeditor twice, sorry).
|
||||
In your application, call CoolForm1.LoadMaskFromFile (FileName); It will return true if successfull,
|
||||
false if not.
|
||||
|
||||
CoolButton 1.3
|
||||
|
||||
The TCoolButton component is a button derived from a standard delphi SpeedButton - only cooler.
|
||||
The glyph *HAS* to contain four (4) equally sized bitmaps, of which the first describes the
|
||||
button in normal state, the second is the disabled button, the third one contains the image
|
||||
if the pressed button, the fourth one is displayed when the mouse cursor is over the button.
|
||||
We're drunk, so don't blame us.
|
||||
Oh, man, it's just a simple button! What do you want to know about it?
|
||||
|
||||
|
||||
|
||||
|
||||
Future enhancements:
|
||||
|
||||
If we don't receive some beer soon, there will be no more enhancements. Thats it.
|
||||
|
||||
Bugreports:
|
||||
|
||||
Please report any bugs you should encounter with a detailed
|
||||
description (or even some source code) to any of the abovementioned EMail-addresses
|
||||
|
||||
MailingList:
|
||||
|
||||
Visit the Coolform Homepage for instructions on how to get on the mailinglist (we don't quite remember now).
|
||||
|
||||
|
||||
|
||||
Have fun.
|
||||
|
||||
|
||||
|
BIN
CDopping/CoolForm/TrMemo.dcu
Normal file
BIN
CDopping/CoolForm/TrMemo.dcu
Normal file
Binary file not shown.
100
CDopping/CoolForm/TrMemo.pas
Normal file
100
CDopping/CoolForm/TrMemo.pas
Normal file
@ -0,0 +1,100 @@
|
||||
unit TrMemo;
|
||||
{$R-}
|
||||
interface
|
||||
uses Messages, Controls, StdCtrls,classes;
|
||||
const TMWM__SpecialInvalidate=WM_USER+1111;
|
||||
type
|
||||
TTransparentMemo = class(TMemo)
|
||||
private
|
||||
procedure SpecialInvalidate(var Message:TMessage); message
|
||||
TMWM__SpecialInvalidate;
|
||||
procedure WMHScroll(var Message: TWMHScroll); message WM_HSCROLL;
|
||||
procedure WMVScroll(var Message: TWMVScroll); message WM_VSCROLL;
|
||||
procedure WMSetText(var Message:TWMSetText); message WM_SETTEXT;
|
||||
procedure CNCTLCOLOREDIT(var Message:TWMCTLCOLOREDIT); message
|
||||
CN_CTLCOLOREDIT;
|
||||
procedure WMKeyDown(var Message: TWMKeyDown); message WM_KEYDOWN;
|
||||
procedure WMEraseBkgnd(var Message: TWMEraseBkgnd); message WM_ERASEBKGND;
|
||||
protected
|
||||
procedure CreateParams(var Params: TCreateParams); override;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
end;
|
||||
procedure Register;
|
||||
implementation
|
||||
uses Windows;
|
||||
{ TTransparentMemo }
|
||||
procedure TTransparentMemo.WMHScroll(var Message: TWMHScroll);
|
||||
begin
|
||||
inherited;
|
||||
PostMessage(Handle,TMWM__SpecialInvalidate,0,0);
|
||||
end;
|
||||
procedure TTransparentMemo.WMVScroll(var Message: TWMVScroll);
|
||||
begin
|
||||
SendMessage(Handle,TMWM__SpecialInvalidate,0,0);
|
||||
inherited;
|
||||
PostMessage(Handle,TMWM__SpecialInvalidate,0,0);
|
||||
end;
|
||||
procedure TTransparentMemo.CNCTLCOLOREDIT(var Message:TWMCTLCOLOREDIT);
|
||||
begin
|
||||
with Message do
|
||||
begin
|
||||
SetBkMode(ChildDC,TRANSPARENT);
|
||||
Result:=GetStockObject(HOLLOW_BRUSH)
|
||||
end
|
||||
end;
|
||||
procedure TTransparentMemo.WMSetText(var Message:TWMSetText);
|
||||
begin
|
||||
inherited;
|
||||
if not (csDesigning in ComponentState) then
|
||||
PostMessage(Handle,TMWM__SpecialInvalidate,0,0)
|
||||
end;
|
||||
procedure TTransparentMemo.SpecialInvalidate(var Message:TMessage);
|
||||
var r:TRect;
|
||||
begin
|
||||
if Parent<>nil then
|
||||
begin
|
||||
r:=ClientRect;
|
||||
r.TopLeft:=Parent.ScreenToClient(ClientToScreen(r.TopLeft));
|
||||
r.BottomRight:=Parent.ScreenToClient(ClientToScreen(r.BottomRight));
|
||||
InvalidateRect(Parent.Handle,@r,true);
|
||||
RedrawWindow(Handle,nil,0,RDW_FRAME+RDW_INVALIDATE)
|
||||
end;
|
||||
end;
|
||||
procedure TTransparentMemo.WMKeyDown(var Message: TWMKeyDown);
|
||||
begin
|
||||
SendMessage(Handle,TMWM__SpecialInvalidate,0,0);
|
||||
inherited;
|
||||
PostMessage(Handle,TMWM__SpecialInvalidate,0,0);
|
||||
end;
|
||||
procedure TTransparentMemo.WMEraseBkgnd(var Message: TWMEraseBkgnd);
|
||||
begin
|
||||
Message.Result:=1
|
||||
end;
|
||||
|
||||
constructor TTransparentMemo.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited;
|
||||
ControlStyle:=[csCaptureMouse, csDesignInteractive,
|
||||
csClickEvents, csSetCaption, csOpaque, csDoubleClicks,
|
||||
csReplicatable, csNoStdEvents];
|
||||
end;
|
||||
|
||||
procedure TTransparentMemo.CreateParams(var Params: TCreateParams);
|
||||
begin
|
||||
inherited CreateParams(Params);
|
||||
with Params do
|
||||
begin
|
||||
ExStyle:=ExStyle or WS_EX_TRANSPARENT and not WS_EX_WINDOWEDGE
|
||||
and not WS_EX_STATICEDGE and not WS_EX_DLGMODALFRAME and not
|
||||
WS_EX_CLIENTEDGE;
|
||||
end;
|
||||
end;
|
||||
procedure Register;
|
||||
begin
|
||||
RegisterComponents('cool!', [tTransparentMemo]);
|
||||
end;
|
||||
end.
|
||||
|
||||
|
||||
|
BIN
CDopping/CoolForm/cool.dcp
Normal file
BIN
CDopping/CoolForm/cool.dcp
Normal file
Binary file not shown.
BIN
CDopping/CoolForm/cool.dcu
Normal file
BIN
CDopping/CoolForm/cool.dcu
Normal file
Binary file not shown.
37
CDopping/CoolForm/cool.dpk
Normal file
37
CDopping/CoolForm/cool.dpk
Normal file
@ -0,0 +1,37 @@
|
||||
package cool;
|
||||
|
||||
{$R *.RES}
|
||||
{$ALIGN ON}
|
||||
{$ASSERTIONS OFF}
|
||||
{$BOOLEVAL OFF}
|
||||
{$DEBUGINFO OFF}
|
||||
{$EXTENDEDSYNTAX ON}
|
||||
{$IMPORTEDDATA ON}
|
||||
{$IOCHECKS ON}
|
||||
{$LOCALSYMBOLS OFF}
|
||||
{$LONGSTRINGS ON}
|
||||
{$OPENSTRINGS ON}
|
||||
{$OPTIMIZATION ON}
|
||||
{$OVERFLOWCHECKS OFF}
|
||||
{$RANGECHECKS OFF}
|
||||
{$REFERENCEINFO OFF}
|
||||
{$SAFEDIVIDE OFF}
|
||||
{$STACKFRAMES OFF}
|
||||
{$TYPEDADDRESS OFF}
|
||||
{$VARSTRINGCHECKS ON}
|
||||
{$WRITEABLECONST ON}
|
||||
{$MINENUMSIZE 1}
|
||||
{$IMAGEBASE $00400000}
|
||||
{$IMPLICITBUILD ON}
|
||||
|
||||
requires
|
||||
vcl30;
|
||||
|
||||
contains
|
||||
CoolButton,
|
||||
CoolForm,
|
||||
MaskEditor,
|
||||
maskgenerator,
|
||||
TrMemo;
|
||||
|
||||
end.
|
BIN
CDopping/CoolForm/cool.dpl
Normal file
BIN
CDopping/CoolForm/cool.dpl
Normal file
Binary file not shown.
BIN
CDopping/CoolForm/maskgenerator.OBJ
Normal file
BIN
CDopping/CoolForm/maskgenerator.OBJ
Normal file
Binary file not shown.
BIN
CDopping/CoolForm/maskgenerator.dcu
Normal file
BIN
CDopping/CoolForm/maskgenerator.dcu
Normal file
Binary file not shown.
BIN
CDopping/CoolForm/maskgenerator.dfm
Normal file
BIN
CDopping/CoolForm/maskgenerator.dfm
Normal file
Binary file not shown.
88
CDopping/CoolForm/maskgenerator.hpp
Normal file
88
CDopping/CoolForm/maskgenerator.hpp
Normal file
@ -0,0 +1,88 @@
|
||||
// Borland C++ Builder
|
||||
// Copyright (c) 1995, 1998 by Borland International
|
||||
// All rights reserved
|
||||
|
||||
// (DO NOT EDIT: machine generated header) 'maskgenerator.pas' rev: 3.00
|
||||
|
||||
#ifndef maskgeneratorHPP
|
||||
#define maskgeneratorHPP
|
||||
#include <ExtDlgs.hpp>
|
||||
#include <CoolForm.hpp>
|
||||
#include <ExtCtrls.hpp>
|
||||
#include <Buttons.hpp>
|
||||
#include <ComCtrls.hpp>
|
||||
#include <StdCtrls.hpp>
|
||||
#include <Dialogs.hpp>
|
||||
#include <Forms.hpp>
|
||||
#include <Controls.hpp>
|
||||
#include <Graphics.hpp>
|
||||
#include <Classes.hpp>
|
||||
#include <SysUtils.hpp>
|
||||
#include <Messages.hpp>
|
||||
#include <Windows.hpp>
|
||||
#include <SysInit.hpp>
|
||||
#include <System.hpp>
|
||||
|
||||
//-- user supplied -----------------------------------------------------------
|
||||
|
||||
namespace Maskgenerator
|
||||
{
|
||||
//-- type declarations -------------------------------------------------------
|
||||
class DELPHICLASS TFormMaskGenerator;
|
||||
class PASCALIMPLEMENTATION TFormMaskGenerator : public Forms::TForm
|
||||
{
|
||||
typedef Forms::TForm inherited;
|
||||
|
||||
__published:
|
||||
Buttons::TSpeedButton* SpeedButton1;
|
||||
Buttons::TSpeedButton* SpeedButton2;
|
||||
Buttons::TSpeedButton* SpeedButton3;
|
||||
Extctrls::TPanel* Panel1;
|
||||
Coolform::TCoolForm* CoolForm1;
|
||||
Extctrls::TImage* Image1;
|
||||
Extdlgs::TOpenPictureDialog* OpenDialog1;
|
||||
Buttons::TSpeedButton* SpeedButton4;
|
||||
Dialogs::TSaveDialog* SaveDialog1;
|
||||
void __fastcall SpeedButton1Click(System::TObject* Sender);
|
||||
void __fastcall SpeedButton2Click(System::TObject* Sender);
|
||||
void __fastcall SpeedButton3Click(System::TObject* Sender);
|
||||
void __fastcall Image1MouseMove(System::TObject* Sender, Classes::TShiftState Shift, int X, int Y);
|
||||
|
||||
void __fastcall Image1MouseDown(System::TObject* Sender, Controls::TMouseButton Button, Classes::TShiftState
|
||||
Shift, int X, int Y);
|
||||
void __fastcall BitMapChange(System::TObject* Sender);
|
||||
void __fastcall FormCreate(System::TObject* Sender);
|
||||
void __fastcall SpeedButton4Click(System::TObject* Sender);
|
||||
|
||||
private:
|
||||
int oldleft;
|
||||
int oldtop;
|
||||
bool generating;
|
||||
|
||||
public:
|
||||
int OriginalRegionSize;
|
||||
_RGNDATA *OriginalRegiondata;
|
||||
HRGN rgn1;
|
||||
void __fastcall SaveOriginalRegionData(void);
|
||||
__fastcall virtual ~TFormMaskGenerator(void);
|
||||
public:
|
||||
/* TCustomForm.Create */ __fastcall virtual TFormMaskGenerator(Classes::TComponent* AOwner) : Forms::
|
||||
TForm(AOwner) { }
|
||||
/* TCustomForm.CreateNew */ __fastcall TFormMaskGenerator(Classes::TComponent* AOwner, int Dummy) :
|
||||
Forms::TForm(AOwner, Dummy) { }
|
||||
|
||||
public:
|
||||
/* TWinControl.CreateParented */ __fastcall TFormMaskGenerator(HWND ParentWindow) : Forms::TForm(ParentWindow
|
||||
) { }
|
||||
|
||||
};
|
||||
|
||||
//-- var, const, procedure ---------------------------------------------------
|
||||
extern PACKAGE TFormMaskGenerator* FormMaskGenerator;
|
||||
|
||||
} /* namespace Maskgenerator */
|
||||
#if !defined(NO_IMPLICIT_NAMESPACE_USE)
|
||||
using namespace Maskgenerator;
|
||||
#endif
|
||||
//-- end unit ----------------------------------------------------------------
|
||||
#endif // maskgenerator
|
261
CDopping/CoolForm/maskgenerator.pas
Normal file
261
CDopping/CoolForm/maskgenerator.pas
Normal file
@ -0,0 +1,261 @@
|
||||
unit maskgenerator;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
||||
StdCtrls, ComCtrls, Buttons, ExtCtrls, CoolForm, ExtDlgs;
|
||||
|
||||
type
|
||||
TFormMaskGenerator = class(TForm)
|
||||
SpeedButton1: TSpeedButton;
|
||||
SpeedButton2: TSpeedButton;
|
||||
SpeedButton3: TSpeedButton;
|
||||
Panel1: TPanel;
|
||||
CoolForm1: TCoolForm;
|
||||
Image1: TImage;
|
||||
OpenDialog1: TOpenPictureDialog;
|
||||
SpeedButton4: TSpeedButton;
|
||||
SaveDialog1: TSaveDialog;
|
||||
procedure SpeedButton1Click(Sender: TObject);
|
||||
procedure SpeedButton2Click(Sender: TObject);
|
||||
procedure SpeedButton3Click(Sender: TObject);
|
||||
procedure Image1MouseMove(Sender: TObject; Shift: TShiftState; X,Y: Integer);
|
||||
procedure Image1MouseDown(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer);
|
||||
procedure BitMapChange(Sender:TObject);
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure SpeedButton4Click(Sender: TObject);
|
||||
private
|
||||
oldleft,oldtop:integer;
|
||||
generating:boolean;
|
||||
public
|
||||
OriginalRegionSize:integer;
|
||||
OriginalRegiondata:pRGNData;
|
||||
rgn1:hrgn;
|
||||
procedure SaveOriginalRegionData;
|
||||
destructor destroy; override;
|
||||
end;
|
||||
|
||||
var
|
||||
FormMaskGenerator: TFormMaskGenerator;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.DFM}
|
||||
|
||||
procedure TFormMaskGenerator.SpeedButton1Click(Sender: TObject);
|
||||
begin
|
||||
if Opendialog1.Execute then image1.Picture.bitmap.LoadFromFile(opendialog1.filename);
|
||||
end;
|
||||
|
||||
|
||||
// This method is necessary to react to changes in the size of the bitmap
|
||||
procedure TFormMaskGenerator.BitMapChange(Sender:TObject);
|
||||
var
|
||||
tr2,temprgn:hrgn;
|
||||
x:pxform;
|
||||
begin
|
||||
if not generating then
|
||||
begin
|
||||
// This is the transformation matrix to be used in the region generating process
|
||||
// will be used in future releases
|
||||
x:=new(pxform);
|
||||
x.eM11:=1;
|
||||
x.eM12:=0;
|
||||
x.eM21:=0;
|
||||
x.eM22:=1;
|
||||
x.eDx:=-oldleft;
|
||||
x.eDy:=-oldtop;
|
||||
|
||||
// the original region is created (the generator form only)
|
||||
temprgn:=ExtCreateRegion(x,originalRegionSize,OriginalRegionData^);
|
||||
image1.width:=image1.picture.bitmap.width;
|
||||
image1.height:=image1.picture.bitmap.height;
|
||||
clientwidth:=image1.Left+image1.Width;
|
||||
clientHeight:=image1.Top+image1.Height;
|
||||
if clientwidth<=150 then ClientWidth:=150;
|
||||
if clientHeight<=150 then ClientHeight:=150;
|
||||
|
||||
// a region for the bitmap is created
|
||||
tr2:=CreateRectRgn(image1.left,image1.top,image1.left+image1.width,image1.top+image1.height);
|
||||
// the two regions are combined
|
||||
CombineRgn(temprgn,temprgn,tr2,RGN_OR);
|
||||
// set the new region
|
||||
DeleteObject(CoolForm1.Mask.fregion);
|
||||
CoolForm1.Mask.Fregion:=tempRgn;
|
||||
SetWindowRgn(handle,temprgn,true);
|
||||
// clean up
|
||||
DeleteObject(tr2);
|
||||
image1.repaint;
|
||||
dispose(x);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
// this method is called by the Propertyeditor to backup the maskgenerator`s mask generated at design-time
|
||||
procedure TFormMaskGenerator.SaveOriginalRegionData;
|
||||
begin
|
||||
// clean up
|
||||
if OriginalRegionData<>nil then
|
||||
begin
|
||||
freemem(OriginalRegionData);
|
||||
OriginalRegionData:=nil;
|
||||
end;
|
||||
// save original mask information
|
||||
oldleft:=left;
|
||||
oldtop:=top;
|
||||
OriginalRegionsize:=GetRegionData(CoolForm1.Mask.Fregion,0,nil);
|
||||
getmem(OriginalRegionData,OriginalRegionsize);
|
||||
getregiondata(CoolForm1.Mask.FRegion,OriginalRegionsize,OriginalRegiondata);
|
||||
end;
|
||||
|
||||
destructor TFormMaskGenerator.destroy;
|
||||
begin
|
||||
// clean up
|
||||
if OriginalRegionData<>nil then
|
||||
begin
|
||||
freemem(originalregiondata);
|
||||
end;
|
||||
OriginalRegionData:=nil;
|
||||
inherited;
|
||||
end;
|
||||
|
||||
|
||||
procedure TFormMaskGenerator.SpeedButton2Click(Sender: TObject);
|
||||
begin
|
||||
close;
|
||||
end;
|
||||
|
||||
// This is called when the User clicks the OK Button
|
||||
procedure TFormMaskGenerator.SpeedButton3Click(Sender: TObject);
|
||||
var
|
||||
// stream : TFileStream;
|
||||
size : integer;
|
||||
// rgndata : pRGNData;
|
||||
x,y : integer;
|
||||
transparentcolor : tcolor;
|
||||
rgn2 : hrgn;
|
||||
startx,endx : integer;
|
||||
R : TRect;
|
||||
|
||||
begin
|
||||
if Panel1.Color = clNone then
|
||||
Begin
|
||||
ShowMessage('You must select the colour to be masked out.'#13+
|
||||
'Click on the mask colour in the bitmap. '#13 +
|
||||
'(It will appear in the square to the right of the load button).');
|
||||
Exit;
|
||||
End;
|
||||
generating:=true;
|
||||
// clean up
|
||||
if rgn1<>0 then deleteObject(rgn1);
|
||||
rgn1 := 0;
|
||||
// set the transparent color
|
||||
transparentcolor:=Panel1.color;
|
||||
// if necessary, load another mask (don`t know why again... should be redundant)
|
||||
if opendialog1.filename<>'' then image1.picture.bitmap.loadfromfile(opendialog1.filename);
|
||||
|
||||
// for every line do...
|
||||
for y := 0 to image1.Picture.Height-1 do
|
||||
begin
|
||||
// don`t look as if we were locked up
|
||||
Application.ProcessMessages;
|
||||
x:=0;
|
||||
endx:=x;
|
||||
// no flicker
|
||||
lockWindowUpdate(FormMaskGenerator.handle);
|
||||
repeat
|
||||
// look for the beginning of a stretch of non-transparent pixels
|
||||
while (image1.picture.bitmap.canvas.pixels[x,y]=transparentcolor) and (x<=image1.picture.width) do
|
||||
inc(x);
|
||||
startx:=x;
|
||||
// paint the pixels up to here black
|
||||
for size:=endx to startx do image1.picture.bitmap.canvas.pixels[size,y]:=image1.picture.bitmap.canvas.pixels[size,y] xor $FFFFFF;
|
||||
// look for the end of a stretch of non-transparent pixels
|
||||
inc(x);
|
||||
while (image1.picture.bitmap.canvas.pixels[x,y]<>transparentcolor) and (x<=image1.picture.width) do
|
||||
inc(x);
|
||||
endx:=x;
|
||||
// do we have some pixels?
|
||||
if startx<>image1.Picture.Width then
|
||||
begin
|
||||
if endx= image1.Picture.Width then dec(endx);
|
||||
// do we have a region already?
|
||||
if rgn1 = 0 then
|
||||
begin
|
||||
// Create a region to start with
|
||||
rgn1:=createrectrgn(startx+1,y,endx,y+1);
|
||||
end else
|
||||
begin
|
||||
// Add to the existing region
|
||||
rgn2:=createrectrgn(startx+1,y,endx,y+1);
|
||||
if rgn2<>0 then combinergn(rgn1,rgn1,rgn2,RGN_OR);
|
||||
deleteobject(rgn2);
|
||||
end;
|
||||
// Paint the pixels white
|
||||
for size:=startx to endx do image1.picture.bitmap.canvas.pixels[size,y]:=image1.picture.bitmap.canvas.pixels[size,y] xor $FFFFFF;
|
||||
end;
|
||||
until x>=image1.picture.width-1;
|
||||
// flicker on
|
||||
lockwindowUpdate(0);
|
||||
// tell windows to repaint only the line of the bitmap we just processed
|
||||
R.top:=image1.top+y;
|
||||
r.Bottom:=image1.top+y+1;
|
||||
r.left:=image1.left;
|
||||
r.right:=image1.left+image1.Width;
|
||||
invalidaterect(formmaskgenerator.handle,@R,false);
|
||||
formmaskgenerator.Update;
|
||||
end;
|
||||
generating:=false;
|
||||
close;
|
||||
end;
|
||||
|
||||
|
||||
procedure TFormMaskGenerator.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,Y: Integer);
|
||||
begin
|
||||
if ssLeft in Shift then
|
||||
begin
|
||||
panel1.color:=image1.picture.bitmap.canvas.pixels[x,y];
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
procedure TFormMaskGenerator.Image1MouseDown(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer);
|
||||
begin
|
||||
panel1.color:=image1.picture.bitmap.canvas.pixels[x,y];
|
||||
end;
|
||||
|
||||
|
||||
procedure TFormMaskGenerator.FormCreate(Sender: TObject);
|
||||
begin
|
||||
image1.picture.OnChange:=BitMapChange;
|
||||
end;
|
||||
|
||||
procedure TFormMaskGenerator.SpeedButton4Click(Sender: TObject);
|
||||
var
|
||||
size : integer;
|
||||
rgndata : pRGNData;
|
||||
writer : TFileStream;
|
||||
|
||||
begin
|
||||
If SaveDialog1.Execute then
|
||||
begin
|
||||
if (rgn1<>0) then
|
||||
begin
|
||||
writer :=TFileStream.Create (SaveDialog1.Filename, fmCreate);
|
||||
// get the region data`s size
|
||||
size:=getregiondata (rgn1, 0, nil);
|
||||
getmem (rgndata, size);
|
||||
// get the data itself
|
||||
getregiondata(rgn1, size, rgndata);
|
||||
// write it
|
||||
writer.write (size, sizeof(size));
|
||||
writer.write (rgndata^, size);
|
||||
freemem(rgndata, size);
|
||||
writer.Free;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
Reference in New Issue
Block a user