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