MG: added DrawItem to TComboBox/TListBox

git-svn-id: trunk@3459 -
This commit is contained in:
lazarus 2002-10-04 14:24:15 +00:00
parent 1ce803bc1c
commit e850093571
8 changed files with 348 additions and 137 deletions

View File

@ -202,7 +202,7 @@ override PACKAGE_NAME=lazarus/lcl
override PACKAGE_VERSION=0.8a
override TARGET_DIRS+=interfaces
override TARGET_UNITS+=allunits
override TARGET_IMPLICITUNITS+=arrow actnlist buttons calendar clipbrd clistbox comctrls commctrl controls dialogs dynhasharray extctrls filectrl forms graphics graphicsmath graphtype imglist interfacebase lazqueue lclmemmanager lcllinux lclstrconsts lcltype lmessages lresources menus messages registry spin stdctrls stringhashlist toolwin utrace vclglobals
override TARGET_IMPLICITUNITS+=arrow actnlist buttons calendar clipbrd clistbox comctrls commctrl controls dialogs dynhasharray extctrls extendedstrings filectrl forms graphics graphicsmath graphtype imglist interfacebase lazqueue lclmemmanager lcllinux lclstrconsts lcltype lmessages lresources menus messages registry spin stdctrls stringhashlist toolwin utrace vclglobals
override TARGET_RSTS+=dialogs
override CLEAN_FILES+=$(wildcard units/*$(OEXT)) $(wildcard units/*$(PPUEXT)) $(wildcard units/*$(RSTEXT))$(wildcard *$(OEXT)) $(wildcard *$(PPUEXT)) $(wildcard *$(RSTEXT))
override INSTALL_BUILDUNIT=allunits

View File

@ -11,10 +11,11 @@ version=0.8a
dirs=interfaces
units=allunits
implicitunits=arrow actnlist buttons calendar clipbrd clistbox comctrls \
commctrl controls dialogs dynhasharray extctrls filectrl forms \
graphics graphicsmath graphtype imglist interfacebase lazqueue \
lclmemmanager lcllinux lclstrconsts lcltype lmessages lresources menus \
messages registry spin stdctrls stringhashlist toolwin utrace vclglobals
commctrl controls dialogs dynhasharray extctrls extendedstrings \
filectrl forms graphics graphicsmath graphtype imglist interfacebase \
lazqueue lclmemmanager lcllinux lclstrconsts lcltype lmessages \
lresources menus messages registry spin stdctrls stringhashlist \
toolwin utrace vclglobals
# !!! do not add interfaces. interfaces.ppu belongs to the interface(s).
# and do not add allunits. It is just a dummy unit used for compiling.

View File

@ -74,16 +74,16 @@ end;
------------------------------------------------------------------------------}
procedure TCustomComboBox.DrawItem(Index: Integer; Rect: TRect;
procedure TCustomComboBox.DrawItem(Index: Integer; ARect: TRect;
State: TOwnerDrawState);
begin
//TControlCanvas(FCanvas).UpdateTextFlags;
if Assigned(FOnDrawItem) then
FOnDrawItem(Self, Index, Rect, State)
else
FOnDrawItem(Self, Index, ARect, State)
else if not (odPainted in State) then
begin
FCanvas.FillRect(Rect);
FCanvas.TextOut(Rect.Left + 2, Rect.Top, Items[Index]);
FCanvas.FillRect(ARect);
FCanvas.TextOut(ARect.Left + 2, ARect.Top, Items[Index]);
end;
end;
@ -508,8 +508,6 @@ begin
FDropDownCount:=8;
FCanvas := TControlCanvas.Create;
TControlCanvas(FCanvas).Control := Self;
// FItems:= TComboBoxStrings.Create;
// TComboBoxStrings(FItems).ComboBox := Self;
end;
{------------------------------------------------------------------------------
@ -648,35 +646,29 @@ begin
end;
{------------------------------------------------------------------------------
Procedure TCustomComboBox.CNDrawItems(var TheMessage : TLMDrawItems);
Procedure TCustomComboBox.LMDrawListItem(var TheMessage : TLMDrawListItem);
Handler for custom drawing items.
------------------------------------------------------------------------------}
Procedure TCustomComboBox.CNDrawItems(var TheMessage : TLMDrawItems);
//var
// State: TOwnerDrawState;
Procedure TCustomComboBox.LMDrawListItem(var TheMessage : TLMDrawListItem);
begin
{with TheMessage.DrawItemStruct^ do
with TheMessage.DrawListItemStruct^ do
begin
State := TOwnerDrawState(LongRec(itemState).Lo);
if itemState and ODS_COMBOBOXEDIT <> 0 then
Include(State, odComboBoxEdit);
if itemState and ODS_DEFAULT <> 0 then
Include(State, odDefault);
FCanvas.Handle := hDC;
FCanvas.Font := Font;
FCanvas.Brush := Brush;
if (Integer(itemID) >= 0) and (odSelected in State) then
FCanvas.Handle := DC;
if Font<>nil then
FCanvas.Font := Font;
if Brush<>nil then
FCanvas.Brush := Brush;
if (ItemID >= 0) and (odSelected in ItemState) then
begin
FCanvas.Brush.Color := clHighlight;
FCanvas.Font.Color := clHighlightText
end;
if Integer(itemID) >= 0 then
DrawItem(itemID, rcItem, State) else
FCanvas.FillRect(rcItem);
if odFocused in State then DrawFocusRect(hDC, rcItem);
DrawItem(ItemID, Area, ItemState);
if odFocused in ItemState then
{DrawFocusRect(hDC, rcItem)};
FCanvas.Handle := 0;
end;}
end;
end;
{------------------------------------------------------------------------------
@ -727,6 +719,9 @@ end;
{
$Log$
Revision 1.18 2002/10/04 14:24:14 lazarus
MG: added DrawItem to TComboBox/TListBox
Revision 1.17 2002/10/03 18:04:46 lazarus
MG: started customdrawitem

View File

@ -14,46 +14,88 @@
*****************************************************************************
}
{ if not HandleAllocated then
FItems contains a normal TStringList
FItems contains a TExtendedStringList
else
FItems contains an interface specific TStrings descendent
}
type
TCustomListBoxItemFlag = (clbiSelected);
TCustomListBoxItemFlags = set of TCustomListBoxItemFlag;
TCustomListBoxItemRecord = record
TheObject: TObject;
Flags: TCustomListBoxItemFlags;
end;
PCustomListBoxItemRecord = ^TCustomListBoxItemRecord;
function GetListBoxItemRecord(ListBoxInternalItems: TStrings;
Index: integer): PCustomListBoxItemRecord;
begin
Result:=PCustomListBoxItemRecord(
TExtendedStringList(ListBoxInternalItems).Records[Index]);
end;
{------------------------------------------------------------------------------}
{ procedure TCustomListBox.CreateHandle }
{------------------------------------------------------------------------------}
procedure TCustomListBox.CreateHandle;
var NewStrings : TStrings;
var
NewStrings : TStrings;
i: integer;
begin
//writeln('[TCustomListBox.CreateHandle] A ',FItems.ClassName);
//writeln('[TCustomListBox.CreateHandle] A ',FItems.ClassName);
inherited CreateHandle;
//writeln('[TCustomListBox.CreateHandle] B ',FItems.ClassName);
//writeln('[TCustomListBox.CreateHandle] B ',FItems.ClassName);
// create
NewStrings:= TStrings(Pointer(CNSendMessage(LM_GETITEMS, Self, nil)));
NewStrings.Assign(Items);
FItems.Free;
FItems:= NewStrings;
{ Sync other properties }
CNSendMessage(LM_SETBORDER, Self, nil);
UpdateSelectionMode;
//writeln('[TCustomListBox.CreateHandle] END ',FItems.ClassName);
UpdateSorted;
// fetch the interface item list
NewStrings:= TStrings(Pointer(CNSendMessage(LM_GETITEMS, Self, nil)));
// copy the items (text+objects)
NewStrings.Assign(Items);
// copy items attributes
for i:=0 to Items.Count-1 do begin
if clbiSelected in GetListBoxItemRecord(FItems,i)^.Flags then
SendItemSelected(i,True);
end;
// free old items
FItems.Free;
// new item list is the interface item list
FItems:= NewStrings;
//writeln('[TCustomListBox.CreateHandle] END ',FItems.ClassName);
end;
{------------------------------------------------------------------------------}
{ procedure TCustomListBox.DestroyHandle }
{------------------------------------------------------------------------------}
procedure TCustomListBox.DestroyHandle;
var NewStrings : TStrings;
var
NewStrings : TStrings;
i, Cnt: integer;
begin
//writeln('[TCustomListBox.DestroyHandle] A ',FItems.ClassName);
NewStrings:= TStringList.Create;
//writeln('[TCustomListBox.DestroyHandle] A ',FItems.ClassName);
// create internal item list
NewStrings:= TExtendedStringList.Create(SizeOf(TCustomListBoxItemRecord));
// copy items (text+objects) from the interface items list
NewStrings.Assign(Items);
// copy items attributes
Cnt:=Items.Count;
for i:=0 to Cnt-1 do begin
if Selected[i] then
Include(GetListBoxItemRecord(NewStrings,i)^.Flags,clbiSelected);
end;
// free the interface items list
FItems.Free;
// new item list is the internal item list
FItems:= NewStrings;
//writeln('[TCustomListBox.DestroyHandle] B ',FItems.ClassName);
//writeln('[TCustomListBox.DestroyHandle] B ',FItems.ClassName);
inherited DestroyHandle;
//writeln('[TCustomListBox.DestroyHandle] END ',FItems.ClassName);
//writeln('[TCustomListBox.DestroyHandle] END ',FItems.ClassName);
end;
{------------------------------------------------------------------------------}
@ -71,11 +113,70 @@ end;
{ procedure TCustomListBox.UpdateSelectionMode }
{------------------------------------------------------------------------------}
procedure TCustomListBox.UpdateSelectionMode;
var Message : TLMSetSelMode;
var
Msg : TLMSetSelMode;
begin
Message.ExtendedSelect:= ExtendedSelect;
Message.MultiSelect:= MultiSelect;
if HandleAllocated then CNSendMessage(LM_SETSELMODE, Self, @Message);
if not HandleAllocated then exit;
Msg.ExtendedSelect:= ExtendedSelect;
Msg.MultiSelect:= MultiSelect;
CNSendMessage(LM_SETSELMODE, Self, @Msg);
end;
{------------------------------------------------------------------------------
procedure TCustomListBox.UpdateSorted;
------------------------------------------------------------------------------}
procedure TCustomListBox.UpdateSorted;
var AMessage : TLMSort;
begin
if not HandleAllocated then exit;
with AMessage do begin
Msg:= LM_SORT;
List:= Items;
IsSorted:= FSorted;
end;
CNSendMessage(LM_SORT, Self, @AMessage);
end;
{------------------------------------------------------------------------------
procedure TCustomListBox.LMDrawListItem(var TheMessage: TLMDrawListItem);
Handler for custom drawing items.
------------------------------------------------------------------------------}
procedure TCustomListBox.LMDrawListItem(var TheMessage: TLMDrawListItem);
begin
with TheMessage.DrawListItemStruct^ do
begin
FCanvas.Handle := DC;
if Font<>nil then
FCanvas.Font := Font;
if Brush<>nil then
FCanvas.Brush := Brush;
if (ItemID >= 0) and (odSelected in ItemState) then
begin
FCanvas.Brush.Color := clHighlight;
FCanvas.Font.Color := clHighlightText
end;
DrawItem(ItemID, Area, ItemState);
if odFocused in ItemState then
{DrawFocusRect(hDC, rcItem)};
FCanvas.Handle := 0;
end;
end;
{------------------------------------------------------------------------------
procedure TCustomListBox.SendItemSelected(Index: integer; IsSelected: boolean);
Tell the interface whether an item is selected.
------------------------------------------------------------------------------}
procedure TCustomListBox.SendItemSelected(Index: integer; IsSelected: boolean);
var
Msg : TLMSetSel;
begin
if HandleAllocated then begin
Msg.Index:= Index;
Msg.Selected:= IsSelected;
CNSendMessage(LM_SETSEL, Self, @Msg);
end;
end;
{------------------------------------------------------------------------------}
@ -104,17 +205,20 @@ end;
{ procedure TCustomListBox.SetSelected }
{------------------------------------------------------------------------------}
procedure TCustomListBox.SetSelected(Index : integer; Val : boolean);
var Message : TLMSetSel;
begin
if (Index < 0) or (Index >= Items.Count) then
raise Exception.Create('List index out of bounds');
//writeln('TCustomListBox.SetSelected A ',Items.Count);
HandleNeeded;
//writeln('TCustomListBox.SetSelected B ',Items.Count);
Message.Index:= Index;
Message.Selected:= Val;
CNSendMessage(LM_SETSEL, Self, @Message);
//writeln('TCustomListBox.SetSelected END ',Items.Count);
//writeln('TCustomListBox.SetSelected A ',Items.Count);
if HandleAllocated then begin
//writeln('TCustomListBox.SetSelected B ',Items.Count);
SendItemSelected(Index,Val);
//writeln('TCustomListBox.SetSelected END ',Items.Count);
end else begin
if Val then
Include(GetListBoxItemRecord(FItems,Index)^.Flags,clbiSelected)
else
Exclude(GetListBoxItemRecord(FItems,Index)^.Flags,clbiSelected)
end;
end;
{------------------------------------------------------------------------------}
@ -125,7 +229,10 @@ begin
if (Index < 0) or (Index >= Items.Count) then
raise Exception.Create('TCustomListBox.GetSelected: index '+IntToStr(Index)
+' out of bound. Count='+IntToStr(Items.Count));
Result:= (CNSendMessage(LM_GETSEL, Self, @Index) >= 0);
if HandleAllocated then
Result:= (CNSendMessage(LM_GETSEL, Self, @Index) >= 0)
else
Result:=clbiSelected in GetListBoxItemRecord(FItems,Index)^.Flags;
end;
{------------------------------------------------------------------------------}
@ -133,7 +240,10 @@ end;
{------------------------------------------------------------------------------}
function TCustomListBox.GetSelCount : integer;
begin
Result:= CNSendMessage(LM_GETSELCOUNT, Self, nil);
if HandleAllocated then
Result:= CNSendMessage(LM_GETSELCOUNT, Self, nil)
else
Result:=0;
end;
function TCustomListBox.GetItemHeight: Integer;
@ -151,16 +261,10 @@ end;
{ procedure TCustomListBox.SetSorted }
{------------------------------------------------------------------------------}
procedure TCustomListBox.SetSorted(Val : boolean);
var AMessage : TLMSort;
begin
if Val <> FSorted then begin
with AMessage do begin
Msg:= LM_SORT;
List:= Items;
IsSorted:= Val;
end;
CNSendMessage(LM_SORT, Self, @AMessage);
FSorted:= Val;
UpdateSorted;
end;
end;
@ -174,6 +278,34 @@ begin
end;
end;
procedure TCustomListBox.DrawItem(Index: Integer; ARect: TRect;
State: TOwnerDrawState);
{var
Flags: Longint;
Data: String;}
begin
if Assigned(FOnDrawItem) then
FOnDrawItem(Self, Index, ARect, State)
else if not (odPainted in State) then
begin
FCanvas.FillRect(ARect);
if (Index>=0) and (Index < Items.Count) then
begin
{Flags := DrawTextBiDiModeFlags(DT_SINGLELINE or DT_VCENTER or DT_NOPREFIX);
if not UseRightToLeftAlignment then
Inc(Rect.Left, 2)
else
Dec(Rect.Right, 2);
Data := '';
if (Style in [lbVirtual, lbVirtualOwnerDraw]) then
Data := DoGetData(Index)
else
Data := Items[Index];
DrawText(FCanvas.Handle, PChar(Data), Length(Data), Rect, Flags);}
end;
end;
end;
{------------------------------------------------------------------------------}
{ function TCustomListBox.SetItems }
{------------------------------------------------------------------------------}
@ -194,7 +326,10 @@ begin
fCompStyle := csListBox;
FBorderStyle:= bsSingle;
FItems := TStringList.Create;
FItems := TExtendedStringList.Create(SizeOf(TCustomListBoxItemRecord));
FItemIndex:=-1;
FCanvas := TControlCanvas.Create;
TControlCanvas(FCanvas).Control := Self;
SetBounds(1, 1, 100, 25);
end;
@ -203,6 +338,8 @@ end;
{------------------------------------------------------------------------------}
destructor TCustomListBox.Destroy;
begin
FCanvas.Free;
FCanvas:=nil;
inherited Destroy;
FItems.Free;
end;
@ -210,7 +347,11 @@ end;
function TCustomListBox.GetItemIndex : integer;
begin
//writeln('[TCustomListBox.GetItemIndex] A ',FItems.ClassName);
Result:= CNSendMessage(LM_GETITEMINDEX, Self, nil);
if HandleAllocated then begin
Result:= CNSendMessage(LM_GETITEMINDEX, Self, nil);
FItemIndex:=Result;
end else
Result:=FItemIndex;
//writeln('[TCustomListBox.GetItemIndex] END ');
end;
@ -218,7 +359,9 @@ procedure TCustomListBox.SetItemIndex(Val : integer);
begin
if (Val < 0) or (Val >= FItems.Count) then raise Exception.Create('Out of bounds');
//writeln('[TCustomListBox.SetItemIndex] A ',FItems.ClassName,' ',Val);
CNSendMessage(LM_SETITEMINDEX, Self, Pointer(Val));
FItemIndex:=Val;
if HandleAllocated then
CNSendMessage(LM_SETITEMINDEX, Self, Pointer(Val));
//writeln('[TCustomListBox.SetItemIndex] END ',FItems.ClassName);
end;

View File

@ -34,8 +34,14 @@ type
function Get(Index : Integer) : string; override;
function GetCount : integer; override;
procedure SetSorted(Val : boolean); virtual;
procedure ConnectItemCallbacks(Index: integer);
procedure ConnectItemCallbacks(Li: PGtkListItem); virtual;
procedure ConnectAllCallbacks; virtual;
procedure RemoveItemCallbacks(Index: integer); virtual;
procedure RemoveAllCallbacks; virtual;
public
constructor Create(List : PGtkList; TheOwner: TWinControl);
destructor Destroy; override;
procedure Assign(Source : TPersistent); override;
procedure Clear; override;
procedure Delete(Index : integer); override;
@ -74,6 +80,9 @@ type
{ =============================================================================
$Log$
Revision 1.5 2002/10/04 14:24:15 lazarus
MG: added DrawItem to TComboBox/TListBox
Revision 1.4 2002/10/03 14:47:31 lazarus
MG: added TComboBox.OnPopup+OnCloseUp+ItemWidth

View File

@ -659,6 +659,8 @@ type
TNMHdr = tagNMHDR;
NMHDR = tagNMHDR;
{painting stuff}
PDrawItemStruct = ^TDrawItemStruct;
tagDrawItemStruct = packed record
ctlType: UINT;
@ -673,8 +675,25 @@ type
end;
TDrawItemStruct = tagDrawItemStruct;
DrawItemStruct = tagDrawItemStruct;
TOwnerDrawStateType = (
odSelected, odGrayed, odDisabled, odChecked,
odFocused, odDefault, odHotLight, odInactive, odNoAccel,
odNoFocusRect, odReserved1, odReserved2, odComboBoxEdit,
odPainted // item already painted
);
TOwnerDrawState = set of TOwnerDrawStateType;
PDrawListItemStruct = ^TDrawListItemStruct;
TDrawListItemStruct = record
ItemID: longint;
Area: TRect;
DC: HDC;
ItemState: TOwnerDrawState;
end;
{painting stuff}
PPaintStruct = ^TPaintStruct;
tagPAINTSTRUCT = packed record
hdc: HDC;
@ -1579,6 +1598,9 @@ end.
{
$Log$
Revision 1.19 2002/10/04 14:24:14 lazarus
MG: added DrawItem to TComboBox/TListBox
Revision 1.18 2002/10/03 18:04:46 lazarus
MG: started customdrawitem

View File

@ -273,73 +273,76 @@ const
// of messages send to the interface
//-------------
LM_USER = $400; // MWE: changed from $100 to $400 since they were in the windows range
WM_USER = LM_USER;
LM_DESTROY = LM_User+2;
LM_ACTIVATEITEM = LM_User+4;
LM_CHANGED = LM_User+5;
LM_FOCUS = LM_User+6;
LM_CLICKED = LM_User+7;
LM_PRESSED = LM_User+8;
LM_RELEASED = LM_User+9;
LM_MOVECURSOR = LM_User+10;
LM_ENTER = LM_User+11;
LM_LEAVE = LM_User+12;
WM_USER = LM_USER;
LM_DESTROY = LM_User+2;
LM_ACTIVATEITEM = LM_User+4;
LM_CHANGED = LM_User+5;
LM_FOCUS = LM_User+6;
LM_CLICKED = LM_User+7;
LM_PRESSED = LM_User+8;
LM_RELEASED = LM_User+9;
LM_MOVECURSOR = LM_User+10;
LM_ENTER = LM_User+11;
LM_LEAVE = LM_User+12;
//LM_SIZEALLOCATE = LM_User+13;
LM_CHECKRESIZE = LM_User+14;
LM_CHECKRESIZE = LM_User+14;
//LM_SHOW = LM_User+15; // Windows Compatability
LM_INSERTTEXT = LM_User+16;
LM_DELETETEXT = LM_User+17;
LM_SETEDITABLE = LM_User+18;
LM_MOVEWORD = LM_User+19;
LM_MOVEPAGE = LM_User+20;
LM_MOVETOROW = LM_User+21;
LM_MOVETOCOLUMN = LM_User+22;
LM_KILLCHAR = LM_User+23;
LM_KILLWORD = LM_User+24;
LM_KILLLINE = LM_User+25;
LM_CUTTOCLIP = LM_User+26;
LM_COPYTOCLIP = LM_User+27;
LM_PASTEFROMCLIP = LM_User+28;
//LM_MOVERESIZE = LM_User+29;
LM_EXPOSEEVENT = LM_User+30;
LM_INSERTTEXT = LM_User+16;
LM_DELETETEXT = LM_User+17;
LM_SETEDITABLE = LM_User+18;
LM_MOVEWORD = LM_User+19;
LM_MOVEPAGE = LM_User+20;
LM_MOVETOROW = LM_User+21;
LM_MOVETOCOLUMN = LM_User+22;
LM_KILLCHAR = LM_User+23;
LM_KILLWORD = LM_User+24;
LM_KILLLINE = LM_User+25;
LM_CUTTOCLIP = LM_User+26;
LM_COPYTOCLIP = LM_User+27;
LM_PASTEFROMCLIP = LM_User+28;
//LM_MOVERESIZE = LM_User+29;
LM_EXPOSEEVENT = LM_User+30;
LM_CONFIGUREEVENT = LM_User+31;
//LM_DRAW = LM_User+32; //LM_DRAW and LM_PAINT are the same.
LM_PAINT = LM_User+32;
LM_SHOWMODAL = LM_USER+33;
LM_SETFILTER = LM_USER+34;
LM_SETFILENAME = LM_USER+35;
LM_OK_CLICKED = LM_USER+36;
//LM_DRAW = LM_User+32; //LM_DRAW and LM_PAINT are the same.
LM_PAINT = LM_User+32;
LM_SHOWMODAL = LM_USER+33;
LM_SETFILTER = LM_USER+34;
LM_SETFILENAME = LM_USER+35;
LM_OK_CLICKED = LM_USER+36;
LM_CANCEL_CLICKED = LM_USER+37;
//LM_KEYDOWN = LM_User+38; // Windows Compatability
//LM_KEYUP = LM_USER+39; // Windows Compatability
LM_TIMER = LM_USER+40;
//LM_KEYDOWN = LM_User+38; // Windows Compatability
//LM_KEYUP = LM_USER+39; // Windows Compatability
LM_TIMER = LM_USER+40;
//LM_MOUSEBTNPRESS = LM_USER+41;
//LM_MOUSEBTNRELEASE = LM_USER+42;
LM_EXIT = LM_USER+60;
LM_SCREENINIT = LM_USER+61;
LM_CLOSEQUERY = LM_USER+62;
LM_DRAGSTART = LM_USER+63;
LM_DEACTIVATE = LM_USER+64; //used when a form is no longer in front
LM_EXIT = LM_USER+60;
LM_SCREENINIT = LM_USER+61;
LM_CLOSEQUERY = LM_USER+62;
LM_DRAGSTART = LM_USER+63;
LM_DEACTIVATE = LM_USER+64; //used when a form is no longer in front
LM_MONTHCHANGED = LM_USER+65;
LM_YEARCHANGED = LM_USER+66;
LM_DAYCHANGED = LM_USER+67;
LM_MONTHCHANGED = LM_USER+65;
LM_YEARCHANGED = LM_USER+66;
LM_DAYCHANGED = LM_USER+67;
LM_MOUSEFIRST2 = LM_USER+68;
LM_MOUSEFIRST2 = LM_USER+68;
LM_LBUTTONTRIPLECLK = LM_USER+68;
LM_LBUTTONQUADCLK = LM_USER+69;
LM_MBUTTONTRIPLECLK = LM_USER+70;
LM_MBUTTONQUADCLK = LM_USER+71;
LM_RBUTTONTRIPLECLK = LM_USER+72;
LM_RBUTTONQUADCLK = LM_USER+73;
LM_MOUSELAST2 = LM_RBUTTONQUADCLK;
LM_MOUSELAST2 = LM_RBUTTONQUADCLK;
LM_GRABFOCUS = LM_USER+74;
LM_GRABFOCUS = LM_USER+74;
LM_DRAWLISTITEM = LM_User+80;
// these IDs are reserved for internal messages in the interfaces
LM_INTERFACEFIRST = LM_User+99;
LM_INTERFACELAST = LM_User+199;
LM_INTERFACELAST = LM_User+199;
LM_UNKNOWN = LM_INTERFACELAST+1;
LM_UNKNOWN = LM_INTERFACELAST+1;
type
@ -347,7 +350,7 @@ type
BOOL = Boolean;
{Linux Messages}
{ LCL Messages }
TLMDrawItems = record
Msg: Cardinal;
@ -355,6 +358,14 @@ type
DrawItemStruct : PDrawItemStruct;
Result : LongInt;
end;
TLMDrawListItem = record
// message from the interface to the LCL
Msg: Cardinal;
Unused : LongInt;
DrawListItemStruct : PDrawListItemStruct;
Result : LongInt;
end;
TLMNoParams = record
Msg: Cardinal;
@ -871,6 +882,9 @@ end.
{
$Log$
Revision 1.35 2002/10/04 14:24:14 lazarus
MG: added DrawItem to TComboBox/TListBox
Revision 1.34 2002/10/03 18:04:46 lazarus
MG: started customdrawitem

View File

@ -37,8 +37,8 @@ interface
uses
VCLGlobals, Classes, SysUtils, Graphics, GraphType, LMessages, Controls,
Forms;
VCLGlobals, Classes, SysUtils, LCLType, Graphics, GraphType, LMessages,
Controls, Forms, ExtendedStrings;
type
@ -164,18 +164,14 @@ type
property OnResize;
end;
{ TCustomComboBox }
TComboBoxStyle = (csDropDown, csSimple, csDropDownList, csOwnerDrawFixed,
csOwnerDrawVariable);
TOwnerDrawStateType = (
odSelected, odGrayed, odDisabled, odChecked,
odFocused, odDefault, odHotLight, odInactive, odNoAccel,
odNoFocusRect, odReserved1, odReserved2, odComboBoxEdit);
TOwnerDrawState = set of TOwnerDrawStateType;
TDrawItemEvent = procedure(Control: TWinControl; Index: Integer;
Rect: TRect; State: TOwnerDrawState) of object;
ARect: TRect; State: TOwnerDrawState) of object;
TMeasureItemEvent = procedure(Control: TWinControl; Index: Integer;
var Height: Integer) of object;
@ -204,12 +200,12 @@ type
function GetItemWidth: Integer;
procedure SetItemWidth(const AValue: Integer);
procedure SetItems(Value : TStrings);
procedure CNDrawItems(var TheMessage : TLMDrawItems); message CN_DrawItem;
procedure LMDrawListItem(var TheMessage : TLMDrawListItem); message LM_DrawListItem;
procedure CNCommand(var TheMessage : TLMCommand); message CN_Command;
protected
procedure CreateHandle; override;
procedure DestroyHandle; override;
procedure DrawItem(Index: Integer; Rect: TRect;
procedure DrawItem(Index: Integer; ARect: TRect;
State: TOwnerDrawState); virtual;
procedure DoChange(var msg); message LM_CHANGED;
procedure Change; dynamic;
@ -318,16 +314,22 @@ type
{ TCustomListBox }
TListBoxStyle = (lbStandard, lbOwnerDrawFixed, lbOwnerDrawVariable);
TCustomListBox = class(TWinControl)
private
FBorderStyle : TBorderStyle;
FCanvas: TCanvas;
FExtendedSelect, FMultiSelect : boolean;
FItems : TStrings;
FItemHeight: Integer;
FItemIndex: integer;
FOnDrawItem: TDrawItemEvent;
FSorted : boolean;
FStyle : TListBoxStyle;
procedure UpdateSelectionMode;
procedure UpdateSorted;
procedure LMDrawListItem(var TheMessage : TLMDrawListItem); message LM_DrawListItem;
procedure SendItemSelected(Index: integer; IsSelected: boolean);
protected
procedure CreateHandle; override;
procedure DestroyHandle; override;
@ -344,25 +346,31 @@ type
procedure SetSelected(Index : integer; Val : boolean);
procedure SetSorted(Val : boolean); virtual;
procedure SetStyle(Val : TListBoxStyle); virtual;
procedure DrawItem(Index: Integer; ARect: TRect;
State: TOwnerDrawState); virtual;
protected
property BorderStyle : TBorderStyle read FBorderStyle write SetBorderStyle;
property ExtendedSelect : boolean read FExtendedSelect write SetExtendedSelect;
property Sorted : boolean read FSorted write SetSorted;
property Style : TListBoxStyle read FStyle write SetStyle;
property ItemHeight: Integer read GetItemHeight write SetItemHeight;
property OnDrawItem: TDrawItemEvent read FOnDrawItem write FOnDrawItem;
public
constructor Create(AOwner : TComponent); override;
destructor Destroy; override;
procedure Clear;
property Canvas: TCanvas read FCanvas;
property ItemIndex : integer read GetItemIndex write SetItemIndex;
property Items : TStrings read FItems write SetItems;
property MultiSelect : boolean read FMultiSelect write SetMultiSelect;
property SelCount : integer read GetSelCount;
property Selected[Index : integer] : boolean read GetSelected write SetSelected;
end;
{ TListBox }
TListBox = class(TCustomListBox)
public
property ItemIndex;
published
property Align;
property Anchors;
@ -380,6 +388,7 @@ type
property Visible;
property OnClick;
property OnDblClick;
property OnDrawItem;
property OnEnter;
property OnExit;
property OnKeyPress;
@ -391,6 +400,9 @@ type
property OnResize;
end;
{ TCustomEdit }
TEditCharCase = (ecNormal, ecUppercase, ecLowerCase);
TEchoMode = (emNormal, emNone, emPassword);
@ -440,6 +452,9 @@ type
property TabStop;
property TabOrder;
end;
{ TCustomMemo }
TCustomMemo = class(TCustomEdit)
private
@ -452,7 +467,6 @@ type
procedure SetWordWrap(const Value : boolean);
procedure SetScrollBars(const Value : TScrollStyle);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Append(const Value : String);
@ -461,6 +475,9 @@ type
property WordWrap: Boolean read FWordWrap write SetWordWrap;
property Font : TFont read FFont write FFont;
end;
{ TEdit }
TEdit = class(TCustomEdit)
published
@ -484,6 +501,9 @@ type
Property OnKeyDown;
Property OnKeyUp;
end;
{ TMemo }
TMemo = class(TCustomMemo)
published
@ -506,6 +526,7 @@ type
Property OnKeyUp;
end;
{ TCustomLabel }
TCustomLabel = class(TWinControl)
@ -570,7 +591,7 @@ type
end;
{ TCHECKBOX }
{ TCustomCheckBox }
// ToDo: delete TLeftRight when in classesh.inc
TLeftRight = taLeftJustify..taRightJustify;
@ -751,6 +772,7 @@ type
property OnStartDrag;
end;
{TRadioButton}
TRadioButton = class(TCustomCheckBox)
@ -789,11 +811,13 @@ type
property OnStartDrag;
end;
Function DeleteAmpersands(var Str : String) : Longint;
implementation
uses LCLLinux, LCLType, Interfaces;
uses LCLLinux, Interfaces;
type
@ -1316,6 +1340,9 @@ end.
{ =============================================================================
$Log$
Revision 1.53 2002/10/04 14:24:14 lazarus
MG: added DrawItem to TComboBox/TListBox
Revision 1.52 2002/10/03 18:04:46 lazarus
MG: started customdrawitem