diff options
Diffstat (limited to 'src/windows-replace.adb')
-rw-r--r-- | src/windows-replace.adb | 143 |
1 files changed, 143 insertions, 0 deletions
diff --git a/src/windows-replace.adb b/src/windows-replace.adb new file mode 100644 index 0000000..5db325a --- /dev/null +++ b/src/windows-replace.adb @@ -0,0 +1,143 @@ + + +with FLTK.Widgets; +with FLTK.Widgets.Groups.Windows.Double; +with FLTK.Widgets.Inputs; +with FLTK.Widgets.Buttons; +with FLTK.Widgets.Buttons.Enter; +with FLTK.Widgets.Buttons.Light.Check; + + +package body Windows.Replace is + + + package W renames FLTK.Widgets; + package WD renames FLTK.Widgets.Groups.Windows.Double; + package IP renames FLTK.Widgets.Inputs; + package BU renames FLTK.Widgets.Buttons; + package EN renames FLTK.Widgets.Buttons.Enter; + package LC renames FLTK.Widgets.Buttons.Light.Check; + + + + + Replace_M : aliased Replace_Marshaller; + + overriding procedure Call + (This : in Replace_Marshaller; + Item : in out W.Widget'Class) + is + use type BU.State; + type Replace_Window_Access is access all Replace_Window; + Dialog : access Replace_Window := Replace_Window_Access (Item.Parent); + begin + if Dialog.Callback /= null then + Dialog.Callback.Call + (Dialog.Find_What.Get_Value, + Dialog.Replace_With.Get_Value, + Dialog.Match_Case.Get_State = BU.On, + Dialog.Replace_All.Get_State = BU.On); + end if; + end Call; + + + + + function Create + return Replace_Window + is + My_Width : Integer := 350; + My_Height : Integer := 180; + + Button_Width : Integer := 140; + Button_Height : Integer := 40; + + Find_Line : Integer := 10; + Replace_Line : Integer := 40; + Match_Line : Integer := 80; + Rep_All_Line : Integer := 100; + Button_Line : Integer := 130; + + Input_Width : Integer := 220; + Input_Height : Integer := 25; + Input_Margin_Right : Integer := 10; + + Check_Width : Integer := 100; + Check_Height : Integer := 20; + Check_Margin_Left : Integer := 50; + + Text_Size : Integer := 12; + begin + return This : Replace_Window := + (WD.Double_Window'(WD.Create (0, 0, My_Width, My_Height, "Replace")) with + + Find_What => IP.Input'(IP.Create + (My_Width - Input_Width - Input_Margin_Right, + Find_Line, Input_Width, Input_Height, "Find what:")), + Replace_With => IP.Input'(IP.Create + (My_Width - Input_Width - Input_Margin_Right, + Replace_Line, Input_Width, Input_Height, "Replace with:")), + Match_Case => LC.Check_Button'(LC.Create + (Check_Margin_Left, Match_Line, + Check_Width, Check_Height, "Match case")), + Replace_All => LC.Check_Button'(LC.Create + (Check_Margin_Left, Rep_All_Line, + Check_Width, Check_Height, "Replace all")), + Cancel => BU.Button'(BU.Create + ((My_Width - 2 * Button_Width) / 3, + Button_Line, Button_Width, Button_Height, "Cancel")), + Start => EN.Enter_Button'(EN.Create + ((My_Width - 2 * Button_Width) * 2 / 3 + Button_Width, + Button_Line, Button_Width, Button_Height, "Replace")), + + Callback => null) do + + This.Add (This.Find_What); + This.Add (This.Replace_With); + This.Add (This.Match_Case); + This.Add (This.Replace_All); + This.Add (This.Cancel); + This.Cancel.Set_Callback (Hide_CB'Access); + This.Add (This.Start); + This.Start.Set_Callback (Replace_M'Access); + + This.Set_Callback (Hide_CB'Access); + This.Set_Icon (Logo); + This.Set_Modal; + end return; + end Create; + + + + + function Create + (X, Y, W, H : in Integer; + Label_Text : in String) + return Replace_Window is + begin + return Create; + end Create; + + + + + function Create + (W, H : in Integer) + return Replace_Window is + begin + return Create; + end Create; + + + + + procedure Set_Replace_Callback + (This : in out Replace_Window; + Func : not null access Replace_Callback'Class) is + begin + This.Callback := Func; + end Set_Replace_Callback; + + +end Windows.Replace; + |