Exemple #1
0
LRESULT CALLBACK MeterWndHandler(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{   
	int t;
	THRESHOLDOBJ * st;
	

	st=NULL;
	for (t=0;(t<GLOBAL.objects)&&(st==NULL);t++)
		if (objects[t]->type==OB_THRESHOLD)
		{	st=(THRESHOLDOBJ *)objects[t];
		    if (st->displayWnd!=hWnd) st=NULL;
		}

	if (st==NULL) return DefWindowProc( hWnd, message, wParam, lParam );
	
	switch( message ) 
	{	case WM_DESTROY:
		 break;
		case WM_KEYDOWN:
			  SendMessage(ghWndMain, message,wParam,lParam);
			break;
		case WM_MOUSEACTIVATE:
   	      st->redraw=1;
		  close_toolbox();
		  actobject=st;
		  SetWindowPos(hWnd,HWND_TOP,0,0,0,0,SWP_DRAWFRAME|SWP_NOMOVE|SWP_NOSIZE);
		  InvalidateRect(ghWndDesign,NULL,TRUE);
			break;
		case WM_SIZE: 
		case WM_MOVE:
			{
			WINDOWPLACEMENT  wndpl;
			GetWindowPlacement(st->displayWnd, &wndpl);
			st->top=wndpl.rcNormalPosition.top;
			st->left=wndpl.rcNormalPosition.left;
			st->right=wndpl.rcNormalPosition.right;
			st->bottom=wndpl.rcNormalPosition.bottom;
			}
			st->redraw=1;
			InvalidateRect(hWnd,NULL,TRUE);
			break;

		case WM_ERASEBKGND:
			st->redraw=1;
			return 0;

		case WM_PAINT:
			draw_meter(st);
  	    	break;
		default:
			return DefWindowProc( hWnd, message, wParam, lParam );
    } 
    return 0;
}
Exemple #2
0
LRESULT CALLBACK MeterWndHandler(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{   
	int t;
	THRESHOLDOBJ * st;
	

	st=NULL;
	for (t=0;(t<GLOBAL.objects)&&(st==NULL);t++)
		if (objects[t]->type==OB_THRESHOLD)
		{	st=(THRESHOLDOBJ *)objects[t];
		    if (st->displayWnd!=hWnd) st=NULL;
		}

	if (st==NULL) return DefWindowProc( hWnd, message, wParam, lParam );
	
	switch( message ) 
	{	case WM_DESTROY:
		 break;
		case WM_KEYDOWN:
			// printf("keydown: %ld, %ld\n",lParam,wParam);
		    switch(wParam) {
				case KEY_UP:
				  // step=st->gain/50; 
				  //if (step<1) step=1;
  				  st->from_input+=1;
	   			  InvalidateRect(st->displayWnd,NULL,TRUE);
				break;
				case KEY_DOWN:
				  // step=st->gain/50; 
				  // if (step<1) step=1;
  				  st->from_input-=1;
	   			  InvalidateRect(st->displayWnd,NULL,TRUE);
				break;
				}
		break;

		case WM_MOUSEACTIVATE:
   	      st->redraw=1;
		  close_toolbox();
		  actobject=st;
		  SetWindowPos(hWnd,HWND_TOP,0,0,0,0,SWP_DRAWFRAME|SWP_NOMOVE|SWP_NOSIZE);
		  InvalidateRect(ghWndDesign,NULL,TRUE);
			break;
		case WM_SIZE: 
		case WM_MOVE:
			{
			WINDOWPLACEMENT  wndpl;
			GetWindowPlacement(st->displayWnd, &wndpl);


			  if (GLOBAL.locksession) {
				  wndpl.rcNormalPosition.top=st->top;
				  wndpl.rcNormalPosition.left=st->left;
				  wndpl.rcNormalPosition.right=st->right;
				  wndpl.rcNormalPosition.bottom=st->bottom;
				  SetWindowPlacement(st->displayWnd, &wndpl);
 				  SetWindowLong(st->displayWnd, GWL_STYLE, GetWindowLong(st->displayWnd, GWL_STYLE)&~WS_SIZEBOX);
			  }
			  else {
				  st->top=wndpl.rcNormalPosition.top;
				  st->left=wndpl.rcNormalPosition.left;
				  st->right=wndpl.rcNormalPosition.right;
				  st->bottom=wndpl.rcNormalPosition.bottom;
				  st->redraw=TRUE;
				  SetWindowLong(st->displayWnd, GWL_STYLE, GetWindowLong(st->displayWnd, GWL_STYLE) | WS_SIZEBOX);
			  }
			  InvalidateRect(hWnd,NULL,TRUE);
			}
			break;

		case WM_ERASEBKGND:
			st->redraw=1;
			return 0;

		case WM_PAINT:
			draw_meter(st);
  	    	break;
		default:
			return DefWindowProc( hWnd, message, wParam, lParam );
    } 
    return 0;
}
Exemple #3
0
static void
update_frame0 (const APP *a, int full)
{
    const DOCKAPP *d = (DOCKAPP *)a;
    const FRAME *frame = &a->frames[0];

    char buf[16];

    time_t at;
    struct tm *bt;

    static CPUSTAT avg;

    int wifi;

    int temp;
    int crit;

    int on_line;
    int battery;
    BATSTAT total;

    if (full) {
	if (!d->iswindowed) {
	    dockapp_set_shape(d, frame->m);
	}

	dockapp_copy_area(d, frame->f, 0, 0, d->width, d->height, 0, 0);
    }

    at = time(NULL);
    bt = localtime(&at);
    sprintf(buf, "%2d:%02d", bt->tm_hour, bt->tm_min);
    draw_text(a, &a->fontx9, buf, 15, 2);

    if (system_get_cpu_load(0, &avg, NULL) > 0) {
	sprintf(buf, "__CPU__%3d%%", avg.used);
    } else {
	strcpy(buf, "      _____");
    }
    draw_text(a, &a->fontx8, buf, 1, 17);

    if (system_get_best_wifi(&wifi)) {
	sprintf(buf, "%3d\xF7", wifi);
    } else {
	strcpy(buf, "   \xF7");
    }
    draw_text(a, &a->fontx8, buf, 0, 31);

    if (system_get_max_temp(a->list, &temp, &crit)) {
	sprintf(buf, "%3d\xF8", temp);
    } else {
	strcpy(buf, "   \xF8");
    }
    draw_text(a, &a->fontx8, buf, 31, 31);

    battery = system_get_battery(a->list, 0, &total, NULL);
    on_line = system_get_ac_adapter(a->list);
    if (battery) {
	int ratio = 100 * total.curr_cap / total.full_cap;
	int ch = 0xB0;
	if (ratio >= 33) {
	    ch++;
	}
	if (ratio >= 66) {
	    ch++;
	}
	if (total.rate) {
	    if (on_line) {
		/* charging */
		int estimate = 60 * (total.full_cap - total.curr_cap) / total.rate;
		int hours = estimate / 60;
		if (hours > 99) {
		    hours = 99;
		}
		sprintf(buf, "%c__%2d:%02d\xAE\x98", ch, hours, estimate % 60);
	    } else {
		/* discharging */
		int estimate = 60 * total.curr_cap / total.rate;
		int hours = estimate / 60;
		if (hours > 99) {
		    hours = 99;
		}
		sprintf(buf, "%c__%2d:%02d__ ", ch, hours, estimate % 60);
	    }
	} else {
	    if (on_line) {
		/* bat + AC */
		sprintf(buf, "%c__%3d%%___\x98", ch, ratio);
	    } else {
		/* bat */
		sprintf(buf, "%c__%3d%%___ ", ch, ratio);
	    }
	}
	draw_meter(a, &a->meter2, total.curr_cap, total.full_cap, 3, 55);
    } else {
	if (on_line) {
	    /* only AC */
	    strcpy(buf, "     _____\x98");
	} else {
	    /* nada */
	    strcpy(buf, "     _____ ");
	}
	draw_meter(a, &a->meter2, 0, 0, 3, 55);
    }
    draw_text(a, &a->fontx9, buf, 2, 44);

    dockapp_update(d);
}