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 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783
|
/*
GMAppKit.m
Copyright (C) 1996 Free Software Foundation, Inc.
Author: Ovidiu Predescu <ovidiu@net-community.com>
Date: November 1997
This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; see the file COPYING.LIB.
If not, see <http://www.gnu.org/licenses/> or write to the
Free Software Foundation, 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#import <Foundation/NSDebug.h>
#import "GNUstepGUI/GMAppKit.h"
#ifndef AUTORELEASE
#define AUTORELEASE(object) [object autorelease]
#define RELEASE(object) [object release]
#define RETAIN(object) [object retain]
#endif
void __dummy_GMAppKit_functionForLinking() {}
@implementation NSApplication (GMArchiverMethods)
- (void)encodeWithModelArchiver:(GMArchiver*)archiver
{
#ifndef GNU_GUI_LIBRARY
NSArray* windows1 = [self windows];
NSMutableArray* windows2 = [NSMutableArray array];
int i, count = [windows1 count];
for (i = 0; i < count; i++) {
NSWindow* window = [windows1 objectAtIndex:i];
if (([window isKindOfClass:[NSMenu class]] == NO)
&& ([NSStringFromClass ([window class])
isEqualToString: @"NSMenuPanel"] == NO))
[windows2 addObject:window];
}
[archiver encodeObject:windows2 withName:@"windows"];
#else
[archiver encodeObject:[self windows] withName:@"windows"];
#endif
[archiver encodeObject:[self keyWindow] withName:@"keyWindow"];
[archiver encodeObject:[self mainWindow] withName:@"mainWindow"];
[archiver encodeObject:[self mainMenu] withName:@"mainMenu"];
[archiver encodeObject:[self delegate] withName:@"delegate"];
}
- (id)initWithModelUnarchiver:(GMUnarchiver*)unarchiver
{
NSArray* windows;
NSEnumerator *enumerator;
NSWindow *win;
NSWindow* keyWindow;
NSWindow* mainWindow;
NSMenu* mainMenu;
id anObject;
#if GNU_GUI_LIBRARY
mainMenu = [unarchiver decodeObjectWithName:@"mainMenu"];
if (mainMenu)
[self setMainMenu:mainMenu];
#endif
windows = [unarchiver decodeObjectWithName:@"windows"];
enumerator = [windows objectEnumerator];
while ((win = [enumerator nextObject]) != nil)
{
/* If we did not retain the windows here, they would all get
released at the end of the event loop. */
RETAIN (win);
}
keyWindow = [unarchiver decodeObjectWithName:@"keyWindow"];
mainWindow = [unarchiver decodeObjectWithName:@"mainWindow"];
anObject = [unarchiver decodeObjectWithName:@"delegate"];
if (anObject)
[self setDelegate:anObject];
#ifndef GNU_GUI_LIBRARY
mainMenu = [unarchiver decodeObjectWithName:@"mainMenu"];
if (mainMenu)
[self setMainMenu:mainMenu];
#endif
[keyWindow makeKeyWindow];
[mainWindow makeMainWindow];
return self;
}
- (void)awakeFromModel
{
NSMenu* mainMenu = [self mainMenu];
[mainMenu update];
#if XDPS_BACKEND_LIBRARY || XRAW_BACKEND_LIBRARY || XGPS_BACKEND_LIBRARY
[mainMenu display];
#endif
}
+ (id)createObjectForModelUnarchiver:(GMUnarchiver*)unarchiver
{
return [NSApplication sharedApplication];
}
@end /* NSApplication (GMArchiverMethods) */
@implementation NSBox (GMArchiverMethods)
/* NSBox is very special because it always has a single subview, which
is the contentview, and it overrides addSubview: to add subviews to
the contentview. Make sure we can manage this case properly and
portably. */
- (NSArray *)subviewsForModel
{
return [NSArray array];
}
- (void)encodeWithModelArchiver:(GMArchiver*)archiver
{
[super encodeWithModelArchiver:archiver];
[archiver encodeSize:[self contentViewMargins] withName:@"contentViewMargins"];
[archiver encodeInt:[self borderType] withName:@"borderType"];
[archiver encodeInt:[self titlePosition] withName:@"titlePosition"];
[archiver encodeString:[self title] withName:@"title"];
[archiver encodeObject:[self titleFont] withName:@"titleFont"];
[archiver encodeObject:[self contentView] withName:@"contentView"];
}
- (id)initWithModelUnarchiver:(GMUnarchiver*)unarchiver
{
self = [super initWithModelUnarchiver:unarchiver];
[self setContentViewMargins:[unarchiver decodeSizeWithName:@"contentViewMargins"]];
[self setBorderType:[unarchiver decodeIntWithName:@"borderType"]];
[self setTitlePosition:[unarchiver decodeIntWithName:@"titlePosition"]];
[self setTitle:[unarchiver decodeStringWithName:@"title"]];
[self setTitleFont:[unarchiver decodeObjectWithName:@"titleFont"]];
[self setContentView: [unarchiver decodeObjectWithName:@"contentView"]];
return self;
}
@end /* NSBox (GMArchiverMethods) */
#if 0
@implementation NSButton (GMArchiverMethods)
- (void)encodeWithModelArchiver:(GMArchiver*)archiver
{
float delay, interval;
id theCell = [self cell];
[archiver encodeInt:[self state] withName:@"state"];
[self getPeriodicDelay:&delay interval:&interval];
[archiver encodeFloat:delay withName:@"delay"];
[archiver encodeFloat:interval withName:@"interval"];
[archiver encodeString:[self title] withName:@"title"];
[archiver encodeString:[self alternateTitle] withName:@"alternateTitle"];
[archiver encodeObject:[self image] withName:@"image"];
[archiver encodeObject:[self alternateImage] withName:@"alternateImage"];
[archiver encodeInt:[self imagePosition] withName:@"imagePosition"];
[archiver encodeBOOL:[self isBordered] withName:@"isBordered"];
[archiver encodeBOOL:[self isTransparent] withName:@"isTransparent"];
[archiver encodeString:[self keyEquivalent] withName:@"keyEquivalent"];
[archiver encodeInt:[theCell highlightsBy] withName:@"highlightsBy"];
[archiver encodeInt:[theCell showsStateBy] withName:@"showsStateBy"];
[super encodeWithModelArchiver:archiver];
}
- (id)initWithModelUnarchiver:(GMUnarchiver*)unarchiver
{
float delay, interval;
id theCell;
self = [super initWithModelUnarchiver:unarchiver];
[self setState:[unarchiver decodeIntWithName:@"state"]];
delay = [unarchiver decodeFloatWithName:@"delay"];
interval = [unarchiver decodeFloatWithName:@"interval"];
[self setPeriodicDelay:delay interval:interval];
[self setTitle:[unarchiver decodeStringWithName:@"title"]];
[self setAlternateTitle:[unarchiver decodeStringWithName:@"alternateTitle"]];
[self setImage:[unarchiver decodeObjectWithName:@"image"]];
[self setAlternateImage:[unarchiver decodeObjectWithName:@"alternateImage"]];
[self setImagePosition:[unarchiver decodeIntWithName:@"imagePosition"]];
[self setBordered:[unarchiver decodeBOOLWithName:@"isBordered"]];
[self setTransparent:[unarchiver decodeBOOLWithName:@"isTransparent"]];
[self setKeyEquivalent:[unarchiver decodeStringWithName:@"keyEquivalent"]];
theCell = [self cell];
[theCell setHighlightsBy:[unarchiver decodeIntWithName:@"highlightsBy"]];
[theCell setShowsStateBy:[unarchiver decodeIntWithName:@"showsStateBy"]];
return self;
}
@end /* NSButton (GMArchiverMethods) */
#endif
@implementation NSCell (GMArchiverMethods)
- (void)encodeWithModelArchiver:(GMArchiver*)archiver
{
[archiver encodeInt:[self type] withName:@"type"];
[archiver encodeObject:[self font] withName:@"font"];
[archiver encodeString:[self stringValue] withName:@"stringValue"];
[archiver encodeInt:[self entryType] withName:@"entryType"];
[archiver encodeInt:[self alignment] withName:@"alignment"];
[archiver encodeBOOL:[self wraps] withName:@"wraps"];
[archiver encodeObject:[self image] withName:@"image"];
[archiver encodeInt:[self state] withName:@"state"];
[archiver encodeBOOL:[self isEnabled] withName:@"isEnabled"];
[archiver encodeBOOL:[self isBordered] withName:@"isBordered"];
[archiver encodeBOOL:[self isBezeled] withName:@"isBezeled"];
[archiver encodeBOOL:[self isEditable] withName:@"isEditable"];
[archiver encodeBOOL:[self isSelectable] withName:@"isSelectable"];
[archiver encodeBOOL:[self isScrollable] withName:@"isScrollable"];
[archiver encodeBOOL:[self isContinuous] withName:@"isContinuous"];
[archiver encodeInt:[self sendActionOn: 0] withName:@"sendActionMask"];
{
/* NB: this is not decoded so maybe we could just do without
encoding it. :-) */
int actionMask = [self sendActionOn: 0];
[archiver encodeInt:actionMask withName:@"sendActionMask"];
[self sendActionOn: actionMask];
}
}
- (id)initWithModelUnarchiver:(GMUnarchiver*)unarchiver
{
int cellType = [unarchiver decodeIntWithName:@"type"];
NSFont* font = [unarchiver decodeObjectWithName:@"font"];
// this is a tricky object to decode, because a number of its methods
// have side-effects; [-setEntryType:] converts the cell to a text-type
// cell and sets its font to the system font, so it comes first
[self setEntryType:[unarchiver decodeIntWithName:@"entryType"]];
// now set the font
[self setFont:font];
// both [-setImage:] and [-setStringValue:] convert the cell to an
// image or text cell (respectively), so they must be called in the
// correct order for the type of cell desired
switch (cellType)
{
case NSTextCellType:
[self setImage:[unarchiver decodeObjectWithName:@"image"]];
[self setStringValue:
[unarchiver decodeStringWithName:@"stringValue"]];
break;
case NSImageCellType:
[self setStringValue:
[unarchiver decodeStringWithName:@"stringValue"]];
[self setImage:[unarchiver decodeObjectWithName:@"image"]];
break;
case NSNullCellType:
[self setType: NSNullCellType];
break;
}
[self setAlignment:[unarchiver decodeIntWithName:@"alignment"]];
[self setWraps:[unarchiver decodeBOOLWithName:@"wraps"]];
[self setState:[unarchiver decodeIntWithName:@"state"]];
[self setEnabled:[unarchiver decodeBOOLWithName:@"isEnabled"]];
[self setBordered:[unarchiver decodeBOOLWithName:@"isBordered"]];
[self setBezeled:[unarchiver decodeBOOLWithName:@"isBezeled"]];
[self setEditable:[unarchiver decodeBOOLWithName:@"isEditable"]];
[self setSelectable:[unarchiver decodeBOOLWithName:@"isSelectable"]];
[self setScrollable:[unarchiver decodeBOOLWithName:@"isScrollable"]];
[self setContinuous:[unarchiver decodeBOOLWithName:@"isContinuous"]];
/* Temporary commented out so buttons keep on working - new code
* fixing this under testing */
// [self sendActionOn:[unarchiver decodeIntWithName:@"sendActionMask"]];
return self;
}
@end /* NSCell (GMArchiverMethods) */
@implementation NSActionCell (GMArchiverMethods)
- (void)encodeWithModelArchiver:(GMArchiver*)archiver
{
[super encodeWithModelArchiver:archiver];
[archiver encodeInt:[self tag] withName:@"tag"];
[archiver encodeObject:[self target] withName:@"target"];
[archiver encodeSelector:[self action] withName:@"action"];
}
- (id)initWithModelUnarchiver:(GMUnarchiver*)unarchiver
{
self = [super initWithModelUnarchiver:unarchiver];
// if (model_version >= 2) {
[self setTag:[unarchiver decodeIntWithName:@"tag"]];
[self setTarget:[unarchiver decodeObjectWithName:@"target"]];
[self setAction:[unarchiver decodeSelectorWithName:@"action"]];
// }
return self;
}
@end /* NSActionCell (GMArchiverMethods) */
@implementation NSButtonCell (GMArchiverMethods)
- (void)encodeWithModelArchiver:(GMArchiver*)archiver
{
float delay, interval;
[super encodeWithModelArchiver:archiver];
[self getPeriodicDelay:&delay interval:&interval];
[archiver encodeFloat:delay withName:@"delay"];
[archiver encodeFloat:interval withName:@"interval"];
[archiver encodeString:[self title] withName:@"title"];
[archiver encodeString:[self alternateTitle] withName:@"alternateTitle"];
[archiver encodeObject:[self alternateImage] withName:@"alternateImage"];
[archiver encodeInt:[self imagePosition] withName:@"imagePosition"];
[archiver encodeBOOL:[self isTransparent] withName:@"isTransparent"];
[archiver encodeString:[self keyEquivalent] withName:@"keyEquivalent"];
[archiver encodeObject:[self keyEquivalentFont] withName:@"keyEquivalentFont"];
[archiver encodeInt:[self keyEquivalentModifierMask] withName:@"keyEquivalentModifierMask"];
[archiver encodeInt:[self highlightsBy] withName:@"highlightsBy"];
[archiver encodeInt:[self showsStateBy] withName:@"showsStateBy"];
}
- (id)initWithModelUnarchiver:(GMUnarchiver*)unarchiver
{
float delay, interval;
id obj;
self = [super initWithModelUnarchiver:unarchiver];
// if (model_version >= 2) {
delay = [unarchiver decodeFloatWithName:@"delay"];
interval = [unarchiver decodeFloatWithName:@"interval"];
[self setPeriodicDelay:delay interval:interval];
obj = [unarchiver decodeObjectWithName:@"alternateImage"];
[self setAlternateImage:obj];
[self setImagePosition:[unarchiver decodeIntWithName:@"imagePosition"]];
[self setTransparent:[unarchiver decodeBOOLWithName:@"isTransparent"]];
[self setKeyEquivalent:[unarchiver decodeStringWithName:@"keyEquivalent"]];
[self setKeyEquivalentFont:[unarchiver decodeObjectWithName:@"keyEquivalentFont"]];
[self setKeyEquivalentModifierMask:[unarchiver decodeIntWithName:@"keyEquivalentModifierMask"]];
[self setHighlightsBy:[unarchiver decodeIntWithName:@"highlightsBy"]];
[self setShowsStateBy:[unarchiver decodeIntWithName:@"showsStateBy"]];
obj = [unarchiver decodeStringWithName:@"title"];
if (obj) [self setTitle:obj];
obj = [unarchiver decodeStringWithName:@"alternateTitle"];
if (obj) [self setAlternateTitle:obj];
// }
return self;
}
@end /* NSButtonCell (GMArchiverMethods) */
@implementation NSMatrix (GMArchiverMethods)
- (void)encodeWithModelArchiver:(GMArchiver*)archiver
{
[super encodeWithModelArchiver:archiver];
[archiver encodeInt:[self mode] withName:@"mode"];
[archiver encodeBOOL:[self allowsEmptySelection] withName:@"allowsEmptySelection"];
[archiver encodeBOOL:[self isSelectionByRect] withName:@"isSelectionByRect"];
[archiver encodeBOOL:[self autosizesCells] withName:@"autosizesCells"];
[archiver encodeBOOL:[self isAutoscroll] withName:@"isAutoscroll"];
[archiver encodeSize:[self cellSize] withName:@"cellSize"];
[archiver encodeSize:[self intercellSpacing] withName:@"intercellSpacing"];
[archiver encodeObject:[self backgroundColor] withName:@"backgroundColor"];
[archiver encodeObject:[self cellBackgroundColor] withName:@"cellBackgroundColor"];
[archiver encodeBOOL:[self drawsBackground] withName:@"drawsBackground"];
[archiver encodeBOOL:[self drawsCellBackground] withName:@"drawsCellBackground"];
[archiver encodeClass:[self cellClass] withName:@"cellClass"];
[archiver encodeObject:[self prototype] withName:@"prototype"];
[archiver encodeInt:[self numberOfRows] withName:@"numberOfRows"];
[archiver encodeInt:[self numberOfColumns] withName:@"numberOfColumns"];
[archiver encodeObject:[self cells] withName:@"cells"];
[archiver encodeObject:[self delegate] withName:@"delegate"];
[archiver encodeObject:[self target] withName:@"target"];
[archiver encodeSelector:[self action] withName:@"action"];
[archiver encodeSelector:[self doubleAction] withName:@"doubleAction"];
[archiver encodeSelector:[self errorAction] withName:@"errorAction"];
}
- (id)initWithModelUnarchiver:(GMUnarchiver*)unarchiver
{
int nr, nc;
NSArray *cell_array;
int i;
id decodedDelegate;
self = [super initWithModelUnarchiver:unarchiver];
// if (model_version >= 2) {
[self setMode:[unarchiver decodeIntWithName:@"mode"]];
[self setAllowsEmptySelection:[unarchiver decodeBOOLWithName:@"allowsEmptySelection"]];
[self setSelectionByRect:[unarchiver decodeBOOLWithName:@"isSelectionByRect"]];
[self setAutosizesCells:[unarchiver decodeBOOLWithName:@"autosizesCells"]];
[self setAutoscroll:[unarchiver decodeBOOLWithName:@"isAutoscroll"]];
[self setCellSize:[unarchiver decodeSizeWithName:@"cellSize"]];
[self setIntercellSpacing:[unarchiver decodeSizeWithName:@"intercellSpacing"]];
[self setBackgroundColor:[unarchiver decodeObjectWithName:@"backgroundColor"]];
[self setCellBackgroundColor:[unarchiver decodeObjectWithName:@"cellBackgroundColor"]];
[self setDrawsBackground:[unarchiver decodeBOOLWithName:@"drawsBackground"]];
[self setDrawsCellBackground:[unarchiver decodeBOOLWithName:@"drawsCellBackground"]];
[self setCellClass:[unarchiver decodeClassWithName:@"cellClass"]];
[self setPrototype:[unarchiver decodeObjectWithName:@"prototype"]];
nr = [unarchiver decodeIntWithName:@"numberOfRows"];
nc = [unarchiver decodeIntWithName:@"numberOfColumns"];
cell_array = [unarchiver decodeObjectWithName:@"cells"];
[self renewRows:nr columns:nc];
#if GNU_GUI_LIBRARY
_selectedRow = _selectedColumn = 0;
#endif
for (i = 0; (i < [cell_array count]) && (i < nr*nc); i++)
{
id cell = [cell_array objectAtIndex:i];
[self putCell:cell atRow:i/nc column:i%nc];
if ([cell state])
[self selectCellAtRow:i/nc column:i%nc];
}
decodedDelegate = [unarchiver decodeObjectWithName:@"delegate"];
if (decodedDelegate)
[self setDelegate:decodedDelegate];
[self setTarget:[unarchiver decodeObjectWithName:@"target"]];
[self setAction:[unarchiver decodeSelectorWithName:@"action"]];
[self setDoubleAction:[unarchiver decodeSelectorWithName:@"doubleAction"]];
[self setErrorAction:[unarchiver decodeSelectorWithName:@"errorAction"]];
[self sizeToCells];
// }
return self;
}
@end /* NSMatrix (GMArchiverMethods) */
@implementation NSScrollView (GMArchiverMethods)
// do not encode our subviews in NSView (it would encode the clipview and
// the scroller, which are not necessary).
- (NSArray *)subviewsForModel
{
return [NSArray array];
}
- (void) encodeWithModelArchiver: (GMArchiver*)archiver
{
[super encodeWithModelArchiver: archiver];
[archiver encodeObject: [self backgroundColor]
withName: @"backgroundColor"];
[archiver encodeInt: [self borderType]
withName: @"borderType"];
[archiver encodeBOOL: [self hasHorizontalScroller]
withName: @"hasHorizontalScroller"];
[archiver encodeBOOL: [self hasVerticalScroller]
withName: @"hasVerticalScroller"];
[archiver encodeObject: [self documentView]
withName: @"documentView"];
}
- (id) initWithModelUnarchiver: (GMUnarchiver*)unarchiver
{
self = [super initWithModelUnarchiver: unarchiver];
[self setContentView: AUTORELEASE([NSClipView new])];
[self setBorderType:
[unarchiver decodeIntWithName: @"borderType"]];
[self setHasHorizontalScroller:
[unarchiver decodeBOOLWithName: @"hasHorizontalScroller"]];
[self setHasVerticalScroller:
[unarchiver decodeBOOLWithName: @"hasVerticalScroller"]];
[self setDocumentView:
[unarchiver decodeObjectWithName: @"documentView"]];
[self setBackgroundColor:
[unarchiver decodeObjectWithName: @"backgroundColor"]];
return self;
}
@end /* NSScrollView (GMArchiverMethods) */
@implementation NSClipView (GMArchiverMethods)
- (void)encodeWithModelArchiver:(GMArchiver*)archiver
{
[super encodeWithModelArchiver:archiver];
[archiver encodeObject:[self documentView] withName:@"documentView"];
[archiver encodeBOOL:[self copiesOnScroll] withName:@"copiesOnScroll"];
if ([self respondsToSelector: @selector(drawsBackground)])
[archiver encodeBOOL:[self drawsBackground] withName:@"drawsBackground"];
[archiver encodeObject:[self backgroundColor] withName:@"backgroundColor"];
}
- (id)initWithModelUnarchiver:(GMUnarchiver*)unarchiver
{
self = [super initWithModelUnarchiver:unarchiver];
[self setDocumentView:[unarchiver decodeObjectWithName:@"documentView"]];
[self setCopiesOnScroll:[unarchiver decodeBOOLWithName:@"copiesOnScroll"]];
if ([self respondsToSelector: @selector(setDrawsBackground:)])
[self setDrawsBackground:[unarchiver decodeBOOLWithName:@"drawsBackground"]];
[self setBackgroundColor:[unarchiver decodeObjectWithName:@"backgroundColor"]];
return self;
}
@end /* NSClipView (GMArchiverMethods) */
@implementation NSColor (GMArchiverMethods)
- (void)encodeWithModelArchiver:(GMArchiver*)archiver
{
NSString* colorSpaceName = [self colorSpaceName];
[archiver encodeString:colorSpaceName withName:@"colorSpaceName"];
if ([colorSpaceName isEqual:@"NSDeviceCMYKColorSpace"]) {
[archiver encodeFloat:[self cyanComponent] withName:@"cyan"];
[archiver encodeFloat:[self magentaComponent] withName:@"magenta"];
[archiver encodeFloat:[self yellowComponent] withName:@"yellow"];
[archiver encodeFloat:[self blackComponent] withName:@"black"];
[archiver encodeFloat:[self alphaComponent] withName:@"alpha"];
}
else if ([colorSpaceName isEqual:@"NSDeviceWhiteColorSpace"]
|| [colorSpaceName isEqual:@"NSCalibratedWhiteColorSpace"]) {
[archiver encodeFloat:[self whiteComponent] withName:@"white"];
[archiver encodeFloat:[self alphaComponent] withName:@"alpha"];
}
else if ([colorSpaceName isEqual:@"NSDeviceRGBColorSpace"]
|| [colorSpaceName isEqual:@"NSCalibratedRGBColorSpace"]) {
[archiver encodeFloat:[self redComponent] withName:@"red"];
[archiver encodeFloat:[self greenComponent] withName:@"green"];
[archiver encodeFloat:[self blueComponent] withName:@"blue"];
[archiver encodeFloat:[self alphaComponent] withName:@"alpha"];
[archiver encodeFloat:[self hueComponent] withName:@"hue"];
[archiver encodeFloat:[self saturationComponent] withName:@"saturation"];
[archiver encodeFloat:[self brightnessComponent] withName:@"brightness"];
}
else if ([colorSpaceName isEqual:@"NSNamedColorSpace"]) {
[archiver encodeString:[self catalogNameComponent]
withName:@"catalogName"];
[archiver encodeString:[self colorNameComponent] withName:@"colorName"];
}
else if ([colorSpaceName isEqual:@"NSPatternColorSpace"]) {
[archiver encodeObject: [self patternImage] withName: @"patternImage"];
}
}
+ (id)createObjectForModelUnarchiver:(GMUnarchiver*)unarchiver
{
NSString* colorSpaceName
= [unarchiver decodeStringWithName:@"colorSpaceName"];
if ([colorSpaceName isEqual:@"NSDeviceCMYKColorSpace"]) {
float cyan = [unarchiver decodeFloatWithName:@"cyan"];
float magenta = [unarchiver decodeFloatWithName:@"magenta"];
float yellow = [unarchiver decodeFloatWithName:@"yellow"];
float black = [unarchiver decodeFloatWithName:@"black"];
float alpha = [unarchiver decodeFloatWithName:@"alpha"];
return [NSColor colorWithDeviceCyan:cyan
magenta:magenta
yellow:yellow
black:black
alpha:alpha];
}
else if ([colorSpaceName isEqual:@"NSDeviceWhiteColorSpace"]) {
float white = [unarchiver decodeFloatWithName:@"white"];
float alpha = [unarchiver decodeFloatWithName:@"alpha"];
return [NSColor colorWithDeviceWhite:white alpha:alpha];
}
else if ([colorSpaceName isEqual:@"NSCalibratedWhiteColorSpace"]) {
float white = [unarchiver decodeFloatWithName:@"white"];
float alpha = [unarchiver decodeFloatWithName:@"alpha"];
return [NSColor colorWithCalibratedWhite:white alpha:alpha];
}
else if ([colorSpaceName isEqual:@"NSDeviceRGBColorSpace"]) {
float red = [unarchiver decodeFloatWithName:@"red"];
float green = [unarchiver decodeFloatWithName:@"green"];
float blue = [unarchiver decodeFloatWithName:@"blue"];
float alpha = [unarchiver decodeFloatWithName:@"alpha"];
return [self colorWithDeviceRed:red green:green blue:blue alpha:alpha];
}
else if ([colorSpaceName isEqual:@"NSCalibratedRGBColorSpace"]) {
float red = [unarchiver decodeFloatWithName:@"red"];
float green = [unarchiver decodeFloatWithName:@"green"];
float blue = [unarchiver decodeFloatWithName:@"blue"];
float alpha = [unarchiver decodeFloatWithName:@"alpha"];
return [self colorWithCalibratedRed:red green:green blue:blue alpha:alpha];
}
else if ([colorSpaceName isEqual:@"NSNamedColorSpace"]) {
NSString *catalog = [unarchiver decodeStringWithName: @"catalogName"];
NSString *colornm = [unarchiver decodeStringWithName: @"colorName"];
return [self colorWithCatalogName: catalog colorName: colornm];
}
else if ([colorSpaceName isEqual:@"NSPatternColorSpace"]) {
NSImage *image = [unarchiver decodeObjectWithName: @"patternImage"];
if (image == nil)
{
NSLog(@"Internal: No can't decode colorspace %@", colorSpaceName);
NSLog(@" creating generic white color");
return [NSColor colorWithDeviceWhite: 1.0 alpha: 1.0];
}
else
return [NSColor colorWithPatternImage: image];
}
else
{
NSLog(@"Internal: No decoder for colorspace %@", colorSpaceName);
NSLog(@" creating generic white color");
return [NSColor colorWithDeviceWhite: 1.0 alpha: 1.0];
}
return nil;
}
- (id)initWithModelUnarchiver:(GMUnarchiver*)unarchiver
{
return self;
}
- (Class)classForModelArchiver
{
return [NSColor class];
}
@end /* NSColor (GMArchiverMethods) */
@implementation NSControl (GMArchiverMethods)
- (void)encodeWithModelArchiver:(GMArchiver*)archiver
{
[archiver encodeObject:[self cell] withName:@"cell"];
[archiver encodeBOOL:[self isEnabled] withName:@"isEnabled"];
[archiver encodeInt:[self tag] withName:@"tag"];
[archiver encodeBOOL:[self ignoresMultiClick] withName:@"ignoresMultiClick"];
[super encodeWithModelArchiver:archiver];
}
- (id)initWithModelUnarchiver:(GMUnarchiver*)unarchiver
{
id decodedCell;
self = [super initWithModelUnarchiver:unarchiver];
// if (model_version == 1) {
//[self setTarget:[unarchiver decodeObjectWithName:@"target"]];
//[self setAction:[unarchiver decodeSelectorWithName:@"action"]];
//[self setEnabled:[unarchiver decodeBOOLWithName:@"isEnabled"]];
//[self setAlignment:[unarchiver decodeIntWithName:@"alignment"]];
//[self setFont:[unarchiver decodeObjectWithName:@"font"]];
//[self setContinuous:[unarchiver decodeBOOLWithName:@"isContinuous"]];
//[self setTag:[unarchiver decodeIntWithName:@"tag"]];
//[self setIgnoresMultiClick:
// [unarchiver decodeBOOLWithName:@"ignoresMultiClick"]];
// } else {
{
// So that custom NSControls, which do not encode the cell,
// can still work.
decodedCell = [unarchiver decodeObjectWithName:@"cell"];
if (decodedCell)
[self setCell: decodedCell];
else
[self setCell: AUTORELEASE([[[self class] cellClass] new])];
}
[self setEnabled:[unarchiver decodeBOOLWithName:@"isEnabled"]];
[self setTag:[unarchiver decodeIntWithName:@"tag"]];
[self setIgnoresMultiClick:
[unarchiver decodeBOOLWithName:@"ignoresMultiClick"]];
// }
return self;
}
@end /* NSControl (GMArchiverMethods) */
@implementation NSFont (GMArchiverMethods)
- (void)encodeWithModelArchiver:(GMArchiver*)archiver
{
[archiver encodeString:[self fontName] withName:@"name"];
[archiver encodeFloat:[self pointSize] withName:@"size"];
}
+ (id)createObjectForModelUnarchiver:(GMUnarchiver*)unarchiver
{
NSFont *f = [NSFont fontWithName:[unarchiver decodeStringWithName:@"name"]
size:[unarchiver decodeFloatWithName:@"size"]];
if (!f)
f = [NSFont systemFontOfSize: [unarchiver decodeFloatWithName:@"size"]];
return f;
}
- (id)initWithModelUnarchiver:(GMUnarchiver*)unarchiver
{
return self;
}
@end /* NSFont (GMArchiverMethods) */
@implementation NSImage (GMArchiverMethods)
extern id _nibOwner;
- (void)encodeWithModelArchiver:(GMArchiver*)archiver
{
[archiver encodeString:[self name] withName:@"name"];
[archiver encodeSize:[self size] withName:@"size"];
}
+ (id)createObjectForModelUnarchiver:(GMUnarchiver*)unarchiver
{
id image = nil;
NSString *imageName;
imageName = [unarchiver decodeStringWithName:@"name"];
if (imageName)
{
image = [NSImage imageNamed: imageName];
if (image == nil)
{
NSBundle *bundle = [NSBundle bundleForClass:[_nibOwner class]];
NSString *path = [bundle pathForImageResource:imageName];
image = [[NSImage alloc] initByReferencingFile:path];
}
}
if (image == nil)
image = [NSImage imageNamed:@"GNUstepMenuImage"];
return image;
}
- (id)initWithModelUnarchiver:(GMUnarchiver*)unarchiver
{
[self setSize:[unarchiver decodeSizeWithName:@"size"]];
return self;
}
@end /* NSImage (GMArchiverMethods) */
@implementation NSMenuItem (GMArchiverMethods)
- (void)encodeWithModelArchiver:(GMArchiver*)archiver
{
[archiver encodeString:[self title] withName:@"title"];
if ([self hasSubmenu] == NO)
{
if ([self respondsToSelector: @selector(image)])
[archiver encodeObject:[self image] withName:@"image"];
if ([self respondsToSelector: @selector(onStateImage)])
[archiver encodeObject:[self onStateImage] withName:@"onStateImage"];
if ([self respondsToSelector: @selector(offStateImage)])
[archiver encodeObject:[self offStateImage] withName:@"offStateImage"];
if ([self respondsToSelector: @selector(mixedStateImage)])
[archiver encodeObject:[self mixedStateImage]
withName:@"mixedStateImage"];
}
[archiver encodeString:[self keyEquivalent] withName:@"keyEquivalent"];
if ([self respondsToSelector: @selector(state)])
{
[archiver encodeInt:[self state] withName:@"state"];
}
[archiver encodeObject:[self target] withName:@"target"];
[archiver encodeSelector:[self action] withName:@"action"];
[archiver encodeInt:[self tag] withName:@"tag"];
[archiver encodeBOOL:[self isEnabled] withName:@"isEnabled"];
if ([self respondsToSelector: @selector(changesState)])
{
[archiver encodeBOOL:[self changesState] withName:@"changesState"];
}
if ([self respondsToSelector: @selector(submenu)])
{
[archiver encodeObject:[self submenu] withName:@"submenu"];
}
[archiver encodeConditionalObject:[self representedObject]
withName:@"representedObject"];
}
- (id)initWithModelUnarchiver:(GMUnarchiver*)unarchiver
{
[self setTitle:[unarchiver decodeStringWithName:@"title"]];
[self setImage:[unarchiver decodeObjectWithName:@"image"]];
[self setOnStateImage:[unarchiver decodeObjectWithName:@"onStateImage"]];
[self setOffStateImage:[unarchiver decodeObjectWithName:@"offStateImage"]];
[self setMixedStateImage:[unarchiver
decodeObjectWithName:@"mixedStateImage"]];
[self setKeyEquivalent:[unarchiver decodeStringWithName:@"keyEquivalent"]];
[self setState:[unarchiver decodeIntWithName:@"state"]];
[self setAction:[unarchiver decodeSelectorWithName:@"action"]];
[self setTarget: [unarchiver decodeObjectWithName: @"target"]];
[self setTag:[unarchiver decodeIntWithName:@"tag"]];
[self setEnabled:[unarchiver decodeBOOLWithName:@"isEnabled"]];
[self setChangesState:[unarchiver decodeBOOLWithName:@"changesState"]];
[self setRepresentedObject:[unarchiver
decodeObjectWithName:@"representedObject"]];
/*
* Here we have quite a delicate point.
* In OPENSTEP 4.x, NSMenuItems with submenus have their submenu
* as target; they do not answer to -submenu, so the encoded submenu
* is nil; the submenu is actually encoded as the target.
*
* In GNUstep the target is instead the menu, and the submenu
* is stored in an additional ivar.
*
* I don't know about MacOS-X.
*
* This code needs to be able to decode gmodels created on OPENSTEP 4.x too,
* that's why we have the following.
*/
/* Safety assignment. */
[self setMenu: nil];
/* Set submenu ... but not if it's nil, because this assignment
* always has side effects on action and target and we don't want to mess
* them up if we don't have a submenu! */
{
id submenu = [unarchiver decodeObjectWithName: @"submenu"];
if (submenu != nil)
{
[self setSubmenu: submenu];
}
}
/* Now we fix the submenu from the target if needed: */
#ifdef GNU_GUI_LIBRARY
/*
* Set submenu from target if not set (this happens if the gmodel
* was created on OPENSTEP).
*/
if ([NSStringFromSelector ([self action])
isEqualToString: @"submenuAction:"])
{
if ([self submenu] == nil)
{
if ([[self target] isKindOfClass: [NSMenu class]])
{
[self setSubmenu: [self target]];
}
else
{
NSLog(@"Error decoding gmodel - submenu not an NSMenu");
}
}
}
#endif
/* NB: The target might now be wrong (in case the gmodel was encoded
in a platform where the target is the submenu while we now want
the target to be the menu) ! This is automatically fixed later,
because after the NSMenuItem is decoded, it is added to its
container NSMenu, which will fix the target. */
#if 0
NSLog (@"menu item %@: target = %@, isEnabled = %d",
[self title], [self target], [self isEnabled]);
#endif
return self;
}
@end /* NSMenuItem (GMArchiverMethods) */
@implementation NSMenu (GMArchiverMethods)
- (void)encodeWithModelArchiver:(GMArchiver*)archiver
{
[archiver encodeString:[self title] withName:@"title"];
[archiver encodeObject:[self itemArray] withName:@"itemArray"];
[archiver encodeBOOL:[self autoenablesItems] withName:@"autoenablesItems"];
}
/* Define this method here because on OPENSTEP 4.x the NSMenu is inherited from
NSWindow and we don't want the NSWindow's method to be called. */
+ (id)createObjectForModelUnarchiver:(GMUnarchiver*)unarchiver
{
NSString* theTitle = [unarchiver decodeStringWithName:@"title"];
return [[[self allocWithZone:[unarchiver objectZone]] initWithTitle:theTitle]
autorelease];
}
- (id)initWithModelUnarchiver:(GMUnarchiver*)unarchiver
{
int i, count;
NSMutableArray* decodedItems;
decodedItems = [unarchiver decodeObjectWithName: @"itemArray"];
count = [decodedItems count];
for (i = 0; i < count; i++)
{
id item = [decodedItems objectAtIndex: i];
[self addItem: item];
}
[self setAutoenablesItems: [unarchiver decodeBOOLWithName:
@"autoenablesItems"]];
[self sizeToFit];
return self;
}
@end /* NSMenu (GMArchiverMethods) */
/* This class is special - to avoid having the cell encoded we encode
it directly. Perhaps it would be wiser to do differently. */
@implementation NSPopUpButton (GMArchiverMethods)
- (void)encodeWithModelArchiver:(GMArchiver*)archiver
{
[archiver encodeRect: [self frame] withName: @"frame"];
[archiver encodeBOOL: [self pullsDown] withName: @"pullsDown"];
[archiver encodeBOOL: [self isEnabled] withName: @"isEnabled"];
[archiver encodeInt: [self tag] withName: @"tag"];
[archiver encodeObject: [self target] withName: @"target"];
[archiver encodeSelector: [self action] withName: @"action"];
[archiver encodeInt: [self autoresizingMask]
withName: @"autoresizingMask"];
#if 0 //def __APPLE__
{
int i;
NSMutableArray *array;
array = [NSMutableArray arrayWithCapacity: [self numberOfItems]];
for (i = 0; i < [self numberOfItems]; i++)
[array addObject: [self itemAtIndex: i]];
[archiver encodeArray: array withName: @"itemArray"];
}
#else
[archiver encodeArray:[self itemArray] withName:@"itemArray"];
#endif
[archiver encodeString:[[self selectedItem] title] withName:@"selectedItem"];
}
+ (id)createObjectForModelUnarchiver:(GMUnarchiver*)unarchiver
{
NSRect rect;
NSPopUpButton *popup;
BOOL pullsDown;
rect = [unarchiver decodeRectWithName: @"frame"];
pullsDown = [unarchiver decodeBOOLWithName: @"pullsDown"];
popup = [NSPopUpButton allocWithZone: [unarchiver objectZone]];
popup = [popup initWithFrame: rect pullsDown: pullsDown];
AUTORELEASE (popup);
return popup;
}
- (id)initWithModelUnarchiver:(GMUnarchiver*)unarchiver
{
int i, count;
NSString *string;
NSArray *decodedItems;
decodedItems = [unarchiver decodeArrayWithName: @"itemArray"];
if (decodedItems && [decodedItems count])
{
count = [decodedItems count];
for (i = 0; i < count; i++)
{
id item = [decodedItems objectAtIndex:i];
id myItem;
[self addItemWithTitle: [item title]];
myItem = [self itemAtIndex:i];
[myItem setTarget: [item target]];
[myItem setAction: [item action]];
[myItem setEnabled: [item isEnabled]];
[myItem setTag: [item tag]];
[myItem setKeyEquivalent: [item keyEquivalent]];
}
string = [unarchiver decodeStringWithName: @"selectedItem"];
[self selectItemWithTitle: string];
}
else
{
/* For old gmodels that didn't support popups */
[self addItemWithTitle: @"Item 1"];
[self selectItemAtIndex: 0];
}
[self setEnabled: [unarchiver decodeBOOLWithName: @"isEnabled"]];
[self setTag: [unarchiver decodeIntWithName: @"tag"]];
[self setTarget: [unarchiver decodeObjectWithName: @"target"]];
[self setAction: [unarchiver decodeSelectorWithName: @"action"]];
[self setAutoresizingMask:
[unarchiver decodeIntWithName: @"autoresizingMask"]];
return self;
}
@end /* NSPopUpButton (GMArchiverMethods) */
@implementation NSResponder (GMArchiverMethods)
- (void)encodeWithModelArchiver:(GMArchiver*)archiver
{
id nextResponder;
if ((nextResponder = [self nextResponder]))
[archiver encodeObject:nextResponder withName:@"nextResponder"];
if ([self respondsToSelector: @selector(interfaceStyle)])
[archiver encodeUnsignedInt: [self interfaceStyle]
withName:@"interfaceStyle"];
}
- (id)initWithModelUnarchiver:(GMUnarchiver*)unarchiver
{
[self setNextResponder:[unarchiver decodeObjectWithName:@"nextResponder"]];
if ([self respondsToSelector: @selector(setInterfaceStyle:)])
[self setInterfaceStyle:
[unarchiver decodeUnsignedIntWithName:@"interfaceStyle"]];
return self;
}
@end /* NSResponder (GMArchiverMethods) */
@implementation NSTextField (GMArchiverMethods)
- (void)encodeWithModelArchiver:(GMArchiver*)archiver
{
[super encodeWithModelArchiver:archiver];
[archiver encodeSelector:[self errorAction] withName:@"errorAction"];
[archiver encodeObject:[self delegate] withName:@"delegate"];
}
- (id)initWithModelUnarchiver:(GMUnarchiver*)unarchiver
{
self = [super initWithModelUnarchiver:unarchiver];
[self setErrorAction:[unarchiver decodeSelectorWithName:@"errorAction"]];
[self setDelegate:[unarchiver decodeObjectWithName:@"delegate"]];
return self;
}
@end /* NSTextField (GMArchiverMethods) */
@implementation NSSecureTextFieldCell (GMArchiverMethods)
- (void)encodeWithModelArchiver:(GMArchiver*)archiver
{
[super encodeWithModelArchiver:archiver];
if ([self respondsToSelector: @selector(echosBullets)])
[archiver encodeBOOL:[self echosBullets] withName:@"echosBullets"];
}
- (id)initWithModelUnarchiver:(GMUnarchiver*)unarchiver
{
self = [super initWithModelUnarchiver:unarchiver];
if ([self respondsToSelector: @selector(setEchosBullets:)])
[self setEchosBullets:[unarchiver decodeBOOLWithName:@"echosBullets"]];
return self;
}
@end /* NSSecureTextFieldCell (GMArchiverMethods) */
@implementation NSView (GMArchiverMethods)
// subclasses may not want to encode all subviews...
- (NSArray *)subviewsForModel
{
#ifdef GNU_GUI_LIBRARY
return [self subviews];
#else /* Do not encode Apple's private classes */
NSArray *views;
NSMutableArray *viewsToEncode;
id e, o;
NSString *classString;
views = [self subviews];
viewsToEncode = [NSMutableArray array];
e = [views objectEnumerator];
while ((o = [e nextObject]))
{
classString = NSStringFromClass ([o class]);
if ([classString isEqualToString: @"_NSKeyboardFocusClipView"] == NO)
[viewsToEncode addObject: o];
}
return viewsToEncode;
#endif
}
- (void)encodeWithModelArchiver:(GMArchiver*)archiver
{
[super encodeWithModelArchiver:archiver];
[archiver encodeConditionalObject:[self superview] withName:@"superview"];
[archiver encodeObject:[self subviewsForModel] withName:@"subviews"];
[archiver encodeRect:[self frame] withName:@"frame"];
[archiver encodeRect:[self bounds] withName:@"bounds"];
[archiver encodeBOOL:[self postsFrameChangedNotifications]
withName:@"postsFrameChangedNotifications"];
[archiver encodeBOOL:[self postsBoundsChangedNotifications]
withName:@"postsBoundsChangedNotifications"];
[archiver encodeBOOL:[self autoresizesSubviews]
withName:@"autoresizesSubviews"];
[archiver encodeUnsignedInt:[self autoresizingMask]
withName:@"autoresizingMask"];
[archiver encodeConditionalObject:[self nextKeyView] withName:@"nextKeyView"];
[archiver encodeConditionalObject:[self previousKeyView]
withName:@"previousKeyView"];
}
+ (id)createObjectForModelUnarchiver:(GMUnarchiver*)unarchiver
{
NSRect rect = [unarchiver decodeRectWithName:@"frame"];
NSView* view = [[[self allocWithZone:[unarchiver objectZone]]
initWithFrame:rect]
autorelease];
if (!view)
NSLog (@"cannot create the requested view!");
return view;
}
- (id)initWithModelUnarchiver:(GMUnarchiver*)unarchiver
{
NSArray* subviews;
int i, count;
id superview;
self = [super initWithModelUnarchiver:unarchiver];
superview = [unarchiver decodeObjectWithName:@"superview"];
/* If we are the content view of an NSBox, don't add ourselves to it.
This is done later in the NSBox unachiver method */
if ([superview isKindOfClass: [NSBox class]] == NO)
[superview addSubview:self];
subviews = [unarchiver decodeObjectWithName:@"subviews"];
for (i = 0, count = [subviews count]; i < count; i++)
[self addSubview:[subviews objectAtIndex:i]];
// [self setBounds:[unarchiver decodeRectWithName:@"bounds"]];
[self setPostsFrameChangedNotifications:
[unarchiver decodeBOOLWithName:@"postsFrameChangedNotifications"]];
[self setPostsBoundsChangedNotifications:
[unarchiver decodeBOOLWithName:@"postsBoundsChangedNotifications"]];
[self setAutoresizesSubviews:
[unarchiver decodeBOOLWithName:@"autoresizesSubviews"]];
[self setAutoresizingMask:
[unarchiver decodeUnsignedIntWithName:@"autoresizingMask"]];
[self setNextKeyView: [unarchiver decodeObjectWithName:@"nextKeyView"]];
[self setPreviousKeyView:
[unarchiver decodeObjectWithName:@"previousKeyView"]];
#ifdef GNU_GUI_LIBRARY
_rFlags.flipped_view = [self isFlipped];
if ([_sub_views count])
_rFlags.has_subviews = 1;
#endif
return self;
}
@end /* NSView (GMArchiverMethods) */
@implementation NSWindow (GMArchiverMethods)
- (void)encodeWithModelArchiver:(GMArchiver*)archiver
{
NSPoint wnOrigin = [self frame].origin;
NSRect ctFrame = [[self contentView] frame], minRect;
unsigned int style;
ctFrame.origin = wnOrigin;
/* convert minSize to GNUstep frame (without title bar and resize bar) */
minRect.origin = wnOrigin;
minRect.size = [self minSize];
minRect = [NSWindow contentRectForFrameRect:minRect
styleMask:[self styleMask]];
[archiver encodeRect:ctFrame withName:@"contentFrame"];
[archiver encodeSize:[self maxSize] withName:@"maxSize"];
[archiver encodeSize:minRect.size withName:@"minSize"];
[archiver encodeString:[self frameAutosaveName]
withName:@"frameAutosaveName"];
[archiver encodeInt:[self level] withName:@"level"];
[archiver encodeBOOL:[self isVisible] withName:@"isVisible"];
[archiver encodeBOOL:[self isAutodisplay] withName:@"isAutodisplay"];
[archiver encodeString:[self title] withName:@"title"];
[archiver encodeString:[self representedFilename]
withName:@"representedFilename"];
[archiver encodeBOOL:[self isReleasedWhenClosed]
withName:@"isReleasedWhenClosed"];
[archiver encodeObject:[self contentView] withName:@"contentView"];
[archiver encodeBOOL:[self hidesOnDeactivate]
withName:@"hidesOnDeactivate"];
[archiver encodeObject:[self backgroundColor] withName:@"backgroundColor"];
style = [self styleMask];
#ifndef GNU_GUI_LIBRARY
/* Work around a bug in OpenStep, which doesn't set the
* NSTitledWindowMask properly. If the window is not borderless,
* always add the title mask. */
if (style != NSBorderlessWindowMask)
{
style |= NSTitledWindowMask;
}
#endif
[archiver encodeUnsignedInt: style withName: @"styleMask"];
[archiver encodeUnsignedInt: [self backingType] withName: @"backingType"];
[archiver encodeConditionalObject: [self initialFirstResponder]
withName: @"initialFirstResponder"];
}
+ (id)createObjectForModelUnarchiver:(GMUnarchiver*)unarchiver
{
unsigned backingType = [unarchiver decodeUnsignedIntWithName:@"backingType"];
unsigned styleMask = [unarchiver decodeUnsignedIntWithName:@"styleMask"];
NSRect ctRect = [unarchiver decodeRectWithName:@"contentFrame"];
NSWindow *win = [[self allocWithZone: [unarchiver objectZone]]
initWithContentRect: ctRect
styleMask: styleMask
backing: backingType
defer: YES];
// printf("content: %g, %g -- frame %g, %g\n", ctRect.size.width, ctRect.size.height, [win frame].size.width, [win frame].size.height);
return AUTORELEASE(win);
}
- (id)initWithModelUnarchiver:(GMUnarchiver*)unarchiver
{
NSString* frameAutosaveName;
[self setContentView:[unarchiver decodeObjectWithName:@"contentView"]];
[self setMaxSize:[unarchiver decodeSizeWithName:@"maxSize"]];
[self setMinSize:[unarchiver decodeSizeWithName:@"minSize"]];
frameAutosaveName = [unarchiver decodeStringWithName:@"frameAutosaveName"];
if (frameAutosaveName)
[self setFrameAutosaveName:frameAutosaveName];
#ifdef GNU_GUI_LIBRARY
_windowLevel = [unarchiver decodeIntWithName:@"level"];
#endif
[self setInitialFirstResponder:
[unarchiver decodeObjectWithName:@"initialFirstResponder"]];
[self setAutodisplay:[unarchiver decodeBOOLWithName:@"isAutodisplay"]];
[self setTitle:[unarchiver decodeStringWithName:@"title"]];
[self setRepresentedFilename:
[unarchiver decodeStringWithName:@"representedFilename"]];
[self setReleasedWhenClosed:
[unarchiver decodeBOOLWithName:@"isReleasedWhenClosed"]];
[self setHidesOnDeactivate:
[unarchiver decodeBOOLWithName:@"hidesOnDeactivate"]];
[self setBackgroundColor:
[unarchiver decodeObjectWithName:@"backgroundColor"]];
if ([unarchiver decodeBOOLWithName:@"isVisible"])
{
/* If we are the main gmodel of the application, this code is
being executed before the app became active, so we have to
force ordering front of the window. TODO: Refine the code so
that if we are not the main gmodel then a more appropriate
[self orderFront:nil] is used.*/
[self orderFrontRegardless];
}
#if GNU_GUI_LIBRARY
[[self contentView] setNeedsDisplay:YES];
#endif
return self;
}
@end /* NSWindow (GMArchiverMethods) */
@implementation NSPanel (GMArchiverMethods)
- (void)encodeWithModelArchiver:(GMArchiver*)archiver
{
[super encodeWithModelArchiver: archiver];
[archiver encodeBOOL:[self isFloatingPanel] withName:@"isFloatingPanel"];
[archiver encodeBOOL:[self becomesKeyOnlyIfNeeded]
withName:@"becomesKeyOnlyIfNeeded"];
[archiver encodeBOOL:[self worksWhenModal] withName:@"worksWhenModal"];
}
+ (id)createObjectForModelUnarchiver:(GMUnarchiver*)unarchiver
{
unsigned backingType = [unarchiver decodeUnsignedIntWithName:
@"backingType"];
unsigned styleMask = [unarchiver decodeUnsignedIntWithName:@"styleMask"];
NSRect ctRect = [unarchiver decodeRectWithName:@"contentFrame"];
NSPanel* panel = [[[[self class] allocWithZone:[unarchiver objectZone]]
initWithContentRect:ctRect
styleMask:styleMask backing:backingType defer:YES]
autorelease];
// use [self class] here, so it works for subclasses
return panel;
}
-(id)initWithModelUnarchiver :(GMUnarchiver *)unarchiver
{
[super initWithModelUnarchiver: unarchiver];
[self setFloatingPanel:
[unarchiver decodeBOOLWithName: @"isFloatingPanel"]];
[self setBecomesKeyOnlyIfNeeded:
[unarchiver decodeBOOLWithName: @"becomesKeyOnlyIfNeeded"]];
[self setWorksWhenModal:
[unarchiver decodeBOOLWithName: @"setWorksWhenModal"]];
return self;
}
@end /* NSPanel (GMArchiverMethods) */
@implementation NSSavePanel (GMArchiverMethods)
- (void)encodeWithModelArchiver:(GMArchiver*)archiver
{
[super encodeWithModelArchiver: archiver];
[archiver encodeString:[self prompt] withName:@"prompt"];
[archiver encodeObject:[self accessoryView] withName:@"accessoryView"];
[archiver encodeString:[self requiredFileType]
withName: @"requiredFileType"];
[archiver encodeBOOL:[self treatsFilePackagesAsDirectories]
withName: @"treatsFilePackagesAsDirectories"];
[archiver encodeString:[self directory]
withName: @"directory"];
}
+ (id)createObjectForModelUnarchiver:(GMUnarchiver*)unarchiver
{
unsigned backingType = [unarchiver decodeUnsignedIntWithName:
@"backingType"];
unsigned styleMask = [unarchiver decodeUnsignedIntWithName:@"styleMask"];
NSRect aRect = [unarchiver decodeRectWithName:@"frame"];
// Use [self class] here instead of NSSavePanel so as to invoke
// +allocWithZone on the correct (if any) sub-class
NSSavePanel* panel = [[[[self class] allocWithZone:[unarchiver objectZone]]
initWithContentRect:aRect
styleMask:styleMask backing:backingType defer:YES]
autorelease];
#if GNU_GUI_LIBRARY
NSDebugLLog(@"NSSavePanel", @"NSSavePanel +createObjectForModelUnarchiver");
#endif
return panel;
}
-(id)initWithModelUnarchiver :(GMUnarchiver *)unarchiver
{
[super initWithModelUnarchiver: unarchiver];
//NSSavePanel specifics
[self setPrompt:[unarchiver decodeStringWithName:@"prompt"]];
[self setAccessoryView:[unarchiver decodeObjectWithName:@"accessoryView"]];
[self setRequiredFileType:
[unarchiver decodeStringWithName:@"requiredFileType"]];
[self setTreatsFilePackagesAsDirectories:
[unarchiver decodeBOOLWithName:@"treatsFilePackagesAsDirectories"]];
[self setDirectory:
[unarchiver decodeStringWithName:@"directory"]];
#if GNU_GUI_LIBRARY
[[self contentView] setNeedsDisplay:YES];
#endif
return self;
}
@end /* NSSavePanel (GMArchiverMethods) */
@implementation NSOpenPanel (GMArchiverMethods)
- (void)encodeWithModelArchiver:(GMArchiver*)archiver
{
[super encodeWithModelArchiver:(GMArchiver*)archiver];
[archiver encodeBOOL:[self canChooseFiles]
withName:@"canChooseFiles"];
[archiver encodeBOOL:[self canChooseDirectories]
withName:@"canChooseDirectories"];
}
- (id)initWithModelUnarchiver:(GMUnarchiver *)unarchiver
{
[super initWithModelUnarchiver:(GMUnarchiver *)unarchiver];
[self setCanChooseFiles:[unarchiver decodeBOOLWithName:@"canChooseFiles"]];
[self setCanChooseDirectories:[unarchiver decodeBOOLWithName:
@"canChooseDirectories"]];
return self;
}
@end /* NSOpenPanel (GMArchiverMethods) */
@implementation NSBrowser (GMArchiverMethods)
- (void)encodeWithModelArchiver :(GMArchiver*)archiver
{
[super encodeWithModelArchiver:archiver];
//NSBrowser
[archiver encodeString:[self path] withName:@"path"];
[archiver encodeString:[self pathSeparator] withName:@"pathSeparator"];
[archiver encodeBOOL:[self allowsBranchSelection]
withName:@"allowsBranchSelection"];
[archiver encodeBOOL:[self allowsEmptySelection]
withName:@"allowsEmptySelection"];
[archiver encodeBOOL:[self allowsMultipleSelection]
withName:@"allowsMultipleSelection"];
[archiver encodeBOOL:[self reusesColumns] withName:@"reusesColumns"];
[archiver encodeUnsignedInt:[self maxVisibleColumns]
withName:@"maxVisibleColumns"];
[archiver encodeUnsignedInt:[self minColumnWidth]
withName:@"minColumnWidth"];
[archiver encodeBOOL:[self separatesColumns]
withName:@"separatesColumns"];
[archiver encodeBOOL:[self takesTitleFromPreviousColumn]
withName:@"takesTitleFromPreviousColumn"];
[archiver encodeBOOL:[self isTitled] withName:@"isTitled"];
[archiver encodeBOOL:[self hasHorizontalScroller]
withName:@"hasHorizontalScroller"];
[archiver encodeBOOL:[self acceptsArrowKeys]
withName:@"acceptsArrowKeys"];
[archiver encodeBOOL:[self sendsActionOnArrowKeys]
withName:@"sendsActionOnArrowKeys"];
[archiver encodeObject:[self delegate] withName:@"delegate"];
[archiver encodeSelector:[self doubleAction] withName:@"doubleAction"];
}
#if 0
+ (id)createObjectForModelUnarchiver:(GMUnarchiver*)unarchiver
{
unsigned backingType = [unarchiver decodeUnsignedIntWithName:
@"backingType"];
unsigned styleMask = [unarchiver decodeUnsignedIntWithName:@"styleMask"];
NSRect aRect = [unarchiver decodeRectWithName:@"frame"];
NSBrowser* browser = [[[NSBrowser allocWithZone:[unarchiver objectZone]]
initWithContentRect:aRect
styleMask:styleMask backing:backingType defer:YES]
autorelease];
return browser;
}
#endif
- (id)initWithModelUnarchiver :(GMUnarchiver *)unarchiver
{
id delegate;
self = [super initWithModelUnarchiver:unarchiver];
[self setPath:[unarchiver decodeStringWithName:@"path"]];
[self setPathSeparator:[unarchiver decodeStringWithName:@"pathSeparator"]];
[self setAllowsBranchSelection:[unarchiver
decodeBOOLWithName:@"allowsBranchSelection"]];
[self setAllowsEmptySelection:[unarchiver
decodeBOOLWithName:@"allowsEmptySelection"]];
[self setAllowsMultipleSelection:[unarchiver
decodeBOOLWithName:@"allowsMultipleSelection"]];
[self setReusesColumns:[unarchiver decodeBOOLWithName:@"reusesColumns"]];
[self setMaxVisibleColumns:[unarchiver
decodeUnsignedIntWithName:@"maxVisibleColumns"]];
[self setMinColumnWidth:[unarchiver
decodeUnsignedIntWithName:@"minColumnWidth"]];
[self setSeparatesColumns:[unarchiver
decodeBOOLWithName:@"separatesColumns"]];
[self setTakesTitleFromPreviousColumn:[unarchiver
decodeBOOLWithName:@"takesTitleFromPreviousColumn"]];
[self setTitled:[unarchiver
decodeBOOLWithName:@"isTitled"]];
[self setHasHorizontalScroller:[unarchiver
decodeBOOLWithName:@"hasHorizontalScroller"]];
[self setAcceptsArrowKeys:[unarchiver
decodeBOOLWithName:@"acceptsArrowKeys"]];
[self setSendsActionOnArrowKeys:[unarchiver
decodeBOOLWithName:@"sendsActionOnArrowKeys"]];
//avoid an exeption
delegate = [unarchiver decodeObjectWithName:@"delegate"];
if (delegate)
[self setDelegate:delegate];
[self setDoubleAction:[unarchiver decodeSelectorWithName:@"doubleAction"]];
return self;
}
@end /* NSBrowser (GMArchiverMethods) */
@implementation NSColorWell (GMArchiverMethods)
- (id)initWithModelUnarchiver:(GMUnarchiver*)unarchiver
{
self = [super initWithModelUnarchiver:unarchiver];
[self setColor:[unarchiver decodeObjectWithName:@"color"]];
[self setBordered:[unarchiver decodeBOOLWithName:@"isBordered"]];
return self;
}
- (void)encodeWithModelArchiver:(GMArchiver*)archiver
{
[super encodeWithModelArchiver:archiver];
[archiver encodeObject:[self color] withName:@"color"];
[archiver encodeBOOL:[self isBordered] withName:@"isBordered"];
}
@end /* NSColorWell (GMArchiverMethods) */
@implementation NSImageView (GMArchiverMethods)
- (void)encodeWithModelArchiver:(GMArchiver*)archiver
{
[super encodeWithModelArchiver:archiver];
[archiver encodeInt:[self imageAlignment] withName:@"alignment"];
[archiver encodeInt:[self imageFrameStyle] withName:@"frameStyle"];
[archiver encodeObject:[self image] withName:@"image"];
[archiver encodeBOOL:[self isEditable] withName:@"isEditable"];
[archiver encodeInt:[self imageScaling] withName:@"scaling"];
}
- (id)initWithModelUnarchiver:(GMUnarchiver*)unarchiver
{
self = [super initWithModelUnarchiver:unarchiver];
[self setImageAlignment:[unarchiver decodeIntWithName:@"alignment"]];
[self setImageFrameStyle:[unarchiver decodeIntWithName:@"frameStyle"]];
[self setImage:[unarchiver decodeObjectWithName:@"image"]];
[self setEditable:[unarchiver decodeBOOLWithName:@"isEditable"]];
[self setImageScaling:[unarchiver decodeIntWithName:@"scaling"]];
return self;
}
@end
@implementation NSSliderCell (GMArchiverMethods)
- (void)encodeWithModelArchiver:(GMArchiver*)archiver
{
[super encodeWithModelArchiver:archiver];
[archiver encodeFloat:[self knobThickness] withName:@"knobThickness"];
[archiver encodeObject:[self image] withName:@"image"];
[archiver encodeDouble:[self maxValue] withName:@"maxValue"];
[archiver encodeDouble:[self minValue] withName:@"minValue"];
// title, color, and font info is encoded by the title cell
[archiver encodeObject:[self titleCell] withName:@"titleCell"];
}
- (id)initWithModelUnarchiver:(GMUnarchiver*)unarchiver
{
[super initWithModelUnarchiver:unarchiver];
[self setKnobThickness:[unarchiver decodeFloatWithName:@"knobThickness"]];
[self setImage:[unarchiver decodeObjectWithName:@"image"]];
[self setMaxValue:[unarchiver decodeDoubleWithName:@"maxValue"]];
[self setMinValue:[unarchiver decodeDoubleWithName:@"minValue"]];
// title, color, and font info is encoded by the title cell
[self setTitleCell:[unarchiver decodeObjectWithName:@"titleCell"]];
return self;
}
@end /* NSSliderCell (GMArchiverMethods) */
@implementation NSTextFieldCell (GMArchiverMethods)
- (void)encodeWithModelArchiver:(GMArchiver*)archiver
{
[super encodeWithModelArchiver:archiver];
[archiver encodeObject:[self backgroundColor] withName:@"backgroundColor"];
[archiver encodeBOOL:[self drawsBackground] withName:@"drawsBackground"];
[archiver encodeObject:[self textColor] withName:@"textColor"];
}
- (id)initWithModelUnarchiver:(GMUnarchiver*)unarchiver
{
self = [super initWithModelUnarchiver:unarchiver];
[self setBackgroundColor:
[unarchiver decodeObjectWithName:@"backgroundColor"]];
[self setDrawsBackground:
[unarchiver decodeBOOLWithName:@"drawsBackground"]];
[self setTextColor:[unarchiver decodeObjectWithName:@"textColor"]];
return self;
}
@end /* NSTextFieldCell (GMArchiverMethods) */
@implementation NSFormCell (GMArchiverMethods)
- (void)encodeWithModelArchiver:(GMArchiver*)archiver
{
[super encodeWithModelArchiver:archiver];
[archiver encodeString:[self title] withName:@"title"];
}
- (id)initWithModelUnarchiver:(GMUnarchiver*)unarchiver
{
self = [super initWithModelUnarchiver:unarchiver];
[self setTitle:[unarchiver decodeStringWithName:@"title"]];
return self;
}
@end /* NSFormCell (GMArchiverMethods) */
@implementation NSText (GMArchiverMethods)
- (void)encodeWithModelArchiver:(GMArchiver*)archiver
{
[super encodeWithModelArchiver:archiver];
[archiver encodeString: [self string] withName: @"string"];
[archiver encodeConditionalObject: [self backgroundColor]
withName: @"backgroundColor"];
[archiver encodeBOOL:[self drawsBackground] withName:@"drawsBackground"];
[archiver encodeObject:[self textColor] withName:@"textColor"];
[archiver encodeBOOL:[self isEditable] withName:@"isEditable"];
[archiver encodeBOOL:[self isSelectable] withName:@"isSelectable"];
[archiver encodeBOOL:[self isFieldEditor] withName:@"isFieldEditor"];
[archiver encodeBOOL:[self isRichText] withName:@"isRichText"];
[archiver encodeBOOL:[self importsGraphics] withName:@"importsGraphics"];
[archiver encodeBOOL:[self usesFontPanel] withName:@"usesFontPanel"];
[archiver encodeObject:[self font] withName:@"font"];
[archiver encodeInt:[self alignment] withName:@"alignment"];
[archiver encodeSize:[self maxSize] withName:@"maxSize"];
[archiver encodeSize:[self minSize] withName:@"minSize"];
[archiver encodeBOOL:[self isVerticallyResizable] withName:@"isVerticallyResizable"];
[archiver encodeBOOL:[self isHorizontallyResizable] withName:@"isHorizontallyResizable"];
[archiver encodeConditionalObject: [self delegate] withName: @"delegate"];
}
- (id)initWithModelUnarchiver:(GMUnarchiver*)unarchiver
{
self = [super initWithModelUnarchiver: unarchiver];
[self setString: [unarchiver decodeStringWithName: @"string"]];
[self setBackgroundColor:
[unarchiver decodeObjectWithName:@"backgroundColor"]];
[self setDrawsBackground:
[unarchiver decodeBOOLWithName:@"drawsBackground"]];
[self setTextColor:[unarchiver decodeObjectWithName:@"textColor"]];
[self setEditable:[unarchiver decodeBOOLWithName:@"isEditable"]];
[self setSelectable:[unarchiver decodeBOOLWithName:@"isSelectable"]];
[self setFieldEditor:[unarchiver decodeBOOLWithName:@"isFieldEditor"]];
[self setRichText:[unarchiver decodeBOOLWithName:@"isRichText"]];
[self setImportsGraphics:[unarchiver decodeBOOLWithName:@"importsGraphics"]];
[self setUsesFontPanel:[unarchiver decodeBOOLWithName:@"usesFontPanel"]];
[self setFont:[unarchiver decodeObjectWithName:@"font"]];
[self setAlignment:[unarchiver decodeIntWithName:@"alignment"]];
[self setMaxSize:[unarchiver decodeSizeWithName:@"maxSize"]];
[self setMinSize:[unarchiver decodeSizeWithName:@"minSize"]];
[self setVerticallyResizable:
[unarchiver decodeBOOLWithName:@"isVerticallyResizable"]];
[self setHorizontallyResizable:
[unarchiver decodeBOOLWithName:@"isHorizontallyResizable"]];
[self setDelegate: [unarchiver decodeObjectWithName: @"delegate"]];
return self;
}
@end /* NSText (GMArchiverMethods) */
@implementation NSTextView (GMArchiverMethods)
- (void)encodeWithModelArchiver:(GMArchiver*)archiver
{
[super encodeWithModelArchiver:archiver];
// Currently the text container is not encoded
[archiver encodeSize:[self textContainerInset] withName:@"textContainerInset"];
if ([self respondsToSelector: @selector(allowsUndo)])
[archiver encodeBOOL:[self allowsUndo] withName:@"allowsUndo"];
[archiver encodeBOOL:[self usesRuler] withName:@"usesRuler"];
[archiver encodeBOOL:[self isRulerVisible] withName:@"isRulerVisible"];
[archiver encodeObject:[self insertionPointColor] withName:@"insertionPointColor"];
}
- (id)initWithModelUnarchiver:(GMUnarchiver*)unarchiver
{
self = [super initWithModelUnarchiver: unarchiver];
// Currently the text container is not encoded
[self setTextContainerInset:[unarchiver decodeSizeWithName:@"textContainerInset"]];
[self setAllowsUndo:[unarchiver decodeBOOLWithName:@"allowsUndo"]];
[self setUsesRuler:[unarchiver decodeBOOLWithName:@"usesRuler"]];
[self setRulerVisible:[unarchiver decodeBOOLWithName:@"isRulerVisible"]];
[self setInsertionPointColor:
[unarchiver decodeObjectWithName:@"insertionPointColor"]];
return self;
}
@end /* NSTextView (GMArchiverMethods) */
|