Menu

[r193]: / trunk / src / MainDlg.cpp  Maximize  Restore  History

Download this file

1662 lines (1535 with data), 53.6 kB

   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
// CommitMonitor - simple checker for new commits in svn repositories
// Copyright (C) 2007 - Stefan Kueng
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software Foundation,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
#include "StdAfx.h"
#include "Resource.h"
#include "MainDlg.h"
#include "URLDlg.h"
#include "OptionsDlg.h"
#include "AboutDlg.h"
#include "AppUtils.h"
#include "DirFileEnum.h"
#include <algorithm>
#include <assert.h>
CMainDlg::CMainDlg(HWND hParent)
: m_nDragMode(DRAGMODE_NONE)
, m_oldx(-1)
, m_oldy(-1)
, m_boldFont(NULL)
, m_pURLInfos(NULL)
, m_bBlockListCtrlUI(false)
, m_hTreeControl(NULL)
, m_hListControl(NULL)
, m_hLogMsgControl(NULL)
, m_hToolbarImages(NULL)
, m_hImgList(NULL)
{
m_hParent = hParent;
// use the default GUI font, create a copy of it and
// change the copy to BOLD (leave the rest of the font
// the same)
HFONT hFont = (HFONT)GetStockObject(DEFAULT_GUI_FONT);
LOGFONT lf = {0};
GetObject(hFont, sizeof(LOGFONT), &lf);
lf.lfWeight = FW_BOLD;
m_boldFont = CreateFontIndirect(&lf);
}
CMainDlg::~CMainDlg(void)
{
if (m_boldFont)
DeleteObject(m_boldFont);
if (m_hToolbarImages)
ImageList_Destroy(m_hToolbarImages);
if (m_hImgList)
ImageList_Destroy(m_hImgList);
}
bool CMainDlg::CreateToolbar()
{
m_hwndToolbar = CreateWindowEx(0,
TOOLBARCLASSNAME,
(LPCTSTR)NULL,
WS_CHILD | WS_BORDER | WS_VISIBLE | TBSTYLE_FLAT | TBSTYLE_TOOLTIPS,
0, 0, 0, 0,
*this,
(HMENU)IDR_MAINDLG,
hResource,
NULL);
if (m_hwndToolbar == INVALID_HANDLE_VALUE)
return false;
SendMessage(m_hwndToolbar, TB_BUTTONSTRUCTSIZE, (WPARAM) sizeof(TBBUTTON), 0);
#define MAINDLG_TOOLBARBUTTONCOUNT 10
TBBUTTON tbb[MAINDLG_TOOLBARBUTTONCOUNT];
// create an image list containing the icons for the toolbar
m_hToolbarImages = ImageList_Create(24, 24, ILC_COLOR32 | ILC_MASK, MAINDLG_TOOLBARBUTTONCOUNT, 4);
if (m_hToolbarImages == NULL)
return false;
int index = 0;
HICON hIcon = LoadIcon(hResource, MAKEINTRESOURCE(IDI_GETALL));
tbb[index].iBitmap = ImageList_AddIcon(m_hToolbarImages, hIcon);
tbb[index].idCommand = ID_MAIN_CHECKREPOSITORIESNOW;
tbb[index].fsState = TBSTATE_ENABLED|BTNS_SHOWTEXT;
tbb[index].fsStyle = BTNS_BUTTON;
tbb[index].dwData = 0;
tbb[index++].iString = (INT_PTR)_T("Check Now");
hIcon = LoadIcon(hResource, MAKEINTRESOURCE(IDI_ADD));
tbb[index].iBitmap = ImageList_AddIcon(m_hToolbarImages, hIcon);
tbb[index].idCommand = ID_MAIN_ADDPROJECT;
tbb[index].fsState = TBSTATE_ENABLED|BTNS_SHOWTEXT;
tbb[index].fsStyle = BTNS_BUTTON;
tbb[index].dwData = 0;
tbb[index++].iString = (INT_PTR)_T("Add Project");
tbb[index].iBitmap = 0;
tbb[index].idCommand = 0;
tbb[index].fsState = TBSTATE_ENABLED;
tbb[index].fsStyle = BTNS_SEP;
tbb[index].dwData = 0;
tbb[index++].iString = 0;
hIcon = LoadIcon(hResource, MAKEINTRESOURCE(IDI_EDIT));
tbb[index].iBitmap = ImageList_AddIcon(m_hToolbarImages, hIcon);
tbb[index].idCommand = ID_MAIN_EDIT;
tbb[index].fsState = BTNS_SHOWTEXT;
tbb[index].fsStyle = BTNS_BUTTON;
tbb[index].dwData = 0;
tbb[index++].iString = (INT_PTR)_T("Edit");
hIcon = LoadIcon(hResource, MAKEINTRESOURCE(IDI_REMOVE));
tbb[index].iBitmap = ImageList_AddIcon(m_hToolbarImages, hIcon);
tbb[index].idCommand = ID_MAIN_REMOVE;
tbb[index].fsState = BTNS_SHOWTEXT;
tbb[index].fsStyle = BTNS_BUTTON;
tbb[index].dwData = 0;
tbb[index++].iString = (INT_PTR)_T("Remove");
tbb[index].iBitmap = 0;
tbb[index].idCommand = 0;
tbb[index].fsState = TBSTATE_ENABLED;
tbb[index].fsStyle = BTNS_SEP;
tbb[index].dwData = 0;
tbb[index++].iString = 0;
hIcon = LoadIcon(hResource, MAKEINTRESOURCE(IDI_DIFF));
tbb[index].iBitmap = ImageList_AddIcon(m_hToolbarImages, hIcon);
tbb[index].idCommand = ID_MAIN_SHOWDIFF;
tbb[index].fsState = BTNS_SHOWTEXT;
tbb[index].fsStyle = BTNS_BUTTON;
tbb[index].dwData = 0;
tbb[index++].iString = (INT_PTR)_T("Show Diff");
tbb[index].iBitmap = 0;
tbb[index].idCommand = 0;
tbb[index].fsState = TBSTATE_ENABLED;
tbb[index].fsStyle = BTNS_SEP;
tbb[index].dwData = 0;
tbb[index++].iString = 0;
hIcon = LoadIcon(hResource, MAKEINTRESOURCE(IDI_OPTIONS));
tbb[index].iBitmap = ImageList_AddIcon(m_hToolbarImages, hIcon);
tbb[index].idCommand = ID_MISC_OPTIONS;
tbb[index].fsState = TBSTATE_ENABLED|BTNS_SHOWTEXT;
tbb[index].fsStyle = BTNS_BUTTON;
tbb[index].dwData = 0;
tbb[index++].iString = (INT_PTR)_T("Options");
hIcon = LoadIcon(hResource, MAKEINTRESOURCE(IDI_ABOUT));
tbb[index].iBitmap = ImageList_AddIcon(m_hToolbarImages, hIcon);
tbb[index].idCommand = ID_MISC_ABOUT;
tbb[index].fsState = TBSTATE_ENABLED|BTNS_SHOWTEXT;
tbb[index].fsStyle = BTNS_BUTTON;
tbb[index].dwData = 0;
tbb[index++].iString = (INT_PTR)_T("About");
SendMessage(m_hwndToolbar, TB_SETIMAGELIST, 0, (LPARAM)m_hToolbarImages);
SendMessage(m_hwndToolbar, TB_ADDBUTTONS, (WPARAM)index, (LPARAM) (LPTBBUTTON) &tbb);
SendMessage(m_hwndToolbar, TB_AUTOSIZE, 0, 0);
ShowWindow(m_hwndToolbar, SW_SHOW);
return true;
}
LRESULT CMainDlg::DlgFunc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_INITDIALOG:
{
InitDialog(hwndDlg, IDI_COMMITMONITOR);
CreateToolbar();
m_hTreeControl = ::GetDlgItem(*this, IDC_URLTREE);
m_hListControl = ::GetDlgItem(*this, IDC_MONITOREDURLS);
m_hLogMsgControl = ::GetDlgItem(*this, IDC_LOGINFO);
::SendMessage(m_hTreeControl, TVM_SETUNICODEFORMAT, 1, 0);
assert(m_pURLInfos);
m_hImgList = ImageList_Create(16, 16, ILC_COLOR32, 4, 4);
if (m_hImgList)
{
HICON hIcon = LoadIcon(hResource, MAKEINTRESOURCE(IDI_PARENTPATHFOLDER));
ImageList_AddIcon(m_hImgList, hIcon);
DestroyIcon(hIcon);
hIcon = LoadIcon(hResource, MAKEINTRESOURCE(IDI_PARENTPATHFOLDEROPEN));
ImageList_AddIcon(m_hImgList, hIcon);
DestroyIcon(hIcon);
hIcon = LoadIcon(hResource, MAKEINTRESOURCE(IDI_REPOURL));
ImageList_AddIcon(m_hImgList, hIcon);
DestroyIcon(hIcon);
hIcon = LoadIcon(hResource, MAKEINTRESOURCE(IDI_REPOURLNEW));
ImageList_AddIcon(m_hImgList, hIcon);
DestroyIcon(hIcon);
TreeView_SetImageList(m_hTreeControl, m_hImgList, LVSIL_SMALL);
TreeView_SetImageList(m_hTreeControl, m_hImgList, LVSIL_NORMAL);
}
RefreshURLTree();
// initialize the window position infos
RECT rect;
GetClientRect(m_hwndToolbar, &rect);
m_topmarg = rect.bottom+2;
GetClientRect(m_hTreeControl, &rect);
m_xSliderPos = rect.right+4;
GetClientRect(m_hListControl, &rect);
m_ySliderPos = rect.bottom+m_topmarg;
GetClientRect(m_hLogMsgControl, &rect);
m_bottommarg = rect.bottom+4+m_ySliderPos;
GetClientRect(*this, &rect);
m_bottommarg = rect.bottom - m_bottommarg;
// subclass the tree view control to intercept the WM_SETFOCUS messages
m_oldTreeWndProc = (WNDPROC)SetWindowLongPtr(m_hTreeControl, GWLP_WNDPROC, (LONG)TreeProc);
SetWindowLongPtr(m_hTreeControl, GWLP_USERDATA, (LONG)this);
::SetTimer(*this, TIMER_REFRESH, 1000, NULL);
SendMessage(m_hParent, COMMITMONITOR_SETWINDOWHANDLE, (WPARAM)(HWND)*this, NULL);
CRegStdWORD regSize(_T("Software\\CommitMonitor\\size"));
if (DWORD(regSize) != 0)
{
SetWindowPos(hwndDlg, HWND_TOP, 0, 0, LOWORD(DWORD(regSize)), HIWORD(DWORD(regSize)), SWP_NOMOVE);
}
}
break;
case WM_SIZE:
{
if (wParam == SIZE_MINIMIZED)
{
EndDialog(*this, IDCANCEL);
return 0;
}
DoResize(LOWORD(lParam), HIWORD(lParam));
}
break;
case WM_GETMINMAXINFO:
{
MINMAXINFO * mmi = (MINMAXINFO*)lParam;
mmi->ptMinTrackSize.x = m_xSliderPos + 100;
mmi->ptMinTrackSize.y = m_ySliderPos + 100;
return 0;
}
break;
case WM_COMMAND:
return DoCommand(LOWORD(wParam));
break;
case WM_SETCURSOR:
{
return OnSetCursor((HWND)wParam, LOWORD(lParam), HIWORD(lParam));
}
break;
case WM_MOUSEMOVE:
{
POINT pt = {LOWORD(lParam), HIWORD(lParam)};
return OnMouseMove(wParam, pt);
}
break;
case WM_LBUTTONDOWN:
{
POINT pt = {LOWORD(lParam), HIWORD(lParam)};
return OnLButtonDown(wParam, pt);
}
break;
case WM_LBUTTONUP:
{
POINT pt = {LOWORD(lParam), HIWORD(lParam)};
return OnLButtonUp(wParam, pt);
}
break;
case WM_TIMER:
{
if (wParam == TIMER_LABEL)
{
SetWindowText(GetDlgItem(*this, IDC_INFOLABEL), _T(""));
KillTimer(*this, TIMER_LABEL);
}
else if (wParam == TIMER_REFRESH)
{
const map<wstring, CUrlInfo> * pRead = m_pURLInfos->GetReadOnlyData();
for (map<wstring, CUrlInfo>::const_iterator it = pRead->begin(); it != pRead->end(); ++it)
{
TVINSERTSTRUCT tv = {0};
tv.hParent = FindParentTreeNode(it->first);
tv.hInsertAfter = TVI_SORT;
tv.itemex.mask = TVIF_TEXT|TVIF_PARAM|TVIF_STATE|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
WCHAR * str = new WCHAR[it->second.name.size()+10];
// find out if there are some unread entries
int unread = 0;
for (map<svn_revnum_t,SVNLogEntry>::const_iterator logit = it->second.logentries.begin(); logit != it->second.logentries.end(); ++logit)
{
if (!logit->second.read)
unread++;
}
tv.itemex.pszText = str;
tv.itemex.lParam = (LPARAM)&it->first;
HTREEITEM directItem = FindTreeNode(it->first);
if (directItem != TVI_ROOT)
{
// The node already exists, just update the information
tv.itemex.hItem = directItem;
tv.itemex.stateMask = TVIS_SELECTED|TVIS_BOLD|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
tv.itemex.pszText = str;
tv.itemex.cchTextMax = it->second.name.size()+9;
TreeView_GetItem(m_hTreeControl, &tv.itemex);
wstring sTitle = wstring(str);
if (unread)
{
_stprintf_s(str, it->second.name.size()+10, _T("%s (%d)"), it->second.name.c_str(), unread);
tv.itemex.state |= TVIS_BOLD;
tv.itemex.stateMask = TVIS_BOLD;
}
else
{
_tcscpy_s(str, it->second.name.size()+1, it->second.name.c_str());
tv.itemex.state &= ~TVIS_BOLD;
tv.itemex.stateMask = TVIS_BOLD;
}
if (it->second.parentpath)
{
tv.itemex.iImage = 0;
tv.itemex.iSelectedImage = 1;
}
else
{
if (unread)
{
tv.itemex.iImage = 3;
tv.itemex.iSelectedImage = 3;
}
else
{
tv.itemex.iImage = 2;
tv.itemex.iSelectedImage = 2;
}
}
if (sTitle.compare(str) != 0)
{
TreeView_SetItem(m_hTreeControl, &tv.itemex);
if (tv.itemex.state & TVIS_SELECTED)
{
m_bBlockListCtrlUI = true;
TreeItemSelected(m_hTreeControl, tv.itemex.hItem);
m_bBlockListCtrlUI = false;
}
}
}
else
{
if (unread)
{
_stprintf_s(str, it->second.name.size()+10, _T("%s (%d)"), it->second.name.c_str(), unread);
tv.itemex.state = TVIS_BOLD;
tv.itemex.stateMask = TVIS_BOLD;
}
else
{
_tcscpy_s(str, it->second.name.size()+1, it->second.name.c_str());
tv.itemex.state = 0;
tv.itemex.stateMask = TVIS_BOLD;
}
m_bBlockListCtrlUI = true;
if (it->second.parentpath)
{
tv.itemex.iImage = 0;
tv.itemex.iSelectedImage = 1;
}
else
{
if (unread)
{
tv.itemex.iImage = 3;
tv.itemex.iSelectedImage = 3;
}
else
{
tv.itemex.iImage = 2;
tv.itemex.iSelectedImage = 2;
}
}
TreeView_InsertItem(m_hTreeControl, &tv);
TreeView_Expand(m_hTreeControl, tv.hParent, TVE_EXPAND);
m_bBlockListCtrlUI = false;
}
delete [] str;
}
m_pURLInfos->ReleaseReadOnlyData();
::InvalidateRect(m_hListControl, NULL, true);
}
}
break;
case WM_NOTIFY:
{
LPNMHDR lpnmhdr = (LPNMHDR)lParam;
if ((lpnmhdr->code == TVN_SELCHANGED)&&(lpnmhdr->hwndFrom == m_hTreeControl))
{
OnSelectTreeItem((LPNMTREEVIEW)lParam);
return TRUE;
}
if ((lpnmhdr->code == LVN_ITEMCHANGED)&&(lpnmhdr->hwndFrom == m_hListControl))
{
OnSelectListItem((LPNMLISTVIEW)lParam);
}
if ((lpnmhdr->code == LVN_KEYDOWN)&&(lpnmhdr->hwndFrom == m_hListControl))
{
OnKeyDownListItem((LPNMLVKEYDOWN)lParam);
}
if ((lpnmhdr->code == NM_CUSTOMDRAW)&&(lpnmhdr->hwndFrom == m_hListControl))
{
return OnCustomDrawListItem((LPNMLVCUSTOMDRAW)lParam);
}
if ((lpnmhdr->code == NM_DBLCLK)&&(lpnmhdr->hwndFrom == m_hListControl))
{
OnDblClickListItem((LPNMITEMACTIVATE)lParam);
}
return FALSE;
}
break;
case WM_CONTEXTMENU:
{
POINT pt;
pt.x = GET_X_LPARAM(lParam);
pt.y = GET_Y_LPARAM(lParam);
if (HWND(wParam) == m_hTreeControl)
{
TVHITTESTINFO hittest = {0};
if (pt.x == -1 && pt.y == -1)
{
hittest.hItem = TreeView_GetSelection(m_hTreeControl);
if (hittest.hItem)
{
hittest.flags = TVHT_ONITEM;
RECT rect;
TreeView_GetItemRect(m_hTreeControl, hittest.hItem, &rect, TRUE);
pt.x = rect.left + ((rect.right-rect.left)/2);
pt.y = rect.top + ((rect.bottom - rect.top)/2);
ClientToScreen(m_hTreeControl, &pt);
}
}
else
{
POINT clPt = pt;
::ScreenToClient(m_hTreeControl, &clPt);
hittest.pt = clPt;
TreeView_HitTest(m_hTreeControl, &hittest);
}
if (hittest.flags & TVHT_ONITEM)
{
HMENU hMenu = ::LoadMenu(hResource, MAKEINTRESOURCE(IDR_TREEPOPUP));
hMenu = ::GetSubMenu(hMenu, 0);
int cmd = ::TrackPopupMenu(hMenu, TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY , pt.x, pt.y, NULL, *this, NULL);
switch (cmd)
{
case ID_MAIN_EDIT:
case ID_MAIN_REMOVE:
{
HTREEITEM hSel = TreeView_GetSelection(m_hTreeControl);
m_bBlockListCtrlUI = true;
TreeView_SelectItem(m_hTreeControl, hittest.hItem);
m_bBlockListCtrlUI = false;
::SendMessage(*this, WM_COMMAND, MAKELONG(cmd, 0), 0);
m_bBlockListCtrlUI = true;
TreeView_SelectItem(m_hTreeControl, hSel);
m_bBlockListCtrlUI = false;
}
break;
case ID_POPUP_MARKALLASREAD:
{
// get the url this entry refers to
TVITEMEX itemex = {0};
itemex.hItem = hittest.hItem;
itemex.mask = TVIF_PARAM;
TreeView_GetItem(m_hTreeControl, &itemex);
map<wstring,CUrlInfo> * pWrite = m_pURLInfos->GetWriteData();
bool bChanged = false;
if (pWrite->find(*(wstring*)itemex.lParam) != pWrite->end())
{
CUrlInfo * info = &pWrite->find(*(wstring*)itemex.lParam)->second;
for (map<svn_revnum_t,SVNLogEntry>::iterator it = info->logentries.begin(); it != info->logentries.end(); ++it)
{
if (!it->second.read)
bChanged = true;
it->second.read = true;
}
// refresh the name of the tree item to indicate the new
// number of unread log messages
WCHAR * str = new WCHAR[info->name.size()+10];
_stprintf_s(str, info->name.size()+10, _T("%s"), info->name.c_str());
itemex.state = 0;
itemex.stateMask = TVIS_BOLD;
itemex.pszText = str;
if (info->parentpath)
{
itemex.iImage = 0;
itemex.iSelectedImage = 1;
}
else
{
itemex.iImage = 2;
itemex.iSelectedImage = 2;
}
itemex.mask = TVIF_TEXT|TVIF_STATE|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
TreeView_SetItem(m_hTreeControl, &itemex);
delete [] str;
}
m_pURLInfos->ReleaseWriteData();
if (bChanged)
::SendMessage(m_hParent, COMMITMONITOR_CHANGEDINFO, (WPARAM)false, (LPARAM)0);
}
break;
}
}
}
else if (HWND(wParam) == m_hListControl)
{
LVHITTESTINFO hittest = {0};
if (pt.x == -1 && pt.y == -1)
{
hittest.iItem = ListView_GetSelectionMark(m_hListControl);
if (hittest.iItem >= 0)
{
hittest.flags = LVHT_ONITEM;
RECT rect;
ListView_GetItemRect(m_hListControl, hittest.iItem, &rect, LVIR_LABEL);
pt.x = rect.left + ((rect.right-rect.left)/2);
pt.y = rect.top + ((rect.bottom - rect.top)/2);
ClientToScreen(m_hListControl, &pt);
}
}
else
{
POINT clPt = pt;
::ScreenToClient(m_hListControl, &clPt);
hittest.pt = clPt;
ListView_HitTest(m_hListControl, &hittest);
}
if (hittest.flags & LVHT_ONITEM)
{
HMENU hMenu = ::LoadMenu(hResource, MAKEINTRESOURCE(IDR_LISTPOPUP));
hMenu = ::GetSubMenu(hMenu, 0);
// set the default entry
MENUITEMINFO iinfo = {0};
iinfo.cbSize = sizeof(MENUITEMINFO);
iinfo.fMask = MIIM_STATE;
GetMenuItemInfo(hMenu, 0, MF_BYPOSITION, &iinfo);
iinfo.fState |= MFS_DEFAULT;
SetMenuItemInfo(hMenu, 0, MF_BYPOSITION, &iinfo);
int cmd = ::TrackPopupMenu(hMenu, TPM_RETURNCMD | TPM_LEFTALIGN | TPM_NONOTIFY , pt.x, pt.y, NULL, *this, NULL);
switch (cmd)
{
case ID_MAIN_SHOWDIFF:
case ID_MAIN_REMOVE:
{
::SendMessage(*this, WM_COMMAND, MAKELONG(cmd, 0), 0);
}
}
}
}
}
break;
case COMMITMONITOR_INFOTEXT:
{
if (lParam)
{
SetWindowText(GetDlgItem(*this, IDC_INFOLABEL), (LPCTSTR)lParam);
}
}
break;
default:
return FALSE;
}
return TRUE;
}
LRESULT CMainDlg::DoCommand(int id)
{
switch (id)
{
case IDCANCEL:
case IDOK:
{
CRegStdWORD regSize(_T("Software\\CommitMonitor\\size"));
RECT rc;
::GetWindowRect(*this, &rc);
regSize = MAKELONG(rc.right-rc.left, rc.bottom-rc.top);
EndDialog(*this, IDCANCEL);
}
break;
case IDC_EXIT:
{
int res = ::MessageBox(*this, _T("Do you really want to quit the CommitMonitor?\nIf you quit, monitoring will stop.\nIf you just want to close the dialog, use the \"Hide\" button.\n\nAre you sure you want to quit the CommitMonitor?"),
_T("CommitMonitor"), MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2);
if (res != IDYES)
break;
EndDialog(*this, IDCANCEL);
PostQuitMessage(IDOK);
}
break;
case ID_MAIN_REMOVE:
{
// which control has the focus?
HWND hFocus = ::GetFocus();
if (hFocus == m_hTreeControl)
{
HTREEITEM hItem = TreeView_GetSelection(m_hTreeControl);
if (hItem)
{
TVITEMEX itemex = {0};
itemex.hItem = hItem;
itemex.mask = TVIF_PARAM;
TreeView_GetItem(m_hTreeControl, &itemex);
map<wstring,CUrlInfo> * pWrite = m_pURLInfos->GetWriteData();
HTREEITEM hPrev = TVI_ROOT;
map<wstring,CUrlInfo>::iterator it = pWrite->find(*(wstring*)itemex.lParam);
if (it != pWrite->end())
{
wstring mask = it->second.name;
// ask the user if he really wants to remove the url
TCHAR question[4096] = {0};
_stprintf_s(question, 4096, _T("Do you really want to delete the project\n%s ?"), mask.c_str());
if (::MessageBox(*this, question, _T("CommitMonitor"), MB_ICONQUESTION|MB_YESNO)==IDYES)
{
// delete all fetched and stored diff files
mask += _T("*.*");
CSimpleFileFind sff(CAppUtils::GetAppDataDir(), mask.c_str());
while (sff.FindNextFileNoDots())
{
DeleteFile(sff.GetFilePath().c_str());
}
int unread = 0;
for (map<svn_revnum_t,SVNLogEntry>::const_iterator logit = it->second.logentries.begin(); logit != it->second.logentries.end(); ++logit)
{
if (!logit->second.read)
unread++;
}
pWrite->erase(it);
if (unread)
::SendMessage(m_hParent, COMMITMONITOR_CHANGEDINFO, (WPARAM)false, (LPARAM)0);
::SendMessage(m_hParent, COMMITMONITOR_REMOVEDURL, 0, 0);
hPrev = TreeView_GetPrevSibling(m_hTreeControl, hItem);
m_pURLInfos->ReleaseWriteData();
TreeView_DeleteItem(m_hTreeControl, hItem);
if (hPrev == NULL)
hPrev = TreeView_GetRoot(m_hTreeControl);
if ((hPrev)&&(hPrev != TVI_ROOT))
TreeView_SelectItem(m_hTreeControl, hPrev);
}
else
m_pURLInfos->ReleaseWriteData();
}
else
m_pURLInfos->ReleaseWriteData();
}
}
else if (hFocus == m_hListControl)
{
RemoveSelectedListItems();
}
}
break;
case ID_MAIN_EDIT:
{
CURLDlg dlg;
HTREEITEM hItem = TreeView_GetSelection(m_hTreeControl);
if (hItem)
{
TVITEMEX itemex = {0};
itemex.hItem = hItem;
itemex.mask = TVIF_PARAM;
TreeView_GetItem(m_hTreeControl, &itemex);
const map<wstring,CUrlInfo> * pRead = m_pURLInfos->GetReadOnlyData();
if (pRead->find(*(wstring*)itemex.lParam) != pRead->end())
{
dlg.SetInfo(&pRead->find(*(wstring*)itemex.lParam)->second);
m_pURLInfos->ReleaseReadOnlyData();
dlg.DoModal(hResource, IDD_URLCONFIG, *this);
CUrlInfo * inf = dlg.GetInfo();
map<wstring,CUrlInfo> * pWrite = m_pURLInfos->GetWriteData();
if ((inf)&&inf->url.size())
{
pWrite->erase(*(wstring*)itemex.lParam);
(*pWrite)[inf->url] = *inf;
}
m_pURLInfos->ReleaseWriteData();
RefreshURLTree();
m_pURLInfos->Save();
}
else
m_pURLInfos->ReleaseWriteData();
}
}
break;
case ID_MAIN_CHECKREPOSITORIESNOW:
SendMessage(m_hParent, COMMITMONITOR_GETALL, 0, 0);
break;
case ID_MAIN_ADDPROJECT:
{
CURLDlg dlg;
dlg.DoModal(hResource, IDD_URLCONFIG, *this);
CUrlInfo * inf = dlg.GetInfo();
if ((inf)&&inf->url.size())
{
map<wstring,CUrlInfo> * pWrite = m_pURLInfos->GetWriteData();
if ((inf)&&inf->url.size())
{
(*pWrite)[inf->url] = *inf;
}
m_pURLInfos->ReleaseWriteData();
m_pURLInfos->Save();
}
RefreshURLTree();
}
break;
case ID_MAIN_SHOWDIFF:
{
ShowDiff();
}
break;
case ID_MISC_OPTIONS:
{
COptionsDlg dlg(*this);
dlg.SetHiddenWnd(m_hParent);
dlg.DoModal(hResource, IDD_OPTIONS, *this);
}
break;
case ID_MISC_ABOUT:
{
CAboutDlg dlg(*this);
dlg.SetHiddenWnd(m_hParent);
dlg.DoModal(hResource, IDD_ABOUTBOX, *this);
}
break;
default:
return 0;
}
return 1;
}
void CMainDlg::SetRemoveButtonState()
{
HWND hFocus = ::GetFocus();
if (hFocus == m_hListControl)
{
SendMessage(m_hwndToolbar, TB_ENABLEBUTTON, ID_MAIN_REMOVE, MAKELONG(ListView_GetSelectedCount(m_hListControl) > 0, 0));
}
else
{
SendMessage(m_hwndToolbar, TB_ENABLEBUTTON, ID_MAIN_REMOVE, MAKELONG(TreeView_GetSelection(m_hTreeControl)!=0, 0));
}
}
bool CMainDlg::ShowDiff()
{
TCHAR buf[4096];
// find the revision we have to show the diff for
int selCount = ListView_GetSelectedCount(m_hListControl);
if (selCount <= 0)
return FALSE; //nothing selected, nothing to show
HTREEITEM hSelectedItem = TreeView_GetSelection(m_hTreeControl);
// get the url this entry refers to
TVITEMEX itemex = {0};
itemex.hItem = hSelectedItem;
itemex.mask = TVIF_PARAM;
TreeView_GetItem(m_hTreeControl, &itemex);
const map<wstring,CUrlInfo> * pRead = m_pURLInfos->GetReadOnlyData();
if (pRead->find(*(wstring*)itemex.lParam) != pRead->end())
{
LVITEM item = {0};
for (int i=0; i<ListView_GetItemCount(m_hListControl); ++i)
{
item.mask = LVIF_PARAM|LVIF_STATE;
item.stateMask = LVIS_SELECTED;
item.iItem = i;
ListView_GetItem(m_hListControl, &item);
if (item.state & LVIS_SELECTED)
{
SVNLogEntry * pLogEntry = (SVNLogEntry*)item.lParam;
// find the diff name
const CUrlInfo * pInfo = &pRead->find(*(wstring*)itemex.lParam)->second;
_stprintf_s(buf, 4096, _T("%s_%ld"), pInfo->name.c_str(), pLogEntry->revision);
wstring diffFileName = CAppUtils::GetAppDataDir();
diffFileName += _T("\\");
diffFileName += wstring(buf);
// construct a title for the diff viewer
_stprintf_s(buf, 4096, _T("%s, revision %ld"), pInfo->name.c_str(), pLogEntry->revision);
wstring title = wstring(buf);
// start the diff viewer
TCHAR apppath[4096];
GetModuleFileName(NULL, apppath, 4096);
wstring cmd;
CRegStdString diffViewer = CRegStdString(_T("Software\\CommitMonitor\\DiffViewer"));
if (wstring(diffViewer).empty())
{
cmd = apppath;
cmd += _T(" /patchfile:\"");
}
else
{
cmd = (wstring)diffViewer;
cmd += _T(" \"");
}
cmd += diffFileName;
cmd += _T("\"");
if (wstring(diffViewer).empty())
{
cmd += _T(" /title:\"");
cmd += title;
cmd += _T("\"");
}
// Check if the diff file exists. If it doesn't, we have to fetch
// the diff first
if (!PathFileExists(diffFileName.c_str()))
{
// fetch the diff
SVN svn;
CProgressDlg progDlg;
svn.SetAndClearProgressInfo(&progDlg);
progDlg.SetTitle(_T("Fetching Diff"));
TCHAR dispbuf[MAX_PATH] = {0};
_stprintf_s(dispbuf, MAX_PATH, _T("fetching diff of revision %ld"), pLogEntry->revision);
progDlg.SetLine(1, dispbuf);
progDlg.SetShowProgressBar(false);
progDlg.ShowModeless(*this);
if (!svn.Diff(pInfo->url, pLogEntry->revision, pLogEntry->revision-1, pLogEntry->revision, true, true, false, wstring(), false, diffFileName, wstring()))
{
progDlg.Stop();
if (svn.Err->apr_err != SVN_ERR_CANCELLED)
::MessageBox(*this, svn.GetLastErrorMsg().c_str(), _T("CommitMonitor"), MB_ICONERROR);
DeleteFile(diffFileName.c_str());
}
else
{
TRACE(_T("Diff fetched for %s, revision %ld\n"), pInfo->url.c_str(), pLogEntry->revision);
progDlg.Stop();
}
}
if (PathFileExists(diffFileName.c_str()))
CAppUtils::LaunchApplication(cmd);
}
}
}
m_pURLInfos->ReleaseReadOnlyData();
return TRUE;
}
/******************************************************************************/
/* tree handling */
/******************************************************************************/
void CMainDlg::RefreshURLTree()
{
// the m_URLInfos member must be up-to-date here
m_bBlockListCtrlUI = true;
// first clear the controls (the data)
ListView_DeleteAllItems(m_hListControl);
TreeView_SelectItem(m_hTreeControl, NULL);
TreeView_DeleteAllItems(m_hTreeControl);
SetWindowText(m_hLogMsgControl, _T(""));
SendMessage(m_hwndToolbar, TB_ENABLEBUTTON, ID_MAIN_SHOWDIFF, MAKELONG(false, 0));
SendMessage(m_hwndToolbar, TB_ENABLEBUTTON, ID_MAIN_EDIT, MAKELONG(false, 0));
SendMessage(m_hwndToolbar, TB_ENABLEBUTTON, ID_MAIN_REMOVE, MAKELONG(false, 0));
// now add a tree item for every entry in m_URLInfos
const map<wstring, CUrlInfo> * pRead = m_pURLInfos->GetReadOnlyData();
for (map<wstring, CUrlInfo>::const_iterator it = pRead->begin(); it != pRead->end(); ++it)
{
TVINSERTSTRUCT tv = {0};
tv.hParent = FindParentTreeNode(it->first);
tv.hInsertAfter = TVI_SORT;
tv.itemex.mask = TVIF_TEXT|TVIF_PARAM|TVIF_STATE|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
WCHAR * str = new WCHAR[it->second.name.size()+10];
// find out if there are some unread entries
int unread = 0;
for (map<svn_revnum_t,SVNLogEntry>::const_iterator logit = it->second.logentries.begin(); logit != it->second.logentries.end(); ++logit)
{
if (!logit->second.read)
unread++;
}
if (unread)
{
_stprintf_s(str, it->second.name.size()+10, _T("%s (%d)"), it->second.name.c_str(), unread);
tv.itemex.state = TVIS_BOLD;
tv.itemex.stateMask = TVIS_BOLD;
}
else
{
_tcscpy_s(str, it->second.name.size()+1, it->second.name.c_str());
tv.itemex.state = 0;
tv.itemex.stateMask = 0;
}
tv.itemex.pszText = str;
tv.itemex.lParam = (LPARAM)&it->first;
if (it->second.parentpath)
{
tv.itemex.iImage = 0;
tv.itemex.iSelectedImage = 1;
}
else
{
if (unread)
{
tv.itemex.iImage = 3;
tv.itemex.iSelectedImage = 3;
}
else
{
tv.itemex.iImage = 2;
tv.itemex.iSelectedImage = 2;
}
}
TreeView_InsertItem(m_hTreeControl, &tv);
TreeView_Expand(m_hTreeControl, tv.hParent, TVE_EXPAND);
delete [] str;
}
m_pURLInfos->ReleaseReadOnlyData();
m_bBlockListCtrlUI = false;
::InvalidateRect(m_hListControl, NULL, true);
}
HTREEITEM CMainDlg::FindParentTreeNode(const wstring& url)
{
size_t pos = url.find_last_of('/');
wstring parenturl = url.substr(0, pos);
do
{
const map<wstring, CUrlInfo> * pRead = m_pURLInfos->GetReadOnlyData();
if (pRead->find(parenturl) != pRead->end())
{
m_pURLInfos->ReleaseReadOnlyData();
// we found a parent URL, but now we have to find it in the
// tree view
return FindTreeNode(parenturl);
}
m_pURLInfos->ReleaseReadOnlyData();
pos = parenturl.find_last_of('/');
parenturl = parenturl.substr(0, pos);
if (pos == string::npos)
parenturl.clear();
} while (!parenturl.empty());
return TVI_ROOT;
}
HTREEITEM CMainDlg::FindTreeNode(const wstring& url, HTREEITEM hItem)
{
if (hItem == TVI_ROOT)
hItem = TreeView_GetRoot(m_hTreeControl);
TVITEM item;
item.mask = TVIF_PARAM;
while (hItem)
{
item.hItem = hItem;
TreeView_GetItem(m_hTreeControl, &item);
if (url.compare(*(wstring*)item.lParam) == 0)
return hItem;
HTREEITEM hChild = TreeView_GetChild(m_hTreeControl, hItem);
if (hChild)
{
item.hItem = hChild;
TreeView_GetItem(m_hTreeControl, &item);
hChild = FindTreeNode(url, hChild);
if (hChild != TVI_ROOT)
return hChild;
}
hItem = TreeView_GetNextSibling(m_hTreeControl, hItem);
};
return TVI_ROOT;
}
void CMainDlg::OnSelectTreeItem(LPNMTREEVIEW lpNMTreeView)
{
HTREEITEM hSelectedItem = lpNMTreeView->itemNew.hItem;
SendMessage(m_hwndToolbar, TB_ENABLEBUTTON, ID_MAIN_EDIT,
MAKELONG(!!(lpNMTreeView->itemNew.state & TVIS_SELECTED), 0));
SetRemoveButtonState();
if (lpNMTreeView->itemNew.state & TVIS_SELECTED)
TreeItemSelected(lpNMTreeView->hdr.hwndFrom, hSelectedItem);
else
{
ListView_DeleteAllItems(m_hListControl);
SetWindowText(m_hLogMsgControl, _T(""));
}
SetWindowText(m_hLogMsgControl, _T(""));
}
void CMainDlg::TreeItemSelected(HWND hTreeControl, HTREEITEM hSelectedItem)
{
// get the url this entry refers to
TVITEMEX itemex = {0};
itemex.hItem = hSelectedItem;
itemex.mask = TVIF_PARAM;
TreeView_GetItem(hTreeControl, &itemex);
const map<wstring,CUrlInfo> * pRead = m_pURLInfos->GetReadOnlyData();
if (pRead->find(*(wstring*)itemex.lParam) != pRead->end())
{
const CUrlInfo * info = &pRead->find(*(wstring*)itemex.lParam)->second;
if ((!info->error.empty())&&(!info->parentpath))
{
// there was an error when we last tried to access this url.
// Show a message box with the error.
int len = info->error.length()+info->url.length()+1024;
TCHAR * pBuf = new TCHAR[len];
_stprintf_s(pBuf, len, _T("An error occurred the last time CommitMonitor\ntried to access the url: %s\n\n%s"), info->url.c_str(), info->error.c_str());
::MessageBox(*this, pBuf, _T("CommitMonitor"), MB_ICONERROR);
delete [] pBuf;
// clear the error so it won't show up again
map<wstring,CUrlInfo> * pWrite = m_pURLInfos->GetWriteData();
if (pWrite->find(*(wstring*)itemex.lParam) != pWrite->end())
{
CUrlInfo * infoWrite = &pWrite->find(*(wstring*)itemex.lParam)->second;
infoWrite->error.clear();
}
m_pURLInfos->ReleaseWriteData();
}
m_bBlockListCtrlUI = true;
DWORD exStyle = LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER;
ListView_DeleteAllItems(m_hListControl);
int c = Header_GetItemCount(ListView_GetHeader(m_hListControl))-1;
while (c>=0)
ListView_DeleteColumn(m_hListControl, c--);
ListView_SetExtendedListViewStyle(m_hListControl, exStyle);
LVCOLUMN lvc = {0};
lvc.mask = LVCF_TEXT;
lvc.fmt = LVCFMT_LEFT;
lvc.cx = -1;
lvc.pszText = _T("revision");
ListView_InsertColumn(m_hListControl, 0, &lvc);
lvc.pszText = _T("date");
ListView_InsertColumn(m_hListControl, 1, &lvc);
lvc.pszText = _T("author");
ListView_InsertColumn(m_hListControl, 2, &lvc);
LVITEM item = {0};
int i = 0;
TCHAR buf[1024];
for (map<svn_revnum_t,SVNLogEntry>::const_iterator it = info->logentries.begin(); it != info->logentries.end(); ++it)
{
item.mask = LVIF_TEXT|LVIF_PARAM;
item.iItem = i;
item.lParam = (LPARAM)&it->second;
_stprintf_s(buf, 1024, _T("%ld"), it->first);
item.pszText = buf;
ListView_InsertItem(m_hListControl, &item);
_tcscpy_s(buf, 1024, CAppUtils::ConvertDate(it->second.date).c_str());
ListView_SetItemText(m_hListControl, i, 1, buf);
_tcscpy_s(buf, 1024, it->second.author.c_str());
ListView_SetItemText(m_hListControl, i, 2, buf);
}
m_bBlockListCtrlUI = false;
ListView_SetColumnWidth(m_hListControl, 0, LVSCW_AUTOSIZE_USEHEADER);
ListView_SetColumnWidth(m_hListControl, 1, LVSCW_AUTOSIZE_USEHEADER);
ListView_SetColumnWidth(m_hListControl, 2, LVSCW_AUTOSIZE_USEHEADER);
::InvalidateRect(m_hListControl, NULL, false);
}
m_pURLInfos->ReleaseReadOnlyData();
}
/******************************************************************************/
/* list view handling */
/******************************************************************************/
void CMainDlg::OnSelectListItem(LPNMLISTVIEW lpNMListView)
{
if (lpNMListView->uNewState & LVIS_SELECTED)
{
const map<wstring,CUrlInfo> * pRead = m_pURLInfos->GetReadOnlyData();
LVITEM item = {0};
item.mask = LVIF_PARAM;
item.iItem = lpNMListView->iItem;
ListView_GetItem(m_hListControl, &item);
SVNLogEntry * pLogEntry = (SVNLogEntry*)item.lParam;
if (pLogEntry)
{
HTREEITEM hSelectedItem = TreeView_GetSelection(m_hTreeControl);
// get the url this entry refers to
TVITEMEX itemex = {0};
itemex.hItem = hSelectedItem;
itemex.mask = TVIF_PARAM;
TreeView_GetItem(m_hTreeControl, &itemex);
if (itemex.lParam == 0)
{
m_pURLInfos->ReleaseReadOnlyData();
return;
}
// set the entry as read
if (!pLogEntry->read)
{
pLogEntry->read = true;
// refresh the name of the tree item to indicate the new
// number of unread log messages
// e.g. instead of 'TortoiseSVN (3)', show now 'TortoiseSVN (2)'
if (pRead->find(*(wstring*)itemex.lParam) != pRead->end())
{
const CUrlInfo * uinfo = &pRead->find(*(wstring*)itemex.lParam)->second;
// count the number of unread messages
int unread = 0;
for (map<svn_revnum_t,SVNLogEntry>::const_iterator it = uinfo->logentries.begin(); it != uinfo->logentries.end(); ++it)
{
if (!it->second.read)
unread++;
}
WCHAR * str = new WCHAR[uinfo->name.size()+10];
if (unread)
{
_stprintf_s(str, uinfo->name.size()+10, _T("%s (%d)"), uinfo->name.c_str(), unread);
itemex.state = TVIS_BOLD;
itemex.stateMask = TVIS_BOLD;
itemex.iImage = 3;
itemex.iSelectedImage = 3;
}
else
{
_stprintf_s(str, uinfo->name.size()+10, _T("%s"), uinfo->name.c_str());
itemex.state = 0;
itemex.stateMask = TVIS_BOLD;
itemex.iImage = 2;
itemex.iSelectedImage = 2;
}
itemex.pszText = str;
itemex.mask = TVIF_TEXT|TVIF_STATE|TVIF_IMAGE|TVIF_SELECTEDIMAGE;
TreeView_SetItem(m_hTreeControl, &itemex);
}
// the icon in the system tray needs to be changed back
// to 'normal'
::SendMessage(m_hParent, COMMITMONITOR_CHANGEDINFO, (WPARAM)false, (LPARAM)0);
}
TCHAR buf[1024];
wstring msg = pLogEntry->message.c_str();
msg += _T("\n\n-------------------------------\n");
// now add all changed paths, one path per line
for (map<stdstring, SVNLogChangedPaths>::const_iterator it = pLogEntry->m_changedPaths.begin(); it != pLogEntry->m_changedPaths.end(); ++it)
{
// action
msg += it->second.action;
msg += _T(" : ");
msg += it->first;
msg += _T(" ");
if (!it->second.copyfrom_path.empty())
{
msg += _T("(copied from: ");
msg += it->second.copyfrom_path;
msg += _T(", revision ");
_stprintf_s(buf, 1024, _T("%ld)\n"), it->second.copyfrom_revision);
msg += wstring(buf);
}
else
msg += _T("\n");
}
CAppUtils::SearchReplace(msg, _T("\n"), _T("\r\n"));
SetWindowText(m_hLogMsgControl, msg.c_str());
// find the diff name
_stprintf_s(buf, 1024, _T("%s_%ld"), pRead->find(*(wstring*)itemex.lParam)->second.name.c_str(), pLogEntry->revision);
wstring diffFileName = CAppUtils::GetAppDataDir();
diffFileName += _T("\\");
diffFileName += wstring(buf);
SendMessage(m_hwndToolbar, TB_ENABLEBUTTON, ID_MAIN_SHOWDIFF, MAKELONG(true, 0));
}
m_pURLInfos->ReleaseReadOnlyData();
}
}
void CMainDlg::OnDblClickListItem(LPNMITEMACTIVATE /*lpnmitem*/)
{
ShowDiff();
}
LRESULT CMainDlg::OnCustomDrawListItem(LPNMLVCUSTOMDRAW lpNMCustomDraw)
{
// First thing - check the draw stage. If it's the control's prepaint
// stage, then tell Windows we want messages for every item.
LRESULT result = CDRF_DODEFAULT;
if (m_bBlockListCtrlUI)
return result;
switch (lpNMCustomDraw->nmcd.dwDrawStage)
{
case CDDS_PREPAINT:
result = CDRF_NOTIFYITEMDRAW;
break;
case CDDS_ITEMPREPAINT:
{
SVNLogEntry * pLogEntry = (SVNLogEntry*)lpNMCustomDraw->nmcd.lItemlParam;
if (!pLogEntry->read)
{
SelectObject(lpNMCustomDraw->nmcd.hdc, m_boldFont);
// We changed the font, so we're returning CDRF_NEWFONT. This
// tells the control to recalculate the extent of the text.
result = CDRF_NEWFONT;
}
}
break;
}
return result;
}
void CMainDlg::OnKeyDownListItem(LPNMLVKEYDOWN pnkd)
{
if (pnkd->wVKey == VK_DELETE)
{
// remove the selected entry
RemoveSelectedListItems();
}
}
void CMainDlg::RemoveSelectedListItems()
{
int selCount = ListView_GetSelectedCount(m_hListControl);
if (selCount <= 0)
return; //nothing selected, nothing to remove
int nFirstDeleted = -1;
HTREEITEM hSelectedItem = TreeView_GetSelection(m_hTreeControl);
// get the url this entry refers to
TVITEMEX itemex = {0};
itemex.hItem = hSelectedItem;
itemex.mask = TVIF_PARAM;
TreeView_GetItem(m_hTreeControl, &itemex);
map<wstring,CUrlInfo> * pWrite = m_pURLInfos->GetWriteData();
if (pWrite->find(*(wstring*)itemex.lParam) != pWrite->end())
{
LVITEM item = {0};
int i = 0;
TCHAR buf[4096];
while (i<ListView_GetItemCount(m_hListControl))
{
item.mask = LVIF_PARAM|LVIF_STATE;
item.stateMask = LVIS_SELECTED;
item.iItem = i;
item.lParam = 0;
ListView_GetItem(m_hListControl, &item);
if (item.state & LVIS_SELECTED)
{
SVNLogEntry * pLogEntry = (SVNLogEntry*)item.lParam;
// find the diff name
_stprintf_s(buf, 4096, _T("%s_%ld"), pWrite->find(*(wstring*)itemex.lParam)->second.name.c_str(), pLogEntry->revision);
wstring diffFileName = CAppUtils::GetAppDataDir();
diffFileName += _T("\\");
diffFileName += wstring(buf);
DeleteFile(diffFileName.c_str());
pWrite->find((*(wstring*)itemex.lParam))->second.logentries.erase(pLogEntry->revision);
ListView_DeleteItem(m_hListControl, i);
if (nFirstDeleted < 0)
nFirstDeleted = i;
}
else
++i;
}
}
m_pURLInfos->ReleaseWriteData();
if (nFirstDeleted >= 0)
{
if (ListView_GetItemCount(m_hListControl) > nFirstDeleted)
{
ListView_SetItemState(m_hListControl, nFirstDeleted, LVIS_SELECTED, LVIS_SELECTED);
}
else
{
ListView_SetItemState(m_hListControl, ListView_GetItemCount(m_hListControl)-1, LVIS_SELECTED, LVIS_SELECTED);
}
}
SetRemoveButtonState();
}
/******************************************************************************/
/* tree, list view and dialog resizing */
/******************************************************************************/
void CMainDlg::DoResize(int width, int height)
{
// when we get here, the controls haven't been resized yet
RECT tree, list, log, ex, ok, label;
HWND hExit = GetDlgItem(*this, IDC_EXIT);
HWND hOK = GetDlgItem(*this, IDOK);
HWND hLabel = GetDlgItem(*this, IDC_INFOLABEL);
::GetClientRect(m_hTreeControl, &tree);
::GetClientRect(m_hListControl, &list);
::GetClientRect(m_hLogMsgControl, &log);
::GetClientRect(hExit, &ex);
::GetClientRect(hOK, &ok);
::GetClientRect(hLabel, &label);
HDWP hdwp = BeginDeferWindowPos(7);
hdwp = DeferWindowPos(hdwp, m_hwndToolbar, *this, 0, 0, width, m_topmarg, SWP_NOZORDER|SWP_NOACTIVATE);
hdwp = DeferWindowPos(hdwp, m_hTreeControl, *this, 0, m_topmarg, m_xSliderPos, height-m_topmarg-m_bottommarg+5, SWP_NOZORDER|SWP_NOACTIVATE);
hdwp = DeferWindowPos(hdwp, m_hListControl, *this, m_xSliderPos+4, m_topmarg, width-m_xSliderPos, m_ySliderPos-m_topmarg+4, SWP_NOZORDER|SWP_NOACTIVATE);
hdwp = DeferWindowPos(hdwp, m_hLogMsgControl, *this, m_xSliderPos+4, m_ySliderPos+8, width-m_xSliderPos-4, height-m_bottommarg-m_ySliderPos-4, SWP_NOZORDER|SWP_NOACTIVATE);
hdwp = DeferWindowPos(hdwp, hExit, *this, width-ok.right+ok.left-ex.right+ex.left-3, height-ex.bottom+ex.top, ex.right-ex.left, ex.bottom-ex.top, SWP_NOZORDER|SWP_NOACTIVATE);
hdwp = DeferWindowPos(hdwp, hOK, *this, width-ok.right+ok.left, height-ok.bottom+ok.top, ok.right-ok.left, ok.bottom-ok.top, SWP_NOZORDER|SWP_NOACTIVATE);
hdwp = DeferWindowPos(hdwp, hLabel, *this, 2, height-label.bottom+label.top+2, width-ok.right-ex.right-8, ex.bottom-ex.top, SWP_NOZORDER|SWP_NOACTIVATE);
EndDeferWindowPos(hdwp);
}
bool CMainDlg::OnSetCursor(HWND hWnd, UINT nHitTest, UINT message)
{
UNREFERENCED_PARAMETER(message);
UNREFERENCED_PARAMETER(nHitTest);
if (hWnd == *this)
{
RECT rect;
POINT pt;
GetClientRect(*this, &rect);
GetCursorPos(&pt);
ScreenToClient(*this, &pt);
if (PtInRect(&rect, pt))
{
ClientToScreen(*this, &pt);
// are we right of the tree control?
::GetWindowRect(m_hTreeControl, &rect);
if ((pt.x > rect.right)&&
(pt.y >= rect.top)&&
(pt.y <= rect.bottom))
{
// but left of the list control?
::GetWindowRect(m_hListControl, &rect);
if (pt.x < rect.left)
{
HCURSOR hCur = LoadCursor(NULL, MAKEINTRESOURCE(IDC_SIZEWE));
SetCursor(hCur);
return TRUE;
}
// maybe we are below the log message list control?
if (pt.y > rect.bottom)
{
::GetWindowRect(m_hLogMsgControl, &rect);
if (pt.y < rect.top)
{
HCURSOR hCur = LoadCursor(NULL, MAKEINTRESOURCE(IDC_SIZENS));
SetCursor(hCur);
return TRUE;
}
}
}
}
}
return FALSE;
}
bool CMainDlg::OnMouseMove(UINT nFlags, POINT point)
{
HDC hDC;
RECT rect, tree, list, treelist, treelistclient, logrect, loglist, loglistclient;
if (m_nDragMode == DRAGMODE_NONE)
return false;
// create an union of the tree and list control rectangle
::GetWindowRect(m_hListControl, &list);
::GetWindowRect(m_hTreeControl, &tree);
::GetWindowRect(m_hLogMsgControl, &logrect);
UnionRect(&treelist, &tree, &list);
treelistclient = treelist;
MapWindowPoints(NULL, *this, (LPPOINT)&treelistclient, 2);
UnionRect(&loglist, &logrect, &list);
loglistclient = loglist;
MapWindowPoints(NULL, *this, (LPPOINT)&loglistclient, 2);
//convert the mouse coordinates relative to the top-left of
//the window
ClientToScreen(*this, &point);
GetClientRect(*this, &rect);
MapWindowPoints(*this, NULL, (LPPOINT)&rect, 2);
point.x -= rect.left;
point.y -= rect.top;
//same for the window coordinates - make them relative to 0,0
LONG tempy = rect.top;
LONG tempx = rect.left;
OffsetRect(&treelist, -tempx, -tempy);
OffsetRect(&loglist, -tempx, -tempy);
if (point.x < treelist.left+REPOBROWSER_CTRL_MIN_WIDTH)
point.x = treelist.left+REPOBROWSER_CTRL_MIN_WIDTH;
if (point.x > treelist.right-REPOBROWSER_CTRL_MIN_WIDTH)
point.x = treelist.right-REPOBROWSER_CTRL_MIN_WIDTH;
if (point.y > loglist.bottom-REPOBROWSER_CTRL_MIN_HEIGHT)
point.y = loglist.bottom-REPOBROWSER_CTRL_MIN_HEIGHT;
if (point.y < loglist.top+REPOBROWSER_CTRL_MIN_HEIGHT)
point.y = loglist.top+REPOBROWSER_CTRL_MIN_HEIGHT;
if ((nFlags & MK_LBUTTON) && ((point.x != m_oldx)||(point.y != m_oldy)))
{
hDC = GetDC(*this);
if (hDC)
{
if (m_nDragMode == DRAGMODE_HORIZONTAL)
{
DrawXorBar(hDC, m_oldx+2, treelistclient.top, 4, treelistclient.bottom-treelistclient.top-2);
DrawXorBar(hDC, point.x+2, treelistclient.top, 4, treelistclient.bottom-treelistclient.top-2);
}
else
{
DrawXorBar(hDC, loglistclient.left, m_oldy+2, loglistclient.right-loglistclient.left-2, 4);
DrawXorBar(hDC, loglistclient.left, point.y+2, loglistclient.right-loglistclient.left-2, 4);
}
ReleaseDC(*this, hDC);
}
m_oldx = point.x;
m_oldy = point.y;
}
return true;
}
bool CMainDlg::OnLButtonDown(UINT nFlags, POINT point)
{
UNREFERENCED_PARAMETER(nFlags);
HDC hDC;
RECT rect, tree, list, treelist, treelistclient, logrect, loglist, loglistclient;
// create an union of the tree and list control rectangle
::GetWindowRect(m_hListControl, &list);
::GetWindowRect(m_hTreeControl, &tree);
::GetWindowRect(m_hLogMsgControl, &logrect);
UnionRect(&treelist, &tree, &list);
treelistclient = treelist;
MapWindowPoints(NULL, *this, (LPPOINT)&treelistclient, 2);
UnionRect(&loglist, &logrect, &list);
loglistclient = loglist;
MapWindowPoints(NULL, *this, (LPPOINT)&loglistclient, 2);
//convert the mouse coordinates relative to the top-left of
//the window
ClientToScreen(*this, &point);
GetClientRect(*this, &rect);
MapWindowPoints(*this, NULL, (LPPOINT)&rect, 2);
point.x -= rect.left;
point.y -= rect.top;
//same for the window coordinates - make them relative to 0,0
LONG tempy = rect.top;
LONG tempx = rect.left;
OffsetRect(&treelist, -tempx, -tempy);
OffsetRect(&loglist, -tempx, -tempy);
if ((point.y < treelist.top) ||
(point.y > treelist.bottom))
return false;
m_nDragMode = DRAGMODE_HORIZONTAL;
if ((point.x+rect.left) > list.left)
m_nDragMode = DRAGMODE_VERTICAL;
if (point.x < treelist.left+REPOBROWSER_CTRL_MIN_WIDTH)
point.x = treelist.left+REPOBROWSER_CTRL_MIN_WIDTH;
if (point.x > treelist.right-REPOBROWSER_CTRL_MIN_WIDTH)
point.x = treelist.right-REPOBROWSER_CTRL_MIN_WIDTH;
if (point.y > loglist.bottom-REPOBROWSER_CTRL_MIN_HEIGHT)
point.y = loglist.bottom-REPOBROWSER_CTRL_MIN_HEIGHT;
if (point.y < loglist.top+REPOBROWSER_CTRL_MIN_HEIGHT)
point.y = loglist.top+REPOBROWSER_CTRL_MIN_HEIGHT;
SetCapture(*this);
hDC = GetDC(*this);
if (m_nDragMode == DRAGMODE_HORIZONTAL)
DrawXorBar(hDC, point.x+2, treelistclient.top, 4, treelistclient.bottom-treelistclient.top-2);
else
DrawXorBar(hDC, loglistclient.left, point.y+2, loglistclient.right-loglistclient.left-2, 4);
ReleaseDC(*this, hDC);
m_oldx = point.x;
m_oldy = point.y;
return true;
}
bool CMainDlg::OnLButtonUp(UINT nFlags, POINT point)
{
UNREFERENCED_PARAMETER(nFlags);
HDC hDC;
RECT rect, tree, list, treelist, treelistclient, logrect, loglist, loglistclient;
if (m_nDragMode == DRAGMODE_NONE)
return false;
// create an union of the tree and list control rectangle
::GetWindowRect(m_hListControl, &list);
::GetWindowRect(m_hTreeControl, &tree);
::GetWindowRect(m_hLogMsgControl, &logrect);
UnionRect(&treelist, &tree, &list);
treelistclient = treelist;
MapWindowPoints(NULL, *this, (LPPOINT)&treelistclient, 2);
UnionRect(&loglist, &logrect, &list);
loglistclient = loglist;
MapWindowPoints(NULL, *this, (LPPOINT)&loglistclient, 2);
//convert the mouse coordinates relative to the top-left of
//the window
ClientToScreen(*this, &point);
GetClientRect(*this, &rect);
MapWindowPoints(*this, NULL, (LPPOINT)&rect, 2);
POINT point2 = point;
if (point2.x < treelist.left+REPOBROWSER_CTRL_MIN_WIDTH)
point2.x = treelist.left+REPOBROWSER_CTRL_MIN_WIDTH;
if (point2.x > treelist.right-REPOBROWSER_CTRL_MIN_WIDTH)
point2.x = treelist.right-REPOBROWSER_CTRL_MIN_WIDTH;
POINT point3 = point;
if (point3.y < loglist.top+REPOBROWSER_CTRL_MIN_HEIGHT)
point3.y = loglist.top+REPOBROWSER_CTRL_MIN_HEIGHT;
if (point3.y > loglist.bottom-REPOBROWSER_CTRL_MIN_HEIGHT)
point3.y = loglist.bottom-REPOBROWSER_CTRL_MIN_HEIGHT;
point.x -= rect.left;
point.y -= rect.top;
//same for the window coordinates - make them relative to 0,0
LONG tempy = treelist.top;
LONG tempx = treelist.left;
OffsetRect(&treelist, -tempx, -tempy);
OffsetRect(&loglist, -tempx, -tempy);
if (point.x < treelist.left+REPOBROWSER_CTRL_MIN_WIDTH)
point.x = treelist.left+REPOBROWSER_CTRL_MIN_WIDTH;
if (point.x > treelist.right-REPOBROWSER_CTRL_MIN_WIDTH)
point.x = treelist.right-REPOBROWSER_CTRL_MIN_WIDTH;
if (point.y > loglist.bottom-REPOBROWSER_CTRL_MIN_HEIGHT)
point.y = loglist.bottom-REPOBROWSER_CTRL_MIN_HEIGHT;
if (point.y < loglist.top+REPOBROWSER_CTRL_MIN_HEIGHT)
point.y = loglist.top+REPOBROWSER_CTRL_MIN_HEIGHT;
hDC = GetDC(*this);
if (m_nDragMode == DRAGMODE_HORIZONTAL)
DrawXorBar(hDC, m_oldx+2, treelistclient.top, 4, treelistclient.bottom-treelistclient.top-2);
else
DrawXorBar(hDC, loglistclient.left, m_oldy+2, loglistclient.right-loglistclient.left-2, 4);
ReleaseDC(*this, hDC);
m_oldx = point.x;
m_oldy = point.y;
ReleaseCapture();
//position the child controls
HDWP hdwp = BeginDeferWindowPos(3);
if (hdwp)
{
if (m_nDragMode == DRAGMODE_HORIZONTAL)
{
GetWindowRect(m_hTreeControl, &treelist);
treelist.right = point2.x - 2;
MapWindowPoints(NULL, *this, (LPPOINT)&treelist, 2);
DeferWindowPos(hdwp, m_hTreeControl, NULL,
treelist.left, treelist.top, treelist.right-treelist.left, treelist.bottom-treelist.top,
SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOZORDER);
GetWindowRect(m_hListControl, &treelist);
treelist.left = point2.x + 2;
MapWindowPoints(NULL, *this, (LPPOINT)&treelist, 2);
DeferWindowPos(hdwp, m_hListControl, NULL,
treelist.left, treelist.top, treelist.right-treelist.left, treelist.bottom-treelist.top,
SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOZORDER);
GetWindowRect(m_hLogMsgControl, &treelist);
treelist.left = point2.x + 2;
MapWindowPoints(NULL, *this, (LPPOINT)&treelist, 2);
DeferWindowPos(hdwp, m_hLogMsgControl, NULL,
treelist.left, treelist.top, treelist.right-treelist.left, treelist.bottom-treelist.top,
SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOZORDER);
}
else
{
GetWindowRect(m_hListControl, &treelist);
treelist.bottom = point3.y - 2;
MapWindowPoints(NULL, *this, (LPPOINT)&treelist, 2);
DeferWindowPos(hdwp, m_hListControl, NULL,
treelist.left, treelist.top, treelist.right-treelist.left, treelist.bottom-treelist.top,
SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOZORDER);
GetWindowRect(m_hLogMsgControl, &treelist);
treelist.top = point3.y + 2;
MapWindowPoints(NULL, *this, (LPPOINT)&treelist, 2);
DeferWindowPos(hdwp, m_hLogMsgControl, NULL,
treelist.left, treelist.top, treelist.right-treelist.left, treelist.bottom-treelist.top,
SWP_NOACTIVATE|SWP_NOOWNERZORDER|SWP_NOZORDER);
}
EndDeferWindowPos(hdwp);
}
// initialize the window position infos
GetClientRect(m_hTreeControl, &rect);
m_xSliderPos = rect.right+4;
GetClientRect(m_hListControl, &rect);
m_ySliderPos = rect.bottom+m_topmarg;
m_nDragMode = DRAGMODE_NONE;
return true;
}
void CMainDlg::DrawXorBar(HDC hDC, LONG x1, LONG y1, LONG width, LONG height)
{
static WORD _dotPatternBmp[8] =
{
0x0055, 0x00aa, 0x0055, 0x00aa,
0x0055, 0x00aa, 0x0055, 0x00aa
};
HBITMAP hbm;
HBRUSH hbr, hbrushOld;
hbm = CreateBitmap(8, 8, 1, 1, _dotPatternBmp);
hbr = CreatePatternBrush(hbm);
SetBrushOrgEx(hDC, x1, y1, NULL);
hbrushOld = (HBRUSH)SelectObject(hDC, hbr);
PatBlt(hDC, x1, y1, width, height, PATINVERT);
SelectObject(hDC, hbrushOld);
DeleteObject(hbr);
DeleteObject(hbm);
}
LRESULT CALLBACK CMainDlg::TreeProc(HWND hWnd, UINT uMessage, WPARAM wParam, LPARAM lParam)
{
CMainDlg *pThis = (CMainDlg*)GetWindowLongPtr(hWnd, GWLP_USERDATA);
if (uMessage == WM_SETFOCUS)
{
pThis->SetRemoveButtonState();
}
return CallWindowProc(pThis->m_oldTreeWndProc, hWnd, uMessage, wParam, lParam);
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.