943,779 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1590
  • C++ RSS
You are currently viewing page 1 of this multi-page discussion thread
Sep 7th, 2009
0

Graphical Menu Design

Expand Post »
Hi .
How we can design graphical menus in c++ for a multimedia device ?
Thanks ...
Similar Threads
Reputation Points: 10
Solved Threads: 1
Light Poster
Behi Jon is offline Offline
47 posts
since Nov 2008
Sep 7th, 2009
2

Re: Graphical Menu Design

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.
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004
Sep 8th, 2009
0

Re: Graphical Menu Design

I say that how we can combining graphic and c++ to design this menus .
For example, look at this codes :
C++ Syntax (Toggle Plain Text)
  1. /*
  2.  * volume screen coordinate constants
  3.  */
  4. #define VOL_ICON_DIMX 32
  5. #define VOL_ICON_DIMY 32
  6. static const unsigned int VolumeIcon [] = {
  7. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  8. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  9. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  10. 0xffffffff, 0xffffffff, 0xff00ffff, 0xffffffff,
  11. 0xffffffff, 0xffffffff, 0x0000ffff, 0xffffffff,
  12. 0xffffffff, 0xffffff00, 0x0000ffff, 0x00ffffff,
  13. 0xffffffff, 0xffff0000, 0x0000ffff, 0xff00ffff,
  14. 0xffffffff, 0xff000000, 0x0000ffff, 0xff00ffff,
  15. 0xffffffff, 0x00000000, 0x0000ff00, 0xff00ffff,
  16. 0xffffff00, 0x00000000, 0x0000ff00, 0xffff00ff,
  17. 0x00000000, 0x00000000, 0x0000ffff, 0x00ff00ff,
  18. 0x00000000, 0x00000000, 0x0000ffff, 0x00ff00ff,
  19. 0x00000000, 0x00000000, 0x0000ffff, 0x00ffff00,
  20. 0x00000000, 0x00000000, 0x0000ffff, 0xff00ff00,
  21. 0x00000000, 0x00000000, 0x0000ffff, 0xff00ff00,
  22. 0x00000000, 0x00000000, 0x0000ffff, 0xff00ff00,
  23. 0x00000000, 0x00000000, 0x0000ffff, 0xff00ff00,
  24. 0x00000000, 0x00000000, 0x0000ffff, 0xff00ff00,
  25. 0x00000000, 0x00000000, 0x0000ffff, 0xff00ff00,
  26. 0x00000000, 0x00000000, 0x0000ffff, 0x00ffff00,
  27. 0x00000000, 0x00000000, 0x0000ffff, 0x00ff00ff,
  28. 0x00000000, 0x00000000, 0x0000ffff, 0x00ff00ff,
  29. 0xffffff00, 0x00000000, 0x0000ff00, 0xffff00ff,
  30. 0xffffffff, 0x00000000, 0x0000ff00, 0xff00ffff,
  31. 0xffffffff, 0xff000000, 0x0000ffff, 0xff00ffff,
  32. 0xffffffff, 0xffff0000, 0x0000ffff, 0xff00ffff,
  33. 0xffffffff, 0xffffff00, 0x0000ffff, 0x00ffffff,
  34. 0xffffffff, 0xffffffff, 0x0000ffff, 0xffffffff,
  35. 0xffffffff, 0xffffffff, 0xff00ffff, 0xffffffff,
  36. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  37. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  38. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff
  39. };
  40. static unsigned char pel_mask[4096];

What it say ?
Reputation Points: 10
Solved Threads: 1
Light Poster
Behi Jon is offline Offline
47 posts
since Nov 2008
Sep 8th, 2009
0

Re: Graphical Menu Design

Click to Expand / Collapse  Quote originally posted by Behi Jon ...
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.

Moderator
Featured Poster
Reputation Points: 4142
Solved Threads: 394
Industrious Poster
Nick Evan is offline Offline
4,132 posts
since Oct 2006
Sep 8th, 2009
0

Re: Graphical Menu Design

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 .
Last edited by Behi Jon; Sep 8th, 2009 at 5:00 am.
Reputation Points: 10
Solved Threads: 1
Light Poster
Behi Jon is offline Offline
47 posts
since Nov 2008
Sep 8th, 2009
0

Re: Graphical Menu Design

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 .
Last edited by Behi Jon; Sep 8th, 2009 at 5:00 am.
Reputation Points: 10
Solved Threads: 1
Light Poster
Behi Jon is offline Offline
47 posts
since Nov 2008
Sep 8th, 2009
0

Re: Graphical Menu Design

Click to Expand / Collapse  Quote originally posted by Behi Jon ...
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.

Click to Expand / Collapse  Quote originally posted by Behi Jon ...
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.
Moderator
Featured Poster
Reputation Points: 4142
Solved Threads: 394
Industrious Poster
Nick Evan is offline Offline
4,132 posts
since Oct 2006
Sep 8th, 2009
0

Re: Graphical Menu Design

What a pity that I can't convey my intention . All right . Thanks .
Reputation Points: 10
Solved Threads: 1
Light Poster
Behi Jon is offline Offline
47 posts
since Nov 2008
Sep 8th, 2009
0

Re: Graphical Menu Design

Please see this codes :
C++ Syntax (Toggle Plain Text)
  1. /*
  2.  * VOL.C ver 0.1
  3.  *
  4.  * (c) Copyright SGS-Thomson Microelectronics Limited 1996.
  5.  *
  6.  * Source file name : VOL.C
  7.  * Authors T.H.Thillai Rajan (tht.rajan@st.com)
  8.  *
  9.  * Original Work: none
  10.  *
  11.  * =======================
  12.  * IMPROVEMENTS THOUGHT OF
  13.  * =======================
  14.  *
  15.  * =====================
  16.  * MODIFICATION HISTORY:
  17.  * =====================
  18.  *
  19.  * Date Initials Modification
  20.  * ---- -------- ------------
  21.  * 07.04.97 THT CREATED
  22.  */
  23. /*{{{ Include files*/
  24. #include "appldef.h"
  25. /*}}}*/
  26.  
  27. /*{{{ module dependant includes*/
  28. #include "usif_ext.h"
  29. /*}}}*/
  30.  
  31. /*
  32.  * volume screen coordinate constants
  33.  */
  34. #define VOL_ICON_DIMX 32
  35. #define VOL_ICON_DIMY 32
  36.  
  37. static const unsigned int VolumeIcon [] = {
  38. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  39. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  40. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  41. 0xffffffff, 0xffffffff, 0xff00ffff, 0xffffffff,
  42. 0xffffffff, 0xffffffff, 0x0000ffff, 0xffffffff,
  43. 0xffffffff, 0xffffff00, 0x0000ffff, 0x00ffffff,
  44. 0xffffffff, 0xffff0000, 0x0000ffff, 0xff00ffff,
  45. 0xffffffff, 0xff000000, 0x0000ffff, 0xff00ffff,
  46. 0xffffffff, 0x00000000, 0x0000ff00, 0xff00ffff,
  47. 0xffffff00, 0x00000000, 0x0000ff00, 0xffff00ff,
  48. 0x00000000, 0x00000000, 0x0000ffff, 0x00ff00ff,
  49. 0x00000000, 0x00000000, 0x0000ffff, 0x00ff00ff,
  50. 0x00000000, 0x00000000, 0x0000ffff, 0x00ffff00,
  51. 0x00000000, 0x00000000, 0x0000ffff, 0xff00ff00,
  52. 0x00000000, 0x00000000, 0x0000ffff, 0xff00ff00,
  53. 0x00000000, 0x00000000, 0x0000ffff, 0xff00ff00,
  54. 0x00000000, 0x00000000, 0x0000ffff, 0xff00ff00,
  55. 0x00000000, 0x00000000, 0x0000ffff, 0xff00ff00,
  56. 0x00000000, 0x00000000, 0x0000ffff, 0xff00ff00,
  57. 0x00000000, 0x00000000, 0x0000ffff, 0x00ffff00,
  58. 0x00000000, 0x00000000, 0x0000ffff, 0x00ff00ff,
  59. 0x00000000, 0x00000000, 0x0000ffff, 0x00ff00ff,
  60. 0xffffff00, 0x00000000, 0x0000ff00, 0xffff00ff,
  61. 0xffffffff, 0x00000000, 0x0000ff00, 0xff00ffff,
  62. 0xffffffff, 0xff000000, 0x0000ffff, 0xff00ffff,
  63. 0xffffffff, 0xffff0000, 0x0000ffff, 0xff00ffff,
  64. 0xffffffff, 0xffffff00, 0x0000ffff, 0x00ffffff,
  65. 0xffffffff, 0xffffffff, 0x0000ffff, 0xffffffff,
  66. 0xffffffff, 0xffffffff, 0xff00ffff, 0xffffffff,
  67. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  68. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff,
  69. 0xffffffff, 0xffffffff, 0xffffffff, 0xffffffff
  70. };
  71.  
  72. static unsigned char pel_mask[4096];
  73.  
  74. #define VOL_BOX_ROW_START 70
  75. #define VOL_BOX_COL_START 344
  76. #define VOL_BOX_WIDTH 222
  77. #define VOL_BOX_HEIGHT 36
  78. #define VOL_BOX_ROW_END ( VOL_BOX_ROW_START + VOL_BOX_HEIGHT )
  79. #define VOL_BOX_COL_END ( VOL_BOX_COL_START + VOL_BOX_WIDTH )
  80.  
  81. #define VOL_ICON_ROW ( VOL_BOX_ROW_START + 2 )
  82. #define VOL_ICON_COL ( VOL_BOX_COL_START + 4 )
  83.  
  84. #define VOL_SLIDE_BOX_ROW_START ( VOL_BOX_ROW_START + 2 )
  85. #define VOL_SLIDE_BOX_COL_START ( VOL_BOX_COL_START + 40 )
  86. #define VOL_SLIDE_BOX_WIDTH 176//342
  87. #define VOL_SLIDE_BOX_HEIGHT 32
  88. #define VOL_SLIDE_BOX_ROW_END ( VOL_SLIDE_BOX_ROW_START + VOL_SLIDE_BOX_HEIGHT )
  89. #define VOL_SLIDE_BOX_COL_END ( VOL_SLIDE_BOX_COL_START + VOL_SLIDE_BOX_WIDTH )
  90.  
  91. /*
  92.  * CODE : DisplayVolume
  93.  * TYPE : sub-routine
  94.  * PROTOTYPE :
  95.  * int DisplayVolume ( char cInvokedBy );
  96.  *
  97.  * STACK : callers stack
  98.  * INPUT :
  99.  * a. cInvokedBy char
  100.  * identifies the type of the key which has invoked this function
  101.  *
  102.  * OUTPUT :
  103.  * a. iKeyValue int
  104.  * <= 0 Timed Out while waiting for active keys ( VOL+/ VOL-/ MUTE)
  105.  * > 0 the key scan code which was different from the active keys
  106.  *
  107.  * GLOBAL VARIABLES USED :
  108.  * a. tclkWaitDuration int ( W )
  109.  * b. bScreen2bCleared BOOLEAN ( W )
  110.  *
  111.  * DEVICES ACCESSED : nothing
  112.  * FUNCTIONS CALLED :
  113.  *
  114.  * CALLERS :
  115.  * a. usif_process ..\USIF\SOURCE\USIF.C
  116.  *
  117.  * PURPOSE:
  118.  * this routine displays the current volume level in graphical form.
  119.  *
  120.  * ALGORITHM:
  121.  * 1. Clear the screen and draw the outer rectangle box
  122.  * 2. wait for the user to press any of the active keys (VOL+/VOL-/MUTE)
  123.  * 3. if any keys other then active keys present then return to the caller
  124.  * with the actual key value read.
  125.  * 4. take appropriate action based on the active key value read.
  126.  * 5. goto step 2.
  127.  *
  128.  * IMPROVEMENT(s) THOUGHT OF:
  129.  */
  130. /*{{{ DisplayVolume ()*/
  131. int DisplayVolume ( char cVolumeAction )
  132. {
  133. extern void mpeg_set_audio_volume_LR ( unsigned int left_volume, unsigned int right_volume );
  134. int iKeyScanCode,i;
  135. BOOLEAN bPrintMessage;
  136. char cPrevVolLevel;
  137.  
  138. gprim_cls ( C_TRANS );
  139. gprim_setfcol ( C_THIGHLIGHT );
  140. gprim_setbcol ( C_BACKGROUNDDARK );
  141. gprim_frect ( VOL_BOX_COL_START, VOL_BOX_ROW_START, VOL_BOX_COL_END, VOL_BOX_ROW_END );
  142.  
  143. switch ( cVolumeAction )
  144. {
  145. case INCREASE_VOLUME:
  146. cCurVolLevel += VOLUME_STEP;
  147. if ( cCurVolLevel >= MAX_VOL_LEVEL )
  148. cCurVolLevel = MAX_VOL_LEVEL;
  149. break;
  150.  
  151. case DECREASE_VOLUME:
  152. cCurVolLevel -= VOLUME_STEP;
  153. if ( cCurVolLevel < MIN_VOL_LEVEL )
  154. cCurVolLevel = MIN_VOL_LEVEL;
  155. break;
  156.  
  157. case MUTE_VOLUME:
  158. if ( bAudioMuteState == TRUE )
  159. {
  160. bAudioMuteState = FALSE;
  161. mpeg_unmute_audio ();
  162. }
  163. else
  164. {
  165. bAudioMuteState = TRUE;
  166. mpeg_mute_audio ();
  167. }
  168. break;
  169. }
  170.  
  171. bPrintMessage = TRUE;
  172. cPrevVolLevel = cCurVolLevel;
  173.  
  174. gprim_setfcol ( C_TRANS );
  175. gprim_setbcol ( C_THIGHLIGHT );
  176. gprim_frect ( VOL_SLIDE_BOX_COL_START, VOL_SLIDE_BOX_ROW_START, VOL_SLIDE_BOX_COL_END, VOL_SLIDE_BOX_ROW_END );
  177.  
  178. while ( TRUE )
  179. {
  180. mpeg_set_audio_volume_LR ( cCurVolLevel, cCurVolLevel );
  181. UpdateBoxVolInfo ( cCurVolLevel, cCurVolBalance, bAudioMuteState );
  182.  
  183. if ( bPrintMessage == TRUE )
  184. {
  185. bPrintMessage = FALSE;
  186.  
  187. gprim_setfcol ( C_THIGHLIGHT );
  188. gprim_setbcol ( C_BACKGROUNDDARK );
  189. gprim_frect ( VOL_ICON_COL, VOL_ICON_ROW, VOL_ICON_COL+32, VOL_ICON_ROW+32 );
  190.  
  191. gprim_setbcol ( C_THIGHLIGHT );
  192. if ( bAudioMuteState == TRUE )
  193. {
  194. gprim_setfcol ( C_BACKMEDIUM );
  195. ShowVolumeIcon();
  196. gprim_line ( VOL_ICON_COL, VOL_ICON_ROW, VOL_ICON_COL + 32, VOL_ICON_ROW + 32 );
  197. gprim_line ( VOL_ICON_COL, VOL_ICON_ROW+32, VOL_ICON_COL+32, VOL_ICON_ROW );
  198. }
  199. else
  200. {
  201. gprim_setfcol ( C_GREEN );
  202. ShowVolumeIcon();
  203. }
  204.  
  205. gprim_setbcol ( C_TRANS );
  206. for(i=48; i<cCurVolLevel+1; i++)
  207. 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 );
  208. }
  209.  
  210. wait_duration_forced_during = WAIT_AT_VOLUME_CONTROL;
  211. if ( bAudioMuteState == TRUE )
  212. tclkWaitDuration = INDEFINITE_WAIT;
  213. else
  214. tclkWaitDuration = WAIT_FOR_3_SEC;
  215.  
  216. cPrevVolLevel = cCurVolLevel;
  217.  
  218. if ( bAudioMuteState == TRUE )
  219. {
  220. gprim_setfcol ( C_BACKMEDIUM );
  221. }
  222. else
  223. {
  224. gprim_setfcol ( C_GREEN );
  225. }
  226.  
  227. mpeg_set_audio_volume ( cCurVolLevel );
  228. iKeyScanCode = ReadKey ( CURSOR_OFF, tclkWaitDuration );
  229.  
  230. switch ( iKeyScanCode )
  231. {
  232. case VOLUME_NEXT_KEY:
  233. case VOL_UP_CUM_RIGHT_ARROW_KEY:
  234. if ( bAudioMuteState == TRUE )
  235. {
  236. bAudioMuteState = FALSE;
  237. mpeg_unmute_audio ();
  238. bPrintMessage = TRUE;
  239. }
  240.  
  241. cCurVolLevel += VOLUME_STEP;
  242. if ( cCurVolLevel >= MAX_VOL_LEVEL )
  243. cCurVolLevel = MAX_VOL_LEVEL;
  244. if ( cPrevVolLevel != MAX_VOL_LEVEL )
  245. 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 );
  246. break;
  247.  
  248. case VOLUME_PREV_KEY:
  249. case VOL_DOWN_CUM_LEFT_ARROW_KEY:
  250.  
  251. if ( bAudioMuteState == TRUE )
  252. {
  253. bAudioMuteState = FALSE;
  254. mpeg_unmute_audio ();
  255. bPrintMessage = TRUE;
  256. }
  257.  
  258. cCurVolLevel -= VOLUME_STEP;
  259. if ( cCurVolLevel < MIN_VOL_LEVEL )
  260. cCurVolLevel = MIN_VOL_LEVEL;
  261. if ( cPrevVolLevel != MIN_VOL_LEVEL )
  262. {
  263. gprim_setfcol ( C_TRANS );
  264. 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 );
  265. }
  266. break;
  267.  
  268. case MUTE_KEY:
  269. if ( bAudioMuteState == TRUE )
  270. {
  271. bAudioMuteState = FALSE;
  272. mpeg_unmute_audio ();
  273. }
  274. else
  275. {
  276. bAudioMuteState = TRUE;
  277. mpeg_mute_audio ();
  278. }
  279. bPrintMessage = TRUE;
  280. break;
  281.  
  282. default:
  283. gprim_cls ( C_TRANS );
  284. return iKeyScanCode;
  285. }
  286. }
  287. }
  288.  
  289. void ShowVolumeIcon()
  290. {
  291.  
  292. int j;
  293. int dim_x, dim_y;
  294. unsigned int *pel;
  295. int IabsX=VOL_ICON_COL;
  296. int IabsY=VOL_ICON_ROW;
  297.  
  298. dim_x = VOL_ICON_DIMX ;
  299. dim_y = VOL_ICON_DIMY ;
  300. pel = (unsigned int *) VolumeIcon;
  301.  
  302. /* Make the Transparent Mask - Color 0 is transparent */
  303. for (j = 0; j < (dim_x * dim_y) /8; j++ )
  304. {
  305. /* Transparency mask */
  306. pel_mask[j] = ((pel[j] & 0xF0000000) != 0) << 7;
  307. pel_mask[j] |= ((pel[j] & 0x0F000000) != 0) << 6;
  308. pel_mask[j] |= ((pel[j] & 0x00F00000) != 0) << 5;
  309. pel_mask[j] |= ((pel[j] & 0x000F0000) != 0) << 4;
  310. pel_mask[j] |= ((pel[j] & 0x0000F000) != 0) << 3;
  311. pel_mask[j] |= ((pel[j] & 0x00000F00) != 0) << 2;
  312. pel_mask[j] |= ((pel[j] & 0x000000F0) != 0) << 1;
  313. pel_mask[j] |= ((pel[j] & 0x0000000F) != 0);
  314. }
  315.  
  316. gprim_setpel(dim_x, dim_y, true, pel, pel_mask , 0, 0);
  317. gprim_pel(IabsX, IabsY);
  318.  
  319. }
  320. /*}}}*/
  321. 
Reputation Points: 10
Solved Threads: 1
Light Poster
Behi Jon is offline Offline
47 posts
since Nov 2008
Sep 8th, 2009
0

Re: Graphical Menu Design

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

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

Do you have a question?
Moderator
Featured Poster
Reputation Points: 4142
Solved Threads: 394
Industrious Poster
Nick Evan is offline Offline
4,132 posts
since Oct 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Pushing a button via winapi
Next Thread in C++ Forum Timeline: what was your first program?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC