diff options
author | Jed Barber <jjbarber@y7mail.com> | 2016-11-09 11:32:47 +1100 |
---|---|---|
committer | Jed Barber <jjbarber@y7mail.com> | 2016-11-09 11:36:51 +1100 |
commit | 1f35137574691335d63e86bf5d2b2366fc91c1ba (patch) | |
tree | 9ef15ab20157b5c10c92819d6a1694287219e1e1 /src/windows-editor.adb | |
parent | 87063e50bfb3dd69d0806897d5b0d97b7d48f92a (diff) |
Moved code for each window into its own package
Diffstat (limited to 'src/windows-editor.adb')
-rw-r--r-- | src/windows-editor.adb | 172 |
1 files changed, 172 insertions, 0 deletions
diff --git a/src/windows-editor.adb b/src/windows-editor.adb new file mode 100644 index 0000000..7f303fe --- /dev/null +++ b/src/windows-editor.adb @@ -0,0 +1,172 @@ + + +with FLTK.Enums; use FLTK.Enums; +with FLTK.Widgets.Groups.Windows.Double; +with FLTK.Widgets.Groups.Text_Displays.Text_Editors; +with FLTK.Widgets.Menus; +with FLTK.Widgets.Menus.Menu_Bars; +with FLTK.Text_Buffers; + + +package body Windows.Editor is + + + package WD renames FLTK.Widgets.Groups.Windows.Double; + package TE renames FLTK.Widgets.Groups.Text_Displays.Text_Editors; + package MB renames FLTK.Widgets.Menus.Menu_Bars; + + + + + function Create + (X, Y, W, H : in Integer; + Label_Text : in String) + return Editor_Window + is + Width : Integer := Min_Editor_Width; + Height : Integer := Min_Editor_Height; + Menu_Height : Integer := 22; + begin + if Width < W then + Width := W; + end if; + + if Height < H then + Height := H; + end if; + + return This : Editor_Window := + (WD.Double_Window'(WD.Create (X, Y, Width, Height, Label_Text)) with + + Editor => TE.Text_Editor'(TE.Create + (0, Menu_Height, Width, Height - Menu_Height, "")), + Bar => MB.Menu_Bar'(MB.Create + (0, 0, Width, Menu_Height, ""))) do + + This.Add (This.Editor); + This.Add (This.Bar); + This.Bar.Set_Box (No_Box); + This.Editor.Set_Text_Font (Courier); + This.Set_Resizable (This.Editor); + This.Set_Size_Range (Min_Editor_Width, Min_Editor_Height); + This.Set_Icon (Logo); + end return; + end Create; + + + + + function Create + (W, H : in Integer) + return Editor_Window is + begin + return Create (0, 0, W, H, "(Untitled)"); + end Create; + + + + + function Get_Buffer + (This : in Editor_Window) + return FLTK.Text_Buffers.Text_Buffer_Cursor is + begin + return This.Editor.Get_Buffer; + end Get_Buffer; + + + + + procedure Set_Buffer + (This : in out Editor_Window; + Buff : in out FLTK.Text_Buffers.Text_Buffer) is + begin + This.Editor.Set_Buffer (Buff); + end Set_Buffer; + + + + + function Get_Menu + (This : in out Editor_Window) + return FLTK.Widgets.Menus.Menu_Cursor is + begin + return Ref : FLTK.Widgets.Menus.Menu_Cursor (This.Bar'Access); + end Get_Menu; + + + + + procedure Undo + (This : in out Editor_Window) is + begin + This.Editor.Undo; + end Undo; + + + + + procedure Cut + (This : in out Editor_Window) is + begin + This.Editor.Cut; + end Cut; + + + + + procedure Copy + (This : in out Editor_Window) is + begin + This.Editor.Copy; + end Copy; + + + + + procedure Paste + (This : in out Editor_Window) is + begin + This.Editor.Paste; + end Paste; + + + + + procedure Delete + (This : in out Editor_Window) is + begin + This.Editor.Delete; + end Delete; + + + + + function Get_Insert_Position + (This : in Editor_Window) + return Natural is + begin + return This.Editor.Get_Insert_Position; + end Get_Insert_Position; + + + + + procedure Set_Insert_Position + (This : in out Editor_Window; + Pos : in Natural) is + begin + This.Editor.Set_Insert_Position (Pos); + end Set_Insert_Position; + + + + + procedure Show_Insert_Position + (This : in out Editor_Window) is + begin + This.Editor.Show_Insert_Position; + end Show_Insert_Position; + + +end Windows.Editor; + |