Example #1
0
/***********************************************************************
 *
 * FUNCTION:    RepeatDescRectHandler
 *
 * DESCRIPTION: This routine is the event handler for rectangle gadget
 *		surrounding the repeat description in the "Repeat
 *              Dialog Box".
 *
 *		Instead of drawing a static rectangle the size of the
 *		gadget bounds, I have sized the gadget to be the full area
 *		of the repeat dialog the description field will still fit
 *		should the field have to be slightly resized for any reason.
 *		The bounding rect drawn is calculated from the field's
 *		bounding rect.
 *
 * PARAMETERS:  gadgetP	- pointer to the gadget
 *		cmd	- the event type to be handled
 *		paramp	- any additional data that is passed to the gadget
 *
 * RETURNED:    true if the event was handled and should not be passed
 *              to a higher level handler.
 *
 ***********************************************************************/
static Boolean RepeatDescRectHandler(FormGadgetTypeInCallback *gadgetP, UInt16 cmd, void *paramP) {
  FieldType* fld = NULL;
  RectangleType	r;
  Boolean handled = false;

  switch(cmd) {
  case formGadgetEraseCmd:
  case formGadgetDrawCmd:

    /* Get the repeat description field and calculate a bounding box */
    fld = GetObjectPointer(FrmGetFormPtr(RepeatForm), RepeatDescField);
    FldGetBounds (fld, &r);
    RctInsetRectangle (&r, -4);
    
    if (cmd == formGadgetDrawCmd)
      WinDrawRectangleFrame(simpleFrame, &r);
    else
      WinEraseRectangle(&r, 0);

    handled = true;
    break;

  case formGadgetHandleEventCmd:
    /* do nothing */
    break;

  default:
    break;
  }
  
  return handled;
}
Example #2
0
File: Window.c Project: ycheng/APDA
////////////////////////////////////////////////////////////////////////
// FUNCTION:    WinEraseWindow
//
// DESCRIPTION: This routine earse the contents of the draw window.
//
// PARAMETERS:  None.
//
// RETURNED:    Returns nothing.
//
// REVISION HISTORY:
//			Name	Date		Description
//			----	----		-----------
//			Jerry	5/06/01	Initial Revision
////////////////////////////////////////////////////////////////////////
void WinEraseWindow (void)
{
	RectangleType	eraseRect;

	RctSetRectangle (&eraseRect, 0, 0, 160, 160);
	WinEraseRectangle (&eraseRect,0);
}
Example #3
0
File: draw.c Project: docwhat/cwimp
void EraseCube(Int die) {
  RectangleType r = { {CubesLeft, 0}, {CubeSize, CubeSize} };;

  r.topLeft.y = CubesTop + (CubeSize + CubeShift) * die;

  WinEraseRectangle( &r, 0 );
  PlaySound( SND_ERASE_CUBE );
}
Example #4
0
void
_WinEraseRectangle(RectangleType *r, UInt16 cornerDiam)
{
	if (hires)
		HRWinEraseRectangle(hires, r, cornerDiam);
	else
		WinEraseRectangle(r, cornerDiam);
}
Example #5
0
/*****************************************************************************
* Function: GadgetDrawHint
*
* Description: Draw the hintbox with the hint
*****************************************************************************/
void
GadgetDrawHint(const char *toptext, const char *bottext, UInt16 note)
{
  RectangleType bounds;
  UInt16 gadgetIndex;
  RectangleType rect, textbox_top, textbox_bot;
  FontID oldFont;
  ControlType *ctl;
  Char noteSymb[2] = { GADGET_NOTESYMBOL, 0 };
  // Not needed any longer, the hint now has its own Gadget
  // UInt16 top = GADGET_TOP + (GADGET_STRINGS_NUM-1) * GADGET_STRINGS_OFFSET + 5;  // 6 - const = VALUE BELOW

  if (! gForm) return;

  gadgetIndex = FrmGetObjectIndex(gForm, gHintGadgetID);
  FrmGetObjectBounds(gForm, gadgetIndex, &bounds);

  WinEraseRectangle(&bounds, 0);

  RctSetRectangle(&rect,
                  bounds.topLeft.x+1,  // +1 for border
                  bounds.topLeft.y+1, // Put VALUE BELOW here.... +top+1 removed because of own Gadget
                  bounds.extent.x-3, bounds.extent.y - 3); // -4 for bottom border

  // Erase Gadget area
  WinSetForeColor(UIColorGetTableEntryIndex(UIObjectFrame));
  WinDrawRectangleFrame(popupFrame, &rect);

  RctSetRectangle(&textbox_top, rect.topLeft.x+2, rect.topLeft.y,
                                rect.extent.x-2,(Int16)((rect.extent.y-2)/2));
  RctSetRectangle(&textbox_bot, textbox_top.topLeft.x, textbox_top.topLeft.y+textbox_top.extent.y+1,
                                textbox_top.extent.x, textbox_top.extent.y);

  oldFont=FntSetFont(boldFont);
  TNDrawCharsToFitWidth(toptext, &textbox_top);
  FntSetFont(oldFont);
  TNDrawCharsToFitWidth(bottext, &textbox_bot);


  gHintNote = note;
  if (note) {
    // This time has a note
    oldFont = FntSetFont(symbolFont);
    RctSetRectangle(&rect, rect.topLeft.x+rect.extent.x-8,
                           rect.topLeft.y+rect.extent.y-12,
                           FntLineWidth(noteSymb, 1), FntLineHeight());
  
    TNDrawCharsToFitWidth(noteSymb, &rect);
    FntSetFont(oldFont);
  }

  ctl=GetObjectPtr(BUTTON_edit);
  CtlShowControl(ctl);
  ctl=GetObjectPtr(BUTTON_beam);
  CtlShowControl(ctl);
}
Example #6
0
/*****************************************************************************
* Function: GadgetDrawTimeline
*
* Description: Draws a line for the current time
*****************************************************************************/
void
GadgetDrawTimeline(GadgetTimelineDrawType drawType)
{
  DateTimeType dt;
  TimeType now;

  TimSecondsToDateTime(TimGetSeconds(), &dt);

  if (drawType == gtDraw) {
    now.hours=dt.hour;
    now.minutes=dt.minute;
    gGadgetLastTimeline.hours=now.hours;
    gGadgetLastTimeline.minutes=now.minutes;
    GadgetDrawWeekdays();
  } else {
    now.hours=gGadgetLastTimeline.hours;
    now.minutes=gGadgetLastTimeline.minutes;
  }

  if ( ((gGadgetCurScreen == GADGET_SCREEN_DAY) && (now.hours >= 8) && (now.hours < 20)) ||
       ((gGadgetCurScreen == GADGET_SCREEN_NIGHT) && ((now.hours < 8) || (now.hours >= 20))) ) {

    UInt8 y, gadgetWidth;
    UInt16 gadgetIndex;
    FormType *frm;
    RectangleType bounds;
    RGBColorType red={0x00, 0xFF, 0x00, 0x00}, old;

    y = GadgetCalcTimeTop(now);

    frm = FrmGetActiveForm();
    gadgetIndex = FrmGetObjectIndex(frm, gGadgetID);
    FrmGetObjectBounds(frm, gadgetIndex, &bounds);
    gadgetWidth=gGadgetDaysNum * gGadgetDaysWidth + gGadgetDaysNum - 1;

    WinInvertLine(bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT, bounds.topLeft.y+GADGET_TOP+y,
                  bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+gadgetWidth-1, bounds.topLeft.y+GADGET_TOP+y);

    if (drawType == gtDraw) {
      TNSetForeColorRGB(&red, &old);
      WinDrawPixel(bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+gGadgetDaysNum*gGadgetDaysWidth+gGadgetDaysNum+1, bounds.topLeft.y+GADGET_TOP+y);
      WinDrawLine(bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+gGadgetDaysNum*gGadgetDaysWidth+gGadgetDaysNum+2, bounds.topLeft.y+GADGET_TOP+y-1,
                  bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+gGadgetDaysNum*gGadgetDaysWidth+gGadgetDaysNum+2, bounds.topLeft.y+GADGET_TOP+y+1);
      WinDrawLine(bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+gGadgetDaysNum*gGadgetDaysWidth+gGadgetDaysNum+3, bounds.topLeft.y+GADGET_TOP+y-2,
                  bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+gGadgetDaysNum*gGadgetDaysWidth+gGadgetDaysNum+3, bounds.topLeft.y+GADGET_TOP+y+2);
      TNSetForeColorRGB(&old, NULL);
    } else if (drawType == gtErase) {
      RectangleType rect;
      RctSetRectangle(&rect,
                      bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+gGadgetDaysNum*gGadgetDaysWidth+gGadgetDaysNum+1, bounds.topLeft.y+GADGET_TOP+y-2,
                      bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+gGadgetDaysNum*gGadgetDaysWidth+gGadgetDaysNum+3, bounds.topLeft.y+GADGET_TOP+y+2);
      WinEraseRectangle(&rect, 0);
    }
  }
}
Example #7
0
/*****************************************************************************
* Function: GadgetDrawWeekdays
*
* Description: Draws the weekdays, extra function since called in
*              GadgetDrawTimeline
*****************************************************************************/
void
GadgetDrawWeekdays(void)
{
  UInt8 i;
  MemHandle mh;
  Char *text;
  RGBColorType color, prevColor;
  DateTimeType now;
  Int16 dow;
  RectangleType bounds, rect;
  UInt16 gadgetIndex;

  // Get info about Gadget
  gadgetIndex = FrmGetObjectIndex(gForm, gGadgetID);
  FrmGetObjectBounds(gForm, gadgetIndex, &bounds);

  // Initialize time constants
  TimSecondsToDateTime(TimGetSeconds(), &now);
  dow = DayOfWeek(now.month, now.day, now.year);
  
  RctSetRectangle(&rect, bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT, bounds.topLeft.y,
                         130, FntLineHeight()+2);

  // Erase background
  WinEraseRectangle(&rect, 0);

  for (i=0; i < gGadgetDaysNum; ++i) {
    Int16 leftoff;
    mh = DmGetResource(strRsc, GADGET_STRINGS_WDAYSTART+i);
    text = MemHandleLock(mh);
    leftoff = (gGadgetDaysWidth+2 - FntLineWidth(text, MemPtrSize(text))) / 2;
    if (TNisColored() && (dow == i+1)) {
      color.r = 0xFF;  color.g = 0x00;  color.b = 0x00;
      TNSetTextColorRGB(&color, &prevColor);
    }
    WinDrawChars(text, StrLen(text), bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+i*gGadgetDaysWidth+i+leftoff+2, bounds.topLeft.y);
    if (dow == i+1) {
      if (TNisColored()) {
        TNSetTextColorRGB(&prevColor, NULL);
      } else {
        // Draw some kind of underline to determine current day
        Int16 lineWidth=FntLineWidth(text, StrLen(text));
        WinDrawLine(rect.topLeft.x+i*gGadgetDaysWidth+i+leftoff+1, rect.topLeft.y+FntLineHeight(),
                    rect.topLeft.x+i*gGadgetDaysWidth+i+leftoff+1+lineWidth, rect.topLeft.y+FntLineHeight());
      }
    }
    MemHandleUnlock(mh);
  }
}
Example #8
0
static void ListDrawDataFunc(Int16 itemNum, RectangleType *bounds, Char **itemsText)
{
	char string[20];
	
	StrNCopy(string, GetDisplayString(itemNum), 19);

	WinSetUnderlineMode(noUnderline);
	FntSetFont(stdFont);
	Int16 width = bounds->extent.x;
	Int16 len = StrLen(string);
	Boolean noFit = false;
	FntCharsInWidth(string, &width, &len, &noFit);

	WinEraseRectangle(bounds, 0);
	WinDrawChars(string, len, bounds->topLeft.x, bounds->topLeft.y);
}
Example #9
0
// Graphics icon setting
//
void DrawFormANIcon(Int16 iconNumber, Int16 id)
{
    FormPtr frmP = FrmGetActiveForm();
    Int16 x, y;
    RectangleType r;
    UInt16 idx = FrmGetObjectIndex(frmP, id);

    FrmGetObjectPosition(frmP, idx, &x, &y);
    FrmGetObjectBounds(frmP, idx, &r);
    
    r.topLeft.x = x;
    r.topLeft.y = y;

    WinEraseRectangle(&r, 0);

    if (iconNumber >= 0) DrawANIcon(iconNumber, x+1, y);
}
Example #10
0
static Int16 LoadIcon(Int16 start)
{
	FormPtr     frmP = FrmGetActiveForm();
	Int8	    i;
    Int16       num;
    Int16       iconButtonID = IconSelectIcon1Button;
    BitmapPtr   pbmp;
    MemHandle   h;
    Int16       x, y;
    RectangleType r;

    num = DmNumResources(IconDB);
    if (start > num) start = 0;
    
	for (i = 0; i < 9*8; i++) {
        UInt16 idx = FrmGetObjectIndex(frmP, iconButtonID + i);

        FrmGetObjectPosition(frmP, idx, &x, &y);
        FrmGetObjectBounds(frmP, idx, &r);

        r.topLeft.x = x;
        r.topLeft.y = y;

        WinEraseRectangle(&r, 0);

        if (i+start <num) {
            h = (MemPtr)GetIconByIndex(IconDB, i + start);
            pbmp = (h) ? MemHandleLock(h) : NULL;

            if (pbmp) {
                WinDrawBitmap(pbmp, x, y);
                                
                MemHandleUnlock(h);
                DmReleaseResource(h);
                ShowObject(frmP, iconButtonID + i);
            }
            else {
                HideObject(frmP, iconButtonID + i);
            }
        }
        else {
            HideObject(frmP, iconButtonID + i);
        }
	}
    return num;
}
Example #11
0
/*****************************************************************************
* Function: GadgetDrawHintErase
*
* Description: Erase the area where the hintbox goes
*****************************************************************************/
void
GadgetDrawHintErase(void)
{
  RectangleType bounds;
  UInt16 gadgetIndex;
  ControlType *ctl;

  if (! gForm) return;

  gadgetIndex = FrmGetObjectIndex(gForm, gHintGadgetID);
  FrmGetObjectBounds(gForm, gadgetIndex, &bounds);

  WinEraseRectangle(&bounds, 0);

  ctl=GetObjectPtr(BUTTON_edit);
  CtlHideControl(ctl);
  ctl=GetObjectPtr(BUTTON_beam);
  CtlHideControl(ctl);

}
Example #12
0
static void
TableDrawSelection(void *table, Int16 row, Int16 column, RectangleType *bounds)
{
  RGBColorType red={0x00, 0xFF, 0x00, 0x00};
  RectangleType r;

  RctSetRectangle(&r, bounds->topLeft.x, bounds->topLeft.y+(bounds->extent.y/2)-3, 4, 7);

  if (gExamsSelRow == row) {
    TNSetForeColorRGB(&red, NULL);
    // WinDrawRectangle(&r,0);    
    WinDrawPixel(r.topLeft.x, r.topLeft.y+3);
    WinDrawLine(r.topLeft.x+1, r.topLeft.y+2, r.topLeft.x+1, r.topLeft.y+4);
    WinDrawLine(r.topLeft.x+2, r.topLeft.y+1, r.topLeft.x+2, r.topLeft.y+5);
    WinDrawLine(r.topLeft.x+3, r.topLeft.y, r.topLeft.x+3, r.topLeft.y+6);
  } else {
    WinEraseRectangle(&r, 0);    
  }

}
Example #13
0
void HanderaUpdateSilkVerticalOffset
    (
    const Char* offText
    )
{
    WinHandle silkWindow, origWindow;
    FontID    origFont;

    silkWindow = SilkGetWindow();
    origWindow = WinSetDrawWindow( silkWindow );
    origFont   = FntSetFont( stdFont );

    WinEraseRectangle( &( iconList[ 1 ].bounds[ currentSilkStatus ] ), 0 );
    WinDrawChars( offText, StrLen( offText ),
        iconList[ 1 ].bounds[ currentSilkStatus ].topLeft.x,
        iconList[ 1 ].bounds[ currentSilkStatus ].topLeft.y );

    FntSetFont( origFont );
    WinSetDrawWindow( origWindow );
}
Example #14
0
// Equivalent of "at".
static void put_char_at(Short row, Short col, Char ch, Boolean bold)
{
  Short cheat, vcheat = DunTopY + (itsy_on ? 0 : 0);//center the map vertically
  RectangleType r;
  Short vc_w = itsy_on ? visible_char_w_itsy : visible_char_w;
  Short vc_h = itsy_on ? visible_char_h_itsy : visible_char_h;

  RctSetRectangle(&r, col * vc_w, row*vc_h+vcheat, vc_w, vc_h);

  if (!my_prefs.black_bg || IsColor)
    WinEraseRectangle(&r, 0);
  else
    WinDrawRectangle(&r, 0);
    
  // calculate pixel position of "row, col" and put char there
  cheat = vc_w - FntCharWidth(ch); // center the variable width characters

  if (cheat <= 1)   cheat = 0;
  else              cheat /= 2;

  if (ch != ' ') {

#ifdef I_AM_COLOR
    //  if (IsColor) {
    //    WinSetTextColor(get_color(ch, col+visible_x, row+visible_y));
    //  }
#endif

    if (!itsy_on && (ch== 'g' || ch== 'j' || ch== 'p' ||ch == 'q' ||ch == 'y'))
      vcheat--; // unfortunately, letters with dangling bits are a pain.
    
    if (!my_prefs.black_bg || IsColor)
      WinDrawChars(&ch, 1, col * vc_w + cheat, row * vc_h+vcheat);
    else
      WinDrawInvertedChars(&ch, 1, col * vc_w + cheat, row * vc_h+vcheat);

    if (bold)  WinInvertRectangle(&r, 0); /* 0 for square corners */
  }
  terminal[row][col] = ch;

}
Example #15
0
static void ListDrawDataFunc(Int16 itemNum, RectangleType *bounds, Char **itemsText)
{
	char string[50];
	
	if (itemNum < g_PhoneGroups.size()) {
		PhoneGroupPtr group = g_PhoneGroups[itemNum];
		StrNCopy(string, group->GetGroupName(), 49);
	} else {
		StrCopy(string, "");
	}

	WinSetUnderlineMode(noUnderline);
	FntSetFont(stdFont);
	Int16 width = bounds->extent.x;
	Int16 len = StrLen(string);
	Boolean noFit = false;
	FntCharsInWidth(string, &width, &len, &noFit);

	WinEraseRectangle(bounds, 0);
	WinDrawChars(string, len, bounds->topLeft.x, bounds->topLeft.y);
}
Example #16
0
/* Draw the actual buttons onto blank bitmaps, and set them as valid
   templates on the silkscreen */
static void DrawButtons( void )
{
    Err       err;
    BitmapPtr silkBitmap;
    BitmapPtr silkBitmapInv;
    WinHandle silkWindow;
    WinHandle silkWindowInv;
    WinHandle origWindow;
    UInt16    i;
    Coord     currentX;
    Coord     currentY;
    Coord     silkX;
    Coord     silkY;

    origWindow = WinGetDrawWindow();

    if ( currentSilkStatus == HANDERA_SILK_UP ) {
        SilkGetTemplateBitmaps( &silkBitmap, &silkBitmapInv, NULL, NULL );
    }
    else {
        SilkGetTemplateBitmaps( NULL, NULL, &silkBitmap, &silkBitmapInv );
    }
    BmpGlueGetDimensions( silkBitmap, &silkX, &silkY, NULL );
    silkWindow = WinCreateOffscreenWindow( silkX, silkY, screenFormat, &err );
    silkWindowInv = WinCreateOffscreenWindow( silkX, silkY, screenFormat, &err);
    WinSetDrawWindow( silkWindow );
    WinDrawBitmap( silkBitmap, 0, 0 );
    WinSetDrawWindow( silkWindowInv );
    WinDrawBitmap( silkBitmapInv, 0, 0 );

    /* We need to move down the existing silkscreen to make room for our
       own toolbar's buttons */
    if ( currentSilkStatus == HANDERA_SILK_UP ) {
        RectangleType area;
        UInt16        moveY;

        area.topLeft.x = 40;
        area.topLeft.y = 1;
        area.extent.x = 200;
        area.extent.y = 18;
        moveY         = 14;

        WinCopyRectangle( silkWindow, silkWindow, &area,
            area.topLeft.x, moveY, winPaint );
        WinCopyRectangle( silkWindowInv, silkWindowInv, &area,
            area.topLeft.x, moveY, winPaint );
        area.extent.y = moveY;
        WinSetDrawWindow( silkWindow );
        WinEraseRectangle( &area, 0 );
        WinSetDrawWindow( silkWindowInv );
        WinEraseRectangle( &area, 0 );
    }
    currentX = TOOLBAR_START_X;
    currentY = TOOLBAR_START_Y;

    for ( i = 0; i < TOTAL_ICONS; i++ ) {
        MemHandle bitmapH;
        BitmapPtr bitmap;
        Coord     width;
        Coord     height;

        if ( iconList[ i ].resourceId == 0 ) {
            /* This is just a placeholder for our '0' resourced offset image */
            width = 22;
            height = 13;
        }
        else {
            bitmapH = DmGetResource( bitmapRsc, iconList[ i ].resourceId );
            bitmap = MemHandleLock( bitmapH );
            BmpGlueGetDimensions( bitmap, &width, &height, NULL );

            WinSetDrawWindow( silkWindow );
            WinDrawBitmap( bitmap, currentX, currentY );
            WinSetDrawWindow( silkWindowInv );
            WinDrawBitmap( bitmap, currentX, currentY );

            MemPtrUnlock( bitmap );
            DmReleaseResource( bitmapH );
        }

        iconList[ i ].bounds[ currentSilkStatus ].topLeft.x = currentX;
        iconList[ i ].bounds[ currentSilkStatus ].topLeft.y = currentY;
        iconList[ i ].bounds[ currentSilkStatus ].extent.x = width;
        iconList[ i ].bounds[ currentSilkStatus ].extent.y = height;
        WinInvertRectangle( &( iconList[ i ].bounds[ currentSilkStatus ]), 0 );

        /* Because some icons are meant to appear right beside each other,
           they're defined here up top. Everything else is spaced so
           it fits nicely */
        switch ( iconList[ i ].resourceId ) {
            case bmpFind:
            case bmpAutoscrollDecr:
            case bmpAutoscrollStop:
            case bmpLeft:
            case bmpHome:
                currentX += width;
                break;

            default:
                currentX += width;
                if ( currentSilkStatus == HANDERA_SILK_UP )
                    currentX += 3;
                else if ( currentSilkStatus == HANDERA_SILK_DOWN )
                    currentX += 7;
                break;
        }
    }
    WinSetDrawWindow( origWindow );

    silkBitmap = WinGetBitmap( silkWindow );
    silkBitmapInv = WinGetBitmap( silkWindowInv );

    if ( currentSilkStatus == HANDERA_SILK_UP )
        SilkSetTemplateBitmaps( silkBitmap, silkBitmapInv, NULL, NULL );
    else
        SilkSetTemplateBitmaps( NULL, NULL, silkBitmap, silkBitmapInv );

    WinDeleteWindow( silkWindow, false );
    WinDeleteWindow( silkWindowInv, false );
}
Example #17
0
void clearScreen(void)
{
   WinEraseRectangle(&dis_area, 0);
}
Example #18
0
/*****************************************************************************
* Function: GadgetDraw
*
* Description: Draws the basic gadget (grid, days, times)
*****************************************************************************/
void
GadgetDraw(Boolean eraseFirst)
{
  RectangleType bounds;
  UInt8 i, gadgetWidth;
  RGBColorType color, prevColor;
  UInt16 gadgetIndex;
  RectangleType rect;
  FormType *frm=gForm;

  // Check if GadgetSet has already been called. If not => die
  if (! frm) return;

  gadgetIndex = FrmGetObjectIndex(frm, gGadgetID);
  FrmGetObjectBounds(frm, gadgetIndex, &bounds);

  // Erase background
  if (eraseFirst)  WinEraseRectangle(&bounds, 0);

  // Write Times
  if (gGadgetCurScreen == GADGET_SCREEN_DAY) {
    for (i=0; i < 7; i++) { // 7 because we have to write 7 times 08:00, 10:00,..., 20:00
      Char time[timeStringLength];
      if (i < 1)  StrPrintF(time, "0%u:00", 8+i*2);
      else  StrPrintF(time, "%u:00", 8+i*2);
      WinDrawChars(time, StrLen(time), bounds.topLeft.x+GADGET_BASELEFT,
                   (i != 7 - 1) ? bounds.topLeft.y+GADGET_STRINGS_TOP+i*GADGET_STRINGS_OFFSET
                   /* ^last^ */ : bounds.topLeft.y+GADGET_STRINGS_TOP+i*GADGET_STRINGS_OFFSET-2);
    }
  } else {
    for (i=0; i < 2; i++) {
      Char time[timeStringLength];
      StrPrintF(time, "%u:00", 20+i*2);
      WinDrawChars(time, StrLen(time), bounds.topLeft.x+GADGET_BASELEFT,
                   bounds.topLeft.y+GADGET_STRINGS_TOP+i*GADGET_STRINGS_OFFSET);
    }
    for (i=2; i < 7; i++) {
      Char time[timeStringLength];
      StrPrintF(time, "0%u:00", (i-2)*2);
      WinDrawChars(time, StrLen(time), bounds.topLeft.x+GADGET_BASELEFT,
                   (i != 7 - 1) ? bounds.topLeft.y+GADGET_STRINGS_TOP+i*GADGET_STRINGS_OFFSET
                   /* ^last^ */ : bounds.topLeft.y+GADGET_STRINGS_TOP+i*GADGET_STRINGS_OFFSET-2);
    }
  }

  // Write Weekdays
  GadgetDrawWeekdays();

  // Draw Grid: Color is light gray on colored palms, dark gray on gray palms
  if (TNisColored()) {
    color.r = 0x77;  color.g = 0x77;  color.b = 0x77;
  } else {
    color.r = 0x44;  color.g = 0x44;  color.b = 0x44;
  }

  TNSetForeColorRGB(&color, &prevColor);

  gadgetWidth=gGadgetDaysNum * gGadgetDaysWidth + gGadgetDaysNum - 1;
  RctSetRectangle(&rect, bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT, bounds.topLeft.y+GADGET_TOP, gadgetWidth, GADGET_HEIGHT);
  WinDrawRectangleFrame(simpleFrame, &rect);
  for(i=1; i <= 5; ++i) { // Draw the 5 gray dashed lines
    if ( (gGadgetCurScreen == GADGET_SCREEN_NIGHT) && (i == 2)) {
      WinDrawLine(bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT, bounds.topLeft.y+GADGET_TOP+i*GADGET_STRINGS_OFFSET,
                  bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+gadgetWidth-1, bounds.topLeft.y+GADGET_TOP+i*GADGET_STRINGS_OFFSET);
    } else {
      WinDrawGrayLine(bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT, bounds.topLeft.y+GADGET_TOP+i*GADGET_STRINGS_OFFSET,
                      bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+gadgetWidth-1, bounds.topLeft.y+GADGET_TOP+i*GADGET_STRINGS_OFFSET);
    }
  }
  for(i=1; i <= gGadgetDaysNum -1; ++i) {
    WinDrawLine(bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+i*gGadgetDaysWidth+(i-1), bounds.topLeft.y+GADGET_TOP,
                bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+i*gGadgetDaysWidth+(i-1), bounds.topLeft.y+GADGET_TOP+GADGET_HEIGHT-1);
  }

  TNSetForeColorRGB(&prevColor, NULL);
}
Example #19
0
void Graphics::erase(const Rect& rect)
{
    WinEraseRectangle(&rect.native(), 0);
}
Example #20
0
void PrivDrawCell(void* table, Int16 row, Int16 column, RectanglePtr bounds)
{
	char string[50];
	FontID font = stdFont;

	if (g_CurrentRow != row) {
		if (g_CurrentMemHandle) {
			MemHandleUnlock(g_CurrentMemHandle);
			g_CurrentMemHandle = NULL;
		}
	}
	if (g_CurrentMemHandle == NULL) {
		Err err = GetSMSRecord(g_SmsDb, g_SelectedCategory, row + g_CurrentPage * TABLE_PAGE_SIZE, 
			g_CurrentRecord, g_CurrentMemHandle, true);
		if (err) return;
		g_CurrentRow = row;
	}
		
	switch(column) {
		case 0:
			StrCopy(string, "");
			if (g_SelectedCategory == CAT_INBOX) {
				if (IsRecordRead(&g_CurrentRecord)) {
					StrCopy(string, "");
				} else {
					font = symbolFont;
					StrCopy(string, "\020");
				}
			} else if (g_SelectedCategory == CAT_SENT) {
				if (IsRecordRequestReport(&g_CurrentRecord)) {
					font = symbolFont;
					if (IsRecordDelivered(&g_CurrentRecord)) {
						StrCopy(string, "\026");
					} else {
						StrCopy(string, "\024");
					}
				}
			}
			break;
		case 1:
			StrNCopy(string, g_CurrentRecord.personName, 48);
			if (StrLen(string) == 0) {
				StrNCopy(string, g_CurrentRecord.phoneNumber, 48);
			}
			break;
		case 2:
			StrNCopy(string, g_CurrentRecord.content, 48);
			break;
		case 3:
			{
				DateTimeType smsDatetime;
				TimSecondsToDateTime(g_CurrentRecord.time, &smsDatetime);

				UInt32 nowSeconds = TimGetSeconds();
				DateTimeType nowDatetime;
				TimSecondsToDateTime(nowSeconds, &nowDatetime);
				
				if ((nowDatetime.year == smsDatetime.year) && 
					(nowDatetime.month == smsDatetime.month) &&
					(nowDatetime.day == smsDatetime.day)) {
					TimeToAscii(smsDatetime.hour, smsDatetime.minute, tfColon24h, string);
				} else {
					StrCopy(string, DayOfWeekInChinese[DayOfWeek(smsDatetime.month, smsDatetime.day, smsDatetime.year)]);
					DateTemplateToAscii(" ^3z-^0z", smsDatetime.month, smsDatetime.day, smsDatetime.year, string + 2, 47);
				}
				MemHandleUnlock(g_CurrentMemHandle);
				g_CurrentMemHandle = NULL;
			}
			break;
		default:
			StrCopy(string, "");
	}

	WinPushDrawState();
	
	RGBColorType foreColor, backColor;

	foreColor.index = 0;
	backColor.index = 0;
	if ((row == g_CurrentSelection) && (column != 0)) {
		foreColor.r = 255;
		foreColor.g = 255;
		foreColor.b = 255;
		
		backColor.r = 10;
		backColor.g = 36;
		backColor.b = 106;
	} else if (row % 2 == 0) {
		backColor.r = 255;
		backColor.g = 255;
		backColor.b = 255;
		
		foreColor.r = 0;
		foreColor.g = 0;
		foreColor.b = 0;
	} else {
		backColor.r = 220;
		backColor.g = 220;
		backColor.b = 220;
		
		foreColor.r = 0;
		foreColor.g = 0;
		foreColor.b = 0;
	}
	WinSetForeColorRGB(&foreColor, NULL);
	WinSetTextColorRGB(&foreColor, NULL);
	WinSetBackColorRGB(&backColor, NULL);
	
	WinSetUnderlineMode(noUnderline);
		
	FntSetFont(font);

	Int16 width = bounds->extent.x - 2;
	Int16 len = StrLen(string);
	Boolean noFit = false;
	FntCharsInWidth(string, &width, &len, &noFit);
	
	UInt16 x = bounds->topLeft.x;
	UInt16 y = bounds->topLeft.y;
	
	bounds->topLeft.x += - 1;
	bounds->topLeft.y += 0;
	bounds->extent.x += 2;
	bounds->extent.y += 0;
	
	WinEraseRectangle(bounds, 0);
	WinDrawGrayLine(
		bounds->topLeft.x + bounds->extent.x - 2, 
		bounds->topLeft.y,
		bounds->topLeft.x + bounds->extent.x - 2, 
		bounds->topLeft.y + bounds->extent.y);// - 2);
		
	WinDrawChars(string, len, x, y);
	
	WinPopDrawState();
}
Example #21
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();
}