Skip to content

Commit

Permalink
Add close snippet panel option to the menu
Browse files Browse the repository at this point in the history
Signed-off-by: Thimo Braker <[email protected]>
  • Loading branch information
LauraRozier committed Apr 23, 2017
1 parent d220363 commit bdb987a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
1 change: 1 addition & 0 deletions Map_Script_Snippets.dproj
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
<DCC_MapFile>3</DCC_MapFile>
<DCC_DebugInformation>2</DCC_DebugInformation>
<DCC_LocalDebugSymbols>true</DCC_LocalDebugSymbols>
<DCC_Define>madExcept;$(DCC_Define)</DCC_Define>
</PropertyGroup>
<ItemGroup>
<DelphiCompile Include="$(MainSource)">
Expand Down
30 changes: 16 additions & 14 deletions src/MSS_Main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ TMSS_Main = class(TNppBasePlugin)
constructor Create;
destructor Destroy; override;
procedure DoNppnStartedUp; override;
procedure DoNppnToolbarModification; override;
procedure InitNpp;
procedure ShowAbout;
procedure ShowSnippetForm;
procedure CloseSnippetForm;
procedure ShowAbout;
end;

implementation
Expand All @@ -56,13 +56,15 @@ implementation
{ TMSS_Main }
constructor TMSS_Main.Create;
resourcestring
sSnipPanel = 'Show Snippet panel';
sAbout = 'About';
sShowSnipPanel = 'Show Snippet panel';
sCloseSnipPanel = 'Close Snippet panel';
sAbout = 'About';
begin
inherited;
PluginName := 'Map Script Snippets';

AddFuncItem(sSnipPanel, _CFuncShowSnippetForm);
AddFuncItem(sShowSnipPanel, _CFuncShowSnippetForm);
AddFuncItem(sCloseSnipPanel, _CFuncCloseSnippetForm);
AddFuncItem('-', nil);
AddFuncItem(sAbout, _CFuncShowAbout);
end;
Expand All @@ -85,15 +87,6 @@ procedure TMSS_Main.DoNppnStartedUp;
ShowSnippetForm
end;

procedure TMSS_Main.DoNppnToolbarModification;
var
tb: TToolbarIcons;
begin
tb.ToolbarIcon := 0;
tb.ToolbarBmp := LoadImage(hInstance, 'IDB_TB_ICON', IMAGE_BITMAP, 0, 0, (LR_DEFAULTSIZE or LR_LOADMAP3DCOLORS));
SendMessage(self.NppData.NppHandle, NPPM_ADDTOOLBARICON, WPARAM(CmdIdFromDlgId(1)), LPARAM(@tb));
end;

procedure TMSS_Main.ShowAbout;
begin
if (not Assigned(GAboutFrm)) then
Expand All @@ -111,6 +104,15 @@ procedure TMSS_Main.ShowSnippetForm;
GSnippetForm.Show;
end;

procedure TMSS_Main.CloseSnippetForm;
begin
if Assigned(GSnippetForm) then
begin
GSnippetForm.Hide;
FreeAndNil(GSnippetForm);
end;
end;

initialization
FNPPPlugin := TMSS_Main.Create as TNppBasePlugin;

Expand Down
6 changes: 6 additions & 0 deletions src/MSS_PluginCInterface.pas
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

interface
procedure _CFuncShowSnippetForm; cdecl;
procedure _CFuncCloseSnippetForm; cdecl;
procedure _CFuncShowAbout; cdecl;

implementation
Expand All @@ -34,6 +35,11 @@ procedure _CFuncShowSnippetForm; cdecl;
(FNPPPlugin as TMSS_Main).ShowSnippetForm;
end;

procedure _CFuncCloseSnippetForm; cdecl;
begin
(FNPPPlugin as TMSS_Main).CloseSnippetForm;
end;

procedure _CFuncShowAbout; cdecl;
begin
(FNPPPlugin as TMSS_Main).ShowAbout;
Expand Down

0 comments on commit bdb987a

Please sign in to comment.