mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-07-22 16:27:20 +02:00
MG: TMenuItems can now be enabled and disabled
git-svn-id: trunk@1820 -
This commit is contained in:
parent
f8643dd008
commit
b86e90e0b7
15
ide/main.pp
15
ide/main.pp
@ -1267,7 +1267,6 @@ begin
|
||||
itmFileQuit.Caption := lisMenuQuit;
|
||||
itmFileQuit.OnClick := @mnuQuitClicked;
|
||||
mnuFile.Add(itmFileQuit);
|
||||
|
||||
end;
|
||||
|
||||
procedure TMainIDE.SetupEditMenu;
|
||||
@ -1355,19 +1354,16 @@ begin
|
||||
itmSearchFindNext := TMenuItem.Create(Self);
|
||||
itmSearchFindNext.Name:='itmSearchFindNext';
|
||||
itmSearchFindNext.Caption := lisMenuFindNext;
|
||||
itmSearchFindNext.Enabled := False;
|
||||
mnuSearch.add(itmSearchFindNext);
|
||||
|
||||
itmSearchFindPrevious := TMenuItem.Create(Self);
|
||||
itmSearchFindPrevious.Name:='itmSearchFindPrevious';
|
||||
itmSearchFindPrevious.Caption := lisMenuFindPrevious;
|
||||
itmSearchFindPrevious.Enabled := False;
|
||||
mnuSearch.add(itmSearchFindPrevious);
|
||||
|
||||
itmSearchFindInFiles := TMenuItem.Create(Self);
|
||||
itmSearchFindInFiles.Name:='itmSearchFindInFiles';
|
||||
itmSearchFindInFiles.Caption := lisMenuFindInFiles;
|
||||
itmSearchFindInFiles.Enabled := False;
|
||||
mnuSearch.add(itmSearchFindInFiles);
|
||||
|
||||
itmSearchReplace := TMenuItem.Create(Self);
|
||||
@ -3542,6 +3538,8 @@ begin
|
||||
AFilename,-1),AnUnitInfo.Source);
|
||||
NewSrcEdit:=SourceNotebook.GetActiveSE;
|
||||
NewSrcEditorCreated:=true;
|
||||
itmFileClose.Enabled:=True;
|
||||
itmFileCloseAll.Enabled:=True;
|
||||
end else begin
|
||||
// revert code in existing source editor
|
||||
NewSrcEdit:=SourceNotebook.FindSourceEditorWithPageIndex(PageIndex);
|
||||
@ -3620,6 +3618,8 @@ begin
|
||||
SourceNotebook.NewFile(CreateSrcEditPageName(NewUnitInfo.UnitName,
|
||||
NewUnitInfo.Filename,-1),
|
||||
NewUnitInfo.Source);
|
||||
itmFileClose.Enabled:=True;
|
||||
itmFileCloseAll.Enabled:=True;
|
||||
NewSrcEdit:=SourceNotebook.GetActiveSE;
|
||||
NewSrcEdit.SyntaxHighlighterType:=NewUnitInfo.SyntaxHighlighter;
|
||||
Project1.InsertEditorIndex(SourceNotebook.NoteBook.PageIndex);
|
||||
@ -3802,7 +3802,9 @@ begin
|
||||
|
||||
// close source editor
|
||||
SourceNoteBook.CloseFile(PageIndex);
|
||||
|
||||
itmFileClose.Enabled:=SourceNoteBook.NoteBook<>nil;
|
||||
itmFileCloseAll.Enabled:=itmFileClose.Enabled;
|
||||
|
||||
// close file in project
|
||||
Project1.CloseEditorIndex(ActiveUnitInfo.EditorIndex);
|
||||
ActiveUnitInfo.Loaded:=false;
|
||||
@ -6856,6 +6858,9 @@ end.
|
||||
|
||||
{ =============================================================================
|
||||
$Log$
|
||||
Revision 1.335 2002/08/05 08:56:54 lazarus
|
||||
MG: TMenuItems can now be enabled and disabled
|
||||
|
||||
Revision 1.334 2002/08/03 14:30:37 lazarus
|
||||
MG: added file access monitoring and diff view
|
||||
|
||||
|
@ -309,14 +309,13 @@ end;
|
||||
|
||||
------------------------------------------------------------------------------}
|
||||
Procedure TMenuItem.MenuChanged(Rebuild : Boolean);
|
||||
Begin
|
||||
//Use send message to re-create the menu if REBUILD is true.
|
||||
//send a message to inform the interface that we need to destroy and recreate this control
|
||||
if not HandleAllocated then Exit;
|
||||
if FHandle <> 0 then
|
||||
Begin
|
||||
// InterfaceObject.IntSendMessage3(LM_RECREATEWND, Self, nil);
|
||||
end;
|
||||
var
|
||||
Source: TMenuItem;
|
||||
begin
|
||||
if (Parent = nil) and (Owner is TMenu) then
|
||||
Source := nil else
|
||||
Source := Self;
|
||||
if Assigned(FOnChange) then FOnChange(Self, Source, Rebuild);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -378,15 +377,13 @@ end;
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TMenuItem.SetEnabled(Value: Boolean);
|
||||
begin
|
||||
if FEnabled <> Value
|
||||
then begin
|
||||
FEnabled := Value;
|
||||
// TODO, finish with correct params
|
||||
// if HandleAllocated and (Parent <> nil)
|
||||
// then EnableMenuItem(Parent.Handle, )
|
||||
if FEnabled <> Value
|
||||
then begin
|
||||
FEnabled := Value;
|
||||
if HandleAllocated and (Parent <> nil) then
|
||||
EnableMenuItem(Handle, FCommand, FEnabled);
|
||||
MenuChanged(False);
|
||||
end;
|
||||
|
||||
//TODO: Add runtime code here
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -492,6 +489,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.15 2002/08/05 08:56:56 lazarus
|
||||
MG: TMenuItems can now be enabled and disabled
|
||||
|
||||
Revision 1.14 2002/05/30 21:33:10 lazarus
|
||||
+ added / fixed streaming functions for TMenu & TMenuItem, stoppok
|
||||
|
||||
@ -562,6 +562,9 @@ end;
|
||||
|
||||
|
||||
$Log$
|
||||
Revision 1.15 2002/08/05 08:56:56 lazarus
|
||||
MG: TMenuItems can now be enabled and disabled
|
||||
|
||||
Revision 1.14 2002/05/30 21:33:10 lazarus
|
||||
+ added / fixed streaming functions for TMenu & TMenuItem, stoppok
|
||||
|
||||
|
@ -1831,8 +1831,9 @@ end;
|
||||
function TGTKObject.EnableMenuItem(hMenu: HMENU; uIDEnableItem: Integer;
|
||||
bEnable: Boolean): Boolean;
|
||||
begin
|
||||
// Your code here
|
||||
Result:=false;
|
||||
if hMenu <> 0
|
||||
then gtk_widget_set_sensitive(pgtkwidget(hMenu), bEnable);
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -1861,7 +1862,7 @@ begin
|
||||
Assert(False, Format('Trace: [TGTKObject.EnableWindow] hWnd: 0x%x, Enable: %s', [hwnd, BOOL_TEXT[bEnable]]));
|
||||
if hWnd <> 0
|
||||
then gtk_widget_set_sensitive(pgtkwidget(hWnd), bEnable);
|
||||
Result:=false;
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -4825,6 +4826,9 @@ end;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.85 2002/08/05 08:56:57 lazarus
|
||||
MG: TMenuItems can now be enabled and disabled
|
||||
|
||||
Revision 1.84 2002/08/05 07:43:29 lazarus
|
||||
MG: fixed BadCursor bug and Circle Reference of FixedWidget of csPanel
|
||||
|
||||
|
27
lcl/menus.pp
27
lcl/menus.pp
@ -53,14 +53,17 @@ type
|
||||
|
||||
TMenu = class;
|
||||
EMenuError = class(Exception);
|
||||
|
||||
// fix for compiler problem
|
||||
|
||||
TMenuItem = class;
|
||||
|
||||
TMenuChangeEvent = procedure (Sender: TObject; Source: TMenuItem;
|
||||
Rebuild: Boolean) of object;
|
||||
|
||||
TMenuItem = class(TComponent)//TWinControl)
|
||||
private
|
||||
FCaption: string;
|
||||
FChecked: Boolean;
|
||||
FCommand: integer;
|
||||
FDefault: Boolean;
|
||||
FEnabled: Boolean;
|
||||
FHandle: HMenu;
|
||||
@ -71,6 +74,7 @@ type
|
||||
FParent: TMenuItem;
|
||||
FShortCut: TShortCut;
|
||||
FVisible: Boolean;
|
||||
FOnChange: TMenuChangeEvent;
|
||||
FOnClick: TNotifyEvent;
|
||||
function GetCount: Integer;
|
||||
function GetItem(Index: Integer): TMenuItem;
|
||||
@ -178,10 +182,24 @@ type
|
||||
function ShortCut(const Key: Word; const Shift : TShiftState) : TShortCut;
|
||||
procedure ShortCuttoKey(const ShortCut : TShortCut; var Key: Word; var Shift : TShiftState);
|
||||
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
Interfaces;
|
||||
Interfaces, LCLLinux;
|
||||
|
||||
{ Menu command managment }
|
||||
|
||||
var
|
||||
CommandPool: TBits;
|
||||
|
||||
function UniqueCommand: Word;
|
||||
begin
|
||||
Result := CommandPool.OpenBit;
|
||||
CommandPool[Result] := True;
|
||||
end;
|
||||
|
||||
|
||||
{$I menubar.inc}
|
||||
{$I menu.inc}
|
||||
@ -215,6 +233,9 @@ end.
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.14 2002/08/05 08:56:56 lazarus
|
||||
MG: TMenuItems can now be enabled and disabled
|
||||
|
||||
Revision 1.13 2002/05/30 21:33:10 lazarus
|
||||
+ added / fixed streaming functions for TMenu & TMenuItem, stoppok
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user