Jump to content
kingofnuthin1980

Dialog Control Group - Child ID depending on Parent ID

Recommended Posts

Hello Arma-Community,

 

can I define the child ID in a control group, depending on the parent ID?

Example:

  • One control group, e.g. for a header with text and an underline.
  • The text should be dynamic.
  • In a Dialog, the Text ID should be always the Group ID + 1.
  • There shouldn't be a class for the child text in every header I use, just in the base class.

 

In Config:

class _CTRL_GROUP
{
	type = 15;
	idc = -1;
	.
	.
	class Controls
	{
		class _CT_TEXT
		{
			idc = Use Parent IDC + 1;
		};
		class _CT_LINE
		{
			idc = -1;
		};
	};
};

In Dialog:

class Rsc_GroupHeader_1: _CTRL_GROUP
{
	idc = 100;
};

class Rsc_GroupHeader_2: _CTRL_GROUP
{
	idc = 200;
};

In SQF:

ctrlSetText [101,"Text 1"];
ctrlSetText [201,"Text 2"];

Thank you for helping!

Share this post


Link to post
Share on other sites
//ui.hpp

#include "IDCs.hpp"
#include "A3_Base_GUI_defines.hpp"

#define HEADER_HEIGHT ( safeZoneH / 20 )

__EXEC( numHeaders = 0 )

#define HEADER_GROUP( GROUPNAME )  \
	__EXEC( numHeaders = numHeaders + 1 ) \
	class GROUPNAME : ctrlControlsGroupNoHScrollbars \
	{ \
		idc = __EVAL( numHeaders * HEADER_START_IDC ); \
 \
 		x = 0; \
 		y = __EVAL( ( numHeaders - 1 ) * HEADER_HEIGHT ); \
 		w = 1; \
 		h = HEADER_HEIGHT; \
 \
		class controls \
		{ \
			class HEADER_TXT : ctrlStatic \
			{ \
				idc = __EVAL( numHeaders * HEADER_START_IDC + HEADER_TXT_IDC ); \
 \
				x = 0; \
				y = 0; \
				w = 1; \
				h = HEADER_HEIGHT; \
 \
				text = "Not Set"; \
			}; \
			class HEADER_LINE : ctrlStatic \
			{ \
				idc = -1; \
				style = ST_LINE; \
 \
 				x = 0; \
 				y = HEADER_HEIGHT * 0.8; \
 				w = 1; \
 				h = pixelH; \
 \
			}; \
		}; \
}


class MyDisplay
{
	idd = 10000;

	onLoad = "_this call TAG_fnc_onDisplayLoad";

	class controls
	{
		HEADER_GROUP( Rsc_GroupHeader_1 );
		HEADER_GROUP( Rsc_GroupHeader_2 );
	};
};

EXAMPLE_MISSION

 

I personally would not number the child classes based on the controlsGroups idc. I would always have the headers text as say 10 increasing for each component in that specific controlsGroup etc etc then the headers text is always...

_display displayCtrl _headerIDC ctrlsGroupControl 10 ctrlSetText "Blah"

...no matter what header text your setting.

Share this post


Link to post
Share on other sites

First of all, thank you for your effort!
Defining variables this way is very new to me. But I'm on it  🙂

Share this post


Link to post
Share on other sites

I'm not sure, if I can put my head around this....

I understood how you set it up. Based on one IDC for Headers, plus Text IDC, and with counting the headers for the IDC and positioning variables. But I'm not figuring out, if I could adapt this into my (noob) idea.

 

Because it would be great, if I could use different IDCs, (container based, not header based), and different positioning, not only based on the amount of headers. 
 

But is it even possible with independent IDCs for the groups?

class MyDisplay
{
	idd = 10000;

	onLoad = "_this call TAG_fnc_onDisplayLoad";

	class CONTROLS
	{
    class CONTAINER_1: ctrlControlsGroupNoHScrollbars
		{
			idc = 1000
			x = safezoneX:
			y = safezoneY;
			w = 0.5 * safezoneH;
			h = 0.5 * safezoneH;

			class CONTROLS
			{
				class HEADER_1: HEADER_GROUP
				{
					idc = 1010;
					y = 1 * ( safeZoneH / 20 ) );
				};

				class TEXT_EDIT_WITH_TWO_INPUTS: TEXT_EDIT_GROUP
				{
					idc = 1020;
					y = 2 * ( safeZoneH / 20 ) );
				};

				class BUTTON_AND_ICON: BUTTON_GROUP
				{
					idc = 1030;
					y = 3 * ( safeZoneH / 20 ) );
				};

				class BUTTON_AND_ICON: BUTTON_GROUP
				{
					idc = 1040;
					y = 4 * ( safeZoneH / 20 ) );
				};

				class HEADER_2: HEADER_GROUP
				{
					idc = 1050;
					y = 5 * ( safeZoneH / 20 ) );
				};

				class BUTTON_AND_ICON: BUTTON_GROUP
				{
					idc = 1060;
					y = 6 * ( safeZoneH / 20 ) );
				};
			};
		};

		class CONTAINER_2: ctrlControlsGroupNoHScrollbars
		{
			idc = 2000
			x = 0.5 * safezoneX:
			y = safezoneY;
			w = 0.5 * safezoneH;
			h = 0.5 * safezoneH;

			class CONTROLS
			{
				class HEADER_1: HEADER_GROUP
				{
					idc = 2010;
					y = 1 * ( safeZoneH / 20 ) );
				};

				class BUTTON_AND_ICON: BUTTON_GROUP
				{
					idc = 2020;
					y = 2 * ( safeZoneH / 20 ) );
				};
			};
		};
	};
};

Sorry, but I often need a working example of exactly my thoughts to figure out how it works.

 

Quote

#define HEADER_GROUP( GROUPNAME )


Thank you for teaching me a different way to name controls and hanging them into the dialog 🙂

 

Quote

I personally would not number the child classes based on the controlsGroups idc. I would always have the headers text as say 10 increasing for each component in that specific controlsGroup etc etc then the headers text is always...

 

That's why I ended up numbering my groups as dezimals and their child IDCs +1,+2 etc.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×