-
Notifications
You must be signed in to change notification settings - Fork 1
/
Edittime.cpp
1228 lines (1042 loc) · 29.4 KB
/
Edittime.cpp
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
// ============================================================================
//
// This file contains routines that are handled only during the Edittime,
// under the Frame and Event editors.
//
// Including creating, display, and setting up your object.
//
// ============================================================================
#include "common.h"
// --------------------
// Properties
// --------------------
PROPS_IDS_START()
// PROPID_TEXT1,
// PROPID_NUM1,
PROPS_IDS_END()
PROPS_DATA_START()
// PropData_EditString(PROPID_TEXT1,PSTR("Text item"),PSTR("I'm more textual than you")),
// PropData_EditNumber(PROPID_NUM1,PSTR("Number item"),PSTR("I'm more numeric than text")),
PROPS_DATA_END()
// --------------------
// Debugger
// --------------------
DEBUGGER_IDS_START()
// DB_CURRENTSTRING,
DEBUGGER_IDS_END()
DEBUGGER_ITEMS_START()
// DB_CURRENTSTRING,
// DB_CURRENTSTRING|DB_EDITABLE,
// DB_CURRENTVALUE|DB_EDITABLE,
// DB_CURRENTCHECK,
// DB_CURRENTCOMBO,
DEBUGGER_ITEMS_END()
// --------------------
// GetProperties
// --------------------
// Inserts properties into the properties of the object.
//
BOOL WINAPI DLLExport GetProperties(LPMV mV, LPEDATA edPtr, BOOL bMasterItem)
{
#ifndef RUN_ONLY
mvInsertProps(mV, edPtr, Properties, PROPID_TAB_GENERAL, TRUE);
#endif // !RUN_ONLY
// OK
return TRUE;
}
// --------------------
// ReleaseProperties
// --------------------
// Called when the properties are removed from the property window.
//
void WINAPI DLLExport ReleaseProperties(LPMV mV, LPEDATA edPtr, BOOL bMasterItem)
{
#ifndef RUN_ONLY
// Write your code here
#endif // !RUN_ONLY
}
// --------------------
// GetPropCreateParam
// --------------------
// Called when a property is initialized and its creation parameter is NULL (in the PropData).
// Allows you, for example, to change the content of a combobox property according to specific settings in the EDITDATA structure.
//
LPARAM WINAPI DLLExport GetPropCreateParam(LPMV mV, LPEDATA edPtr, UINT nPropID)
{
#ifndef RUN_ONLY
// Example
// -------
// if ( nPropID == PROPID_COMBO )
// {
// switch (edPtr->sType)
// {
// case TYPE1:
// return (LPARAM)ComboList1;
// case TYPE2:
// return (LPARAM)ComboList2;
// }
// }
#endif // !RUN_ONLY
return NULL;
}
// ----------------------
// ReleasePropCreateParam
// ----------------------
// Called after a property has been initialized.
// Allows you, for example, to free memory allocated in GetPropCreateParam.
//
void WINAPI DLLExport ReleasePropCreateParam(LPMV mV, LPEDATA edPtr, UINT nPropID, LPARAM lParam)
{
#ifndef RUN_ONLY
#endif // !RUN_ONLY
}
// --------------------
// GetPropValue
// --------------------
// Returns the value of properties that have a value.
// Note: see GetPropCheck for checkbox properties
//
LPVOID WINAPI DLLExport GetPropValue(LPMV mV, LPEDATA edPtr, UINT nPropID)
{
#ifndef RUN_ONLY
// Example
// -------
// switch (nPropID) {
//
// // Returns a color.
// case PROPID_COLOR:
// return new CPropDWordValue(edPtr->dwColor);
//
// // Returns a string
// case PROPID_TEXT:
// return new CPropDataValue(&edPtr->szText[0]);
//
// // Returns the value of the combo box
// case PROPID_COMBO:
// return new CPropDWordValue(edPtr->nComboIndex);
// }
#endif // !RUN_ONLY
return NULL;
}
// --------------------
// GetPropCheck
// --------------------
// Returns the checked state of properties that have a check box.
//
BOOL WINAPI DLLExport GetPropCheck(LPMV mV, LPEDATA edPtr, UINT nPropID)
{
#ifndef RUN_ONLY
// Example
// -------
// switch (nPropID) {
//
// // Return 0 (unchecked) or 1 (checked)
// case PROPID_CHECK:
// return edPtr->nCheck;
// }
#endif // !RUN_ONLY
return 0; // Unchecked
}
// --------------------
// SetPropValue
// --------------------
// This routine is called by MMF after a property has been modified.
//
void WINAPI DLLExport SetPropValue(LPMV mV, LPEDATA edPtr, UINT nPropID, LPVOID lParam)
{
#ifndef RUN_ONLY
// Gets the pointer to the CPropValue structure
CPropValue* pValue = (CPropValue*)lParam;
// Example
// -------
// switch (nPropID) {
//
// case PROPID_COMBO:
// // Simply grab the value
// edPtr->nComboIndex = ((CPropDWordValue*)pValue)->m_dwValue;
// break;
// case PROPID_COLOR:
// // Here too, gets the value
// edPtr->dwColor = ((CPropDWordValue*)pValue)->m_dwValue;
// break;
// case PROPID_TEXT:
// {
// // Gets the string
// LPSTR pStr = (LPSTR)((CPropDataValue*)pValue)->m_pData;
//
// // You can simply poke the string if your EDITDATA structure has a fixed size,
// // or have an adaptive size of structure like below
//
// // If the length is different
// if (strlen(pStr)!=strlen(edPtr->text))
// {
// // Asks MMF to reallocate the structure with the new size
// LPEDATA pNewPtr = (LPEDATA)mvReAllocEditData(mV, edPtr, sizeof(EDITDATA)+strlen(pStr));
//
// // If reallocation worked
// if (pNewPtr!=NULL)
// {
// // Copy the string
// edPtr=pNewPtr;
// strcpy(edPtr->text, pStr);
// }
// }
// else
// {
// // Same size : simply copy
// strcpy(edPtr->text, pStr);
// }
// }
// break;
// }
// You may want to have your object redrawn in the frame editor after the modifications,
// in this case, just call this function
// mvInvalidateObject(mV, edPtr);
#endif // !RUN_ONLY
}
// --------------------
// SetPropCheck
// --------------------
// This routine is called by MMF when the user modifies a checkbox in the properties.
//
void WINAPI DLLExport SetPropCheck(LPMV mV, LPEDATA edPtr, UINT nPropID, BOOL nCheck)
{
#ifndef RUN_ONLY
// Example
// -------
// switch (nPropID)
// {
// case PROPID_CHECK:
// edPtr->nCheck = nCheck;
// mvInvalidateObject(mV, edPtr);
// mvRefreshProp(mV, edPtr, PROPID_COMBO);
// break;
// }
#endif // !RUN_ONLY
}
// --------------------
// EditProp
// --------------------
// This routine is called when the user clicks the button of a Button or EditButton property.
//
BOOL WINAPI DLLExport EditProp(LPMV mV, LPEDATA edPtr, UINT nPropID)
{
#ifndef RUN_ONLY
// Example
// -------
/*
if (nPropID==PROPID_EDITCONTENT)
{
if ( EditObject(mV, NULL, NULL, edPtr) )
return TRUE;
}
*/
#endif // !RUN_ONLY
return FALSE;
}
// --------------------
// IsPropEnabled
// --------------------
// This routine returns the enabled state of a property.
//
BOOL WINAPI IsPropEnabled(LPMV mV, LPEDATA edPtr, UINT nPropID)
{
#ifndef RUN_ONLY
// Example
// -------
/*
switch (nPropID) {
case PROPID_CHECK:
return (edPtr->nComboIndex != 0);
}
*/
#endif // !RUN_ONLY
return TRUE;
}
// ============================================================================
//
// TEXT PROPERTIES
//
// ============================================================================
// --------------------
// GetTextCaps
// --------------------
// Return the text capabilities of the object under the frame editor.
//
DWORD WINAPI DLLExport GetTextCaps(mv _far *mV, LPEDATA edPtr)
{
return 0; // (TEXT_ALIGN_LEFT|TEXT_ALIGN_HCENTER|TEXT_ALIGN_RIGHT|TEXT_ALIGN_TOP|TEXT_ALIGN_VCENTER|TEXT_ALIGN_BOTTOM|TEXT_FONT|TEXT_COLOR);
}
// --------------------
// GetTextFont
// --------------------
// Return the font used the object.
// Note: the pStyle and cbSize parameters are obsolete and passed for compatibility reasons only.
//
BOOL WINAPI DLLExport GetTextFont(mv _far *mV, LPEDATA edPtr, LPLOGFONT plf, LPSTR pStyle, UINT cbSize)
{
#if !RUN_ONLY
// Example: copy LOGFONT structure from EDITDATA
// memcpy(plf, &edPtr->m_lf, sizeof(LOGFONT));
#endif // !RUN_ONLY
return TRUE;
}
// --------------------
// SetTextFont
// --------------------
// Change the font used the object.
// Note: the pStyle parameter is obsolete and passed for compatibility reasons only.
//
BOOL WINAPI DLLExport SetTextFont(mv _far *mV, LPEDATA edPtr, LPLOGFONT plf, LPCSTR pStyle)
{
#if !RUN_ONLY
// Example: copy LOGFONT structure to EDITDATA
// memcpy(&edPtr->m_lf, plf, sizeof(LOGFONT));
#endif // !RUN_ONLY
return TRUE;
}
// --------------------
// GetTextClr
// --------------------
// Get the text color of the object.
//
COLORREF WINAPI DLLExport GetTextClr(mv _far *mV, LPEDATA edPtr)
{
// Example
return 0; // edPtr->fontColor;
}
// --------------------
// SetTextClr
// --------------------
// Set the text color of the object.
//
void WINAPI DLLExport SetTextClr(mv _far *mV, LPEDATA edPtr, COLORREF color)
{
// Example
//edPtr->fontColor = color;
}
// --------------------
// GetTextAlignment
// --------------------
// Get the text alignment of the object.
//
DWORD WINAPI DLLExport GetTextAlignment(mv _far *mV, LPEDATA edPtr)
{
DWORD dw = 0;
#if !RUN_ONLY
// Example
// -------
/* if ( (edPtr->eData.dwFlags & ALIGN_LEFT) != 0 )
dw |= TEXT_ALIGN_LEFT;
if ( (edPtr->eData.dwFlags & ALIGN_HCENTER) != 0 )
dw |= TEXT_ALIGN_HCENTER;
if ( (edPtr->eData.dwFlags & ALIGN_RIGHT) != 0 )
dw |= TEXT_ALIGN_RIGHT;
if ( (edPtr->eData.dwFlags & ALIGN_TOP) != 0 )
dw |= TEXT_ALIGN_TOP;
if ( (edPtr->eData.dwFlags & ALIGN_VCENTER) != 0 )
dw |= TEXT_ALIGN_VCENTER;
if ( (edPtr->eData.dwFlags & ALIGN_BOTTOM) != 0 )
dw |= TEXT_ALIGN_BOTTOM;
*/
#endif // !RUN_ONLY
return dw;
}
// --------------------
// SetTextAlignment
// --------------------
// Set the text alignment of the object.
//
void WINAPI DLLExport SetTextAlignment(mv _far *mV, LPEDATA edPtr, DWORD dwAlignFlags)
{
#if !RUN_ONLY
// Example
// -------
/* DWORD dw = edPtr->eData.dwFlags;
if ( (dwAlignFlags & TEXT_ALIGN_LEFT) != 0 )
dw = (dw & ~(ALIGN_LEFT|ALIGN_HCENTER|ALIGN_RIGHT)) | ALIGN_LEFT;
if ( (dwAlignFlags & TEXT_ALIGN_HCENTER) != 0 )
dw = (dw & ~(ALIGN_LEFT|ALIGN_HCENTER|ALIGN_RIGHT)) | ALIGN_HCENTER;
if ( (dwAlignFlags & TEXT_ALIGN_RIGHT) != 0 )
dw = (dw & ~(ALIGN_LEFT|ALIGN_HCENTER|ALIGN_RIGHT)) | ALIGN_RIGHT;
if ( (dwAlignFlags & TEXT_ALIGN_TOP) != 0 )
dw = (dw & ~(ALIGN_TOP|ALIGN_VCENTER|ALIGN_BOTTOM)) | ALIGN_TOP;
if ( (dwAlignFlags & TEXT_ALIGN_VCENTER) != 0 )
dw = (dw & ~(ALIGN_TOP|ALIGN_VCENTER|ALIGN_BOTTOM)) | ALIGN_VCENTER;
if ( (dwAlignFlags & TEXT_ALIGN_BOTTOM) != 0 )
dw = (dw & ~(ALIGN_TOP|ALIGN_VCENTER|ALIGN_BOTTOM)) | ALIGN_BOTTOM;
edPtr->eData.dwFlags = dw;
*/
#endif // !RUN_ONLY
}
// -----------------
// BmpToImg
// -----------------
// Converts an image from the resource to an image displayable under MMF2
// Not used in this template, but it is a good example on how to create
// an image.
//
/*
WORD BmpToImg(int bmID, npAppli idApp, short HotX = 0, short HotY = 0, short ActionX = 0, short ActionY = 0)
{
Img ifo;
WORD img;
HRSRC hs;
HGLOBAL hgBuf;
LPBYTE adBuf;
LPBITMAPINFOHEADER adBmi;
img = 0;
if ((hs = FindResource(hInstLib, MAKEINTRESOURCE(bmID), RT_BITMAP)) != NULL)
{
if ((hgBuf = LoadResource(hInstLib, hs)) != NULL)
{
if ((adBuf = (LPBYTE)LockResource(hgBuf)) != NULL)
{
adBmi = (LPBITMAPINFOHEADER)adBuf;
ifo.imgXSpot = HotX;
ifo.imgYSpot = HotY;
ifo.imgXAction = ActionX;
ifo.imgYAction = ActionY;
if (adBmi->biBitCount > 4)
RemapDib((LPBITMAPINFO)adBmi, idApp, NULL);
img = (WORD)DibToImage(idApp, &ifo, adBmi);
UnlockResource(hgBuf);
}
FreeResource(hgBuf);
}
}
return img;
}
*/
// ============================================================================
//
// ROUTINES USED UNDER FRAME EDITOR
//
// ============================================================================
// --------------------
// MakeIcon
// --------------------
// Called once object is created or modified, just after setup.
//
// Note: this function is optional. If it's not defined in your extension,
// MMF2 will load the EXO_ICON bitmap if it's defined in your resource file.
//
// If you need to draw the icon manually, remove the comments around this function and in the .def file.
//
/*
int WINAPI DLLExport MakeIconEx ( mv _far *mV, cSurface* pIconSf, LPSTR lpName, fpObjInfo oiPtr, LPEDATA edPtr )
{
int error = -1;
#ifndef RUN_ONLY
if ( pIconSf->LoadImage(hInstLib, EXO_ICON) != 0 )
error = 0;
#endif // !RUN_ONLY
return error;
}
*/
// --------------------
// CreateObject
// --------------------
// Called when you choose "Create new object". It should display the setup box
// and initialize everything in the datazone.
int WINAPI DLLExport CreateObject(mv _far *mV, fpLevObj loPtr, LPEDATA edPtr)
{
#ifndef RUN_ONLY
// Do some rSDK stuff
#include "rCreateObject.h"
// Set default object settings
// edPtr->swidth = 32;
// edPtr->sheight = 32;
return 0; // No error
#endif // !RUN_ONLY
// Error
return -1;
}
// --------------------
// EditObject
// --------------------
// One of the option from the menu has been selected, and not a default menu option
// automatically handled by MMF2: this routine is then called.
//
BOOL WINAPI EditObject (mv _far *mV, fpObjInfo oiPtr, fpLevObj loPtr, LPEDATA edPtr)
{
#ifndef RUN_ONLY
return TRUE;
#endif // !RUN_ONLY
// Error
return FALSE;
}
// --------------------
// SetEditSize
// --------------------
// Called by MMF2 when the object has been resized
//
// Note: remove the comments if your object can be resized (and remove the comments in the .def file)
/*
BOOL WINAPI SetEditSize(LPMV mv, LPEDATA edPtr, int cx, int cy)
{
#ifndef RUN_ONLY
edPtr->swidth = cx;
edPtr->sheight = cy;
#endif // !RUN_ONLY
return TRUE; // OK
}
*/
// --------------------
// PutObject
// --------------------
// Called when each individual object is dropped in the frame.
//
void WINAPI DLLExport PutObject(mv _far *mV, fpLevObj loPtr, LPEDATA edPtr, ushort cpt)
{
#ifndef RUN_ONLY
#endif // !RUN_ONLY
}
// --------------------
// RemoveObject
// --------------------
// Called when each individual object is removed from the frame.
//
void WINAPI DLLExport RemoveObject(mv _far *mV, fpLevObj loPtr, LPEDATA edPtr, ushort cpt)
{
#ifndef RUN_ONLY
// Is the last object removed?
if (0 == cpt)
{
// Do whatever necessary to remove our data
}
#endif // !RUN_ONLY
}
// --------------------
// DuplicateObject
// --------------------
// Called when an object is created from another one (note: should be called CloneObject instead...)
//
void WINAPI DLLExport DuplicateObject(mv __far *mV, fpObjInfo oiPtr, LPEDATA edPtr)
{
#ifndef RUN_ONLY
#endif // !RUN_ONLY
}
// --------------------
// GetObjectRect
// --------------------
// Returns the size of the rectangle of the object in the frame editor.
//
void WINAPI DLLExport GetObjectRect(mv _far *mV, RECT FAR *rc, fpLevObj loPtr, LPEDATA edPtr)
{
#ifndef RUN_ONLY
rc->right = rc->left + 32; // edPtr->swidth;
rc->bottom = rc->top + 32; // edPtr->sheight;
#endif // !RUN_ONLY
return;
}
// --------------------
// EditorDisplay
// --------------------
// Displays the object under the frame editor
//
// Note: this function is optional. If it's not defined in your extension,
// MMF2 will load and display the EXO_IMAGE bitmap if it's defined in your resource file.
//
// If you need to draw the icon manually, remove the comments around this function and in the .def file.
//
/*
void WINAPI DLLExport EditorDisplay(mv _far *mV, fpObjInfo oiPtr, fpLevObj loPtr, LPEDATA edPtr, RECT FAR *rc)
{
#ifndef RUN_ONLY
// This is a simple case of drawing an image onto MMF's frame editor window
// First, we must get a pointer to the surface used by the frame editor
LPSURFACE ps = WinGetSurface((int)mV->mvIdEditWin);
if ( ps != NULL ) // Do the following if this surface exists
{
int x = rc->left; // get our boundaries
int y = rc->top;
int w = rc->right-rc->left;
int h = rc->bottom-rc->top;
cSurface is; // New surface variable for us to use
is.Create(4, 4, ps); // Create a surface implementation from a prototype (frame editor win)
is.LoadImage(hInstLib, EXO_IMAGE, LI_REMAP); // Load our bitmap from the resource,
// and remap palette if necessary
is.Blit(*ps, x, y, BMODE_TRANSP, BOP_COPY, 0); // Blit the image to the frame editor surface!
// This actually blits (or copies) the whole of our surface onto the frame editor's surface
// at a specified position.
// We could use different image effects when we copy, e.g. invert, AND, OR, XOR,
// blend (semi-transparent, the 6th param is amount of transparency)
// You can 'anti-alias' with the 7th param (default=0 or off)
}
#endif // !RUN_ONLY
}
*/
// --------------------
// IsTransparent
// --------------------
// This routine tells MMF2 if the mouse pointer is over a transparent zone of the object.
//
extern "C" BOOL WINAPI DLLExport IsTransparent(mv _far *mV, fpLevObj loPtr, LPEDATA edPtr, int dx, int dy)
{
#ifndef RUN_ONLY
// Write your code here
#endif // !RUN_ONLY
return FALSE;
}
// --------------------
// PrepareToWriteObject
// --------------------
// Just before writing the datazone when saving the application, MMF2 calls this routine.
//
void WINAPI DLLExport PrepareToWriteObject(mv _far *mV, LPEDATA edPtr, fpObjInfo adoi)
{
#ifndef RUN_ONLY
// Write your code here
#endif // !RUN_ONLY
}
// --------------------
// GetFilters
// --------------------
//
BOOL WINAPI GetFilters(LPMV mV, LPEDATA edPtr, DWORD dwFlags, LPVOID pReserved)
{
#ifndef RUN_ONLY
// If your extension uses image filters
// if ( (dwFlags & GETFILTERS_IMAGES) != 0 )
// return TRUE;
// If your extension uses sound filters
// if ( (dwFlags & GETFILTERS_SOUNDS) != 0 )
// return TRUE;
#endif // RUN_ONLY
return FALSE;
}
// --------------------
// UsesFile
// --------------------
// Triggers when a file is dropped onto the frame
// Return TRUE if you can create an object from the given file
//
BOOL WINAPI DLLExport UsesFile (LPMV mV, LPSTR fileName)
{
BOOL r = FALSE;
#ifndef RUN_ONLY
// Example: return TRUE if file extension is ".txt"
/*
LPSTR ext, npath;
if ( fileName != NULL )
{
if ( (ext=(LPSTR)malloc(_MAX_EXT)) != NULL )
{
if ( (npath=(LPSTR)malloc(_MAX_PATH)) != NULL )
{
strcpy(npath, fileName);
_splitpath(npath, NULL, NULL, NULL, ext);
if ( _stricmp(ext, ".txt") == 0 )
r = TRUE;
free(npath);
}
free(ext);
}
} */
#endif // !RUN_ONLY
return r;
}
// --------------------
// CreateFromFile
// --------------------
// Creates a new object from file
//
void WINAPI DLLExport CreateFromFile (LPMV mV, LPSTR fileName, LPEDATA edPtr)
{
#ifndef RUN_ONLY
// Initialize your extension data from the given file
// edPtr->swidth = 32;
// edPtr->sheight = 32;
// Example: store the filename
// strcpy(edPtr->myFileName, fileName);
#endif // !RUN_ONLY
}
// ============================================================================
//
// ROUTINES USED UNDER EVENT / TIME / STEP-THROUGH EDITOR
// You should not need to change these routines
//
// ============================================================================
// -----------------
// menucpy
// -----------------
// Internal routine used later, copy one menu onto another
//
#ifndef RUN_ONLY
void menucpy(HMENU hTargetMenu, HMENU hSourceMenu)
{
int n, id, nMn;
NPSTR strBuf;
HMENU hSubMenu;
nMn = GetMenuItemCount(hSourceMenu);
strBuf = (NPSTR)LocalAlloc(LPTR, 80);
for (n=0; n<nMn; n++)
{
if (0 == (id = GetMenuItemID(hSourceMenu, n)))
AppendMenu(hTargetMenu, MF_SEPARATOR, 0, 0L);
else
{
GetMenuString(hSourceMenu, n, strBuf, 80, MF_BYPOSITION);
if (id != -1)
AppendMenu(hTargetMenu, GetMenuState(hSourceMenu, n, MF_BYPOSITION), id, strBuf);
else
{
hSubMenu = CreatePopupMenu();
AppendMenu(hTargetMenu, MF_POPUP | MF_STRING, (uint)hSubMenu, strBuf);
menucpy(hSubMenu, GetSubMenu(hSourceMenu, n));
}
}
}
LocalFree((HLOCAL)strBuf);
}
// -----------------
// GetPopupMenu
// -----------------
// Internal routine used later. Returns the first popup from a menu
//
HMENU GetPopupMenu(LPEDATA edPtr,short mn)
{
HMENU hPopup=CreatePopupMenu();
if(mn == MN_CONDITIONS)
menucpy(hPopup,ConditionMenu(edPtr));
else if(mn == MN_ACTIONS)
menucpy(hPopup,ActionMenu(edPtr));
else if(mn == MN_EXPRESSIONS)
menucpy(hPopup,ExpressionMenu(edPtr));
return hPopup;
}
// --------------------
// GetEventInformations
// --------------------
// Internal routine used later. Look for one event in one of the eventInfos array...
// No protection to go faster: you must properly enter the conditions/actions!
//
static LPEVENTINFOS2 GetEventInformations(LPEVENTINFOS2 eiPtr, short code)
{
while(eiPtr->infos.code != code)
eiPtr = EVINFO2_NEXT(eiPtr);
return eiPtr;
}
#endif // !RUN_ONLY
// ----------------------------------------------------
// GetConditionMenu / GetActionMenu / GetExpressionMenu
// ----------------------------------------------------
// Load the condition/action/expression menu from the resource, eventually
// enable or disable some options, and returns it to MMF2.
//
HMENU WINAPI DLLExport GetConditionMenu(mv _far *mV, fpObjInfo oiPtr, LPEDATA edPtr)
{
#ifndef RUN_ONLY
// Check compatibility
return GetPopupMenu(edPtr,MN_CONDITIONS);
#endif // !RUN_ONLY
return NULL;
}
HMENU WINAPI DLLExport GetActionMenu(mv _far *mV, fpObjInfo oiPtr, LPEDATA edPtr)
{
#ifndef RUN_ONLY
// Check compatibility
return GetPopupMenu(edPtr,MN_ACTIONS);
#endif // !RUN_ONLY
return NULL;
}
HMENU WINAPI DLLExport GetExpressionMenu(mv _far *mV, fpObjInfo oiPtr, LPEDATA edPtr)
{
#ifndef RUN_ONLY
// Check compatibility
return GetPopupMenu(edPtr,MN_EXPRESSIONS);
#endif // !RUN_ONLY
return NULL;
}
// -------------------------------------------------------
// GetConditionTitle / GetActionTitle / GetExpressionTitle
// -------------------------------------------------------
// Returns the title of the dialog box displayed when entering
// parameters for the condition, action or expressions, if any.
// Here, we simply return the title of the menu option
//
#ifndef RUN_ONLY
void GetCodeTitle(LPEVENTINFOS2 eiPtr, short code, short param, short mn, LPSTR strBuf, WORD maxLen)
{
HMENU hMn;
// Finds event in array
eiPtr=GetEventInformations(eiPtr, code);
// If a special string is to be returned
short strID = EVINFO2_PARAMTITLE(eiPtr, param);
if(strID) {
switch(mn) {
case MN_CONDITIONS:
if(code>=0&&code<(short)Conditions.size()) {
if(param>=0&¶m<(short)Conditions[code]->getParamCount())
strcpy(strBuf,Conditions[code]->getParamName(param));
}
break;
case MN_ACTIONS:
if(code>=0&&code<(short)Actions.size()) {
if(param>=0&¶m<(short)Actions[code]->getParamCount())
strcpy(strBuf,Actions[code]->getParamName(param));
}
break;
case MN_EXPRESSIONS:
if(code>=0&&code<(short)Expressions.size()) {
if(param>=0&¶m<(short)Expressions[code]->getParamCount())
strcpy(strBuf,Expressions[code]->getParamName(param));
}
break;
}
} else {
if((hMn=LoadMenu(hInstLib, MAKEINTRESOURCE(mn)))) {
GetMenuString(hMn, eiPtr->menu, strBuf, maxLen, MF_BYCOMMAND);
DestroyMenu(hMn);
}
}
}
#else
#define GetCodeTitle(a,b,c,d,e,f)
#endif // !RUN_ONLY
void WINAPI DLLExport GetConditionTitle(mv _far *mV, short code, short param, LPSTR strBuf, short maxLen) {
GetCodeTitle((LPEVENTINFOS2)conditionsInfos, code, param, MN_CONDITIONS, strBuf, maxLen);
}
void WINAPI DLLExport GetActionTitle(mv _far *mV, short code, short param, LPSTR strBuf, short maxLen) {
GetCodeTitle((LPEVENTINFOS2)actionsInfos, code, param, MN_ACTIONS, strBuf, maxLen);
}
void WINAPI DLLExport GetExpressionTitle(mv _far *mV, short code, LPSTR strBuf, short maxLen) {
GetCodeTitle((LPEVENTINFOS2)expressionsInfos, code, 0, MN_EXPRESSIONS, strBuf, maxLen);
}
// -------------------------------------------------------
// GetConditionTitle / GetActionTitle / GetExpressionTitle
// -------------------------------------------------------
// From a menu ID, these routines returns the code of the condition,
// action or expression, as defined in the .H file
//
short WINAPI DLLExport GetConditionCodeFromMenu(mv _far *mV, short menuId)
{
#ifndef RUN_ONLY
LPEVENTINFOS2 eiPtr;
int n;
for(n=Conditions.size(),eiPtr=(LPEVENTINFOS2)conditionsInfos;n>0&&eiPtr->menu!=menuId;n--)
eiPtr=EVINFO2_NEXT(eiPtr);
if(n>0)
return eiPtr->infos.code;
#endif // !RUN_ONLY
return -1;
}
short WINAPI DLLExport GetActionCodeFromMenu(mv _far *mV, short menuId)
{
#ifndef RUN_ONLY
LPEVENTINFOS2 eiPtr;
int n;
for (n=Actions.size(),eiPtr=(LPEVENTINFOS2)actionsInfos;n>0&&eiPtr->menu!=menuId;n--)
eiPtr = EVINFO2_NEXT(eiPtr);
if (n>0)
return eiPtr->infos.code;
#endif // !RUN_ONLY
return -1;
}
short WINAPI DLLExport GetExpressionCodeFromMenu(mv _far *mV, short menuId)
{
#ifndef RUN_ONLY
LPEVENTINFOS2 eiPtr;
int n;
for (n=Expressions.size(),eiPtr=(LPEVENTINFOS2)expressionsInfos;n>0&&eiPtr->menu!=menuId;n--)
eiPtr = EVINFO2_NEXT(eiPtr);
if (n>0)
return eiPtr->infos.code;
#endif // !RUN_ONLY
return -1;
}
// -------------------------------------------------------
// GetConditionInfos / GetActionInfos / GetExpressionInfos