home *** CD-ROM | disk | FTP | other *** search
- #include "rb_plugin.h"
-
- extern struct REALcontrol facelessControl;
-
- REALevent facelessEvents[] = {
- { "Action(red As Integer)" }
- };
-
- Pattern black = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
-
- struct facelessData
- {
- int fillColor;
- };
-
- static void facelessInit(REALcontrolInstance instance)
- {
- }
-
- static void facelessDraw(REALcontrolInstance instance)
- {
- ControlData(facelessControl, instance, facelessData, data);
- RGBColor oldCol, fillCol;
- Rect r;
-
- REALGetControlBounds(instance, &r);
-
- GetForeColor(&oldCol);
- fillCol.red = (data->fillColor >> 16) * 257;
- fillCol.green = ((data->fillColor >> 8) & 0xff) * 257;
- fillCol.blue = ((data->fillColor & 0xff) * 257);
- RGBForeColor(&fillCol);
- FillRect(&r, &black);
- RGBForeColor(&oldCol);
-
- MoveTo(r.left, r.top);
- LineTo(r.right - 1, r.top);
- LineTo(r.right - 1, r.bottom - 1);
- LineTo(r.left, r.bottom - 1);
- LineTo(r.left, r.top);
- LineTo(r.right - 1, r.bottom - 1);
- }
-
- static void boxMakeRed(REALcontrolInstance instance)
- {
- ControlData(facelessControl, instance, facelessData, data);
-
- void (*fp)(REALcontrolInstance instance, int);
-
- fp = (void (*)(REALcontrolInstance instance, int)) REALGetEventInstance(instance, &facelessEvents[0]);
- if (fp)
- fp(instance, data->fillColor >> 16);
-
- data->fillColor = 0xFF0000;
- }
-
- static int boxColorComponent(REALcontrolInstance instance, int bit)
- {
- ControlData(facelessControl, instance, facelessData, data);
-
- if (bit == 0)
- return data->fillColor >> 16;
- else if (bit == 1)
- return (data->fillColor >> 8) & 0xff;
- else
- return (data->fillColor) & 0xff;
- }
-
- REALproperty facelessProperties[] = {
- { "Appearance", "BackColor", "Color", REALpropInvalidate, REALstandardGetter, REALstandardSetter, FieldOffset(facelessData, fillColor) }
- };
-
- REALmethodDefinition facelessMethods[] = {
- { (REALproc) boxMakeRed, REALnoImplementation, "makered" },
- { (REALproc) boxColorComponent, REALnoImplementation, "colorComponent(v as integer) as integer" },
- };
-
- REALcontrolBehaviour facelessBehaviour = {
- facelessInit,
- nil,
- facelessDraw,
- nil,
- nil,
- nil,
- };
-
- REALcontrol facelessControl = {
- kCurrentREALControlVersion,
- "faceless",
- sizeof(facelessData),
- REALinvisibleControl,
- 128,
- 129,
- 32, 32,
- facelessProperties,
- sizeof(facelessProperties) / sizeof(REALproperty),
- facelessMethods,
- sizeof(facelessMethods) / sizeof(REALmethodDefinition),
- facelessEvents,
- sizeof(facelessEvents) / sizeof(REALevent),
- &facelessBehaviour
- };
-
- void PluginEntry(void)
- {
- REALRegisterControl(&facelessControl);
- }
-