|
From: Ralph T. <ra...@us...> - 2005-04-19 20:41:27
|
Update of /cvsroot/adobe-source/sandbox/visual_refactor/adobe/test/visual/headers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23614/visual_refactor/adobe/test/visual/headers Added Files: factory.hpp Log Message: Initial idea of the public widget factory interface. --- NEW FILE: factory.hpp --- /* Copyright 2005 Ralph Thomas Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt or a copy at http://opensource.adobe.com/licenses.html) */ /****************************************************************************************************/ #ifndef ADOBE_UI_CORE_FACTORY_HPP #define ADOBE_UI_CORE_FACTORY_HPP /****************************************************************************************************/ #include "display.hpp" #include "ui_core.hpp" #include <adobe/future/assemblage.hpp> #include <adobe/dictionary.hpp> #include <adobe/eve_parser.hpp> /****************************************************************************************************/ // /// This file defines the factory functions which are used to create widgets specified by /// the Eve file. The main factory function "default_factory" can be passed to window_server_t /// as the factory function to create widgets. All it does is call the other factory functions /// defined here to create specific widgets. /// /// The motivation behind having the factory split out into a function for each widget, is that /// it should be really easy for application developers to add custom attributes in Eve for /// widgets that interest them. /// /// In order to avoid complexities with passing type information around, the factory methods all /// insert the widget they create into the given parent. They also register with the assemblage /// in the factory token to be destroyed when the assemblage is destroyed. // /****************************************************************************************************/ namespace adobe { /****************************************************************************************************/ // /// This structure is given to all factory functions, so that they can correctly create /// the widgets they need to create. // struct factory_token_t { factory_token_t() {} /* explicit factory_token_t(display_t& display, assemblage_t& assemblage, sheet_t& sheet) : display_m(display), assemblage_m(assemblage), sheet_m(sheet) {}*/ // /// Created widgets should be made with respect to this display, and inserted /// into the given parent by this display. // display_t* display_m; // /// This is the assemblage which widget factories register the created widget /// (or wrapping structure) with, such that the widget gets deleted when the /// assemblage does. // assemblage_t* assemblage_m; // /// The current Adam sheet -- this contains all of the cells which widgets might /// want to bind against. // sheet_t* sheet_m; }; /****************************************************************************************************/ // /// This is the main factory function. It will create the named widget (if possible) /// and insert it into the parent. If the widget named is unknown, or the parent is /// not valid then a std::runtime_error exception is thrown. /// /// \param name the name of the widget to create, like "button" or "checkbox". /// \param parameters a dictionary of paramters for the new widget. /// \param parent the parent widget for this new (child) widget. This parameter /// may be zero when creating top-level widgets, such as windows. /// \param token a factory token, containing appropriate references. /// /// \return the newly created widget. This opaque position_t should not need to /// be poked at by client code -- everything it needs to do should have /// been set up by this factory function (e.g.: binding to cells in the /// token's sheet). // eve::position_t default_factory(std::string name, const dictionary_t& parameters, eve::position_t parent, const factory_token_t& token); /****************************************************************************************************/ // /// Create a window widget with the given parameters, and insert it into the /// given parent. /// /// \param parameters a dictionary of parameters for the new window. /// \param parent the parent widget for this button, may be zero. /// \param token a factory token, containing approprate references. /// /// \return the newly created widget. This pointer will have been added to the /// assemblage's (in the token) list of things to delete, so it will /// not be valid after the assemblage has been released. // window_t* window_factory(const dictionary_t& parameters, eve::position_t parent, const factory_token_t& token); /****************************************************************************************************/ /// Create a group widget with the given parameters, and insert it into the /// given parent. /// /// \param parameters a dictionary of parameters for the new group. /// \param parent the parent widget for this button, may not be zero. /// \param token a factory token, containing approprate references. /// /// \return the newly created widget. This pointer will have been added to the /// assemblage's (in the token) list of things to delete, so it will /// not be valid after the assemblage has been released. // button_t* group_factory(const dictionary_t& parameters, eve::position_t parent, const factory_token_t& token); /****************************************************************************************************/ // /// Create a tab group widget with the given parameters, and insert it into the /// given parent. /// /// \param parameters a dictionary of parameters for the new tab group. /// \param parent the parent widget for this button, may not be zero. /// \param token a factory token, containing approprate references. /// /// \return the newly created widget. This pointer will have been added to the /// assemblage's (in the token) list of things to delete, so it will /// not be valid after the assemblage has been released. // tab_group_t* tab_group_factory(const dictionary_t& parameters, eve::position_t parent, const factory_token_t& token); /****************************************************************************************************/ // /// Create a button widget with the given parameters, and insert it into the /// given parent. /// /// \param parameters a dictionary of parameters for the new button. /// \param parent the parent widget for this button, may not be zero. /// \param token a factory token, containing approprate references. /// /// \return the newly created widget. This pointer will have been added to the /// assemblage's (in the token) list of things to delete, so it will /// not be valid after the assemblage has been released. // button_t* button_factory(const dictionary_t& parameters, eve::position_t parent, const factory_token_t& token); /****************************************************************************************************/ // /// Create a panel widget with the given parameters, and insert it into the /// given parent. /// /// \param parameters a dictionary of parameters for the new panel. /// \param parent the parent widget for this button, may not be zero. /// \param token a factory token, containing approprate references. /// /// \return the newly created widget. This pointer will have been added to the /// assemblage's (in the token) list of things to delete, so it will /// not be valid after the assemblage has been released. // panel_t* panel_factory(const dictionary_t& parameters, eve::position_t parent, const factory_token_t& token); /****************************************************************************************************/ // /// Create a radio button widget with the given parameters, and insert it into the /// given parent. /// /// \param parameters a dictionary of parameters for the new radio button. /// \param parent the parent widget for this button, may not be zero. /// \param token a factory token, containing approprate references. /// /// \return the newly created widget. This pointer will have been added to the /// assemblage's (in the token) list of things to delete, so it will /// not be valid after the assemblage has been released. // radio_button_t* radio_button_factory(const dictionary_t& parameters, eve::position_t parent, const factory_token_t& token); /****************************************************************************************************/ // /// Create a check box widget with the given parameters, and insert it into the /// given parent. /// /// \param parameters a dictionary of parameters for the new check box. /// \param parent the parent widget for this button, may not be zero. /// \param token a factory token, containing approprate references. /// /// \return the newly created widget. This pointer will have been added to the /// assemblage's (in the token) list of things to delete, so it will /// not be valid after the assemblage has been released. // checkbox_t* check_box_factory(const dictionary_t& parameters, eve::position_t parent, const factory_token_t& token); /****************************************************************************************************/ // /// Create a link widget with the given parameters, and insert it into the /// given parent. /// /// \param parameters a dictionary of parameters for the new link. /// \param parent the parent widget for this button, may not be zero. /// \param token a factory token, containing approprate references. /// /// \return the newly created widget. This pointer will have been added to the /// assemblage's (in the token) list of things to delete, so it will /// not be valid after the assemblage has been released. // link_t* link_factory(const dictionary_t& parameters, eve::position_t parent, const factory_token_t& token); /****************************************************************************************************/ // /// Create a progress bar widget with the given parameters, and insert it into the /// given parent. /// /// \param parameters a dictionary of parameters for the new progress bar. /// \param parent the parent widget for this button, may not be zero. /// \param token a factory token, containing approprate references. /// /// \return the newly created widget. This pointer will have been added to the /// assemblage's (in the token) list of things to delete, so it will /// not be valid after the assemblage has been released. // progress_bar_t* progress_bar_factory(const dictionary_t& parameters, eve::position_t parent, const factory_token_t& token); /****************************************************************************************************/ // /// Create a separator widget with the given parameters, and insert it into the /// given parent. /// /// \param parameters a dictionary of parameters for the new separator. /// \param parent the parent widget for this button, may not be zero. /// \param token a factory token, containing approprate references. /// /// \return the newly created widget. This pointer will have been added to the /// assemblage's (in the token) list of things to delete, so it will /// not be valid after the assemblage has been released. // separator_t* separator_factory(const dictionary_t& parameters, eve::position_t parent, const factory_token_t& token); /****************************************************************************************************/ // /// Create a static text widget with the given parameters, and insert it into the /// given parent. /// /// \param parameters a dictionary of parameters for the new static text. /// \param parent the parent widget for this button, may not be zero. /// \param token a factory token, containing approprate references. /// /// \return the newly created widget. This pointer will have been added to the /// assemblage's (in the token) list of things to delete, so it will /// not be valid after the assemblage has been released. // static_text_t* static_text_factory(const dictionary_t& parameters, eve::position_t parent, const factory_token_t& token); /****************************************************************************************************/ // /// Create a edit text widget with the given parameters, and insert it into the /// given parent. /// /// \param parameters a dictionary of parameters for the new edit text. /// \param parent the parent widget for this button, may not be zero. /// \param token a factory token, containing approprate references. /// /// \return the newly created widget. This pointer will have been added to the /// assemblage's (in the token) list of things to delete, so it will /// not be valid after the assemblage has been released. // edit_text_t* edit_text_factory(const dictionary_t& parameters, eve::position_t parent, const factory_token_t& token); /****************************************************************************************************/ // /// Create a popup widget with the given parameters, and insert it into the /// given parent. /// /// \param parameters a dictionary of parameters for the new popup. /// \param parent the parent widget for this button, may not be zero. /// \param token a factory token, containing approprate references. /// /// \return the newly created widget. This pointer will have been added to the /// assemblage's (in the token) list of things to delete, so it will /// not be valid after the assemblage has been released. // popup_t* popup_factory(const dictionary_t& parameters, eve::position_t parent, const factory_token_t& token); /****************************************************************************************************/ // /// Create a unit edit text widget with the given parameters, and insert it into the /// given parent. /// /// \param parameters a dictionary of parameters for the new unit edit text. /// \param parent the parent widget for this button, may not be zero. /// \param token a factory token, containing approprate references. /// /// \return the newly created widget. This pointer will have been added to the /// assemblage's (in the token) list of things to delete, so it will /// not be valid after the assemblage has been released. // unit_edit_text_t* unit_edit_text_factory(const dictionary_t& parameters, eve::position_t parent, const factory_token_t& token); /****************************************************************************************************/ // /// Create a slider widget with the given parameters, and insert it into the /// given parent. /// /// \param parameters a dictionary of parameters for the new slider. /// \param parent the parent widget for this button, may not be zero. /// \param token a factory token, containing approprate references. /// /// \return the newly created widget. This pointer will have been added to the /// assemblage's (in the token) list of things to delete, so it will /// not be valid after the assemblage has been released. // slider_t* slider_factory(const dictionary_t& parameters, eve::position_t parent, const factory_token_t& token); /****************************************************************************************************/ // /// Create a bevel button widget with the given parameters, and insert it into the /// given parent. /// /// \param parameters a dictionary of parameters for the new bevel button. /// \param parent the parent widget for this button, may not be zero. /// \param token a factory token, containing approprate references. /// /// \return the newly created widget. This pointer will have been added to the /// assemblage's (in the token) list of things to delete, so it will /// not be valid after the assemblage has been released. // bevel_button_t* bevel_button_factory(const dictionary_t& parameters, eve::position_t parent, const factory_token_t& token); /****************************************************************************************************/ } /****************************************************************************************************/ #endif /****************************************************************************************************/ |