Example #1
0
Rectangle Rectangle::quadrant( int q ) const
{

    q %= 4;

    int qWidth = getwidth() / 2 - (getwidth() % 2 ? 0 : 1);
    int qHeight = getheight() / 2 - (getheight() % 2 ? 0 : 1);

    switch (q)
    {

        case 0:
            return Rectangle( a.get_x(), a.get_y(), a.get_x() + qWidth, a.get_y() + qHeight );

        case 1:
            return Rectangle( b.get_x() - qWidth, a.get_y(), b.get_x(), a.get_y() + qHeight );

        case 2:
            return Rectangle( a.get_x(), b.get_y() - qHeight, a.get_x() + qWidth, b.get_y() );

        case 3:
            return Rectangle( b.get_x() - qWidth, b.get_y() - qHeight, b.get_x(), b.get_y() );
        default:
            break;
    }

    // Error getting rectangle quadrant:
    assert(0);
    return Rectangle();

}
Example #2
0
HelpWin::HelpWin(int rows, int cols) : NGroup(NRect(rows, cols, getmaxy(stdscr)/2-rows/2,getmaxx(stdscr)/2-cols/2))
{
    caption = strdup(" Hot keys list ");
    modalflag = true;
    resize(17,60);
    wattrset(win,getcolorpair(COLOR_WHITE, COLOR_BLACK) | A_BOLD);
    if(asciilinedraw == 1)
	wborder(win, '|', '|', '-', '-', '+', '+', '+', '+');
    else
	box(win,0,0);
    mvwprintw(win,0,getwidth()/2-(strlen(caption)/2),caption);
    text1 = new NStaticText(NRect(getheight()-2,getwidth()-2,/*rect.begrow+*/1,/*rect.begcol+*/1));
    int attr1 = getcolorpair(COLOR_YELLOW, COLOR_BLACK) | A_BOLD;
    int attr2 = getcolorpair(COLOR_WHITE, COLOR_BLACK) | A_BOLD;
    text1->setstring(attr1,   "\n   Common Controls:\n");
    text1->appendstring(attr2,"       \"N\"           - Toogle between BOINC hosts\n");
    text1->appendstring(attr2,"       \"C\"           - Edit configuration\n");
    text1->appendstring(attr2,"       \"Q\"           - Quit boinctui\n");
    text1->appendstring(attr2,"       \"F9\"          - Toogle main menu\n");
    text1->appendstring(attr2,"       \"PgUp\"/\"PgDn\" - Scroll Messages Window\n");
    text1->appendstring(attr2,"\n");
    text1->appendstring(attr1,"   Task Controls:\n");
    text1->appendstring(attr2,"       \"Up\"/\"Dn\"     - Select task\n");
    text1->appendstring(attr2,"       \"S\"           - Suspend selected running task\n");
    text1->appendstring(attr2,"       \"R\"           - Resume selected suspended task\n");
    text1->appendstring(attr2,"       \"A\"           - Abort selected task\n");
    text1->appendstring(attr2,"       \"Enter\"       - View selected task raw info\n");
    insert(text1);
}
Example #3
0
File: scene2.c Project: stroucki/bb
static void dvojprujezd2(int starttime, char *text1, char *text2)
{
    int pos = (getwidth(2) * strlen(text1) + 1);
    centerprint(-pos / 2 + (aa_imgwidth(context) + pos * 1.2) * STATE / (endtime - starttime), aa_imgheight(context) / 3, 2, 255, text1, 0);
    pos = (getwidth(2) * strlen(text2) + 1);
    centerprint(aa_imgwidth(context) + pos / 2 - (aa_imgwidth(context) + pos * 1.2) * STATE / (endtime - starttime), 2 * aa_imgheight(context) / 3, 2, 255, text2, 0);
}
Example #4
0
void getwidth(struct node* root,int con[],int level)
{
    if(root)
    {
     con[level]++;
     getwidth(root->left,con,level+1);
     getwidth(root->right,con,level+1);
    }
}
Example #5
0
MainWin::MainWin(NRect rect/*, Config* cfg*/) : NGroup(rect)
{
    //читаем опции из конфига если нет то создаем
    wtaskheightpercent = 5000;
    if (gCfg != NULL)
    {
	Item* rootcfg = gCfg->getcfgptr();
	if (rootcfg != NULL)
	{
	    Item* wtask_height_percent = rootcfg->findItem("wtask_height_percent");
	    if (wtask_height_percent == NULL) //создать
	    {
		wtask_height_percent = new Item("wtask_height_percent");
		wtask_height_percent->setivalue(wtaskheightpercent);
		rootcfg->addsubitem(wtask_height_percent);
	    }
	    wtaskheightpercent = wtask_height_percent->getivalue();
	}
    }
    colname.push_back("  #  ");
    colname.push_back("state ");
    colname.push_back("   done%%");
    colname.push_back("  project             ");
    colname.push_back("  est");
    colname.push_back("  d/l");
    colname.push_back("  application                   ");
    colname.push_back("  task");
    tablheader = new NStaticText(NRect(1, rect.cols -2-(INFPANWIDTH)-1, 1, 1));
    tablheader->setstring(getcolorpair(COLOR_CYAN,COLOR_BLACK) | A_BOLD,"  #  state    done%%  project               est d/l   task");
    int wtaskheight = getheight() * wtaskheightpercent / 10000.0;
    if (wtaskheight < 5)
	wtaskheight = 5;
    if (wtaskheight > getheight() - 10)
	wtaskheight = getheight() - 10;
    wtask = new TaskWin(NRect(wtaskheight/*getheight()/2*/, getwidth()-2-(INFPANWIDTH)-1, 2, 1)); //создаем окно процессов внутри wmain
    setcoltitle();
    taskscrollbar = new NScrollBar(NRect(wtask->getheight()+2,1, wtask->getbegrow()-2, getwidth()-INFPANWIDTH-2), ACS_TTEE | A_BOLD, 0, ACS_VLINE | A_BOLD); //скроллбар панели задач
    wtask->setscrollbar(taskscrollbar);
    wmsg = new MsgWin(NRect(getheight()-wtask->getheight()-4, getwidth()-2-(INFPANWIDTH+1), wtask->getheight()+3, 1)); //создаем окно евентов
    hline = new NHLine(NRect(1, getwidth()-2-(INFPANWIDTH+1), wtask->getheight()+2, 1), NULL); //горизонтальная линия
//    vline = new NVLine(NRect(wtask->getheight()+1/*getheight()-2*/, 1, 1, getwidth()-INFPANWIDTH-2), NULL); //вертикальная линия
    msgscrollbar = new NScrollBar(NRect(wmsg->getheight()+2,1, wmsg->getbegrow()-1, getwidth()-INFPANWIDTH-2/*vline->getbegcol()*/),/*ACS_RTEE*/ACS_VLINE | A_BOLD,ACS_BTEE | A_BOLD, ACS_VLINE | A_BOLD); //скроллбар панели сообщений
    wmsg->setscrollbar(msgscrollbar);
    panel1 = new InfoPanel(NRect(getheight()-2,INFPANWIDTH,1,getwidth()-INFPANWIDTH-1));
    caption = new NColorString(0,"");
    insert(tablheader);
    insert(wtask);
    insert(wmsg);
    insert(hline);
//    insert(vline);
    insert(taskscrollbar);
    insert(msgscrollbar);
    insert(panel1);
}
Example #6
0
File: tabs.c Project: 99years/plan9
static
int
tablewidth(Table *t, int tw, int sep)
{
	Tablecell *c;
	int i, w, tmin, tmax, d;
	int *maxw, *minw;
	int totw;

	maxw = emalloc(sizeof(int)*t->ncol);
	minw = emalloc(sizeof(int)*t->ncol);
	for(c=t->cells; c!=nil; c=c->next){
		if(dimenkind(c->wspec) != Dnone){
			d = c->minw;
			c->minw = c->maxw = max(dimwidth(c->wspec, tw), c->minw);
			c->minw = d;
		}
		if(c->colspan != 1)
			continue;
		maxw[c->col] = max(maxw[c->col], c->maxw);
		minw[c->col] = max(minw[c->col], c->minw);
	}
	totw = 0;
	fixcols(t, maxw, sep, TRUE);
	tmax = getwidth(maxw, t->ncol);
	if(tmax <= tw){
		d = 0;
		if(tw>tmax && dimenkind(t->width)!=Dnone && t->availw!=Tablemax)
			d = (tw-tmax)/t->ncol;
		for(i=0; i<t->ncol; i++){
			t->cols[i].width = maxw[i] + d;
			totw += t->cols[i].width;
		}
	}else{
		fixcols(t, minw, sep, FALSE);
		tmin = getwidth(minw, t->ncol);
		w = tw - tmin;
		d = tmax - tmin;
		for(i=0; i<t->ncol; i++){
			if(w<=0 || d<=0)
				t->cols[i].width = minw[i];
			else
				t->cols[i].width = minw[i] + (maxw[i] - minw[i])*w/d;
			totw += t->cols[i].width;
		}
	}
	free(minw);
	free(maxw);

	return totw;
}
Example #7
0
bool Rectangle2D::contains(const Rectangle2D &r)
{
    //if the specified rectangle is inside this rectangle
    if ( ( x - getwidth()/2) < ( r.x - r.getwidth()/2 ) &&
         ( x + getwidth()/2) > ( r.x + r.getwidth()/2 ) &&
         ( y - getheight()/2) > ( r.y - r.getheight()/2 ) &&
         ( y + getheight()/2) < ( r.y + r.getheight()/2 ) )
    {
        return true;
    }
    else
    {
        return false;
    }
}
Example #8
0
/* PROTO */
void
get_screen_size(void)
{
#if defined(__MINGW32__) || defined(__DJGPP__) || defined(PLAN9)
#ifdef __MINGW32__
	CONSOLE_SCREEN_BUFFER_INFO p;

	GetConsoleScreenBufferInfo(hOut, &p);

	screen_cols = (int) p.dwSize.X;
	screen_lines = (int) p.dwSize.Y;
#endif

#ifdef PLAN9
	screen_cols = getwidth();
	screen_lines = 25;
#endif

#ifdef __DJGPP__
	struct text_info ti;

	gettextinfo(&ti);

	screen_cols = ti.screenwidth;
	screen_lines = ti.screenheight;
#endif
#else
	struct winsize  scrsize;

	ioctl(fileno(stdin), TIOCGWINSZ, &scrsize);
	screen_cols = scrsize.ws_col;
	screen_lines = scrsize.ws_row;
#endif
}
Example #9
0
void init(){

	int i;
	int hei,wid,col;

	C = H = W = 0;

	for(i = 0 ;i < N; i++){
		if(seq[i]){
			Color[C++] = -1;
			Width[W++] = -1;
			Height[H++] = -1;
		}else{
			col = getcolor();
			wid = getwidth();
			hei = getheight();
			colcount[col] += (hei*2) + (wid*4) -3;
		}
	}

	i = -1;
	S = 0;
	while(++i < MCOL && colcount[i]) S += colcount[i];

	K = i;

}
Example #10
0
int		getprecision(const char **str)
{
	int	rslt;
	(*str)++;
	rslt = getwidth(str);
	return (rslt);
}
void MessageDialog::on_dialog_init()
{
	Gobang::set_font(font_family_.c_str(), font_size_, false, false, dialog_image_);
	putimage_withalpha(dialog_image_, dialog_icon_,
										 icon_margin_,
										 (height_ - button_area_height_ - getheight(dialog_icon_)) / 2);

	setcolor(BLACK, dialog_image_);
	static UINT text_format = DT_LEFT | DT_TOP | DT_EDITCONTROL | DT_WORDBREAK | DT_WORD_ELLIPSIS;
	text_rect_.left = icon_margin_ + getwidth(dialog_icon_) + text_margin_;
	text_rect_.top = text_margin_;
	text_rect_.right = width_ - text_margin_;
	text_rect_.bottom = height_ - button_area_height_ - text_margin_;
	//rectangle(text_rect_.left, text_rect_.top, text_rect_.right, text_rect_.bottom, dialog_image_);
	//计算文本高度
	int text_height = DrawText(dialog_dc_, text_.c_str(), -1, &text_rect_, text_format | DT_CALCRECT);
	text_rect_.top = (height_ - button_area_height_ - text_height) / 2;
	text_rect_.bottom = height_ - button_area_height_ - text_margin_;
	DrawText(dialog_dc_, text_.c_str(), -1, &text_rect_, text_format);

	setfillcolor(EGERGB(230, 230, 230), dialog_image_);
	bar(0, height_ - button_area_height_, width_, height_, dialog_image_);

	ok_listener_ = OkButtonListener(dialog_handle_);
	ok_button_->set_on_click_listener(&ok_listener_);

}
Example #12
0
int main()
{
	initgraph(640, 480);

	//设置视口矩形区域为(200,100) - (330, 130)
	//最后一个参数为1表示出了这个区域的图形会被裁剪
	//后面所绘画的图形的原点坐标(0,0),会映射到(200,100)
	setviewport(200, 100, 330, 130, 1);

	//画一些文字,注意文字会因区域被裁剪的效果
	setcolor(EGERGB(0x0, 0xFF, 0x0));
	setfontbkcolor(RGB(0x80, 0x00, 0x80));
	setfont(18, 0, "宋体");
	outtextxy(0, 0, "Hello EGE Graphics");

	setbkmode(TRANSPARENT);
	outtextxy(0, 20, "Hello EGE Graphics");

	//还原视口
	setviewport(0, 0, getwidth(), getheight(), 1);
	outtextxy(0, 0, "Hello EGE Graphics");

	getch();

	closegraph();
	return 0;
}
Example #13
0
int main()
{
	Bitree T=NULL;
	Bitree AVL=NULL;
	int taller;
	int BST_height=0;
	int AVL_height=0;
	int BST_width=0;
	int AVL_width=0;
	srand(time(0));
	printf("please input treenode number:\n");
    int n,i;
	scanf("%d",&n);
	for(i=0;i<=n;i++)
	{
		insertBST(&T,rand()%1000);
	}
	for(i=0;i<=n;i++){
		insertAVL(&AVL,rand()%1000,&taller);
	}
	printf("average binary tree:\n");
	midordertraverse(AVL);
	printf("\n");
	printf("preordertraverse,root->lchild->rchild.:\n");
	preordertraverse(T);
	printf("\n");
	printf("midordertraverse,lchild->root->rchild.:\n");
	midordertraverse(T);
	printf("\n");
	printf("postordertraverse,visit leaves firstly.lchild->rchild.:\n");
	postordertraverse(T);
	printf("\n");
	printf("delete element of tree...\n");
	if(DeleteBST(&T,99)>0){
       midordertraverse(T);
	   printf("\n");
	}
	else 
		printf("element does not in this tree\n");
	BST_height=getHeight(T);
	AVL_height=getHeight(AVL);
	printf("BST_height:%d\nAVL_height:%d\n",BST_height,AVL_height);
	BST_width=getwidth(T);
	AVL_width=getwidth(AVL);
	printf("BST_height:%d\nAVL_height:%d\n",BST_width,AVL_width);

}
Example #14
0
void init() {
    int g = TRUECOLORSIZE, m = (g_height<<16) | g_width;
    //initgraph(&g, &m, "碧波荡漾");
    //setinitmode(3);
    initgraph(640, 480);
    g_width  = getwidth();
    g_height = getheight();
}
Example #15
0
void clearx(int y, int offset) {
	int start = 0, end = getwidth();
	if(offset < 0) {
		// from 0 to WIDTH-ABS(OFFSET)
		start = 0;
		end = getwidth() + offset;
	} else if(offset > 0) {
		// from OFFSET to WIDTH
		start = offset;
		end = getwidth();
	}

	for(int x = start; x <= end; x++) {
		gotoxy(x, y);
		printf(" ");
	}
}
Example #16
0
// 主函数
int main( int argc, char* argv[] ) {
    int i, ms_x = -1024, ms_y = -1024, exitflag = 0;
    int fps = 60;
    double dtime;

    int mode = preinit( argc, argv ); // 记录初始化模式
    if ( mode < 0 ) return 0;

    randomize(); // 初始化随机种子
    initgraph( -1, -1 ); // 打开图形窗口,以全屏模式

    showmouse( mode );
    sc_width = getwidth();
    sc_heigh = getheight();

    // 初始化所有星星
    for ( i = 0; i < g_max; i++ ) {
        InitStar( i );
        star[i].x = randomf();
    }
    // 绘制星空,按任意键或移动鼠标退出
    setfont( 12, 6, "宋体" );
    setrendermode( RENDER_MANUAL );
    dtime = fclock();
    while ( kbmsg() ) getkey();

    for ( ; !exitflag && is_run() && kbmsg() == 0; delay_fps( fps ) ) { //每秒画120帧,kbhit(1)是获取键盘任意键的消息,详见pdf
        // 如果有鼠标消息
        while ( mousemsg() ) {
            mouse_msg msg = getmouse();
            if ( ms_x <= -1024 ) {
                ms_x = msg.x;
                ms_y = msg.y;
            }
            // 处理鼠标,移动超出范围就退出
            if ( mode == 0 ) { // 仅全屏模式才处理鼠标
                int x = msg.x, y = msg.y;
                x -= ms_x;
                y -= ms_y;
                if ( x * x + y * y > 400 ) exitflag = 1;
            }
        }
        // 显示星星
        double dt = 1.0 / fps; //fclock() - dtime;
        dtime += dt;
        for ( int i = 0; i < g_max; i++ ) {
            MoveStar( i, dt );
        }
        // 显示FPS
        {
            char str[60];
            sprintf( str, "%8.2f FPS", getfps());
            outtextxy( 0, 0, str ); //显示fps
        }
    }
    closegraph(); // 关闭图形窗口
    return 0;
}
Example #17
0
void MainWin::resize(int rows, int cols)
{
    NGroup::resize(rows, cols);
    tablheader->resize(1, getwidth()-2-(INFPANWIDTH)-1);

    int wtaskheight = getheight() * wtaskheightpercent / 10000.0;
    if (wtaskheight < 5)
	wtaskheight = 5;
    if (wtaskheight > getheight() - 10)
	wtaskheight = getheight() - 10;
    wtask->resize(wtaskheight/*getheight()/2*/, getwidth()-2-(INFPANWIDTH)-1); //размер окна задач

    wmsg->resize(getheight()-wtask->getheight()-4, getwidth()-2-(INFPANWIDTH+1));
    wmsg->move(wtask->getheight()+3, 1);
    hline->resize(1, getwidth()-2-(INFPANWIDTH+1)); //горизонтальная линия
    hline->move(wtask->getheight()+2, 1);
//    vline->resize(wtask->getheight()+1/*getheight()-2*/, 1);
//    vline->move(1 , getwidth()-INFPANWIDTH-2);
    msgscrollbar->resize(wmsg->getheight()+2,1);
    msgscrollbar->move(wmsg->getbegrow()-1, getwidth()-INFPANWIDTH-2/*vline->getbegcol()*/);
    taskscrollbar->resize(wtask->getheight()+2,1);
    taskscrollbar->move(wtask->getbegrow()-2, getwidth()-INFPANWIDTH-2);
    panel1->resize(getheight()-2,INFPANWIDTH);
    panel1->move(1,getwidth()-INFPANWIDTH-1);
}
Example #18
0
void MainWin::eventhandle(NEvent* ev) 	//обработчик событий
{
    NGroup::eventhandle(ev); //предок

    if ( ev->done )
	return;
    if (ev->type == NEvent::evKB) //клавиатурные
    {
        switch(ev->keycode)
	{
	    case '-': //меняем размер окна логов
	    case '+': //меняем размер окна логов
	    {
		int wtaskheight = getheight() * wtaskheightpercent / 10000.0; //высота в строках
		//игнорировать событие если дошли до ограничителей
		if ((ev->keycode == '+')&&(wtaskheight < 5))
		    break;
		if ((ev->keycode == '-')&&(wtaskheight > getheight() -10))
		    break;
		//расчитать новый процентный размер окна
		int delta = 10000.0/getheight();
		if (ev->keycode == '+')
		    delta*=-1;
		wtaskheightpercent+=delta;
		if (wtaskheightpercent > 10000)
		    wtaskheightpercent = 10000;
		wtaskheightpercent-=10;
		if (wtaskheightpercent < 0)
		    wtaskheightpercent = 0;
		//сохранить новое значение в конфиге
		saveopttoconfig();
		//ресайз и перерисовка
		resize(getheight(),getwidth());
		refresh();
		break;
	    }
	}
    }
    if (ev->type == NEvent::evPROG) //прграммные
    {
	switch(ev->cmdcode)
	{
	    case evCOLVIEWCH: //изменился набор колонок
	    {
		setcoltitle();
		tablheader->refresh();
		wtask->refresh();
	    }
	} //switch
    }
    //событие таймера
    if (ev->type == NEvent::evTIMER) //таймер
    {
	updatecaption();
    }
}
Example #19
0
NMessageBox::NMessageBox(const char* text) : NGroup(NRect(3, 40, 1, 1))
{
    //расчитать сколько строк нужно для отображения контента
    int contentheight = 0;
    int bsize = strlen(text); //количество байт
    int result = 0; //подсчитанное кол-во символов
    int nbytes = 0; //просмотренное кол-во байтов
    int nlines = 0; //количество экранных строк
    int col = getwidth() - 4;
    const char* p = text;
    do
    {
	col++;
	if ((col >= getwidth() - 4)||(*p == '\n'))
	{
	    if (*p == '\n')
		col = 0;
	    else
		col = 1;
	    contentheight++; //след строка
	}
	int symlen = mblen(p,bsize-nbytes);
	nbytes = nbytes + symlen;
	result++;
	p = p + symlen; //адрес начала след символа
    }
    while ( (*p != 0)&&(nbytes < bsize) ); //дошли до конца
    //заполняем содержимое
    content = new NStaticText(NRect(contentheight, getwidth()-4, 2, 2));
    content->setbgcolor(getcolorpair(COLOR_WHITE, COLOR_BLACK));
    insert(content);
    content->appendstring(getcolorpair(COLOR_WHITE, COLOR_BLACK) | A_BOLD, text);
    modalflag = true;
    resize(contentheight + 6,getwidth());
    wattrset(win,getcolorpair(COLOR_WHITE, COLOR_BLACK) | A_BOLD);
    if(asciilinedraw == 1)
	wborder(win, '|', '|', '-', '-', '+', '+', '+', '+');
    else
	box(win,0,0);
    //content->setalign(1);
    move(getmaxy(stdscr)/2-getheight()/2,getmaxx(stdscr)/2-getwidth()/2); //центрируем

}
Example #20
0
int maxwidth(struct node *root)
{
    if(root)
    {
        int h=hight(root);
        int *con=(int *)calloc(sizeof(int),h);
        int level=0;
        getwidth(root,con,level);
      return ma(con,h);
    }
}
Example #21
0
FloatImage *FloatImage::normalize()
{
  int count = getwidth() * getheight();

  FloatImage *newimage = new FloatImage(getwidth(), getheight());

  /* find minimum and maximum values */

  float min,max;
  get_extrema (min, max);
  if (max == min)
    min = max - 1;

  float scale = 255 * (max - min);
  float trans = -min;

  for (int i = 0; i < count; i++)
    newimage->pixel(i) = (pixel(i) - min) / (max - min);

  return (newimage);
}
Example #22
0
AddProjectForm::AddProjectForm(int rows, int cols,  Srv* srv, const char* projname, bool userexist) : NForm(rows,cols)
{
    this->srv = srv;
    settitle(projname);
    this->projname = projname;
    this->userexist = userexist;
    Item* project = NULL;
    if (srv !=NULL)
	project = srv->findprojectbynamefromall(projname);
    int row = 1;
    //поля
    genfields(row,project);
    //пересчитываем высоту формы, чтобы влезли все поля и центрируем
    resize(row + 2,getwidth());
    move(getmaxy(stdscr)/2-getheight()/2,getmaxx(stdscr)/2-getwidth()/2);

    set_form_fields(frm, fields);
    set_current_field(frm, fields[0]); //фокус на поле

    post_form(frm);
    this->refresh();
}
Example #23
0
void hud::render(void){
  glMatrixMode(GL_PROJECTION);							// Select The Projection Matrix
	glLoadIdentity();										      // Reset The Projection Matrix
	glOrtho(0.0f,(GLfloat)getwidth(),(GLfloat)getheight(),0.0f,-1.0f,1.0f);
	glMatrixMode(GL_MODELVIEW);								// Select The Modelview Matrix
	glLoadIdentity();										      // Reset The Modelview Matrix
  for(uint c=0;c<this->getchildren().size();c++){
    widget* w = this->getchildren()[c];
    w->render();
  }
  printinputline();
  glFlush();
}
QuestionDialog::QuestionDialog(int width, int height, QuestionDialog::IconType type) : Dialog(width, height),
yes_button_listener_(NULL, NULL, response_none), no_button_listener_(NULL, NULL, response_none)
{
	if (!icon_question_)
	{
		icon_question_ = newimage();
		getimage_mem(icon_question_, binary_dialog_icon_question_png, sizeof(binary_dialog_icon_question_png));
	}
	if (!icon_warning_)
	{
		icon_warning_ = newimage();
		getimage_mem(icon_warning_, binary_dialog_icon_warning_png, sizeof(binary_dialog_icon_warning_png));
	}
	switch (type)
	{
		case QuestionDialog::icon_question:
			dialog_icon_ = icon_question_;
			break;
		case QuestionDialog::icon_warning:
			dialog_icon_ = icon_warning_;
			break;
	}

	if (!yes_button_)
	{
		yes_button_ = new Button(button_width_, button_height_);
		yes_button_->set_text("确定");
		static PIMAGE icon_ok = newimage();
		getimage_mem(icon_ok, binary_dialog_button_ok_png, sizeof(binary_dialog_button_ok_png));
		yes_button_->set_icon(icon_ok);
	}
	if (!no_button_)
	{
		no_button_ = new Button(button_width_, button_height_);
		no_button_->set_text("取消");
		static PIMAGE icon_cancel = newimage();
		getimage_mem(icon_cancel, binary_dialog_button_cancel_png, sizeof(binary_dialog_button_cancel_png));
		no_button_->set_icon(icon_cancel);
	}

	no_button_->set_position(width_ - button_margin_ - button_width_, height_ - button_margin_ - button_height_);
	yes_button_->set_position(width_ - button_margin_ * 2 - button_width_ * 2, height_ - button_margin_ - button_height_);

	text_rect_.left = icon_margin_ + getwidth(dialog_icon_) + text_margin_;
	text_rect_.top = text_margin_;
	text_rect_.right = width - text_margin_;
	text_rect_.bottom = height_ - button_area_height_ - text_margin_;
	text_ = "A question message.";
}
Example #25
0
File: mc.c Project: mkhl/plan9port
void
threadmain(int argc, char *argv[])
{
	int i;
	int lineset;
	int ifd;

	lineset = 0;
	Binit(&bout, 1, OWRITE);
	while(argc > 1 && argv[1][0] == '-'){
		--argc; argv++;
		switch(argv[0][1]){
		case '\0':
			colonflag = 1;
			break;
		case 't':
			tabflag = 0;
			break;
		default:
			linewidth = atoi(&argv[0][1]);
			if(linewidth <= 1)
				linewidth = WIDTH;
			lineset = 1;
			break;
		}
	}
	if(lineset == 0)
		getwidth();
	cbuf = cbufp = malloc(ALLOC_QUANTA*(sizeof *cbuf));
	word = malloc(WORD_ALLOC_QUANTA*(sizeof *word));
	if(word == 0 || cbuf == 0)
		error("out of memory");
	if(argc == 1)
		readbuf(0);
	else{
		for(i = 1; i < argc; i++){
			if((ifd = open(*++argv, OREAD)) == -1)
				fprint(2, "mc: can't open %s (%r)\n", *argv);
			else{
				readbuf(ifd);
				Bflush(&bin);
				close(ifd);
			}
		}
	}
	columnate();
	Bflush(&bout);
	threadexitsall(0);
}
Example #26
0
void
_xgetwidth(void)
{
	eucwidth_t	_eucwidth;

	*_cswidth = 1; /* set to 1 when called */
	getwidth(&_eucwidth);

	if (_eucwidth._eucw1 <= 4)
		_cswidth[1] = _eucwidth._eucw1;
	if (_eucwidth._eucw2 <= 4)
		_cswidth[2] = _eucwidth._eucw2;
	if (_eucwidth._eucw3 <= 4)
		_cswidth[3] = _eucwidth._eucw3;
}
Example #27
0
int main(int argc, char *argv[]){

	int xcoord;
	int ycoord; 
	xcoord= atoi(argv[3]);
	ycoord= atoi(argv[4]);
    ip= fopen(argv[1], "rb");
      if(!ip){ goto error;
      }
	op= fopen(argv[2], "wb");
      if(!op){ goto error;
      }
    pinsimp= (simple*) malloc(sizeof(simple));
   	poutsimp= (simple*) malloc(sizeof(simple));

	pinsimp->w=getwidth(ip);
	pinsimp->h=getheight(ip);	
	poutsimp->w = atoi(argv[5]);
	poutsimp->h = atoi(argv[6]);	
	if(xcoord+poutsimp->w>pinsimp->w||ycoord+poutsimp->h>pinsimp->h){
		goto error; }
	pinsimp= (simple*) realloc( pinsimp, sizeof(simple) * sizeof(unsigned char) * pinsimp->w * pinsimp->h);
	poutsimp= (simple*) realloc(poutsimp, sizeof(simple) * sizeof(unsigned char) * poutsimp->w * poutsimp->w);

	pinsimp->matrix= (pixel**) malloc(pinsimp->w*sizeof(pixel*));
		for(i=0; i<pinsimp->w; i++){
			pinsimp->matrix[i]= (pixel*) malloc(pinsimp->h * sizeof(pixel));
			}
	poutsimp->matrix= (pixel**) malloc(poutsimp->w*sizeof(pixel*));
		for(i=0; i<poutsimp->w; i++){
			poutsimp->matrix[i]= (pixel*) malloc(poutsimp->h * sizeof(pixel));
			}	
		
	converttopixels(ip);	
	
		for(j=0;j<poutsimp->h;j++){
			for(i=0;i<poutsimp->w;i++){
				poutsimp->matrix[i][j]=pinsimp->matrix[i+xcoord][j+ycoord];
			}
		}
	convertfromoutsimp(poutsimp);
	free(pinsimp);
	free(poutsimp);
		
		
	return 0; 
		error: printf("there was a problem opening the file or with the dimensions used as arguments, the process was not completed as intended! :(");
}
Example #28
0
File: label.c Project: DaviWei/uGFX
static void gwinLabelDefaultDraw(GWidgetObject *gw, void *param) {
	coord_t				w, h;
	(void)				param;

	w = (gw->g.flags & GLABEL_FLG_WAUTO) ? getwidth(gw->text, gw->g.font, gdispGetWidth() - gw->g.x) : gw->g.width;
	h = (gw->g.flags & GLABEL_FLG_HAUTO) ? getheight(gw->text, gw->g.font, gdispGetWidth() - gw->g.x) : gw->g.height;

	if (gw->g.width != w || gw->g.height != h) {
		gwinResize(&gw->g, w, h);
		return;
	}

	gdispFillStringBox(gw->g.x, gw->g.y, gw->g.width, gw->g.height, gw->text, gw->g.font,
			(gw->g.flags & GWIN_FLG_ENABLED) ? gw->pstyle->enabled.text : gw->pstyle->disabled.text, gw->pstyle->background,
			justifyLeft);
}
Example #29
0
void FloatImage::get_extrema(float& min, float& max)
{
  int count = getwidth() * getheight();

  /* find minimum and maximum values */

  min = pixel(0);
  max = pixel(0);

  for (int i = 0; i < count; i++) {
    if (pixel(i) < min)
      min = pixel(i);
    if (pixel(i) > max)
      max = pixel(i);
  }
}
Example #30
0
static void editorprint(control m)
{
    printer lpr;
    font f;
    textbox t = getdata(m);
    const char *contents = gettext(t);
    char msg[LF_FACESIZE + 128];
    char *linebuf = NULL;
    int cc, rr, fh, page, linep, i, j, istartline;
    int top, left;

    if (!(lpr = newprinter(0.0, 0.0, ""))) return;
    f = gnewfont(lpr, strcmp(fontname, "FixedFont") ? fontname : "Courier New",
		 fontsty, pointsize, 0.0, 1);
    top = devicepixelsy(lpr) / 5;
    left = devicepixelsx(lpr) / 5;
    fh = fontheight(f);
    rr = getheight(lpr) - top;
    cc = getwidth(lpr) - 2*left;

    linep = rr; /* line in printer page */
    page = 1;
    i = 0;
    while (i < strlen(contents)) {
	if ( linep + fh >= rr ) { /* new page */
	    if (page > 1) nextpage(lpr);
	    snprintf(msg, LF_FACESIZE + 128, "Page %d", page++);
	    gdrawstr(lpr, f, Black, pt(cc - gstrwidth(lpr, f, msg) - 1, top),
		     msg);
	    linep = top + 2*fh;
	}
	j = 0;
	istartline = i;
	while (contents[i] != '\n' && contents[i] != '\0') {
	    ++i; ++j;
	}
	linebuf = realloc(linebuf, (j+1)*sizeof(char));
	strncpy(linebuf, &contents[istartline], j);
	linebuf[j] = '\0';
	gdrawstr(lpr, f, Black, pt(left, linep), linebuf);
	linep += fh;
	++i;
    }
    free(linebuf);
    if (f != FixedFont) del(f);
    del(lpr);
}