Hi dmitry, On Thu, 2010-06-17 at 08:49 +0400, dmitry boyarintsev wrote: > You need to LCL add to the packege's dependency! > > Open the package dialog (the one opened with " Package / New > Package"), press "Add" button (on the top panel of the dialog). "New > Requirement"->Package Name, select LCL. Press OK. > > This will add LCL to the package requirements. You don't need to add > any directories for the LCL (if you've added you must remove them). >
I managed to successfully install the ugradbtn.pas component to the Misc component tab however I have not been able to install my arraycolorbtn_pkg which uses it. I have tried uninstalling the ugradbtn.pas component and installing just arraycolourbtn_pkg but without any joy. Package arraycolorbtn_pkg Files - arraycolorbutton.pas - ugradbtn.pas Required Packages - LCL - FCL (>=1.0) Recompiling Graphics, checksum changed for FPCAdds graphics.pp(81,12) Fatal: Can't find unit Graphics used by arraycolorbutton I am using the default installation of Lazarus not the home folder version. My component is in the home folder which I mentioned in my original post. Any ideas??? Peter > thanks, > dmitry -- Proudly developing Quality Cross Platform Open Source Games Since 1970 with a Commodore PET 4016 with 16 KRAM http://pews-freeware-games.org (<--- brand new)
arraycolorbtn_pkg.lpk
Description: XML document
{ This file was automatically created by Lazarus. do not edit!
This source is only used to compile and install the package.
}
unit arraycolorbtn_pkg;
interface
uses
arraycolorbutton, ugradbtn, LazarusPackageIntf;
implementation
procedure Register;
begin
RegisterUnit('ugradbtn', @ugradbtn.Register);
end;
initialization
RegisterPackage('arraycolorbtn_pkg', @Register);
end.
unit arraycolorbutton;
{$MODE Delphi}
{ ------------------------------------------------------------
Author: Unknown +
------ modifications by Peter E. Williams +
suggestions from alt.comp.lang.borland-delphi newsgroup +
suggestions from Mark Meyer in [email protected].
This code is freeware and is placed into the Public Domain by Peter E. Williams
( [email protected] ).
Version 0.1a - for Lazarus by PEW
Date: 17 June 2010
Added :--------
FRowCount, FColCount: integer;
procedure SetRowCount(r: integer);
procedure SetColCount(c: integer);
Version: 0.04a - by PEW. 'col' changed to 'column'. Setcol changed to
setcolumn.
Previous versions:
-----------------
Versions: 0.03a to 0.03f - trial versions to declare component based
on tcustomcontrol instead of on tbutton. Unsuccessful.
Version: 0.02b - mods by Mark Meyer + PEW.
Version: 0.02 - Dated: 15 February 2001
Version: 0.01 - Dated: 14 April 2000
Modified to form new unit based on AColorBtn & arraybtn,
based entirely on Acolorbtn with Row & Column properties of arraybtn added.
Note: The only difference between this component and AColorBtn is
* essentially that this component has additional 'row' & 'Column' published
properties.
Thanks and Acknowledgements:
---------------------------
Thanks to the unknown person who originally sent me version 0.01 of this code,
and to Bruce Roberts ([email protected]) who posted up v0.02 modifications
to the ng. Thanks also to all those in the alt.comp.lang.borland-delphi newsgroup
for their discussion of it and support.
Last modified by: Peter E. Williams
Known bugs:
----------
(#1 is now fixed!!!)
#1 - Captions containing #13 characters are displayed as
as single line of text.
#2 - There is no visual difference between Enabled true or false. The
Enabled property works otherwise as normal. Workaround is to use
the Font.Style settings to show when a button is Enabled, e.g.
for Enabled = true set to [fsbold], false set to [fsitalic] (this
is NOT done automatically).
#3 - Color property is assigned an invalid value of clCream.
Reported by "Mark Meyer" <gee...@g...>
(via [email protected])
Available from:
?????????????? http://www.angelfire.com/biz6/pwillcomputing/peter_delphi_page.html
as filename:
arraycolorbtn_src.zip
------------------------------------------------------------
}
interface
uses
{Windows, Messages,} SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
{StdCtrls,}
LcLType,
ugradbtn;
type
TOnArrowKeyEvent = procedure( Sender: TObject;
Key: Word;
Row: integer;
Column: integer;
RowCount : integer; // new
ColCount : integer; // new
var handled: boolean) of object;
TArrayColorButton = class(TGradButton) { class(TButton) }
private
IsFocused: Boolean;
FCanvas: TCanvas;
FRow,FColumn, FRowCount, FColCount: integer;
FUseDefaultKeyHandler : boolean;
FOnArrowKey : TOnArrowKeyEvent;
procedure SetRow(r: integer);
procedure SetColumn(c: integer);
procedure SetRowCount(r: integer);
procedure SetColCount(c: integer);
{
procedure CNDrawItem(var Msg: MDrawItemStruct); message CN_DRAWITEM;
//procedure CNDrawItem(var Msg: TWMDrawItem); message CN_DRAWITEM;
procedure CMFontChanged(var Msg: TMessage); message CM_FONTCHANGED;
procedure CMEnabledChanged(var Msg: TMessage); message CM_ENABLEDCHANGED;
procedure WMLButtonDblClk(var Message: TWMLButtonDblClk);
message WM_LBUTTONDBLCLK;
}
protected
// procedure CreateParams(var Params: TCreateParams); override;
// procedure CreateWnd; override;
// procedure SetButtonStyle(ADefault: Boolean); override;
procedure DoArrowKey(key : word);
public
procedure SetBounds (ALeft, ATop, AWidth, AHeight: Integer); override;
constructor Create (AOwner: TComponent); override;
destructor Destroy; override;
procedure KeyPress(var Key: Char); override;
procedure KeyUp(var Key: Word; Shift: TShiftState); override;
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
published
property UseDefaultKeyHandler: boolean read FUseDefaultKeyHandler write FUseDefaultKeyHandler;
property OnArrowKey : TOnArrowKeyEvent read FOnArrowKey write FOnArrowKey;
property Row: integer read FRow write SetRow default 1;
property Column: integer read FColumn write SetColumn default 1;
property RowCount: integer read FRowCount write SetRowCount default 1;
property ColCount: integer read FColCount write SetColCount default 1;
property Color;
property Width default 75;
property Height default 25;
property ParentShowHint;
property ShowHint;
property TabOrder;
property TabStop;
property Visible;
property OnEnter;
property OnExit;
end;
procedure Register;
implementation
{------------------------------------------------------------}
procedure TArrayColorbutton.KeyPress(var Key: char);
begin
if (FUseDefaultKeyHandler) then
begin
inherited;
// messagedlg('using default',mtinformation,[mbok],0);
end{if}
else
begin
DoArrowKey(word(key));
end;
end;
{------------------------------------------------------------}
procedure TArrayColorbutton.KeyUp(var Key: Word; Shift: TShiftState);
begin
if (FUseDefaultKeyHandler) then
begin
inherited;
// messagedlg('using default keyup',mtinformation,[mbok],0);
end{if}
else
begin
DoArrowKey(key);
end;
end;
{------------------------------------------------------------}
procedure TArrayColorbutton.KeyDown(var Key: Word; Shift: TShiftState);
begin
if (FUseDefaultKeyHandler) then
begin
inherited;
// messagedlg('using default keydown',mtinformation,[mbok],0);
end{if}
else
begin
DoArrowKey(key);
end;
end;
{------------------------------------------------------------}
procedure TArrayColorbutton.DoArrowKey(Key: Word);
var
handled : boolean;
begin
handled := false;
(*
i am unsure what is going to be best for you or what you have visualized here
to call an event here seems somewhat redundant - you could really do this
inside of the overriden events for keypress, keydown, and keyup - but you
know better what it is you want to do
if you do want to call your own event - say with some additional info - then use
the following code
[ comment by Mark Meyer ]
*)
case key of
VK_UP, VK_DOWN, VK_RIGHT, VK_LEFT :
if assigned(FOnArrowKey) then
FOnArrowKey(self, key, self.row, self.Column,
self.RowCount, self.ColCount, // new
handled);
end;{case}
end;
{------------------------------------------------------------}
constructor TArrayColorButton.Create (AOwner: TComponent);
begin
inherited Create (AOwner);
SetBounds (Left, Top, 75, 25);
FCanvas := TCanvas.Create;
FRow:=1;
FColumn:=1;
FRowCount:=1;
FColCount:=1;
//##########
end;
{------------------------------------------------------------}
destructor TArrayColorButton.Destroy;
begin
inherited Destroy;
FCanvas.Free;
end;
{------------------------------------------------------------}
{
procedure TArrayColorButton.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
with Params
do Style := Style or bs_OwnerDraw;
end;
{------------------------------------------------------------}
{
procedure TArrayColorButton.CreateWnd;
begin
inherited CreateWnd;
end;
{------------------------------------------------------------}
procedure TArrayColorButton.SetBounds (ALeft, ATop,
AWidth, AHeight: Integer);
begin
inherited SetBounds (ALeft, ATop, AWidth, AHeight);
end;
{------------------------------------------------------------}
{ from LCLType
// painting stuff
PDrawItemStruct = ^TDrawItemStruct;
tagDrawItemStruct = record
ctlType: UINT;
ctlID : UINT;
itemID : UINT;
itemAction : UINT;
itemState : UINT;
hwndItem: HWND;
_hDC: HDC;
rcItem: TRect;
itemData : ULONG_PTR;
end;
TDrawItemStruct = tagDrawItemStruct;
DrawItemStruct = tagDrawItemStruct;
}
{
//procedure TArrayColorButton.CNDrawItem(var Msg: TWMDrawItem);
procedure TArrayColorButton.CNDrawItem(var Msg: MDrawItemStruct);
var
OdsDown, OdsFocus, ActionFocus: Boolean;
Rect, bRect : TRect;
spacer : integer;
begin
// initialize
FFocused:=true;
LCLIntf.SetFocus(Handle);
FCanvas.Handle := Msg.DrawItemStruct^.hDC;
Rect := ClientRect;
Dec (Rect.Right);
Dec (Rect.Bottom);
with Msg.DrawItemStruct^ do
begin
OdsDown := itemState and ODS_SELECTED <> 0;
OdsFocus := itemState and ODS_FOCUS <> 0;
ActionFocus := ItemAction = oda_Focus
end;
with FCanvas do
begin
Brush.Color := Color;
if not ActionFocus then
begin
// fill with current color
Brush.Style := bsSolid;
FillRect (Rect);
end;
// do not fill any more
Brush.Style := bsClear;
// draw border if default
if Default or OdsFocus then
begin
Pen.Color := clWindowFrame;
if not ActionFocus then
Rectangle (Rect.Left, Rect.Top, Rect.Right, Rect.Bottom);
// reduce the area for further operations
InflateRect (Rect, -1, -1);
end;
if OdsDown then
begin
// draw gray border all around
Pen.Color := clBtnShadow;
if not ActionFocus then
Rectangle (Rect.Left, Rect.Top, Rect.Right, Rect.Bottom);
end
else if not ActionFocus then
begin
// gray border (bottom-right)
Pen.Color := clWindowFrame;
MoveTo(Rect.Left, Rect.Bottom);
LineTo(Rect.Right, Rect.Bottom);
LineTo(Rect.Right, Rect.Top);
// white border (top-left)
Pen.Color := clWhite;
LineTo(Rect.Left, Rect.Top);
LineTo(Rect.Left, Rect.Bottom);
// gray border (bottom-right, internal)
Pen.Color := clBtnShadow;
InflateRect (Rect, -1, -1);
MoveTo(Rect.Left, Rect.Bottom);
LineTo(Rect.Right, Rect.Bottom);
LineTo(Rect.Right, Rect.Top);
end;
// draw the caption
InflateRect (Rect, -2, -2);
if OdsDown then
begin
Inc (Rect.Left, 2);
Inc (Rect.Top, 2);
end;
Font := Self.Font;
// --- new code for v0.02
if not ActionFocus then
begin
bRect := Rect;
DrawText(fCanvas.Handle, pChar(Caption), -1, bRect, dt_CalcRect or dt_WordBreak or dt_Center);
spacer := (((Rect.Bottom - Rect.Top) - (bRect.Bottom - bRect.Top)) div 2);
bRect := Rect;
bRect.Top := bRect.Top + spacer;
DrawText(fCanvas.Handle, pChar(Caption), -1, bRect, dt_WordBreak or dt_Center);
end;
// --- end of v0.02 new code.
// draw the focus rect around the text
Brush.Style := bsSolid;
Pen.Color:= clBlack;
Brush.Color := clWhite;
if IsFocused or OdsFocus or ActionFocus then
DrawFocusRect (Rect);
end; // with FCanvas and if DrawEntire
FCanvas.Handle := 0;
Msg.Result := 1; // message handled
end;
}
{------------------------------------------------------------}
{
procedure TArrayColorButton.CMFontChanged(var Msg: TMessage);
begin
inherited;
Invalidate;
end;
}
{------------------------------------------------------------}
{
procedure TArrayColorButton.CMEnabledChanged(var Msg: TMessage);
begin
inherited;
Invalidate;
end;
{------------------------------------------------------------}
{
procedure TArrayColorButton.WMLButtonDblClk(var Message: TWMLButtonDblClk);
begin
Perform(WM_LBUTTONDOWN, Message.Keys, Longint(Message.Pos));
end;
{------------------------------------------------------------}
{
procedure TArrayColorButton.SetButtonStyle (ADefault: Boolean);
begin
if ADefault <> IsFocused then
begin
IsFocused := ADefault;
Invalidate;
end;
end;
{------------------------------------------------------------}
procedure TArrayColorButton.SetRow(r: integer);
begin
if r>-1 then
FRow:= r;
end;
{------------------------------------------------------------}
procedure TArrayColorButton.SetColumn(c: integer);
begin
if c>-1 then
FColumn:= c;
end;
{------------------------------------------------------------}
procedure TArrayColorButton.SetRowCount(r: integer);
begin
if r>-1 then
FRowCount:= r;
end;
{------------------------------------------------------------}
procedure TArrayColorButton.SetColCount(c: integer);
begin
if c>-1 then
FColCount:= c;
end;
{------------------------------------------------------------}
procedure Register;
begin
RegisterComponents('Misc', [TArrayColorButton]);
end;
{------------------------------------------------------------}
initialization
{$I tArrayColorButton.lrs}
end.
-- _______________________________________________ Lazarus mailing list [email protected] http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
