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

📄 maindlg.c

📁 这个是boot gui的程序
💻 C
字号:
/*
 *  Start of Zoran Standard Header
 *  Copyright (c) 2005, 2006 Zoran Corporation
 *  
 *  
 *  All rights reserved.  Proprietary and confidential.
 *  
 *  DESCRIPTION for maindlg.c
 *      Main dialog
 *  
 *  NEW HISTORY COMMENT (description must be followed by a blank line)
 *  <Enter change description here>

 *  ===== HISTORY of changes in //depot/imgeng/sw/se_gw/gui/maindlg.c
 *  
 *   7/Feb/06 #13  dstrauss  Removed (commented out) unused menu entries: 
 *                           contrast, cyan, magenta, yellow, segmentation, 
 *                           postermode, n-up.
 *  26/Jan/06 #12  dstrauss  Allow user to go directly to a menu item by 
 *                           pressing one of the "settings" keys.
 *  24/Jan/06 #11  dstrauss  If a print error occurs, allow the user to 
 *                           restart the job by pressing the "select" key.
 *  13/Dec/05 #10  dstrauss  Reordered menu.
 *                           Fixed bug in saving values on Up or Down key.
 *  13/Dec/05 #9  dstrauss   Added Photo Size menu item; dispatch to image
 *                           selection dialog when appropriate.
 *  12/Dec/05 #8  dstrauss   Deleted uiwindows.h
 *  12/Dec/05 #7  dstrauss   GPMIncrementDisplayValue and 
 *                           GPMDecrementDisplayValue now handle out-of-bounds 
 *                           values automatically.
 *  12/Dec/05 #6  dstrauss   Allow the cursor to be "normal", "modified", 
 *                           or "erase" color.
 *   9/Dec/05 #5  dstrauss   Call GUIUpdateStatus() every tick.  Allow jobs to
 *                           be canceled.  Set status to "Ready" at startup.
 *   7/Dec/05 #3  dstrauss   Implement value increment/decrement
 *   6/Dec/05 #2  dstrauss   Added menu; implemented up/down scrolling.
 *   5/Dec/05 #1  dstrauss   Created
 *  
 *
 *  End of Zoran Standard Header
 */
#include "standard.h"

#include "vopu.h"
#include "guigraphics.h"
#include "guievents.h"
#include "dialogs.h"
#include "guiproperties.h"
#include "guiactions.h"
#include "guistatus.h"

/* this array defines the main menu, which consists
 * of an array of property id's.  The GUI properties
 * manager is used to look up attributes of each
 * ID, including its name, type, and value.
 */
static const guiPID mainMenu[] = {
  GPID_COPIES,
  GPID_QUALITY,
  GPID_SCALE,
  GPID_PAPERTYPE,
  GPID_PAPERSIZE,
  GPID_MODE,
  GPID_PHOTOSIZE,
  GPID_BRIGHTNESS,
  //GPID_CONTRAST,
  //GPID_CYAN,                    /* cyan adjustment level */
  //GPID_MAGENTA,                 /* magenta adjustment level */
  //GPID_YELLOW,                  /* yellow adjustment level */
  //GPID_SEGMENTATION,
  //GPID_POSTERMODE,
  //GPID_NUP                      /* N-UP setting */
};

/* The following defines set up the menu organization */

/* number of items in the menu */
#define MENUITEMS (sizeof(mainMenu)/sizeof(mainMenu[0]))

/* number of items which can be displayed on the screen */
#define SCREENITEMS 4

/* Y position of the first menu item on the screen */
#define FIRSTLINE 46

/* Spacing between menu items on the screen */
#define YINCR 36

/* Column for item names */
#define NAMECOLUMN 4

/* Column for item values */
#define VALUECOLUMN (VopuWidth()/2 + 24)

/* Cursor location.  Index into the mainMenu array which points
 * to the currently active menu item. 
 */
static int cursor;

/* Window pointer.  Index into the mainMenu array which points
 * to TOP line of the items currently displayed on the screen.
 * The combination of the window pointer and the cursor determins
 * while lines are displayed on the screen.
 */
static int topline;

/* displayCursor - display the cursor box around the current "value".
 * Implicit inputs are "cursor" and "topline".
 * If "erase" is TRUE erase the cursor box instead of drawing it.
*/
static void displayCursor(int erase)
{
  int currentY = FIRSTLINE;
  int Yincr = YINCR;
  int valueX = VALUECOLUMN;
  int linecount;
  eCursorColor color;

  /* figure out where the cursor box should go */
  for (linecount = topline; linecount < topline + SCREENITEMS; linecount++) {
    if (linecount == cursor) {
      /* we found the cursor location */
      if (erase) {
        color = eCCErase;
      } else {
        if (GPMIsValueModified(mainMenu[linecount])) {
          color = eCCModified;
        } else {
          color = eCCNormal;
        }
      }
      GUICursorBox(valueX - 2, currentY - 2, 150, 36, color);
      break;
    }
    currentY += Yincr;
  }
}

/* displayMenuValue - display current value pointed to by the
 * cursor.  Implicit inputs are "cursor", "topline", and "mainMenu"
 *
 * If "erase" is TRUE, erase the menu item value from the screen instead 
 * drawing it.
 */
static void displayMenuValue(int erase)
{
  int currentY = FIRSTLINE;
  int Yincr = YINCR;
  int valueX = VALUECOLUMN;
  int linecount;

  /* figure out where the current value should go */
  for (linecount = topline; linecount < topline + SCREENITEMS; linecount++) {
    if (linecount == cursor) {
      /* we found the cursor location */
      const char * itemvalue;
      itemvalue = GPMGetDisplayValue(mainMenu[linecount]);
      GUIText(valueX, currentY, itemvalue, erase);
      break;
    }
    currentY += Yincr;
  }
}

/* displayMenu - display menu based on current cursor and topline settings.
 * Implicit inputs are "cursor", "topline", and "mainMenu"
 *
 * If "erase" is TRUE, erase the menu from the screen instead 
 * drawing it.
 */
static void displayMenu(int erase)
{
  int currentY = FIRSTLINE;
  int Yincr = YINCR;
  int nameX = NAMECOLUMN;
  int valueX = VALUECOLUMN;
  int linecount;

  for (linecount = topline; linecount < topline + SCREENITEMS; linecount++) {
    const char * itemname;
    const char * itemvalue;
    itemname = GPMGetName(mainMenu[linecount]);
    GUIText(nameX, currentY, itemname, erase);
    itemvalue = GPMGetDisplayValue(mainMenu[linecount]);
    GUIText(valueX, currentY, itemvalue, erase);
    currentY += Yincr;
  }
  displayCursor(erase);
}


/* find the menu index for a particular item.  Returns index (>= 0)
   if successful else -1 */
static int getIndexforItem(int itemID)
{
  int itemIndex;

  for (itemIndex = 0; itemIndex < MENUITEMS; itemIndex++) {
    if (mainMenu[itemIndex] == (guiPID)itemID) {
      return (itemIndex);
    }
  }
  return (-1);
}

/* Go to a particular entry on the menu */
void GUIActionMainMenuGotoItem(int itemID)
{
  int newCursor;
  int newtopline;

  newCursor = getIndexforItem(itemID);
  if (newCursor >= 0) {
    /* do something only if we found the item in the menu */
    if (cursor != newCursor) {
      /* do something only if the cursor changed */
      newtopline = topline;
      if (newtopline > newCursor) {
        newtopline = newCursor;
      }
      if (newCursor >= newtopline + SCREENITEMS) {
        newtopline = newCursor;
      }
      if (newtopline + SCREENITEMS > MENUITEMS) {
        newtopline = MENUITEMS - SCREENITEMS;
      }
      cursor = newCursor;     /* set new values */
      topline = newtopline;
    }
  }
}

/* utility routine to handle the details surrounding a "go to this
   menu line" event.
 */
static void handleGotoEvent(int itemID)
{
  int oldCursor;
  int oldTopline;
  int newcursor;
  int newtopline;

  /* save the value at the current cursor before we move the cursor */
  GPMSaveDisplayValue(mainMenu[cursor]);

  oldCursor = cursor;           /* save the cursor and topline */
  oldTopline = topline;

  /* update cursor and topline to new values */
  GUIActionMainMenuGotoItem(itemID);
  newcursor = cursor;           /* save new cursor and topline values */
  newtopline = topline;
  cursor = oldCursor;           /* resture old cursor and topline */
  topline = oldTopline;

  /* repaint the menu if necessary */
  if (newtopline != topline) {
    displayMenu(TRUE);      /* erase old menu items */
    cursor = newcursor;     /* set new values */
    topline = newtopline;
    displayMenu(FALSE);     /* display new menu items */
  } else {
    displayCursor(TRUE);
    cursor = newcursor;     /* set new value */
    displayCursor(FALSE);
  }
}

/* main dialog entrypoint */
void * MainDialog(unsigned int event)
{
  switch (event) {
  case GUIEVENT_REPAINT:
    GUIPaintLogo(10, 4);
    displayMenu(FALSE);
    GUISetStatus(GStatusReady);
    break;

  case GUIEVENT_KEY_UP_DOWN:    /* the "up" key has been pressed */
    {
      int newcursor;
      int newtopline;

      newcursor = cursor;
      newtopline = topline;

      newcursor--;
      if (newcursor < 0) {
        newcursor = 0;
      }
      if (newcursor < newtopline) {
        newtopline--;
      }
      if (newtopline < 0) {
        newtopline = 0;
      }
      if (newcursor != cursor) {
        GPMSaveDisplayValue(mainMenu[cursor]);
        if (newtopline != topline) {
          displayMenu(TRUE);      /* erase old menu items */
          cursor = newcursor;     /* set new values */
          topline = newtopline;
          displayMenu(FALSE);     /* display new menu items */
        } else {
          displayCursor(TRUE);
          cursor = newcursor;     /* set new value */
          displayCursor(FALSE);
        }
      }
    }
    break;

  case GUIEVENT_KEY_DOWN_DOWN:  /* the "down" key has been pressed */
    {
      int newcursor;
      int newtopline;

      newcursor = cursor;
      newtopline = topline;

      newcursor++;
      if (newcursor >= MENUITEMS) {
        newcursor = MENUITEMS - 1;
      }
      if (newcursor >= newtopline + SCREENITEMS) {
        newtopline++;
      }
      if (newcursor != cursor) {
        GPMSaveDisplayValue(mainMenu[cursor]);
        if (newtopline != topline) {
          displayMenu(TRUE);      /* erase old menu items */
          cursor = newcursor;     /* set new values */
          topline = newtopline;
          displayMenu(FALSE);     /* display new menu items */
        } else {
          displayCursor(TRUE);
          cursor = newcursor;     /* set new value */
          displayCursor(FALSE);
        }
      }
    }
    break;

  case GUIEVENT_KEY_SELECT_DOWN:    /* the "select" key has been pressed */
    if (GPMIsValueModified(mainMenu[cursor])) {
      /* save whichever value we're currently pointing to */
      GPMSaveDisplayValue(mainMenu[cursor]);
      displayCursor(TRUE);      /* erase old cursor */
      displayCursor(FALSE);     /* display new cursor */
    } else if (GUIGetStatus() == GStatusPrinting) {
      GUIActionRestartJob();
    }
    break;


  case GUIEVENT_KEY_CANCEL_DOWN:    /* the "cancel" key has been pressed */
    if (GPMIsValueModified(mainMenu[cursor])) {
      /* if a value has been modified, cancel the changes */
      displayMenuValue(TRUE);   /* erase old menu item value*/
      displayCursor(TRUE);      /* erase old cursor */
      GPMRestoreDisplayValue(mainMenu[cursor]);
      displayMenuValue(FALSE);  /* display new menu item value*/ 
      displayCursor(FALSE);     /* display new cursor */
    } else if (GUIGetStatus() == GStatusPrinting) {
      int didCancel;
      didCancel = GUIActionCancelJob();
      if (didCancel) {
        GUISetStatus(GStatusCanceling);
      }
    }
    break;

  case GUIEVENT_KEY_LEFT_DOWN:    /* the "left" key has been pressed */
    displayMenuValue(TRUE);   /* erase old menu item value*/
    displayCursor(TRUE);      /* erase old cursor */
    GPMDecrementDisplayValue(mainMenu[cursor]); /* decrement value */
    displayMenuValue(FALSE);  /* display new menu item value*/
    displayCursor(FALSE);     /* display new cursor */
    break;

  case GUIEVENT_KEY_RIGHT_DOWN:    /* the "left" key has been pressed */
    displayMenuValue(TRUE);   /* erase old menu item value*/
    displayCursor(TRUE);      /* erase old cursor */
    GPMIncrementDisplayValue(mainMenu[cursor]);
    displayMenuValue(FALSE);  /* display new menu item value*/
    displayCursor(FALSE);     /* display new cursor */
    break;

  case GUIEVENT_KEY_COPIES_DOWN:
    /* go to the copies menu item */
    handleGotoEvent(GPID_COPIES);
    break;

  case GUIEVENT_KEY_SCALE_DOWN:
    /* go to the scale menu item */
    handleGotoEvent(GPID_SCALE);
    break;

  case GUIEVENT_KEY_BRIGHTNESS_DOWN:
    /* go to the brightness menu item */
    handleGotoEvent(GPID_BRIGHTNESS);
    break;

  case GUIEVENT_KEY_QUALITY_DOWN:
    /* go to the quality menu item */
    handleGotoEvent(GPID_QUALITY);
    break;

  case GUIEVENT_KEY_PAPERTYPE_DOWN:
    /* go to the papertype menu item */
    handleGotoEvent(GPID_PAPERTYPE);
    break;

  case GUIEVENT_KEY_MODE_DOWN:
    /* go to the mode menu item */
    handleGotoEvent(GPID_MODE);
    break;

  case GUIEVENT_KEY_MONOPHOTO_DOWN:
  case GUIEVENT_KEY_COLORPHOTO_DOWN:
    /* check if a memory card is inserted and switch to the image
     * selection screen if it is
     */
    if (GUIMemcardReady()) {
      displayMenu(TRUE);        /* erase menu */
      return ((void *)ImageSelectDialog);
    }
    break;

  case GUIEVENT_KEY_COLORCOPY_DOWN: /* the "color copy" key has been pressed */
    GUIActionCopyJobColor();
    break;

  case GUIEVENT_KEY_MONOCOPY_DOWN: /* the "color copy" key has been pressed */
    GUIActionCopyJobMono();
    break;

  case GUIEVENT_TICK:
    GUIUpdateStatus();
    break;

  default:                  /* ignore events not explicitly handled */
    break;
  }

  return (NULL);
}

⌨️ 快捷键说明

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