Beispiel #1
0
void DrawTime(int hr, int min, int sec) {
#define TIME_SIZE 16
    char	time[TIME_SIZE];
    char	*p = time;
    int		i,j,k=6;
    int numfields;

    /* 7x13 */

    if (noseconds) {
        snprintf(time, TIME_SIZE, "%02d:%02d ", hr, min);
        numfields = 2;
    }
    else {
        snprintf(time, TIME_SIZE, "%02d:%02d:%02d ", hr, min, sec);
        numfields = 3;
    }

    for (i=0; i < numfields; i++) {
        for (j=0; j<2; j++) {
            copyXPMArea((*p-'0')*7 + 1, 84, 8, 13, k, 18);
            k += 7;
            p++;
        }
        if (*p == ':') {
            copyXPMArea(71, 84, 5, 13, k, 18);
            k += 4;
            p++;
        }
    }
}
Beispiel #2
0
void
DrawStats (int num, int size, int x_left, int y_bottom)
{

    int pixels_per_byte;
    int j, k;

    pixels_per_byte = size;
    for (j = 0; j < num; j++)
      if ((ppp_history[j][0]+ppp_history[j][1]) > pixels_per_byte)
	pixels_per_byte = ppp_history[j][0] + ppp_history[j][1];

    pixels_per_byte /= size;

    for (k = 0; k < num; k++)
      for (j = 0; j < size; j++)
	{
	  if (j < (ppp_history[k][0] / pixels_per_byte))
	    copyXPMArea (58 + 2, 92, 1, 1, k + x_left, y_bottom - j);
	  else if (j < (ppp_history[k][0] + ppp_history[k][1]) / pixels_per_byte)
	    copyXPMArea (58 + 1, 92, 1, 1, k + x_left, y_bottom - j);
	  else
	    copyXPMArea (58 + 0, 92, 1, 1, k + x_left, y_bottom - j);
	}
}
Beispiel #3
0
void
ButtonDown (int button)
{

    switch (button)
      {
      case BUT_V:
	  copyXPMArea (BUT_V_SRC_X, BUT_V_SRC_Y,
		       12, 11,
		       BUT_V_X, BUT_V_Y);
	  break;
      case BUT_X:
	  copyXPMArea (BUT_X_SRC_X, BUT_X_SRC_Y,
		       12, 11,
		       BUT_X_X, BUT_X_Y);
	  break;
      case BUT_REW:
	  copyXPMArea (BUT_R_SRC_X, BUT_R_SRC_Y,
		       12, 11,
		       BUT_R_X, BUT_R_Y);
	  break;
      case BUT_FF:
	  copyXPMArea (BUT_F_SRC_X, BUT_F_SRC_Y,
		       12, 11,
		       BUT_F_X, BUT_F_Y);
	  break;
      }
}
Beispiel #4
0
static void draw_scale(int width,int dx,int dy)
{
    copyXPMArea(scale_f_x,scale_f_y,width,scale_height,dx,dy);
    if(width<scale_width) {
	copyXPMArea(scale_b_x+width,scale_b_y,scale_width-width,scale_height,dx+width,dy);
    }
    RedrawWindowXY(0,0);
}
Beispiel #5
0
void DrawBar(int sx, int sy, int w, int h, float percent, int dx, int dy)
{
    int	tx = (float)((float)w * ((float)percent / (float)100.0));

    copyXPMArea(sx, sy, tx, h, dx, dy);

    copyXPMArea(sx, sy + h + 1, w - tx, h, dx + tx, dy);
}
Beispiel #6
0
/* Show AC status led */
void ShowACstatus(int ac_on_line)
{
  /* Check AC status. */
  if (ac_on_line)
    /* AC on-line. I.e. we are "plugged-in". */
    copyXPMArea (68, 6, 12, 7, 31, 35);
  else
    /* AC off-line. I.e. we are using battery. */
    copyXPMArea (68, 20, 12, 7, 31, 35);
}
Beispiel #7
0
/* Display Temperature */
void ShowTemperature(int temp, int temp_is_celsius)
{
  /* PM_Error getting temperature value */
  /* or value out of range              */
  if ( (temp < 0) || (temp > 99) )
  {
    /* Plot PM_Error message */
    copyXPMArea (165, 60, 6, 7, 33, 50);
    copyXPMArea (165, 60, 6, 7, 39, 50);
    copyXPMArea (135, 60, 6, 7, 45, 50);
    copyXPMArea ( 68, 69, 6, 7, 51, 50);
    return;
  }

  /* Plot temperature */
  if (temp < 10) copyXPMArea ((temp) * 6 + 4, 69, 6, 7, 39, 50);
  else
  {
    copyXPMArea ((temp / 10) * 6 + 4, 69, 6, 7, 33, 50);
    copyXPMArea ((temp % 10) * 6 + 4, 69, 6, 7, 39, 50);
  }

  /* Plot the ° Symbol */
  copyXPMArea (135, 60, 6, 7, 45, 50);

  /* Plot the C Symbol */
  if (temp_is_celsius) copyXPMArea (68, 69, 6, 7, 51, 50);
}
Beispiel #8
0
static void draw_digit(int value,int dx,int dy)
{
    if(value>99) {
	copyXPMArea(9*digit_width+digit_2_x,digit_2_y,digit_width,digit_height,dx,dy);
	copyXPMArea(9*digit_width+digit_2_x,digit_2_y,digit_width,digit_height,dx+digit_width,dy);
    } else {
	copyXPMArea((value/10)*digit_width+digit_1_x,digit_1_y,digit_width,digit_height,dx,dy);
	copyXPMArea((value%10)*digit_width+digit_1_x,digit_1_y,digit_width,digit_height,dx+digit_width,dy);
    }
    RedrawWindowXY(0,0);
}
Beispiel #9
0
/* Display fan status */
void ShowFanStatus(int fan_status)
{
  if (fan_status == PM_Error)
  {
    /* Plot the red - Symbol                */
    copyXPMArea (165, 60, 6, 7, 23, 50);
    return;
  }

  /* Plot fan status: 0 not active, 1 running */
  copyXPMArea (fan_status * 6 + 4, 69, 6, 7, 23, 50);
}
Beispiel #10
0
void DrawActiveIFS(char *real_name)
{

	/* Cijfers op: 0,65
	   Letters op: 0,75
	   Alles 9 hoog, 6 breedt

	   Destinatie: 5,5
	*/

	size_t		i;
	int		k;
	size_t		len;
	char		name[256];


	copyXPMArea(5, 84, 30, 10, 5, 5);


	strcpy(name, real_name);
	len = strlen(name);
	if (len > 5) {
		for (i = len-5; i < len && !(name[i] >= '0' && name[i] <= '9'); i++)
			;
		for (; i <= len; i++) /* '=' to get the '\0' character moved too \*/
			name[i-(len-5)] = name[i];
	}

	k = 5;
	for (i = 0; name[i]; i++) {
		int c;

		if (i == strlen(name)-1 && strlen(name) <= 4 && name[strlen(name)-1] >= '0' &&
		    name[strlen(name)-1] <= '9') {
			copyXPMArea(61, 64, 4, 9, k, 5);
			k += 4;
		}
		c = toupper(name[i]);
		if (c >= 'A' && c <= 'Z') {
			c -= 'A';
			copyXPMArea(c * 6, 74, 6, 9, k, 5);
			k += 6;
		} else {
			c -= '0';
			copyXPMArea(c * 6, 64, 6, 9, k, 5);
			k += 6;
		}
	}

}
Beispiel #11
0
/* Display charge status */
void ShowChargeStatus(int charging)
{
  /* Paste up the default charge status and time */
  copyXPMArea ( 83, 93, 41, 9, 15, 7);
  copyXPMArea (104,  6,  5, 7,  6, 7);

  /* Check to see if we are charging. */
  if (charging)
    /* Battery Status: Charging.      */
    copyXPMArea (82, 68, 7, 9, 6, 7);
  else
    /* Battery Status: NOT Charging.  */
    copyXPMArea (88, 68, 7, 9, 6, 7);
}
Beispiel #12
0
/*
 *  This routine handles button presses. Pressing the '<|' button
 *  invokes 'previous UPS' to change the monitored UPS (if multiple)
 *  pressing the '|>' button invokes 'next UPS'...
 *
 */
void pressEvent(XButtonEvent *xev){
  
  int x=xev->x;
  int y=xev->y;
  
  if(x>=5 && y>=48 && x<=17 && y<=58){
    
    /* 
     *  look if multiple hosts are monitored
     */
    
    /*
     *  Standby Call.
     *
     *  Draw button as 'pushed'. Redraw window to show it.
     *  Call 'nut -S' to standby. Sleep for 2 seconds so that
     *  the button doesnt immediately redraw back to unpressed
     *  before the 'nut -S' takes effect.
     */
    copyXPMArea(5, 106, 13, 11, 5, 48);
    RedrawWindow();

    GetPrevHost();

    //	system("nut -S");
    
  } else if (x>=46 && y>=48 && x<=58 && y<=58){
    
    /*
     *  Suspend Call.
     *
     *  Draw button as 'pushed'. Redraw window to show it.
     *  Call 'nut -s' to suspend. Sleep for 2 seconds so that
     *  the button doesnt immediately redraw back to unpressed
     *  before the 'nut -s' takes effect.
     */
    copyXPMArea(21, 106, 13, 11, 46, 48);
    RedrawWindow();
    
    GetNextHost();

    //	system("nut -s");    
  }

  //usleep(2000000L);
  usleep(500L);
  
  return;
}
Beispiel #13
0
void DrawLite(int state, int dx, int dy)
{
    switch (state) {
    case B_RED:
        copyXPMArea(BREDX, BREDY, LITEW, LITEH, dx, dy);
        break;
    case B_GREEN:
        copyXPMArea(BGREENX, BGREENY, LITEW, LITEH, dx, dy);
        break;
    default:
    case B_OFF:
        copyXPMArea(BOFFX, BOFFY, LITEW, LITEH, dx, dy);
        break;
    }
}
Beispiel #14
0
void DrawMeter(unsigned int level, unsigned int peak, int dx, int dy)
{
    unsigned int	a;

    /* meters are on a per interruptscale, dictated by the peak, maintain
     * this peak outside of here, you can use a fixed peak for all ints but
     * since we're using only 4 lines for our level, the timer interrupt
     * usually kills the peak for the others so they never move. */

    if (peak) {
        a = level * 3 / peak;
    } else a = 0;

#ifdef MONDEBUG
    printf("level: %u peak: %u selection: %u\n", level, peak, a);
    fflush(stdout);
#endif

    if (a > 3) a = 3;

    copyXPMArea(meter[a][0],
                meter[a][1],
                VBAR_W,
                VBAR_H,
                dx,
                dy);
}
Beispiel #15
0
/*******************************************************************************\
|* SetOffLED                                                                                                                               *|
\*******************************************************************************/
void SetOffLED(int led)
{

	switch (led) {

	case LED_NET_RX:
		copyXPMArea(LED_OFF_NET_X, LED_OFF_NET_Y, LED_SZE_X, LED_SZE_Y,  LED_RCV_X, LED_RCV_Y);
		break;
	case LED_NET_TX:
		copyXPMArea(LED_OFF_NET_X, LED_OFF_NET_Y, LED_SZE_X, LED_SZE_Y,  LED_SND_X, LED_SND_Y);
		break;
	case LED_NET_POWER:
		copyXPMArea(LED_OFF_NET_X, LED_OFF_NET_Y, LED_SZE_X, LED_SZE_Y,  LED_PWR_X, LED_PWR_Y);
		break;
	}
}
Beispiel #16
0
void
SetOnLED (int led)
{
    switch (led)
      {
      case LED_PPP_POWER:
	  copyXPMArea (LED_ON_X, LED_ON_Y, LED_SZE_X, LED_SZE_Y, LED_PWR_X, LED_PWR_Y);
	  break;
      case LED_PPP_RX:
	  copyXPMArea (ARR_DN_X, ARR_DN_Y+ARR_ACTV, ARR_W, ARR_H, LED_RCV_X, LED_RCV_Y);
	  break;
      case LED_PPP_TX:
	  copyXPMArea (ARR_UP_X, ARR_UP_Y+ARR_ACTV, ARR_W, ARR_H, LED_SND_X, LED_SND_Y);
	  break;
      }
}
Beispiel #17
0
void draw_string(char* s)
{
  int i;
  for(i=0; i<strlen(s) && i<8; i++) {
    copyXPMArea((toupper(s[i]) - 'A')*6, 74, 6, 9, 5+(i*6), 49);
  }
}
Beispiel #18
0
static void
DisplayOpenedEmptyMailbox( void )
{
  /* Opened and empty mailbox image */
  copyXPMArea( MAILBOX_OPENED_EMPTY_SRC_X, MAILBOX_OPENED_EMPTY_SRC_Y,
	       MAILBOX_SIZE_X, MAILBOX_SIZE_Y, MAILBOX_DEST_X, MAILBOX_DEST_Y );
  RedrawWindow();
}
Beispiel #19
0
static void
DisplayExecuteCommandNotification( void )
{
  /* Visual notification that the double-click was catched. */
  copyXPMArea( EXEC_CMD_IMG_SRC_X, EXEC_CMD_IMG_SRC_Y,
	       MAILBOX_SIZE_X, MAILBOX_SIZE_Y, MAILBOX_DEST_X, MAILBOX_DEST_Y );
  RedrawWindow();
}
Beispiel #20
0
static void
DisplayClosedMailbox( void )
{
  /* Opened mailbox image */
  copyXPMArea( MAILBOX_CLOSED_SRC_X, MAILBOX_CLOSED_SRC_Y,
	       MAILBOX_SIZE_X, MAILBOX_SIZE_Y,
	       MAILBOX_DEST_X, MAILBOX_DEST_Y );
  RedrawWindow();
}
Beispiel #21
0
static void
DisplayOpenedFullMailbox( void )
{
  /* Full mailbox image */
  copyXPMArea( MAILBOX_OPENED_FULL_SRC_X, MAILBOX_OPENED_FULL_SRC_Y,
	       MAILBOX_SIZE_X, MAILBOX_SIZE_Y,
	       MAILBOX_DEST_X, MAILBOX_DEST_Y );
  RedrawWindow();
}
Beispiel #22
0
/*******************************************************************************\
|* SetErrLED                                                                                                                               *|
\*******************************************************************************/
void SetErrLED(int led)
{

	switch (led) {
	case LED_NET_POWER:
		copyXPMArea(LED_ERR_NET_X, LED_ERR_NET_Y, LED_SZE_X, LED_SZE_Y,  LED_PWR_X, LED_PWR_Y);
		break;
	}
}
Beispiel #23
0
void
dockapp_draw_big_str( const char* string_to_draw,
		      int digit_draw_location_x,
		      int digit_draw_location_y )
{
   int string_length = 0;
   int string_character_position = 0;
   int string_character = 0;
   int digit_new_draw_location_x = 0;

   string_length = strlen( string_to_draw );

   if ( ( ( DOCKAPP_WIDTH - DOCKAPP_BIG_CHAR_WIDTH ) < digit_draw_location_x
	  || ( DOCKAPP_HEIGHT - DOCKAPP_BIG_CHAR_HEIGHT ) < digit_draw_location_y )
	|| ( 0 > digit_draw_location_x || 0 > digit_draw_location_y ) )
    {
       fprintf( stderr,
		"%s: Invalid x,y position: %d,%d\n",
		__func__,
		digit_draw_location_x,
		digit_draw_location_y );

       return;
    }
   else if ( 0 == string_length )
   {
      fprintf( stderr, "%s: Draw string is empty!\n", __func__ );
      return;
   }
   else if ( ( DOCKAPP_WIDTH / DOCKAPP_BIG_CHAR_WIDTH ) < string_length )
   {
      fprintf( stderr, "%s: Draw string is too long!", __func__ );
      return;
   }

   digit_new_draw_location_x = digit_draw_location_x;

   for ( string_character_position = 0;
	 string_character_position < string_length;
	 ++string_character_position )
   {
      string_character = dockapp_utils_get_char( string_to_draw[string_character_position] );

      copyXPMArea( string_character * DOCKAPP_BIG_CHAR_WIDTH + DOCKAPP_BIG_LETTER_X,
		     DOCKAPP_BIG_LETTER_Y,
		     DOCKAPP_BIG_CHAR_WIDTH,
		     DOCKAPP_BIG_CHAR_HEIGHT,
		     digit_new_draw_location_x,
		     digit_draw_location_y );

      digit_new_draw_location_x += DOCKAPP_BIG_CHAR_WIDTH;
   }

  RedrawWindow();
}
Beispiel #24
0
void
PrintLittle (int i, int *k)
{

    switch (i)
      {
      case -1:
	  *k -= 5;
	  copyXPMArea (12 * 5, ERR_SRC_Y, 4, 8, *k, ERR_DEST_Y);
	  break;
      case 0:
	  *k -= 5;
	  copyXPMArea (45, ERR_SRC_Y, 5, 8, *k, ERR_DEST_Y);
	  break;
      default:
	  *k -= 5;
	  copyXPMArea (i * 5 - 5, ERR_SRC_Y, 5, 8, *k, ERR_DEST_Y);
	  break;
      }
}
Beispiel #25
0
void
SetWaitLED (int led)
{

    switch (led)
      {
      case LED_PPP_POWER:
	  copyXPMArea (LED_WTE_X, LED_WTE_Y, LED_SZE_X, LED_SZE_Y, LED_PWR_X, LED_PWR_Y);
	  break;
      }
}
Beispiel #26
0
void ButtonDisable(int button)
{
	switch (button) {
	case BUT_START:
		copyXPMArea( 65,  1, 18, 11,  5, 48);
		break;
	case BUT_PAUSE:
		copyXPMArea( 84,  1, 18, 11, 23, 48);
		break;
	case BUT_STOP:
		copyXPMArea(103,  1, 18, 11, 41, 48);
		break;
	case BUT_PREV:
		copyXPMArea(122,  1, 12, 11,  5, 33);
		break;
	case BUT_NEXT:
		copyXPMArea(135,  1, 12, 11, 47, 33);
		break;
	}
}
Beispiel #27
0
void show_governor(char *ptr)
{
   int i,a,c;
   for(i=0;i<8;i++)
     {
	a=(int)ptr[i];
	c=show_char(a);
	copyXPMArea(6+(6*c),78,6,9, 7+(6*i), 49);
     }
   RedrawWindow();
   return;
}
Beispiel #28
0
void show_driver( char *pt)
{
   int i,a,c;
   for(i=0;i<8;i++)
     {
	a=(int)pt[i];
        c=show_char(a);
	copyXPMArea(6+(6*c),64,6,9, 7+(6*i), 34);
     }
   RedrawWindow();
   return;
}
Beispiel #29
0
void
DrawTime (int i, int j)
{

    int k = 1000;

    copyXPMArea (TIMER_SZE_X * ((i / k) % 10) + 1, TIMER_SRC_Y,
		 5, 7,
		 TIMER_DES_X + 6 * 0, TIMER_DES_Y);
    k = k / 10;
    copyXPMArea (TIMER_SZE_X * ((i / k) % 10) + 1, TIMER_SRC_Y,
		 5, 7,
		 TIMER_DES_X + 6 * 1, TIMER_DES_Y);
    k = k / 10;

    /* colon */
    if (j)
	copyXPMArea (62, TIMER_SRC_Y,
		     1, 7,
		     TIMER_DES_X + 6 * 2 + 1, TIMER_DES_Y);
    else
	copyXPMArea (63, TIMER_SRC_Y,
		     1, 7,
		     TIMER_DES_X + 6 * 2 + 1, TIMER_DES_Y);

    copyXPMArea (TIMER_SZE_X * ((i / k) % 10) + 1, TIMER_SRC_Y,
		 5, 7,
		 TIMER_DES_X + 6 * 2 + 4, TIMER_DES_Y);
    k = k / 10;
    copyXPMArea (TIMER_SZE_X * ((i / k) % 10) + 1, TIMER_SRC_Y,
		 5, 7,
		 TIMER_DES_X + 6 * 3 + 4, TIMER_DES_Y);
}
Beispiel #30
0
/* Display battery status led */
void ShowBatteryLed(int present, int percentage, int ac_on_line)
{
  static int Toggle;  /* Switch for battery led blinking */

  if (!present)
  {
    copyXPMArea (95, 19, 16, 10, 43, 34);
    return;
  }

  /* Battery Status: Critical.   */
  /* Blink the red led on/off... */
  if (percentage <= CriticalLevel && !ac_on_line)
  {
    if (Toggle || (BlinkRate == 0.0))
    {
      if (Beep && !ac_on_line) XBell (display, Volume);
      Toggle = 0;
      copyXPMArea (4, 105, 16, 10, 43, 34);
    }
    else
    {
      Toggle = 1;
      copyXPMArea (58, 105, 16, 10, 43, 34);
    }
    return;
  }

  /* Battery Status: Low. */
  /* Fixed yellow led     */
  if (percentage <= LowLevel)
  {
    copyXPMArea (22, 105, 16, 10, 43, 34);
    return;
  }

  /* Battery Status: Normal. */
  /* Fixed blue led          */
  copyXPMArea (40, 105, 16, 10, 43, 34);
}