Hi .
How we can design graphical menus in c++ for a multimedia device ?
Thanks ...

We usually start by thinking about what we want. Then we might even draw it before working up a quick prototype. If the prototype meets out needs, we do the full implementation.

I say that how we can combining graphic and c++ to design this menus .
For example, look at this codes :

/*
 * volume screen coordinate constants 
 */
#define VOL_ICON_DIMX 32
#define VOL_ICON_DIMY 32
static const unsigned int VolumeIcon [] = {
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xff00ffff, 0xffffffff,
0xffffffff, 0xffffffff, 0x0000ffff, 0xffffffff,
0xffffffff, 0xffffff00, 0x0000ffff, 0x00ffffff,
0xffffffff, 0xffff0000, 0x0000ffff, 0xff00ffff,
0xffffffff, 0xff000000, 0x0000ffff, 0xff00ffff,
0xffffffff, 0x00000000, 0x0000ff00, 0xff00ffff,
0xffffff00, 0x00000000, 0x0000ff00, 0xffff00ff,
0x00000000, 0x00000000, 0x0000ffff, 0x00ff00ff,
0x00000000, 0x00000000, 0x0000ffff, 0x00ff00ff,
0x00000000, 0x00000000, 0x0000ffff, 0x00ffff00,
0x00000000, 0x00000000, 0x0000ffff, 0xff00ff00,
0x00000000, 0x00000000, 0x0000ffff, 0xff00ff00,
0x00000000, 0x00000000, 0x0000ffff, 0xff00ff00,
0x00000000, 0x00000000, 0x0000ffff, 0xff00ff00,
0x00000000, 0x00000000, 0x0000ffff, 0xff00ff00,
0x00000000, 0x00000000, 0x0000ffff, 0xff00ff00,
0x00000000, 0x00000000, 0x0000ffff, 0x00ffff00,
0x00000000, 0x00000000, 0x0000ffff, 0x00ff00ff,
0x00000000, 0x00000000, 0x0000ffff, 0x00ff00ff,
0xffffff00, 0x00000000, 0x0000ff00, 0xffff00ff,
0xffffffff, 0x00000000, 0x0000ff00, 0xff00ffff,
0xffffffff, 0xff000000, 0x0000ffff, 0xff00ffff,
0xffffffff, 0xffff0000, 0x0000ffff, 0xff00ffff,
0xffffffff, 0xffffff00, 0x0000ffff, 0x00ffffff,
0xffffffff, 0xffffffff, 0x0000ffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xff00ffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff
};
static unsigned char pel_mask[4096];

What it say ?

For example, look at this codes :
[..code..]

What it say ?

It declares an int-array and loads it with values. The array is const static which means that the values in the array cannot be changed.

The second line of code declares a static unsigned char array with a size of 4096 elements. But it doesn't have any values yet. This is not a problem, because the second array isn't const, so the values may be loaded later.

:icon_wink:

I think you don't understand my intention . How can I convert a graphical shape to data such as preceded example :
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, .................
How can I use graphic in c++ ? Don't say that I can use libraries . Because I want to compile the code for a micro of a multimedia device .

I think you don't understand my intention . How can I convert a graphical shape to data such as preceded example :
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, .................
How can I use graphic in c++ ? Don't say that I can use libraries . Because I want to compile the code for a micro of a multimedia device .

I think you don't understand my intention . How can I convert a graphical shape to data such as preceded example :
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff, .................

That's not a graphical shape. It's data nothing more and nothing less.

How can I use graphic in c++ ? Don't say that I can use libraries .

Fine, I won't. But you actually do need them.

What a pity that I can't convey my intention . All right . Thanks .

Please see this codes :

/*
 * VOL.C 						ver 0.1
 *
 * (c) Copyright SGS-Thomson Microelectronics Limited 1996. 
 *
 * Source file name : VOL.C
 * Authors	T.H.Thillai Rajan (tht.rajan@st.com)
 *
 * Original Work:  none
 *
 * =======================
 * IMPROVEMENTS THOUGHT OF
 * =======================
 *
 * =====================
 * MODIFICATION HISTORY:
 * =====================
 *
 * Date		Initials		Modification               								
 * ----     --------		------------               								
 * 07.04.97	THT			CREATED															
 */
/*{{{ Include files*/
#include "appldef.h"
/*}}}*/

/*{{{ module dependant includes*/
#include "usif_ext.h"
/*}}}*/

/*
 * volume screen coordinate constants 
 */
#define VOL_ICON_DIMX 32
#define VOL_ICON_DIMY 32

static const unsigned int VolumeIcon [] = {
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xff00ffff, 0xffffffff,
0xffffffff, 0xffffffff, 0x0000ffff, 0xffffffff,
0xffffffff, 0xffffff00, 0x0000ffff, 0x00ffffff,
0xffffffff, 0xffff0000, 0x0000ffff, 0xff00ffff,
0xffffffff, 0xff000000, 0x0000ffff, 0xff00ffff,
0xffffffff, 0x00000000, 0x0000ff00, 0xff00ffff,
0xffffff00, 0x00000000, 0x0000ff00, 0xffff00ff,
0x00000000, 0x00000000, 0x0000ffff, 0x00ff00ff,
0x00000000, 0x00000000, 0x0000ffff, 0x00ff00ff,
0x00000000, 0x00000000, 0x0000ffff, 0x00ffff00,
0x00000000, 0x00000000, 0x0000ffff, 0xff00ff00,
0x00000000, 0x00000000, 0x0000ffff, 0xff00ff00,
0x00000000, 0x00000000, 0x0000ffff, 0xff00ff00,
0x00000000, 0x00000000, 0x0000ffff, 0xff00ff00,
0x00000000, 0x00000000, 0x0000ffff, 0xff00ff00,
0x00000000, 0x00000000, 0x0000ffff, 0xff00ff00,
0x00000000, 0x00000000, 0x0000ffff, 0x00ffff00,
0x00000000, 0x00000000, 0x0000ffff, 0x00ff00ff,
0x00000000, 0x00000000, 0x0000ffff, 0x00ff00ff,
0xffffff00, 0x00000000, 0x0000ff00, 0xffff00ff,
0xffffffff, 0x00000000, 0x0000ff00, 0xff00ffff,
0xffffffff, 0xff000000, 0x0000ffff, 0xff00ffff,
0xffffffff, 0xffff0000, 0x0000ffff, 0xff00ffff,
0xffffffff, 0xffffff00, 0x0000ffff, 0x00ffffff,
0xffffffff, 0xffffffff, 0x0000ffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xff00ffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff
};

static unsigned char pel_mask[4096];

#define	VOL_BOX_ROW_START		70
#define	VOL_BOX_COL_START		344
#define	VOL_BOX_WIDTH			222
#define	VOL_BOX_HEIGHT			36
#define	VOL_BOX_ROW_END		( VOL_BOX_ROW_START + VOL_BOX_HEIGHT )
#define	VOL_BOX_COL_END		( VOL_BOX_COL_START + VOL_BOX_WIDTH )

#define	VOL_ICON_ROW		( VOL_BOX_ROW_START + 2 )
#define	VOL_ICON_COL		( VOL_BOX_COL_START + 4 )

#define	VOL_SLIDE_BOX_ROW_START	( VOL_BOX_ROW_START + 2 )
#define	VOL_SLIDE_BOX_COL_START	( VOL_BOX_COL_START + 40 )
#define	VOL_SLIDE_BOX_WIDTH 		176//342
#define	VOL_SLIDE_BOX_HEIGHT		32
#define	VOL_SLIDE_BOX_ROW_END	( VOL_SLIDE_BOX_ROW_START + VOL_SLIDE_BOX_HEIGHT )
#define	VOL_SLIDE_BOX_COL_END	( VOL_SLIDE_BOX_COL_START + VOL_SLIDE_BOX_WIDTH )

/*
 * CODE							:	DisplayVolume
 * TYPE							:	sub-routine
 * PROTOTYPE					:  
 *		int DisplayVolume ( char cInvokedBy );
 *
 * STACK							:	callers stack
 * INPUT							:	
 *	a. cInvokedBy		char
 *		identifies the type of the key which has invoked this function
 *
 * OUTPUT						: 	
 * a.	iKeyValue		int
 *	   <= 0	Timed Out while waiting for active keys ( VOL+/ VOL-/ MUTE)
 *		> 0 the key scan code which was different from the active keys
 *
 * GLOBAL VARIABLES USED	:
 *	a. tclkWaitDuration			int  					( W )
 * b. bScreen2bCleared		BOOLEAN				( W )
 *
 * DEVICES ACCESSED			:	nothing
 * FUNCTIONS CALLED			:  
 *
 * CALLERS						:	
 *	a.	usif_process						..\USIF\SOURCE\USIF.C
 * 
 * PURPOSE:
 *	this routine displays the current volume level in graphical form.
 *
 * ALGORITHM:	
 *	1. Clear the screen and draw the outer rectangle box 
 *	2.	wait for the user to press any of the active keys (VOL+/VOL-/MUTE)
 *	3.	if any keys other then active keys present then return to the caller
 *		with the actual key value read.
 *	4.	take appropriate action based on the active key value read.
 *	5. goto step 2. 
 *
 * IMPROVEMENT(s) THOUGHT OF:
 */
/*{{{ DisplayVolume ()*/
int	DisplayVolume ( char	cVolumeAction )
{
	extern	void mpeg_set_audio_volume_LR ( unsigned int left_volume, unsigned int right_volume );
	int	iKeyScanCode,i;
	BOOLEAN	bPrintMessage;
	char	cPrevVolLevel;

	gprim_cls ( C_TRANS );
	gprim_setfcol ( C_THIGHLIGHT );
	gprim_setbcol ( C_BACKGROUNDDARK );
	gprim_frect ( VOL_BOX_COL_START, VOL_BOX_ROW_START, VOL_BOX_COL_END, VOL_BOX_ROW_END );

	switch ( cVolumeAction )
	{
		case INCREASE_VOLUME:
			cCurVolLevel += VOLUME_STEP;
			if ( cCurVolLevel >= MAX_VOL_LEVEL )
				cCurVolLevel = MAX_VOL_LEVEL;
			break;

		case DECREASE_VOLUME:
			cCurVolLevel -= VOLUME_STEP;
			if ( cCurVolLevel < MIN_VOL_LEVEL )
				cCurVolLevel = MIN_VOL_LEVEL;
			break;

		case MUTE_VOLUME:
			if ( bAudioMuteState == TRUE )
			{
				bAudioMuteState = FALSE;
				mpeg_unmute_audio ();
			}
			else
			{
				bAudioMuteState = TRUE;
				mpeg_mute_audio ();
			}
			break;
	}

	bPrintMessage = TRUE;
	cPrevVolLevel = cCurVolLevel;

	gprim_setfcol ( C_TRANS );
	gprim_setbcol ( C_THIGHLIGHT );
	gprim_frect ( VOL_SLIDE_BOX_COL_START, VOL_SLIDE_BOX_ROW_START, VOL_SLIDE_BOX_COL_END, VOL_SLIDE_BOX_ROW_END );

	while ( TRUE )
	{
		mpeg_set_audio_volume_LR ( cCurVolLevel, cCurVolLevel );
		UpdateBoxVolInfo ( cCurVolLevel, cCurVolBalance, bAudioMuteState );

		if ( bPrintMessage == TRUE )
		{
			bPrintMessage = FALSE;

			gprim_setfcol ( C_THIGHLIGHT );
			gprim_setbcol ( C_BACKGROUNDDARK );
			gprim_frect ( VOL_ICON_COL, VOL_ICON_ROW, VOL_ICON_COL+32, VOL_ICON_ROW+32 );

			gprim_setbcol ( C_THIGHLIGHT );
			if ( bAudioMuteState == TRUE )
			{
				gprim_setfcol ( C_BACKMEDIUM );
				ShowVolumeIcon();
				gprim_line ( VOL_ICON_COL, VOL_ICON_ROW, VOL_ICON_COL + 32, VOL_ICON_ROW + 32 );
				gprim_line ( VOL_ICON_COL, VOL_ICON_ROW+32, VOL_ICON_COL+32, VOL_ICON_ROW );
			}
			else
			{
				gprim_setfcol ( C_GREEN );
				ShowVolumeIcon();
			}

			gprim_setbcol ( C_TRANS );
			for(i=48; i<cCurVolLevel+1; i++)
			gprim_frect ( VOL_SLIDE_BOX_COL_START+5+(i- MIN_VOL_LEVEL)*10, VOL_SLIDE_BOX_ROW_START+2, VOL_SLIDE_BOX_COL_START+5+(i- MIN_VOL_LEVEL)*10+5, VOL_SLIDE_BOX_ROW_END-4 );
		}

		wait_duration_forced_during = WAIT_AT_VOLUME_CONTROL;
		if ( bAudioMuteState == TRUE )
		tclkWaitDuration 		= INDEFINITE_WAIT;
		else
		tclkWaitDuration 		= WAIT_FOR_3_SEC;

		cPrevVolLevel = cCurVolLevel;

		if ( bAudioMuteState == TRUE )
		{
			gprim_setfcol ( C_BACKMEDIUM );
		}
		else
		{
			gprim_setfcol ( C_GREEN );
		}

		mpeg_set_audio_volume ( cCurVolLevel );
		iKeyScanCode = ReadKey ( CURSOR_OFF, tclkWaitDuration );

		switch ( iKeyScanCode )
		{
        	case VOLUME_NEXT_KEY:
			case VOL_UP_CUM_RIGHT_ARROW_KEY:
				if ( bAudioMuteState == TRUE )
				{
					bAudioMuteState = FALSE;
					mpeg_unmute_audio ();
					bPrintMessage = TRUE;
				}

				cCurVolLevel += VOLUME_STEP;
				if ( cCurVolLevel >= MAX_VOL_LEVEL )
					cCurVolLevel = MAX_VOL_LEVEL;
				if ( cPrevVolLevel != MAX_VOL_LEVEL )
				gprim_frect ( VOL_SLIDE_BOX_COL_START+5+(cCurVolLevel- MIN_VOL_LEVEL)*10, VOL_SLIDE_BOX_ROW_START+2, VOL_SLIDE_BOX_COL_START+5+(cCurVolLevel- MIN_VOL_LEVEL)*10+5, VOL_SLIDE_BOX_ROW_START+VOL_SLIDE_BOX_HEIGHT-4 );
				break;

			case VOLUME_PREV_KEY:
			case VOL_DOWN_CUM_LEFT_ARROW_KEY:

				if ( bAudioMuteState == TRUE )
				{
					bAudioMuteState = FALSE;
					mpeg_unmute_audio ();
					bPrintMessage = TRUE;
				}

				cCurVolLevel -= VOLUME_STEP;
				if ( cCurVolLevel < MIN_VOL_LEVEL )
					cCurVolLevel = MIN_VOL_LEVEL;
				if ( cPrevVolLevel != MIN_VOL_LEVEL )
				{
				gprim_setfcol ( C_TRANS );
				gprim_frect ( VOL_SLIDE_BOX_COL_START+5+(cPrevVolLevel- MIN_VOL_LEVEL)*10, VOL_SLIDE_BOX_ROW_START+2, VOL_SLIDE_BOX_COL_START+5+(cPrevVolLevel- MIN_VOL_LEVEL)*10+5, VOL_SLIDE_BOX_ROW_START+VOL_SLIDE_BOX_HEIGHT-4 );
				}
				break;

			case MUTE_KEY:
				if ( bAudioMuteState == TRUE )
				{
					bAudioMuteState = FALSE;
					mpeg_unmute_audio ();
				}
				else
				{
					bAudioMuteState = TRUE;
					mpeg_mute_audio ();
				}
				bPrintMessage = TRUE;
				break;

			default:
				gprim_cls ( C_TRANS );
				return iKeyScanCode;
		}
	}
}

void ShowVolumeIcon()
{

	int j;
	int dim_x, dim_y;
	unsigned int *pel;
	int IabsX=VOL_ICON_COL;
	int IabsY=VOL_ICON_ROW;

	dim_x = VOL_ICON_DIMX ;
	dim_y = VOL_ICON_DIMY ;
	pel = (unsigned int *) VolumeIcon;

	/* Make the Transparent Mask  - Color 0 is transparent */
	for (j = 0; j < (dim_x * dim_y) /8; j++ )
		{
		/* Transparency mask */
		pel_mask[j]  = ((pel[j] & 0xF0000000) != 0) << 7;
		pel_mask[j] |= ((pel[j] & 0x0F000000) != 0) << 6;
		pel_mask[j] |= ((pel[j] & 0x00F00000) != 0) << 5;
		pel_mask[j] |= ((pel[j] & 0x000F0000) != 0) << 4;
		pel_mask[j] |= ((pel[j] & 0x0000F000) != 0) << 3;
		pel_mask[j] |= ((pel[j] & 0x00000F00) != 0) << 2;
		pel_mask[j] |= ((pel[j] & 0x000000F0) != 0) << 1;
		pel_mask[j] |= ((pel[j] & 0x0000000F) != 0);
		}

	gprim_setpel(dim_x, dim_y, true, pel, pel_mask , 0, 0);
	gprim_pel(IabsX, IabsY);

}
/*}}}*/

>> (c) Copyright SGS-Thomson Microelectronics Limited 1996.

Do they know you've just put their code on the web?

Do you have a question?

that how this code works ?

that how this code works ?

You can't just wack a code here and expect people to explain it to you line by line.
I know you probably want to be a l33t game hacker, but this is not the way to learn C/C++.
Start here and come back when you have a specific question about a specific problem or line.

commented: :) +13
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.