📄 propertydlg.cpp
字号:
//PropertyDlg.cpp, Copyright (c) 2001, 2002, 2003, 2004, 2005 R.Lackner
//Property dialogs for graphic objects
//
// This file is part of RLPlot.
//
// RLPlot is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// RLPlot is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with RLPlot; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
#include "rlplot.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "TheDialog.h"
extern tag_Units Units[];
extern char TmpTxt[];
extern TextDEF DlgText;
extern Default defs;
extern int dlgtxtheight;
extern Axis **CurrAxes;
extern UndoObj Undo;
extern int AxisTempl3D;
int ODtickstyle;
//prototypes: WinSpec.cpp
void *CreateDlgWnd(char *title, int x, int y, int width, int height, tag_DlgObj *d, DWORD flags);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Symbol properties dialog
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bool
Symbol::PropertyDlg()
{
TabSHEET tab1 = {0, 45, 10, "Size & Color"};
TabSHEET tab2 = {110, 130, 10, "Edit"};
TabSHEET tab3 = {68, 110, 10, "Text Prop."};
TabSHEET tab4 = {45, 68, 10, "Text"};
Symbol *PrevSym = 0L;
char text1[40], text2[100];
int syms[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, SYM_TEXT};
DlgInfo SymDlg[] = {
{1, 2, 0, DEFAULT, PUSHBUTTON, (void*)"Apply to SYMBOL", 145, 10, 60, 12},
{2, 3, 0, 0x0L, PUSHBUTTON, (void*)"Apply to PLOT", 145, 25, 60, 12},
{3, 4, 0, 0x0L, PUSHBUTTON, (void*)"Cancel", 145, 40, 60, 12},
{4, 500, 5, CHECKED | ISPARENT, GROUP, NULL, 138, 40, 55, 12},
{5, 6, 100, ISPARENT | CHECKED, SHEET, &tab1, 5, 10, 130, 70},
{6, 7, 300, ISPARENT, SHEET, &tab2, 5, 10, 130, 70},
{7, 8, 200, TOUCHEXIT | ISPARENT, SHEET, &tab3, 5, 10, 130, 70},
{8, 401, 250, TOUCHEXIT | ISPARENT, SHEET, &tab4, 5, 10, 130, 70},
{100, 101, 0, 0x0L, RTEXT, (void*)"size", 5, 25, 45, 8},
{101, 102, 0, TOUCHEXIT, INCDECVAL1, &size, 55, 25, 32, 10},
{102, 103, 0, 0x0L, LTEXT, (void *) Units[defs.cUnits].display, 89, 25, 20, 8},
{103, 104, 0, 0x0L, RTEXT, (void*)"line width", 5, 37, 45, 8},
{104, 105, 0, TOUCHEXIT, INCDECVAL1, &SymLine.width, 55, 37, 32, 10},
{105, 106, 0, 0x0L, LTEXT, (void *) Units[defs.cUnits].display, 89, 37, 20, 8},
{106, 107, 0, 0x0L, RTEXT, (void*)"line color", 5, 49, 45, 8},
{107, 108, 0, TOUCHEXIT | OWNDIALOG, COLBUTTON, (void *)SymLine.color, 55, 49, 25, 10},
{108, 109, 0, 0x0L, RTEXT, (void*)"fill color" , 5, 61, 45, 8},
{109, 0, 0, TOUCHEXIT | OWNDIALOG, COLBUTTON, (void *)SymFill.color, 55, 61, 25, 10},
{200, 204, 201, CHECKED | ISPARENT, GROUPBOX, (void*)" font ", 12, 28, 50, 45},
{201, 202, 0, TOUCHEXIT, RADIO1, (void*)"Helvetica", 15, 35, 45, 8},
{202, 203, 0, TOUCHEXIT, RADIO1, (void*)"Times", 15, 45, 45, 8},
{203, 0, 0, TOUCHEXIT, RADIO1, (void*)"Courier", 15, 55, 45, 8},
{204, 0, 205, CHECKED | ISPARENT, GROUPBOX, (void*)" style ", 72, 28, 57, 45},
{205, 206, 0, TOUCHEXIT, CHECKBOX, (void*)"bold", 75, 35, 25, 8},
{206, 207, 0, TOUCHEXIT, CHECKBOX, (void*)"italic", 75, 45, 25, 8},
{207, 0, 0, TOUCHEXIT, CHECKBOX, (void*)"underlined", 75, 55, 25, 8},
{250, 251, 0, TOUCHEXIT | CHECKED, RADIO1, (void*)"fixed text:", 10, 30, 45, 8},
{251, 252, 0, 0x0L, EDTEXT, text1, 60, 30, 45, 10},
{252, 253, 0, TOUCHEXIT, RADIO1, (void*)"from spreadsheet range:", 10, 45, 60, 8},
{253, 0, 0, 0x0L, EDTEXT, text2, 20, 55, 100, 10},
{300, 301, 0, 0x0L, RTEXT, (void*)"x-value", 5, 30, 45, 8},
{301, 302, 0, 0x0L, EDVAL1, &fPos.fx, 55, 30, 45, 10},
{302, 303, 0, 0x0L, RTEXT, (void*)"y-value", 5, 50, 45, 8},
{303, 0, 0, 0x0L, EDVAL1, &fPos.fy, 55, 50, 45, 10},
{401, 402, 0, TOUCHEXIT, SYMRADIO, (void*)&syms[0], 15, 85, 10, 10},
{402, 403, 0, TOUCHEXIT, SYMRADIO, (void*)&syms[1], 25, 85, 10, 10},
{403, 404, 0, TOUCHEXIT, SYMRADIO, (void*)&syms[2], 35, 85, 10, 10},
{404, 405, 0, TOUCHEXIT, SYMRADIO, (void*)&syms[3], 45, 85, 10, 10},
{405, 406, 0, TOUCHEXIT, SYMRADIO, (void*)&syms[4], 55, 85, 10, 10},
{406, 407, 0, TOUCHEXIT, SYMRADIO, (void*)&syms[5], 65, 85, 10, 10},
{407, 408, 0, TOUCHEXIT, SYMRADIO, (void*)&syms[6], 75, 85, 10, 10},
{408, 409, 0, TOUCHEXIT, SYMRADIO, (void*)&syms[7], 85, 85, 10, 10},
{409, 410, 0, TOUCHEXIT, SYMRADIO, (void*)&syms[8], 95, 85, 10, 10},
{410, 411, 0, TOUCHEXIT, SYMRADIO, (void*)&syms[9], 105, 85, 10, 10},
{411, 412, 0, TOUCHEXIT, SYMRADIO, (void*)&syms[10], 115, 85, 10, 10},
{412, 413, 0, TOUCHEXIT, SYMRADIO, (void*)&syms[11], 15, 95, 10, 10},
{413, 414, 0, TOUCHEXIT, SYMRADIO, (void*)&syms[12], 25, 95, 10, 10},
{414, 415, 0, TOUCHEXIT, SYMRADIO, (void*)&syms[13], 35, 95, 10, 10},
{415, 416, 0, TOUCHEXIT, SYMRADIO, (void*)&syms[14], 45, 95, 10, 10},
{416, 0, 0, TOUCHEXIT, SYMRADIO, (void*)&syms[15], 55, 95, 40, 10},
{500, 0, 0, LASTOBJ | TOUCHEXIT, SYMBUTT, (void*)&PrevSym, 155, 65, 40, 40}};
DlgRoot *Dlg;
void *hDlg;
int res, tmpType, width, height;
DWORD tmpCol, undo_flags = 0L;
double tmpVal, o_size, n_size, o_lwidth, n_lwidth;
TextDEF textdef;
anyOutput *cdisp = Undo.cdisp;
lfPOINT o_pos, n_pos;
if(!parent) return false;
if(!Command(CMD_GETTEXT, (void*)text1, 0L)) sprintf(text1, "text");
if(data && data->GetSize(&width, &height)) sprintf(text2, "b1:b%d", height);
else sprintf(text2, "(not available)");
if((PrevSym = new Symbol(0L, data, 0.0f, 0.0f, type))){
PrevSym->SetColor(COL_SYM_LINE, SymLine.color);
PrevSym->SetColor(COL_SYM_FILL, SymFill.color);
PrevSym->SetSize(SIZE_SYMBOL, size);
PrevSym->SetSize(SIZE_SYM_LINE, SymLine.width);
PrevSym->Command(CMD_SETTEXT, (void*)text1, 0L);
PrevSym->Command(CMD_GETTEXTDEF, &textdef, 0L);
PrevSym->Command(CMD_SET_DATAOBJ, (void*)data, 0L);
if(Command(CMD_GETTEXTDEF, &textdef, 0L))
PrevSym->Command(CMD_SETTEXTDEF, &textdef, 0L);
PrevSym->idx = idx;
}
if(PrevSym && (Dlg = new DlgRoot(SymDlg))) {
Dlg->TextFont(201, FONT_HELVETICA);
Dlg->TextFont(202, FONT_TIMES);
Dlg->TextFont(203, FONT_COURIER);
Dlg->TextStyle(205, TXS_BOLD);
Dlg->TextStyle(206, TXS_ITALIC);
Dlg->TextStyle(207, TXS_UNDERLINE);
if(type == SYM_TEXT) Dlg->SetCheck(416, 0L, true);
else Dlg->SetCheck(401+type, 0L, true);
switch(textdef.Font) {
case FONT_TIMES: Dlg->SetCheck(202, 0L, true); break;
case FONT_COURIER: Dlg->SetCheck(203, 0L, true); break;
default: Dlg->SetCheck(201, 0L, true); break;
}
if(textdef.Style & TXS_BOLD) Dlg->SetCheck(205, 0L, true);
if(textdef.Style & TXS_ITALIC) Dlg->SetCheck(206, 0L, true);
if(textdef.Style & TXS_UNDERLINE) Dlg->SetCheck(207, 0L, true);
}
else return false;
if(parent->name) sprintf(TmpTxt, "Symbol of %s", parent->name);
else strcpy(TmpTxt, "Symbol properties");
if(!(hDlg = CreateDlgWnd(TmpTxt, 50, 50, 430, 260, Dlg, 0x0L)))return false;
tmpCol = 0x00c0c0c0L; o_size = size; o_lwidth = SymLine.width;
Dlg->GetValue(101, &o_size); Dlg->GetValue(104, &o_lwidth);
n_size = o_size; n_lwidth = o_lwidth;
o_pos.fx = fPos.fx; o_pos.fy = fPos.fy;
if(Dlg->GetValue(301, &tmpVal)) o_pos.fx = tmpVal; n_pos.fx = o_pos.fx;
if(Dlg->GetValue(303, &tmpVal)) o_pos.fy = tmpVal; n_pos.fy = o_pos.fy;
do {
LoopDlgWnd();
res = Dlg->GetResult();
switch(res) {
case 2:
case 1:
Undo.SetDisp(cdisp);
if(PrevSym->type == SYM_TEXT && Dlg->GetCheck(250)){
Dlg->GetText(251, text1);
if(PrevSym->Command(CMD_GETTEXT, (void *)text2, 0L) && strcmp(text1, text2)) {
PrevSym->Command(CMD_SETTEXT, (void *)text1, 0L);
Dlg->DoPlot(NULL);
res = -1;
}
}
else if(PrevSym->type == SYM_TEXT && Dlg->GetCheck(252)) {
if(Dlg->GetCheck(252) && Dlg->GetText(253, text2))
PrevSym->Command(CMD_RANGETEXT, &text2, 0L);
}
Dlg->GetValue(101, &n_size); Dlg->GetValue(104, &n_lwidth);
break;
case 7: //the text sheets
case 8:
Dlg->SetCheck(416, 0L, true);
if(PrevSym->type != SYM_TEXT) {
PrevSym->type = SYM_TEXT;
Dlg->DoPlot(NULL);
}
res = -1;
break;
case 201: case 202: case 203: //fonts and styles
case 205: case 206: case 207:
if(PrevSym->Command(CMD_GETTEXTDEF, &textdef, 0L)) {
if(Dlg->GetCheck(202)) textdef.Font = FONT_TIMES;
else if(Dlg->GetCheck(203)) textdef.Font = FONT_COURIER;
else textdef.Font = FONT_HELVETICA;
textdef.Style = TXS_NORMAL;
if(Dlg->GetCheck(205)) textdef.Style |= TXS_BOLD;
if(Dlg->GetCheck(206)) textdef.Style |= TXS_ITALIC;
if(Dlg->GetCheck(207)) textdef.Style |= TXS_UNDERLINE;
PrevSym->Command(CMD_SETTEXTDEF, &textdef, 0L);
Dlg->DoPlot(NULL);
}
res = -1;
break;
case 252: //use spreadsheet text
if(!data) Dlg->SetCheck(250, 0L, true);
case 250: //use fixed text
if(Dlg->GetCheck(250) && Dlg->GetText(251,text1))PrevSym->Command(CMD_SETTEXT, text1, 0L);
else if(Dlg->GetCheck(252) && Dlg->GetText(253, text2))
PrevSym->Command(CMD_RANGETEXT, text2, 0L);
Dlg->DoPlot(NULL);
res = -1;
break;
case 401: case 402: case 403: case 404: //symbol selection
case 405: case 406: case 407: case 408:
case 409: case 410: case 411: case 412:
case 413: case 414: case 415:
tmpType = res - 401;
case 416: //text symbol
if(res == 416) tmpType = SYM_TEXT;
PrevSym->type = tmpType;
case 107: //line color button
if(res == 107 && Dlg->GetColor(107, &tmpCol))
PrevSym->SetColor(COL_SYM_LINE, tmpCol);
case 109: //fill color button
if(res == 109 && Dlg->GetColor(109, &tmpCol))
PrevSym->SetColor(COL_SYM_FILL, tmpCol);
case 101: //symbol size changed
case 104: //line width changed
case 500: //preview button
if(Dlg->GetValue(101, &tmpVal)) PrevSym->SetSize(SIZE_SYMBOL, tmpVal);
if(Dlg->GetValue(104, &tmpVal)) PrevSym->SetSize(SIZE_SYM_LINE, tmpVal);
if(PrevSym->type == SYM_TEXT) {
if(Dlg->GetCheck(250) && Dlg->GetText(251,text1))PrevSym->Command(CMD_SETTEXT, text1, 0L);
else if(Dlg->GetCheck(252) && Dlg->GetText(253, text2))
PrevSym->Command(CMD_RANGETEXT, text2, 0L);
}
Dlg->DoPlot(NULL);
res = -1;
break;
}
}while (res < 0);
switch (res) {
case 1: //accept values for symbol
undo_flags = CheckNewFloat(&size, o_size, n_size, parent, undo_flags);
undo_flags = CheckNewFloat(&SymLine.width, o_lwidth, n_lwidth, parent, undo_flags);
if(Dlg->GetValue(301, &tmpVal)) n_pos.fx = tmpVal;
if(Dlg->GetValue(303, &tmpVal)) n_pos.fy = tmpVal;
undo_flags = CheckNewLFPoint(&fPos, &o_pos, &n_pos, parent, undo_flags);
if(Dlg->GetColor(107, &tmpCol)) undo_flags =
CheckNewDword(&SymLine.color, SymLine.color, tmpCol, parent, undo_flags);
if(Dlg->GetColor(109, &tmpCol)) undo_flags =
CheckNewDword(&SymFill.color, SymFill.color, tmpCol, parent, undo_flags);
undo_flags = CheckNewInt(&type, type, PrevSym->type, parent, undo_flags);
if(type == SYM_TEXT && PrevSym->Command(CMD_GETTEXTDEF, &textdef, 0L)){
if(SymTxt && cmpTextDEF(SymTxt, &textdef)){
Undo.TextDef(parent, SymTxt, undo_flags); undo_flags |= UNDO_CONTINUE;
}
if(PrevSym->Command(CMD_GETTEXT, text1, 0L)) Command(CMD_SETTEXT, text1, 0L);
Command(CMD_SETTEXTDEF, &textdef, 0L);
}
break;
case 2: //accept values for all symbols of plot
parent->Command(CMD_SAVE_SYMBOLS, 0L, 0L);
parent->SetSize(SIZE_SYMBOL, n_size);
parent->SetSize(SIZE_SYM_LINE, n_lwidth);
if(Dlg->GetColor(107, &tmpCol)) parent->SetColor(COL_SYM_LINE, tmpCol);
if(Dlg->GetColor(109, &tmpCol)) parent->SetColor(COL_SYM_FILL, tmpCol);
parent->Command(CMD_SYM_TYPE, (void*)(& PrevSym->type), 0L);
if(PrevSym->type == SYM_TEXT) {
if(Dlg->GetCheck(250) && PrevSym->Command(CMD_GETTEXT, text1, 0L))
parent->Command(CMD_SYMTEXT_UNDO, text1, 0L);
else if(Dlg->GetCheck(252) && Dlg->GetText(253, text2))
parent->Command(CMD_SYM_RANGETEXT, text2, 0L);
if(PrevSym->Command(CMD_GETTEXTDEF, &textdef, 0L))
parent->Command(CMD_SYMTEXTDEF, &textdef, 0L);
}
break;
}
CloseDlgWnd(hDlg);
delete Dlg;
delete PrevSym;
return true;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Bubble properties dialog
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bool
Bubble::PropertyDlg()
{
TabSHEET tab1 = {0, 50, 10, "Shape & Color"};
TabSHEET tab2 = {50, 90, 10, "Scaling"};
TabSHEET tab3 = {90, 120, 10, "Edit"};
int syms[] = {SYM_CIRCLE, SYM_RECT, SYM_TRIAU, SYM_TRIAD};
DlgInfo BubDlg[] = {
{1, 2, 0, DEFAULT, PUSHBUTTON, (void*)"Apply to BUBBLE", 130, 10, 60, 12},
{2, 3, 0, 0x0L, PUSHBUTTON, (void*)"Apply to PLOT", 130, 25, 60, 12},
{3, 4, 0, 0x0L, PUSHBUTTON, (void*)"Cancel", 130, 40, 60, 12},
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -