educationlaz: fixed compilation

git-svn-id: trunk@44086 -
This commit is contained in:
mattias 2014-02-15 23:45:24 +00:00
parent d683f4106d
commit e2ece1726a
6 changed files with 91 additions and 51 deletions

View File

@ -1,5 +1,7 @@
inherited EduCompPaletteFrame: TEduCompPaletteFrame object EduCompPaletteFrame: TEduCompPaletteFrame
Left = 0
Height = 409 Height = 409
Top = 0
Width = 480 Width = 480
ClientHeight = 409 ClientHeight = 409
ClientWidth = 480 ClientWidth = 480
@ -7,39 +9,37 @@ inherited EduCompPaletteFrame: TEduCompPaletteFrame
TabOrder = 0 TabOrder = 0
DesignLeft = 286 DesignLeft = 286
DesignTop = 126 DesignTop = 126
object ComponentsGroupBox: TGroupBox[0] object ComponentsGroupBox: TGroupBox
AnchorSideTop.Control = Owner
AnchorSideBottom.Control = Owner
AnchorSideBottom.Side = asrBottom AnchorSideBottom.Side = asrBottom
Left = 169 Left = 153
Height = 397 Height = 397
Top = 6 Top = 6
Width = 305 Width = 321
Align = alClient Align = alClient
Anchors = [akTop, akBottom] Anchors = [akTop, akBottom]
BorderSpacing.Around = 6 BorderSpacing.Around = 6
Caption = 'ComponentsGroupBox' Caption = 'ComponentsGroupBox'
ClientHeight = 378 ClientHeight = 380
ClientWidth = 301 ClientWidth = 317
TabOrder = 0 TabOrder = 0
object ComponentsTreeView: TTreeView object ComponentsTreeView: TTreeView
Left = 0 Left = 0
Height = 378 Height = 380
Top = 0 Top = 0
Width = 301 Width = 317
Align = alClient Align = alClient
DefaultItemHeight = 19 DefaultItemHeight = 18
ReadOnly = True ReadOnly = True
TabOrder = 0 TabOrder = 0
OnMouseDown = ComponentsTreeViewMouseDown OnMouseDown = ComponentsTreeViewMouseDown
Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips] Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips]
end end
end end
object LeftPanel: TPanel[1] object LeftPanel: TPanel
Left = 0 Left = 0
Height = 409 Height = 409
Top = 0 Top = 0
Width = 163 Width = 147
Align = alLeft Align = alLeft
AutoSize = True AutoSize = True
ChildSizing.LeftRightSpacing = 6 ChildSizing.LeftRightSpacing = 6
@ -47,13 +47,13 @@ inherited EduCompPaletteFrame: TEduCompPaletteFrame
ChildSizing.HorizontalSpacing = 6 ChildSizing.HorizontalSpacing = 6
ChildSizing.VerticalSpacing = 6 ChildSizing.VerticalSpacing = 6
ClientHeight = 409 ClientHeight = 409
ClientWidth = 163 ClientWidth = 147
TabOrder = 1 TabOrder = 1
object ShowAllButton: TButton object ShowAllButton: TButton
Left = 7 Left = 7
Height = 29 Height = 27
Top = 77 Top = 73
Width = 149 Width = 133
Align = alTop Align = alTop
AutoSize = True AutoSize = True
Caption = 'ShowAllButton' Caption = 'ShowAllButton'
@ -62,9 +62,9 @@ inherited EduCompPaletteFrame: TEduCompPaletteFrame
end end
object HideAllButton: TButton object HideAllButton: TButton
Left = 7 Left = 7
Height = 29 Height = 27
Top = 136 Top = 130
Width = 149 Width = 133
Align = alTop Align = alTop
AutoSize = True AutoSize = True
BorderSpacing.Top = 30 BorderSpacing.Top = 30
@ -74,9 +74,9 @@ inherited EduCompPaletteFrame: TEduCompPaletteFrame
end end
object ShowMinimalButton: TButton object ShowMinimalButton: TButton
Left = 7 Left = 7
Height = 29 Height = 27
Top = 7 Top = 7
Width = 149 Width = 133
Align = alTop Align = alTop
AutoSize = True AutoSize = True
Caption = 'ShowMinimalButton' Caption = 'ShowMinimalButton'
@ -85,9 +85,9 @@ inherited EduCompPaletteFrame: TEduCompPaletteFrame
end end
object ShowExtendedButton: TButton object ShowExtendedButton: TButton
Left = 7 Left = 7
Height = 29 Height = 27
Top = 42 Top = 40
Width = 149 Width = 133
Align = alTop Align = alTop
AutoSize = True AutoSize = True
Caption = 'ShowExtendedButton' Caption = 'ShowExtendedButton'

View File

@ -62,14 +62,16 @@ type
private private
HideImgID: LongInt; HideImgID: LongInt;
ShowImgID: LongInt; ShowImgID: LongInt;
fCompNameToImgIndex: TStringToPointerTree; // Component.ClassName to index+1 in TreeViews.Images
procedure FillComponentTreeView; procedure FillComponentTreeView;
procedure SaveFillComponentTreeView; procedure SaveFillComponentTreeView;
procedure ShowHideAll(aShow: boolean); procedure ShowHideAll(aShow: boolean);
procedure ShowSelected(extended: boolean); procedure ShowSelected(extended: boolean);
public public
destructor Destroy; override;
function GetTitle: String; override; function GetTitle: String; override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override; procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override; procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override; class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override; procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
end; end;
@ -137,9 +139,52 @@ begin
ShowSelected(false); ShowSelected(false);
end; end;
procedure TEduCompPaletteFrame.FillComponentTreeView; procedure TEduCompPaletteFrame.FillComponentTreeView;
function GetIconCopy(ResName: string): TCustomBitMap;
var
ResHandle: TLResource;
begin
Result := nil;
// prevent raising exception and speedup a bit search/load
ResHandle := LazarusResources.Find(ResName);
if ResHandle <> nil then
Result := CreateBitmapFromLazarusResource(ResHandle)
else
if FindResource(HInstance, PChar(ResName), PChar(RT_BITMAP)) <> 0 then
begin
Result := TBitmap.Create;
Result.LoadFromResourceName(HInstance, ResName);
Result.Transparent := True;
end
else
if FindResource(HInstance, PChar(ResName), PChar(RT_RCDATA)) <> 0 then
Result := CreateBitmapFromResourceName(HInstance, ResName);
end;
function GetCompImgIndex(ResName: string): integer;
var
Img: TCustomBitmap;
begin
if fCompNameToImgIndex=nil then
fCompNameToImgIndex:=TStringToPointerTree.Create(false);
if fCompNameToImgIndex.Contains(ResName) then begin
Result:=PtrUInt(fCompNameToImgIndex[ResName])-1;
end else begin
// load
Img:=GetIconCopy(ResName);
if Img=nil then
Img:=GetIconCopy('unregisteredcomponent');
if Img<>nil then begin
Result:=ComponentsTreeView.Images.Add(Img,nil);
Img.Free;
end else begin
Result:=-1;
end;
fCompNameToImgIndex[ResName]:=Pointer(PtrUInt(Result+1));
end;
end;
var var
i: Integer; i: Integer;
Page: TBaseComponentPage; Page: TBaseComponentPage;
@ -147,8 +192,6 @@ var
Comp: TRegisteredComponent; Comp: TRegisteredComponent;
PageNode: TTreeNode; PageNode: TTreeNode;
CompNode: TTreeNode; CompNode: TTreeNode;
ResHandle: TLResource;
Image: TCustomBitmap;
CompName: String; CompName: String;
begin begin
ComponentsTreeView.BeginUpdate; ComponentsTreeView.BeginUpdate;
@ -170,15 +213,7 @@ begin
Comp:=Page[j]; Comp:=Page[j];
CompName:=Comp.ComponentClass.ClassName; CompName:=Comp.ComponentClass.ClassName;
CompNode:=ComponentsTreeView.Items.AddChild(PageNode,CompName); CompNode:=ComponentsTreeView.Items.AddChild(PageNode,CompName);
ResHandle := LazarusResources.Find(CompName); CompNode.ImageIndex:=GetCompImgIndex(CompName);
if ResHandle <> nil then
Image := CreateBitmapFromResourceName(HInstance, ResHandle)
else
Image := nil;
if Image = nil then
Image := CreateBitmapFromResourceName(HInstance, 'default');
CompNode.ImageIndex:=ComponentsTreeView.Images.Add(Image,nil);
Image.Free;
CompNode.SelectedIndex:=CompNode.ImageIndex; CompNode.SelectedIndex:=CompNode.ImageIndex;
if EduComponentPaletteOptions.ComponentVisible[CompName] then if EduComponentPaletteOptions.ComponentVisible[CompName] then
CompNode.StateIndex:=ShowImgID CompNode.StateIndex:=ShowImgID
@ -316,6 +351,12 @@ begin
ComponentsTreeView.EndUpdate; ComponentsTreeView.EndUpdate;
end; end;
destructor TEduCompPaletteFrame.Destroy;
begin
FreeAndNil(fCompNameToImgIndex);
inherited Destroy;
end;
function TEduCompPaletteFrame.GetTitle: String; function TEduCompPaletteFrame.GetTitle: String;
begin begin
Result:=ersEduCompPaletteTitle; Result:=ersEduCompPaletteTitle;
@ -363,7 +404,7 @@ begin
if AValue then if AValue then
fVisible[ComponentName]:='1' fVisible[ComponentName]:='1'
else else
fVisible.Delete(ComponentName); fVisible.Remove(ComponentName);
end; end;
procedure TEduComponentPaletteOptions.VoteForVisible( procedure TEduComponentPaletteOptions.VoteForVisible(

View File

@ -55,7 +55,7 @@ type
ShowAllChildsButton: TButton; ShowAllChildsButton: TButton;
procedure FrameClick(Sender: TObject); procedure FrameClick(Sender: TObject);
procedure MenusTreeViewMouseDown(Sender: TObject; Button: TMouseButton; procedure MenusTreeViewMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer); {%H-}Shift: TShiftState; X, Y: Integer);
procedure ShowAllButtonClick(Sender: TObject); procedure ShowAllButtonClick(Sender: TObject);
procedure ShowAllChildsButtonClick(Sender: TObject); procedure ShowAllChildsButtonClick(Sender: TObject);
private private
@ -71,7 +71,7 @@ type
public public
function GetTitle: String; override; function GetTitle: String; override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override; procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override; procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override; class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override; procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
end; end;
@ -328,7 +328,7 @@ begin
if AValue then if AValue then
fHidden[MenuPath]:='1' fHidden[MenuPath]:='1'
else else
fHidden.Delete(MenuPath); fHidden.Remove(MenuPath);
end; end;
constructor TEduMenuOptions.Create; constructor TEduMenuOptions.Create;

View File

@ -44,8 +44,8 @@ type
TFileDescSingleFileProgram = class(TProjectFileDescriptor) TFileDescSingleFileProgram = class(TProjectFileDescriptor)
public public
constructor Create; override; constructor Create; override;
function CreateSource(const Filename, SourceName, function CreateSource(const {%H-}Filename, SourceName,
ResourceName: string): string; override; {%H-}ResourceName: string): string; override;
function GetLocalizedName: string; override; function GetLocalizedName: string; override;
function GetLocalizedDescription: string; override; function GetLocalizedDescription: string; override;
end; end;
@ -95,7 +95,7 @@ type
public public
function GetTitle: String; override; function GetTitle: String; override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override; procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override; procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override; class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override; procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
end; end;
@ -149,7 +149,6 @@ begin
end; end;
constructor TEduNewPrgOptions.Create; constructor TEduNewPrgOptions.Create;
const le = LineEnding;
begin begin
inherited Create; inherited Create;
Name:='NewProgram'; Name:='NewProgram';

View File

@ -83,7 +83,7 @@ type
public public
function GetTitle: String; override; function GetTitle: String; override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override; procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override; procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override; class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override; procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
end; end;

View File

@ -56,7 +56,7 @@ type
procedure ShowAllButtonClick(Sender: TObject); procedure ShowAllButtonClick(Sender: TObject);
procedure ShowSelectionButtonClick(Sender: TObject); procedure ShowSelectionButtonClick(Sender: TObject);
procedure SpeedButtonsTreeViewMouseDown(Sender: TObject; procedure SpeedButtonsTreeViewMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer); Button: TMouseButton; {%H-}Shift: TShiftState; X, Y: Integer);
procedure FrameClick(Sender: TObject); procedure FrameClick(Sender: TObject);
private private
HideImgID: LongInt; HideImgID: LongInt;
@ -69,7 +69,7 @@ type
public public
function GetTitle: String; override; function GetTitle: String; override;
procedure ReadSettings(AOptions: TAbstractIDEOptions); override; procedure ReadSettings(AOptions: TAbstractIDEOptions); override;
procedure Setup(ADialog: TAbstractOptionsEditorDialog); override; procedure Setup({%H-}ADialog: TAbstractOptionsEditorDialog); override;
class function SupportedOptionsClass: TAbstractIDEOptionsClass; override; class function SupportedOptionsClass: TAbstractIDEOptionsClass; override;
procedure WriteSettings(AOptions: TAbstractIDEOptions); override; procedure WriteSettings(AOptions: TAbstractIDEOptions); override;
end; end;
@ -118,7 +118,7 @@ begin
if AValue then if AValue then
fVisible[ButtonName]:='1' fVisible[ButtonName]:='1'
else else
fVisible.Delete(ButtonName); fVisible.Remove(ButtonName);
end; end;
function TEduSpeedButtonsOptions.Load(Config: TConfigStorage): TModalResult; function TEduSpeedButtonsOptions.Load(Config: TConfigStorage): TModalResult;