1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338
|
//========================= viedcmdw.cxx ================================
// This is the source file for the command window class.
//
// Copyright (C) 1996 Philip Eckenroth, Mike Tipping, Marilee Padilla,
// John Fredric Jr. Masciantoni, and Bruce E. Wampler.
//
// This file is part of the V Icon Editor, and is covered
// under the terms of the GNU General Public License,
// Version 2. This program has NO WARRANTY. See the source file
// viedapp.cpp for more complete information about license terms.
//=======================================================================
#include <v/vnotice.h> // use notice box
#include <v/vfilesel.h> // for file selection
#include <v/vutil.h> // use utilities
#include <v/vynreply.h> // use yes/no reply box
#include <v/vreply.h> // use reply box
#include <v/vpen.h> // use a pen
#include <v/vicon.h> // use v defined icons
#include <v/vmodald.h>
#include <iostream.h>
#include <ctype.h>
#include "viedapp.h"
#include "viedcmdw.h" // our header
#include "viedcnv.h" // myCanvasPane class
#include "coldlg.h" // color palette dialog
#include "brshdlg.h" // brush dialog
//-------------------------------------------------------------
// MENUS and COMMAND BARS
//-------------------------------------------------------------
// Define the File and Edit pulldown menus
// Note - The space padding is necessary for X Athena to come out
// looking right, and it is harmless for Windows
static vMenu FileMenu[] =
{
{"&New ", M_New, isSens, notChk, "Ctrl-N", 'N'-'@', noSub},
{"&Open... ", M_Open, isSens, notChk, "Ctrl-O", 'O'-'@', noSub},
{"&Save ", M_Save, isSens, notChk, "Ctrl-S", 'S'-'@', noSub},
{"Save &as...", M_SaveAs, isSens,notChk,noKeyLbl,noKey,noSub},
{"C&lose ", m_CloseFile, isSens,notChk,"Ctrl-L",'L'-'@',noSub},
{"-", M_Line, notSens, notChk, noKeyLbl, noKey, noSub},
{"About V Icon Ed",M_About, isSens,notChk,noKeyLbl,noKey,noSub},
{"-", M_Line, notSens, notChk, noKeyLbl, noKey, noSub},
{"E&xit ", M_Exit, isSens, notChk, noKeyLbl, noKey, noSub},
{NULL}
};
static vMenu ZoomMenu[] =
{
{"&2", m_Zoom2, isSens, notChk, noKeyLbl, noKey,noSub},
{"&4", m_Zoom4, isSens, notChk, noKeyLbl, noKey,noSub},
{"&8", m_Zoom8, isSens, isChk, noKeyLbl, noKey,noSub},
{"&16", m_Zoom16, isSens, notChk, noKeyLbl, noKey,noSub},
{"&32", m_Zoom32, isSens, notChk, noKeyLbl, noKey,noSub},
{NULL}
};
static vMenu EditMenu[] =
{
{"&Undo ", m_Undo, isSens, notChk, "Ctrl-Z", 'Z'-'@',noSub},
{"&Clear", m_Clear, isSens, notChk, noKeyLbl, noKey,noSub},
{"-", M_Line, notSens, notChk, noKeyLbl, noKey, noSub},
{"&Resize",m_Resize, isSens,notChk,noKeyLbl, noKey, noSub},
{NULL}
};
static vMenu DrawMenu[] =
{
{"&Point", m_DrawPoint, isSens, isChk, noKeyLbl, noKey,noSub},
{"&Line", m_DrawLine, isSens, notChk, noKeyLbl, noKey, noSub},
{"&Rectangle", m_DrawRect, isSens, notChk, noKeyLbl, noKey,noSub},
{"R&ounded Rectangle", m_DrawRdRect, isSens, notChk, noKeyLbl, noKey,noSub},
{"&Ellipse", m_DrawEllipse, isSens, notChk, noKeyLbl, noKey,noSub},
{"Pick &Color", m_DrawDropper, isSens, notChk, noKeyLbl, noKey,noSub},
{"&Fill", m_DrawFill, isSens, notChk, noKeyLbl, noKey,noSub},
{"-", M_Line, notSens, notChk, noKeyLbl, noKey, noSub},
{"Refresh Image",m_DrawRefresh, isSens, notChk, noKeyLbl, noKey, noSub},
{"Show &Grid ",m_DrawGrid, isSens, isChk, "Ctrl-G", 'G'-'@', noSub},
{NULL}
};
static vMenu BrushMenu[] =
{
{"&Regular Brush", m_DrawPixel, isSens, isChk, noKeyLbl, noKey,noSub},
{"&Text Brush", m_DrawText, isSens, notChk, noKeyLbl, noKey,noSub},
{"&Cut/Paste Brush", m_DrawSelect, isSens, notChk, noKeyLbl, noKey,noSub},
{NULL}
};
// Define the main menu
vMenu MainMenu[] =
{
{"&File",M_File,isSens,notUsed,notUsed,noKey,&FileMenu[0]},
{"&Edit",M_Edit,isSens,notUsed,notUsed,noKey,&EditMenu[0]},
{"&Draw",92,isSens,notUsed,notUsed,noKey,&DrawMenu[0]},
{"&Brush",93,isSens,notUsed,notUsed,noKey,&BrushMenu[0]},
{"&Zoom",94,isSens,notUsed,notUsed,noKey,&ZoomMenu[0]},
{NULL}
};
// icon image files for command window toolbar
#include "palett.vbm"
#include "brushes.vbm"
#include "snap.vbm"
#include "clear.vbm"
#include "undo.vbm"
// define command window toolbar
static vIcon palett(&palett_bits[0], palett_height, palett_width, palett_depth);
static vIcon brushes(&brushes_bits[0], brushes_height, brushes_width, brushes_depth);
static vIcon snap(&snap_bits[0], snap_height, snap_width, snap_depth);
static vIcon undo(&undo_bits[0], undo_height, undo_width, undo_depth);
static vIcon clear(&clear_bits[0], clear_height, clear_width, clear_depth);
#include "drwbnorm.vbm"
#include "drwbsel.vbm"
#include "drwbabc.vbm"
static vIcon drwbnorm(&drwbnorm_bits[0], drwbnorm_height, drwbnorm_width, drwbnorm_depth);
static vIcon drwbsel(&drwbsel_bits[0], drwbsel_height, drwbsel_width, drwbsel_depth);
static vIcon drwbabc(&drwbabc_bits[0], drwbabc_height, drwbabc_width, drwbabc_depth);
static vColor fgBtnColor(0,0,0);
static vColor bgBtnColor(255,255,255);
// Define the tool command bar
static CommandObject CommandBar[] =
{
{C_Frame, m_fgbgFrame,0,"",NoList, CA_NoBorder | CA_NoSpace,isSens,NoFrame,0,0},
{C_ColorButton,m_fgColor,0," ",(void*)&fgBtnColor,CA_None,isSens,m_fgbgFrame,0,0,20},
{C_ColorButton,m_bgColor,0," ",(void*)&bgBtnColor,CA_None,isSens,m_fgbgFrame,m_fgColor,0,20},
{C_Blank,999,0," ",NoList, CA_None,isSens,NoFrame,0,0},
{C_ToggleIconButton, m_Snap, 0, "Snap", (void*)&snap,
CA_None,isSens,NoFrame,0,0},
{C_ToggleIconButton, m_BrshBox, 0, "BrushBox", (void*)&brushes,
CA_None,isSens,NoFrame,0,0},
{C_ToggleIconButton, m_ColorPalette, 0, "Palette", (void*)&palett,
CA_None,isSens,NoFrame,0,0},
{C_Blank,999,0," ",NoList, CA_None,isSens,NoFrame,0,0},
{C_Frame, m_brushFrame,0,"",NoList, CA_NoSpace,isSens,NoFrame,0,0},
{C_ToggleIconButton, m_DrawPixel, 1, "Norm Brush", (void*)&drwbnorm,
CA_None,isSens,m_brushFrame,0,0},
{C_ToggleIconButton, m_DrawText, 0, "Text Brush", (void*)&drwbabc,
CA_None,isSens,m_brushFrame,m_DrawPixel,0},
{C_ToggleIconButton, m_DrawSelect, 0, "Select Brush", (void*)&drwbsel,
CA_None,isSens,m_brushFrame,m_DrawText,0},
{C_EndOfList,0,0,0,0,CA_None,0,0,0}
};
// Shapes and tools icon images
#include "rect.vbm"
#include "rdrect.vbm"
#include "ellipse.vbm"
#include "line.vbm"
#include "point.vbm"
#include "fill.vbm"
#include "dropper.vbm"
// Shapes and tools icon declarations
static vIcon rect(&rect_bits[0], rect_height, rect_width, rect_depth);
static vIcon rdrect(&rdrect_bits[0], rdrect_height, rdrect_width, rdrect_depth);
static vIcon ellipse(&ellipse_bits[0], ellipse_height, ellipse_width, ellipse_depth);
static vIcon line(&line_bits[0], line_height, line_width, line_depth);
static vIcon point(&point_bits[0], point_height, point_width, point_depth);
static vIcon fill(&fill_bits[0], fill_height, fill_width, fill_depth);
static vIcon dropper(&dropper_bits[0], dropper_height, dropper_width, dropper_depth);
// Define shapes and tools icon item values
const ItemVal frShapeBox = 104;
const ItemVal frShape = 105;
static CommandObject ToolBar[] =
{
//----------- The shape frame ---------------------------------
{C_IconButton, m_Clear, 0, "Clear", (void*)&clear,
CA_None,isSens,NoFrame,0,0},
{C_IconButton, m_Undo, 0, "Undo", (void*)&undo,
CA_None,isSens,NoFrame,0,0},
{C_Frame, frShape, 0, "", NoList, CA_NoSpace, isSens, NoFrame, 0, lbL1},
{C_ToggleIconButton, m_DrawPoint, 1, "", (void*)&point, CA_None, isSens,
frShape, 0, 0},
{C_ToggleIconButton, m_DrawLine, 0, "", (void*)&line, CA_None, isSens,
frShape, m_DrawPoint, 0},
{C_ToggleIconButton, m_DrawRect, 0, "", (void*)&rect, CA_None, isSens,
frShape, m_DrawLine, 0},
{C_ToggleIconButton, m_DrawRdRect, 0, "", (void*)&rdrect, CA_None, isSens,
frShape, m_DrawRect, 0},
{C_ToggleIconButton, m_DrawEllipse, 0, "", (void*)&ellipse, CA_None, isSens,
frShape, m_DrawRdRect,0},
{C_ToggleIconButton, m_DrawDropper, 0, "", (void*)&dropper, CA_None, isSens,
frShape, m_DrawEllipse, 0},
{C_ToggleIconButton, m_DrawFill, 0, "", (void*)&fill, CA_None, isSens,
frShape, m_DrawDropper, 0},
{C_EndOfList,0,0,0,0,CA_None,0,0,0}
};
// Define the Status bar
vStatus StatBar[] =
{
{"X,Y: ", m_MousePosLbl, CA_NoBorder, isSens, 0 },
{" 000 ", m_MousePosX, CA_None, isSens, 0},
{" 000 ", m_MousePosY, CA_None, isSens, 0},
{NULL,0,0,0,0}
};
#include "about.vbm"
static vIcon about(&about_bits[0], about_height, about_width, about_depth);
static CommandObject About[] =
{
{C_Icon,800,0,"",&about,CA_None,isSens,0,0,0},
{C_Label,802,0," V Icon Editor Version" ,NoList,CA_None,isSens,0,800,0},
{C_Label,803,0,viedVers ,NoList,CA_None,isSens,0,802,0},
{C_Label,810,0,"Developed by Philip Eckenroth, Mike Tipping,",
NoList,CA_None,isSens,0,0,800},
{C_Label,820,0,"Marilee Padilla, and John Fredric Jr. Masciantoni,",
NoList,CA_None,isSens,0,0,810},
{C_Label,830,0,"for UNM CS-460 Software Engineering, Spring 1996.",
NoList,CA_None,isSens,0,0,820},
{C_Label,840,0,"Enhancements by Bruce E. Wampler. " ,
NoList,CA_None,isSens,0,0,830},
{C_Button,M_OK,0," OK ", NoList,CA_DefaultButton,isSens,0,840,840},
{C_EndOfList,0,0,0,0,CA_None,0,0,0}
};
static char* filter[] = {"*.vbm;*.bmp;*.xbm;*.xpm",
"*.vbm","*.bmp","*.xbm", "*.xpm","*", 0}; // file filter
static int filterIndex = 0;
//================>>> myCmdWindow::myCmdWindow <<<================
myCmdWindow::myCmdWindow(char* name, int width, int height) :
vCmdWindow(name, width, height)
{
// Create and add the proper panes to the CmdWindow
*_fname = 0; // no name
_fgbrush.SetColor(0,0,0); // black brush
_pen.SetColor(0,0,0); // black pen
_bg.Set(255,255,255); // white background
curWidth = 1; // brush width
_mx = _my = 0;
brushMenuId = m_BrushSolid;
penMenuId = m_PenSolid;
myMenu = new vMenuPane(MainMenu); // Add the main menu
AddPane(myMenu);
myCmdPane = new vCommandPane(CommandBar); // Add command pane
AddPane(myCmdPane);
myToolPane = new vCommandPane(ToolBar); // Add command pane
AddPane(myToolPane);
myCmdWindow* me = this;
myCanvas = new myCanvasPane(me); // Add the canvas pane
AddPane(myCanvas);
myCanvas->SetDrawShape(m_DrawPoint); // We will be drawing line
curShape = m_DrawPoint;
// Add the Status bar pane
myStatus = new vStatusPane(StatBar); // a new status bar
AddPane(myStatus);
myColDlg = 0; // all dialog windows are closed
myBrshDlg = 0;
ShowWindow(); // FINALLY, we must show the window!
myCanvas->ShowVScroll(1); // And, now turn on scroll bars
myCanvas->ShowHScroll(1);
myCanvas->SetDrawShape(m_DrawPoint);
}
//===============>>> myCmdWindow::~myCmdWindow <<<================
myCmdWindow::~myCmdWindow()
{
// Destory the command window and everything in it
delete myMenu; // Delete main menu
delete myCanvas; // Delete the canvas
delete myCmdPane; // Delete the command pane
delete myToolPane; // Delete the Tool pane
delete myStatus; // Delete the status bar
if (myColDlg) // if color palette is open, delete it
delete myColDlg;
if (myBrshDlg) // if brushes box is open, delete it
delete myBrshDlg;
}
//===================>>> myCmdWindow::SetFGBtn <<<====================
void myCmdWindow::SetFGBtn(vColor& color)
{
fgBtnColor = color;
SetValue(m_fgColor,0,ChangeColor);
}
//===================>>> myCmdWindow::SetBGBtn <<<====================
void myCmdWindow::SetBGBtn(vColor& color)
{
bgBtnColor = color;
SetValue(m_bgColor,0,ChangeColor);
}
//===================>>> myCmdWindow::GetText <<<====================
int myCmdWindow::GetText(void)
{
// Opens a reply dialog box, which allows the user to enter text.
// The text is then read from the input box, and the text is placed
// in the current brush.
vReplyDialog rp(this);
char r[25]; // a buffer for the reply
char temp_str[256];
char letter;
int location = 0; // this gives x location only - top left of letters
if ( rp.Reply("Enter Text for brush:",r,25) == M_Cancel)
return 0;
myCanvas->_myPicture->Clear(BrushLayer, myCanvas->_myColorPal->getbg());
while (strlen(r) > 0)
{
letter = r[0];
strcpy(temp_str, r+1);
strcpy(r, temp_str);
location = write_text(letter, location);
// add the call to add the letter to the brush layer here
}
myCanvas->_BrushOffX = 0;
myCanvas->_BrushOffY = 0;
myCanvas->_BrushWidth = location;
myCanvas->_BrushHeight = 7;
return 1;
}
//===================>>> myCmdWindow::write_text <<<=====================
int myCmdWindow::write_text(char letter, int location)
{
// Converts text input into a bit sequence, and draws it on the canvas
char bit_seq[46]; // text bit sequence
int pos;
int width = 5; // width of our custom font
int height = 7; // height of our custom font
char cur_bit;
if ( (location + width) > myCanvas->_myPicture->GetPicWidth())
return location;
switch(letter)
{
case 'A' :
{
strcpy(bit_seq, "01110100011000111111100011000110001");
break;
}
case 'B' :
{
strcpy(bit_seq, "11110100011000111110100011000111110");
break;
}
case 'C' :
{
strcpy(bit_seq, "01110100011000010000100001000101110");
break;
}
case 'D' :
{
strcpy(bit_seq, "11110100011000110001100011000111110");
break;
}
case 'E' :
{
strcpy(bit_seq, "11111100001000011110100001000011111");
break;
}
case 'F' :
{
strcpy(bit_seq, "11111100001000011110100001000010000");
break;
}
case 'G' :
{
strcpy(bit_seq, "01110100011000010000100111000101110");
break;
}
case 'H' :
{
strcpy(bit_seq, "10001100011000111111100011000110001");
break;
}
case 'I' :
{
strcpy(bit_seq, "11111001000010000100001000010011111");
break;
}
case 'J' :
{
strcpy(bit_seq, "11111001000010000100001001010011000");
break;
}
case 'K' :
{
strcpy(bit_seq, "10001100101010011000101001001010001");
break;
}
case 'L' :
{
strcpy(bit_seq, "10000100001000010000100001000011111");
break;
}
case 'M' :
{
strcpy(bit_seq, "10001110111010110101100011000110001");
break;
}
case 'N' :
{
strcpy(bit_seq, "10001110011010110101101011001110001");
break;
}
case 'O' :
{
strcpy(bit_seq, "01110100011000110001100011000101110");
break;
}
case 'P' :
{
strcpy(bit_seq, "11110100011000111110100001000010000");
break;
}
case 'Q' :
{
strcpy(bit_seq, "01110100011000110001101011001001101");
break;
}
case 'R' :
{
strcpy(bit_seq, "11110100011000111110101001001010001");
break;
}
case 'S' :
{
strcpy(bit_seq, "01110100011000001110000011000101110");
break;
}
case 'T' :
{
strcpy(bit_seq, "11111001000010000100001000010000100");
break;
}
case 'U' :
{
strcpy(bit_seq, "10001100011000110001100011000101110");
break;
}
case 'V' :
{
strcpy(bit_seq, "10001100010101001010010100010000100");
break;
}
case 'W' :
{
strcpy(bit_seq, "10001100011000110101101011010101110");
break;
}
case 'X' :
{
strcpy(bit_seq, "10001010100101000100010100101010001");
break;
}
case 'Y' :
{
strcpy(bit_seq, "10001010100101000100001000010000100");
break;
}
case 'Z' :
{
strcpy(bit_seq, "11111100010001000100010001000111111");
break;
}
case '0' :
{
strcpy(bit_seq, "01110100011000110001100011000101110");
break;
}
case '1' :
{
strcpy(bit_seq, "00100011001010000100001000010011111");
break;
}
case '2' :
{
strcpy(bit_seq, "01110100010000100010001000100011111");
break;
}
case '3' :
{
strcpy(bit_seq, "01110100010000100110000011000101110");
break;
}
case '4' :
{
strcpy(bit_seq, "10001100011000111111000010000100001");
break;
}
case '5' :
{
strcpy(bit_seq, "11111100001000011110000010000111110");
break;
}
case '6' :
{
strcpy(bit_seq, "00001000100010001110100011000101110");
break;
}
case '7' :
{
strcpy(bit_seq, "11111000010000100010001000100010000");
break;
}
case '8' :
{
strcpy(bit_seq, "01110100011000101110100011000101110");
break;
}
case '9' :
{
strcpy(bit_seq, "01110100011000101110000100010001000");
break;
}
case '-' :
{
strcpy(bit_seq, "00000000000000011111000000000000000");
break;
}
case '_' :
{
strcpy(bit_seq, "00000000000000000000000000000011111");
break;
}
case '=' :
{
strcpy(bit_seq, "00000000001111100000111110000000000");
break;
}
case '+' :
{
strcpy(bit_seq, "00000001000010011111001000010000000");
break;
}
case '!' :
{
strcpy(bit_seq, "00100001000010000100001000000000100");
break;
}
case '@' :
{
strcpy(bit_seq, "01110100011001110101101101000001110");
break;
}
case '#' :
{
strcpy(bit_seq, "00000010101111101010111110101000000");
break;
}
case '$' :
{
strcpy(bit_seq, "00100011101010001110001010111000100");
break;
}
case '%' :
{
strcpy(bit_seq, "01001101010101000100010101010110010");
break;
}
case '^' :
{
strcpy(bit_seq, "00100010101000100000000000000000000");
break;
}
case '&' :
{
strcpy(bit_seq, "01000101001010001000101011001001101");
break;
}
case '*' :
{
strcpy(bit_seq, "00000101010111011111011101010100000");
break;
}
case '(' :
{
strcpy(bit_seq, "00100010001000010000100000100000100");
break;
}
case ')' :
{
strcpy(bit_seq, "00100000100000100001000010001000100");
break;
}
case '~' :
{
strcpy(bit_seq, "01001101011001000000000000000000000");
break;
}
case '`' :
{
strcpy(bit_seq, "01100001000001000000000000000000000");
break;
}
case '[' :
{
strcpy(bit_seq, "01110010000100001000010000100001110");
break;
}
case ']' :
{
strcpy(bit_seq, "01110000100001000010000100001001110");
break;
}
case '{' :
{
strcpy(bit_seq, "00110010000010011000001000100000110");
break;
}
case '}' :
{
strcpy(bit_seq, "01100000100010000011001000001001100");
break;
}
case ':' :
{
strcpy(bit_seq, "00100011100010000000001000111000100");
break;
}
case ';' :
{
strcpy(bit_seq, "00100011100010000000001100010001000");
break;
}
case '"' :
{
strcpy(bit_seq, "01010010100101000000000000000000000");
break;
}
case '\'' :
{
strcpy(bit_seq, "00110001000100000000000000000000000");
break;
}
case '<' :
{
strcpy(bit_seq, "00000000110110010000011000001100000");
break;
}
case '>' :
{
strcpy(bit_seq, "00000110000011000001001101100000000");
break;
}
case ',' :
{
strcpy(bit_seq, "00000000000000000000001100010001000");
break;
}
case '.' :
{
strcpy(bit_seq, "00000000000000000000001000111000100");
break;
}
case '/' :
{
strcpy(bit_seq, "00001000010001000100010001000010000");
break;
}
case '\\' :
{
strcpy(bit_seq, "10000100000100000100000100000100001");
break;
}
case '|' :
{
strcpy(bit_seq, "00100001000010000000001000010000100");
break;
}
case '?' :
{
strcpy(bit_seq, "01110100010001000100001000000000100");
break;
}
case 'a' :
{
strcpy(bit_seq, "00000000000111000001011111000101111");
break;
}
case 'b' :
{
strcpy(bit_seq, "10000100001011011001100011100110110");
break;
}
case 'c' :
{
strcpy(bit_seq, "00000000000111010001100001000101110");
break;
}
case 'd' :
{
strcpy(bit_seq, "00001000010110110011100011001101101");
break;
}
case 'e' :
{
strcpy(bit_seq, "00000000000111010001111111000001110");
break;
}
case 'f' :
{
strcpy(bit_seq, "00110010010100011110010000100001000");
break;
}
case 'g' :
{
strcpy(bit_seq, "01101100100110010000011101000101110");
break;
}
case 'h' :
{
strcpy(bit_seq, "10000100001011011001100011000110001");
break;
}
case 'i' :
{
strcpy(bit_seq, "00100000000110000100001000010001110");
break;
}
case 'j' :
{
strcpy(bit_seq, "00010000000001000010100101001001100");
break;
}
case 'k' :
{
strcpy(bit_seq, "10000100001000110010111001001010001");
break;
}
case 'l' :
{
strcpy(bit_seq, "01100001000010000100001000010001110");
break;
}
case 'm' :
{
strcpy(bit_seq, "00000000001101010101101011010110001");
break;
}
case 'n' :
{
strcpy(bit_seq, "00000000001011011001100011000110001");
break;
}
case 'o' :
{
strcpy(bit_seq, "00000000000111010001100011000101110");
break;
}
case 'p' :
{
strcpy(bit_seq, "10110110011100110110100001000010000");
break;
}
case 'q' :
{
strcpy(bit_seq, "01101100111001101101000010000100001");
break;
}
case 'r' :
{
strcpy(bit_seq, "00000000001011011001100001000010000");
break;
}
case 's' :
{
strcpy(bit_seq, "00000000000111010000011100000111110");
break;
}
case 't' :
{
strcpy(bit_seq, "01000010001111001000010000100100110");
break;
}
case 'u' :
{
strcpy(bit_seq, "00000000001000110001100011001101101");
break;
}
case 'v' :
{
strcpy(bit_seq, "00000000001000110001010100101000100");
break;
}
case 'w' :
{
strcpy(bit_seq, "00000000001000110001101011010101010");
break;
}
case 'x' :
{
strcpy(bit_seq, "00000000001000101010001000101010001");
break;
}
case 'y' :
{
strcpy(bit_seq, "10001100011001101101000011000101110");
break;
}
case 'z' :
{
strcpy(bit_seq, "00000000001111100010001000100011111");
break;
}
case ' ' :
{
strcpy(bit_seq, "00000000000000000000000000000000000");
break;
}
}
for (int y=0; y < height; y++)
{
for (int x=0; x < width; x++)
{
pos = y * width + x;
cur_bit = bit_seq[pos];
if (cur_bit == '1')
myCanvas->_myPicture->SetIndex(location+x, y, 2, -99);
}
}
return location + width + 1;
}
//==============>>> myCmdWindow::OpenFile <<<================
void myCmdWindow::OpenFile(char* fname)
{
// Opens a given file
char fn[256]; // scratch copy
int ix;
if (*_fname) // already have one!
return;
for (ix = 0 ; fname[ix] != 0 && ix < 255 ; ++ix)
fn[ix] = fname[ix]; // safe copy
fn[ix] = 0;
if (!*fn) // no file open yet
{
vFileSelect fsel(this); // V file select dialog
if (!fsel.FileSelect("Open V Icon File",
fn,255,filter,filterIndex) || !*fn)
return;
}
if (!myCanvas->Read(fn)) // Save in _fname
{
vNoticeDialog note(this); // for user notification
note.Notice("Unable to open file.");
return;
}
if (myColDlg)
myColDlg->UpdatePalette(myCanvas->_myColorPal->_Palette,
myCanvas->_myColorPal->ColorsUsed());
myCanvas->setfg(0);
myCanvas->setbg(1);
WindowCommand(m_DrawPixel,1,C_Button);
WindowCommand(m_DrawPoint,1,C_Button);
SetTitle(fn); // show on title bar
strcpy(_fname,fn); // keep copy
myCanvas->Redraw(0,0,0,0); // paint it
myCanvas->SetChanged(0); // not really changed
}
//==============>>> myCmdWindow::CheckClose <<<================
int myCmdWindow::CheckClose()
{
// Checks to see if the user wants to save changes, if changes have been
// done, before it closes the application.
// Return 1 if ok to close now, 0 to abort
if (myCanvas->Changed()) // changes have been made
{
vYNReplyDialog ynr(this);
int ans = ynr.AskYN("Save new or changed drawing?");
if (ans == 0)
{
myCanvas->SetChanged(0);
return 1; // don't want to save
}
if (ans == -1) // cancel
return 0;
// ok, want to save changed file
if (*_fname) // have a name
{
if (!myCanvas->Save(_fname)) // Save in _fname
{
vNoticeDialog note(this); // for user notification
note.Notice("Unable to save file");
return 0;
}
}
else // need to request name
{
vFileSelect fsel(this); // V file select dialog
if (!fsel.FileSelectSave("Save icon file as",
_fname,99,filter,filterIndex) || !*_fname)
return 0;
if (!myCanvas->Save(_fname)) // Save in _fname
{
vNoticeDialog note(this); // for user notification
note.Notice("Unable to save file");
return 0;
}
}
}
return 1;
}
//==============>>> myCmdWindow::MouseXYStatus <<<================
void myCmdWindow::MouseXYStatus(int x, int y)
{
// Get the current X, Y status of the mouse
char buff[12];
_mx = x; _my = y;
IntToStr(x,buff); // convert x coordinate to a string
SetString(m_MousePosX,buff);
IntToStr(y,buff); // convert y coordinate to a string
SetString(m_MousePosY,buff);
}
//==============>>> myCmdWindow::GetDigit <<<====================
int myCmdWindow::GetDigit(char * digitstring)
{
// Get a digit from the string and make sure it is writable
int add = 0;
int x = 0;
while (isdigit(digitstring[x]))
{
add = (add * 10) + (digitstring[x] - '0');
x++;
}
return add;
}
//====================>>> myCmdWindow::GetWH <<<==========================
int myCmdWindow::GetWH(int& width, int& height)
{
// instantiate a dialog to ask for size of new icon.
vReplyDialog rp(this);
char r[32], tempr[32]; // a buffer for the reply
r[0] = 0;
if (rp.Reply("Please enter WIDTH and HEIGHT",r,30) == M_Cancel)
return 0;
if (r[0] == 0)
return 0;
// parse the returned size string - clean out crap and get
// just the numbers. If both nums are not there, punt and go
// with the standard defaults settings.
while (!(isdigit(r[0])) && (strlen(r) > 0))
{
strcpy(tempr, r+1);
strcpy(r, tempr);
}
width = GetDigit(r);
while (isdigit(r[0]) && (strlen(r) > 0))
{
strcpy(tempr, r+1);
strcpy(r, tempr);
}
while (!(isdigit(r[0])) && (strlen(r) > 0))
{
strcpy(tempr, r+1);
strcpy(r, tempr);
}
height = GetDigit(r);
// Check to see that nums are within ranges
if (height > 150 || width > 150)
{
vNoticeDialog note(this); // for user notification
note.Notice("Maximum icon size is 150x150.");
return 0;
}
return 1;
}
//====================>>> myCmdWindow::WindowCommand <<<==========================
void myCmdWindow::WindowCommand(ItemVal id, ItemVal val, CmdType cType)
{
// Implements the commands given from buttons and menu from the command window
int width, height;
// route all commands through here - menus and buttons
vNoticeDialog note(this); // for user notification
switch (id) // switch on id of commands
{
case M_New: // start new icon
{
if (!CheckClose()) // ok to close
break;
if (!GetWH(width,height))
break;
// make call for a new canvas of size - default is height = 0
if (height == 0)
myCanvas->NewCanvas();
else
myCanvas->NewCanvas(width, height);
myCanvas->setfg(0);
myCanvas->setbg(1);
WindowCommand(m_DrawPixel,1,C_Button);
WindowCommand(m_DrawPoint,1,C_Button);
myCanvas->ClearShapes();
if (myColDlg)
myColDlg->UpdatePalette(myCanvas->_myColorPal->_Palette,
myCanvas->_myColorPal->ColorsUsed());
break;
}
case M_Open: // open existing file
{
if (*_fname || myCanvas->Changed()) // need to create a new window
{
// create new window, then open a file in it.
myCmdWindow* cw = (myCmdWindow*)
theApp->NewAppWin(0,"V Icon Edit",400,200);
cw->OpenFile(""); // open via dialog
cw->RaiseWindow(); // bring to front
}
else
OpenFile(""); // open a file using dialog
myCanvas->setfg(0);
myCanvas->setbg(1);
WindowCommand(m_DrawPixel,1,C_Button);
WindowCommand(m_DrawPoint,1,C_Button);
break;
}
case m_CloseFile: // Close current file
{
if (!CheckClose()) // ok to close
break;
myCanvas->ClearShapes();
myCanvas->Redraw(0,0,0,0);
*_fname = 0;
SetTitle("Icon Edit - No Name"); // no file
break;
}
case M_Save: // save current drawing
{
if (*_fname) // already have a name
{
if (!myCanvas->Save(_fname)) // Save in _fname
{
note.Notice("Unable to save file");
}
else if (id == m_CloseFile)
{
*_fname = 0;
SetTitle("Icon Edit - No Name"); // no file
}
break;
}
// else fall through to SaveAs
}
case M_SaveAs: // save file as
{
vFileSelect fsel(this); // V file select dialog
if (!fsel.FileSelectSave("Save icon file as",
_fname,99,filter,filterIndex) || !*_fname)
break; // ignore if no selection
if (!myCanvas->Save(_fname)) // Save in _fname
{
note.Notice("Unable to save file");
break;
}
if (id == m_CloseFile)
{
*_fname = 0;
SetTitle("Icon Edit - No Name"); // no file
}
else
SetTitle(_fname); // change title
break;
}
case M_About:
{
vModalDialog about(this,"About V Icon Editor");
ItemVal dummy;
about.AddDialogCmds(About);
about.ShowModalDialog("",dummy);
break;
}
case M_Exit: // quit all
{
if (CheckClose()) // ok to close
theApp->Exit(); // Standard action for Exit
break;
}
case m_Undo:
{
myCanvas->Undo();
break;
}
case m_Clear: // clear the screen
{
myCanvas->ClearShapes();
myCanvas->Redraw(0,0,0,0);
myCanvas->SetChanged(1);
break;
}
case m_Resize:
{
int h, w;
if (!GetWH(w,h))
break;
myCanvas->ResizeCanvas(w,h);
WindowCommand(m_DrawPixel,1,C_Button);
WindowCommand(m_DrawPoint,1,C_Button);
break;
}
case m_Zoom2: // note: these values MUST be 700-732
case m_Zoom4:
case m_Zoom8:
case m_Zoom16:
case m_Zoom32:
{
SetValue(m_Zoom2,0,Checked);
SetValue(m_Zoom4,0,Checked);
SetValue(m_Zoom8,0,Checked);
SetValue(m_Zoom16,0,Checked);
SetValue(m_Zoom32,0,Checked);
SetValue(id,1,Checked); // turn on ours
myCanvas->_PixSize = id - m_Zoom0;
myCanvas->ResetScroll(); // reset any scrolling
myCanvas->Clear();
myCanvas->Redraw(0,0,0,0);
break;
}
case m_DrawDropper:
case m_DrawLine: // set what we are drawing
case m_DrawPoint:
case m_DrawRect:
case m_DrawRdRect:
case m_DrawEllipse:
case m_DrawFill:
{
SetValue(curShape,0,Checked); // fix the menu check
curShape = id;
SetValue(curShape,1,Checked);
myCanvas->SetDrawShape(id);
break;
}
case m_DrawText: // Text Brush
{
if (myCanvas->_cwin->GetText()) // Read text
{
SetValue(m_DrawText,1,Checked);
SetValue(m_DrawSelect,0,Checked);
SetValue(m_DrawPixel,0,Checked);
myCanvas->SetDrawShape(id);
}
else
{
SetValue(m_DrawText,0,Checked);
SetValue(m_DrawSelect,0,Checked);
SetValue(m_DrawPixel,1,Checked);
myCanvas->SetDrawShape(m_DrawPixel);
}
// myCanvas->Redraw(0,0,0,0); // paint it
break;
}
case m_DrawSelect:
{
SetValue(m_DrawText,0,Checked);
SetValue(m_DrawSelect,1,Checked);
SetValue(m_DrawPixel,0,Checked);
myCanvas->SetDrawShape(id);
// myCanvas->Redraw(0,0,0,0); // paint it
break;
}
case m_DrawPixel:
{
SetValue(m_DrawText,0,Checked);
SetValue(m_DrawSelect,0,Checked);
SetValue(m_DrawPixel,1,Checked);
myCanvas->SetDrawShape(id);
// myCanvas->Redraw(0,0,0,0); // paint it
break;
}
case m_ColorPalette: // open the color palette dialog
{
if (val)
{
if (!myColDlg) // not created yet
myColDlg = new vColorDialog(this, 0, myCanvas);
myColDlg->UpdatePalette(myCanvas->_myColorPal->_Palette,
myCanvas->_myColorPal->ColorsUsed());
myColDlg->ShowDialog("Color Selection");
int l,t,w,h;
GetPosition(l,t,w,h); // my position
myColDlg->SetDialogPosition(l+w+2,t); // put quick pick here
}
else // close the dialog
{
myColDlg->CloseDialog();
}
break;
}
case m_DrawGrid:
{
myCanvas->_drawGrid = !myCanvas->_drawGrid; // toggle
SetValue(m_DrawGrid,myCanvas->_drawGrid,Checked); // fix menu
myCanvas->Clear();
myCanvas->Redraw(0,0,0,0); // paint it
break;
}
case m_DrawRefresh:
{
myCanvas->Clear();
myCanvas->Redraw(0,0,0,0); // paint it
break;
}
case m_BrshBox: // open the brush box dialog
{
if (val)
{
if (!myBrshDlg) // not created yet
myBrshDlg = new vBrshDialog(this, 0, myCanvas);
myBrshDlg->ShowDialog("*Brushes*");
int l,t,w,h;
GetPosition(l,t,w,h); // my position
myBrshDlg->SetDialogPosition(l+w+2,t+280);
}
else // close the dialog
{
myBrshDlg->CloseDialog();
}
break;
}
case m_Snap: // enable the Snap utility
{
if (myCanvas->_snap == 0)
myCanvas->_snap = 1;
else
myCanvas->_snap = 0;
}
default: // change pen color?
{
vCmdWindow::WindowCommand(id, val, cType);
break;
}
}
}
|