Commit 2f492d98 authored by Claes Sjofors's avatar Claes Sjofors

Ge optionmenu, functionality for dynamic texts added

parent 88e7f186
......@@ -3727,7 +3727,18 @@ the list corresponds to an enumeration value, and when an alternative is selecte
is inserted into the database attribute. The component is continuously reading the value of the
databas attribute, and displays the corresponding text in the text field.
The option men can be static or dynamic. For a static meny you state the texts and
enumeration values in different items. For a dynamic meny the meny text are fetched
from a database attribute of type array of String80. The number of texts in the menu is
fetched from an attribute of type Int32, and further more you should state an attribute
that indicates that new texts should be loaded. This attribute should be of type Boolean
and the new texts are loaded when the value is changed from 0 to 1.
<b>Attribute <t><t>Description
OptionMenu.Type <t><t>Type of option menu. Static eller dynamic.
Static menu
OptionMenu.Attribute <t><t>Database attribute of type Float32, Float64, Int32,
<t><t>UInt32, Int16, UInt16, Int8 or UInt8. The value in
<t><t>ItemEnum for a selected alternative inserted into the
......@@ -3737,6 +3748,20 @@ OptionMenu.ItemText1 <t><t>Text of the first menu alternative.
OptionMenu.ItemEnum1 <t><t>Enumeration value of the first menu alternative.
OptionMenu.ItemText2 <t><t>Text of the second menu alternative.
OptionMenu.ItemEnum2 <t><t>Enumeration value of the second menu alternative.
Dynamic menu
OptionMenu.Attribute <t><t>Database attribute of type Float32, Float64, Int32,
<t><t>UInt32, Int16, UInt16, Int8 or UInt8. The value in
<t><t>ItemEnum for a selected alternative inserted into the
<t><t>database attribute.
OptionMenu.TextAttribute <t><t>Database attribute of type array of String80. The array
<t><t>contains the texts that are displayed in the menu.
OptionMenu.SizeAttribute <t><t>Database attribute of type Int32. States the number of
<t><t>alternative in the menu.
OptionMenu.UpdateAttribute <t><t>Database attribute of type Boolean. Should be set to
<t><t>1 when new texts are present in the TextAttribute. New text
<t><t>are loaded when the value is changed from 0 to 1.
</topic>
</headerlevel>
<pagebreak>
......
......@@ -3686,7 +3686,18 @@ listan motsvarar ett uppr
databas-attributet. Komponenten läser kontinuerligt av värdet på databasattributet, och
skriver ut texten för det alternativ som motsvarar värdet, i sitt text-fält.
Optionmenyn kan vara statisk eller dynamisk. För en statisk meny anger man texter och
uppräkningsvärde i olika item, för en dynamisk meny hämtas meny-texterna från ett attribut
i databasen av typen array of String80. Antalet texter i menyn hämtas från ett attribut
av typen Int32, och dessutom ska man ange ett attribut som indikerar att nya texter ska
läsas in. Det här attributet ska vara av typen Boolean och inläsningen av nya texter sker
när värdet ändras från 0 till 1.
<b>Attribut <t><t>Beskrivning
OptionMenu.Type <t><t>Typ av optionmeny. Statisk eller dynamisk.
Statisk meny
OptionMenu.Attribute <t><t>Databas attribut av typen Float32, Float64, Int32,
<t><t>UInt32, Int16, UInt16, Int8 eller UInt8. Värdet i
<t><t>ItemEnum för valt alternativ sätts i databas attributet.
......@@ -3695,6 +3706,20 @@ OptionMenu.ItemText1 <t><t>Text f
OptionMenu.ItemEnum1 <t><t>Uppräkningsvärdet för första menyalternativet.
OptionMenu.ItemText2 <t><t>Text för andra menyalternativet.
OptionMenu.ItemEnum2 <t><t>Uppräkningsvärdet för andra menyalternativet.
Dynamisk meny
OptionMenu.Attribute <t><t>Databas attribut av typen Float32, Float64, Int32,
<t><t>UInt32, Int16, UInt16, Int8 eller UInt8. Index för
<t><t>valt alternativ sätts i databas attributet.
OptionMenu.TextAttribute <t><t>Databas attribut av typen vektor med String80, som
<t><t>innehåller de texter som visas i menyn.
OptionMenu.SizeAttribute <t><t>Databas attribut av typen Int32, som anger antalet
<t><t>alternativ i menyn.
OptionMenu.UpdateAttribute <t><t>Databas attribut av typen Boolean, som anger att
<t><t>texterna i menyn ska uppdateras. Uppdateringen sker när
<t><t>värdet ändras från 0 till 1.
</topic>
</headerlevel>
<pagebreak>
......
......@@ -969,6 +969,11 @@ static attrnav_sEnumElement elem_gradient[] = {
{ (int) glow_eGradient_RadialLowerRight, "RadialLowerRight"},
{ 0, ""}};
static attrnav_sEnumElement elem_optionmenu_type[] = {
{ (int) ge_eOptionMenuType_Static, "Static"},
{ (int) ge_eOptionMenuType_Dynamic, "Dynamic"},
{ 0, ""}};
static attrnav_sEnum enum_types[] = {
{ (int) glow_eType_Direction, (attrnav_sEnumElement *) &elem_direction},
{ (int) glow_eType_Color, (attrnav_sEnumElement *) &elem_color},
......@@ -987,7 +992,8 @@ static attrnav_sEnum enum_types[] = {
{ (int) ge_eAttrType_CurveDataType, (attrnav_sEnumElement *) &elem_curve_datatype},
{ (int) glow_eType_Gradient, (attrnav_sEnumElement *) &elem_gradient},
{ (int) glow_eType_HotIndication, (attrnav_sEnumElement *) &elem_hot_indication},
{ (int) glow_eType_AnnotType, (attrnav_sEnumElement *) &elem_annot_type},
{ (int) glow_eType_AnnotType, (attrnav_sEnumElement *) &elem_annot_type},
{ (int) ge_eAttrType_OptionMenuType, (attrnav_sEnumElement *) &elem_optionmenu_type},
{ 0, NULL}};
static attrnav_sEnum mask_types[] = {
......@@ -1062,6 +1068,7 @@ int attrnav_attr_string_to_value( int type_id, char *value_str,
case ge_eAttrType_InputFocus:
case ge_eAttrType_ScaleType:
case ge_eAttrType_CurveDataType:
case ge_eAttrType_OptionMenuType:
{
if ( sscanf( value_str, "%u", (int *)buffer_ptr) != 1)
return ATTRNAV__INPUT_SYNTAX;
......@@ -1142,6 +1149,7 @@ void attrnav_attrvalue_to_string( int type_id, void *value_ptr,
case ge_eAttrType_LimitType:
case ge_eAttrType_ScaleType:
case ge_eAttrType_CurveDataType:
case ge_eAttrType_OptionMenuType:
{
attrnav_sEnumElement *elem_p;
attrnav_sEnum *enum_p;
......@@ -1612,6 +1620,11 @@ static int attrnav_brow_cb( FlowCtx *ctx, flow_tEvent event)
*(int *)((ItemEnum *)item)->value_p = ((ItemEnum *)item)->num;
}
if ( (((ItemEnum *)item)->type_id == ge_eAttrType_OptionMenuType) &&
attrnav->reconfigure_attr_cb) {
(attrnav->reconfigure_attr_cb)(attrnav->parent_ctx);
return FLOW__DESTROYED;
}
break;
}
case attrnav_eItemType_Mask:
......@@ -1631,10 +1644,10 @@ static int attrnav_brow_cb( FlowCtx *ctx, flow_tEvent event)
*(unsigned int *)((ItemEnum *)item)->value_p |=
((ItemMask *)item)->mask;
}
if ( (((ItemEnum *)item)->type_id == ge_eAttrType_DynType ||
((ItemEnum *)item)->type_id == ge_eAttrType_DynTypeTone ||
((ItemEnum *)item)->type_id == ge_eAttrType_ActionType ||
((ItemEnum *)item)->type_id == ge_eAttrType_InstanceMask) &&
if ( (((ItemMask *)item)->type_id == ge_eAttrType_DynType ||
((ItemMask *)item)->type_id == ge_eAttrType_DynTypeTone ||
((ItemMask *)item)->type_id == ge_eAttrType_ActionType ||
((ItemMask *)item)->type_id == ge_eAttrType_InstanceMask) &&
attrnav->reconfigure_attr_cb) {
(attrnav->reconfigure_attr_cb)(attrnav->parent_ctx);
return FLOW__DESTROYED;
......@@ -1717,6 +1730,11 @@ static int attrnav_brow_cb( FlowCtx *ctx, flow_tEvent event)
*(int *)((ItemEnum *)item)->value_p = ((ItemEnum *)item)->num;
}
if ( (((ItemEnum *)item)->type_id == ge_eAttrType_OptionMenuType) &&
attrnav->reconfigure_attr_cb) {
(attrnav->reconfigure_attr_cb)(attrnav->parent_ctx);
return FLOW__DESTROYED;
}
break;
case attrnav_eItemType_Mask:
brow_SetRadiobutton( event->radiobutton.object,
......@@ -1731,6 +1749,7 @@ static int attrnav_brow_cb( FlowCtx *ctx, flow_tEvent event)
if ( (((ItemMask *)item)->type_id == ge_eAttrType_DynType ||
((ItemMask *)item)->type_id == ge_eAttrType_DynTypeTone ||
((ItemMask *)item)->type_id == ge_eAttrType_ActionType ||
((ItemMask *)item)->type_id == ge_eAttrType_OptionMenuType ||
((ItemMask *)item)->type_id == ge_eAttrType_InstanceMask) &&
attrnav->reconfigure_attr_cb) {
(attrnav->reconfigure_attr_cb)(attrnav->parent_ctx);
......@@ -2204,6 +2223,7 @@ ItemLocal::ItemLocal( AttrNav *attrnav, const char *item_name, const char *attr,
case ge_eAttrType_InputFocus:
case ge_eAttrType_ScaleType:
case ge_eAttrType_CurveDataType:
case ge_eAttrType_OptionMenuType:
if ( !noedit)
{
brow_SetAnnotPixmap( node, 0, attrnav->brow->pixmap_attrarray);
......
This diff is collapsed.
......@@ -96,6 +96,12 @@
ge_eCurveDataType_TableObject //!< Table object syntax.
} ge_eCurveDataType;
//! Types of animation sequences.
typedef enum {
ge_eOptionMenuType_Static, //!< Static optionmenu.
ge_eOptionMenuType_Dynamic //!< Dynamic optionmenu.
} ge_eOptionMenuType;
//! Dyn attributes displayed in attribute editor
typedef enum {
ge_eDynAttr_All,
......@@ -667,6 +673,10 @@
ge_eSave_OptionMenu_items_enum30 = 6963,
ge_eSave_OptionMenu_items_enum31 = 6964,
ge_eSave_OptionMenu_attribute = 6965,
ge_eSave_OptionMenu_text_attribute = 6966,
ge_eSave_OptionMenu_size_attribute = 6967,
ge_eSave_OptionMenu_update_attribute = 6968,
ge_eSave_OptionMenu_optionmenu_type = 6969,
ge_eSave_SetValue_attribute = 7000,
ge_eSave_SetValue_value = 7001,
ge_eSave_SetValue_instance = 7002,
......@@ -2533,8 +2543,11 @@ class GePulldownMenu : public GeDynElem {
class GeOptionMenu : public GeDynElem {
public:
pwr_tAName attribute; //!< Database reference for analog attribute.
pwr_tAName text_attribute; //!< Database reference for text array attribute.
pwr_tAName size_attribute; //!< Database reference for menu size attribute.
pwr_tAName update_attribute; //!< Database reference for update text attribute.
unsigned int items_enum[32];
char items_text[80][32];
char items_text[32][80];
unsigned int button_mask;
grow_tObject menu_object;
pwr_tTime focus_gained_time;
......@@ -2543,15 +2556,23 @@ class GeOptionMenu : public GeDynElem {
pwr_tSubid subid;
int size;
graph_eDatabase db;
pwr_tBoolean *update_p;
pwr_tSubid update_subid;
bool first_scan;
char old_value[8];
int type_id;
unsigned int text_size;
pwr_tBoolean old_update_value;
ge_eOptionMenuType optionmenu_type;
GeOptionMenu( GeDyn *e_dyn) :
GeDynElem(e_dyn, (ge_mDynType) 0, ge_mActionType_OptionMenu, ge_eDynPrio_OptionMenu),
button_mask(1), menu_object(0)
{
strcpy( attribute, "");
strcpy( text_attribute, "");
strcpy( size_attribute, "");
strcpy( update_attribute, "");
for ( int i = 0; i < 32; i++)
items_enum[i] = i;
memset( items_text, 0, sizeof( items_text));
......@@ -2562,6 +2583,9 @@ class GeOptionMenu : public GeDynElem {
{
memset( &focus_gained_time, 0, sizeof( focus_gained_time));
strcpy( attribute, x.attribute);
strcpy( text_attribute, x.text_attribute);
strcpy( size_attribute, x.size_attribute);
strcpy( update_attribute, x.update_attribute);
memcpy( items_text, x.items_text, sizeof(items_text));
for ( int i = 0; i < 32; i++) {
items_enum[i] = x.items_enum[i];
......
......@@ -99,7 +99,8 @@ typedef enum {
ge_eAttrType_InputFocus = 1006, //!< Initial input focus mask.
ge_eAttrType_Dyn = 1007, //!< Dynamic data.
ge_eAttrType_ScaleType = 1008, //!< Scale type.
ge_eAttrType_CurveDataType = 1009 //!< Data type for XY_Curve.
ge_eAttrType_CurveDataType = 1009, //!< Data type for XY_Curve.
ge_eAttrType_OptionMenuType = 1010 //!< OptionMenu type.
} ge_eAttrType;
//! Graph mode.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment