-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathFrameworkWndProc.cpp
862 lines (730 loc) · 29.5 KB
/
FrameworkWndProc.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
/*
* omnis.xcomp.framework
* =====================
*
* FrameworkWndProc.cpp
* This contains our main entry point for our xcomp
*
* Note that the basis of this code comes straight from the generic examples in the Omnis SDK
*
* Bastiaan Olij
*
* Todos:
* - find a way to prevent having to pass ECI along to everything
*
* https://github.com/BastiaanOlij/omnis.xcomp.framework
*/
// Include our framework files
#include "omnis.xcomp.framework.h"
// Component library entry point (name as declared in resource 31000 )
extern "C" qlong OMNISWNDPROC FrameworkWndProc(HWND pHWND, LPARAM pMsg, WPARAM wParam, LPARAM lParam, EXTCompInfo *pECI) {
// Initialize callback tables - THIS MUST BE DONE
ECOsetupCallbacks(pHWND, pECI);
mainlib *xcomplib = mainlib::get_singleton();
switch (pMsg) {
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// library initialisation
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ECM_CONNECT - this message is sent once per OMNIS session and should not be confused
// with ECM_OBJCONSTRUCT which is sent once per object. ECM_CONNECT can be used if load other libraries
// once or other general global actions that need to be done only once.
//
// For most components this can be removed - see other BLYTH component examples
case ECM_CONNECT: {
return xcomplib->ecm_connect(); // Return external flags
} break;
// ECM_DISCONNECT - this message is sent only once when the OMNIS session is ending and should not be confused
// with ECM_OBJDESTRUCT which is sent once per object. ECM_DISCONNECT can be used to free other libraries
// loaded on ECM_CONNECT or other general global actions that need to be done only once.
//
// For most components this can be removed - see other BLYTH component examples
case ECM_DISCONNECT: {
qbool lvResult = xcomplib->ecm_disconnect();
mainlib::cleanup();
return lvResult;
} break;
// ECM_GETOBJECT - this is sent by OMNIS to find out which non-visual objects are part of our library
case ECM_GETOBJECT: {
qECOobjects *lvObject = xcomplib->objects();
return ECOreturnObjects(gInstLib, pECI, (ECOobject *)lvObject->getArray(), (qshort)lvObject->numberOfElements());
} break;
// ECM_GETSTATICOBJECT - this is sent by OMNIS to find out about our static methods
case ECM_GETSTATICOBJECT: {
return ECOreturnMethods(gInstLib, pECI, xcomplib->staticMethods(), (qshort)xcomplib->numberOfStaticMethods());
};
// ECM_GETCOMPLIBINFO - this is sent by OMNIS to find out the name of the library, and
// the number of components this library supports
case ECM_GETCOMPLIBINFO: {
return ECOreturnCompInfo(gInstLib, pECI, xcomplib->getResourceID(), (qshort)xcomplib->numberOfvisComps());
} break;
// ECM_GETCOMPID - this message is sent by OMNIS to get information about each component in this library
// wParam is a number from 1 to the number of components return on the ECM_GETCOMPLIBINFO message.
//
// For each call you should return the internal object ID and the type of object it is.
// The object id will be used for other calls such as ECM_GETCOMPICON
//
// The object type is for example : cObjType_Basic - a basic window object or
// cRepObjType_Basic - a basic report object.
// There are others - see BLYTH examples and headers
case ECM_GETCOMPID: {
OXFcomponent lvComponent = xcomplib->visCompByIndex(wParam - 1);
if (lvComponent.componentType != 0) {
return ECOreturnCompID(gInstLib, pECI, lvComponent.componentID, lvComponent.componentType);
}
} break;
// ECM_GETCOMPICON - this is sent by OMNIS to get an icon for the OMNIS component store and
// external component browser. You need to always supply an icon in your resource file.
case ECM_GETCOMPICON: {
// OMNIS will call you once per component for an icon.
// GENERIC_ICON is defined in the header and included in the resource file
OXFcomponent lvComponent = xcomplib->componentByID(pECI->mCompId);
if (lvComponent.componentType != 0) {
return ECOreturnIcon(gInstLib, pECI, lvComponent.bitmapID);
}
return qfalse;
} break;
case ECM_GETVERSION: {
qshort major = xcomplib->major();
qshort minor = xcomplib->minor();
return ECOreturnVersion(major, minor);
} break;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// construct/destruct and initialisation of objects
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ECM_OBJCONSTRUCT - this is a message to create a new object.
case ECM_OBJCONSTRUCT: {
oBaseComponent *lvObject;
if (pHWND == 0) {
// Try and see if we have an existing NV object for this
lvObject = (oBaseComponent *)ECOfindNVObject(pECI->mOmnisInstance, lParam);
if (lvObject != NULL) {
// nothing more to do...
return qtrue;
};
};
// instantiate our component
lvObject = xcomplib->instantiateComponent(pECI->mCompId, pECI, pHWND, lParam);
if (lvObject != NULL) {
return qtrue;
};
return qfalse;
} break;
// ECM_OBJDESTRUCT - this is a message to inform you to delete the object
case ECM_OBJDESTRUCT: {
oBaseComponent *lvObject;
// See if we can remove this as a visual component
if (pHWND != 0) {
lvObject = (oBaseComponent *)ECOremoveObject(pECI, pHWND);
if (lvObject != NULL) {
delete lvObject;
};
} else if (wParam == ECM_WPARAM_OBJINFO) {
// checking for non-visual component we only do if wParam == ECM_WPARAM_OBJINFO
lvObject = (oBaseComponent *)ECOremoveNVObject(pECI->mOmnisInstance, lParam);
if (lvObject != NULL) {
delete lvObject;
}
}
return qtrue;
} break;
// ECM_OBJECT_COPY - this is a message to inform you that a copy of our object is required
case ECM_OBJECT_COPY: {
objCopyInfo *lvCopyInfo = (objCopyInfo *)lParam;
oBaseNVComponent *lvSourceObj = (oBaseNVComponent *)ECOfindNVObject(pECI->mOmnisInstance, lvCopyInfo->mSourceObject);
if (lvSourceObj != NULL) {
oBaseNVComponent *lvDestObj = (oBaseNVComponent *)ECOfindNVObject(pECI->mOmnisInstance, lvCopyInfo->mDestinationObject);
if (lvDestObj == NULL) {
lvDestObj = (oBaseNVComponent *)xcomplib->instantiateComponent(pECI->mCompId, pECI, pHWND, lvCopyInfo->mDestinationObject); // hopefully we can trust mCompID here..
};
if (lvDestObj != NULL) {
lvDestObj->copyObject(lvSourceObj);
};
};
} break;
// ECM_OBJECT_REBUILD is send to query if the non-visual object needs a rebuild
case ECM_OBJECT_REBUILD: {
oBaseNVComponent *lvObject = (oBaseNVComponent *)ECOfindNVObject(pECI->mOmnisInstance, lParam);
if (lvObject != NULL) {
return lvObject->ecm_object_rebuild(pECI);
};
}; break;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// properties
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ECM_GETPROPNAME - this message is sent by OMNIS to get information about the properties of an object
case ECM_GETPROPNAME: {
qProperties *lvProperties = xcomplib->properties(pECI->mCompId);
if (lvProperties != NULL) {
qlong retVal = ECOreturnProperties(gInstLib, pECI, (ECOproperty *)lvProperties->getArray(), (qshort)lvProperties->numberOfElements());
return retVal;
};
}; break;
// ECM_INBUILT_OVERRIDE - sent by Omnis to find out if our object wants to maintain certain build in properties itself
case ECM_INBUILT_OVERRIDE: {
oBaseVisComponent *lvObject = (oBaseVisComponent *)ECOfindObject(pECI, pHWND); // Must be a visual component
if (lvObject != NULL) {
return lvObject->inBuildOverride(ECOgetId(pECI)) ? 1L : 0L;
};
return WNDdefWindowProc(pHWND, pMsg, wParam, lParam, pECI);
} break;
// ECM_PROPERTYCANASSIGN: Is the property assignable
case ECM_PROPERTYCANASSIGN: {
oBaseComponent *lvObject;
if (pHWND == 0) {
lvObject = (oBaseComponent *)ECOfindNVObject(pECI->mOmnisInstance, lParam); // first try and see if this is an NV object
} else {
lvObject = (oBaseComponent *)ECOfindObject(pECI, pHWND); // No? must be a visual component
}
if (lvObject != NULL) {
return lvObject->canAssign(ECOgetId(pECI));
};
}; break;
// ECM_SETPROPERTY: Assignment to a property
case ECM_SETPROPERTY: {
EXTParamInfo *lvNewParam = ECOfindParamNum(pECI, 1);
oBaseComponent *lvObject;
if (pHWND == 0) {
lvObject = (oBaseComponent *)ECOfindNVObject(pECI->mOmnisInstance, lParam); // first try and see if this is an NV object
} else {
lvObject = (oBaseComponent *)ECOfindObject(pECI, pHWND); // No? must be a visual component
}
if ((lvObject != NULL) && (lvNewParam != NULL)) {
EXTfldval lvValue((qfldval)lvNewParam->mData);
if (lvObject->setProperty(ECOgetId(pECI), lvValue, pECI)) {
return 1L;
};
// let Omnis do its default logic...
};
}; break;
// ECM_GETPROPERTY: Retrieve value from property
case ECM_GETPROPERTY: {
oBaseComponent *lvObject;
if (pHWND == 0) {
lvObject = (oBaseComponent *)ECOfindNVObject(pECI->mOmnisInstance, lParam); // first try and see if this is an NV object
} else {
lvObject = (oBaseComponent *)ECOfindObject(pECI, pHWND); // No? must be a visual component
}
if (lvObject != NULL) {
EXTfldval lvValue;
if (lvObject->getProperty(ECOgetId(pECI), lvValue, pECI)) {
ECOaddParam(pECI, &lvValue);
return 1L;
};
// let Omnis do its default logic...
};
}; break;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Our special $dataname property
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ECM_SETPRIMARYDATA: The contents of our $dataname property has changed
case ECM_SETPRIMARYDATA: {
oBaseVisComponent *lvObject = (oBaseVisComponent *)ECOfindObject(pECI, pHWND);
if (lvObject == NULL) {
// huh?
} else if (lvObject->enablePrimaryData() == qtrue) {
EXTParamInfo *lvNewParam = ECOfindParamNum(pECI, 1);
if (lvNewParam != NULL) {
EXTfldval lvValue((qfldval)lvNewParam->mData);
if (lvObject->setPrimaryData(lvValue) == qtrue) {
return 1L;
} else {
return 0L;
};
};
};
}; break;
// ECM_GETPRIMARYDATA: Omnis would like to get a copy of our data.
case ECM_GETPRIMARYDATA: {
oBaseVisComponent *lvObject = (oBaseVisComponent *)ECOfindObject(pECI, pHWND);
if (lvObject == NULL) {
// huh?
} else if (lvObject->enablePrimaryData() == qtrue) {
EXTfldval lvValue;
if (lvObject->getPrimaryData(lvValue) == qtrue) {
ECOaddParam(pECI, &lvValue);
return 1L;
} else {
return 0L;
};
};
}; break;
// ECM_CMPPRIMARYDATA: Omnis would like to know if our copy of the data has changed
case ECM_CMPPRIMARYDATA: {
oBaseVisComponent *lvObject = (oBaseVisComponent *)ECOfindObject(pECI, pHWND);
if (lvObject == NULL) {
// huh?
} else if (lvObject->enablePrimaryData() == qtrue) {
EXTParamInfo *lvNewParam = ECOfindParamNum(pECI, 1);
if (lvNewParam != NULL) {
EXTfldval lvValue((qfldval)lvNewParam->mData);
return lvObject->cmpPrimaryData(lvValue);
};
};
}; break;
// ECM_GETPRIMARYDATALEN: Omnis would like to know how big our copy of the data is
case ECM_GETPRIMARYDATALEN: {
oBaseVisComponent *lvObject = (oBaseVisComponent *)ECOfindObject(pECI, pHWND);
if (lvObject == NULL) {
// huh?
} else if (lvObject->enablePrimaryData() == qtrue) {
qlong datalen = lvObject->getPrimaryDataLen();
if (datalen >= 0) {
EXTfldval lvValue;
lvValue.setLong(datalen);
ECOaddParam(pECI, &lvValue);
return 1L;
} else {
return 0L;
};
};
}; break;
// ECM_PRIMARYDATACHANGE: lets our component know the primary data has changed
case ECM_PRIMARYDATACHANGE: {
oBaseVisComponent *lvObject = (oBaseVisComponent *)ECOfindObject(pECI, pHWND);
if (lvObject != NULL) {
// !BAS! Do we only do this when enablePrimaryData is true? or do we always inform our component so we can automate redraws?
lvObject->primaryDataHasChanged();
return 1L;
};
}; break;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Methods
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ECM_GETMETHODNAME: Return method names for class
case ECM_GETMETHODNAME: {
qMethods *lvMethods = xcomplib->methods(pECI->mCompId);
if (lvMethods != NULL) {
qlong retVal = ECOreturnMethods(gInstLib, pECI, (ECOmethodEvent *)lvMethods->getArray(), (qshort)lvMethods->numberOfElements());
return retVal;
};
}; break;
// ECM_METHODCALL: Call a method on an instance
case ECM_METHODCALL: {
qlong lvResult = 1L;
qlong methodID = ECOgetId(pECI);
oBaseComponent *lvObject;
if ((pHWND == 0) && (lParam == 0) && (wParam == 0)) {
// must be static method call, need to test this
lvResult = xcomplib->invokeMethod(methodID, pECI);
} else {
if (pHWND == 0) {
lvObject = (oBaseComponent *)ECOfindNVObject(pECI->mOmnisInstance, lParam); // first try and see if this is an NV object
} else {
lvObject = (oBaseComponent *)ECOfindObject(pECI, pHWND); // No? must be a visual component
}
if (lvObject != NULL) {
lvResult = lvObject->invokeMethod(methodID, pECI);
if (pHWND == 0) {
lvObject = (oBaseComponent *)ECOfindNVObject(pECI->mOmnisInstance, lParam);
};
} else {
str255 lvStr(QTEXT("Method call on unknown object"));
ECOaddTraceLine(&lvStr);
};
};
return lvResult;
}; break;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Events
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ECM_GETEVENTMETHOD: Return events supported by classes
case ECM_GETEVENTMETHOD: {
unsigned int lvID = xcomplib->eventMethodID(pECI->mCompId);
if (lvID > 0) {
return ECOreturnEventMethod(gInstLib, pECI, lvID);
};
}; break;
// ECM_GETEVENTNAME: Return event names
case ECM_GETEVENTNAME: {
qEvents *lvEvents = xcomplib->events(pECI->mCompId);
if (lvEvents != NULL) {
qlong retVal = ECOreturnEvents(gInstLib, pECI, (ECOmethodEvent *)lvEvents->getArray(), (qshort)lvEvents->numberOfElements());
return retVal;
};
}; break;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// (Drop)List object functions
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// ECM_PAINTCONTENTS: Paint the contents of a line for a list based control
case ECM_PAINTCONTENTS: {
// This should only be called on visual object
oBaseVisComponent *lvObject = (oBaseVisComponent *)ECOfindObject(pECI, pHWND);
if (lvObject != NULL) {
EXTListLineInfo *lineInfo = (EXTListLineInfo *)lParam;
if (lvObject->ecm_paintcontents(lineInfo, pECI)) {
return 1L;
};
};
};
// ECM_LISTDRAWLINE: Draw line for a list based control
case ECM_LISTDRAWLINE: {
// This should only be called on visual object
oBaseVisComponent *lvObject = (oBaseVisComponent *)ECOfindObject(pECI, pHWND);
if (lvObject != NULL) {
EXTListLineInfo *lineInfo = (EXTListLineInfo *)lParam;
if (lvObject->ecm_listdrawline(lineInfo, pECI)) {
return 1L;
};
};
}; break;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// window messaging
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// WM_KEYDOWN and WM_KEYUP: React to key down/up events
case WM_KEYDOWN:
case WM_KEYUP: {
// This should only be called on visual object
oBaseVisComponent *lvObject = (oBaseVisComponent *)ECOfindObject(pECI, pHWND);
if (lvObject != NULL) {
qkey *keyMessage = (qkey *)lParam;
if (lvObject->evKeyPressed(keyMessage, pMsg == WM_KEYDOWN, pECI)) {
return 0L;
} else {
return 1L;
};
};
}; break;
// WM_HSCROLL, WM_VSCROLL - scrollbar position has changed
case WM_HSCROLL:
case WM_VSCROLL: {
// This should only be called on visual object
oBaseVisComponent *lvObject = (oBaseVisComponent *)ECOfindObject(pECI, pHWND);
if (lvObject != NULL) {
qdim min, max, page, oldPos, newPos, otherPos, stepSize;
bool scrollParent = false;
if (pMsg == WM_HSCROLL) {
stepSize = lvObject->getHorzStepSize();
WNDgetScrollPos(pHWND, SB_HORZ, &oldPos);
WNDgetScrollPos(pHWND, SB_VERT, &otherPos);
WNDgetScrollRange(pHWND, SB_HORZ, &min, &max, &page);
} else {
stepSize = lvObject->getVertStepSize();
WNDgetScrollPos(pHWND, SB_VERT, &oldPos);
WNDgetScrollPos(pHWND, SB_HORZ, &otherPos);
WNDgetScrollRange(pHWND, SB_VERT, &min, &max, &page);
};
switch (wParam) {
case SB_LINEDOWN:
newPos = oldPos + stepSize;
break;
case SB_LINEUP:
newPos = oldPos - stepSize;
break;
case SB_PAGEDOWN:
newPos = oldPos + page;
break;
case SB_PAGEUP:
newPos = oldPos - page;
break;
case SB_TOP:
newPos = min;
break;
case SB_BOTTOM:
newPos = max;
break;
case SB_THUMBPOSITION:
case SB_THUMBTRACK: {
// handle sign extension correctly
qshort shortNewPos = LOWORD(lParam);
newPos = shortNewPos;
break;
};
case SB_ENDSCROLL:
default:
newPos = oldPos;
break;
};
max = max - (max % 8); // seems constraint by 8ths..
if (newPos < min) {
newPos = min;
scrollParent = true;
};
if (newPos > max) {
newPos = max;
scrollParent = true;
};
if (newPos != oldPos) {
if (pMsg == WM_HSCROLL) {
lvObject->evWindowScrolled(newPos, otherPos);
} else {
lvObject->evWindowScrolled(otherPos, newPos);
};
};
if (scrollParent) {
EXTfldval hasScroll;
// pass this to our parent, but only if our parent has scroll on!
HWND parentHwnd = WNDgetParent(pHWND);
ECOgetProperty(parentHwnd, pMsg == WM_HSCROLL ? anumHorzscroll : anumVertscroll, hasScroll);
if (hasScroll.getBool() == 2) {
WNDsendMessage(parentHwnd, pMsg, wParam, lParam);
};
};
return 0L;
};
}; break;
// WM_SETCURSOR - gets sent when the mouse is above our control and Omnis wants to know what cursor to show
case WM_SETCURSOR: {
// This should only be called on visual object
oBaseVisComponent *lvObject = (oBaseVisComponent *)ECOfindObject(pECI, pHWND);
if (lvObject != NULL) {
qword2 hittest = LOWORD(lParam);
qpoint pt;
// get our mouse position and map it to our control so 0,0 is the left-top of our control
WNDgetCursorPos(&pt);
WNDmapWindowPoint(HWND_DESKTOP, pHWND, &pt);
HCURSOR cursor = lvObject->getCursor(pt, hittest);
if (cursor != WND_CURS_DEFAULT) {
WNDsetCursor(cursor);
return 1L;
} else {
// let omnis do its thing...
};
};
}; break;
// WM_LBUTTONDOWN - standard left mouse button down event
case WM_LBUTTONDOWN: {
// This should only be called on visual object
oBaseVisComponent *lvObject = (oBaseVisComponent *)ECOfindObject(pECI, pHWND);
// and if its good, call the function
if (lvObject != NULL) {
// let our object know that we have pressed our mouse down.
qpoint pt;
// get some info about our mouse
WNDmakePoint(lParam, &pt);
if (lvObject->wm_lbutton(pt, true, pECI)) { // only if we return true do we round this off, if false we assume default logic for Omnis.
// capture our mouse
if (!WNDhasCapture(pHWND, WND_CAPTURE_MOUSE)) {
WNDsetCapture(pHWND, WND_CAPTURE_MOUSE);
};
return 0L;
};
};
} break;
// WM_LBUTTONUP - standard left mouse button up event
case WM_LBUTTONUP: {
// This should only be called on visual object
oBaseVisComponent *lvObject = (oBaseVisComponent *)ECOfindObject(pECI, pHWND);
// and if its good, call the function
if (lvObject != NULL) {
// always release our capture, if we open up a window or something weird things start to happen.
if (WNDhasCapture(pHWND, WND_CAPTURE_MOUSE)) {
WNDreleaseCapture(WND_CAPTURE_MOUSE);
// now process this...
qpoint pt;
// get some info about our mouse
WNDmakePoint(lParam, &pt);
if (lvObject->wm_lbutton(pt, false, pECI)) { // only if we return true do we round this off, if false we assume default logic for Omnis.
return 0L;
};
};
};
} break;
// WM_LBUTTONDBLCLK - user double clicked
case WM_LBUTTONDBLCLK: {
// This should only be called on visual object
oBaseVisComponent *lvObject = (oBaseVisComponent *)ECOfindObject(pECI, pHWND);
// and if its good, call the function
if (lvObject != NULL) {
// now process our double click...
qpoint pt;
WNDmakePoint(lParam, &pt);
if (lvObject->wm_lbDblClick(pt, pECI)) {
return 0L;
};
// always release our capture, if we open up a window or something weird things start to happen.
if (WNDhasCapture(pHWND, WND_CAPTURE_MOUSE)) {
WNDreleaseCapture(WND_CAPTURE_MOUSE);
};
};
}; break;
// WM_RBUTTONDOWN - standard right mouse button down event
case WM_RBUTTONDOWN:
// WM_RBUTTONUP - standard right mouse button up event
case WM_RBUTTONUP: {
// This should only be called on visual object
oBaseVisComponent *lvObject = (oBaseVisComponent *)ECOfindObject(pECI, pHWND);
// and if its good, call the function
if (lvObject != NULL) {
// let our object know that we have pressed our mouse down.
qpoint pt;
WNDmakePoint(lParam, &pt);
if (lvObject->wm_rbutton(pt, pMsg == WM_RBUTTONDOWN, pECI)) {
return 0L;
};
};
} break;
// WM_MOUSEMOVE - mouse has been moved while it is above us or we have captured the mouse
case WM_MOUSEMOVE: {
// This should only be called on visual object
oBaseVisComponent *lvObject = (oBaseVisComponent *)ECOfindObject(pECI, pHWND);
// and if its good, call the function
if (lvObject != NULL) {
HWND mouse_over = NULL;
qpoint pt, pt_desktop;
qword2 hittest;
// get some info about our mouse
WNDmakePoint(lParam, &pt);
pt_desktop = pt;
WNDmapWindowPoint(pHWND, HWND_DESKTOP, &pt_desktop);
WNDgetWindowFromPt(&mouse_over, &hittest, &pt_desktop);
bool mouseIsOver = (mouse_over == pHWND) && (hittest != HTNOWHERE);
// mouse moved
lvObject->wm_mousemove(pt, pECI, mouseIsOver);
return 0L;
};
} break;
// WM_DRAGDROP - events related to dragging and dropping
case WM_DRAGDROP: {
// only handle if we're not in design mode, else leave it up to Omnis.
if (!ECOisDesign(pHWND)) {
oBaseVisComponent *lvObject = (oBaseVisComponent *)ECOfindObject(pECI, pHWND);
if (lvObject != NULL) {
qlong retval = lvObject->wm_dragdrop(wParam, lParam, pECI);
if (retval != -1) {
return retval;
};
};
};
}; break;
// WM_GETERASEINFO - get info for drawing non client area background
case WM_GETERASEINFO: {
// This should only be called on visual object
oBaseVisComponent *lvObject = (oBaseVisComponent *)ECOfindObject(pECI, pHWND);
if (lvObject != NULL) {
if (lvObject->wm_geteraseinfo((WNDeraseInfoStruct *)lParam, pECI)) {
return 1L;
};
};
} break;
// WM_ERASEBKGND - erase the background
case WM_ERASEBKGND: {
// This should only be called on visual object
oBaseVisComponent *lvObject = (oBaseVisComponent *)ECOfindObject(pECI, pHWND);
// and if its good, call the erase function
if (lvObject != NULL) {
if (lvObject->wm_erasebkgnd(pECI)) {
return 1L;
};
};
} break;
// WM_PAINT - standard paint message
case WM_PAINT: {
// This should only be called on visual object
oBaseVisComponent *lvObject = (oBaseVisComponent *)ECOfindObject(pECI, pHWND);
// and if its good, call the paint function
if (lvObject != NULL) {
if (lvObject->wm_paint(pECI)) {
return 1L;
};
};
} break;
// WM_WINDOWPOSCHANGED - inform that the position or size of our visual component has changed
case WM_WINDOWPOSCHANGED: {
// This should only be called on visual object
oBaseVisComponent *lvObject = (oBaseVisComponent *)ECOfindObject(pECI, pHWND);
// and if its good, call the paint function
if (lvObject != NULL) {
#if OMNISSDK >= 70
lvObject->wm_windowposchanged(pECI, (WNDsetWindowPosStruct *)lParam);
#else
lvObject->wm_windowposchanged(pECI, (WNDwindowPosStruct *)lParam);
#endif
return 1L;
}
} break;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// undocumented but handy!
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 1026 - $enabled or $active set to true in runtime INCLUDING if this action is done on a container!
case 1026: {
// must do our standard logic..
qlong result = WNDdefWindowProc(pHWND, pMsg, wParam, lParam, pECI);
/* Can't do anything with this yet, Omnis is not telling us whether $enabled or $active is being set so we have no reliable way of knowing how to react here...
oBaseVisComponent* lvObject = (oBaseVisComponent*)ECOfindObject( pECI, pHWND );
if (lvObject!=NULL) {
oBaseComponent::addToTraceLog("%li: active/enabled changed to true w: %li, l: %li", pHWND, wParam, lParam);
};
*/
// do call a redraw on our object just in case it wants to change the way it draws...
WNDinvalidateRect(pHWND, NULL);
return result;
} break;
// 1027 - $enabled or $active set to false in runtime INCLUDING if this action is done on a container!
case 1027: {
// must do our standard logic..
qlong result = WNDdefWindowProc(pHWND, pMsg, wParam, lParam, pECI);
/* Can't do anything with this yet, Omnis is not telling us whether $enabled or $active is being set so we have no reliable way of knowing how to react here...
oBaseVisComponent* lvObject = (oBaseVisComponent*)ECOfindObject( pECI, pHWND );
if (lvObject!=NULL) {
oBaseComponent::addToTraceLog("%li: active/enabled changed to false w: %li, l: %li", pHWND, wParam, lParam);
};
*/
// do call a redraw on our object just in case it wants to change the way it draws...
WNDinvalidateRect(pHWND, NULL);
return result;
} break;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// place holders for later implementation..
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// WM_CREATE - create an object
case WM_CREATE: {
return WNDdefWindowProc(pHWND, pMsg, wParam, lParam, pECI);
} break;
// WM_DESTROY - destroy an object
case WM_DESTROY: {
return WNDdefWindowProc(pHWND, pMsg, wParam, lParam, pECI);
} break;
// WM_SHOWWINDOW - make object visible
case WM_SHOWWINDOW: {
return WNDdefWindowProc(pHWND, pMsg, wParam, lParam, pECI);
} break;
// WM_WINDOWPOSCHANGING - moving component around (WM_WINDOWPOSCHANGED is called once finished)
case WM_WINDOWPOSCHANGING: {
return WNDdefWindowProc(pHWND, pMsg, wParam, lParam, pECI);
} break;
// ECM_OBJINITIALIZE - Sent during object construction (before set property WPARAM=0; after WPARAM=1)
case ECM_OBJINITIALIZE: {
return WNDdefWindowProc(pHWND, pMsg, wParam, lParam, pECI);
} break;
// ECM_PROPERTYCALCTYPE - Request for the Calculation type of an attribute // mt40455
case ECM_PROPERTYCALCTYPE: {
return WNDdefWindowProc(pHWND, pMsg, wParam, lParam, pECI);
} break;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// unknowns worth looking into
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 1027: Mouse move in design time?
case 1037: { // 0x40D seems to be called when the mouse moves in design time
return WNDdefWindowProc(pHWND, pMsg, wParam, lParam, pECI);
} break;
// 1051: ???
case 1051: { // 0x41B seems to be called regularly
return WNDdefWindowProc(pHWND, pMsg, wParam, lParam, pECI);
} break;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// omnis internal calls that we need to pass through..
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// WM_NULL - no message?
case WM_NULL: {
return WNDdefWindowProc(pHWND, pMsg, wParam, lParam, pECI);
} break;
// ECM_OBJECTDATABLOCK - Setting object properties with a data block
case ECM_OBJECTDATABLOCK: {
return WNDdefWindowProc(pHWND, pMsg, wParam, lParam, pECI);
} break;
// ECM_MEMORYDELETION tells our xcomp to free up memory
case ECM_MEMORYDELETION: {
return WNDdefWindowProc(pHWND, pMsg, wParam, lParam, pECI);
} break;
default: {
/* uncomment for debugging
qstring lvString;
lvString.appendFormattedString("Call not implemented: %li", pMsg);
str255 lvStr(lvString.cString());
ECOaddTraceLine(&lvStr); */
}; break;
};
// As a final result, if we haven't handled our message this must be called. It handles all other messages that this component
// decided to ignore.
return WNDdefWindowProc(pHWND, pMsg, wParam, lParam, pECI);
}