⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pcd_m.c

📁 Zoran VP2K731 DVD源代码,极具参考价值!
💻 C
📖 第 1 页 / 共 5 页
字号:
  0x0607,
  0x0809
};

static const NEW_MS_WIDGET nmsw =
{
  MS_ASCII | MS_HOT_SPOT,
  ALIGN_CENTER,
  I_COLOR,
  {0, 0, MP3M_BUTTON_WIDTH, MS_LINE_HEIGHT},
  NO_PARENT,
  override_button_user_op
};
#endif // DISABLE

static void initButton( int iItemNum )
{
  MS_BUTTON *msb = &gmp3m.msbTrack[iItemNum];
  MS_WIDGET *msw = (MS_WIDGET *) msb;

  memcpy( msb, &msbProto, sizeof(msbProto) );
  
  msw->pos.x = button_pos_x(iItemNum);
  msw->pos.y = button_pos_y(iItemNum);

  msb->present.text = (void *) gmp3m.szButtonNumber[iItemNum];

  MS_add_item((MS_DIALOG *) screen, msw, ((iItemNum == 0) ? C_FOCUSED : !C_FOCUSED) );
};

static void initFilename( int iItemNum )
{
  MS_WIDGET *msw = (MS_WIDGET *) &gmp3m.mssTrack[iItemNum];
  
  memcpy( msw, &mssProto, sizeof(mssProto));

  msw->pos.x = name_pos_x(iItemNum);
  msw->pos.y = name_pos_y(iItemNum);
  
  ((MS_STATIC *) msw)->text = 0;

  MS_add_item((MS_DIALOG *) screen, msw, !C_FOCUSED);
}

static void initListItem( int iItemNum )
{
  initButton( iItemNum );
  initFilename( iItemNum );
}

static void hideListItem( int iItemNum )
{
  SetButton(iItemNum, -1);
  SetFilename(iItemNum, -1);
  SET_NONSELECTABLE( &(gmp3m.msbTrack[iItemNum].present) );
}

// -----------------------------------------------------------
//
// List files for the current directory starting at iFileIndex
// All items in the menu will be filled unless the end of
// end of directory is reached.
//
// Updates:
//
// gmp3m.dirBounds.iFirstFileIndex
// gmp3m.dirBounds.iLastFileIndex
// gmp3m.dirBounds.iLastItemNum
//
// gmp3m.firstDisplayed.iFileIndex
// gmp3m.lastDisplayed.iFileIndex
// gmp3m.lastDisplayed.iItemNum
// 
static void list_files(int iFileIndex)
{
  // We always start at the first list item
  int iItemNum = 0;

  // These are scratch for receiving the return parameters of file_list_get
  DWORD dwLbn;
  DWORD dwSize;
  char *szFilename;
  
  // Initialize so first displayed file will be detected
  gmp3m.firstDisplayed.iFileIndex = -1;
  // REMINDER rework the structure if this isn't needed:
  gmp3m.firstDisplayed.iItemNum = -1;

  // These should be invalid until the first file is detected
  gmp3m.lastDisplayed.iFileIndex = -1;
  gmp3m.lastDisplayed.iItemNum = -1;

  // This should be invalid until the first file is detected
  gmp3m.dirBounds.iLastItemNum = -1;

  // Handle all list items in some manner
  while ( iItemNum < MAX_DISPLAY_TRACKS )
  {
	if ( iFileIndex >= g_file_list_count )
	{
	  hideListItem(iItemNum);
	  iItemNum++;

	  continue;
	}

	// Get the file information from the file list
	file_list_get( iFileIndex, &dwLbn, &dwSize, &szFilename );
	
	// If we haven't reached the correct directory yet, skip this file
	if ( go_TmpFileRec.DirNum < gmp3m.iDirNum )
	{
	  iFileIndex++;
	}
	else
	// The directory matches, so set the list item and adjust our navigation information
	if ( go_TmpFileRec.DirNum == gmp3m.iDirNum )
	{
	  setListItem(iItemNum, iFileIndex);

	  // Remember the first file in the directory and its item number
	  if ( gmp3m.dirBounds.iFirstFileIndex < 0 )
	  {
		gmp3m.dirBounds.iFirstFileIndex = iFileIndex;
	  }

	  // We must test this because we can scroll backwards
	  // Remember the last item and file in the directory
	  if ( gmp3m.dirBounds.iLastFileIndex < iFileIndex )
	  {
		gmp3m.dirBounds.iLastFileIndex = iFileIndex;
		gmp3m.dirBounds.iLastItemNum = iItemNum;
	  }

	  // Remember the first displayed file and its item number
	  if ( gmp3m.firstDisplayed.iFileIndex < 0 )
	  {
		gmp3m.firstDisplayed.iFileIndex = iFileIndex;
		gmp3m.firstDisplayed.iItemNum = iItemNum;
	  }

	  // Always set the last displayed file and its item number
	  gmp3m.lastDisplayed.iItemNum = iItemNum;
	  gmp3m.lastDisplayed.iFileIndex = iFileIndex;

	  SET_SELECTABLE(&(gmp3m.msbTrack[iItemNum].present));

	  iItemNum++;
	  iFileIndex++;
	}
	else
	{
	  hideListItem(iItemNum);
	  iItemNum++;
	}
  }

  // if (last file in directory < next file) and (all items displayed and more files can be listed)
  // look ahead to see if the next file is in the same directory
  if ( (gmp3m.dirBounds.iLastFileIndex < iFileIndex) && (gmp3m.lastDisplayed.iItemNum == (MAX_DISPLAY_TRACKS - 1)) && (gmp3m.dirBounds.iLastFileIndex < (g_file_list_count - 1)) )
  {
	// Get the file information from the file list
	file_list_get( iFileIndex, &dwLbn, &dwSize, &szFilename );
	
	// Remember if the next file is in the same directory, adjust the navigation 
	if ( go_TmpFileRec.DirNum == gmp3m.iDirNum )
	{
	  gmp3m.dirBounds.iLastFileIndex = iFileIndex;
	}	
  }

  MS_change_focus((MS_DIALOG *)screen, (MS_WIDGET *) &gmp3m.msbTrack[gmp3m.firstDisplayed.iItemNum]);
}

static void update_scroll_statics(void)
{
#ifdef DISABLE
  if ( !can_scroll( !B_SCROLL_FORWARD ) )
  {
	MS_hide( (MS_WIDGET *) &mssScrollBack, (MS_DIALOG *) screen );
  }

  if ( !can_scroll( B_SCROLL_FORWARD ) )
  {
	MS_hide( (MS_WIDGET *) &mssScrollForward, (MS_DIALOG *) screen );
  }
#endif // DISABLE
}

static void scroll_forward( void )
{
#ifdef D_PICTURE_CD_ENABLED
	if ( !IS_STATE(MP3M_STATE_IMAGE_OPEN) )
#endif // D_PICTURE_CD_ENABLED
		mp3m_erase_menu();

  // gmp3.dirBounds.iFirstFileIndex, gmp3_dirBounds.iLastFileIndex should still be valid

	list_files( gmp3m.firstDisplayed.iFileIndex + ITEMNUM_COLUMN2 );

#ifdef D_PICTURE_CD_ENABLED
	if ( !IS_STATE(MP3M_STATE_IMAGE_OPEN) )
#endif // D_PICTURE_CD_ENABLED
	{
	// REMINDER We need to disable the erase in MS_display for use here
	  MS_refresh((MS_DIALOG *) screen);

	  update_scroll_statics();
	}
}

static void scroll_backward( void )
{
#ifdef D_PICTURE_CD_ENABLED	//ZORAN DM1112 copy from scroll_forward()
	if ( !IS_STATE(MP3M_STATE_IMAGE_OPEN) )
#endif // D_PICTURE_CD_ENABLED
  mp3m_erase_menu();

  // gmp3.dirBounds.iFirstFileIndex, gmp3_dirBounds.iLastFileIndex should still be valid

  list_files( gmp3m.firstDisplayed.iFileIndex - ITEMNUM_COLUMN2 );
#ifdef D_PICTURE_CD_ENABLED //ZORAN DM1112 copy from scroll_forward()
	if ( !IS_STATE(MP3M_STATE_IMAGE_OPEN) )
#endif // D_PICTURE_CD_ENABLED
	{

  MS_refresh((MS_DIALOG *) screen);

  update_scroll_statics();
	}
}

static MS_UOP override_button_user_op(MS_WIDGET *widget,MS_UOP uop,char param) 
{
	MS_BUTTON *button = (MS_BUTTON *)widget;
	if ( uop == MS_UOP_ENTER )
	{
	  gmp3m.iButtonNumber = button_number(widget);

#ifdef NO_C_STDLIB
	  rtouts("\niButtonNumber set to "); rtouti(gmp3m.iButtonNumber);
#endif // NO_C_STDLIB
	}
	uop = button_user_op(widget, uop, param);
	if ( uop != MS_UOP_NOP )
	{
	  switch (uop)
	  {
		  case MS_UOP_LEFT:
#ifdef NO_C_STDLIB
			  rtouts("\noverride_button_user_op: left key");
			  if ( widget->pos.x == MP3M_BUTTON_COLUMN_1 )
			  {
				if ( can_scroll(!B_SCROLL_FORWARD) )
				{
				  rtouts("\nCan scroll backward");

				  scroll_backward();

				  uop = 0;
				}
				else
				{
				  rtouts("\nCan't scroll backward");
				}
			  }
#endif
			  break;

		  case MS_UOP_RIGHT:
#ifdef NO_C_STDLIB
			  rtouts("\noverride_button_user_op: right key");
			  if ( widget->pos.x == MP3M_BUTTON_COLUMN_2 )
			  {
				if ( can_scroll(B_SCROLL_FORWARD) )
				{
				  rtouts("\nCan scroll forward");

				  scroll_forward();

				  uop = 0;
				}
				else
				{
				  rtouts("\nCan't scroll forward");
				}
			  }
#endif
			  break;

		  case MS_UOP_UP:
#ifdef NO_C_STDLIB
			  rtouts("\noverride_button_user_op: up key");
#endif
			  break;

		  case MS_UOP_DOWN:
#ifdef NO_C_STDLIB
			  rtouts("\noverride_button_user_op: down key");
#endif
			  break;
	  }
	}
	return uop;
}

#ifdef DISABLE
MS_BUTTON msbTrack_1 =
{
  { // MS_STATIC

	{ // MS_WIDGET
	  MS_HOT_SPOT,
	  ALIGN_CENTER,
	  I_COLOR,
	  TRACK_1_BUTTON_POS,
	  NO_PARENT,
	  override_button_user_op
	},

	(void *)S_1
  },

  track_1_action
};

MS_STATIC mss_track_1 =
{
  {
	MS_ASCII | MS_STRING_ON_SC,
	ALIGN_LEFT_PAD,
	I_COLOR,
	TRACK_1_NAME_POS,
	NO_PARENT,
	static_user_op,
  },

  NULL
};

MS_BUTTON msbTrack_2 =
{
  { // MS_STATIC

	{ // MS_WIDGET
	  MS_HOT_SPOT,
	  ALIGN_CENTER,
	  I_COLOR,
	  TRACK_2_BUTTON_POS,
	  NO_PARENT,
	  override_button_user_op
	},

	(void *)S_2
  },

  track_2_action
};

MS_STATIC mss_track_2 =
{
  {
	MS_ASCII | MS_STRING_ON_SC,
	ALIGN_LEFT_PAD,
	I_COLOR,
	TRACK_2_NAME_POS,
	NO_PARENT,
	static_user_op,
  },

  NULL
};

MS_BUTTON msbTrack_3 =
{
  { // MS_STATIC

	{ // MS_WIDGET
	  MS_HOT_SPOT,
	  ALIGN_CENTER,
	  I_COLOR,
	  TRACK_3_BUTTON_POS,
	  NO_PARENT,
	  override_button_user_op
	},

	(void *)S_3
  },

  track_3_action
};

MS_STATIC mss_track_3 =
{
  {
	MS_ASCII | MS_STRING_ON_SC,
	ALIGN_LEFT_PAD,
	I_COLOR,
	TRACK_3_NAME_POS,
	NO_PARENT,
	static_user_op,
  },

  NULL
};
#endif // DISABLE

// <<< ZORAN CDE0924 : Implement PictureCD Browser (allocate dynamically and add to mp3m)
#ifdef D_PICTURE_CD_ENABLED
#else
static const MS_STATIC mssMenuTitle = {
	{
	  0,
	  ALIGN_LEFT,
	  I_COLOR,
	  {0, MS_LINE_0, 48, MS_LINE_HEIGHT},
	  NO_PARENT,
	  static_user_op,
	},

	(void *)S_MP3
};
#endif // D_PICTURE_CD_ENABLED
// ZORAN CDE0924 >>>

// Constants and macros for dynamically allocated statics
#ifdef D_PICTURE_CD_ENABLED

#define MP3M_FONT_WIDTH		  12

#define MSS_TITLE_X				0

#define MP3M_MSS_TITLE_WIDTH	(3 * MP3M_FONT_WIDTH + 8)
#define PCDM_MSS_TITLE_WIDTH	(9 * MP3M_FONT_WIDTH)

#define NEXT_X(_pWidget_)		(((MS_WIDGET *)(_pWidget_))->pos.x + ((MS_WIDGET *)(_pWidget_))->pos.w + 8)

#define MSS_DIRNAME_X			NEXT_X(gmp3m.pmssMenuTitle)
#define PCDM_MSS_DIRNAME_X		(MSS_TITLE_X + PCDM_MSS_TITLE_WIDTH + 8)
#define MSS_DIRNAME_WIDTH		(DIRNAME_SZ * MP3M_FONT_WIDTH + 8)

#define MSS_TMP_MSG_X			NEXT_X(gmp3m.pmssDirName)
#define PCDM_MSS_TMP_MSG_X		(PCDM_MSS_DIRNAME_X + MSS_DIRNAME_WIDTH + 8)
#define MSS_TMP_MSG_WIDTH		(8 * MP3M_FONT_WIDTH)

#else // D_PICTURE_CD_ENABLED

#define MSS_DIRNAME_X	  56
// <<< ZORAN CDE0711 : Fix long directory name bug
#ifdef DISABLE
#define MSS_DIRNAME_WIDTH	  (DIRNAME_SZ * 8 + 8)
#else
#define MP3M_FONT_WIDTH		  24
#define MSS_DIRNAME_WIDTH	  (DIRNAME_SZ * MP3M_FONT_WIDTH + 8)
#endif // DISABLE
// ZORAN CDE0711 >>>

static MS_STATIC mssDirName =
{
	{
	  MS_HOT_SPOT | MS_ASCII | MS_STRING_ON_SC,
	  ALIGN_LEFT_PAD,
	  BUTTON_COLOR,
	  {MSS_DIRNAME_X, MS_LINE_0, MSS_DIRNAME_WIDTH, MS_LINE_HEIGHT},
	  NO_PARENT,
	  dirName_user_op,
	},

	(void *)NULL
};

#define TMP_X	(MSS_DIRNAME_X + MSS_DIRNAME_WIDTH)

static const MS_STATIC tmp_msg = {
	{
	MS_STRING_ON_SC,
	ALIGN_LEFT_PAD,
	I_COLOR,
	{TMP_X, MS_LINE_0, 120, MS_LINE_HEIGHT},

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -