示例#1
0
文件: IRexxApp.cpp 项目: Jaxo/yaxx
/*------------------------------------------------CIRexxApp::NewScriptIndexDB-+
| Load the scripts DB                                                         |
+----------------------------------------------------------------------------*/
void CIRexxApp::NewScriptIndexDB()
{
   //<<<JAL since searching for many scripts can be slow,
   //       we draw a little indicator at the start.
   //       palm os does provide a set of progress functions,
   //       but their progress dialog is too much for something simple.
   Err err;
   RectangleType saveFrame;
   WinHandle saveWindow = 0;
   if (WinGetDrawWindow()) { // If we can't draw yet, forget it!
      const char * s = getRexxAppMessage(msgRexxIsStarting); // the text in the rectangle
      const int wFrame = 2; // the width of dialogFrame
      const int padding = 2; // padding for the text in the rectangle
      Int16 w = FntCharsWidth(s, StrLen(s)) + (padding * 2);
      Int16 h = FntCharHeight() + (padding * 2);
      RectangleType r;
      RctSetRectangle(&r, (160-w)/2, (160-h)/2, w, h);
      RctSetRectangle(&saveFrame,
         r.topLeft.x-wFrame, r.topLeft.y-wFrame, r.extent.x+(wFrame*2), r.extent.y+(wFrame*2));
      saveWindow = WinSaveBits(&saveFrame, &err);
      WinDrawRectangleFrame(dialogFrame, &r);
      WinDrawChars(s, StrLen(s), r.topLeft.x+padding, r.topLeft.y+padding);
   }
   initializeIndexDatabase();
   if (saveWindow) {
      WinRestoreBits(saveWindow, saveFrame.topLeft.x, saveFrame.topLeft.y);
   }
   return;
}
示例#2
0
/***********************************************************************
 *
 * FUNCTION:    PrvTimeZoneListDrawItem
 *
 * DESCRIPTION: Draw the itemNum item of the time zone list. Used as draw
 *		callback routine for the time zone list object.
 *
 * PARAMETERS:
 *		itemNum		 ->	what item to draw
 *		bounds		 ->	rectangle to draw into 
 *		itemsText	 ->	ptr to array of TimeZoneEntryType records.
 *
 * RETURNED: nothing	
 *
 * HISTORY:
 *		03/07/00	peter	initial revision
 *		07/31/00	kwk	Modified to use TimeZoneEntryType records.
 *
 ***********************************************************************/
static void PrvTimeZoneListDrawItem(Int16 itemNum, RectanglePtr bounds, Char** itemsText)
{
	const TimeZoneEntryType* tzList = (const TimeZoneEntryType*)itemsText;
	Char gmtOffset[maxGmtOffsetLength + 1];
	
	// Skip to appropriate item to draw.
	tzList += itemNum;
	
	// Draw the name left-justified, and truncated.
	// DOLATER kwk - should we worry about the text in ZeroTimeZoneOffsetString
	// being wider than gmtOffsetColumnWidth?
	WinDrawTruncChars(tzList->tzName,
							StrLen(tzList->tzName),
							bounds->topLeft.x + descriptionColumnOffset,
							bounds->topLeft.y,
							usableListWidth - descriptionColumnOffset - gmtOffsetColumnWidth);
	
	// Draw the offset right-justified.
	if (tzList->tzOffset == 0)
	{
		SysCopyStringResource(gmtOffset, ZeroTimeZoneOffsetString);
	}
	else
	{
		PrvOffsetToString(gmtOffset, tzList->tzOffset);
	}
	
	WinDrawChars(	gmtOffset,
						StrLen(gmtOffset),
						bounds->topLeft.x + usableListWidth - gmtColumnOffset - FntCharsWidth(gmtOffset, StrLen(gmtOffset)),
						bounds->topLeft.y);
} // PrvTimeZoneListDrawItem
示例#3
0
void Graphics::drawText(const char_t* text, ulong_t length, const Point& topLeft, bool inverted)
{
    FontEffects fx = font_.effects();    
    PalmUnderlineSetter setUnderline(convertUnderlineMode(fx.underline()));

    ScalingSetter setScaling(*this);

    uint_t height = fontHeight();
    uint_t top=topLeft.y;
    if (fx.subscript())
        top+=(height/3);
    if (inverted)
        WinDrawInvertedChars(text, length, topLeft.x, top);
    else         
        WinDrawChars(text, length, topLeft.x, top);

    if (fx.strikeOut())
    {
        uint_t baseline = fontBaseline();
        top=topLeft.y + (baseline*2)/3;
        uint_t width = FntCharsWidth(text, length);
        Color_t color=setTextColor(0);
        setTextColor(color); // Quite strange method of querying current text color...
        color=setForegroundColor(color);
        WinDrawOperation old;
        if (inverted)
            old=WinSetDrawMode(winInvert);
        drawLine(topLeft.x, top, topLeft.x+width, top);
        if (inverted)
            WinSetDrawMode(old);
        setForegroundColor(color);
    }
  }
示例#4
0
文件: Window.c 项目: ycheng/APDA
////////////////////////////////////////////////////////////////////////
// FUNCTION:    WinDrawTruncChars
//
// DESCRIPTION: This routine draw the specified characters in the draw
//					 window, truncating the characters to the specified width.
//
// PARAMETERS:  (const Char *) chars - Pointer to the characters to draw
//					 (Int16) len - Length in bytes of the characters to draw.
//					 (Coord) x - x coordinate of the location where the
//							characters is to be drawn.
//					 (Coord) y - y coordinate of the location where the
//							characters is to be drawn.
//					 (Coord) maxWidth - Maximum width in pixel of the characters
//							that are to be drawn.
//
// RETURNED:    Returns nothing.
//
// REVISION HISTORY:
//			Name	Date		Description
//			----	----		-----------
//			Jerry	5/29/01	Initial Revision
//			Jerry	9/13/01	Calculate the actual width instead of estimate
////////////////////////////////////////////////////////////////////////
void WinDrawTruncChars (const Char *chars, Int16 len, Coord x, Coord y, Coord maxWidth)
{
	int	strWidth = FntCharsWidth (chars, len);
	Int16	width=0, i, charWidth;

	if ( strWidth > maxWidth ) {
		for ( i = 0; i < len; i++ ) {
			charWidth = FntCharsWidth (&(chars[i]), 1);
			if ( (width + charWidth) > maxWidth ) 			
				break;
			else
				width += charWidth;
		}
	}

	VDrawChars (chars, i, x, y, COORD_STRETCH);
}
示例#5
0
// Right justify.
Short WinDrawChars_rj(Char *buf, Short len, Short x_right, Short y)
{
  Short x, width;
  width = FntCharsWidth(buf, len);
  x = x_right - width;
  if (x < 0) x = 0;
  WinDrawChars(buf, len, x, y);
  return x;
}
示例#6
0
// Draw text centered around x_mid, at y.
Short WinDrawChars_ctr(Char *buf, Short len, Short x_mid, Short y)
{
  Short x, width;
  width = FntCharsWidth(buf, len);
  x = x_mid - width / 2;
  if (x < 0) x = 0;
  WinDrawChars(buf, len, x, y);
  return x;
}
示例#7
0
文件: Window.c 项目: ycheng/APDA
////////////////////////////////////////////////////////////////////////
// FUNCTION:    WinDrawInvertedChars
//
// DESCRIPTION: This routine draw the specified characters inverted 
//					 (background color) in the draw window.
//
// PARAMETERS:  (const Char *) chars - Pointer to the characters to draw
//					 (Int16) len - Length in bytes of the characters to draw.
//					 (Coord) x - x coordinate of the location where the
//							characters is to be drawn.
//					 (Coord) y - y coordinate of the location where the
//							characters is to be drawn.
//
// RETURNED:    Returns nothing.
//
// REVISION HISTORY:
//			Name	Date		Description
//			----	----		-----------
//			Jerry	5/29/01	Initial Revision
//			Jerry 8/08/01	Modify call VDrawString to draw the invert color
////////////////////////////////////////////////////////////////////////
void WinDrawInvertedChars (const Char *chars, Int16 len, Coord x, Coord y)
{
	RectangleType	srcRect;

	srcRect.topLeft.x = x;
	srcRect.topLeft.y = y;
	srcRect.extent.x = FntCharsWidth (chars, len)+4;
	srcRect.extent.y = FntLineHeight();

	VDrawRect (&srcRect, PS_SOLID, 0, CL_FOREGROUND, COORD_PARTSTRETCH, DRAW_SET);
	VDrawString ((Coord)(VPDAToSysXCoord(x)+2), (Coord)(VPDAToSysYCoord(y)+1), 
			chars, len, SINGLELINE, CL_BACKGROUND, COORD_NORMAL);
}
示例#8
0
文件: Window.c 项目: ycheng/APDA
////////////////////////////////////////////////////////////////////////
// FUNCTION:    WinDrawTitleChars
//
// DESCRIPTION: This routine draw the specified characters inverted 
//					 (background color) in the draw window.
//
// PARAMETERS:  (const Char *) chars - Pointer to the characters to draw
//					 (Int16) len - Length in bytes of the characters to draw.
//					 (Coord) x - x coordinate of the location where the
//							characters is to be drawn.
//					 (Coord) y - y coordinate of the location where the
//							characters is to be drawn.
//
// RETURNED:    Returns nothing.
//
// REVISION HISTORY:
//			Name	Date		Description
//			----	----		-----------
//			Jerry	5/29/01	Initial Revision
//			Jerry 8/08/01	Modify call VDrawString to draw the invert color
////////////////////////////////////////////////////////////////////////
void WinDrawTitleChars (const Char *chars, Int16 len, Coord x, Coord y)
{
	RectangleType	srcRect;

	srcRect.topLeft.x = x;
	srcRect.topLeft.y = y;
	srcRect.extent.x = FntCharsWidth (chars, len)+4;
	srcRect.extent.y = VPDAToSysYRes(FntLineHeight());

	VDrawRect (&srcRect, PS_SOLID, 0, CL_FOREGROUND, COORD_PARTSTRETCH, DRAW_SET);
	VDrawString ((Coord)(x+1), (Coord)(y+FntLineHeight()/4), 
					chars, len, SINGLELINE, CL_BACKGROUND, COORD_STRETCH);
}
示例#9
0
/***********************************************************************
 *
 * FUNCTION:    FntWCharWidth
 *
 * DESCRIPTION: This routine returns the width of the specified character,
 *		which can be any valid character character. If the specified
 *		character does not exist within the current font, the Missing Char
 *		Symbol will be substituted.
 *
 * PARAMETERS:  ch   character whose width is desired
 *
 * RETURNED:    width of the specified character, in pixels
 *
 * HISTORY:
 *		05/12/00	kwk	Created by Ken Krugler from TxtCharWidth.
 *		05/17/00	kwk	Add call to TxtCharIsValid on debug ROMs.
 *
 ***********************************************************************/
Int16 FntWCharWidth(WChar iChar)
{
	Char buffer[maxCharBytes];

	if (iChar >= 0xFF80) {
		ErrNonFatalDisplay("Sign extended char passed to FntWCharWidth");
		iChar &= 0x00FF;
	}

	// On debug ROMs, make sure the character is valid (e.g. not a
	// virtual character).
	ErrNonFatalDisplayIf(!TxtCharIsValid(iChar), "Invalid char passed to FntWCharWidth");
	
	return(FntCharsWidth(buffer, TxtSetNextChar(buffer, 0, iChar)));
} // FntWCharWidth
示例#10
0
文件: Window.c 项目: ycheng/APDA
////////////////////////////////////////////////////////////////////////
// FUNCTION:    WinEraseChars
//
// DESCRIPTION: This routine erase the specified characters in the draw
//					 window.
//
// PARAMETERS:  (const Char *) chars - Pointer to the characters to draw
//				(Int16) len - Length in bytes of the characters to draw.
//				(Coord) x - x coordinate of the location where the
//							characters is to be drawn.
//				(Coord) y - y coordinate of the location where the
//							characters is to be drawn.
//
// RETURNED:    Returns nothing.
//
// REVISION HISTORY:
//			Name	Date		Description
//			----	----		-----------
//			Jerry	5/29/01	Initial Revision
//			Jerry	9/13/01	Calculate actual width instead of estimate value
////////////////////////////////////////////////////////////////////////
void WinEraseChars (const Char *chars, Int16 len, Coord x, Coord y)
{
	RectangleType	srcRect;

	srcRect.topLeft.x = x;
	srcRect.topLeft.y = y;
	srcRect.extent.x = FntCharsWidth (chars, len);
	srcRect.extent.y = FntCharHeight();

	if ( (srcRect.topLeft.x+srcRect.extent.x) > PDAWIDTH ) {
		srcRect.extent.x = PDAWIDTH - srcRect.topLeft.x;
	}

	VDrawRect (&srcRect, PS_SOLID, 0, CL_BACKGROUND, COORD_STRETCH, DRAW_SET);
}
示例#11
0
/*
** Initializes the transfer group structures.
*/
static void InitXferList(void) {
  SysDBListItemType* pluglistP = NULL;
  Char str[48];
  FormType* frm = FrmGetActiveForm();
  Int16 i = 0;
  Int16 width = 0;
  Int16 n = 0;

  /* Return if we've already initialized the plugin list */
  if (d.xfer.pluglistH) 
    return;

  /* Return if there are no plugins */
  if (!SysCreateDataBaseList('BooG', 0, &d.xfer.num_plugs,
			     &d.xfer.pluglistH, true)) {
    /* No databases found */
    d.xfer.pluglistH = NULL;
    d.xfer.num_plugs = 0;
    return;
  }

  /* This will unset the p.xfer_current_plug if it has been deleted */
  GetCurrentXferAppListIndex();
  /* Update the plug button */
  DrawPlugButton((DynamicButtonType*)FrmGetGadgetData(frm, FrmGetObjectIndex(frm, XferDetailsButton)));
  /* Update XferDone button */
  DrawXferDoneButton((DynamicButtonType*)FrmGetGadgetData(frm, FrmGetObjectIndex(frm, XferDoneButton)));

  /* Find the menu width and set it */
  pluglistP = MemHandleLock(d.xfer.pluglistH);
  for (; i < d.xfer.num_plugs; i++) {
    GetPlugString(i, boogerID_plugname, str);
    n = FntCharsWidth(str, StrLen(str));

    if ((pluglistP[i].version) & (IBVERSION_ORIG|IBVERSION_PICTURE))
      width = Max(width, n);
  }

  d.xfer.plug_menu_width = width + 25;

  /* Clean up */
  MemHandleUnlock(d.xfer.pluglistH);
}
示例#12
0
/* write document name in details form */
static void AddDocNameTitle
    (
    Char* name
    )
{
    FontID oldFont;
    Coord  x;
    Coord  y;
    
    UInt16 oldCoordSys;

    oldCoordSys = PalmSetCoordinateSystem( STANDARD );

    oldFont = FntSetFont( HiResFont( boldFont ) );
    x       = ( MaxExtentX() - FntCharsWidth( name, StrLen( name ) ) ) / 2;
    y       = 20;
    HiResAdjust( &y, sonyHiRes | handeraHiRes );
    WinDrawChars( name, StrLen( name ), x, y );
    FntSetFont( oldFont );

    PalmSetCoordinateSystem( oldCoordSys );
}
示例#13
0
/***********************************************************************
 *
 * FUNCTION:    DrawRecordName
 *
 * DESCRIPTION: Draws an address book record name.  It is used
 * for the list view and note view.
 *
 * PARAMETERS:  name1, name2 - first and seconds names to draw
 *              nameExtent - the space the names must be drawn in
 *              *x, y - where the names are drawn
 *
 * RETURNED:    x is set after the last char drawn
 *
 * REVISION HISTORY:
 *            Name        Date      Description
 *            ----        ----      -----------
 *            roger      6/20/95   Initial Revision
 *            frigino    970813    Rewritten. Now includes a variable ratio for
 *                             name1/name2 width allocation, a prioritization
 *                             parameter, and a word break search to allow
 *                             reclaiming of space from the low priority
 *                             name.
 *            jmjeong    99/12/22  Abridged version. make the num of
 *                                     parameters small
 *
 ***********************************************************************/
void DrawRecordName(
    char* name1, char* name2,
    UInt16 nameExtent, Int16 *x, Int16 y,
    Boolean center, Boolean priorityIsName1)
{
    Int16 name1MaxWidth;
    Int16 name2MaxWidth;
    Boolean ignored;
    Int16 totalWidth;
    Char * lowPriName;
    Int16 highPriNameWidth;
    Int16 lowPriNameWidth;
    Int16 highPriMaxWidth;
    Int16 lowPriMaxWidth;
    Char * spaceP;
    UInt16 shortenedFieldWidth;
    UInt16 fieldSeparatorWidth;
    Int16 name1Length, name1Width;
    Int16 name2Length, name2Width;

    shortenedFieldWidth =  FntCharsWidth(shortenedFieldString, 
                                         shortenedFieldLength);
    fieldSeparatorWidth = FntCharsWidth(fieldSeparatorString, 
                                        fieldSeparatorLength);

    if (*name1) {
        /* Only show text from the first line in the field */
        name1Length = nameExtent; /* longer than possible */
        name1Width = nameExtent;  /* wider than possible */
        FntCharsInWidth(name1, &name1Width, &name1Length, &ignored);
    } else {
        /* Set the name to the unnamed string */
        name1 = UnnamedRecordStringPtr;
        name1Length = StrLen(UnnamedRecordStringPtr);
        name1Width = FntCharsWidth(UnnamedRecordStringPtr,
                                   name1Length);
    }
      
    if (*name2) {
        /* Only show text from the first line in the field */
        name2Length = nameExtent; /* longer than possible */
        name2Width = nameExtent;  /* wider than possible */
        FntCharsInWidth(name2, &name2Width, &name2Length, &ignored);
    } else {
        name2Length = 0;
        name2Width = 0;
    }

    /* Check if both names fit */
    totalWidth = name1Width + (*name2 ? fieldSeparatorWidth : 0) + name2Width;

    /*
     * If we are supposed to center the names then move in the x position
     * by the amount that centers the text
     */
    if (center && (nameExtent > totalWidth)) {
        *x += (nameExtent - totalWidth) / 2;
    }

    /* Special case if only name1 is given */
    if (!*name2) {
        /*
         * For some reason, OS3 changed the code so that it doesn't show
         * ellipses if there is only name1.  I liked it the old way!
         */
        /* Does name1 fit in its maximum width? */
        if (name1Width > nameExtent) {
            /* No. Draw it to max width minus the ellipsis */
            name1Width = nameExtent-shortenedFieldWidth;
            FntCharsInWidth(name1, &name1Width, &name1Length, &ignored);
            WinDrawChars(name1, name1Length, *x, y);
            *x += name1Width;
            /* Draw ellipsis */
            WinDrawChars(shortenedFieldString, shortenedFieldLength, *x, y);
            *x += shortenedFieldWidth;
        } else {
            /* Yes. Draw name1 within its width */
            FntCharsInWidth(name1, &name1Width, &name1Length, &ignored);
            WinDrawChars(name1, name1Length, *x, y);
            *x += name1Width;
        }
        return;
    }

    /* Remove name separator width */
    nameExtent -= fieldSeparatorWidth;

    /* Test if both names fit */
    if ((name1Width + name2Width) <= nameExtent) {
        name1MaxWidth = name1Width;
        name2MaxWidth = name2Width;
    } else {
        /*
         * They dont fit. One or both needs truncation
         * Establish name priorities and their allowed widths
         * Change this to alter the ratio of the low and high
         * priority name spaces
         */
        highPriMaxWidth = (nameExtent << 1)/3; /* 1/3 to low and 2/3 to high */
        lowPriMaxWidth = nameExtent-highPriMaxWidth;

        /* Save working copies of names and widths based on priority */
        if (priorityIsName1) {
            /* Priority is name1 */
            highPriNameWidth = name1Width;
            lowPriName = name2;
            lowPriNameWidth = name2Width;
        } else {
            /* Priority is name2 */
            highPriNameWidth = name2Width;
            lowPriName = name1;
            lowPriNameWidth = name1Width;
        }

        /* Does high priority name fit in high priority max width? */
        if (highPriNameWidth > highPriMaxWidth) {
            /* No. Look for word break in low priority name */
            spaceP = StrChr(lowPriName, spaceChr);
            if (spaceP != NULL) {
                /* Found break. Set low priority name width to break width */
                lowPriNameWidth = FntCharsWidth(lowPriName, spaceP-lowPriName);
                /*
                 * Reclaim width from low pri name width to low pri max width,
                 * if smaller.
                 */
                if (lowPriNameWidth < lowPriMaxWidth) {
                    lowPriMaxWidth = lowPriNameWidth;
                    /* Set new high pri max width */
                    highPriMaxWidth = nameExtent-lowPriMaxWidth;
                }
            }
        } else {
            /* Yes. Adjust maximum widths */
            highPriMaxWidth = highPriNameWidth;
            lowPriMaxWidth = nameExtent-highPriMaxWidth;
        }

        /* Convert priority widths back to name widths */
        if (priorityIsName1) {
            /* Priority is name1 */
            name1Width = highPriNameWidth;
            name2Width = lowPriNameWidth;
            name1MaxWidth = highPriMaxWidth;
            name2MaxWidth = lowPriMaxWidth;
        } else {
            /* Priority is name2 */
            name1Width = lowPriNameWidth;
            name2Width = highPriNameWidth;
            name1MaxWidth = lowPriMaxWidth;
            name2MaxWidth = highPriMaxWidth;
        }
    }

    /* Does name1 fit in its maximum width? */
    if (name1Width > name1MaxWidth) {
        /* No. Draw it to max width minus the ellipsis */
        name1Width = name1MaxWidth-shortenedFieldWidth;
        FntCharsInWidth(name1, &name1Width, &name1Length, &ignored);
        WinDrawChars(name1, name1Length, *x, y);
        *x += name1Width;

        /* Draw ellipsis */
        WinDrawChars(shortenedFieldString, shortenedFieldLength, *x, y);
        *x += shortenedFieldWidth;
    } else {
        /* Yes. Draw name1 within its width */
        FntCharsInWidth(name1, &name1Width, &name1Length, &ignored);
        WinDrawChars(name1, name1Length, *x, y);
        *x += name1Width;
    }

    if (*name1 && *name2) {
        /* Draw name separator */
        WinDrawChars(fieldSeparatorString, fieldSeparatorLength, *x, y);
        *x += fieldSeparatorWidth;
    }
    
    /* Draw name2 within its maximum width */
    FntCharsInWidth(name2, &name2MaxWidth, &name2Length, &ignored);
    WinDrawChars(name2, name2Length, *x, y);
    *x += name2MaxWidth;
}
示例#14
0
/*
** TrackXferDone
*/
static void TrackXferDone(DynamicButtonType* btn) {
  RectangleType bounds[5], frame, popFrame, popShadowFrame;
  Boolean penDown, on_button;
  Int16 x, y, clicked_on = 0;
  Int16 state = 1;
  Int16 i = 0;
  WinHandle offscreenH = NULL;
  FormType* frm = FrmGetActiveForm();
  const UInt16 listIdx = FrmGetObjectIndex(frm, XferDoneList);
  ListType* list = FrmGetObjectPtr(frm, listIdx);
  UInt16 width = 0, choices = 0;
  Err err = errNone;
  Char str[48];
  Int16 n = 0;

  /* Save the old drawing context */
  WinPushDrawState();

  /* This should match the XferDoneButton bounds */
  FrmGetObjectBounds(frm, FrmGetObjectIndex(frm, btn->id), &bounds[0]);

  /* Invert the done button */
  SelectAndDrawButton(btn, true);
  SndPlaySystemSound(sndClick);

  /* Set the status of each menu pick */
  for (; i < 4; i++)
    d.xfer.status[i] = 0x00;
  
  if (xferGotoIsAlways)
    d.xfer.status[0] = TRACKXFERDONE_ALWAYS;
  else if (xferGotoIsNever)
    d.xfer.status[0] = TRACKXFERDONE_NEVER;
  else if (p.flags&PFLAGS_XFER_GOTO)
    d.xfer.status[0] = TRACKXFERDONE_CHECKED;

  if (xferCompleteIsAlways)
    d.xfer.status[1] = TRACKXFERDONE_ALWAYS;
  else if (xferCompleteIsNever)
    d.xfer.status[1] = TRACKXFERDONE_NEVER;
  else if (d.xfer.complete)
    d.xfer.status[1] = TRACKXFERDONE_CHECKED;

  if (!d.linker_available)
    d.xfer.status[2] = TRACKXFERDONE_NEVER;
  else if (p.flags&PFLAGS_XFER_BACKLINK)
    d.xfer.status[2] = TRACKXFERDONE_CHECKED;
  if (p.flags&PFLAGS_XFER_DELETE)
    d.xfer.status[3] = TRACKXFERDONE_CHECKED;

  for (i = 0; i < 4; ++i) {
    if (!(d.xfer.status[i] & TRACKXFERDONE_NEVER)) {
      d.xfer.choice_map[choices] = i;
      ++choices;

      /* calculate list width */
      SysCopyStringResource(str, XferMenuOptionsStrings + i);
      n = FntCharsWidth(str, StrLen(str));
      width = Max(width, n);
    }
  }

  LstSetDrawFunction(list, XferDoneListDrawFunc);
  LstSetListChoices(list, 0, choices);
  LstSetHeight(list, Min(choices, 10));
  FrmGetObjectBounds(frm, listIdx, &frame);
  frame.topLeft.y = 144 - frame.extent.y - 1; /* -1 to compensate for white border */
  frame.extent.x = width + 15 + 6;
  FrmSetObjectBounds(frm, listIdx, &frame);
  WinGetFramesRectangle(popupFrame, &frame, &popFrame);
  WinGetFramesRectangle(rectangleFrame, &popFrame, &popShadowFrame);

  for (i = 0; i < choices; ++i)
    RctSetRectangle(&bounds[i+1], frame.topLeft.x, frame.topLeft.y + 10 * i, 
		    frame.extent.x, 10);

  /* Save the bits of the whole menu */
  offscreenH = WinSaveBits(&popShadowFrame, &err);
  if (err) abort();

  /* None selected */
  LstSetSelection(list, -1);

  FrmShowObject(frm, listIdx);
  WinEraseRectangle(&popShadowFrame, 0);
  LstDrawList(list);
  WinEraseRectangleFrame(rectangleFrame, &frame);
  WinDrawRectangleFrame(popupFrame, &frame);

  do {
    EvtGetPen(&x, &y, &penDown);
    if (!state || !RctPtInRectangle(x, y, &bounds[state-1])) {
      on_button = false;
      for (i = 1; i <= choices + 1; i++) {
	if ((state != i) && RctPtInRectangle(x, y, &bounds[i-1])) {
	  /* Invert the new state */
	  LstSetSelection(list, i - 2);
	  LstDrawList(list);
	  WinEraseRectangleFrame(rectangleFrame, &frame);
	  WinDrawRectangleFrame(popupFrame, &frame);
	  
	  SelectAndDrawButton(btn, i == 1);
	  
	  state = i;
	  on_button = true;
	}
      }

      if (state && !on_button) {
	/* Moved off the current button */
	LstSetSelection(list, -1);
	LstDrawList(list);
	WinEraseRectangleFrame(rectangleFrame, &frame);
	WinDrawRectangleFrame(popupFrame, &frame);

	if (state == 1) 
	  SelectAndDrawButton(btn, false);
	state = 0;
      }
    }
  } while (penDown);

  FrmHideObject(frm, listIdx);
  LstEraseList(list);

  /* Restore the framed rect */
  WinRestoreBits(offscreenH, popShadowFrame.topLeft.x, popShadowFrame.topLeft.y);

  /* Unselect the button */
  SelectAndDrawButton(btn, false);

  /* Finish up if we just tapped the button */
  if (RctPtInRectangle(x, y, &bounds[0])) {
    FinishXferMode();
    
    /* Restore the old draw state */
    WinPopDrawState();
    return;
  }

  /* Change the setting for goto or delete */
  for (i = 1; i <= choices; i++) {
    if (RctPtInRectangle(x, y, &bounds[i])) {
      clicked_on = i;
      break;
    }
  }

  if (clicked_on) 
    clicked_on = d.xfer.choice_map[clicked_on-1] + 1;

  switch (clicked_on) {
  case 1: /* Goto */
    if (d.xfer.status[0] & TRACKXFERDONE_CHECKED)
      p.flags &= ~PFLAGS_XFER_GOTO;
    else if (!d.xfer.status[0])
      p.flags |= PFLAGS_XFER_GOTO;
    break;
  case 2: /* Complete */
    if (d.xfer.status[1] & TRACKXFERDONE_CHECKED)
      d.xfer.complete = false;
    else if (!d.xfer.status[1])
      d.xfer.complete = true;
    break;
  case 3: /* BackLink */
    if (d.xfer.status[2] & TRACKXFERDONE_CHECKED)
      p.flags &= ~PFLAGS_XFER_BACKLINK;
    else if (!d.xfer.status[2]) {
      p.flags |= PFLAGS_XFER_BACKLINK;
      p.flags &= ~PFLAGS_XFER_DELETE; /* No delete if backlink */
    }
    break;
  case 4: /* Delete */
    if (d.xfer.status[3] & TRACKXFERDONE_CHECKED)
      p.flags &= ~PFLAGS_XFER_DELETE;
    else if (!d.xfer.status[3]) {
      p.flags |= PFLAGS_XFER_DELETE;
      p.flags &= ~PFLAGS_XFER_BACKLINK; /* No backlink if delete */
    }
    break;
  }

  /* Click and redraw the button */
  if (clicked_on) {
    DrawXferDoneButton(btn);
    DynBtnDraw(btn);
    
    if (d.xfer.status[clicked_on-1] & TRACKXFERDONE_ALWAYS)
      SndPlaySystemSound(sndWarning);
    else
      SndPlaySystemSound(sndClick);
  }

  /* Restore the old draw state */
  WinPopDrawState();
}
示例#15
0
文件: EventLib.c 项目: ycheng/APDA
////////////////////////////////////////////////////////////////////////
// FUNCTION:    SysHandleEvent
//
// DESCRIPTION: This routine return the next available event.
//
// PARAMETERS:  (EventType *) event - Pointer to the structure to hold
//											the event returned.
//
// RETURNED:    Returns nothing
//
// REVISION HISTORY:
//			Name	Date		Description
//			----	----		-----------
//			Jerry	2/14/01	Initial Revision
//			Jerry	7/04/01	Add push button control handler
//			Jerry 8/03/01	Add popSelectEvent
//			Jerry 8/07/01	Modify popSelectEvent to get the correct List
//			Jerry 8/08/01	Complete event->data.popSelect event
//			Jerry	8/09/01	Add frmListObj option
//			Jerry	8/28/01	Processing frmCloseEvent, blinking field cursor
//			Jerry	9/03/01	Clear control before redraw it
//			Jerry	9/12/01	Fixed push button showing problem
//			Jerry	9/13/01	Put the string on the center of control
////////////////////////////////////////////////////////////////////////
Boolean SysHandleEvent(EventType *event)
{
	if ( MenuActive || (!ActiveForm) || (ActiveObjIndex == -1) )
		return	0;

	// if current active control is fieldtype, draw cursor if editable
	if ( (ActiveForm->objects[ActiveObjIndex].objectType == frmFieldObj) &&
			(ActiveForm->objects[ActiveObjIndex].object.field->attr.editable) ) {
		VDrawCursor ( (Coord)(ActiveForm->objects[ActiveObjIndex].object.field->insPtXPos),
						  (Coord)(ActiveForm->objects[ActiveObjIndex].object.field->insPtYPos+2),
						  CUR_DRAW);
		VDrawGrafState (TRUE);
	} else {
		VDrawGrafState (FALSE);
	}

	// close current form, free all allocate memory on this form.
	if ( event->eType == ctlSelectEvent ) {
		if ( (ActiveForm->objects[ActiveObjIndex].objectType == frmControlObj) ) {
			if (ActiveForm->objects[ActiveObjIndex].object.control->style == checkboxCtl) {
				// CHECKBOX Style[0] is used for checked message
				ControlType *ctlP = ActiveForm->objects[ActiveObjIndex].object.control;

//				VSetCheckBox (ctlP, ctlP->attr.on);
				ctlP->attr.on = ~ctlP->attr.on;

				VRedrawControl (ActiveForm->objects[ActiveObjIndex]);
			} else if (ActiveForm->objects[ActiveObjIndex].object.control->style == pushButtonCtl) {
				// Press on push button, invert the push button
				ControlType *ctlP = ActiveForm->objects[ActiveObjIndex].object.control;
				RectangleType	rect;
				int			strWidth;

				if ( !ctlP->attr.on ) {
					int	i;

					rect.topLeft.x = (ctlP->bounds.topLeft.x+1);
					rect.topLeft.y = (ctlP->bounds.topLeft.y+1);
					// get the width of string
					strWidth = FntCharsWidth (ctlP->text, (Int16)Vstrlen(ctlP->text));

					if ( ctlP->bounds.extent.x == -1 ) {
						rect.extent.x = (UInt16)strWidth+2;
					} else {
						rect.extent.x = (ctlP->bounds.extent.x-3);
					}
					if ( ctlP->bounds.extent.y == -1 ) {
						rect.extent.y = FntCharHeight()-3;
					} else {
						rect.extent.y = (ctlP->bounds.extent.y-4);
					}

					VDrawRect (&rect, PS_SOLID, 0, CL_FOREGROUND, COORD_STRETCH, DRAW_XOR);
/*
					VDrawRect (&rect, PS_SOLID, 0, CL_FOREGROUND, COORD_STRETCH, DRAW_SET);

					// calculate string width (put the string on the center of control)
					VDrawString ((Coord)(ctlP->bounds.topLeft.x+((ctlP->bounds.extent.x-strWidth)/2)), 
									(ctlP->bounds.topLeft.y), 
									ctlP->text, 
									Vstrlen(ctlP->text), 
									SINGLELINE, CL_BACKGROUND, COORD_STRETCH);
*/
					ctlP->attr.on = 1;
	
					for ( i = 0; i < ActiveForm->numObjects; i++ ) {
						// if other same group push button is on, off it
						if ( (i != ActiveObjIndex) &&
							  (ActiveForm->objects[i].objectType == frmControlObj) &&
							  (ActiveForm->objects[i].object.control->style == pushButtonCtl) &&
							  (ActiveForm->objects[i].object.control->attr.on) ) {
							ctlP = ActiveForm->objects[i].object.control;
							rect.topLeft.x = (ctlP->bounds.topLeft.x+1);
							rect.topLeft.y = (ctlP->bounds.topLeft.y+1);
							// get the width of string
							strWidth = FntCharsWidth (ctlP->text, (Int16)Vstrlen(ctlP->text));
							if ( ctlP->bounds.extent.x == -1 ) {
								rect.extent.x = strWidth+2;
							} else {
								rect.extent.x = (ctlP->bounds.extent.x-3);
							}
							if ( ctlP->bounds.extent.y == -1 ) {
								rect.extent.y = FntCharHeight()-3;
							} else {
								rect.extent.y = (ctlP->bounds.extent.y-4);
							}
	
							VDrawRect (&rect, PS_SOLID, 0, CL_FOREGROUND, COORD_STRETCH, DRAW_XOR);
/*
							VDrawRect (&rect, PS_SOLID, 0, CL_FOREGROUND, COORD_STRETCH, DRAW_SET);

							VDrawString ((Coord)(ctlP->bounds.topLeft.x+((ctlP->bounds.extent.x-strWidth)/2)), 
											(ctlP->bounds.topLeft.y), 
											ctlP->text, 
											Vstrlen(ctlP->text), 
											SINGLELINE, CL_FOREGROUND, COORD_STRETCH);
*/
							ctlP->attr.on = 0;
						}
					}
				}
			}
		} // end of	if ( (ActiveForm->objects[ActiveObjIndex].objectType == frmControlObj) ) {
/*
	} else if ( event->eType == popSelectEvent ) {
		Int16				theIndex, i, listObjIndex = -1;
		UInt16			hitObjIndex = ActiveObjIndex;
		UInt16			popupID = ActiveForm->objects[ActiveObjIndex].object.control->id;
		UInt16			listID=0;

		event->data.popSelect.controlP = (ControlType *)ActiveForm->objects[ActiveObjIndex].object.control;
		for ( i = 0; i < ActiveForm->numObjects; i++ ) {
			if ( (ActiveForm->objects[i].objectType == frmPopupObj) && 
					(popupID == ActiveForm->objects[i].object.popup->controlID) ) {
				listID = ActiveForm->objects[i].object.popup->listID;
				break;
			}
		}

		if ( listID ) {
			event->data.popSelect.listID = listID;
			for ( i = 0; i < ActiveForm->numObjects; i++ ) {
				if ( (ActiveForm->objects[i].objectType == frmListObj) && 
						(listID == ActiveForm->objects[i].object.list->id) ) {
					listObjIndex = i;
					event->data.popSelect.listP = ActiveForm->objects[ActiveObjIndex].object.list;
					break;
				}
			}

			if ( listObjIndex >= 0 ) {
				ListType *listP = (ListType *)ActiveForm->objects[listObjIndex].object.list;

				event->data.popSelect.priorSelection = LstGetSelection (listP);
				theIndex = LstPopupList(listP);

				if (theIndex >= 0) {
					RectangleType	rect;
					ControlType *controlP;
					int		strWidth;
						
					event->data.popSelect.selection = theIndex;
					ActiveObjIndex = hitObjIndex;
					controlP = (ControlType *)ActiveForm->objects[ActiveObjIndex].object.control;

					// clear the control first
					Vmemcpy (&rect, &(controlP->bounds), sizeof(RectangleType));

					strWidth = FntCharsWidth (controlP->text, (Int16)Vstrlen(controlP->text));
					// recalculate size if attribute is AUTO
					if ( controlP->bounds.extent.x == -1 ) {
						rect.extent.x = strWidth;
						if ( controlP->style == popupTriggerCtl ) 
							rect.extent.x += ArrowWidth;
					}
					if ( controlP->bounds.extent.y == -1 ) {
						rect.extent.y = FntCharHeight();
					}
					VDrawRect (&rect, PS_SOLID, 0, CL_BACKGROUND, COORD_STRETCH, DRAW_SET);

					// draw control
					CtlSetLabel (ActiveForm->objects[ActiveObjIndex].object.control, 
						LstGetSelectionText(listP,theIndex));
				}
			}
		}
*/
	} else if ( event->eType == keyDownEvent ) {
		// CHECKBOX Style[0] is used for checked message
		FormObjListType	object = ActiveForm->objects[ActiveObjIndex];
		switch (object.objectType) {
			case frmTableObj:
				{
					TableType	*tableP = object.object.table;
					UInt16	index = tableP->currentRow*tableP->numColumns+tableP->currentColumn;

					if ( !tableP->attr.editable )
						return	false;

					if ( tableP->items[index].ptr == NULL ) {
						tableP->items[index].ptr = (char *) Vmalloc(1);
						tableP->items[index].ptr[0] = 0;
					}
					tableP->items[index].ptr = 
						(char *) Vrealloc(tableP->items[index].ptr, Vstrlen(tableP->items[index].ptr)+2);
					VAppendStr (tableP->items[index].ptr, (UInt16)event->data.keyDown.keyCode);
					VRedrawControl (object);
				}
				break;
			case frmFieldObj:
				{
					FieldType *fldP = object.object.field;

					if ( !fldP->attr.editable )
						return	false;

					FldInsert (fldP, (char*)&(event->data.keyDown.chr), 1);
//					VRedrawControl (object);
					break;
				}
			default :
				{
/*
					ControlType *ctlP = object.object.control;

					if ( !ctlP->attr.enabled )
						return	false;

					if ( ctlP->text == NULL ) {
						ctlP->text = (char *) Vmalloc(1);
						ctlP->text[0] = 0;
					}
					ctlP->text = (char *) Vrealloc(ctlP->text, Vstrlen(ctlP->text)+2);
					VAppendStr (ctlP->text, (UInt16)event->data.keyDown.keyCode);
					VRedrawControl (object);
*/
					break;
				}
		}
	}

	return	0;
}
示例#16
0
uint_t Graphics::textWidth(const char_t* text, ulong_t length)
{
    ScalingSetter setScaling(*this);
    return FntCharsWidth(text, length);
}