⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 thedialog.cpp

📁 Linux/windows 环境下跨平台开发程序
💻 CPP
📖 第 1 页 / 共 5 页
字号:

void
ColorButton::DoPlot(anyOutput *o)
{
	POINT pts[5];

	Fill.color = col;
	o->SetFill(&Fill);
	if(flags & ISRADIO) {
		Line.color = bChecked ? 0x00000000L : DlgBGcolor;
		o->SetLine(&Line);
		pts[0].x = pts[3].x = pts[4].x = cr.left;
		pts[0].y = pts[1].y = pts[4].y = cr.top;
		pts[1].x = pts[2].x = cr.right-1;
		pts[2].y = pts[3].y = cr.bottom-1;
		o->oPolyline(pts, 5);
		Line.color = 0x00000000L;
		o->SetLine(&Line);
		o->oRectangle(cr.left+3, cr.top+3, cr.right-3, cr.bottom-3);
		}
	else {
		Line.color = 0x00000000L;
		o->SetLine(&Line);
		o->oRectangle(cr.left, cr.top, cr.right, cr.bottom);
		}
	o->UpdateRect(&cr, false);
}

bool
ColorButton::Select(int x, int y, anyOutput *o)
{
	if(!parent) return false;
	if(IsInRect(&cr, x, y)) {
		bChecked = true;
		if((flags & OWNDIALOG)) {
			parent->Command(CMD_CONTINUE, 0L, o);
			col = GetNewColor(col);
			}
		if(flags & ISRADIO) parent->Command(CMD_RADIOBUTT, (void *)this, o);
		if(flags & TOUCHEXIT) parent->Command(CMD_ENDDIALOG, (void *)this, o);
		DoPlot(o);
		return true;
		}
	return false;
}

FillButton::FillButton(tag_DlgObj *par, DlgInfo * desc, RECT rec, FillDEF *fill)
	:Dialog(par, desc, rec)
{
	CurrFill = fill;
}

void
FillButton::DoPlot(anyOutput *o)
{
	Line.color = 0x00000000L;
	o->SetLine(&Line);
	o->SetFill(CurrFill);
	o->oRectangle(cr.left, cr.top, cr.right, cr.bottom);
	o->UpdateRect(&cr, false);
}

bool
FillButton::Select(int x, int y, anyOutput *o)
{
	if(IsInRect(&cr, x, y)) {
		if((flags & OWNDIALOG)) {
			if(parent)parent->Command(CMD_CONTINUE, 0L, o);
			GetNewFill(CurrFill);
			}
		if((flags & TOUCHEXIT) && parent) 
			parent->Command(CMD_ENDDIALOG, (void *)this, o);
		DoPlot(o);
		return true;
		}
	return false;
}

Shade3D::Shade3D(tag_DlgObj *par, DlgInfo * desc, RECT rec, FillDEF *fill)
	:Dialog(par, desc, rec)
{
	CurrFill = fill;
}

void
Shade3D::DoPlot(anyOutput *o)
{
	POINT pts[5];
	FillDEF fd;
	int dx;

	Line.color = 0x00000000L;
	o->SetLine(&Line);
	if(CurrFill->type & FILL_LIGHT3D) {
		fd.color = fd.color2 = CurrFill->color;
		fd.hatch = 0L;		fd.scale = 1.0;
		fd.type = 0L;
		dx = iround(((double)(cr.bottom - cr.top))*.26);
		pts[0].x = pts[1].x = pts[4].x = ((cr.left + cr.right)>>1);
		pts[0].y = pts[4].y = cr.bottom;
		pts[1].y = ((cr.top + cr.bottom)>>1);
		pts[2].x = pts[3].x = pts[0].x + (dx<<1);
		pts[2].y = pts[1].y - dx;		pts[3].y = pts[0].y - dx;
		o->SetFill(&fd);
		o->oPolygon(pts, 5, 0L);
		fd.color = fd.color2 = IpolCol(CurrFill->color, CurrFill->color2, 0.4);
		pts[2].x = pts[3].x = pts[0].x - (dx<<1);
		o->SetFill(&fd);
		o->oPolygon(pts, 5, 0L);
		fd.color = fd.color2 = CurrFill->color2;
		pts[0].y = pts[4].y = pts[1].y;
		pts[1].x = pts[2].x;			pts[1].y = pts[3].y = pts[2].y;
		pts[2].x = pts[0].x;			pts[2].y -= dx;
		pts[3].x = pts[0].x + (dx<<1);
		o->SetFill(&fd);
		o->oPolygon(pts, 5, 0L);
		}
	else {
		o->SetFill(CurrFill);
		o->oRectangle(cr.left, cr.top, cr.right, cr.bottom);
		}
	o->UpdateRect(&cr, false);
}

void ConfShade(FillDEF *oldfill);
bool
Shade3D::Select(int x, int y, anyOutput *o)
{
	if(IsInRect(&cr, x, y)) {
		if((flags & OWNDIALOG)) {
			if(parent)parent->Command(CMD_CONTINUE, 0L, o);
			ConfShade(CurrFill);
			}
		if((flags & TOUCHEXIT) && parent) 
			parent->Command(CMD_ENDDIALOG, (void *)this, o);
		DoPlot(o);
		return true;
		}
	return false;
}

LineButton::LineButton(tag_DlgObj *par, DlgInfo * desc, RECT rec, LineDEF *line)
	:Dialog(par, desc, rec)
{
	Line.color = 0x00000000L;
	CurrLine = line;
	Fill.color = defs.Color(COL_BG);
	pts[0].x = cr.left+4;
	pts[1].x = cr.right-5;
	pts[0].y = pts[1].y = (cr.top + cr.bottom)/2;
}

void
LineButton::DoPlot(anyOutput *o)
{
	o->SetLine(&Line);
	o->SetFill(&Fill);
	o->oRectangle(cr.left, cr.top, cr.right, cr.bottom);
	o->SetLine(CurrLine);
	o->oPolyline(pts, 2);
	o->UpdateRect(&cr, false);
}

bool
LineButton::Select(int x, int y, anyOutput *o)
{
	if(IsInRect(&cr, x, y)) {
		if((flags & TOUCHEXIT) && parent) 
			parent->Command(CMD_ENDDIALOG, (void *)this, o);
		DoPlot(o);
		return true;
		}
	return false;
}

SymButton::SymButton(tag_DlgObj *par, DlgInfo * desc, RECT rec, Symbol **sym)
	:Dialog(par, desc, rec)
{
	symbol = sym;
	Line.color = 0x00000000L;
	Fill.color = 0x00ffffffL;
}

void
SymButton::DoPlot(anyOutput *o)
{
	Line.color = 0x00000000L;
	o->SetLine(&Line);
	o->SetFill(&Fill);
	o->oRectangle(cr.left, cr.top, cr.right, cr.bottom);
	if(*(symbol)) {		//center symbol in the rectangle
		(*symbol)->SetSize(SIZE_XPOS, (cr.right+cr.left)/2.0);
		(*symbol)->SetSize(SIZE_YPOS, (cr.bottom+cr.top)/2.0);
		(*symbol)->DoPlot(o);
		}
	o->UpdateRect(&cr, false);
}

bool
SymButton::Select(int x, int y, anyOutput *o)
{
	if(IsInRect(&cr, x, y)) {
		if((flags & TOUCHEXIT) && parent) 
			parent->Command(CMD_ENDDIALOG, (void *)this, o);
		DoPlot(o);
		return true;
		}
	return false;
}

FillRadioButt::FillRadioButt(tag_DlgObj *par, DlgInfo * desc, RECT rec, unsigned int pattern)
	:Dialog(par, desc, rec)
{
	Line.pattern = 0x00000000L;			Fill.type = pattern;
	Fill.color = 0x00ffffffL;			Fill.hatch = &Line;
	flags |= ISRADIO;
}

void
FillRadioButt::DoPlot(anyOutput *o)
{
	POINT pts[5];

	Line.color = bChecked ? 0x00000000L : DlgBGcolor;
	o->SetLine(&Line);
	pts[0].x = pts[3].x = pts[4].x = cr.left;
	pts[0].y = pts[1].y = pts[4].y = cr.top;
	pts[1].x = pts[2].x = cr.right-1;
	pts[2].y = pts[3].y = cr.bottom-1;
	o->oPolyline(pts, 5);
	Line.color = 0x00000000L;
	o->SetLine(&Line);
	o->SetFill(&Fill);
	o->oRectangle(cr.left+3, cr.top+3, cr.right-3, cr.bottom-3);
	o->UpdateRect(&cr, false);
}

bool
FillRadioButt::Select(int x, int y, anyOutput *o)
{
	if(IsInRect(&cr, x, y)) {
		bChecked = true;
		DoPlot(o);
		if(parent) parent->Command(CMD_RADIOBUTT, (void *)this, o);
		if((flags & TOUCHEXIT) && parent) 
			parent->Command(CMD_ENDDIALOG, (void *)this, o);
		return true;
		}
	return false;
}

SymRadioButt::SymRadioButt(tag_DlgObj *par, DlgInfo * desc, RECT rec, int* type)
	:Dialog(par, desc, rec)
{
	double size;

	if(type && (Sym = new Symbol(0L, 0L, ((double)(cr.right+cr.left))/2.0, 
		((double)(cr.bottom+cr.top))/2.0, *type))){
		size = (0.14*(double)(cr.bottom-cr.top))/Units[defs.cUnits].convert;
		Sym->SetSize(SIZE_SYMBOL, size);			Sym->SetSize(SIZE_SYM_LINE, size/10.0);
		Sym->SetColor(COL_SYM_LINE, 0x00000000L);	Sym->SetColor(COL_SYM_FILL, 0x00ffffffL);
		}
	Fill.color = DlgBGhigh;		flags |= ISRADIO;
}

SymRadioButt::~SymRadioButt()
{
	if (Sym) delete Sym;
}

void
SymRadioButt::DoPlot(anyOutput *o)
{
	if(!Sym) return;
	Line.color = bChecked ? 0x00000000L : Fill.color;
	o->SetFill(&Fill);
	o->SetLine(&Line);
	o->oRectangle(cr.left, cr.top, cr.right, cr.bottom);
	Sym->DoPlot(o);
	o->UpdateRect(&cr, false);
}

bool
SymRadioButt::Select(int x, int y, anyOutput *o)
{
	if(IsInRect(&cr, x, y)) {
		bChecked = true;
		DoPlot(o);
		if(parent) parent->Command(CMD_RADIOBUTT, (void *)this, o);
		if((flags & TOUCHEXIT) && parent) 
			parent->Command(CMD_ENDDIALOG, (void *)this, o);
		return true;
		}
	return false;
}

CheckBox::CheckBox(tag_DlgObj *par, DlgInfo * desc, RECT rec, char *text)
	:Dialog(par, desc, rec)
{
	if(text)Text = strdup(text);
	else Text = 0L;
	hcr.left = cr.left+2;		hcr.right = cr.left+14;
	hcr.top = cr.top+3;			hcr.bottom = cr.top+15;
}

CheckBox::~CheckBox()
{
	if(Text) free (Text);
}

bool
CheckBox::Command(int cmd, void *tmpl, anyOutput *o)
{
	switch(cmd) {
	case CMD_SETTEXT:
		if(Text) free(Text);
		if(tmpl) Text = strdup((char *)tmpl);
		else Text = 0L;
		return true;
		}
	return false;
}

void
CheckBox::DoPlot(anyOutput *o)
{
	POINT pts[3];

	if(flags & HIDDEN) return;
	Line.color = 0x00000000L;
	Line.width = 0.0;
	Fill.color = bLBdown ? DlgBGcolor : 0x00ffffffL;
	o->SetLine(&Line);
	o->SetFill(&Fill);
	o->oRectangle(cr.left+2, cr.top+3, cr.left+14, cr.top+15);
	if(bChecked) {
		Line.width = defs.GetSize(SIZE_SYM_LINE)*2.0;
		o->SetLine(&Line);
		pts[0].x = cr.left+4;			pts[0].y = cr.top+5;
		pts[1].x = cr.left+11;			pts[1].y = cr.top+12;
		o->oSolidLine(pts);
		pts[0].x = cr.left+11;			pts[1].x = cr.left+4;
		o->oSolidLine(pts);
		}
	if(Text) {
		o->SetTextSpec(&TextDef);
		o->oTextOut(cr.left + 20, cr.top + 1, Text, strlen(Text));
		}
	o->UpdateRect(&cr, false);
}

bool
CheckBox::Select(int x, int y, anyOutput *o)
{
	if(!(flags & HIDDEN) && IsInRect(&hcr, x, y)) {
		bChecked ^= 0x01;	//toggle selection
		bLBdown = false;
		DoPlot(o);
		if((flags & ISRADIO) && parent)
			parent->Command(CMD_RADIOBUTT, (void *)this, o);
		if((flags & TOUCHEXIT) && parent) 
			parent->Command(CMD_ENDDIALOG, (void *)this, o);
		return true;
		}
	return false;
}

CheckPin::CheckPin(tag_DlgObj *par, DlgInfo * desc, RECT rec)
	:Dialog(par, desc, rec)
{
	hcr.left = cr.left+2;		hcr.right = cr.right-2;
	hcr.top = cr.top+2;			hcr.bottom = cr.bottom-2;
}

CheckPin::~CheckPin()
{
}

bool
CheckPin::Command(int cmd, void *tmpl, anyOutput *o)
{
	switch(cmd) {
	case CMD_UNLOCK:
		bChecked = false;
		return true;
		}
	return false;
}

void
CheckPin::DoPlot(anyOutput *o)
{
	POINT pts[20];

	if(!o || flags & HIDDEN) return;
	Line.width = 0.0;
	Line.color = DlgBGcolor;		Fill.color = DlgBGcolor;
	o->SetLine(&Line);		o->SetFill(&Fill);
	o->oRectangle(hcr.left+2, hcr.top, hcr.right, hcr.bottom);
	Line.color = 0x00000000L;		Fill.color = bLBdown ? 0x00ffffff : 0x00e8e8e8L;
	o->SetLine(&Line);		o->SetFill(&Fill);
	if(bChecked) {
		o->oCircle(hcr.left + 5, hcr.top + 1, hcr.left + 15, hcr.top + 12);
		o->oCircle(hcr.left + 8, hcr.top + 3, hcr.left + 15, hcr.top + 10);
		}
	else {
		pts[0].x = hcr.left + 8;	pts[0].y = hcr.top + 4;
		pts[1].x = pts[0].x - 5;	pts[1].y = pts[0].y + 1;
		pts[2].x = pts[0].x;		pts[2].y = pts[1].y + 1;
		pts[3].x = pts[0].x;		pts[3].y = pts[0].y;
		o->oPolygon(pts, 4);
		pts[0].x = hcr.left + 8;	pts[0].y = hcr.top + 1;
		pts[1].x = pts[0].x;		pts[1].y = pts[0].y + 9;
		pts[2].x = pts[1].x + 3;	pts[2].y = pts[1].y - 3;
		pts[3].x = pts[2].x + 4;	pts[3].y = pts[2].y;
		pts[4].x = pts[3].x;		pts[4].y = pts[3].y - 3;
		pts[5].x = pts[4].x - 4;	pts[5].y = pts[4].y;
		pts[6].x = pts[0].x;		pts[6].y = pts[0].y;
		o->oPolygon(pts, 7);
		o->oCircle(pts[4].x-2, pts[0].y, pts[4].x+3, pts[1].y+1);
		}
	o->UpdateRect(&cr, false);
}

bool
CheckPin::Select(int x, int y, anyOutput *o)
{
	if(!(flags & HIDDEN) && IsInRect(&hcr, x, y)) {
		bChecked ^= 0x01;	//toggle selection
		bLBdown = false;	DoPlot(o);
		if((flags & TOUCHEXIT) && parent) 
			parent->Command(CMD_ENDDIALOG, (void *)this, o);
		bLBdown=false;				DoPlot(o);
		return true;
		}
	return false;
}

Trash::Trash(tag_DlgObj *par, DlgInfo * desc, RECT rec)
	:Dialog(par, desc, rec)
{
	hcr.left = cr.left+2;		hcr.right = cr.right-2;
	hcr.top = cr.top+2;			hcr.bottom = cr.bottom-2;
}

Trash::~Trash()
{
}

bool
Trash::Command(int cmd, void *tmpl, anyOutput *o)
{
	return false;
}

void
Trash::DoPlot(anyOutput *o)
{
	POINT pts[2];

	if(!o || flags & HIDDEN) return;
	Line.width = 0.0;
	Line.color = DlgBGcolor;		Fill.color = DlgBGcolor;
	o->SetLine(&Line);		o->SetFill(&Fill);
	o->oRectangle(hcr.left+2, hcr.top, hcr.right, hcr.bottom);
	Line.color = 0x00000000L;		Fill.color = bLBdown ? 0x00ffffff : 0x00e8e8e8L;
	o->SetLine(&Line);		o->SetFill(&Fill);
	o->oRectangle(cr.left+8, cr.top+10, cr.right-8, cr.bottom-3);
	o->oRectangle(cr.left+6, cr.top+5, cr.right-6, cr.top+10);
	o->oRectangle(cr.left+11, cr.top+2, cr.right-11, cr.top+5);
	pts[0].y = cr.top + 12;						pts[1].y = cr.bottom - 5;
	pts[0].x = pts[1].x = cr.left + 12;			o->oSolidLine(pts);
	pts[0].x = pts[1].x = cr.right - 13;		o->oSolidLine(pts);
	o->UpdateRect(&cr, false);
}

bool
Trash::Select(int x, int y, anyOutput *o)
{
	if(!(flags & HIDDEN) && IsInRect(&hcr, x, y)) {
		if((flags & TOUCHEXIT) && parent) 
			parent->Command(CMD_ENDDIALOG, (void *)this, o);
		bLBdown=false;				DoPlot(o);
		return true;
		}
	return false;
}

Config::Config(tag_DlgObj *par, DlgInfo * desc, RECT rec)
	:Dialog(par, desc, rec)
{
	hcr.left = cr.left+2;		hcr.right = cr.right-2;
	hcr.top = cr.top+2;			hcr.bottom = cr.bottom-2;
}

Config::~Config()
{
}

bool
Config::Command(int cmd, void *tmpl, anyOutput *o)
{
	return false;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -