diff options
Diffstat (limited to 'src/adapad.adb')
-rw-r--r-- | src/adapad.adb | 36 |
1 files changed, 30 insertions, 6 deletions
diff --git a/src/adapad.adb b/src/adapad.adb index 48ca844..d1f895f 100644 --- a/src/adapad.adb +++ b/src/adapad.adb @@ -11,6 +11,8 @@ with FLTK.Widgets.Menus; use FLTK.Widgets.Menus; with FLTK.Popups; use FLTK.Popups; +with FLTK.Widgets.Groups.Windows; +use FLTK.Widgets.Groups.Windows; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; @@ -29,16 +31,20 @@ function AdaPad return Integer is procedure Do_Save_As; procedure Load_File (Name : in String); procedure Save_File (Name : in String); + procedure Centre (Win : in out Window'Class); -- global state of the text editor - Editor : aliased Editor_Window := Create (0, 0, 640, 400, "(Untitled)"); - Buffer : aliased Text_Buffer := Create; + Editor : Editor_Window := Create (0, 0, 640, 400, "(Untitled)"); + Buffer : Text_Buffer := Create; + About : About_Window := Create (250, 200); + Find : Find_Window := Create (200, 100); + Replace : Replace_Window := Create (200, 100); - Changed : Boolean := False; + Changed : Boolean := False; Filename : Unbounded_String := To_Unbounded_String (0); @@ -118,6 +124,7 @@ function AdaPad return Integer is Item : in out Widget'Class) is begin if not Safe_To_Discard then return; end if; + About.Hide; Editor.Hide; end Call; @@ -209,7 +216,9 @@ function AdaPad return Integer is (This : in Find_Callback; Item : in out Widget'Class) is begin - Ada.Text_IO.Put_Line ("Find callback executed."); + Centre (Find); + Find.Reset; + Find.Show; end Call; @@ -222,7 +231,9 @@ function AdaPad return Integer is (This : in Replace_Callback; Item : in out Widget'Class) is begin - Ada.Text_IO.Put_Line ("Replace callback executed."); + Centre (Replace); + Replace.Reset; + Replace.Show; end Call; @@ -235,7 +246,8 @@ function AdaPad return Integer is (This : in About_Callback; Item : in out Widget'Class) is begin - Ada.Text_IO.Put_Line ("About callback executed."); + Centre (About); + About.Show; end Call; @@ -353,6 +365,18 @@ function AdaPad return Integer is end Save_File; + + + procedure Centre (Win : in out Window'Class) is + Middle_X : Integer := Editor.Get_X + Editor.Get_W / 2; + Middle_Y : Integer := Editor.Get_Y + Editor.Get_H / 2; + begin + Win.Reposition + (Middle_X - Win.Get_W / 2, + Middle_Y - Win.Get_H / 2); + end Centre; + + begin |