?? dispdigit.c
字號(hào):
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <pwd.h>
#include <math.h>
#include <minigui/common.h>
#include <minigui/minigui.h>
#include <minigui/gdi.h>
#include <minigui/window.h>
#include <minigui/control.h>
#include <sys/types.h>
#include <sys/shm.h>
#include <sys/ipc.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "common.h"
#include "fonts.h"
#include "dispdigit.h"
//通過(guò)channel_disp結(jié)構(gòu)體中
//color
//tagname,
//unit來(lái)傳遞參數(shù)
void DrawDigitalRect(HDC hdc,int i, int l, int t, int w, int h)
{
unsigned char str[10];
int id;
gal_pixel colorl_text;
id=i;
colorl_text=RGB2Pixel(hdc,0,0,0);//PIXEL_lightgray
SetPenColor (hdc,PIXEL_lightgray);//COLOR_darkgray
Rectangle(hdc, l, t, l + w, t + h); //channel_disp[id].color
SetBrushColor(hdc,channel_disp[id].color); //RGB2Pixel(hmemDC,id*30,128,abs(8-id)*64)
FillBox(hdc, l+1, t+1, w-1, h-1);
SelectFont(hdc,songgb16font); //設(shè)置字體
TextOut(hdc,l+w/2,t+h/2,channel_disp[id].data);
bzero(str,10);
sprintf(str,"%ds",channel_conf[id].interval);
TextOut(hdc,l+w-30,t+h-16,str);//采樣時(shí)間間隔
memcpy(str,channel_conf[id].name,sizeof(channel_conf[id].name));
TextOut(hdc,l,t,str);//channel_disp[id].tagname
TextOut(hdc,l+w-30,t,channel_conf[id].unit);//單位
}
/*
根據(jù)通道個(gè)數(shù)計(jì)算出坐標(biāo),大小
根據(jù)坐標(biāo),大小,顏色顯示
入口:當(dāng)前頁(yè)計(jì)數(shù)器,當(dāng)前頁(yè)顯示的個(gè)數(shù)
number:總共啟用的通道數(shù)目
*/
void DrawDigital(HDC hdc,int first,int number,int add_x,int add_h)
{
int i;
int x,y,w,h;
int add_y,add_w;
HDC hmemDC;
gal_pixel rect_color_back;
hmemDC=CreateCompatibleDC(hdc);
SetBrushColor(hmemDC,PIXEL_black);//PIXEL_lightwhite
SetBkMode(hmemDC,BM_TRANSPARENT);
add_w=WIDTH-add_x;
FillBox(hmemDC,add_x,TOP,add_w,add_h);
// SetBkMode(hmemDC,PIXEL_lightwhite);
for (i=first;i<number+first;i++)
{
x=channel_disp[i].x;
y=channel_disp[i].y;
w=channel_disp[i].width;
h=channel_disp[i].height;
DrawDigitalRect(hmemDC,i,x,y,w,h);
}
BitBlt(hmemDC,0,TOP,add_w,add_h,hdc,add_x,TOP,0);//
DeleteCompatibleDC(hmemDC);
// rect_color_back=RGB2Pixel(hdc,0,0,100);
// SetBrushColor(hdc,rect_color_back);
// FillBox(hdc,1,1,WIDTH,TOP);
}
//剛進(jìn)入此頁(yè)面時(shí)候調(diào)用通道坐標(biāo)生成
//設(shè)置顯示坐標(biāo)
void SetCoordinate(int first,int n,int x,int h)
{
int channum;
int rows;
int cols;
int i;//行計(jì)數(shù)器
int j;//列計(jì)數(shù)器
int r;//余數(shù)
int LastRowCols;
int sn;
int temp_row;
unsigned char tempstr[20];
unsigned int y,w;
y=TOP;
w=WIDTH-x;
//規(guī)范化
if( first<0)first=0;
//加入n=1那么cols=1,rows=1
/*設(shè)置坐標(biāo)*/
channum=n;
cols=sqrt(channum);//列
rows=channum/cols;
r=channum-(cols*rows); /*余數(shù)*/
while((r>0)&&((r<=cols/2) ||( r>cols)))
{
cols=cols+1;
rows=channum/cols;
r=channum-(cols*rows);
}
//正好整除
if(cols*rows==channum)
{
for(i=0;i<rows;i++)
for(j=0;j<cols;j++)
{sn=first+i*cols+j;
channel_disp[sn].x=j*w/cols;
channel_disp[sn].y=i*h /rows+y;
channel_disp[sn].width=w/cols-1;
channel_disp[sn].height=h /rows-1;
}
}
if(cols*rows<channum)
{
for(i=0;i<rows;i++)
{
for(j=0;j<cols;j++)
{sn=first+i*cols+j;
channel_disp[sn].x=j*w/cols;
channel_disp[sn].y=i*h/(rows+1)+y;
if(j==(cols-1))channel_disp[sn].width=w/cols-1;
else channel_disp[sn].width=w/cols;
channel_disp[sn].height=h /(rows+1);
}
}
LastRowCols=channum-cols*(rows);
for(i=1;i<=LastRowCols;i++)
{
sn=cols*(rows)+i-1;
if(i==LastRowCols){
channel_disp[sn].x=(i-1)*w/LastRowCols-1;
channel_disp[sn].width=w/LastRowCols+1;
}
else {
channel_disp[sn].x=(i-1)*w/LastRowCols;
channel_disp[sn].width=w/LastRowCols;
}
channel_disp[sn].y=h-h /(rows+1)+y;
channel_disp[sn].height=h /(rows+1);
}
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -