tell openssl to look for the ca-bundle.crt in our common location
[AROS-Contrib.git] / bgui / stringclass.c
blobf46924e2e4e35bfba04078fcb9083fa1f25d6869
1 /*
2 * @(#) $Header$
4 * BGUI library
5 * stringclass.c
7 * (C) Copyright 1998 Manuel Lemos.
8 * (C) Copyright 1996-1997 Ian J. Einman.
9 * (C) Copyright 1993-1996 Jaba Development.
10 * (C) Copyright 1993-1996 Jan van den Baard.
11 * All Rights Reserved.
13 * $Log$
14 * Revision 42.3 2004/06/16 20:16:48 verhaegs
15 * Use METHODPROTO, METHOD_END and REGFUNCPROTOn where needed.
17 * Revision 42.2 2000/05/15 19:27:02 stegerg
18 * another hundreds of REG() macro replacements in func headers/protos.
20 * Revision 42.1 2000/05/14 23:32:48 stegerg
21 * changed over 200 function headers which all use register
22 * parameters (oh boy ...), because the simple REG() macro
23 * doesn't work with AROS. And there are still hundreds
24 * of headers left to be fixed :(
26 * Many of these functions would also work with stack
27 * params, but since i have fixed every single one
28 * I encountered up to now, I guess will have to do
29 * the same for the rest.
31 * Revision 42.0 2000/05/09 22:10:23 mlemos
32 * Bumped to revision 42.0 before handing BGUI to AROS team
34 * Revision 41.11 2000/05/09 19:55:14 mlemos
35 * Merged with the branch Manuel_Lemos_fixes.
37 * Revision 41.10.2.2 1999/08/05 01:40:28 mlemos
38 * Added Jilles Tjoelker fix to assure that OM_GET always get a STRING_LongVal
39 * value within the integer range limits.
41 * Revision 41.10.2.1 1998/07/05 19:27:59 mlemos
42 * Made calls to RectFill be made to safe RectFill instead.
44 * Revision 41.10 1998/02/25 21:13:15 mlemos
45 * Bumping to 41.10
47 * Revision 1.1 1998/02/25 17:09:52 mlemos
48 * Ian sources
53 /// Class definitions.
55 #include "include/classdefs.h"
58 * Object instance data.
60 typedef struct {
61 Object *sd_StrGad; /* strgclass object */
62 UBYTE *sd_TextContents; /* contents of the string gadget */
63 LONG sd_IntegerContents; /* contents of the integer gadget */
64 LONG sd_IntegerMin; /* minimum integer contents */
65 LONG sd_IntegerMax; /* maximum integer contents */
66 struct TextFont *sd_Font; /* string gadget font */
67 ULONG sd_Pens; /* Copy of user-pens. */
68 ULONG sd_Active; /* " " " " */
69 ULONG sd_MinChars; /* Min # of chars visible. */
70 UBYTE *sd_Buffer; /* BGUI allocated buffers */
71 UBYTE *sd_UndoBuffer; /* " " " */
72 UBYTE *sd_WorkBuffer; /* " " " */
73 UWORD sd_Flags; /* See below */
74 Object *sd_T_View;
75 WORD sd_T_X, sd_T_Y;
76 WORD sd_T_W, sd_T_H;
77 struct RastPort *sd_T_Buffer;
78 struct Window *sd_T_Window;
79 } SD;
81 #define SDF_STRINGACTIVE (1<<0) /* The strgclass object is active */
83 ///
87 * Obtain the LongVal and TextVal
88 * values from the strgclass object.
90 STATIC ASM VOID GetValues(REG(a0) SD *sd)
92 IPTR tmp;
93 Get_Attr(sd->sd_StrGad, STRINGA_TextVal, (IPTR *)&sd->sd_TextContents);
94 Get_Attr(sd->sd_StrGad, STRINGA_LongVal, &tmp);
95 sd->sd_IntegerContents = (LONG)tmp;
99 * Object cleanup.
101 STATIC METHOD(StringClassDispose, Msg, msg )
103 SD *sd = INST_DATA(cl, obj);
106 * Dispose of the strgadget.
108 DisposeObject(sd->sd_StrGad);
111 * Kill the buffers.
113 if (sd->sd_Buffer ) BGUI_FreePoolMem(sd->sd_Buffer );
114 if (sd->sd_UndoBuffer) BGUI_FreePoolMem(sd->sd_UndoBuffer);
115 if (sd->sd_WorkBuffer) BGUI_FreePoolMem(sd->sd_WorkBuffer);
118 * The rest is for the superclass.
120 return AsmDoSuperMethodA(cl, obj, msg);
122 METHOD_END
125 * Allocate buffers. (Only when maxchars > 128)
127 STATIC ASM BOOL StringClassBuffers( REG(a0) SD *sd, REG(a1) struct TagItem *tags, REG(d0) ULONG max )
130 * We only allocate buffer when:
132 * A) The maximum amount of characters exceeds
133 * 128 bytes.
134 * B) The user did not supply his/her own
135 * buffers.
137 if ( ! FindTagItem( STRINGA_Buffer, tags )) {
138 if ( ! ( sd->sd_Buffer = ( UBYTE * )BGUI_AllocPoolMem( max )))
139 return( FALSE );
141 if ( ! FindTagItem( STRINGA_UndoBuffer, tags )) {
142 if ( ! ( sd->sd_UndoBuffer = ( UBYTE * )BGUI_AllocPoolMem( max )))
143 return( FALSE );
145 if ( ! FindTagItem( STRINGA_WorkBuffer, tags )) {
146 if ( ! ( sd->sd_WorkBuffer = ( UBYTE * )BGUI_AllocPoolMem( max )))
147 return( FALSE );
149 return( TRUE );
153 * Create a shiny new object.
155 STATIC METHOD(StringClassNew, struct opSet *, ops )
157 SD *sd;
158 struct TagItem *tag, *tags;
159 IPTR rc;
161 tags = DefTagList(BGUI_STRING_GADGET, ops->ops_AttrList);
164 * First we let the superclass
165 * create an object.
167 if ((rc = NewSuperObject(cl, obj, tags)))
169 sd = INST_DATA(cl, rc);
172 * Force activation flags.
174 GADGET(rc)->Activation |= GACT_RELVERIFY;
177 * Setup defaults.
179 sd->sd_IntegerMin = GetTagData(STRINGA_IntegerMin, 0xEFFFFFFF, tags);
180 sd->sd_IntegerMax = GetTagData(STRINGA_IntegerMax, 0x0FFFFFFF, tags);
183 * We take care of the GA_Disabled attribute
184 * so we don't let the strgclass see it.
186 if ((tag = FindTagItem(GA_Disabled, tags)))
187 tag->ti_Tag = TAG_IGNORE;
190 * Handle NULL-STRINGA_TextVal.
192 if ((tag = FindTagItem(STRINGA_TextVal, tags)))
194 if (!tag->ti_Data)
195 tag->ti_Data = (IPTR)"";
197 else if ((tag = FindTagItem(STRINGA_LongVal, tags)))
200 * Clamp the integer value between
201 * min and max.
203 tag->ti_Data = range((LONG)tag->ti_Data, sd->sd_IntegerMin, sd->sd_IntegerMax);
207 * Work-around for STRINGA_MaxChars.
209 if ((tag = FindTagItem(STRINGA_MaxChars, tags)))
211 tag->ti_Data++;
213 * See if we need to allocate the
214 * buffers.
216 if (tag->ti_Data > 128)
218 if (!StringClassBuffers(sd, tags, tag->ti_Data))
219 goto stringFail;
224 * Create a strgclass object.
226 if ((sd->sd_StrGad = NewObject( NULL, StrGClass,
227 sd->sd_Buffer ? STRINGA_Buffer : TAG_IGNORE, sd->sd_Buffer,
228 sd->sd_UndoBuffer ? STRINGA_UndoBuffer : TAG_IGNORE, sd->sd_UndoBuffer,
229 sd->sd_WorkBuffer ? STRINGA_WorkBuffer : TAG_IGNORE, sd->sd_WorkBuffer,
230 TAG_MORE, tags)))
233 * Copy of the pens.
235 if ((tag = FindTagItem(STRINGA_Pens, tags))) sd->sd_Pens = tag->ti_Data;
236 if ((tag = FindTagItem(STRINGA_ActivePens, tags))) sd->sd_Active = tag->ti_Data;
239 * Obtain LongVal and TextVal values.
241 GetValues(sd);
244 * Get the minimum number of chars always visible.
246 sd->sd_MinChars = GetTagData(STRINGA_MinCharsVisible, 2, tags);
247 if (sd->sd_MinChars < 2) sd->sd_MinChars = 2;
249 else
251 stringFail:
252 AsmCoerceMethod(cl, (Object *)rc, OM_DISPOSE);
253 rc = 0;
256 FreeTagItems(tags);
258 return rc;
260 METHOD_END
263 * Change the object attributes.
265 STATIC METHOD(StringClassSetUpdate, struct opUpdate *, opu )
267 SD *sd = INST_DATA(cl, obj);
268 struct TagItem *clones, *tag;
269 WORD dis = GADGET( obj )->Flags & GFLG_DISABLED, gv = 0;
270 ULONG rc = 1;
271 IPTR inhibit;
272 //BC *bc = BASE_DATA(obj);
273 struct GadgetInfo *gi = opu->opu_GInfo;
276 * First we let the superclass
277 * change what it can.
279 AsmDoSuperMethodA(cl, obj, (Msg)opu);
282 * Clone tags.
284 if ((clones = CloneTagItems(opu->opu_AttrList)))
287 * Get min and max.
289 sd->sd_IntegerMin = GetTagData(STRINGA_IntegerMin, sd->sd_IntegerMin, clones);
290 sd->sd_IntegerMax = GetTagData(STRINGA_IntegerMax, sd->sd_IntegerMax, clones);
292 * Handle NULL-STRINGA_TextVal.
294 if ((tag = FindTagItem(STRINGA_TextVal, clones)))
296 if (!tag->ti_Data) tag->ti_Data = (IPTR)"";
297 gv = TRUE;
299 else if ((tag = FindTagItem(STRINGA_LongVal, clones)))
302 * Clamp value between min and max.
304 tag->ti_Data = range((LONG)tag->ti_Data, sd->sd_IntegerMin, sd->sd_IntegerMax);
305 gv = TRUE;
309 * We handle GA_Disabled.
311 if ((tag = FindTagItem(GA_Disabled, clones)))
312 tag->ti_Tag = TAG_IGNORE;
315 if (tag = FindTagItem(GA_Left, clones)) tag->ti_Data += bc->bc_InnerBox.Left - bc->bc_OuterBox.Left;
316 if (tag = FindTagItem(GA_Top, clones)) tag->ti_Data += bc->bc_InnerBox.Top - bc->bc_OuterBox.Top;
317 if (tag = FindTagItem(GA_Width, clones)) tag->ti_Data += bc->bc_InnerBox.Width - bc->bc_OuterBox.Width;
318 if (tag = FindTagItem(GA_Height, clones)) tag->ti_Data += bc->bc_InnerBox.Height - bc->bc_OuterBox.Height;
322 * Rendering inhibited?
324 Get_SuperAttr(cl, obj, BT_Inhibit, &inhibit);
327 * Set strgclass attributes.
329 AsmDoMethod(sd->sd_StrGad, opu->MethodID, clones, inhibit ? NULL : gi, opu->opu_Flags);
332 * Force activation flags.
334 GADGET( obj )->Activation |= GACT_RELVERIFY;
337 * Setting a new font? Save it..
339 if (opu->MethodID == OM_SET)
341 if ((tag = FindTagItem(BT_TextAttr, clones)))
343 Get_SuperAttr(cl, obj, BT_TextFont, (IPTR *)&sd->sd_Font);
344 DoSetMethodNG(sd->sd_StrGad, STRINGA_Font, sd->sd_Font, TAG_END);
347 * Copy of the pens.
349 if ((tag = FindTagItem(STRINGA_Pens, clones))) sd->sd_Pens = tag->ti_Data;
350 if ((tag = FindTagItem(STRINGA_ActivePens, clones))) sd->sd_Active = tag->ti_Data;
354 * Get the LongVal and TextVal values.
356 GetValues(sd);
359 * Change visually?
361 if (((GADGET(obj)->Flags & GFLG_DISABLED) != dis) || gv)
362 DoRenderMethod(obj, gi, GREDRAW_UPDATE);
365 * When GACT_LONGINT is set we notify
366 * STRINGA_LongVal when it changed. Otherwise
367 * we notify STRINGA_TextVal.
369 if (gv)
371 if (GADGET(sd->sd_StrGad)->Activation & GACT_LONGINT)
372 DoNotifyMethod(obj, gi, opu->opu_Flags, GA_ID, GADGET(obj)->GadgetID, STRINGA_LongVal, sd->sd_IntegerContents, TAG_END);
373 else
374 DoNotifyMethod(obj, gi, opu->opu_Flags, GA_ID, GADGET(obj)->GadgetID, STRINGA_TextVal, sd->sd_TextContents, TAG_END);
378 * Free the clones.
380 FreeTagItems(clones);
381 } else
382 rc = 0;
384 return rc;
386 METHOD_END
388 /// OM_GET
390 * Get an attribute.
392 METHOD(StringClassGet, struct opGet *, opg)
394 SD *sd = INST_DATA(cl, obj);
395 ULONG rc = 1;
396 IPTR *store = opg->opg_Storage;
398 switch (opg->opg_AttrID)
400 case STRINGA_StringInfo:
402 * Give 'm the pointer to the
403 * StringInfo structure.
405 STORE GADGET( sd->sd_StrGad )->SpecialInfo;
406 break;
408 default:
410 * First we try the strgclass object.
412 rc = AsmDoMethodA(sd->sd_StrGad, (Msg)opg);
415 * Then the superclass.
417 if (!rc) rc = AsmDoSuperMethodA(cl, obj, (Msg)opg);
420 * Clamp the integer value between min and max
421 * Use: if the program does GetAttr() when the user has typed a
422 * value but did not press return, or if the strgclass OM_GET failed
423 * for some reason.
425 if (opg->opg_AttrID == STRINGA_LongVal) {
426 *(opg->opg_Storage) = range(*(opg->opg_Storage), sd->sd_IntegerMin, sd->sd_IntegerMax);
428 break;
430 return rc;
432 METHOD_END
434 /// BASE_RENDER
436 * Render the gadget.
438 METHOD(StringClassRender, struct bmRender *, bmr)
440 SD *sd = INST_DATA(cl, obj);
441 BC *bc = BASE_DATA(obj);
442 struct BaseInfo *bi = bmr->bmr_BInfo;
443 ULONG rc, mypens;
446 * First the superclass.
448 AsmDoSuperMethodA(cl, obj, (Msg)bmr);
451 * Setup default pens.
453 mypens = PACKPENS(bi->bi_Pens[TEXTPEN], bi->bi_Pens[BACKGROUNDPEN]);
456 * Setup string object size and pens.
458 *GADGETBOX(sd->sd_StrGad) = bc->bc_InnerBox;
460 DoSetMethodNG(sd->sd_StrGad, STRINGA_Pens, sd->sd_Pens ? sd->sd_Pens : mypens,
461 STRINGA_ActivePens, sd->sd_Active ? sd->sd_Active : mypens,
462 TAG_DONE);
465 * Let the strgclass render itself.
467 BClearAfPt(bi);
468 rc = AsmDoMethod(sd->sd_StrGad, GM_RENDER, bi, bi->bi_RPort, GREDRAW_REDRAW);
471 * Disable the gadget when necessary.
473 if (GADGET(obj)->Flags & GFLG_DISABLED) BDisableBox(bi, &bc->bc_InnerBox);
475 return rc;
477 METHOD_END
479 /// GM_HITTEST
481 * Did they click in the strgclass object?
483 METHOD(StringClassHitTest, struct gpHitTest *, gph)
485 SD *sd = INST_DATA(cl, obj);
486 ULONG rc = 0;
489 * Only when not disabled.
491 if (!(GADGET(obj)->Flags & GFLG_DISABLED))
494 * Hit inside the object?
496 if (AsmDoSuperMethodA(cl, obj, (Msg)gph) == GMR_GADGETHIT)
499 * Pass on to the strgclass object.
501 rc = AsmDoMethodA(sd->sd_StrGad, (Msg)gph);
504 return rc;
506 METHOD_END
508 /// GM_GOACTIVE
510 * Go to the active state and/or handle the user input.
512 METHOD(StringClassGoActive, struct gpInput *, gpi)
514 SD *sd = INST_DATA(cl, obj);
515 BC *bc = BASE_DATA(obj);
516 ULONG rc = GMR_NOREUSE;
517 struct GadgetInfo *gi;
518 struct RastPort *rp;
519 struct Window *win;
520 int x, y, w, h, wx1, wy1, wx2, wy2;
521 IPTR tmp;
524 * Only if not disabled.
526 if (!(GADGET(obj)->Flags & GFLG_DISABLED))
528 if (bc->bc_View)
531 * Get coordinates of object.
533 Get_Attr(bc->bc_View, VIEW_AbsoluteX, &tmp);
534 x = (int)tmp;
535 Get_Attr(bc->bc_View, VIEW_AbsoluteY, &tmp);
536 y = (int)tmp;
538 gi = gpi->gpi_GInfo;
539 win = gi->gi_Window;
541 x = bc->bc_OuterBox.Left + x - 2;
542 y = bc->bc_OuterBox.Top + y - 2;
543 w = bc->bc_OuterBox.Width + 4;
544 h = bc->bc_OuterBox.Height + 4;
547 * Get bounds of master group.
549 wx1 = win->BorderLeft;
550 wy1 = win->BorderTop;
551 wx2 = win->Width - win->BorderRight;
552 wy2 = win->Height - win->BorderBottom;
555 * Clip to fit in the master group.
557 if (x < wx1) x = wx1;
558 if (y < wy1) y = wy1;
560 if ((x + w) > wx2) x -= (x + w) - wx2;
561 if ((y + h) > wy2) y -= (y + h) - wy2;
563 if (x < wx1) { x = wx1; w = wx2 - wx1; };
564 if (y < wy1) { y = wy1; h = wy2 - wy1; };
566 if ((rp = BGUI_ObtainGIRPort(gi)))
568 if (!(sd->sd_T_Buffer = BGUI_CreateRPortBitMap(rp, w, h, FGetDepth(rp))))
570 ReleaseGIRPort(rp);
571 return rc;
575 * Store deltas.
577 sd->sd_T_X = (x + 2) - bc->bc_OuterBox.Left;
578 sd->sd_T_Y = (y + 2) - bc->bc_OuterBox.Top;
579 sd->sd_T_W = (w - 4) - bc->bc_OuterBox.Width;
580 sd->sd_T_H = (h - 4) - bc->bc_OuterBox.Height;
582 sd->sd_T_Window = win;
583 sd->sd_T_View = bc->bc_View;
584 bc->bc_View = NULL;
587 * Save area to buffer.
589 ClipBlit(rp, x, y, sd->sd_T_Buffer, 0, 0, w, h, 0xC0);
591 AsmDoMethod(obj, BASE_MOVEBOUNDS, sd->sd_T_X, sd->sd_T_Y, sd->sd_T_W, sd->sd_T_H, TAG_DONE);
594 * Clear the area and render the object.
596 SetAPen(rp, 0);
597 SRectFill(rp, x, y, x + w - 1, y + h - 1);
598 AsmDoMethod(obj, GM_RENDER, gi, rp, GREDRAW_REDRAW);
600 ReleaseGIRPort(rp);
605 * Let the superclass have a go...
607 AsmDoSuperMethodA(cl, obj, (Msg)gpi);
610 * Pass message on.
612 if ((rc = AsmDoMethodA(sd->sd_StrGad, (Msg)gpi)) == GMR_MEACTIVE)
614 * Mark us as active.
616 sd->sd_Flags |= SDF_STRINGACTIVE;
619 return rc;
621 METHOD_END
623 /// GM_HANDLEINPUT
625 * Handle the user input.
627 METHOD(StringClassHandleInput, struct gpInput *, gpi)
629 SD *sd = INST_DATA(cl, obj);
630 ULONG rc;
631 LONG val;
632 struct GadgetInfo *gi = gpi->gpi_GInfo;
633 IPTR tmp;
636 * Pass on the message.
638 rc = AsmDoMethodA(sd->sd_StrGad, (Msg)gpi);
641 * RETURN or TAB or SHIFT TAB?
643 if (rc & GMR_VERIFY)
645 GetValues(sd);
648 * Check if the entered value of an integer object is in range and,
649 * if not, adjust it and don't go inactive.
651 if (GADGET(sd->sd_StrGad)->Activation & GACT_LONGINT)
654 * Get the value.
656 Get_Attr(sd->sd_StrGad, STRINGA_LongVal, &tmp);
657 val = (LONG)tmp;
659 * Out of range?
661 if (val < sd->sd_IntegerMin)
663 val = sd->sd_IntegerMin;
664 rc = GMR_MEACTIVE;
666 else if (val > sd->sd_IntegerMax)
668 val = sd->sd_IntegerMax;
669 rc = GMR_MEACTIVE;
671 if (rc == GMR_MEACTIVE)
673 sd->sd_IntegerContents = val;
674 DisplayBeep(gi->gi_Window->WScreen);
675 DoSetMethod(sd->sd_StrGad, gi, STRINGA_LongVal, val, TAG_END);
678 DoNotifyMethod(obj, gi, 0, GA_ID, GADGET(obj)->GadgetID, STRINGA_LongVal, sd->sd_IntegerContents, TAG_END);
679 } else
680 DoNotifyMethod(obj, gi, 0, GA_ID, GADGET(obj)->GadgetID, STRINGA_TextVal, sd->sd_TextContents, TAG_END);
683 * Shift-tabbed?
685 if (rc & GMR_NEXTACTIVE)
688 * Tell the window we're in
689 * to activate the previous
690 * GA_TabCycle object.
692 DoNotifyMethod(obj, gi, 0, GA_ID, GADGET(obj)->GadgetID, STRINGA_Tabbed, obj, TAG_END);
694 * We handle this ourselves.
696 rc &= ~GMR_NEXTACTIVE;
698 else if (rc & GMR_PREVACTIVE)
701 * Tell the window we're in
702 * to activate the next
703 * GA_TabCycle object.
705 DoNotifyMethod(obj, gi, 0, GA_ID, GADGET(obj)->GadgetID, STRINGA_ShiftTabbed, obj, TAG_END);
707 * We handle this ourselves.
709 rc &= ~GMR_PREVACTIVE;
712 return rc;
714 METHOD_END
716 /// GM_GOINACTIVE
718 * Go inactive.
720 METHOD(StringClassGoInActive, struct gpGoInactive *, gpi)
722 SD *sd = INST_DATA(cl, obj);
723 BC *bc = BASE_DATA(obj);
725 int x, y, w, h;
728 * Pass on to the string object
729 * if it was active.
731 if (sd->sd_Flags & SDF_STRINGACTIVE)
733 AsmDoMethodA(sd->sd_StrGad, (Msg)gpi);
735 * Were not active nomore.
737 sd->sd_Flags &= ~SDF_STRINGACTIVE;
740 if (sd->sd_T_View)
742 bc->bc_View = sd->sd_T_View;
743 sd->sd_T_View = NULL;
745 x = bc->bc_OuterBox.Left - 2;
746 y = bc->bc_OuterBox.Top - 2;
747 w = bc->bc_OuterBox.Width + 4;
748 h = bc->bc_OuterBox.Height + 4;
750 AsmDoMethod(obj, BASE_MOVEBOUNDS, -sd->sd_T_X, -sd->sd_T_Y, -sd->sd_T_W, -sd->sd_T_H, TAG_DONE);
752 ClipBlit(sd->sd_T_Buffer, 0, 0, sd->sd_T_Window->RPort, x, y, w, h, 0xC0);
753 BGUI_DoGadgetMethod(obj, sd->sd_T_Window, NULL, GM_RENDER, NULL, sd->sd_T_Window->RPort, GREDRAW_REDRAW);
754 BGUI_FreeRPortBitMap(sd->sd_T_Buffer);
757 return AsmDoSuperMethodA(cl, obj, (Msg)gpi);
759 METHOD_END
761 /// BASE_DIMENSIONS
763 * The object size is requested.
765 METHOD(StringClassDimensions, struct bmDimensions *, bmd)
767 SD *sd = INST_DATA(cl, obj);
768 struct BaseInfo *bi = bmd->bmd_BInfo;
769 int tlen;
771 if (sd->sd_Font) BSetFont(bi, sd->sd_Font);
774 * We must make sure that at least sd_MinChars
775 * characters will fit.
777 tlen = TextWidth(bi->bi_RPort, "M");
780 * Set it up.
782 return CalcDimensions(cl, obj, bmd, tlen * sd->sd_MinChars + (tlen >> 1), bi->bi_RPort->TxHeight);
784 METHOD_END
786 /// WM_KEYACTIVE
788 * Keyboard activation.
790 METHOD(StringClassKeyActive, struct wmKeyInput *, wmki)
793 * Let intuition do it.
795 return WMKF_ACTIVATE;
797 METHOD_END
799 /// SM_FORMAT_STRING
801 * Format string to the string object.
803 METHOD(StringClassFString, struct smFormatString *, smfs)
805 SD *sd = INST_DATA(cl, obj);
806 UBYTE *sb;
807 ULONG rc = 0;
810 * Only on string objects.
812 if (!(GADGET(obj)->Activation & GACT_LONGINT))
815 * Allocate string buffer.
817 if ((sb = (UBYTE *)BGUI_AllocPoolMem(CompStrlenF(smfs->smfs_FStr, (RAWARG)&smfs->smfs_Arg1))))
820 * Format and set it.
822 DoSPrintF(sb, smfs->smfs_FStr, (RAWARG)&smfs->smfs_Arg1);
823 DoSetMethod(sd->sd_StrGad, smfs->smfs_GInfo, STRINGA_TextVal, sb, TAG_END);
825 * Free the string.
827 BGUI_FreePoolMem(sb);
828 rc = 1;
831 return rc;
833 METHOD_END
836 /// Class initialization.
838 * Class function table.
840 STATIC DPFUNC ClassFunc[] = {
841 { BASE_RENDER, StringClassRender, },
842 { BASE_DIMENSIONS, StringClassDimensions, },
844 { OM_NEW, StringClassNew, },
845 { OM_SET, StringClassSetUpdate, },
846 { OM_UPDATE, StringClassSetUpdate, },
847 { OM_GET, StringClassGet, },
848 { OM_DISPOSE, StringClassDispose, },
849 { GM_HITTEST, StringClassHitTest, },
850 { GM_GOACTIVE, StringClassGoActive, },
851 { GM_HANDLEINPUT, StringClassHandleInput, },
852 { GM_GOINACTIVE, StringClassGoInActive, },
853 { WM_KEYACTIVE, StringClassKeyActive, },
854 { SM_FORMAT_STRING, StringClassFString, },
855 { DF_END, NULL },
859 * Simple class initialization.
861 makeproto Class *InitStringClass(void)
863 return BGUI_MakeClass(CLASS_SuperClassBGUI, BGUI_BASE_GADGET,
864 CLASS_ObjectSize, sizeof(SD),
865 CLASS_DFTable, ClassFunc,
866 TAG_DONE);