So an update.  I have two different implementations.  They each have pros
and cons and wanted to get feedback on which one would be better to
submit.  I can submit both if desired

Version 1:
I publicly extend Dialog_Type from View_Base_Type and privately extend it
from View_Type.
Pros:  Dialog_Type can be easily used with other Gnoga API calls and
Components can be added to the view using the normal Gnoga patterns.
Cons:  A lot of functions have to be overridden and I don't know how to
test if the overrides will break anything.  Additionally, some of the init
functions (Create_With_HTML for example) would totally break a dialog box
so I had to override them and have the procedures raise an exception.
Finally GNAT has a bug in most (all?) versions where subtyping the
Dialog_Type exposes the private extension.  This has workarounds but is
annoying.

Version 2:
Dialog_Type is completely private and does not extend any Gnoga types.  It
uses full Composition instead.
Pros:  The Dialog_Type is much more safe against inadvertent tampering
since it only exposes the procedures needed.  It is easier to test and
maintain due to not having to override so many functions.
Cons:  It doesn't follow the standard Gnoga patterns for creation when it
comes to adding components.  Instead of calling
Some_Component.Create(My_Dialog), you have to do
My_Dialog.Create_Main_View(Some_View) and then
Some_Component.Create(Some_View)..  It cannot be managed dynamically by
other Gnoga components easily.

Side question:  how do I handle the copyright notice in the top of the
files.  David holds copyright over Gnoga.  Since this is an extension, do I
put my name in the copyright or his or both?

Below are the current specs
Version 1:
*********************************************************************************
with Gnoga.Gui.Window;
with Gnoga.Types.Colors;

--  This unit provides a modal dialog type for custom modal dialog designs.
package Gnoga.Gui.View.Modal_Dialog is

   -------------------------------------------------------------------------
   --  Dialog_Type
   -------------------------------------------------------------------------
   --  Dialog_Type is the class encapsulating the a modal frame and a
   --  modal background.
   type Dialog_Type is new Gnoga.Gui.View.View_Base_Type with private;
   type Dialog_Access is access all Dialog_Type;
   type Pointer_To_Dialog_Class is access all Dialog_Type'Class;


   procedure Create
      (Object : in out Dialog_Type;
       Parent : in out Gnoga.Gui.Window.Window_Type'Class;
       ID     :        String := "");
   procedure Create
      (Object : in out Dialog_Type;
       Parent : in out Gnoga.Gui.View.View_Base_Type'Class;
       ID     :        String := "");
   --  Creates a modal dialog using either a Window_Type or a View_Base_Type
   --  as a parent.


   procedure Show
      (Dialog : in out Dialog_Type;
       Show   :        Boolean := True;
       Center :        Boolean := True);
   --  Shows or hidees a dialog

   procedure Center (Dialog : in out Dialog_Type);
   --  Center a dialog within its parent window or view

   procedure Modal_Background_Color
      (Dialog : in out Dialog_Type;
       Color  :        String);
   --  Change the background color of the modal dialog's fill view

   procedure Modal_Background_Color
      (Dialog : in out Dialog_Type;
       Color  :        Gnoga.Types.Colors.Color_Enumeration);
   --  Change the background color of the modal dialog's fill view




-----------------------------------------------------------------------------
   --  Gnoga.Gui.View.View_Base_Type overrides

-----------------------------------------------------------------------------

   overriding
   procedure Fill_Parent (View : in out Dialog_Type);
   --  Cause View to expand its height and width to fill its parent's client
   --  area. View's parent must have Position set to Absolute, Fixed or
   --  Relative for Fill_Parent to work properly.
   --  Note:
   --     Position will be modified for View to either Absolute or Relative
   --     if Absolute positioning fails (i.e. on IE)




-----------------------------------------------------------------------------
   --  Gnoga.Gui.Element.Element_Type overrides

-----------------------------------------------------------------------------

   overriding
   procedure Auto_Place (Element : in out Dialog_Type; Value : Boolean);
   overriding
   function Auto_Place (Element : Dialog_Type) return Boolean;
   --  Elements by default are created outside the DOM and therefore not
   --  visible. If Auto_Place is set to false _before_ Create is called on
   --  an Element, View's will not place the Element in to the DOM as is
   --  the View's default behavior. Custom widgets that have child widgets
   --  should be designed to respect this property. Auto_Place if set to
   --  False will also prevent Auto_Set_View if Element's Parent is a Window

   overriding
   procedure Place_Inside_Top_Of
      (Element : in out Dialog_Type;
       Target  : in out Gnoga.Gui.Element.Element_Type'Class);
   overriding
   procedure Place_Inside_Bottom_Of
      (Element : in out Dialog_Type;
       Target  : in out Gnoga.Gui.Element.Element_Type'Class);
   overriding
   procedure Place_Before
      (Element : in out Dialog_Type;
       Target  : in out Gnoga.Gui.Element.Element_Type'Class);
   overriding
   procedure Place_After
      (Element : in out Dialog_Type;
       Target  : in out Gnoga.Gui.Element.Element_Type'Class);
   --  DOM placement method

   overriding
   procedure Remove (Element : in out Dialog_Type);
   --  Removes an element from the DOM, if the ID_Type is DOM_ID, the ID
   --  will be changed to a unique Gnoga_ID before removal.




-----------------------------------------------------------------------------
   --  Gnoga.Gui.Base.Base_Type overrides

-----------------------------------------------------------------------------

   overriding
   function Parent
      (Object : Dialog_Type)
       return Gnoga.Gui.Base.Pointer_To_Base_Class;
   overriding
   procedure Parent
      (Object : in out Dialog_Type;
       Value  : in out Gnoga.Gui.Base.Base_Type'Class);
   overriding
   procedure Parent
      (Object : in out Dialog_Type;
       Value  :        Gnoga.Gui.Base.Pointer_To_Base_Class);
   --  Parent of Object. Setting/changing the parent will fire the
   --  On_Parent_Added event on the Parent object and if changing the parent
   --  On_Parent_Removed event on the old Parent
   --
   --  Setting the parent Object does not change the position Object may
have
   --  in the DOM by default. That should be done using Element_Type.Place_*




-----------------------------------------------------------------------------
   --  Unsupported functionality.  Do not use.

-----------------------------------------------------------------------------

   Use_Error : exception;
   --  Called when an unsupported function is used

   overriding
   procedure Create_From_HTML
      (Element : in out Dialog_Type;
       Parent  : in out Gnoga.Gui.Base.Base_Type'Class;
       HTML    : in     String;
       ID      : in     String := "");
   overriding
   procedure Create_XML_Element
      (Element      : in out Dialog_Type;
       Parent       : in out Gnoga.Gui.Base.Base_Type'Class;
       Namespace    : in     String;
       Element_Type : in     String;
       ID           : in     String := "");
   overriding
   procedure Create_With_Script
     (Object        : in out Dialog_Type;
      Connection_ID : in     Gnoga.Types.Connection_ID;
      ID            : in     String;
      Script        : in     String;
      ID_Type       : in     Gnoga.Types.ID_Enumeration :=
Gnoga.Types.DOM_ID);
   overriding
   procedure Attach_Using_Parent
     (Object   : in out Dialog_Type;
      Parent   : in     Gnoga.Gui.Base.Base_Type'Class;
      ID       : in     String;
      ID_Type  : in     Gnoga.Types.ID_Enumeration := Gnoga.Types.DOM_ID);
   overriding
   procedure Attach
     (Object        : in out Dialog_Type;
      Connection_ID : in     Gnoga.Types.Connection_ID;
      ID            : in     String;
      ID_Type       : in     Gnoga.Types.ID_Enumeration :=
Gnoga.Types.DOM_ID);
   --  Unsupported.  Raises Use_Error if called

private

   type Dialog_Type is new Gnoga.Gui.View.View_Type with record
      Modal_Background : Gnoga.Gui.View.View_Type;
   end record;

end Gnoga.Gui.View.Modal_Dialog;
*********************************************************************************


Version 2:
*********************************************************************************
with Gnoga.Gui.Window;
with Gnoga.Types.Colors;
with Gnoga.Gui.View;

--  This unit provides a modal dialog type for custom modal dialog designs.
package Gnoga.Gui.Modal_Dialog is

   -------------------------------------------------------------------------
   --  Dialog_Type
   -------------------------------------------------------------------------
   --  Dialog_Type is the class encapsulating the a modal frame and a
   --  modal background.
   type Dialog_Type is tagged limited private;
   type Dialog_Access is access all Dialog_Type;
   type Pointer_To_Dialog_Class is access all Dialog_Type'Class;

   procedure Create
      (Dialog : in out Dialog_Type;
       Parent : in out Gnoga.Gui.Window.Window_Type'Class;
       ID     : in     String := "");
   --  Create a modal dialog using the window as a parent

   procedure Create
      (Dialog : in out Dialog_Type;
       Parent : in out Gnoga.Gui.View.View_Base_Type'Class;
       ID     : in     String := "");
   --  Create a modal dialog using a view as the parent

   procedure Create_Main_View
      (Dialog : in out Dialog_Type;
       View   : in out Gnoga.Gui.View.View_Type'Class;
       ID     : in     String := "");
   --  Attach and create a user created view to the dialog.  Call this
   --  in place of the Create procedure for the view supplied.

   procedure Show
      (Dialog : in out Dialog_Type;
       Show   :        Boolean := True;
       Center :        Boolean := True);
   --  Shows or hidees a dialog

   procedure Center (Dialog : in out Dialog_Type);
   --  Center a dialog within its parent window or view

   procedure Top (Dialog : in out Dialog_Type; Top  : Integer);
   --  Set the "top" position of the dialog.

   procedure Left (Dialog : in out Dialog_Type; Left : Integer);
   --  Set the "left" position of the dialog.

   procedure Modal_Background_Color
      (Dialog : in out Dialog_Type;
       Color  :        String);
   --  Change the background color of the modal dialog's fill view

   procedure Modal_Background_Color
      (Dialog : in out Dialog_Type;
       Color  :        Gnoga.Types.Colors.Color_Enumeration);
   --  Change the background color of the modal dialog's fill view

   procedure Remove (Dialog : in out Dialog_Type);
   --  Removes an element from the DOM, if the ID_Type is DOM_ID, the ID
   --  will be changed to a unique Gnoga_ID before removal.

private

   type Dialog_Type is tagged limited record
      Modal_Background : Gnoga.Gui.View.View_Type;
      Modal_Frame      : Gnoga.Gui.View.View_Type;
   end record;

end Gnoga.Gui.Modal_Dialog;

*********************************************************************************

On Thu, May 25, 2017 at 2:52 PM, Pascal wrote:

> Hello Jeremiah,
>
> What about of deriving Modal_Dialog from View_Base_Type in a package named
> Gnoga.Gui.View.Modal_Dialog.Dialog_Type?
>
>    type Dialog_Type is new Gnoga.Gui.View.View_Base_Type with record
>       Main_View : Gnoga.Gui.View.View_Access := null;
>    end record;
>
> It may solve the issue of Gauthier?
>
> > modal.adb:69:16: ambiguous call to "Create"
> > modal.adb:69:16: possible interpretation (inherited) at line 17
> > modal.adb:69:16: possible interpretation (inherited) at line 17
>
>
> Well, the simplest is to put it in Gnoga dev_1.3 branch and lets use it ;-)
>
> Could you please send source codes in files with standard Gnoga header and
> so on?
> See https://sourceforge.net/p/gnoga/wiki/Coding-Guidelines.
>
> Thanks, Pascal.
> http://blady.pagesperso-orange.fr
>
>
> > Le 17 mai 2017 à 05:19, Jeremiah Breeden a écrit :
> >
> > So after trying a bunch of implementations, I am leaning towards the
> following:
> >
> >
>
> <...>
>
> > Thoughts?
> >
>
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Gnoga-list mailing list
Gnoga-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gnoga-list

Reply via email to