📄 odbuttons.cpp
字号:
//ODbuttons.cpp, Copyright (c) 2001, 2002, 2003, 2004 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
//
// Tis module contains the different graphic buttons for dialogs
#include "rlplot.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include "TheDialog.h"
extern int ODtickstyle;
extern int AxisTempl3D;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Common code to modify drawing order in any dialog
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Exceute drawing order buttons as owner drwn buttons
void OD_DrawOrder(int cmd, void *par, RECT *rec, anyOutput *o,
void *data, int id)
{
LineDEF Line = {.0f, 1.0f, 0x0L, 0x0L};
FillDEF Fill = {FILL_NONE, 0x0080ffffL, 1.0, 0L};
POINT pts[5];
RECT hrc;
int i, j, x, y;
Fill.color = 0x0080ffffL;
switch(cmd) {
case OD_MBTRACK:
if(!data) return;
x = ((MouseEvent*)data)->x; y = ((MouseEvent*)data)->y;
memcpy(&hrc, rec, sizeof(RECT));
IncrementMinMaxRect(&hrc, -6);
if(IsInRect(&hrc, x, y)) Fill.color = 0x00e0ffffL;
case OD_DRAWNORMAL:
case OD_DRAWSELECTED:
pts[0].x = rec->left+10; pts[0].y = rec->bottom-3;
pts[1].x = rec->right-9; pts[1].y = rec->bottom-3;
pts[2].x = rec->right-3; pts[2].y = rec->bottom-9;
pts[3].x = rec->left+16; pts[3].y = rec->bottom-9;
pts[4].x = pts[0].x; pts[4].y = pts[0].y;
o->SetLine(&Line); o->SetFill(&Fill);
for(i = 0; i < 5; i++){
o->oPolygon(pts, 5);
for(j = 0; j < 5; j++) {
pts[j].y -=4;
}
}
pts[0].x = pts[1].x = pts[3].x = rec->left+4;
pts[2].x = rec->left+1; pts[4].x = rec->left+7;
switch (id) {
case 600:
pts[0].y = pts[3].y = rec->top+6; pts[1].y = rec->bottom-3;
pts[2].y = pts[4].y = rec->top+9;
break;
case 601:
pts[0].y = pts[3].y = rec->top+12; pts[1].y = rec->bottom-9;
pts[2].y = pts[4].y = rec->top+15;
break;
case 602:
pts[0].y = pts[3].y = rec->bottom-9; pts[1].y = rec->top+12;
pts[2].y = pts[4].y = rec->bottom-12;
break;
case 603:
pts[0].y = pts[3].y = rec->bottom-3; pts[1].y = rec->top+6;
pts[2].y = pts[4].y = rec->bottom-6;
break;
}
Fill.color = 0x0fL; o->SetFill(&Fill);
o->oPolyline(pts, 2); o->oPolygon(pts+2, 3);
o->UpdateRect(rec, false);
break;
}
}
int ExecDrawOrderButt(GraphObj *parent, GraphObj *obj, int id)
{
switch(id){
case 600:
parent->Command(CMD_MOVE_TOP, obj, 0L);
return -1;
case 601:
parent->Command(CMD_MOVE_UP, obj, 0L);
return -1;
case 602:
parent->Command(CMD_MOVE_DOWN, obj, 0L);
return -1;
case 603:
parent->Command(CMD_MOVE_BOTTOM, obj, 0L);
return -1;
}
return id;
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Execute line style as owner drawn buttons
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void OD_LineStyleTempl(int cmd, void *par, RECT *rec, anyOutput *o,
void *data, int id)
{
LineDEF Line = {.1f, 1.0f, 0x0L, 0x0L};
FillDEF Fill = {FILL_NONE, 0x00ffffffL, 1.0, 0L};
POINT *pts;
int i, ix, iy, np;
if(!(pts=(POINT*)malloc(sizeof(POINT)*(rec->right-rec->left)))) return;
switch(cmd) {
case OD_DRAWNORMAL:
case OD_DRAWSELECTED:
Line.color = cmd == OD_DRAWSELECTED ? 0x00000000L : 0x00e8e8e8L;
Fill.color = cmd == OD_DRAWSELECTED ? 0x00ffffffL : 0x00e8e8e8L;
ix = (rec->left + rec->right)/2;
iy = (rec->top +rec->bottom)/2;
o->SetLine(&Line);
pts[0].x = pts[3].x = pts[4].x = rec->left;
pts[0].y = pts[1].y = pts[4].y = rec->top;
pts[1].x = pts[2].x = rec->right-1;
pts[2].y = pts[3].y = rec->bottom-1;
o->oPolyline(pts, 5);
Line.color = 0x00000000L;
o->SetLine(&Line);
o->SetFill(&Fill);
o->oRectangle(rec->left+3, rec->top+3, rec->right-3, rec->bottom-3);
np = 0;
switch(id) {
case 201:
pts[np].x = rec->left+15; pts[np++].y = rec->bottom-15;
pts[np].x = rec->right-15; pts[np++].y = rec->top+15;
break;
case 206:
pts[np].x = rec->left+15; pts[np++].y = rec->bottom-10;
case 202:
pts[np].x = rec->left+15; pts[np++].y = rec->bottom-15;
pts[np].x = ix; pts[np++].y = pts[np-1].y;
pts[np].x = ix; pts[np++].y = iy;
pts[np].x = rec->right-15; pts[np++].y = iy;
pts[np].x = pts[np-1].x; pts[np++].y = rec->top+15;
if(id == 206){
pts[np].x = rec->right-8; pts[np++].y = rec->top+15;
}
break;
case 207:
pts[np].x = rec->left+8; pts[np++].y = rec->bottom-15;
case 203:
pts[np].x = rec->left+15; pts[np++].y = rec->bottom-15;
pts[np].x = pts[np-1].x; pts[np++].y = iy;
pts[np].x = ix; pts[np++].y = iy;
pts[np].x = ix; pts[np++].y = rec->top+15;
pts[np].x = rec->right-15; pts[np++].y = pts[np-1].y;
if(id == 207){
pts[np].x = rec->right-15; pts[np++].y = rec->top+7;
}
break;
case 208:
pts[np].x = rec->left+8; pts[np++].y = rec->bottom-15;
case 204:
pts[np].x = rec->left+15; pts[np++].y = rec->bottom-15;
pts[np].x = (pts[np-1].x + ix)>>1; pts[np++].y = pts[np-1].y;
pts[np].x = pts[np-1].x; pts[np++].y = iy;
pts[np].x = (rec->right-15 + ix)>>1; pts[np++].y = iy;
pts[np].x = pts[np-1].x; pts[np++].y = rec->top+15;
pts[np].x = rec->right-15; pts[np++].y = pts[np-1].y;
if(id == 208) pts[np-1].x += 6;
break;
case 209:
pts[np].x = rec->left+15; pts[np++].y = rec->bottom-10;
case 205:
pts[np].x = rec->left+15; pts[np++].y = rec->bottom-15;
pts[np].x = pts[0].x; pts[np++].y = (pts[np-1].y +iy)>>1;
pts[np].x = ix; pts[np++].y = pts[np-1].y;
pts[np].x = ix; pts[np++].y = (iy + rec->top+15)>>1;
pts[np].x = rec->right-15; pts[np++].y = pts[np-1].y;
pts[np].x = pts[np-1].x; pts[np++].y = rec->top+15;
if(id == 209) pts[np-1].y -= 7;
break;
case 210:
pts[0].x = rec->left +9; pts[0].y = iy+4; pts[1].x = pts[0].x+1;
for(i = 0; i < (rec->right - rec->left - 18); i++) {
pts[1].y = 4 + iy + iround(pow(20.0, 1.0+((double)-i)/30.0) * -sin(((double)i)/4.0));
o->oSolidLine(pts);
pts[0].x++; pts[1].x++; pts[0].y = pts[1].y;
}
o->oCircle(rec->left+7, iy+4, rec->left+12, iy +9);
o->oCircle(rec->left+12, iy-10, rec->left+17, iy -5);
o->oCircle(rec->right-19, iy+5, rec->right-24, iy +10);
o->oCircle(rec->right-9, iy, rec->right-14, iy+5);
break;
case 211:
pts[0].y = rec->top +9; pts[0].x = ix; pts[1].y = pts[0].y+1;
for(i = 0; i < (rec->bottom - rec->top - 18); i++) {
pts[1].x = ix + iround(pow(20.0, 1.0+((double)-i)/50.0) * -sin(((double)i)/4.0));
o->oSolidLine(pts);
pts[0].y++; pts[1].y++; pts[0].x = pts[1].x;
}
o->oCircle(ix-3, rec->top + 7, ix+2, rec->top + 12);
o->oCircle(rec->left+11, iy-10, rec->left+16, iy -5);
o->oCircle(ix+3, rec->top + 27, ix+8, rec->top + 32);
o->oCircle(ix-5, iy+12, ix, iy + 17);
break;
}
if(np) o->oPolyline(pts, np);
switch(id) {
case 201: case 202: case 203: case 204: case 205:
case 206: case 207: case 208: case 209:
o->oCircle(ix-2, iy-2, ix+2, iy+2);
#ifdef _WINDOWS
o->oCircle(rec->left+13, rec->bottom-13, rec->left+17, rec->bottom-17);
o->oCircle(rec->right-13, rec->top+13, rec->right-17, rec->top+17);
#else
o->oCircle(rec->left+13, rec->bottom-14, rec->left+17, rec->bottom-16);
o->oCircle(rec->right-14, rec->top+13, rec->right-16, rec->top+17);
#endif
break;
case 210: case 211:
break;
}
o->UpdateRect(rec, false);
free(pts);
break;
}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Execute error bar style as owner drawn buttons for the error bar dialog
// and in the scatterplot dialog
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void OD_ErrBarTempl(int cmd, void *par, RECT *rec, anyOutput *o,
void *data, int id)
{
LineDEF Line = {.1f, 1.0f, 0x0L, 0x0L};
FillDEF Fill = {FILL_NONE, 0x00ffffffL, 1.0, 0L};
POINT pts[6];
int ix, iy;
switch(cmd) {
case OD_DRAWNORMAL:
case OD_DRAWSELECTED:
Line.color = cmd == OD_DRAWSELECTED ? 0x00000000L : 0x00e8e8e8L;
Fill.color = cmd == OD_DRAWSELECTED ? 0x00ffffffL : 0x00e8e8e8L;
ix = (rec->left + rec->right)/2;
iy = (rec->top +rec->bottom)/2;
o->SetLine(&Line);
pts[0].x = pts[3].x = pts[4].x = rec->left;
pts[0].y = pts[1].y = pts[4].y = rec->top;
pts[1].x = pts[2].x = rec->right-1;
pts[2].y = pts[3].y = rec->bottom-1;
o->oPolyline(pts, 5);
Line.color = 0x00000000L;
o->SetLine(&Line);
o->SetFill(&Fill);
o->oRectangle(rec->left+3, rec->top+3, rec->right-3, rec->bottom-3);
switch(id) {
case 500:
pts[2].x = pts[3].x = ix;
pts[0].x = pts[4].x = ix-5; pts[1].x = pts[5].x = ix+5;
pts[0].y = pts[1].y = pts[2].y = rec->top +8;
pts[3].y = pts[4].y = pts[5].y = rec->bottom -8;
o->oSolidLine(pts); o->oSolidLine(pts+2); o->oSolidLine(pts+4);
break;
case 501:
case 502:
pts[2].x = pts[3].x = ix; pts[0].x = ix-5; pts[1].x = ix+5;
pts[0].y = pts[1].y = pts[2].y = (id == 502 ? rec->bottom -8 : rec->top +8);
pts[3].y = iy;
o->oSolidLine(pts); o->oSolidLine(pts+2);
break;
case 503:
pts[2].y = pts[3].y = iy;
pts[0].y = pts[4].y = iy-5; pts[1].y = pts[5].y = iy+5;
pts[0].x = pts[1].x = pts[2].x = rec->left +8;
pts[3].x = pts[4].x = pts[5].x = rec->right -8;
o->oSolidLine(pts); o->oSolidLine(pts+2); o->oSolidLine(pts+4);
break;
case 504:
case 505:
pts[2].y = pts[3].y = iy; pts[0].y = iy-5; pts[1].y = iy+5;
pts[0].x = pts[1].x = pts[2].x = (id == 505 ? rec->right -8 : rec->left +8);
pts[3].x = ix;
o->oSolidLine(pts); o->oSolidLine(pts+2);
break;
}
o->oCircle(ix-4, iy-4, ix+4, iy+4);
o->UpdateRect(rec, false);
break;
}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Execute whisker style as owner drawn buttons
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void OD_WhiskerTempl(int cmd, void *par, RECT *rec, anyOutput *o,
void *data, int id)
{
LineDEF Line = {.1f, 1.0f, 0x0L, 0x0L};
FillDEF Fill = {FILL_NONE, 0x00ffffffL, 1.0, 0L};
POINT pts[6];
int ix, iy;
switch(cmd) {
case OD_DRAWNORMAL:
case OD_DRAWSELECTED:
Line.color = cmd == OD_DRAWSELECTED ? 0x00000000L : 0x00e8e8e8L;
Fill.color = cmd == OD_DRAWSELECTED ? 0x00ffffffL : 0x00e8e8e8L;
ix = (rec->left + rec->right)/2;
iy = (rec->top +rec->bottom)/2;
o->SetLine(&Line);
pts[0].x = pts[3].x = pts[4].x = rec->left;
pts[0].y = pts[1].y = pts[4].y = rec->top;
pts[1].x = pts[2].x = rec->right-1;
pts[2].y = pts[3].y = rec->bottom-1;
o->oPolyline(pts, 5);
Line.color = 0x00000000L;
o->SetLine(&Line);
o->SetFill(&Fill);
o->oRectangle(rec->left+3, rec->top+3, rec->right-3, rec->bottom-3);
switch(id) {
case 500:
pts[2].x = pts[3].x = ix;
pts[0].x = pts[4].x = ix-5; pts[1].x = pts[5].x = ix+5;
pts[0].y = pts[1].y = pts[2].y = rec->top +8;
pts[3].y = pts[4].y = pts[5].y = rec->bottom -8;
o->oSolidLine(pts); o->oSolidLine(pts+2); o->oSolidLine(pts+4);
break;
case 501:
pts[0].x = pts[1].x = ix; pts[0].y = rec->bottom -8;
pts[1].y = rec->top +8; o->oSolidLine(pts);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -