mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-29 15:30:38 +02:00
+ Implemented TCheckListBox.Checked[] property
git-svn-id: trunk@4384 -
This commit is contained in:
parent
822a5a7bd7
commit
0a7ac9d03a
@ -1,3 +1,26 @@
|
||||
{ $Id$
|
||||
/***************************************************************************
|
||||
checklst.pp
|
||||
-----------
|
||||
|
||||
Initial Revision : Thu Jun 19 CST 2003
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
*****************************************************************************
|
||||
* *
|
||||
* This file is part of the Lazarus Component Library (LCL) *
|
||||
* *
|
||||
* See the file COPYING.LCL, included in this distribution, *
|
||||
* for details about the copyright. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* *
|
||||
*****************************************************************************
|
||||
}
|
||||
|
||||
unit CheckLst;
|
||||
|
||||
{$mode objfpc} {$H+}
|
||||
@ -5,7 +28,7 @@ unit CheckLst;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, StdCtrls, Graphics, GraphType, Controls, VCLGlobals;
|
||||
Classes, SysUtils, StdCtrls, Graphics, GraphType, Controls, VCLGlobals, LMessages;
|
||||
|
||||
|
||||
type
|
||||
@ -13,9 +36,17 @@ type
|
||||
|
||||
TCheckListBox = class(TCustomListBox)
|
||||
private
|
||||
FItemDataOffset: Integer;
|
||||
function GetChecked(const AIndex: Integer): Boolean;
|
||||
procedure SetChecked(const AIndex: Integer; const AValue: Boolean);
|
||||
procedure SendItemChecked(const AIndex: Integer; const AChecked: Boolean);
|
||||
protected
|
||||
procedure AssignItemDataToCache(const AIndex: Integer; const AData: Pointer); override;
|
||||
procedure AssignCacheToItemData(const AIndex: Integer; const AData: Pointer); override;
|
||||
function GetCachedDataSize: Integer; override;
|
||||
public
|
||||
constructor Create(AOwner: TComponent); override;
|
||||
property Checked[const AIndex: Integer]: Boolean read GetChecked write SetChecked;
|
||||
published
|
||||
property Align;
|
||||
property Anchors;
|
||||
@ -56,13 +87,74 @@ begin
|
||||
RegisterComponents('Additional',[TCheckListBox]);
|
||||
end;
|
||||
|
||||
type
|
||||
PCachedItemData = ^TCachedItemData;
|
||||
TCachedItemData = Boolean;
|
||||
|
||||
{ TCheckListBox }
|
||||
|
||||
procedure TCheckListBox.AssignCacheToItemData(const AIndex: Integer; const AData: Pointer);
|
||||
begin
|
||||
inherited AssignCacheToItemData(AIndex, AData);
|
||||
if PCachedItemData(AData + FItemDataOffset)^
|
||||
then SendItemChecked(AIndex, True);
|
||||
end;
|
||||
|
||||
procedure TCheckListBox.AssignItemDataToCache(const AIndex: Integer; const AData: Pointer);
|
||||
begin
|
||||
inherited AssignItemDataToCache(AIndex, AData);
|
||||
PCachedItemData(AData + FItemDataOffset)^ := Checked[AIndex];
|
||||
end;
|
||||
|
||||
constructor TCheckListBox.Create(AOwner: TComponent);
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
FCompStyle := csCheckListBox;
|
||||
end;
|
||||
|
||||
function TCheckListBox.GetCachedDataSize: Integer;
|
||||
begin
|
||||
FItemDataOffset := inherited GetCachedDataSize;
|
||||
Result := FItemDataOffset + SizeOf(TCachedItemData);
|
||||
end;
|
||||
|
||||
function TCheckListBox.GetChecked(const AIndex: Integer): Boolean;
|
||||
begin
|
||||
CheckIndex(AIndex);
|
||||
|
||||
if HandleAllocated
|
||||
then Result := (CNSendMessage(LM_CLB_GETCHECKED, Self, @AIndex) <> 0)
|
||||
else Result := PCachedItemData(GetCachedData(AIndex) + FItemDataOffset)^;
|
||||
end;
|
||||
|
||||
procedure TCheckListBox.SendItemChecked(const AIndex: Integer; const AChecked: Boolean);
|
||||
var
|
||||
Msg : TLMSetChecked;
|
||||
begin
|
||||
if HandleAllocated
|
||||
then begin
|
||||
Msg.Index:= AIndex;
|
||||
Msg.Checked := AChecked;
|
||||
CNSendMessage(LM_CLB_SETCHECKED, Self, @Msg);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCheckListBox.SetChecked(const AIndex: Integer; const AValue: Boolean);
|
||||
begin
|
||||
CheckIndex(AIndex);
|
||||
|
||||
if HandleAllocated
|
||||
then SendItemChecked(AIndex, AValue)
|
||||
else PCachedItemData(GetCachedData(AIndex) + FItemDataOffset)^ := AValue;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.2 2003/07/07 23:58:43 marc
|
||||
+ Implemented TCheckListBox.Checked[] property
|
||||
|
||||
|
||||
}
|
||||
|
@ -20,31 +20,39 @@
|
||||
}
|
||||
|
||||
type
|
||||
TCustomListBoxItemFlag = (clbiSelected);
|
||||
TCustomListBoxItemFlags = set of TCustomListBoxItemFlag;
|
||||
|
||||
TCustomListBoxItemRecord = record
|
||||
TheObject: TObject;
|
||||
Flags: TCustomListBoxItemFlags;
|
||||
Selected: Boolean;
|
||||
end;
|
||||
PCustomListBoxItemRecord = ^TCustomListBoxItemRecord;
|
||||
|
||||
|
||||
function GetListBoxItemRecord(ListBoxInternalItems: TStrings;
|
||||
Index: integer): PCustomListBoxItemRecord;
|
||||
{------------------------------------------------------------------------------}
|
||||
{ procedure TCustomListBox.AssignCacheToItemData }
|
||||
{------------------------------------------------------------------------------}
|
||||
procedure TCustomListBox.AssignCacheToItemData(const AIndex: Integer; const AData: Pointer);
|
||||
begin
|
||||
Result:=PCustomListBoxItemRecord(
|
||||
TExtendedStringList(ListBoxInternalItems).Records[Index]);
|
||||
if PCustomListBoxItemRecord(AData)^.Selected
|
||||
or (FItemIndex = AIndex)
|
||||
then SendItemSelected(AIndex, True);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ procedure TCustomListBox.AssignItemDataToCache }
|
||||
{------------------------------------------------------------------------------}
|
||||
procedure TCustomListBox.AssignItemDataToCache(const AIndex: Integer; const AData: Pointer);
|
||||
begin
|
||||
PCustomListBoxItemRecord(AData)^.Selected := Selected[AIndex];
|
||||
end;
|
||||
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
procedure TCustomListBox.CreateHandle
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TCustomListBox.CreateHandle;
|
||||
var
|
||||
NewStrings : TStrings;
|
||||
i: integer;
|
||||
OldItems: TStrings;
|
||||
i, cnt: integer;
|
||||
OldItems: TExtendedStringList;
|
||||
begin
|
||||
//writeln('[TCustomListBox.CreateHandle] A ',FItems.ClassName);
|
||||
inherited CreateHandle;
|
||||
@ -56,10 +64,11 @@ begin
|
||||
NewStrings:= TStrings(Pointer(CNSendMessage(LM_GETITEMS, Self, nil)));
|
||||
// copy the items (text+objects)
|
||||
NewStrings.Assign(Items);
|
||||
OldItems:=FItems;
|
||||
OldItems := FItems as TExtendedStringList;
|
||||
|
||||
// new item list is the interface item list
|
||||
FItems:= NewStrings;
|
||||
FCacheValid := False;
|
||||
|
||||
UpdateSelectionMode;
|
||||
UpdateSorted;
|
||||
@ -67,11 +76,10 @@ begin
|
||||
CNSendMessage(LM_SETITEMINDEX, Self, Pointer(FItemIndex));
|
||||
|
||||
// copy items attributes
|
||||
for i:=0 to OldItems.Count-1 do begin
|
||||
if (clbiSelected in GetListBoxItemRecord(OldItems,i)^.Flags)
|
||||
or (FItemIndex=i) then
|
||||
SendItemSelected(i,True);
|
||||
end;
|
||||
cnt := OldItems.Count;
|
||||
for i:=0 to cnt-1 do
|
||||
AssignCacheToItemData(i, OldItems.Records[i]);
|
||||
|
||||
// free old items
|
||||
OldItems.Free;
|
||||
|
||||
@ -79,30 +87,29 @@ begin
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ procedure TCustomListBox.DestroyHandle }
|
||||
{ procedure TCustomListBox.DestroyHandle }
|
||||
{------------------------------------------------------------------------------}
|
||||
procedure TCustomListBox.DestroyHandle;
|
||||
var
|
||||
NewStrings : TStrings;
|
||||
NewStrings : TExtendedStringList;
|
||||
i, Cnt: integer;
|
||||
begin
|
||||
//writeln('[TCustomListBox.DestroyHandle] A ',FItems.ClassName);
|
||||
// create internal item list
|
||||
NewStrings:= TExtendedStringList.Create(SizeOf(TCustomListBoxItemRecord));
|
||||
NewStrings:= TExtendedStringList.Create(GetCachedDataSize);
|
||||
|
||||
// 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)
|
||||
else
|
||||
Exclude(GetListBoxItemRecord(NewStrings,i)^.Flags,clbiSelected);
|
||||
end;
|
||||
for i:=0 to Cnt-1 do
|
||||
AssignItemDataToCache(i, NewStrings.Records[i]);
|
||||
|
||||
// free the interface items list
|
||||
FItems.Free;
|
||||
// new item list is the internal item list
|
||||
FItems:= NewStrings;
|
||||
FCacheValid := True;
|
||||
//writeln('[TCustomListBox.DestroyHandle] B ',FItems.ClassName);
|
||||
inherited DestroyHandle;
|
||||
//writeln('[TCustomListBox.DestroyHandle] END ',FItems.ClassName);
|
||||
@ -239,25 +246,17 @@ end;
|
||||
{------------------------------------------------------------------------------}
|
||||
procedure TCustomListBox.SetSelected(Index : integer; Val : boolean);
|
||||
begin
|
||||
if (Index < 0) or (Index >= Items.Count) then
|
||||
raise Exception.CreateFmt(rsIndexOutOfRange,[ClassName,Index,Items.Count]);
|
||||
CheckIndex(Index);
|
||||
|
||||
if not MultiSelect then begin
|
||||
if Val then
|
||||
ItemIndex:=Index
|
||||
else if Index=ItemIndex then
|
||||
ItemIndex:=-1;
|
||||
end else begin
|
||||
//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;
|
||||
if HandleAllocated
|
||||
then SendItemSelected(Index,Val)
|
||||
else PCustomListBoxItemRecord(GetCachedData(Index))^.Selected := Val;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -266,12 +265,11 @@ end;
|
||||
{------------------------------------------------------------------------------}
|
||||
function TCustomListBox.GetSelected(Index : integer) : boolean;
|
||||
begin
|
||||
if (Index < 0) or (Index >= Items.Count) then
|
||||
raise Exception.CreateFmt(rsIndexOutOfRange,[ClassName,Index,Items.Count]);
|
||||
CheckIndex(Index);
|
||||
if HandleAllocated then
|
||||
Result:= (CNSendMessage(LM_GETSEL, Self, @Index) > 0)
|
||||
else
|
||||
Result:=clbiSelected in GetListBoxItemRecord(FItems,Index)^.Flags;
|
||||
Result:= PCustomListBoxItemRecord(GetCachedData(Index))^.Selected;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
@ -348,6 +346,26 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ function TCustomListBox.GetCachedData }
|
||||
{------------------------------------------------------------------------------}
|
||||
function TCustomListBox.GetCachedData(const AIndex: Integer): Pointer;
|
||||
begin
|
||||
if not FCacheValid then raise EInvalidOperation.Create('Reading form invalid cache');
|
||||
Result := TExtendedStringList(FItems).Records[AIndex];
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ function TCustomListBox.GetCachedDataSize }
|
||||
{ }
|
||||
{ Returns the amount of data needed when the widged isn't realized in the }
|
||||
{ interface }
|
||||
{------------------------------------------------------------------------------}
|
||||
function TCustomListBox.GetCachedDataSize: Integer;
|
||||
begin
|
||||
Result := SizeOf(TCustomListBoxItemRecord);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------}
|
||||
{ function TCustomListBox.SetItems }
|
||||
{------------------------------------------------------------------------------}
|
||||
@ -366,9 +384,9 @@ constructor TCustomListBox.Create(AOwner : TComponent);
|
||||
begin
|
||||
inherited Create(AOwner);
|
||||
fCompStyle := csListBox;
|
||||
|
||||
FBorderStyle:= bsSingle;
|
||||
FItems := TExtendedStringList.Create(SizeOf(TCustomListBoxItemRecord));
|
||||
FCacheValid := True;
|
||||
FItemIndex:=-1;
|
||||
FCanvas := TControlCanvas.Create;
|
||||
TControlCanvas(FCanvas).Control := Self;
|
||||
@ -380,10 +398,9 @@ end;
|
||||
{------------------------------------------------------------------------------}
|
||||
destructor TCustomListBox.Destroy;
|
||||
begin
|
||||
FCanvas.Free;
|
||||
FCanvas:=nil;
|
||||
FreeAndNil(FCanvas);
|
||||
inherited Destroy;
|
||||
FItems.Free;
|
||||
FreeAndNil(FItems);
|
||||
end;
|
||||
|
||||
function TCustomListBox.GetItemIndex : integer;
|
||||
@ -409,6 +426,16 @@ begin
|
||||
//writeln('[TCustomListBox.SetItemIndex] END ',FItems.ClassName);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
procedure TCustomListBox.CheckIndex
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TCustomListBox.CheckIndex(const AIndex: Integer);
|
||||
begin
|
||||
if (AIndex < 0)
|
||||
or (AIndex >= Items.Count)
|
||||
then raise Exception.CreateFmt(rsIndexOutOfRange,[ClassName, AIndex, Items.Count]);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
procedure TCustomListBox.Clear
|
||||
------------------------------------------------------------------------------}
|
||||
|
@ -2263,24 +2263,25 @@ end;
|
||||
function TgtkObject.IntSendMessage3(LM_Message : Integer; Sender : TObject;
|
||||
data : pointer) : integer;
|
||||
var
|
||||
handle : hwnd; // handle of sender
|
||||
pStr : PChar; // temporary string pointer, must be allocated/disposed when used!
|
||||
Widget : PGtkWidget; // pointer to gtk-widget (local use when neccessary)
|
||||
AParent : TWinControl; // only used twice, replace with typecasts!
|
||||
Pixmap : pgdkPixMap;
|
||||
box1 : pgtkWidget; // currently only used for TBitBtn
|
||||
pixmapwid : pGtkWidget; // currently only used for TBitBtn, possibly replace with pixmap!!!!
|
||||
pLabel : PgtkWidget; // currently only used as extra label-widget for TBitBtn
|
||||
Num : Integer; // currently only used for LM_INSERTTOOLBUTTON and LM_ADDITEM
|
||||
pStr2 : PChar; // currently only used for LM_INSERTTOOLBUTTON
|
||||
GList : pGList; // Only used for listboxes, replace with widget!!!!!
|
||||
handle : hwnd; // handle of sender
|
||||
pStr : PChar; // temporary string pointer, must be allocated/disposed when used!
|
||||
Widget : PGtkWidget; // pointer to gtk-widget (local use when neccessary)
|
||||
ChildWidget : PGtkWidget; // generic pointer to a child gtk-widget (local use when neccessary)
|
||||
AParent : TWinControl; // only used twice, replace with typecasts!
|
||||
Pixmap : pgdkPixMap;
|
||||
box1 : pgtkWidget; // currently only used for TBitBtn
|
||||
pixmapwid : pGtkWidget; // currently only used for TBitBtn, possibly replace with pixmap!!!!
|
||||
pLabel : PgtkWidget; // currently only used as extra label-widget for TBitBtn
|
||||
Num : Integer; // currently only used for LM_INSERTTOOLBUTTON and LM_ADDITEM
|
||||
pStr2 : PChar; // currently only used for LM_INSERTTOOLBUTTON
|
||||
GList : pGList; // Only used for listboxes, replace with widget!!!!!
|
||||
SelectionMode : TGtkSelectionMode; // currently only used for listboxes
|
||||
ListItem : PGtkListItem; // currently only used for listboxes
|
||||
Rect : TRect;
|
||||
ListItem : PGtkListItem; // currently only used for listboxes
|
||||
Rect : TRect;
|
||||
FormIconGdiObject: PGdiObject; // currently only used by LM_SETFORMICON
|
||||
Geometry : TGdkGeometry;
|
||||
Accel : integer;
|
||||
AWindow : PGdkWindow;
|
||||
Geometry : TGdkGeometry;
|
||||
Accel : integer;
|
||||
AWindow : PGdkWindow;
|
||||
begin
|
||||
Result := 0; //default value just in case nothing sets it
|
||||
|
||||
@ -3002,33 +3003,74 @@ begin
|
||||
end;
|
||||
|
||||
LM_GETSEL :
|
||||
case (Sender as TControl).fCompStyle of
|
||||
csListBox, csCheckListBox:
|
||||
begin
|
||||
{ Get the child in question of that index }
|
||||
Widget:=GetWidgetInfo(Pointer(Handle),True)^.ImplementationWidget;
|
||||
ListItem:= g_list_nth_data(PGtkList(Widget)^.children, Integer(Data^));
|
||||
if (ListItem<>nil)
|
||||
and (g_list_index(PGtkList(Widget)^.selection, ListItem)>=0) then
|
||||
Result:=1
|
||||
else
|
||||
Result:=0;
|
||||
end;
|
||||
csCListBox:
|
||||
begin
|
||||
{ Get the selections }
|
||||
Widget:=GetWidgetInfo(Pointer(Handle),True)^.ImplementationWidget;
|
||||
GList:= PGtkCList(Widget)^.selection;
|
||||
Result := 0; { assume: nothing found }
|
||||
while Assigned(GList) do begin
|
||||
if integer(GList^.data) = integer(Data^) then begin
|
||||
Result:= 1;
|
||||
Break;
|
||||
end else
|
||||
GList := GList^.Next;
|
||||
begin
|
||||
Result := 0; { assume: nothing found }
|
||||
if (Sender is TControl)
|
||||
and Assigned (data)
|
||||
then case TControl(Sender).fCompStyle of
|
||||
csListBox, csCheckListBox:
|
||||
begin
|
||||
{ Get the child in question of that index }
|
||||
Widget:=GetWidgetInfo(Pointer(Handle),True)^.ImplementationWidget;
|
||||
ListItem:= g_list_nth_data(PGtkList(Widget)^.children, Integer(Data^));
|
||||
if (ListItem<>nil)
|
||||
and (g_list_index(PGtkList(Widget)^.selection, ListItem)>=0)
|
||||
then Result:=1
|
||||
end;
|
||||
csCListBox:
|
||||
begin
|
||||
{ Get the selections }
|
||||
Widget:=GetWidgetInfo(Pointer(Handle),True)^.ImplementationWidget;
|
||||
GList:= PGtkCList(Widget)^.selection;
|
||||
while Assigned(GList) do begin
|
||||
if integer(GList^.data) = integer(Data^) then begin
|
||||
Result:= 1;
|
||||
Break;
|
||||
end else
|
||||
GList := GList^.Next;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
LM_CLB_GETCHECKED :
|
||||
begin
|
||||
Result := 0;
|
||||
if Assigned(Data)
|
||||
and (Sender is TControl)
|
||||
and (TControl(Sender).fCompStyle = csCheckListBox)
|
||||
then begin
|
||||
{ Get the child in question of that index }
|
||||
Widget := GetWidgetInfo(Pointer(Handle),True)^.ImplementationWidget;
|
||||
ListItem := g_list_nth_data(PGtkList(Widget)^.children, Integer(Data^));
|
||||
if ListItem <> nil
|
||||
then begin
|
||||
ChildWidget := PPointer(PGTKBox(PGtkBin(ListItem)^.child)^.Children^.Data)^;
|
||||
if (ChildWidget <> nil)
|
||||
and gtk_toggle_button_get_active(PGTKToggleButton(ChildWidget))
|
||||
then Result := 1;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
LM_CLB_SETCHECKED :
|
||||
begin
|
||||
if Assigned(Data)
|
||||
and (Sender is TControl)
|
||||
and (TControl(Sender).fCompStyle = csCheckListBox)
|
||||
then begin
|
||||
Widget := GetWidgetInfo(Pointer(Handle), True)^.ImplementationWidget;
|
||||
ListItem := g_list_nth_data(PGtkList(Widget)^.children,
|
||||
TLMSetChecked(Data^).Index);
|
||||
if ListItem <> nil
|
||||
then begin
|
||||
ChildWidget := PPointer(PGTKBox(PGtkBin(ListItem)^.child)^.Children^.Data)^;
|
||||
if (ChildWidget <> nil)
|
||||
then gtk_toggle_button_set_active(PGTKToggleButton(ChildWidget),
|
||||
TLMSetChecked(Data^).Checked);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
LM_SETLIMITTEXT :
|
||||
begin
|
||||
@ -3055,31 +3097,22 @@ begin
|
||||
LM_SETSEL:
|
||||
begin
|
||||
if (Sender is TControl)
|
||||
and (TControl(Sender).fCompStyle in [csListBox, csCheckListBox, csCListBox])
|
||||
and assigned (data) then
|
||||
begin
|
||||
if (TControl(Sender).fCompStyle in [csListBox, csCheckListBox]) then
|
||||
begin
|
||||
if TLMSetSel(Data^).Selected then begin
|
||||
gtk_list_select_item(
|
||||
PGtkList(GetWidgetInfo(Pointer(Handle), True)^.ImplementationWidget),
|
||||
TLMSetSel(Data^).Index);
|
||||
end else
|
||||
gtk_list_unselect_item(
|
||||
PGtkList(GetWidgetInfo(Pointer(Handle), True)^.ImplementationWidget),
|
||||
TLMSetSel(Data^).Index);
|
||||
end
|
||||
else if (TControl(Sender).fCompStyle = csCListBox) then
|
||||
begin
|
||||
if TLMSetSel(Data^).Selected then
|
||||
gtk_clist_select_row(
|
||||
PGtkCList(GetWidgetInfo(Pointer(Handle), True)^.ImplementationWidget),
|
||||
TLMSetSel(Data^).Index, 0)
|
||||
else
|
||||
gtk_clist_unselect_row(
|
||||
PGtkCList(GetWidgetInfo(Pointer(Handle), True)^.ImplementationWidget),
|
||||
TLMSetSel(Data^).Index, 0);
|
||||
end;
|
||||
and Assigned (data)
|
||||
then case TControl(Sender).fCompStyle of
|
||||
csListBox, csCheckListBox:
|
||||
begin
|
||||
Widget := GetWidgetInfo(Pointer(Handle), True)^.ImplementationWidget;
|
||||
if TLMSetSel(Data^).Selected
|
||||
then gtk_list_select_item(PGtkList(Widget), TLMSetSel(Data^).Index)
|
||||
else gtk_list_unselect_item(PGtkList(Widget), TLMSetSel(Data^).Index);
|
||||
end;
|
||||
csCListBox:
|
||||
begin
|
||||
Widget := GetWidgetInfo(Pointer(Handle), True)^.ImplementationWidget;
|
||||
if TLMSetSel(Data^).Selected
|
||||
then gtk_clist_select_row(PGtkCList(Widget), TLMSetSel(Data^).Index, 0)
|
||||
else gtk_clist_unselect_row(PGtkCList(Widget), TLMSetSel(Data^).Index, 0);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -7912,6 +7945,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.393 2003/07/07 23:58:43 marc
|
||||
+ Implemented TCheckListBox.Checked[] property
|
||||
|
||||
Revision 1.392 2003/07/06 17:53:34 mattias
|
||||
updated polish localization
|
||||
|
||||
|
@ -122,30 +122,36 @@ const
|
||||
|
||||
// TListView
|
||||
LM_LV_FIRST = LM_COMUSER+80;
|
||||
LM_LV_ADDITEM = LM_LV_FIRST+1;
|
||||
LM_LV_CHANGEITEM = LM_LV_FIRST+2;
|
||||
LM_LV_DELETEITEM = LM_LV_FIRST+3;
|
||||
LM_LV_SELECTITEM = LM_LV_FIRST+4;
|
||||
LM_LV_ADDITEM = LM_LV_FIRST+0;
|
||||
LM_LV_CHANGEITEM = LM_LV_FIRST+1;
|
||||
LM_LV_DELETEITEM = LM_LV_FIRST+2;
|
||||
LM_LV_SELECTITEM = LM_LV_FIRST+3;
|
||||
LM_LV_LAST = LM_LV_FIRST+9; // LM_COMUSER+89
|
||||
|
||||
// TComboBox
|
||||
LM_CB_FIRST = LM_LV_LAST+1; // LM_COMUSER+90
|
||||
LM_CB_GETCOUNT = LM_CB_FIRST+1;
|
||||
LM_CB_GETTEXT = LM_CB_FIRST+2;
|
||||
LM_CB_ADDTEXT = LM_CB_FIRST+3;
|
||||
LM_CB_GETCOUNT = LM_CB_FIRST+0;
|
||||
LM_CB_GETTEXT = LM_CB_FIRST+1;
|
||||
LM_CB_ADDTEXT = LM_CB_FIRST+2;
|
||||
LM_CB_LAST = LM_CB_FIRST+9; // LM_COMUSER+99
|
||||
|
||||
// TNoteBook
|
||||
LM_NB_First = LM_CB_LAST+1;
|
||||
LM_NB_UpdateTab = LM_NB_First+1;
|
||||
LM_NB_UpdateTab = LM_NB_First+0;
|
||||
LM_NB_Last = LM_NB_UpdateTab;
|
||||
|
||||
// TListBox
|
||||
LM_LB_First = LM_NB_Last +1;
|
||||
LM_LB_GETTOPINDEX = LM_LB_First +1;
|
||||
LM_LB_SETTOPINDEX = LM_LB_First +2;
|
||||
LM_LB_GETINDEXAT = LM_LB_First +3;
|
||||
LM_LB_GETTOPINDEX = LM_LB_First +0;
|
||||
LM_LB_SETTOPINDEX = LM_LB_First +1;
|
||||
LM_LB_GETINDEXAT = LM_LB_First +2;
|
||||
LM_LB_Last = LM_LB_GETINDEXAT;
|
||||
|
||||
// TCheckListBox
|
||||
LM_CLB_FIRST = LM_LB_Last + 1;
|
||||
LM_CLB_GETCHECKED = LM_CLB_FIRST + 0;
|
||||
LM_CLB_SETCHECKED = LM_CLB_FIRST + 1;
|
||||
LM_CLB_LAST = LM_CLB_SETCHECKED;
|
||||
|
||||
|
||||
//-------------
|
||||
@ -712,6 +718,11 @@ type
|
||||
ExtendedSelect : boolean;
|
||||
end;
|
||||
|
||||
TLMSetChecked = record
|
||||
Index : integer;
|
||||
Checked : boolean;
|
||||
end;
|
||||
|
||||
TLMSetFocus = packed record
|
||||
Msg: Cardinal;
|
||||
FocusedWnd: HWND;
|
||||
@ -951,6 +962,9 @@ begin
|
||||
LM_LB_SETTOPINDEX :Result:='LM_LB_SETTOPINDEX';
|
||||
//LM_LB_Last :Result:='LM_LB_Last';
|
||||
|
||||
// TCheckListBox
|
||||
LM_CLB_GETCHECKED :Result:='LM_CLB_GETCHECKED';
|
||||
LM_CLB_SETCHECKED :Result:='LM_CLB_SETCHECKED';
|
||||
|
||||
//-------------
|
||||
// lcl messages
|
||||
@ -1045,6 +1059,9 @@ end.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.49 2003/07/07 23:58:43 marc
|
||||
+ Implemented TCheckListBox.Checked[] property
|
||||
|
||||
Revision 1.48 2003/04/29 13:35:39 mattias
|
||||
improved configure build lazarus dialog
|
||||
|
||||
|
@ -345,6 +345,7 @@ type
|
||||
FSorted: boolean;
|
||||
FStyle: TListBoxStyle;
|
||||
FTopIndex: integer;
|
||||
FCacheValid: Boolean;
|
||||
function GetTopIndex: Integer;
|
||||
procedure SetTopIndex(const AValue: Integer);
|
||||
procedure UpdateSelectionMode;
|
||||
@ -352,12 +353,17 @@ type
|
||||
procedure LMDrawListItem(var TheMessage : TLMDrawListItem); message LM_DrawListItem;
|
||||
procedure SendItemSelected(Index: integer; IsSelected: boolean);
|
||||
protected
|
||||
procedure AssignItemDataToCache(const AIndex: Integer; const AData: Pointer); virtual; // called to store item data while the handle isn't created
|
||||
procedure AssignCacheToItemData(const AIndex: Integer; const AData: Pointer); virtual; // called to restore the itemdata after a handle is created
|
||||
procedure CreateHandle; override;
|
||||
procedure DestroyHandle; override;
|
||||
procedure CheckIndex(const AIndex: Integer);
|
||||
function GetItemHeight: Integer;
|
||||
function GetItemIndex : integer; virtual;
|
||||
function GetSelCount : integer;
|
||||
function GetSelected(Index : integer) : boolean;
|
||||
function GetCachedDataSize: Integer; virtual; // returns the amount of data needed per item
|
||||
function GetCachedData(const AIndex: Integer): Pointer;
|
||||
procedure SetBorderStyle(Val : TBorderStyle); virtual;
|
||||
procedure SetExtendedSelect(Val : boolean); virtual;
|
||||
procedure SetItemIndex(Val : integer); virtual;
|
||||
@ -1459,6 +1465,9 @@ end.
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.100 2003/07/07 23:58:43 marc
|
||||
+ Implemented TCheckListBox.Checked[] property
|
||||
|
||||
Revision 1.99 2003/06/23 09:42:09 mattias
|
||||
fixes for debugging lazarus
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user