MG: added close buttons and images to TNoteBook and close buttons to source editor

git-svn-id: trunk@1740 -
This commit is contained in:
lazarus 2002-06-08 17:16:02 +00:00
parent dcb1f3247f
commit ed57800398
12 changed files with 358 additions and 67 deletions

View File

@ -179,7 +179,6 @@ begin
TrimmedIdentifier:=GetIdentifier(Params.Identifier);
end;
end;
writeln('RRR ',TrimmedIdentifier,' ',Params.NewNode.DescAsString);
FullTopLvlName:=FullTopLvlName+TrimmedIdentifier;
Result:=ifrSuccess;
end;

View File

@ -139,9 +139,10 @@ type
xmlconfig:TXMLConfig;
// general options
fFindTextAtCursor:boolean;
fShowTabCloseButtons: boolean;
fSynEditOptions: TSynEditorOptions;
fUndoAfterSave:boolean;
fFindTextAtCursor:boolean;
fUseSyntaxHighlight:boolean;
fBlockIndent:integer;
fUndoLimit:integer;
@ -205,6 +206,8 @@ type
property SynEditOptions:TSynEditorOptions
read fSynEditOptions write fSynEditOptions
default SYNEDIT_DEFAULT_OPTIONS;
property ShowTabCloseButtons: boolean
read fShowTabCloseButtons write fShowTabCloseButtons;
property UndoAfterSave:boolean
read fUndoAfterSave write fUndoAfterSave default true;
property FindTextAtCursor:boolean
@ -294,11 +297,11 @@ type
DropFilesCheckBox:TCheckBox;
HalfPageScrollCheckBox:TCheckBox;
KeepCaretXCheckBox:TCheckBox;
NoSelectionCheckBox:TCheckBox;
PersistentCaretCheckBox:TCheckBox;
ScrollByOneLessCheckBox:TCheckBox;
ScrollPastEofCheckBox:TCheckBox;
ScrollPastEolCheckBox:TCheckBox;
ShowCloseBtnInNoteBookCheckBox:TCheckBox;
ShowScrollHintCheckBox:TCheckBox;
SmartTabsCheckBox:TCheckBox;
TabsToSpacesCheckBox:TCheckBox;
@ -972,6 +975,7 @@ begin
// set defaults
// General options
fShowTabCloseButtons:=true;
fBlockIndent:=2;
fUndoLimit:=32767;
fTabWidths:=8;
@ -1034,7 +1038,6 @@ begin
eoDropFiles:SynEditOptName:='DropFiles';
eoHalfPageScroll:SynEditOptName:='HalfPageScroll';
eoKeepCaretX:SynEditOptName:='KeepCaretX';
eoNoSelection:SynEditOptName:='NoSelection';
eoPersistentCaret:SynEditOptName:='PersistentCaret';
eoScrollByOneLess:SynEditOptName:='ScrollByOneLess';
eoScrollPastEof:SynEditOptName:='ScrollPastEof';
@ -1055,6 +1058,8 @@ begin
end;
end;
fShowTabCloseButtons:=
XMLConfig.GetValue('EditorOptions/General/Editor/ShowTabCloseButtons',true);
fUndoAfterSave:=
XMLConfig.GetValue('EditorOptions/General/Editor/UndoAfterSave',true);
fFindTextAtCursor:=
@ -1152,7 +1157,6 @@ begin
eoHalfPageScroll:SynEditOptName:='HalfPageScroll';
eoKeepCaretX:SynEditOptName:='KeepCaretX';
eoPersistentCaret:SynEditOptName:='PersistentCaret';
eoNoSelection:SynEditOptName:='NoSelection';
eoScrollByOneLess:SynEditOptName:='ScrollByOneLess';
eoScrollPastEof:SynEditOptName:='ScrollPastEof';
eoScrollPastEol:SynEditOptName:='ScrollPastEol';
@ -1169,6 +1173,8 @@ begin
end;
end;
XMLConfig.SetValue('EditorOptions/General/Editor/ShowTabCloseButtons'
,fShowTabCloseButtons);
XMLConfig.SetValue('EditorOptions/General/Editor/UndoAfterSave'
,fUndoAfterSave);
XMLConfig.SetValue('EditorOptions/General/Editor/FindTextAtCursor'
@ -2083,14 +2089,14 @@ begin
// general
SetOption(AltSetsColumnModeCheckBox,eoAltSetsColumnMode);
SetOption(AutoIndentCheckBox,eoAutoIndent);
//SetOption(BracketHighlightCheckBox,eoBracketHighlight);
// not for Preview: SetOption(BracketHighlightCheckBox,eoBracketHighlight);
SetOption(DoubleClickLineCheckBox,eoDoubleClickSelectsLine);
SetOption(DragDropEditingCheckBox,eoDragDropEditing);
SetOption(DropFilesCheckBox,eoDropFiles);
SetOption(HalfPageScrollCheckBox,eoHalfPageScroll);
SetOption(KeepCaretXCheckBox,eoKeepCaretX);
SetOption(PersistentCaretCheckBox,eoPersistentCaret);
//SetOption(NoSelectionCheckBox,eoNoSelection);
// not for Preview: SetOption(NoSelectionCheckBox,eoNoSelection);
SetOption(ScrollByOneLessCheckBox,eoScrollByOneLess);
SetOption(ScrollPastEoFCheckBox,eoScrollPastEoF);
SetOption(ScrollPastEoLCheckBox,eoScrollPastEoL);
@ -3068,6 +3074,7 @@ begin
// many, many checkboxes ...
// left side
AltSetsColumnModeCheckBox:=TCheckBox.Create(Self);
with AltSetsColumnModeCheckBox do begin
Name:='AltSetsColumnModeCheckBox';
@ -3167,25 +3174,11 @@ begin
Show;
end;
NoSelectionCheckBox:=TCheckBox.Create(Self);
with NoSelectionCheckBox do begin
Name:='NoSelectionCheckBox';
Parent:=EditorOptionsGroupBox;
Top:=KeepCaretXCheckBox.Top+KeepCaretXCheckBox.Height+5;
Left:=AltSetsColumnModeCheckBox.Left;
Width:=ChkBoxW;
Height:=AltSetsColumnModeCheckBox.Height;
Caption:='No Selection';
Checked:=eoNoSelection in EditorOpts.SynEditOptions;
OnClick:=@GeneralCheckBoxOnClick;
Show;
end;
PersistentCaretCheckBox:=TCheckBox.Create(Self);
with PersistentCaretCheckBox do begin
Name:='PersistentCaretCheckBox';
Parent:=EditorOptionsGroupBox;
Top:=NoSelectionCheckBox.Top+NoSelectionCheckBox.Height+5;
Top:=KeepCaretXCheckBox.Top+KeepCaretXCheckBox.Height+5;
Left:=AltSetsColumnModeCheckBox.Left;
Width:=ChkBoxW;
Height:=AltSetsColumnModeCheckBox.Height;
@ -3213,8 +3206,8 @@ begin
with ScrollPastEoFCheckBox do begin
Name:='ScrollPastEoFCheckBox';
Parent:=EditorOptionsGroupBox;
Top:=5;
Left:=AltSetsColumnModeCheckBox.Left+(MaxX div 2)+5;
Top:=ScrollByOneLessCheckBox.Top+ScrollByOneLessCheckBox.Height+5;
Left:=ScrollByOneLessCheckBox.Left;
Width:=ChkBoxW;
Height:=AltSetsColumnModeCheckBox.Height;
Caption:='Scroll Past End of File';
@ -3223,11 +3216,12 @@ begin
Show;
end;
// right side
ScrollPastEoLCheckBox:=TCheckBox.Create(Self);
with ScrollPastEoLCheckBox do begin
Name:='ScrollPastEoLCheckBox';
Parent:=EditorOptionsGroupBox;
Top:=ScrollPastEoFCheckBox.Top+ScrollPastEoFCheckBox.Height+5;
Left:=AltSetsColumnModeCheckBox.Left+(MaxX div 2)+5;
Left:=ScrollPastEoFCheckBox.Left;
Width:=ChkBoxW;
Height:=AltSetsColumnModeCheckBox.Height;
@ -3237,12 +3231,27 @@ begin
Show;
end;
ShowCloseBtnInNoteBookCheckBox:=TCheckBox.Create(Self);
with ShowCloseBtnInNoteBookCheckBox do begin
Name:='ShowCloseBtnInNoteBookCheckBox';
Parent:=EditorOptionsGroupBox;
Top:=ScrollPastEoLCheckBox.Top+ScrollPastEoLCheckBox.Height+5;
Left:=ScrollPastEoLCheckBox.Left;
Width:=ChkBoxW;
Height:=AltSetsColumnModeCheckBox.Height;
Caption:='Close buttons in notebook';
Checked:=EditorOpts.ShowTabCloseButtons;
OnClick:=@GeneralCheckBoxOnClick;
Show;
end;
ShowScrollHintCheckBox:=TCheckBox.Create(Self);
with ShowScrollHintCheckBox do begin
Name:='ShowScrollHintCheckBox';
Parent:=EditorOptionsGroupBox;
Top:=ScrollPastEoLCheckBox.Top+ScrollPastEoLCheckBox.Height+5;
Left:=ScrollPastEoLCheckBox.Left;
Top:=ShowCloseBtnInNoteBookCheckBox.Top
+ShowCloseBtnInNoteBookCheckBox.Height+5;
Left:=ShowCloseBtnInNoteBookCheckBox.Left;
Width:=ChkBoxW;
Height:=AltSetsColumnModeCheckBox.Height;
Caption:='Show Scroll Hint';
@ -3509,16 +3518,9 @@ begin
Height:=AltSetsColumnModeCheckBox.Height;
end;
with NoSelectionCheckBox do begin
Top:=KeepCaretXCheckBox.Top+KeepCaretXCheckBox.Height+5;
Left:=AltSetsColumnModeCheckBox.Left;
Width:=ChkBoxW;
Height:=AltSetsColumnModeCheckBox.Height;
end;
with PersistentCaretCheckBox do begin
Left:=AltSetsColumnModeCheckBox.Left;
Top:=NoSelectionCheckBox.Top+NoSelectionCheckBox.Height+5;
Top:=KeepCaretXCheckBox.Top+KeepCaretXCheckBox.Height+5;
Width:=ChkBoxW;
Height:=AltSetsColumnModeCheckBox.Height;
end;
@ -3531,22 +3533,30 @@ begin
end;
with ScrollPastEoFCheckBox do begin
Top:=ScrollByOneLessCheckBox.Top+ScrollByOneLessCheckBox.Height+5;
Left:=AltSetsColumnModeCheckBox.Left;
Width:=ChkBoxW;
Height:=AltSetsColumnModeCheckBox.Height;
end;
with ScrollPastEoLCheckBox do begin
Top:=5;
Left:=AltSetsColumnModeCheckBox.Left+(MaxX div 2)+5;
Width:=ChkBoxW;
Height:=AltSetsColumnModeCheckBox.Height;
end;
with ScrollPastEoLCheckBox do begin
Top:=ScrollPastEoFCheckBox.Top+ScrollPastEoFCheckBox.Height+5;
Left:=ScrollPastEoFCheckBox.Left;
with ShowCloseBtnInNoteBookCheckBox do begin
Top:=ScrollPastEoLCheckBox.Top+ScrollPastEoLCheckBox.Height+5;
Left:=ScrollPastEoLCheckBox.Left;
Width:=ChkBoxW;
Height:=AltSetsColumnModeCheckBox.Height;
end;
with ShowScrollHintCheckBox do begin
Top:=ScrollPastEoLCheckBox.Top+ScrollPastEoLCheckBox.Height+5;
Left:=ScrollPastEoLCheckBox.Left;
Top:=ShowCloseBtnInNoteBookCheckBox.Top
+ShowCloseBtnInNoteBookCheckBox.Height+5;
Left:=ShowCloseBtnInNoteBookCheckBox.Left;
Width:=ChkBoxW;
Height:=AltSetsColumnModeCheckBox.Height;
end;
@ -5077,16 +5087,13 @@ begin
Include(SynOptions,eoBracketHighlight)
else
Exclude(SynOptions,eoBracketHighlight);
if NoSelectionCheckBox.Checked then
Include(SynOptions,eoNoSelection)
else
Exclude(SynOptions,eoNoSelection);
PreviewEdits[1].Options:=SynOptions;
EditorOpts.SetSynEditSettings(PreviewEdits[1]);
PreviewEdits[1].Options:=SynOptions-[eoBracketHighlight]
+[eoNoCaret,eoNoSelection];
// general
EditorOpts.ShowTabCloseButtons:=ShowCloseBtnInNoteBookCheckBox.Checked;
EditorOpts.UndoAfterSave:=UndoAfterSaveCheckBox.Checked;
EditorOpts.FindTextAtCursor:=FindTextAtCursorCheckBox.Checked;
EditorOpts.UseSyntaxHighlight:=UseSyntaxHighlightCheckBox.Checked;

View File

@ -1803,9 +1803,17 @@ begin
end;
procedure TMainIDE.mnuCloseClicked(Sender : TObject);
var PageIndex: integer;
begin
if SourceNoteBook.NoteBook=nil then exit;
DoCloseEditorUnit(SourceNoteBook.NoteBook.PageIndex,true);
if Sender is TPage then begin
PageIndex:=SourceNoteBook.NoteBook.PageList.IndexOf(Sender);
if PageIndex<0 then
PageIndex:=SourceNoteBook.NoteBook.PageIndex;
end else begin
PageIndex:=SourceNoteBook.NoteBook.PageIndex;
end;
DoCloseEditorUnit(PageIndex,true);
end;
procedure TMainIDE.mnuCloseAllClicked(Sender : TObject);
@ -3559,7 +3567,7 @@ begin
AText:='Unit "'+ActiveUnitInfo.Unitname+'" has changed. Save?'
else
AText:='Source of page "'+
SourceNotebook.NoteBook.Pages[SourceNotebook.NoteBook.PageIndex]
SourceNotebook.NoteBook.Pages[PageIndex]
+'" has changed. Save?';
ACaption:='Source modified';
if Messagedlg(ACaption, AText, mtConfirmation, [mbYes, mbNo], 0)=mrYes then
@ -6408,6 +6416,9 @@ end.
{ =============================================================================
$Log$
Revision 1.307 2002/06/08 17:15:59 lazarus
MG: added close buttons and images to TNoteBook and close buttons to source editor
Revision 1.306 2002/06/04 15:17:17 lazarus
MG: improved TFont for XLFD font names

View File

@ -487,7 +487,6 @@ type
read FOnCreateBreakPoint write FOnCreateBreakPoint;
property OnDeleteBreakPoint: TOnCreateDeleteBreakPoint
read FOnDeleteBreakPoint write FOnDeleteBreakPoint;
end;
//=============================================================================
@ -1595,7 +1594,7 @@ begin
MarksImgList.Width:=11;
MarksImgList.Height:=11;
//load 10 bookmark images
// load 10 bookmark images
for I := 0 to 9 do Begin
Pixmap1:=TPixMap.Create;
Pixmap1.TransparentColor:=clBtnFace;
@ -2117,7 +2116,12 @@ Begin
Height := ClientHeight-Notebook.top;
Pages.Strings[0] := 'unit1';
PageIndex := 0; // Set it to the first page
if EditorOpts.ShowTabCloseButtons then
Options:=Options+[nboShowCloseButtons]
else
Options:=Options-[nboShowCloseButtons];
OnPageChanged := @NotebookPageChanged;
OnCloseTabClicked:=@CloseClicked;
{$IFDEF IDE_DEBUG}
writeln('[TSourceNotebook.CreateNotebook] E');
{$ENDIF}
@ -2761,7 +2765,8 @@ Begin
end;
Procedure TSourceNotebook.CloseFile(PageIndex:integer);
var TempEditor: TSourceEditor;
var
TempEditor: TSourceEditor;
Begin
{$IFDEF IDE_DEBUG}
writeln('TSourceNotebook.CloseFile A PageIndex=',PageIndex);
@ -2772,10 +2777,11 @@ Begin
TempEditor.Free;
if Notebook.Pages.Count>1 then begin
//writeln('TSourceNotebook.CloseFile B PageIndex=',PageIndex);
Notebook.Pages.Delete(PageIndex);
// switch to left PageIndex
if PageIndex>0 then
// if this is the current page, switch to left PageIndex
if (Notebook.PageIndex=PageIndex) and (PageIndex>0) then
Notebook.PageIndex:=PageIndex-1;
// delete the page
Notebook.Pages.Delete(PageIndex);
//writeln('TSourceNotebook.CloseFile C PageIndex=',PageIndex);
UpdateStatusBar;
end else begin
@ -3075,6 +3081,12 @@ Begin
end;
EditorOpts.KeyMap.AssignTo(FKeyStrokes);
if NoteBook<>nil then begin
if EditorOpts.ShowTabCloseButtons then
NoteBook.Options:=NoteBook.Options+[nboShowCloseButtons]
else
NoteBook.Options:=NoteBook.Options-[nboShowCloseButtons];
end;
end;
procedure TSourceNotebook.KeyDown(var Key : Word; Shift : TShiftState);

View File

@ -64,6 +64,8 @@ type
TPage = class(TWinControl)
private
FImageIndex: integer;
procedure SetImageIndex(const AValue: integer);
protected
procedure ReadState(Reader: TAbstractReader); override;
//procedure Paint; override;
@ -76,6 +78,7 @@ type
published
property Caption;
//property Height;
property ImageIndex: integer read FImageIndex write SetImageIndex default -1;
// property TabOrder; This property needs to be created in TWinControl
property Visible;
//property Width;
@ -110,11 +113,17 @@ type
{ TCustomNotebook }
{
@abstract(Base class for TNotebook and TTabbedNotebook.)
Introduced and (currently) maintained by Curtis White
Introduced by Curtis White
}
TNoteBookOption = (nboShowCloseButtons);
TNoteBookOptions = set of TNoteBookOption;
TCustomNotebook = class(TCustomControl)
private
fAccess: TStrings; // TNBPages
FImages: TImageList;
FOnCloseTabClicked: TNotifyEvent;
FOptions: TNoteBookOptions;
fPageIndex: Integer;
fPageList: TList; // List of TPage
//fMultiLine: boolean;
@ -129,6 +138,8 @@ type
function GetPageIndex: Integer;
//function InternalSetMultiLine(Value: boolean): boolean;
procedure SetActivePage(const Value: String);
procedure SetImages(const AValue: TImageList);
procedure SetOptions(const AValue: TNoteBookOptions);
//procedure SetMultiLine(Value: boolean);
procedure SetPageIndex(Value: Integer);
procedure SetPages(Value: TStrings);
@ -142,6 +153,7 @@ type
procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
procedure ReadState(Reader: TAbstractReader); override;
procedure ShowControl(AControl: TControl); override;
procedure UpdateTabProperties; virtual;
property ActivePage: String read GetActivePage write SetActivePage;
//property MultiLine: boolean read fMultiLine write SetMultiLine default false;
@ -156,7 +168,12 @@ type
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure DoCloseTabClicked(APage: TPage); virtual;
property Images: TImageList read FImages write SetImages;
property Name;
property OnCloseTabClicked: TNotifyEvent
read FOnCloseTabClicked write FOnCloseTabClicked;
property Options: TNoteBookOptions read FOptions write SetOptions;
end;
{ TNotebook }
@ -173,8 +190,11 @@ type
property Pages;
published
property ActivePage;
property Images;
property OnCloseTabClicked;
//property MultiLine;
property OnPageChanged;
property Options;
property PageIndex;
property PageList;
property ShowTabs;
@ -443,6 +463,9 @@ end.
{
$Log$
Revision 1.25 2002/06/08 17:16:02 lazarus
MG: added close buttons and images to TNoteBook and close buttons to source editor
Revision 1.24 2002/05/13 14:47:00 lazarus
MG: fixed client rectangles, TRadioGroup, RecreateWnd

View File

@ -662,6 +662,9 @@ function ClearXLFDHeight(const LongFontName: string): string;
function ClearXLFDPitch(const LongFontName: string): string;
function ClearXLFDStyle(const LongFontName: string): string;
function XPMToPPChar(const XPM: string): PPChar;
function LazResourceXPMToPPChar(const ResourceName: string): PPChar;
var
{ Stores information about the current screen }
ScreenInfo : TLMScreenInit;
@ -816,6 +819,9 @@ end.
{ =============================================================================
$Log$
Revision 1.34 2002/06/08 17:16:02 lazarus
MG: added close buttons and images to TNoteBook and close buttons to source editor
Revision 1.33 2002/06/05 12:33:57 lazarus
MG: fixed fonts in XLFD format and styles

View File

@ -72,13 +72,13 @@ begin
Msg.Child := TPage(fPageList[Index]);
Msg.fCompStyle := fNotebook.fCompStyle;
Msg.Str := S;
{$IFDEF NOTEBOOK_DEBUG}
writeln('[TNBPages.Put] A ',Index,' ',S);
{$ENDIF}
CNSendMessage(LM_SETTEXT, fNotebook, @Msg);
{$IFDEF NOTEBOOK_DEBUG}
writeln('[TNBPages.Put] B ');
{$ENDIF}
{$IFDEF NOTEBOOK_DEBUG}
writeln('[TNBPages.Put] A ',Index,' ',S);
{$ENDIF}
CNSendMessage(LM_SetLabel, fNotebook, @Msg);
{$IFDEF NOTEBOOK_DEBUG}
writeln('[TNBPages.Put] B ');
{$ENDIF}
end;
end;
@ -191,6 +191,7 @@ procedure TNBPages.Move(CurIndex, NewIndex: Integer);
//var
// theObject: TObject;
begin
// move TPage components
//fPageList.Move(CurIndex, NewIndex);
//theObject := fPageList[CurIndex];
//fPageList[CurIndex] := fPageList[NewIndex];
@ -273,6 +274,18 @@ begin
inherited Destroy;
end;
{------------------------------------------------------------------------------
method TCustomNotebook DoCloseTabClicked
Params: APage: TPage
Result: none
Called whenever the user closes the tab.
------------------------------------------------------------------------------}
procedure TCustomNotebook.DoCloseTabClicked(APage: TPage);
begin
if Assigned(OnCloseTabClicked) then OnCloseTabClicked(APage);
end;
{------------------------------------------------------------------------------
TCustomNotebook GetActivePage
------------------------------------------------------------------------------}
@ -298,6 +311,25 @@ begin
end;
end;
procedure TCustomNotebook.SetImages(const AValue: TImageList);
begin
if FImages=AValue then exit;
FImages:=AValue;
if (csLoading in ComponentState) then exit;
UpdateTabProperties;
end;
procedure TCustomNotebook.SetOptions(const AValue: TNoteBookOptions);
var ChangedOptions: TNoteBookOptions;
begin
if FOptions=AValue then exit;
ChangedOptions:=(FOptions-AValue)+(AValue-FOptions);
FOptions:=AValue;
if (csLoading in ComponentState) then exit;
if nboShowCloseButtons in ChangedOptions then
UpdateTabProperties;
end;
{------------------------------------------------------------------------------
TCustomNotebook SetPageIndex
------------------------------------------------------------------------------}
@ -401,7 +433,7 @@ begin
Msg.fCompStyle := fCompStyle;
Msg.TabPosition := @fTabPosition;
//InterfaceObject.IntCNSendMessage2(LM_SETTABPOSITION, Self, nil, @fTabPosition);
CNSendMessage(LM_SETTABPOSITION, Self, @Msg);
CNSendMessage(LM_SetTabPosition, Self, @Msg);
end;
end;
@ -462,6 +494,20 @@ begin
end;
end;
{------------------------------------------------------------------------------
method TCustomNotebook UpdateTabProperties
Params: none
Result: none
Tells the interface to update all tabs.
------------------------------------------------------------------------------}
procedure TCustomNotebook.UpdateTabProperties;
var i: integer;
begin
for i := 0 to PageCount - 1 do
CNSendMessage(LM_NB_UpdateTab, Page[i], nil);
end;
{------------------------------------------------------------------------------
TCustomNotebook Change
------------------------------------------------------------------------------}
@ -520,6 +566,9 @@ end;}
{ =============================================================================
$Log$
Revision 1.18 2002/06/08 17:16:02 lazarus
MG: added close buttons and images to TNoteBook and close buttons to source editor
Revision 1.17 2002/05/24 07:16:31 lazarus
MG: started mouse bugfix and completed Makefile.fpc

View File

@ -291,12 +291,13 @@ end;
------------------------------------------------------------------------------}
procedure TCustomImageList.Draw(Canvas: TCanvas; X, Y, Index: Integer; Enabled: Boolean);
var
aBitmap : TBitmap;
aBitmap : TBitmap;
begin
if (FCount = 0) or (Index >= FCount) then Exit;
aBitmap := TBitmap(FImageList[Index]);
Canvas.CopyRect(Rect(X, Y, X + FWidth, Y + FHeight), aBitmap.Canvas, Rect(0, 0, FWidth, FHeight));
Canvas.CopyRect(Rect(X, Y, X + FWidth, Y + FHeight), aBitmap.Canvas,
Rect(0, 0, FWidth, FHeight));
end;
{------------------------------------------------------------------------------
@ -329,8 +330,8 @@ end;
------------------------------------------------------------------------------}
Function TCustomImageList.GetCount : Integer;
begin
Result := FImageList.Count;
FCount := Result;
Result := FImageList.Count;
FCount := Result;
end;
@ -765,7 +766,8 @@ end;
Internal routine to move images on the internal image list.
------------------------------------------------------------------------------}
procedure TCustomImageList.ShiftImages(const Source: TCanvas; Start, Shift: Integer);
procedure TCustomImageList.ShiftImages(const Source: TCanvas;
Start, Shift: Integer);
var
FMoveBitmap: TBitmap;
begin
@ -837,6 +839,9 @@ end;
{
$Log$
Revision 1.11 2002/06/08 17:16:02 lazarus
MG: added close buttons and images to TNoteBook and close buttons to source editor
Revision 1.10 2002/05/10 06:05:52 lazarus
MG: changed license to LGPL

View File

@ -1,3 +1,4 @@
// included by extctrls.pp
{******************************************************************************
TPage
******************************************************************************
@ -29,6 +30,9 @@ end;
constructor TPage.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
fImageIndex:=-1;
{set the default height and width}
if (AOwner<>nil) and (AOwner is TControl) then begin
@ -49,6 +53,21 @@ begin
Caption := '';
end;
{------------------------------------------------------------------------------
method TPage SetImageIndex
Params: const AValue: integer
Result: none
Set the image index of the image shown in the tabs.
------------------------------------------------------------------------------}
procedure TPage.SetImageIndex(const AValue: integer);
begin
if FImageIndex=AValue then exit;
FImageIndex:=AValue;
if (csLoading in ComponentState) then exit;
CNSendMessage(LM_NB_UpdateTab, Self, nil);
end;
{------------------------------------------------------------------------------
TPage ReadState
------------------------------------------------------------------------------}
@ -102,8 +121,12 @@ begin
ARect:=GetClientRect;
end;
// included by extctrls.pp
{
$Log$
Revision 1.9 2002/06/08 17:16:02 lazarus
MG: added close buttons and images to TNoteBook and close buttons to source editor
Revision 1.8 2002/05/10 06:05:55 lazarus
MG: changed license to LGPL

View File

@ -1,3 +1,4 @@
// included by graphics.pp
{******************************************************************************
TPixmap
******************************************************************************
@ -16,6 +17,126 @@
*****************************************************************************
}
{-------------------------------------------------------------------------------
function XPMToPPChar
Params: const XPM: string
Result: PPChar
Converts the source of an XPM image file into an array of PChar.
The memory is allocated as one block, so freeing can simply be done via
FreeMem(TheResult). The data is just behind the array.
An XPM file can be included by a C source file, because it has a C syntax.
In the compiled program it is simply an array of PChar.
This function converts an XPM source file to the same array, by removing the
comments and the string constant symbols.
-------------------------------------------------------------------------------}
function XPMToPPChar(const XPM: string): PPChar;
var
TrimmedXPM: string;
SrcLen, SrcPos, DestPos, LineCount, CurLine, LineLen: integer;
LineStart: PChar;
begin
// trim all comments and symbols and extract only the xpm data between ""
SrcLen:=length(XPM);
SetLength(TrimmedXPM,SrcLen+1); // +1 because TrimmedXPM should be at least
// one byte
SrcPos:=1;
DestPos:=1;
LineCount:=1;
while (SrcPos<=SrcLen) do begin
case XPM[SrcPos] of
'/':
begin
if (SrcPos<SrcLen) and (XPM[SrcPos+1]='*') then begin
// this is a C comment
// -> skip comment
inc(SrcPos,2);
while (SrcPos<SrcLen) do begin
if (XPM[SrcPos]='*') and (XPM[SRcPos+1]='/') then begin
// comment end found
inc(SrcPos,2);
break;
end;
inc(SrcPos);
end;
end;
end;
'"':
begin
// start of a string constant
inc(SrcPos);
while (SrcPos<SrcLen) do begin
if XPM[SrcPos]='\' then
inc(SrcPos);
if (XPM[SrcPos]='"') and (XPM[SrcPos-1]<>'\') then begin
// string end found
inc(SrcPos);
break;
end;
// copy char
TrimmedXPM[DestPos]:=XPM[SrcPos];
inc(DestPos);
inc(SrcPos);
end;
end;
',':
begin
// new string constant
// -> add #0 char
inc(SrcPos);
TrimmedXPM[DestPos]:=#0;
inc(DestPos);
inc(LineCount);
end;
else
inc(SrcPos);
end;
end;
TrimmedXPM[DestPos]:=#0; // DestPos now contains the length of trimmed data
// create array of PChar + image data
GetMem(Result,SizeOf(PChar)*(LineCount+1)+DestPos);
// copy data
Move(TrimmedXPM[1],Result[LineCount+1],DestPos);
// calculate the array of PChar
LineStart:=@Result[LineCount+1];
for CurLine:=0 to LineCount-1 do begin
LineLen:=StrLen(LineStart)+1;
Result[CurLine]:=LineStart;
inc(LineStart,LineLen);
end;
Result[LineCount]:=nil; // mark the end of the array with a nil
end;
{-------------------------------------------------------------------------------
function LazResourceXPMToPPChar
Params: const ResourceName: string
Result: PPChar
Loads the source of an XPM image file from the LazarusResources into an array
of PChar.
See XPMToPPChar for more info.
-------------------------------------------------------------------------------}
function LazResourceXPMToPPChar(const ResourceName: string): PPChar;
var XPMSource: TLResource;
begin
XPMSource:=LazarusResources.Find(ResourceName);
if XPMSource.ValueType<>'XPM' then
raise Exception.Create('LazResourceXPMToPPChar: The resource "'
+ResourceName+'" is not of type XPM');
Result:=XPMToPPChar(XPMSource.Value);
end;
{ TPixmap }
procedure TPixmap.LoadFromLazarusResource(const ResName: String);
var
ms:TMemoryStream;
@ -144,9 +265,14 @@ begin
end;
end;
// included by graphics.pp
{ =============================================================================
$Log$
Revision 1.13 2002/06/08 17:16:02 lazarus
MG: added close buttons and images to TNoteBook and close buttons to source editor
Revision 1.12 2002/05/10 06:05:55 lazarus
MG: changed license to LGPL

View File

@ -55,6 +55,23 @@ end;
{ callback routines }
{*************************************************************}
{-------------------------------------------------------------------------------
function gtkNoteBookCloseBtnClicked
Params: Widget: PGtkWidget; Data: Pointer
Result: GBoolean
gtkNoteBookCloseBtnClicked is called by the gtk, whenever a close button in
the tab of notebook page is clicked.
-------------------------------------------------------------------------------}
function gtkNoteBookCloseBtnClicked(Widget: PGtkWidget;
Data: Pointer): GBoolean; cdecl;
var APage: TPage;
begin
APage:=TPage(Data);
TCustomNoteBook(APage.Parent).DoCloseTabClicked(APage);
Result:=true; // handled = true
end;
{-------------------------------------------------------------------------------
function GTKRealizeCB
Params: Widget: PGtkWidget; Data: Pointer
@ -2038,6 +2055,9 @@ end;
{ =============================================================================
$Log$
Revision 1.81 2002/06/08 17:16:02 lazarus
MG: added close buttons and images to TNoteBook and close buttons to source editor
Revision 1.80 2002/06/06 14:41:29 lazarus
MG: if completion form visible it will now get all synedit keys

View File

@ -36,7 +36,7 @@ const
//-------------
// Commands SENT TO the interface units
// add also a description to a message at the end of this unit
// here are no defines of messages send to the interface
// here are no defines of message records sent to the interface
// These are declared in a later section
//-------------
LM_ComUser = $1000;
@ -134,6 +134,10 @@ const
LM_CB_GETTEXT = LM_CB_FIRST+2;
LM_CB_ADDTEXT = LM_CB_FIRST+3;
LM_CB_LAST = LM_CB_FIRST+9; // LM_COMUSER+99
// additional for TNoteBook
LM_NB_UpdateTab = LM_CB_LAST+1;
LM_NB_Last = LM_NB_UpdateTab;
//-------------
//end of messages that are sent to the interface
@ -823,6 +827,9 @@ begin
LM_BRINGTOFRONT : Result :='LM_BRINGTOFRONT ';
LM_CB_GETCOUNT : Result :='LM_CB_GETCOUNT ';
LM_SETSHORTCUT : Result := 'LM_SETSHORTCUT';
// additional for TNoteBook
LM_NB_UpdateTab : Result := 'LM_NB_UpdateTab';
else
Result := Format('Unknown message 0x%x (%d)', [AMessage, AMessage]);
end;
@ -835,6 +842,9 @@ end.
{
$Log$
Revision 1.26 2002/06/08 17:16:02 lazarus
MG: added close buttons and images to TNoteBook and close buttons to source editor
Revision 1.25 2002/05/10 06:05:50 lazarus
MG: changed license to LGPL