From de8fdfcfac107c2144c067ec77c58f93d253daf0 Mon Sep 17 00:00:00 2001 From: totoro Date: Tue, 9 Feb 2016 17:54:09 +0100 Subject: [PATCH] add icon and help_text to HK_App rename the db_display into hk_display --- database/model/db_model.anubis | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 82 insertions(+), 5 deletions(-) diff --git a/database/model/db_model.anubis b/database/model/db_model.anubis index 7c250d9..3a49628 100644 --- a/database/model/db_model.anubis +++ b/database/model/db_model.anubis @@ -102,6 +102,7 @@ public type HK_Help_Text: help_text_TAG(String), //TAG use with Anubis translation tool /locale/L3.anubis help_text(String). //pure text to show + public define String /* Return the Anubis source of the type component */ @@ -115,6 +116,36 @@ public define String help_text_TAG(tag) then "help_text_TAG(\""+tag+"\")", help_text(str) then "help_text(\""+str+"\")" }. + +public type HK_Icon: + no_icon, + icon16(String name). + +public define String +/* Return the Anubis source of the type component +*/ + to_Anubis_source + ( + HK_Icon icon + )= + if icon is + { + no_icon then "no_icon", + icon16(icn_str) then "icon16(\""+icn_str+"\")" + }. + +public define String +/* Return the Anubis source of the type component +*/ + to_String + ( + HK_Icon icon + )= + if icon is + { + no_icon then "\"\"", + icon16(icn_str) then "\""+icn_str+"_icon\"" + }. Of course, 'NOT NULL' is not an alternative of 'HK_Model_Attr' because it is already coded into the database type itself (type 'HK_Model_Field' above). @@ -169,7 +200,7 @@ public type HK_Edit_View: edit_view(String view_name, List(String) columns). public type HK_Display: - db_display(List(HK_List_View) list_views, + hk_display(List(HK_List_View) list_views, //List(HK_Edit_View) edit_views List(String)). @@ -183,10 +214,41 @@ public type HK_Table: Description of a whole database: public type HK_App: - hk_app( String app_name, - List(HK_Table) hk_tables - ). - + hk_app( + String app_name, + HK_Icon icon, + HK_Help_Text help, + List(HK_Table) hk_tables + ). + + /* Default constructor for HK_App*/ +public define HK_App + hk_app + ( + String app_name, + HK_Help_Text help, + List(HK_Table) hk_tables + )= + hk_app(app_name, no_icon, help, hk_tables). + +public define HK_App + hk_app + ( + String app_name, + HK_Icon icon, + List(HK_Table) hk_tables + )= + hk_app(app_name, icon, no_help_text, hk_tables). + + +public define HK_App + hk_app + ( + String app_name, + List(HK_Table) hk_tables + )= + hk_app(app_name, no_icon, no_help_text, hk_tables). + public type HK_Database: hk_database (String name, // name of the database List(HK_App) apps //list of applications @@ -268,6 +330,21 @@ define macro Maybe(String) } }. +public define Int + longest_table_name_size + ( + List(HK_App) apps, + Int current_size + )= + if apps is + { + [] then current_size, + [app . t_apps] then + since app is hk_app(_, _, _, tables), + with max_size = max(map((HK_Table table) |-> length(table.name), tables), current_size), + longest_table_name_size(t_apps, max_size) + }. + define Int _max ( -- libgit2 0.21.4