-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPPC_WIND.C
More file actions
1359 lines (1194 loc) · 37.9 KB
/
Copy pathPPC_WIND.C
File metadata and controls
1359 lines (1194 loc) · 37.9 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
/*-----------------------------------------------------------------------------
Paper Plane cUI Window 処理
-----------------------------------------------------------------------------*/
#include "WINAPI.H"
#include <commctrl.h>
#include "PPX.H"
#include "PPC_STRU.H"
#include "PPC_FUNC.H"
#include "PPCOMBO.H"
#pragma hdrstop
#define HDR_FILENAME hdrstrings[0]
#define HDR_DATE hdrstrings[1]
#define HDR_SIZE hdrstrings[2]
#define HDR_ATTR hdrstrings[3]
const TCHAR *typestr1[] = {T("PATH"), T("LINE"), T("HMNU"), T("INFO"), T("ICON")};
const TCHAR *typestr2[] = {T("SPC"), T("MARK"), T("ENT"), T("TAIL")};
const TCHAR *XDtype[] = {T("?D"), T("XD"), T("YD"), T("ZD")};
const TCHAR *Xtype[] = {T("?"), T("X"), T("Y"), T("Z")};
typedef struct {
const TCHAR *label;
BYTE sortlow, sorthigh;
} TIME2HEADERSTRUCT;
TIME2HEADERSTRUCT Time2Header[] = {
{ MES_HDRC, 4, 12 },
{ MES_HDRE, 5, 13 },
{ hdrstrings_eng_date, 3, 11 },
};
// マウス操作の解析・実行 -----------------------------------------------------
BOOL PPcMouseCommand(PPC_APPINFO *cinfo, const TCHAR *click, const TCHAR *type)
{
TCHAR buf[CMDLINESIZE], *butptr;
// クライアント領域の判別
if ( (DWORD_PTR)type < 0x100 ){
int inttype;
inttype = PtrToValue(type);
if ( (inttype >= PPCR_PATH) && (inttype <= PPCR_INFOICON) ){
type = typestr1[inttype - PPCR_PATH];
}else if ( (inttype >= PPCR_CELLBLANK) && (inttype <= PPCR_CELLTAIL) ){
type = typestr2[inttype - PPCR_CELLBLANK];
}else{
return FALSE;
}
}
// 操作の確定
butptr = PutShiftCode(buf, GetShiftKey());
thprintf(butptr, 200, T("%s_%s"), click, type);
// 実行
if ( NO_ERROR == GetCustTable(T("MC_click"), buf, buf, sizeof(buf)) ){
if ( type != typestr2[PPCR_CELLTAIL - PPCR_CELLBLANK] ){
ExecDualParam(cinfo, buf); // 通常
}else{ // PPCR_CELLTAIL の場合
if ( (cinfo->e.cellPoint >= 0) && (cinfo->e.cellPoint < cinfo->e.cellIMax) ){
ENTRYINDEX oldcelln;
oldcelln = cinfo->e.cellN;
cinfo->e.cellN = cinfo->e.cellPoint; // 一時的に変更
ExecDualParam(cinfo, buf); // 通常
cinfo->e.cellN = oldcelln;
}
}
if ( IsTrue(cinfo->UnpackFix) ) OffArcPathMode(cinfo);
return TRUE;
}else{
return FALSE;
}
}
HWND GetParentWnd(HWND hWnd)
{
HWND hTmpWnd;
hTmpWnd = GetParent(hWnd);
return ( hTmpWnd == NULL ) ? hWnd : hTmpWnd;
}
// 非クライアント領域の判別 ---------------------------------------------------
LRESULT PPcNCMouseCommand(PPC_APPINFO *cinfo, UINT message, WPARAM wParam, LPARAM lParam)
{
const TCHAR *click, *type;
switch( LOWORD(wParam) ){
case HTBOTTOM:
case HTBOTTOMLEFT:
case HTBOTTOMRIGHT:
case HTLEFT:
case HTRIGHT:
case HTTOP:
case HTTOPLEFT:
case HTTOPRIGHT:
type = T("FRAM");
break;
case HTSYSMENU:
type = T("SYSM");
break;
case HTCAPTION:
type = T("TITL");
break;
case HTREDUCE:
type = T("MINI");
break;
case HTZOOM:
type = T("ZOOM");
break;
case HTCLOSE:
type = T("CLOS");
break;
case HTHSCROLL:
case HTVSCROLL:
type = T("SCRL");
break;
case HTMENU:
type = T("MENU");
break;
default:
return DefWindowProc(GetParentWnd(cinfo->info.hWnd), message, wParam, lParam);
}
switch ( message ){
case WM_NCLBUTTONDBLCLK:
click = T("LD");
break;
case WM_NCMBUTTONDBLCLK:
click = T("MD");
break;
case WM_NCMBUTTONUP:
click = T("M");
break;
case WM_NCRBUTTONDBLCLK:
click = T("RD");
break;
case WM_NCRBUTTONUP:
click = T("R");
break;
case WM_NCXBUTTONDBLCLK:
click = XDtype[CheckXMouseButton(wParam)];
break;
case WM_NCXBUTTONUP:
click = Xtype[CheckXMouseButton(wParam)];
break;
// case WM_NCLBUTTONUP:
default:
click = T("L");
break;
}
cinfo->LastInputType = GetPointType();
cinfo->PopupPosType = PPT_MOUSE;
if ( !PPcMouseCommand(cinfo, click, type) ){
return DefWindowProc(GetParentWnd(cinfo->info.hWnd), message, wParam, lParam);
}
return 0;
}
// 窓の大きさを調整 -----------------------------------------------------------
void FixWindowSize(PPC_APPINFO *cinfo, int offsetx, int offsety)
{
int width, height;
int widthFix, heightFix; // 補正分
widthFix = cinfo->wnd.NCArea.cx - cinfo->wnd.Area.cx + // 枠分
cinfo->BoxEntries.left - cinfo->fontX; // 位置補正
heightFix = cinfo->wnd.NCArea.cy - cinfo->wnd.Area.cy + // 枠分
cinfo->BoxEntries.top + cinfo->docks.b.client.bottom; // 位置補正
// スクロールバーが表示されていないときは、その分も加算する
if ( cinfo->hScrollBarWnd != NULL ){
if ( cinfo->ScrollBarHV == SB_HORZ ){
heightFix += cinfo->ScrollBarSize;
}else{
widthFix += cinfo->ScrollBarSize;
}
}else if ( !(cinfo->X_win & XWIN_HIDESCROLL) &&
!(GetWindowLongPtr(cinfo->info.hWnd, GWL_STYLE) &
(WS_HSCROLL | WS_VSCROLL)) ){
if ( cinfo->ScrollBarHV == SB_HORZ ){
heightFix += GetSystemMetrics(SM_CYHSCROLL) % cinfo->cel.Size.cy;
}else{
if ( cinfo->celF.attr & DE_ATTR_WIDEW ){
widthFix += GetSystemMetrics(SM_CXVSCROLL) % cinfo->fontX;
}else{
widthFix += GetSystemMetrics(SM_CXVSCROLL) % cinfo->cel.Size.cx;
}
}
}
if ( cinfo->celF.attr & DE_ATTR_WIDEW ){
width = cinfo->cel.Area.cx *
(cinfo->cel.Size.cx + offsetx * cinfo->fontX) + widthFix;
}else{
width = cinfo->cel.Area.cx * cinfo->cel.Size.cx + widthFix;
if ( width != cinfo->wnd.NCArea.cx ){ // 微調整が必要
if ( width > cinfo->wnd.NCArea.cx ){ // 1桁より少ない
offsetx = 0;
}else{
if ( offsetx <= 0 ) offsetx += 1;
}
}
width = max(1, cinfo->cel.Area.cx + offsetx) * cinfo->cel.Size.cx
+ widthFix;
}
height = (cinfo->cel.Area.cy + offsety) * cinfo->cel.Size.cy + // cellArea分
heightFix;
if ( (width >= 16) && (height >= 8) ){
if ( cinfo->combo ){
SendMessage(cinfo->hComboWnd, WM_PPXCOMMAND, TMAKELPARAM(KCW_reqsize, 1), 0);
}
SetWindowPos(cinfo->info.hWnd, NULL, 0, 0, width, height,
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER);
}
InitCli(cinfo);
}
BOOL CalcJoinRate(int site, int mode, LONG *thispos, LONG *thissize, LONG *pairpos, LONG *pairsize, int offset, int mintype)
{
int minvalue;
if ( mode == FPS_RATE ){
offset = (*thissize + *pairsize) * offset / 100 - *thissize;
}
if ( site & PAIRBIT ){ // 基準が(上/左)
*thissize += offset;
*pairpos += offset;
*pairsize -= offset;
}else{ // 基準が(下/右)
if ( mode == FPS_KEYBOARD ) offset = -offset; // キーボード操作
*thispos -= offset;
*thissize += offset;
*pairsize -= offset;
}
minvalue = GetSystemMetrics(mintype);
if ( *thissize < minvalue ) return FALSE; // これ以上はできない
if ( *pairsize < minvalue ) return FALSE; // これ以上はできない
return TRUE;
}
void FixPaneSize(PPC_APPINFO *cinfo, int offsetx, int offsety, int mode)
{
if ( cinfo->combo ){ // 一体化窓
SCW_REQSIZE rs;
rs.hWnd = cinfo->info.hWnd;
rs.offsetx = offsetx;
rs.offsety = offsety;
rs.mode = mode;
SendMessage(cinfo->hComboWnd, WM_PPXCOMMAND, KCW_reqsize, (LPARAM)&rs);
return;
}
// 連結窓
if ( (cinfo->swin & (SWIN_WBOOT | SWIN_FIXACTIVE)) && CheckReady(cinfo) ){
HWND hPairWnd;
HDWP hDWP;
RECT thisbox, pairbox;
int site;
hPairWnd = GetJoinWnd(cinfo);
if ( hPairWnd == NULL ) return;
if ( cinfo->swin & SWIN_PILEJOIN ) return;// 重ねるときは処理しない
thisbox = cinfo->wnd.NCRect;
GetWindowRect(hPairWnd, &pairbox);
thisbox.right -= thisbox.left;
thisbox.bottom -= thisbox.top;
pairbox.right -= pairbox.left;
pairbox.bottom -= pairbox.top;
site = cinfo->RegID[2];
if ( cinfo->swin & SWIN_SWAPMODE ) site ^= PAIRBIT;
if ( cinfo->swin & SWIN_UDJOIN ){ // 上
if ( mode == FPS_RATE ){
if ( offsety <= 0 ) offsety = 1;
if ( offsety >= 100 ) offsety = 99;
}else{
if ( (mode == FPS_KEYBOARD) && offsetx ) return;
offsety *= cinfo->fontY;
}
if ( FALSE == CalcJoinRate(site, mode,
&thisbox.top, &thisbox.bottom,
&pairbox.top, &pairbox.bottom, offsety, SM_CYMIN) ){
return;
}
}else{ // 左
if ( mode == FPS_RATE ){
if ( offsetx <= 0 ) offsetx = 1;
if ( offsetx >= 100 ) offsetx = 99;
}else{
if ( (mode == FPS_KEYBOARD) && offsety ) return;
offsetx *= cinfo->fontX;
}
if ( FALSE == CalcJoinRate(site, mode,
&thisbox.left, &thisbox.right,
&pairbox.left, &pairbox.right, offsetx, SM_CXMIN) ){
return;
}
}
hDWP = BeginDeferWindowPos(2);
hDWP = DeferWindowPos(hDWP, cinfo->info.hWnd, 0,
thisbox.left, thisbox.top, thisbox.right, thisbox.bottom,
SWP_NOACTIVATE | SWP_NOZORDER);
hDWP = DeferWindowPos(hDWP, hPairWnd, 0,
pairbox.left, pairbox.top, pairbox.right, pairbox.bottom,
SWP_NOACTIVATE | SWP_NOZORDER);
if ( hDWP != NULL ) EndDeferWindowPos(hDWP);
}
}
int GetTime2Len(char *format)
{
int len = 0;
for ( ;; ){
char c;
c = *format;
switch ( c ){
case '\0':
return len;
case 'I':
case 'a':
case 'g':
case 'w':
len += 3;
break;
case 'T':
case 'Y':
len += 4;
break;
case 'G':
len += 6;
break;
default:
if ( IsalphaA(c) ){
len += 2;
}else{
len++;
}
break;
}
format++;
}
}
int GetSortMark(PPC_APPINFO *cinfo, char up, char down)
{
int i, fmt = 0;
char *mode;
for ( i = 0, mode = cinfo->sort_last.mode.dat ; i < 3 ; i++, mode++ ){
if ( *mode == down ){
setflag(fmt, HDF_SORTDOWN);
break;
}else if ( *mode == up ){
setflag(fmt, HDF_SORTUP);
break;
}
}
return fmt;
}
#define HEADERLPARAM(fmt, low, high) TMAKELPARAM(low + (high << 8), fmt - cinfo->celF.fmt)
void FixHeader(PPC_APPINFO *cinfo)
{
HD_ITEM hdri;
BYTE *fmt;
int width = cinfo->fontX;
int index = 0;
BOOL UseCheckBox = OSver.dwMajorVersion >= 6;
// 削除
while ( SendMessage(cinfo->hHeaderWnd, HDM_DELETEITEM, 0, 0) );
fmt = cinfo->celF.fmt;
while( *fmt ){
hdri.mask = HDI_TEXT | HDI_WIDTH | HDI_FORMAT | HDI_LPARAM;
hdri.fmt = HDF_STRING;
hdri.lParam = -1;
hdri.cchTextMax = 0;
hdri.pszText = NilStrNC;
switch( *fmt ){
case DE_IMAGE: // 画像
hdri.cxy = width * *(fmt + 1);
hdri.fmt = GetSortMark(cinfo, 6, 14);
hdri.lParam = HEADERLPARAM(fmt, 6, 14);
break;
case DE_CHECK: // チェック
case DE_CHECKBOX: // チェックボックス
case DE_ICON: // アイコン
hdri.cxy = width * 2;
hdri.fmt = GetSortMark(cinfo, 6, 14);
hdri.lParam = HEADERLPARAM(fmt, 6, 14);
break;
case DE_ICON2: // アイコン2
hdri.cxy = *(fmt + 1) + ICONBLANK;
hdri.fmt = GetSortMark(cinfo, 6, 14);
hdri.lParam = HEADERLPARAM(fmt, 6, 14);
break;
case DE_MARK: // マーク
hdri.fmt = GetSortMark(cinfo, 6, 14);
hdri.lParam = HEADERLPARAM(fmt, 6, 14);
// DE_sepline へ
case DE_sepline: // 区切り線
hdri.cxy = width;
break;
case DE_SPC: // 空白
case DE_BLANK: // 空白
hdri.cxy = width * *(fmt + 1);
break;
case DE_LFN:
case DE_SFN:
case DE_LFN_MUL:
case DE_LFN_LMUL:
case DE_LFN_EXT:
case DE_SFN_EXT:
{
int w;
w = *(fmt + 2);
if ( w >= 0xff ) w = 0;
hdri.cxy = width * (*(fmt + 1) + w);
hdri.pszText = HDR_FILENAME;
hdri.fmt = GetSortMark(cinfo, 0, 8);
hdri.lParam = HEADERLPARAM(fmt, 0, 8);
break;
}
case DE_SIZE1:
hdri.cxy = cinfo->fontNumX * (7 - 1) + width;
hdri.pszText = HDR_SIZE;
hdri.fmt = GetSortMark(cinfo, 2, 10);
hdri.lParam = HEADERLPARAM(fmt, 2, 10);
break;
case DE_SIZE2:
case DE_SIZE3:
case DE_SIZE4:
hdri.cxy = cinfo->fontNumX * ((int)*(fmt + 1) - 1) + width;
hdri.pszText = HDR_SIZE;
hdri.fmt = GetSortMark(cinfo, 2, 10);
hdri.lParam = HEADERLPARAM(fmt, 2, 10);
break;
case DE_ATTR1:
hdri.cxy = width * *(fmt + 1);
hdri.pszText = HDR_ATTR;
hdri.fmt = GetSortMark(cinfo, 16, 16);
hdri.lParam = HEADERLPARAM(fmt, 16, 16);
break;
case DE_itemname:
case DE_string:
case DE_ivalue:
hdri.cxy = width * tstrlen32((TCHAR *)fmt + 1);
break;
case DE_TIME1:
hdri.cxy = width * *(fmt + 1);
if ( UsePFont ){ // 可変長補正
HDC hDC = GetDC(cinfo->info.hWnd);
SIZE boxsize;
HGDIOBJ hOldFont;
hOldFont = SelectObject(hDC, cinfo->hBoxFont);
GetTextExtentPoint32(hDC, T("00-00-00 00:00:00.000"),
*(fmt + 1), &boxsize);
hdri.cxy = boxsize.cx;
SelectObject(hDC, hOldFont); // フォント
ReleaseDC(cinfo->info.hWnd, hDC);
}
hdri.pszText = HDR_DATE;
hdri.fmt = GetSortMark(cinfo, 3, 11);
hdri.lParam = HEADERLPARAM(fmt, 3, 11);
break;
case DE_TIME2: {
DWORD timetype;
TIME2HEADERSTRUCT *hdrs;
timetype = *(fmt + 1);
if ( timetype > 2 ) timetype = 2;
hdrs = &Time2Header[timetype];
hdri.cxy = width * GetTime2Len((char *)fmt + 2);
hdri.pszText = (TCHAR *)MessageText(hdrs->label);
hdri.fmt = GetSortMark(cinfo, hdrs->sortlow, hdrs->sorthigh);
hdri.lParam = HEADERLPARAM(fmt, hdrs->sortlow, hdrs->sorthigh);
break;
}
case DE_COLUMN:
case DE_MEMOEX: {
WORD itemindex;
if ( *fmt == DE_COLUMN ){
hdri.cxy = width * ((DISPFMT_COLUMN *)(fmt + 1))->width;
hdri.pszText = ((DISPFMT_COLUMN *)(fmt + 1))->name;
hdri.cchTextMax = tstrlen32(hdri.pszText);
itemindex = ((DISPFMT_COLUMN *)(fmt + 1))->itemindex;
if ( itemindex == DFC_UNDEF ){ // 未初期化
itemindex = ((DISPFMT_COLUMN *)(fmt + 1))->itemindex =
GetColumnExtItemIndex(cinfo,
((DISPFMT_COLUMN *)(fmt + 1))->name);
}
}else{
hdri.cxy = width * *(fmt + 1);
itemindex = (WORD)(DFC_COMMENTEX_MAX - (*(fmt + 2) - 1));
}
if ( cinfo->sort_columnindex == (DWORD)itemindex ){
if ( cinfo->sort_last.mode.dat[0] == SORT_COLUMN_UP ){
setflag(hdri.fmt, HDF_SORTUP);
}else if ( cinfo->sort_last.mode.dat[0] == SORT_COLUMN_DOWN){
setflag(hdri.fmt, HDF_SORTDOWN);
}
}
hdri.lParam =
TMAKELPARAM( (0x8000 | itemindex), fmt - cinfo->celF.fmt);
break;
}
case DE_MODULE:
hdri.cxy = width * *(fmt + 1);
break;
case DE_NEWLINE:
return;
default:
hdri.cxy = 0;
break;
}
fmt += GetDispFormatSkip(fmt);
if ( hdri.cxy ){
if ( UseCheckBox && (hdri.cxy > (width * 4)) ){
setflag(hdri.fmt, HDF_CHECKBOX);
if ( cinfo->e.markC ) setflag(hdri.fmt, HDF_CHECKED);
UseCheckBox = FALSE;
}
SendMessage(cinfo->hHeaderWnd,
HDM_INSERTITEM, index++, (LPARAM)&hdri);
}
}
}
void CalcClickWidth(PPC_APPINFO *cinfo)
{
BYTE *fmt;
int width = 0;
int tmpfontX = cinfo->fontX;
fmt = cinfo->celF.fmt;
for (;;){
BYTE fmtdata;
int attr;
fmtdata = *fmt;
if ( fmtdata == DE_END ) break;
attr = DispAttributeTable[fmtdata];
if ( attr & DE_ATTR_WIDTH_L ){
width += *(fmt + 1) * tmpfontX;
}else if ( attr & DE_ATTR_WIDTH ) switch( fmtdata ){
case DE_IMAGE: // 画像
width += *(fmt + 1);
break;
case DE_ICON: // アイコン
case DE_CHECK: // チェック
case DE_CHECKBOX: // チェックボックス
width += 2 * tmpfontX;
break;
case DE_MARK: // マーク
case DE_sepline: // 区切り線
width += tmpfontX;
break;
case DE_LFN:
case DE_SFN:
case DE_LFN_MUL:
case DE_LFN_LMUL:
case DE_LFN_EXT:
case DE_SFN_EXT:
{
int filew, extw;
filew = *(fmt + 1);
extw = *(fmt + 2);
if ( extw >= 0xff ) extw = 0;
width += (filew + extw) * tmpfontX;
if ( filew ){
if ( (DWORD)width < cinfo->CellNameWidth ){
cinfo->CellNameWidth = width;
}
return;
}
break;
}
case DE_COLUMN:
width += *(fmt + 1 + sizeof(DWORD) + sizeof(BYTE));
fmt += GetDispFormatSkip_column(fmt);
continue;
case DE_NEWLINE: // ファイル名がないまま行末に到達→次の行検索
width = 0;
break;
case DE_pix_Lgap:
width = *(WORD *)(fmt + 1) / tmpfontX;
break;
case DE_chr_Lgap:
width = *(fmt + 1);
break;
// default: // 未使用
// XMessage(NULL, NULL, XM_DbgDIA, T("%x %d"), fmt, *fmt);
}
fmt += GetDispFormatSkip(fmt);
}
}
// windowwidth の桁数に応じて DE_WIDEW の調整を行う(ステータス行、情報行用)
void FixInfoWideW(XC_CFMT *cfmt, int windowwidthLen)
{
BYTE *fmt;
int cfmtwidth = cfmt->width;
if ( cfmt->fmtbase == NULL ) return;
fmt = cfmt->fmt;
for ( ; ; ){
if ( *fmt == DE_WIDEW ){
int nameLen, cellminLen;
cellminLen = cfmtwidth - (fmt[fmt[3]] + cfmt->ext_width); // ファイル名幅(拡張子除く)を除いた桁数
nameLen = windowwidthLen - cellminLen;
if ( nameLen < fmt[1] ) nameLen = fmt[1]; // 下限チェック
if ( nameLen > DE_FN_ALL_WIDTH ){
cfmt->ext_width = nameLen - DE_FN_ALL_WIDTH;
}else{
cfmt->ext_width = 0;
}
cfmt->width = cellminLen + nameLen;
fmt[fmt[3]] = (BYTE)(nameLen - cfmt->ext_width);
}
if ( *(WORD *)(fmt - DE_HEAD_NEXTLINE_SIZE) == 0 ) break;
fmt += *(WORD *)(fmt - DE_HEAD_NEXTLINE_SIZE); // 次の行をチェックする
}
}
// 窓枠内に収まるようにエントリ表示の桁数を調整する
void FixEntryWideW(PPC_APPINFO *cinfo, int fixPix, int clientPix)
{
BYTE *fmt;
int tmpfontX = cinfo->fontX;
int celFwidth = cinfo->celF.width;
if ( cinfo->celF.fmtbase == NULL ) return;
fmt = cinfo->celF.fmt;
for ( ; ; ){
if ( *fmt == DE_WIDEW ){
int AllPix; // 全体の幅 pixel
int nameLen, minLen;
minLen = celFwidth - (fmt[fmt[3]] + cinfo->celF.ext_width); // ファイル名幅(拡張子除く)を除いた桁数
AllPix = clientPix + tmpfontX;
if ( fmt[2] < DE_FN_ALL_WIDTH ){ // 1行表示でなければ分割数を調整
int VAreaXmax, VAreaXmin;
// 最大桁数のときの分割数
VAreaXmax = clientPix / (((minLen + fmt[2]) * tmpfontX) + fixPix);
// 最小桁数のときの分割数
VAreaXmin = clientPix / (((minLen + fmt[1]) * tmpfontX) + fixPix);
// 最小桁数分割数が最大の時よりも多いなら、分割数を増やせば
// 隙間が埋まる。※ぴったり埋まる時はこのままだと余計に
// 分割するので AllPix - tmpfontX を AllPix2 として採用
if ( VAreaXmin > VAreaXmax ) VAreaXmax++;
if ( VAreaXmax <= 0 ) VAreaXmax = 1;
AllPix = AllPix / VAreaXmax;
}
nameLen = (AllPix - fixPix) / tmpfontX - minLen;
if ( nameLen < fmt[1] ) nameLen = fmt[1]; // 下限チェック
if ( nameLen > DE_FN_ALL_WIDTH ){
cinfo->celF.ext_width = nameLen - DE_FN_ALL_WIDTH;
}else{
cinfo->celF.ext_width = 0;
}
cinfo->celF.width = minLen + nameLen;
cinfo->cel.Size.cx = (minLen + nameLen) * tmpfontX + fixPix;
fmt[fmt[3]] = (BYTE)(nameLen - cinfo->celF.ext_width);
}
// if ( fmt < (cinfo->celF.fmt + sizeof(WORD)) ) break;
if ( *(WORD *)(fmt - DE_HEAD_NEXTLINE_SIZE) == 0 ) break;
fmt += *(WORD *)(fmt - DE_HEAD_NEXTLINE_SIZE); // 次の行をチェックする
fixPix = 0; // fixPix は1行目用の補正値
}
if ( cinfo->hHeaderWnd != NULL ) FixHeader(cinfo);
}
void SetScrollBar(PPC_APPINFO *cinfo, int scroll)
{
SCROLLINFO sinfo;
// スクロールバー設定 -----------------
cinfo->winOmax = (cinfo->e.cellIMax - 1) / cinfo->cel.Area.cy;
if ( (cinfo->winOmax < 0) || (cinfo->cel.Area.cx > cinfo->winOmax) ){
cinfo->winOmax = 0; // 1画面に納まる
}else{
if ( cinfo->cel.Area.cx > 2 ) cinfo->winOmax -= cinfo->cel.Area.cx - 2;
}
sinfo.nPage = cinfo->cel.Area.cx * cinfo->cel.Area.cy;
sinfo.nPos = cinfo->cellWMin;
if ( scroll ){
sinfo.nMax = cinfo->e.cellIMax - 1;
}else{
sinfo.nMax = (cinfo->winOmax + ((cinfo->cel.Area.cx < 2) ?
1 : cinfo->cel.Area.cx - 1)) * cinfo->cel.Area.cy - 1;
}
if ( (sinfo.nPage != cinfo->oldspos.nPage) ||
(sinfo.nPos != cinfo->oldspos.nPos) ||
(sinfo.nMax != cinfo->oldspos.nMax) ){
int bartype;
if ( cinfo->hScrollBarWnd != NULL ){
if ( (sinfo.nPage != cinfo->oldspos.nPage) ||
(sinfo.nMax != cinfo->oldspos.nMax) ){
ShowWindow(cinfo->hScrollBarWnd,
// ※sinfo.nMax は通常正の範囲
( (sinfo.nPage > (UINT)sinfo.nMax) ||
(cinfo->X_win & XWIN_HIDESCROLL)) ?
SW_HIDE : SW_SHOWNOACTIVATE);
}
}
cinfo->oldspos.nPage = sinfo.nPage;
cinfo->oldspos.nPos = sinfo.nPos;
cinfo->oldspos.nMax = sinfo.nMax;
if ( cinfo->X_win & XWIN_HIDESCROLL ) return;
sinfo.cbSize = sizeof(sinfo);
sinfo.fMask = SIF_PAGE | SIF_POS | SIF_RANGE;
sinfo.nMin = 0;
if ( cinfo->hScrollBarWnd != NULL ){
bartype = SB_CTL;
}else{
bartype = cinfo->ScrollBarHV;
}
SetScrollInfo(cinfo->hScrollTargetWnd, bartype, &sinfo, TRUE);
}
}
/*=============================================================================
InitCli - クライアント領域の情報再設定
=============================================================================*/
const TCHAR SampleText_Time[] = T("00-00-00 00:00:00.000");
void InitCli(PPC_APPINFO *cinfo)
{
int clientPix, fixX = 0, tmpfontX = cinfo->fontX;
int iconsize;
if ( TouchMode & TOUCH_LARGEHEIGHT ){
int TouchHeight;
int orgY = cinfo->fontY - cinfo->X_lspc;
TouchHeight = CalcMinDpiSize(cinfo->FontDPI, X_tous[tous_ITEMSIZE]);
if ( (cinfo->fontY * cinfo->celF.height) < TouchHeight ){
cinfo->fontY = (TouchHeight + cinfo->celF.height - 1) / cinfo->celF.height;
cinfo->X_lspc = cinfo->fontY - orgY;
}else if ( cinfo->X_lspc > cinfo->X_lspcOrg ){
if ( ((orgY + cinfo->X_lspcOrg) * cinfo->celF.height) >= TouchHeight ){
cinfo->X_lspc = cinfo->X_lspcOrg;
cinfo->fontY = orgY + cinfo->X_lspc;
}
}
}
cinfo->DrawTargetFlags = DRAWT_ALL;
// 各表示領域を区分けする -------------
// キャプション/ラベル
cinfo->BoxStatus.left = 0;
cinfo->BoxStatus.top = (cinfo->combo && !(X_combos[0] & CMBS_NOCAPTION)) ? cinfo->fontY : cinfo->docks.t.client.bottom;
// ステータス行
cinfo->BoxStatus.right = cinfo->wnd.Area.cx;
cinfo->BoxStatus.bottom =
((cinfo->X_win & XWIN_NOSTATUS) ||
(cinfo->docks.t.hStatusWnd != NULL) ||
(cinfo->docks.b.hStatusWnd != NULL))
? cinfo->BoxStatus.top :
cinfo->BoxStatus.top + cinfo->fontY * cinfo->stat.height;
if ( cinfo->stat.attr & DE_ATTR_WIDEW ){
FixInfoWideW(&cinfo->stat, (cinfo->BoxStatus.right - cinfo->BoxStatus.left) / tmpfontX + 1);
}
// 情報行
cinfo->BoxInfo.left = 0;
cinfo->BoxInfo.right = cinfo->BoxStatus.right;
cinfo->BoxInfo.top = cinfo->BoxStatus.bottom;
if ( (cinfo->combo && (X_combos[0] & CMBS_COMMONINFO)) ||
(cinfo->X_win & XWIN_NOINFO) ||
(cinfo->docks.t.hInfoWnd != NULL) ||
(cinfo->docks.b.hInfoWnd != NULL) ){
RECT box;
int width;
cinfo->BoxInfo.bottom = cinfo->BoxInfo.top;
if ( cinfo->combo && (X_combos[0] & CMBS_COMMONINFO) ){
width = Combo.Panes.box.right;
}else if ( cinfo->docks.t.hInfoWnd != NULL ){
GetClientRect(cinfo->docks.t.hInfoWnd, &box);
width = box.right;
}else if ( cinfo->docks.b.hInfoWnd != NULL ){
GetClientRect(cinfo->docks.t.hInfoWnd, &box);
width = box.right;
}else{
width = cinfo->wnd.Area.cx;
}
width = (width - (cinfo->iconR + tmpfontX - 1)) / tmpfontX;
if ( cinfo->inf1.attr & DE_ATTR_WIDEW ){
FixInfoWideW(&cinfo->inf1, width);
}
if ( cinfo->inf2.attr & DE_ATTR_WIDEW ){
FixInfoWideW(&cinfo->inf2, width);
}
}else{
int height = cinfo->fontY * (cinfo->inf1.height + cinfo->inf2.height);
if ( height < (cinfo->XC_ifix_size.cy + 1) ){
height = cinfo->XC_ifix_size.cy + 1;
}
cinfo->BoxInfo.bottom = cinfo->BoxInfo.top + height;
if ( cinfo->inf1.attr & DE_ATTR_WIDEW ){
FixInfoWideW(&cinfo->inf1, (cinfo->BoxInfo.right - cinfo->BoxInfo.left - cinfo->iconR) / tmpfontX + 1);
}
if ( cinfo->inf2.attr & DE_ATTR_WIDEW ){
FixInfoWideW(&cinfo->inf2, (cinfo->BoxInfo.right - cinfo->BoxInfo.left - cinfo->iconR) / tmpfontX + 1);
}
}
// エントリ行など
cinfo->BoxEntries.left = cinfo->TreeX;
cinfo->BoxEntries.top = cinfo->BoxInfo.bottom;
cinfo->BoxEntries.right = cinfo->BoxStatus.right;
cinfo->BoxEntries.bottom= cinfo->wnd.Area.cy - cinfo->docks.b.client.bottom;
if ( cinfo->hToolBarWnd != NULL ){
cinfo->BoxEntries.top += cinfo->ToolbarHeight;
}
cinfo->BoxEntries.top += cinfo->HeaderHeight;
if ( cinfo->hScrollBarWnd != NULL ){
if ( cinfo->X_win & XWIN_HIDESCROLL ){ // 非表示
cinfo->ScrollBarSize = 0;
}else if ( cinfo->ScrollBarHV == SB_HORZ ){ // 水平
cinfo->ScrollBarSize = GetSystemMetrics(SM_CYHSCROLL);
cinfo->BoxEntries.bottom -= cinfo->ScrollBarSize;
if ( cinfo->BoxEntries.bottom < cinfo->BoxEntries.top ){
cinfo->BoxEntries.bottom = cinfo->BoxEntries.top;
}
}else{ // 垂直
cinfo->ScrollBarSize = GetSystemMetrics(SM_CXVSCROLL);
cinfo->BoxEntries.right -= cinfo->ScrollBarSize;
if ( cinfo->BoxEntries.right < cinfo->BoxEntries.left ){
cinfo->BoxEntries.right = cinfo->BoxEntries.left;
}
}
cinfo->ScrollBarY = cinfo->BoxEntries.bottom;
}
cinfo->cel.Size.cx = tmpfontX * cinfo->celF.width;
cinfo->cel.Size.cy = cinfo->fontY * cinfo->celF.height;
if ( UsePFont ){ // 可変長フォント用補正
SIZE boxsize;
BYTE *fmt;
HDC hDC = GetDC(cinfo->info.hWnd);
HGDIOBJ hOldFont;
hOldFont = SelectObject(hDC, cinfo->hBoxFont);
fmt = cinfo->celF.fmt;
for ( ;; ){
BYTE fmtdata;
fmtdata = *fmt;
if ( (fmtdata == DE_END) || (fmtdata == DE_NEWLINE) ) break;
if ( fmtdata == DE_TIME1 ){
BYTE timelen = *(fmt + 1);
int timefixX;
if ( timelen > TSIZEOFSTR(SampleText_Time) ){
timelen = TSIZEOFSTR(SampleText_Time);
}
GetTextExtentPoint32(hDC, SampleText_Time, timelen, &boxsize);
timefixX = boxsize.cx - (tmpfontX * timelen);
fixX += timefixX;
}else if ( fmtdata == DE_SIZE1 ){
// fixX += ((7 - 1) * cinfo->fontNumX) + tmpfontX - (tmpfontX * 7);
fixX += (cinfo->fontNumX - tmpfontX) * (7 - 1);
}else if ( (fmtdata == DE_SIZE2) || (fmtdata == DE_SIZE3) || (fmtdata == DE_SIZE4) ){
BYTE sizelen = *(fmt + 1);
if ( sizelen > 0 ){
// fixX += ((sizelen - 1) * cinfo->fontNumX) + tmpfontX - (tmpfontX * sizelen);
fixX += (cinfo->fontNumX - tmpfontX) * (sizelen - 1);
}
}
fmt += GetDispFormatSkip(fmt);
}
SelectObject(hDC, hOldFont);
ReleaseDC(cinfo->info.hWnd, hDC);
cinfo->cel.Size.cx += fixX;
}
{ // cinfo->cel.Size.cy の決定と、アイコンの補正
BYTE *fmt;
fmt = cinfo->celF.fmt;
if ( (*fmt == DE_WIDEV) || (*fmt == DE_WIDEW) ) fmt += DE_WIDEV_SIZE;
if ( *fmt == DE_IMAGE ){
#if 0 // 丁寧な行数決定
int imgY;
imgY = cinfo->fontY * fmt[2];
if ( cinfo->cel.Size.cy < imgY ) cinfo->cel.Size.cy = imgY;
#else
cinfo->cel.Size.cy = cinfo->fontY * fmt[2];
#endif
}else if ( *fmt == DE_ICON2 ){ // アイコン2 の幅補正
int iconLen, iconFix;
iconsize = fmt[1];
if ( cinfo->X_textmag != 100 ){
iconsize = (iconsize * cinfo->X_textmag) / 100;
}
if ( cinfo->FontDPI != DEFAULT_WIN_DPI ){
iconsize = (iconsize * cinfo->FontDPI) / DEFAULT_WIN_DPI;
}
iconsize += ICONBLANK;
if ( cinfo->cel.Size.cy < iconsize ) cinfo->cel.Size.cy = iconsize;
iconLen = GetIcon2Len(fmt[1]);
iconFix = iconsize - iconLen * tmpfontX;
cinfo->cel.Size.cx += iconFix;
fixX += iconFix;
}
}
if ( cinfo->cel.Size.cy <= 0 ) cinfo->cel.Size.cy = 1;
// 窓の幅を取得 -----------------------
clientPix = cinfo->BoxEntries.right - cinfo->BoxEntries.left;
if ( clientPix <= 0 ){
cinfo->cel.VArea.cx = cinfo->cel.Area.cx = 1;
}else{
if ( cinfo->celF.attr & DE_ATTR_WIDEW ){ // 窓の幅に合わせて桁数調整
FixEntryWideW(cinfo, fixX, clientPix);
}
if ( cinfo->cel.Size.cx <= 0 ) cinfo->cel.Size.cx = 1;
cinfo->cel.Area.cx = (clientPix + tmpfontX) / cinfo->cel.Size.cx;
if ( cinfo->cel.Area.cx <= 0 ) cinfo->cel.Area.cx = 1;
cinfo->cel.VArea.cx = cinfo->list.orderZ ?
cinfo->cel.Area.cx : (clientPix - 1) / cinfo->cel.Size.cx + 1;
}