diff options
Diffstat (limited to 'src/editor_windows.adb')
-rw-r--r-- | src/editor_windows.adb | 48 |
1 files changed, 40 insertions, 8 deletions
diff --git a/src/editor_windows.adb b/src/editor_windows.adb index 4fdf2ae..64b1cf0 100644 --- a/src/editor_windows.adb +++ b/src/editor_windows.adb @@ -21,8 +21,17 @@ package body Editor_Windows is Width, Height : Integer; begin - if W < 300 then Width := 300; else Width := W; end if; - if H < 60 then Height := 60; else Height := H; end if; + if W < Min_Editor_Width then + Width := Min_Editor_Width; + else + Width := W; + end if; + + if H < Min_Editor_Height then + Height := Min_Editor_Height; + else + Height := H; + end if; return This : Editor_Window := (Double_Window'(Create (X, Y, Width, Height, Label_Text)) with @@ -31,6 +40,8 @@ package body Editor_Windows is This.Add (This.Editor); This.Add (This.Bar); This.Editor.Set_Text_Font (Courier); + This.Set_Resizable (This.Editor); + This.Set_Size_Range (Min_Editor_Width, Min_Editor_Height); end return; end Create; @@ -131,8 +142,18 @@ package body Editor_Windows is (This : in Hide_Callback; Item : in out Widget'Class) is begin + -- + -- this is an ugly hack + -- + -- it only works because the Item will either be the About/Find/Replace window + -- directly or it'll be a close/cancel button in said window + -- + -- need to figure out how to properly loop up via Widget Parent method + -- if Item in Window'Class then Window (Item).Hide; + else + Window (Item.Parent.Data.all).Hide; end if; end Call; @@ -146,19 +167,30 @@ package body Editor_Windows is Label_Text : in String) return About_Window is - Heading_Text : String := "AdaPad 0.9"; + Heading_Text : String := "Adapad 0.5"; Blurb_Text : String := "FLTK based simple text editor written in Ada"; - Author_Text : String := "Written by Jed Barber"; + Author_Text : String := "Programmed by Jed Barber"; begin return This : About_Window := (Double_Window'(Create (X, Y, W, H, Label_Text)) with - Heading => Box'(Create (0, Y * 7 / 16, W, H / 8, Heading_Text)), - Blurb => Box'(Create (0, Y * 10 / 16, W, H / 8, Blurb_Text)), - Author => Box'(Create (0, Y * 12 / 16, W, H / 8, Author_Text))) do + + -- this layout could use fewer magic numbers + Heading => Box'(Create + (0, Integer (Float (H) * 0.36), W, 22, Heading_Text)), + Blurb => Box'(Create + (0, Integer (Float (H) * 0.53), W, 12, Blurb_Text)), + Author => Box'(Create + (0, Integer (Float (H) * 0.63), W, 12, Author_Text)), + Dismiss => Enter_Button'(Create + (W / 2 - 50, Integer (Float (H) * 0.76), 100, 40, "Close"))) do + This.Add (This.Heading); + This.Heading.Set_Label_Size (22); This.Add (This.Blurb); This.Add (This.Author); + This.Add (This.Dismiss); + This.Dismiss.Set_Callback (Hide_CB'Access); This.Set_Callback (Hide_CB'Access); end return; end Create; @@ -170,7 +202,7 @@ package body Editor_Windows is (W, H : in Integer) return About_Window is begin - return Create (0, 0, W, H, "About AdaPad"); + return Create (0, 0, W, H, "About Adapad"); end Create; |