Beispiel #1
0
void draw_histogram(int from_idx, int to_idx) {
  int i, y;
  char tmp_text[200];

  // Draw everything if scaling has changed.
  if (old_scaling != scaling) {
    from_idx = 0;
    to_idx = region_stack_idx;
  }
    
  // Draw regions as horizontal lines.
  for (i=from_idx;i<=to_idx;i=i+1) {
    y = 160-(int)(90.0*region_stat[i]/scaling);
    if (y<70) {
	StrPrintF(tmp_text, "scaling with y=%i, region_sta[i]=%lu and scaling %lu",y, region_stat[i],(UInt32)scaling);
	panic(tmp_text);
    }
    if (i == max_reg_idx)
      WinDrawLine (i*2, y, i*2, 159);
    else
      WinDrawGrayLine (i*2, y, i*2, 159);
    WinEraseLine(i*2, 70, i*2, y-1);
  }
  if (old_max_reg_idx != max_reg_idx) {
    // Draw old max idx
    y = 160-(90*region_stat[old_max_reg_idx]/scaling);
    WinDrawGrayLine (old_max_reg_idx*2, y, old_max_reg_idx*2, 159);
    WinEraseLine(old_max_reg_idx*2, 70, old_max_reg_idx*2, y-1);
    // Draw new max idx
    y = 160-(90*region_stat[max_reg_idx]/scaling);
    WinDrawLine (max_reg_idx*2, y, max_reg_idx*2, 159);
    WinEraseLine(max_reg_idx*2, 70, max_reg_idx*2, y-1);
  }
}
Beispiel #2
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);
    }
  }
}
Beispiel #3
0
static void MainFormDraw(AppContext* appContext, FormType* form, UInt16 updateCode=redrawAll)
{
    UInt16 statusBarStartY=appContext->screenHeight-lookupStatusBarHeight;
    switch (updateCode)
    {
        case redrawAll:
            FrmDrawForm(form);
            WinDrawLine(0, statusBarStartY-3, appContext->screenWidth, statusBarStartY-3);
            switch (appContext->mainFormContent)
            {
                case mainFormShowsAbout:
                    MainFormDisplayAbout(appContext);
                    break;
                
                case mainFormShowsMessage:
                case mainFormShowsDefinition:
                    MainFormDrawCurrentDisplayInfo(appContext);
                    break;
                    
                default:
                    Assert(false);
            }
            if (!(appContext->lookupStatusBarVisible && ConnectionInProgress(appContext))) 
                break; // fall through in case we should redraw status bar
                
        case redrawLookupStatusBar:
            MainFormDrawLookupStatus(appContext, form);
            break;
            
        default:            
            Assert(false);
    }            
}
Beispiel #4
0
void EQStatus(Int x)
{
  WinInvertLine( 0 + x*3, 159,
                 1 + x*3, 159);
  WinDrawLine(   0 + x*3, 158,
                 1 + x*3, 158);
}
Beispiel #5
0
static void GreyCube(Int die)
{
  Int i;
  Int yoff, xoff;
  yoff = CubesTop + (CubeSize + CubeShift) * die;
  xoff = CubesLeft;

  /* Do the X stuff first */
  for( i = 3; i <= 17; i+=2 ) {
    WinDrawLine( i+xoff,    1+yoff,
                 1+xoff,    i+yoff);
    WinDrawLine(18+xoff,    i+yoff-1,
                 i+xoff-1, 18+yoff);
  }

}
Beispiel #6
0
static void
TableDrawData(void *table, Int16 row, Int16 column, RectangleType *bounds)
{
  UInt16 index=TblGetRowID(table, row);
  ExamDBRecord *ex;
  MemHandle mex;
  RGBColorType fore={0x00, 0x00, 0x00, 0x00}, back={0x00, 0xFF, 0xFF, 0xFF};

  if (! TblRowUsable(table, row)) return;
  
  TNSetBackColorRGB(&back, NULL);
  TNSetForeColorRGB(&back, NULL);
  WinDrawRectangle(bounds, 0);

  mex = DmQueryRecord(DatabaseGetRefN(DB_MAIN), index);
  ex = (ExamDBRecord *)MemHandleLock(mex);

  if (column == EXCOL_COURSE) {
    Char *temp;
    MemHandle m=MemHandleNew(1);
    CourseGetName(ex->course, &m, true);
    temp = MemHandleLock(m);

    TNSetForeColorRGB(&fore, NULL);
    TNDrawCharsToFitWidth(temp, bounds);

    MemHandleUnlock(m);
    MemHandleFree(m);
  } else if (column == EXCOL_NOTE) {
    if (ex->note) {
      Char noteSymb[2] = { GADGET_NOTESYMBOL, 0 };
      FontID oldFont = FntSetFont(symbolFont);

      TNDrawCharsToFitWidth(noteSymb, bounds);
      FntSetFont(oldFont);
    }
  } else if (column == EXCOL_DATE) {
    Char dateTemp[dateStringLength];
    DateToAscii(ex->date.month, ex->date.day, ex->date.year+MAC_SHIT_YEAR_CONSTANT, PrefGetPreference(prefDateFormat), dateTemp);
    TNDrawCharsToFitWidth(dateTemp, bounds);
  } else if (column == EXCOL_TIME) {
    Char timeTemp[timeStringLength];
    TimeToAscii(ex->begin.hours, ex->begin.minutes, PrefGetPreference(prefTimeFormat), timeTemp);
    TNDrawCharsToFitWidth(timeTemp, bounds);
  }


  if (ex->flags & EX_FLAG_DONE) {
    RGBColorType red = {0x00, 0xFF, 0x00, 0x00}, old;
    Int16 yCoord=bounds->topLeft.y+(bounds->extent.y / 2);
    TNSetForeColorRGB(&red, &old);
    WinDrawLine(bounds->topLeft.x, yCoord, bounds->topLeft.x+bounds->extent.x, yCoord);
    TNSetForeColorRGB(&old, NULL);
  }

  MemHandleUnlock(mex);
}
Beispiel #7
0
void drawRectangleSafe(int sx, int sy, int w, int h) // x,y,width,height
{
   int y,x;
   DEBUGBOX("drawRect","");
   for(y=sy,x=sx;y<sy+h;y++)
      WinDrawLine(x,y,x+h,y);
   //RectangleType r; // = { {0, l, {160, 12} };
   //RctSetRectangle(&r, sx, sy, w, h); // x,y,width,height
   //WinDrawRectangleFrame(dialogFrame, &r); // sdk/include/Core/System/Window.h
}
Beispiel #8
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);    
  }

}
Beispiel #9
0
static void MainFormDrawLookupStatus(AppContext* appContext, FormType* form)
{
    WinPushDrawState();
    SetGlobalBackColor(appContext);
    UInt16 statusBarStartY=appContext->screenHeight-lookupStatusBarHeight;
    ClearRectangle(0, statusBarStartY, appContext->screenWidth, lookupStatusBarHeight);
    WinDrawLine(0, statusBarStartY-3, appContext->screenWidth, statusBarStartY-3);
    const char* text=GetConnectionStatusText(appContext);
    Assert(text);
    UInt16 textLen=StrLen(text);    
    WinDrawTruncChars(text, textLen, 1, statusBarStartY+1, appContext->screenWidth - 14);
    WinPopDrawState();
}
Beispiel #10
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);
  }
}
Beispiel #11
0
void CrossCube(Int die)
{
  Int yoff, xoff;
  
  yoff = CubesTop + (CubeSize + CubeShift) * die;
  xoff = CubesLeft;

  if( die == 0 ) {
    WinEraseLine( 3  +xoff, 4  +yoff,
                  15 +xoff, 16 +yoff);
    WinEraseLine( 3  +xoff, 3  +yoff,
                  16 +xoff, 16 +yoff);
    WinEraseLine( 4  +xoff, 3  +yoff,
                  16 +xoff, 15 +yoff);
  
    WinEraseLine( 3  +xoff, 15 +yoff,
                  15 +xoff, 3  +yoff);
    WinEraseLine( 3  +xoff, 16 +yoff,
                  16 +xoff, 3  +yoff);
    WinEraseLine( 4  +xoff, 16 +yoff,
                  16 +xoff, 4  +yoff);
  } else {

    WinDrawLine( 3  +xoff, 4  +yoff,
                 15 +xoff, 16 +yoff);
    WinDrawLine( 3  +xoff, 3  +yoff,
                 16 +xoff, 16 +yoff);
    WinDrawLine( 4  +xoff, 3  +yoff,
                 16 +xoff, 15 +yoff);
  
    WinDrawLine( 3  +xoff, 15 +yoff,
                 15 +xoff, 3  +yoff);
    WinDrawLine( 3  +xoff, 16 +yoff,
                 16 +xoff, 3  +yoff);
    WinDrawLine( 4  +xoff, 16 +yoff,
                 16 +xoff, 4  +yoff);
  }

}
Beispiel #12
0
Boolean
CourseListHandleEvent(EventPtr event)
{
  FormPtr frm=FrmGetActiveForm();
  Boolean handled = false;
  ListType *lstP=GetObjectPtr(LIST_courses);
  Boolean categoryEdited, reDraw=false;
  UInt16 category, numRecords;
  ControlType *ctl;
  UInt32 *recordList;

  if (event->eType == ctlSelectEvent) {
    // button handling
    switch (event->data.ctlSelect.controlID) {
      case BUTTON_courselist_back:
        handled=true;
        FrmGotoForm(FORM_main);
        break;

      case BUTTON_courselist_del:
        handled=true;
        if (LstGetSelection(lstP) == noListSelection) {
          FrmAlert(ALERT_clist_noitem);
        } else {
          DeleteCourse(gCourseInd[LstGetSelection(lstP)]);
          CleanupCourselist();
          DrawCourses(lstP);
          FrmDrawForm(FrmGetActiveForm());
        }
        break;

      case BUTTON_courselist_add:
        handled=true;
        gMenuCurrentForm=FORM_courselist;
        AddCourse();
        break;

      case BUTTON_courselist_edit:
        handled=true;
        if (LstGetSelection(lstP) == noListSelection) {
          FrmAlert(ALERT_clist_noitem);
        } else {
          gMenuCurrentForm=FORM_courselist;
          EditCourse(gCourseInd[LstGetSelection(lstP)]);
        }
        break;

      case BUTTON_courselist_beam:
        handled=true;
        if (LstGetSelection(lstP) == noListSelection) {
          FrmAlert(ALERT_clist_noitem);
        } else {
          BeamCourse(gCourseInd[LstGetSelection(lstP)]);
        }
        break;


      case LIST_cl_cat_trigger:
        handled=true;
        category=DatabaseGetCat();
        numRecords=DmNumRecordsInCategory(DatabaseGetRef(), DELETE_CATEGORY);
        recordList=(UInt32 *)MemPtrNew(numRecords * sizeof(UInt32));
        CatPreEdit(numRecords, recordList);
        categoryEdited = CategorySelect(DatabaseGetRef(), frm,
                                        LIST_cl_cat_trigger, LIST_cl_cat, false,
                                        &category, gCategoryName, 0,
                                        STRING_cat_edit); // categoryDefaultEditCategoryString
        if (categoryEdited || (category != DatabaseGetCat())) {
          reDraw=true;
          DatabaseSetCat(category);
          ctl = GetObjectPtr(LIST_cl_cat_trigger);
          CategoryGetName(DatabaseGetRef(), category, gCategoryName); 
          CategorySetTriggerLabel(ctl, gCategoryName);
        }
        CatPostEdit(numRecords, recordList);
        if (reDraw) {
          CleanupCourselist();
          DrawCourses(lstP);
          FrmDrawForm(FrmGetActiveForm());
        }
        if (recordList != NULL)  MemPtrFree((MemPtr)recordList);
        break;



      default:
        break;
    }
  } else if (event->eType == keyDownEvent) {
    // We have a hard button assigned and it was pressed
    if (TxtCharIsHardKey(event->data.keyDown.modifiers, event->data.keyDown.chr)) {
      if (! (event->data.keyDown.modifiers & poweredOnKeyMask)) {
        FrmGotoForm(FORM_main);
        handled = true;
      }
    } else if (EvtKeydownIsVirtual(event)) {
      // Up or down keys pressed
      ListType *lst=GetObjectPtr(LIST_courses);
      switch (event->data.keyDown.chr) {
        case vchrPageUp:
          if (LstGetSelection(lst) == noListSelection) {
            LstSetSelection(lst, gNumCourses-1);
            CourseListHandleSelection();
          } else if (LstGetSelection(lst) > 0) {
            LstSetSelection(lst, LstGetSelection(lst)-1);
            CourseListHandleSelection();
          }
          handled=true;
          break;
        
        case vchrPageDown:
          if (LstGetSelection(lst) == noListSelection) {
            LstSetSelection(lst, 0);
            CourseListHandleSelection();
          } else if (LstGetSelection(lst) < (gNumCourses-1)) {
            LstSetSelection(lst, LstGetSelection(lst)+1);
            CourseListHandleSelection();
          }
          handled=true;
          break;

        default:
          break;
      }
    }
  } else if (event->eType == lstSelectEvent) {
    return CourseListHandleSelection();
  } else if (event->eType == menuOpenEvent) {
    return HandleMenuOpenEvent(event);
  } else if (event->eType == menuEvent) {
    // forwarding of menu events
    return HandleMenuEvent(event->data.menu.itemID);
  } else if (event->eType == frmOpenEvent) {
    // initializes and draws the form
    ControlType *ctl;

    frm = FrmGetActiveForm();
    lstP=GetObjectPtr(LIST_courses);
    FrmDrawForm (frm);
    DrawCourses(lstP);
    FrmDrawForm (frm);

    ctl = GetObjectPtr(LIST_cl_cat_trigger);
    CategoryGetName (DatabaseGetRef(), DatabaseGetCat(), gCategoryName); 
    CategorySetTriggerLabel (ctl, gCategoryName); 

    WinDrawLine(1, 140, 158, 140);
    
    handled = true;
  } else if (event->eType == frmUpdateEvent) {
    // redraws the form if needed
    CleanupCourselist();
    DrawCourses(GetObjectPtr(LIST_courses));
    FrmDrawForm (frm);
    WinDrawLine(1, 140, 158, 140);
    handled = false;
  } else if (event->eType == frmCloseEvent) {
    // this is done if form is closed
    CleanupCourselist();
  }

  return (handled);

}
Beispiel #13
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);
}
Beispiel #14
0
static Boolean MainFormHandleEvent (EventPtr e)
{
    Boolean handled = false;
    FormPtr frm;
    static UInt32 start_sec=0;
    static UInt32 start_tik;
    static UInt32 end_sec;
    static UInt32 end_tik;
    //static int run = 0;
    
    switch (e->eType) {
    case frmOpenEvent:
	frm = FrmGetActiveForm();
	FrmDrawForm(frm);

	// resume interrupted count
	// note now stopWatchPrefs.tik_timestamp != stopWatchPrefs.timestamp
        // now this does work okay when switching away from app BUT
        // not when palm is turned off & on but stays in app
        // I think possibly GetTicks gets ticks from start of app
        // when palm off the ticks do not increment
	if (stopWatchPrefs.timestamp != 0) {
	    stopWatchPrefs.tik_timestamp = TimGetSeconds();
	    start_tik = TimGetTicks();
	    RunCount(start_tik);
	}

	handled = true;
	break;

    case menuEvent:
	MenuEraseStatus(NULL);

	switch(e->data.menu.itemID) {
	    // TODO add to TestTemp code
	    //case itemBar:
	    case itemRun:
		if (start_sec == 0) {
		    stopWatchPrefs.tik_timestamp =
			stopWatchPrefs.timestamp = 
			start_sec = TimGetSeconds();
		    start_tik = TimGetTicks();
		}
		RunCount(start_tik);
		break;
	    case itemHold:
		// break the run loop
		run = 0;
		break;
	    case itemStop:
		// break the run loop
		run = 0;
		end_sec = TimGetSeconds();
 		end_tik = TimGetTicks();
		break;
	    case itemClear:
		// break the run loop
		run = 0;
		start_sec = 0;
		stopWatchPrefs.timestamp = 0;
		stopWatchPrefs.tik_timestamp = 0;
		end_tik = 0;
		drawCount(0);
		break;

	    case itemPrefs:
		FrmPopupForm(PrefForm);
		break;

	    case itemTest1:

		WinDrawLine(20,20,50,50);
//void WinDrawChar (WChar theChar, Coord x, Coord y)
///void WinDrawChars (const Char *chars, Int16 len, Coord x, Coord y)
//void WinPaintChar (WChar theChar, Coord x, Coord y)
//void WinPaintChars (const Char *chars, Int16 len, Coord x, Coord y)
///opt/palmdev/sdk-5/include/Core/System/Window.h
// Font.h
		WinDrawChar('X',20,50);
		FntSetFont(symbol11Font);
		WinDrawChar('Y',40,50);
		FntSetFont(largeFont);
		WinDrawChar('Z',60,50);
		WinDrawChars("large Font",10,80,50);
		FntSetFont(largeBoldFont);
		WinDrawChars("large Bold",10,110,50);

		{
		    char buf[100];
		    int l=0;
		    UInt32 t = SysTicksPerSecond();
		    l+=StrPrintF(buf+l, "SysTicksPerSec is %lu", t);
		    FntSetFont(largeBoldFont);
		    WinPaintChars(buf,l,1,20);
		}

		if (0){
		    digiFontType ft;
		    ft.h = 20;
		    ft.w = 16;
		    ft.th = 4; ft.tw = 7;
		    drawHSeg(11,9,ft,WinDrawLineF);
		    drawVSeg(10,10,ft,WinDrawLineF);
		    drawHSeg(11,36,ft,WinDrawLineF);
		    drawVSeg(39,10,ft,WinDrawLineF);
		}

		if (0){
		    digiFontType ft;
		    ft.h = 20;
		    ft.w = 12;
		    ft.th = 4; ft.tw = 7;
		    drawHSeg(11,59,ft,WinDrawLineF);
		    drawVSeg(10,60,ft,WinDrawLineF);
		    drawVSeg(38,60,ft,WinDrawLineF);
		    drawHSeg(11,79,ft,WinDrawLineF);
		    drawVSeg(10,80,ft,WinDrawLineF);
		    drawVSeg(38,80,ft,WinDrawLineF);
		    drawHSeg(11,99,ft,WinDrawLineF);
		}

		bigDigit(5,20,'2',WinDrawLineF);
		bigDigit(40,20,'5',WinDrawLineF);
		bigDigit(5,70,'7',WinDrawLineF);
		break;

	    case itemTest2:

		bigDigit(5,20,'8',WinEraseLineF);
		bigDigit(40,20,'8',WinEraseLineF);
		bigDigit(5,70,'8',WinEraseLineF);

		WinDrawChars("Hello",5,20,80);
		WinPaintChars("Paint",5,20,110);

		//Err err; err = TimInit();
		{
		    char buf[100];
		    int l=0;
		    UInt32 s,t;
		    UInt32 hour,min,sec;
		    UInt32 day;
		    // seconds since 1/1/1904
		    //void TimSetSeconds(UInt32 seconds) 	
		    // ticks since power on
		    t = TimGetTicks();
		    s = TimGetSeconds();
		    
		    l+=StrPrintF(buf+l, "Secs %lu", s);
		    FntSetFont(largeBoldFont);
		    WinPaintChars(buf,l,1,20);

		    l=0;
		    l+=StrPrintF(buf+l, "Ticks %lu", t);
		    FntSetFont(largeBoldFont);
		    WinPaintChars(buf,l,1,40);

		    day = s / (UInt32)(24 * 60 * 60);
		    s = s - day * (24 * 60 * 60);
		    hour = s / (60 * 60);
		    s = s - hour * (60 * 60);
		    min = s / 60;
		    sec = s - min * 60;
		    l=0;
		    l+=StrPrintF(buf+l, "%07d:%02d:%02d:%02d", day, hour,min,sec);
		    FntSetFont(largeBoldFont);
		    WinPaintChars(buf,l,1,60);

		}
		break;

		// call this periodically to hold off auto off  
		// Err EvtResetAutoOffTimer(void)

// SystemMgr.h
//Err SysTimerCreate(UInt32 *timerIDP, UInt32 *tagP, 
//            SysTimerProcPtr timerProc, UInt32 periodicDelay, UInt32	param)
//Err		SysTimerDelete(UInt32 timerID)
//Err		SysTimerWrite(UInt32 timerID, UInt32 value)
//Err		SysTimerRead(UInt32 timerID, UInt32 *valueP)

//      SysTaskDelay((100 * SysTicksPerSecond())/1000);

	    case itemOptHelp:
		FrmHelp(hlpHelp);
		break;
		//case itemOptDbgDump:
		//debugDump(e->eType);
		//break;
	    case itemOptCopy:
		FrmHelp(hlpCopy);
		break;
	    case itemOptAbout:
		FrmCustomAlert(alertInfo, 
			       "stopWatch v" VERSION " not even Alpha. "
			       "Built " __DATE__ ", " __TIME__ ". "
			       "James Coleman http://www.dspsrv.com/~jamesc "
			       "copyleft me.", "", "");
		break;

	}

	//DEBUGBOX("menuEvent","");

    	handled = true;
	break;

    case ctlSelectEvent:
	switch(e->data.ctlSelect.controlID) {

	    case btnRun:
		if (start_sec == 0) {
		    stopWatchPrefs.tik_timestamp =
			stopWatchPrefs.timestamp = 
			start_sec = TimGetSeconds();
		    start_tik = TimGetTicks();
		}
		RunCount(start_tik);
		break;
	    case btnHold:
		// break the run loop
		run = 0;
		break;
	    case btnStop:
		// break the run loop
		run = 0;
		end_sec = TimGetSeconds();
 		end_tik = TimGetTicks();
		break;
	    case btnClear:
		// break the run loop
		run = 0;
		stopWatchPrefs.timestamp = start_sec = 0;
		stopWatchPrefs.tik_timestamp = 0;
		end_tik = 0;
		drawCount(0);
		break;

	}
	break;

    //case ctlRepeatEvent:
    //break;

    case penDownEvent:
    case penMoveEvent:
      doPenAction( e->eType, e->screenX, e->screenY, 0, 0); 
      //FrmCustomAlert(alertInfo, "pen down", "ARGSTR1", "ARGSTR2");
      break;

    case penUpEvent:
      doPenAction( penUpEvent, 
      	   e->data.penUp.start.x, e->data.penUp.start.y, 
      	   e->data.penUp.end.x, e->data.penUp.end.y);
      break;

    case keyDownEvent:

      {
	char buf[1000];
	int l=0;
	l+=StrPrintF(buf+l, "Char: %c %02x\n",e->data.keyDown.chr,e->data.keyDown.chr);
	buf[l]=0;
	DEBUGBOX("keyDownEvent",buf);
      }

      switch(e->data.keyDown.chr) {
      case pageUpChr:
      case pageDownChr:
	handled = true;
	break;
      case prevFieldChr:
      case nextFieldChr:
      case '\n':
	handled = true;
	break;
      default:
	if (!TxtCharIsCntrl(e->data.keyDown.chr)) {
	  handled = true;                 /* Swallow event */
	}
	break;
      }
      break;

    default:
        break;
    }

    return handled;
}
Beispiel #15
0
void WinDrawLineF(Coord x1, Coord y1, Coord x2, Coord y2)
{
   WinDrawLine(x1,y1,x2,y2);
}
Beispiel #16
0
static void CrossPlayer(Int player) {
  Int y;
  y = 52 + 6 + player * 10;
  WinDrawLine( 36   , y,
               36+64, y );
}
Beispiel #17
0
void TPointDrawLine(TPoint_type p1, TPoint_type p2)
{
    WinDrawLine((short int) p1.x, (short int) p1.y, (short int) p2.x,
		(short int) p2.y);
}