int main(int argc, char **argv) { /* Declare variables. */ CDKSCREEN *cdkscreen; CDKLABEL *demo; WINDOW *cursesWin; char *mesg[4]; CDK_PARAMS params; CDKparseParams(argc, argv, ¶ms, CDK_MIN_PARAMS); /* Set up CDK. */ cursesWin = initscr(); cdkscreen = initCDKScreen (cursesWin); /* Start CDK Colors. */ initCDKColor(); /* Set the labels up. */ mesg[0] = "</5><#UL><#HL(30)><#UR>"; mesg[1] = "</5><#VL(10)>Hello World!<#VL(10)>"; mesg[2] = "</5><#LL><#HL(30)><#LR>"; /* Declare the labels. */ demo = newCDKLabel (cdkscreen, CDKparamValue(¶ms, 'X', CENTER), CDKparamValue(¶ms, 'Y', CENTER), mesg, 3, CDKparamValue(¶ms, 'N', TRUE), CDKparamValue(¶ms, 'S', TRUE)); setCDKLabelBackgroundAttrib (demo, COLOR_PAIR(2)); /* Is the label null? */ if (demo == 0) { /* Clean up the memory. */ destroyCDKScreen (cdkscreen); /* End curses... */ endCDK(); /* Spit out a message. */ printf ("Oops. Can't seem to create the label. Is the window too small?\n"); ExitProgram (EXIT_FAILURE); } /* Draw the CDK screen. */ refreshCDKScreen (cdkscreen); waitCDKLabel (demo, ' '); /* Clean up. */ destroyCDKLabel (demo); destroyCDKScreen (cdkscreen); endCDK(); ExitProgram (EXIT_SUCCESS); }
/* * This displays the marker(s) on the given day. */ static int displayCalendarMarkCB (EObjectType objectType GCC_UNUSED, void *object, void *clientData, chtype key GCC_UNUSED) { /* *INDENT-EQLS* */ CDKCALENDAR *calendar = (CDKCALENDAR *)object; CDKLABEL *label = 0; struct AppointmentInfo *appointmentInfo = (struct AppointmentInfo *)clientData; int found = 0; int day = 0; int month = 0; int year = 0; int mesgLines = 0; const char *type = 0; char *mesg[10], temp[256]; int x; /* Look for the marker in the list. */ for (x = 0; x < appointmentInfo->appointmentCount; x++) { /* Get the day month year. */ /* *INDENT-EQLS* */ day = appointmentInfo->appointment[x].day; month = appointmentInfo->appointment[x].month; year = appointmentInfo->appointment[x].year; /* Determine the appointment type. */ if (appointmentInfo->appointment[x].type == vBirthday) { type = "Birthday"; } else if (appointmentInfo->appointment[x].type == vAnniversary) { type = "Anniversary"; } else if (appointmentInfo->appointment[x].type == vAppointment) { type = "Appointment"; } else { type = "Other"; } /* Find the marker by the day/month/year. */ if ((day == calendar->day) && (month == calendar->month) && (year == calendar->year) && (appointmentInfo->appointment[x].description != 0)) { /* Create the message for the label widget. */ sprintf (temp, "<C>Appointment Date: %02d/%02d/%d", day, month, year); mesg[mesgLines++] = copyChar (temp); mesg[mesgLines++] = copyChar (" "); mesg[mesgLines++] = copyChar ("<C><#HL(35)>"); sprintf (temp, " Appointment Type: %s", type); mesg[mesgLines++] = copyChar (temp); mesg[mesgLines++] = copyChar (" Description :"); sprintf (temp, " %s", appointmentInfo->appointment[x].description); mesg[mesgLines++] = copyChar (temp); mesg[mesgLines++] = copyChar ("<C><#HL(35)>"); mesg[mesgLines++] = copyChar (" "); mesg[mesgLines++] = copyChar ("<C>Press space to continue."); found = 1; break; } } /* If we didn't find the marker, create a different message. */ if (found == 0) { sprintf (temp, "<C>There is no appointment for %02d/%02d/%d", calendar->day, calendar->month, calendar->year); mesg[mesgLines++] = copyChar (temp); mesg[mesgLines++] = copyChar ("<C><#HL(30)>"); mesg[mesgLines++] = copyChar ("<C>Press space to continue."); } /* Create the label widget. */ label = newCDKLabel (ScreenOf (calendar), CENTER, CENTER, (CDK_CSTRING2)mesg, mesgLines, TRUE, FALSE); drawCDKLabel (label, ObjOf (label)->box); waitCDKLabel (label, ' '); destroyCDKLabel (label); /* Clean up the memory used. */ for (x = 0; x < mesgLines; x++) { freeChar (mesg[x]); } /* Redraw the calendar widget. */ drawCDKCalendar (calendar, ObjOf (calendar)->box); return (FALSE); }