コード例 #1
0
ファイル: gui.c プロジェクト: foxymoron/process-migration
void cleanup_handler(int signum)
{
	shmdt(shared_memory);
	destroyCDKSwindow(loadDaemon);
	destroyCDKSwindow(commsDaemon);
	destroyCDKSwindow(migrateDaemon);
	destroyCDKSwindow(extraInfo);
	destroyCDKLabel(title);
	destroyCDKLabel(info);
	delwin(cursesWin);
	endCDK();
	exit(0);
}
コード例 #2
0
ファイル: popup_label.c プロジェクト: iamjamestl/school
/*
 * This pops up a message.
 */
void popupLabelAttrib (CDKSCREEN *screen, char **mesg, int count, chtype attrib)
{
   CDKLABEL *popup = 0;
   int oldCursState;
   boolean functionKey;

   /* Create the label. */
   popup = newCDKLabel (screen, CENTER, CENTER, mesg, count, TRUE, FALSE);
   setCDKLabelBackgroundAttrib(popup, attrib);

   oldCursState = curs_set(0);
   /* Draw it on the screen. */
   drawCDKLabel (popup, TRUE);

   /* Wait for some input. */
   keypad (popup->win, TRUE);
   getchCDKObject (ObjOf(popup), &functionKey);

   /* Kill it. */
   destroyCDKLabel (popup);

   /* Clean the screen. */
   curs_set(oldCursState);
   eraseCDKScreen (screen);
   refreshCDKScreen (screen);
}
コード例 #3
0
void CCDKLabel::Destroy(void)
{
    if (!m_pLabel) return;

    CBaseCDKWidget::Destroy();
    destroyCDKLabel(m_pLabel);
    m_pLabel = NULL;
}
コード例 #4
0
ファイル: hello_ex.c プロジェクト: iamjamestl/school
int main(int argc, char **argv)
{
   /* Declare variables. */
   CDKSCREEN	*cdkscreen;
   CDKLABEL	*demo;
   WINDOW	*cursesWin;
   char		*mesg[4];

   CDK_PARAMS params;

   CDKparseParams(argc, argv, &params, 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(&params, 'X', CENTER),
		       CDKparamValue(&params, 'Y', CENTER),
		       mesg, 3,
		       CDKparamValue(&params, 'N', TRUE),
		       CDKparamValue(&params, '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);
}
コード例 #5
0
ファイル: stopSign.c プロジェクト: ThomasDickey/cdk-snapshots
int main (void)
{
   /* *INDENT-EQLS* */
   CDKSCREEN *cdkscreen = 0;
   CDKLABEL *stopSign   = 0;
   CDKLABEL *title      = 0;
   const char *mesg[5];
   const char *sign[4];
   chtype key;
   boolean functionKey;

   cdkscreen = initCDKScreen (NULL);

   /* Start CDK Colors. */
   initCDKColor ();

   /* Set the labels up. */
   mesg[0] = "<C><#HL(40)>";
   mesg[1] = "<C>Press </B/16>r<!B!16> for the </B/16>red light";
   mesg[2] = "<C>Press </B/32>y<!B!32> for the </B/32>yellow light";
   mesg[3] = "<C>Press </B/24>g<!B!24> for the </B/24>green light";
   mesg[4] = "<C><#HL(40)>";
   sign[0] = " <#DI> ";
   sign[1] = " <#DI> ";
   sign[2] = " <#DI> ";

   /* Declare the labels. */
   title = newCDKLabel (cdkscreen, CENTER, TOP,
			(CDK_CSTRING2) mesg, 5,
			FALSE, FALSE);
   stopSign = newCDKLabel (cdkscreen, CENTER, CENTER,
			   (CDK_CSTRING2) sign, 3,
			   TRUE, TRUE);

   /* Do this until they hit q or escape. */
   for (;;)
   {
      drawCDKLabel (title, FALSE);
      drawCDKLabel (stopSign, TRUE);

      key = (chtype)getchCDKObject (ObjOf (stopSign), &functionKey);
      if (key == KEY_ESC || key == 'q' || key == 'Q')
      {
	 break;
      }
      else if (key == 'r' || key == 'R')
      {
	 sign[0] = " </B/16><#DI> ";
	 sign[1] = " o ";
	 sign[2] = " o ";
      }
      else if (key == 'y' || key == 'Y')
      {
	 sign[0] = " o ";
	 sign[1] = " </B/32><#DI> ";
	 sign[2] = " o ";
      }
      else if (key == 'g' || key == 'G')
      {
	 sign[0] = " o ";
	 sign[1] = " o ";
	 sign[2] = " </B/24><#DI> ";
      }

      /* Set the contents of the label and re-draw it. */
      setCDKLabel (stopSign, (CDK_CSTRING2) sign, 3, TRUE);
   }

   /* Clean up. */
   destroyCDKLabel (title);
   destroyCDKLabel (stopSign);
   destroyCDKScreen (cdkscreen);
   endCDK ();
   ExitProgram (EXIT_SUCCESS);
}
コード例 #6
0
ファイル: fselect.c プロジェクト: dyne/MuSE
/*
 * This is a callback to the scrolling list which displays information
 * about the current file. (and the whole directory as well)
 */
static int displayFileInfoCB (EObjectType objectType GCC_UNUSED, void *object, void *clientData, chtype key GCC_UNUSED)
{
   /* Declare local variables. */
   CDKENTRY		*entry		= (CDKENTRY *)object;
   CDKFSELECT		*fselect	= (CDKFSELECT *)clientData;
   CDKLABEL		*infoLabel;
   struct stat		fileStat;
   struct passwd	*pwEnt;
   struct group		*grEnt;
   char			*filename;
   char			*filetype;
   char			*mesg[10];
   char			temp[100];
   char			stringMode[15];
   int			len;
   int			intMode;

   /* Get the file name. */
   filename	= fselect->entryField->info;

   /* Get specific information about the files. */
   lstat (filename, &fileStat);

   /* Determine the file type. */
   switch (mode2Filetype(fileStat.st_mode)) {
   case 'l':
      filetype = "Symbolic Link";
      break;
   case '@':
      filetype = "Socket";
      break;
   case '-':
      filetype = "Regular File";
      break;
   case 'd':
      filetype = "Directory";
      break;
   case 'c':
      filetype = "Character Device";
      break;
   case 'b':
      filetype = "Block Device";
      break;
   case '&':
      filetype = "FIFO Device";
      break;
   default:
      filetype = "Unknown";
      break;
   }

   /* Get the user name and group name. */
   pwEnt = getpwuid (fileStat.st_uid);
   grEnt = getgrgid (fileStat.st_gid);

   /* Convert the mode_t type to both string and int. */
   intMode = mode2Char (stringMode, fileStat.st_mode);

   /* Create the message. */
   sprintf (temp, "Directory  : </U>%s", fselect->pwd);
   mesg[0] = copyChar (temp);

   sprintf (temp, "Filename   : </U>%s", filename);
   mesg[1] = copyChar (temp);

   sprintf (temp, "Owner      : </U>%s<!U> (%d)", pwEnt->pw_name, (int)fileStat.st_uid);
   mesg[2] = copyChar (temp);

   sprintf (temp, "Group      : </U>%s<!U> (%d)", grEnt->gr_name, (int)fileStat.st_gid);
   mesg[3] = copyChar (temp);

   sprintf (temp, "Permissions: </U>%s<!U> (%o)", stringMode, intMode);
   mesg[4] = copyChar (temp);

   sprintf (temp, "Size       : </U>%ld<!U> bytes", (long) fileStat.st_size);
   mesg[5] = copyChar (temp);

   sprintf (temp, "Last Access: </U>%s", ctime (&fileStat.st_atime));
   len = (int)strlen (temp);
   temp[len] = '\0'; temp[len-1] = '\0';
   mesg[6] = copyChar (temp);

   sprintf (temp, "Last Change: </U>%s", ctime (&fileStat.st_ctime));
   len = (int)strlen (temp);
   temp[len] = '\0'; temp[len-1] = '\0';
   mesg[7] = copyChar (temp);

   sprintf (temp, "File Type  : </U>%s", filetype);
   mesg[8] = copyChar (temp);

   /* Create the pop up label. */
   infoLabel = newCDKLabel (entry->obj.screen, CENTER, CENTER,
				mesg, 9, TRUE, FALSE);
   drawCDKLabel (infoLabel, TRUE);
   wgetch (infoLabel->win);

   /* Clean up some memory. */
   destroyCDKLabel (infoLabel);
   freeCharList (mesg, 9);

   /* Redraw the file selector. */
   drawCDKFselect (fselect, ObjOf(fselect)->box);
   return (TRUE);
}
コード例 #7
0
ファイル: appointment.c プロジェクト: lavenliu/linuxc
/*
 * 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);
}
コード例 #8
0
ファイル: simpletui.cpp プロジェクト: hephaisto/simpletui
SimpletuiTempMessage::~SimpletuiTempMessage()
{
	destroyCDKLabel(reinterpret_cast<CDKLABEL*>(label));
}
コード例 #9
0
ファイル: clock.c プロジェクト: iamjamestl/school
int main (int argc, char **argv)
{
   /* Declare variables. */
   CDKSCREEN *cdkscreen = 0;
   CDKLABEL *demo	= 0;
   WINDOW *cursesWin	= 0;
   int boxLabel		= 0;
   char *mesg[4], temp[256];
   struct tm *currentTime;
   time_t clck;
   int ret;

   /* Parse up the command line. */
   while ((ret = getopt (argc, argv, "b")) != -1)
   {
      switch (ret)
      {
	 case 'b' :
	      boxLabel = 1;
      }
   }

   /* Set up CDK */ 
   cursesWin = initscr();
   cdkscreen = initCDKScreen (cursesWin);

   /* Start CDK Colors */
   initCDKColor();

   /* Set the labels up. */
   mesg[0] = "</1/B>HH:MM:SS";

   /* Declare the labels. */
   demo = newCDKLabel (cdkscreen, CENTER, CENTER, mesg, 1, boxLabel, FALSE);

   /* 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);
   }

   curs_set(0);
   wtimeout (WindowOf(demo), 50);

   /* Do this for-a-while... */
   do
   {
      /* Get the current time. */
      time(&clck);
      currentTime = localtime (&clck);

      /* Put the current time in a string. */
      sprintf (temp, "<C></B/29>%02d:%02d:%02d", currentTime->tm_hour, currentTime->tm_min, currentTime->tm_sec);
      mesg[0] = copyChar (temp);

      /* Set the label contents. */
      setCDKLabel (demo, mesg, 1, ObjOf(demo)->box);

      /* Clean up the memory used. */
      freeChar (mesg[0]);

      /* Draw the label, and sleep. */
      drawCDKLabel (demo, ObjOf(demo)->box);
      napms (500);
   }
   while (wgetch(WindowOf(demo)) == ERR);

   /* Clean up */
   destroyCDKLabel (demo);
   destroyCDKScreen (cdkscreen);
   endCDK();

   ExitProgram (EXIT_SUCCESS);
}