IPTR Levelmeter__MUIM_Setup(struct IClass *cl, Object *obj, struct MUIP_Setup *msg) { struct Levelmeter_DATA *data = INST_DATA(cl, obj); //struct RastPort rp; IPTR retval; retval = DoSuperMethodA(cl, obj, (Msg)msg); if (retval) { #if 0 InitRastPort(&rp); SetFont(&rp,_font(obj)); DeinitRastPort(&rp); #endif data->levelbgpen = ObtainBestPen(_screen(obj)->ViewPort.ColorMap, 0x4b4b4b4b, 0x39393939, 0x93939393, OBP_FailIfBad, FALSE, OBP_Precision, PRECISION_GUI, TAG_DONE); } return retval; }
IPTR Register__MUIM_Setup(struct IClass *cl, Object *obj, struct MUIP_Setup *msg) { struct Register_DATA *data = INST_DATA(cl, obj); WORD i, h = 0; if (!DoSuperMethodA(cl, obj, (Msg)msg)) { return FALSE; } _font(obj) = zune_font_get(obj, MUIV_Font_Title); data->fonth = _font(obj)->tf_YSize; data->fontb = _font(obj)->tf_Baseline; h = 0; i = data->fonth + REGISTERTAB_EXTRA_HEIGHT; h = (i > h) ? i : h; data->tab_height = h; data->ty = data->fontb + 1 + (data->tab_height - data->fonth) / 2; /* D(bug("Register_Setup : data->height=%d\n", data->tab_height)); */ for(i = 0; i < data->numitems; i++) { data->items[i].textlen = strlen(data->items[i].text); } data->total_hspacing = (data->columns + 1) * INTERTAB - 2; /* D(bug("Register_AskMinMax : data->total_hspacing = %d\n", data->total_hspacing)); */ data->min_width = data->total_hspacing * 3; data->def_width = data->total_hspacing; if (!(muiGlobalInfo(obj)->mgi_Prefs->register_truncate_titles)) { struct RastPort temprp; int i; WORD textpixmax; InitRastPort(&temprp); SetFont(&temprp, _font(obj)); textpixmax = 0; for(i = 0; i < data->numitems; i++) { WORD textpix = TextLength(&temprp, data->items[i].text, data->items[i].textlen); textpixmax = MAX(textpix, textpixmax); } data->def_width += (textpixmax + TEXTSPACING + 1) * data->numitems; data->def_width = MAX(data->min_width, data->def_width); DeinitRastPort(&temprp); } SetHardCoord(obj,data); muiAreaData(obj)->mad_Flags |= (MADF_INNERLEFT | MADF_INNERTOP | MADF_INNERRIGHT | MADF_INNERBOTTOM); DoMethod(_win(obj), MUIM_Window_AddEventHandler, (IPTR)&data->ehn); return TRUE; }
IPTR Ascii__DTM_ASYNCLAYOUT(Class *cl, Object *o, struct gpLayout *gpl) { struct DTSpecialInfo *si = (struct DTSpecialInfo *) G (o)->SpecialInfo; struct AsciiData *data = INST_DATA (cl, o); ULONG visible = 0, total = 0; struct RastPort trp; ULONG hunit = 1; ULONG bsig = 0; /* Switches */ BOOL linefeed = FALSE; BOOL newseg = FALSE; BOOL abort = FALSE; /* Attributes obtained from super-class */ struct TextAttr *tattr; struct TextFont *font; struct List *linelist; struct IBox *domain; IPTR wrap = FALSE; IPTR bufferlen; STRPTR buffer; STRPTR title; /* Line information */ ULONG num, offset, swidth; ULONG anchor = 0, newanchor; ULONG style = FS_NORMAL; struct Line *line; ULONG yoffset = 0; ULONG linelength, max_linelength = 0; UBYTE fgpen = 1; UBYTE bgpen = 0; ULONG tabspace; ULONG numtabs; ULONG i; ULONG nomwidth, nomheight; D(bug("AsciiDataType_AsyncLayout\n")); /* Get all the attributes that we are going to need for a successful layout */ if (GetDTAttrs (o, DTA_TextAttr , (IPTR) &tattr , DTA_TextFont , (IPTR) &font , DTA_Domain , (IPTR) &domain , DTA_ObjName , (IPTR) &title , TDTA_Buffer , (IPTR) &buffer , TDTA_BufferLen , (IPTR) &bufferlen , TDTA_LineList , (IPTR) &linelist , TDTA_WordWrap , (IPTR) &wrap , TAG_DONE) == 8) { D(bug("AsciiDataType_AsyncLayout: Got all attrs\n")); /* Lock the global object data so that nobody else can manipulate it */ ObtainSemaphore (&(si->si_Lock)); /* Make sure we have a buffer */ if (buffer) { D(bug("AsciiDataType_AsyncLayout: Got buffer\n")); /* Initialize the temporary RastPort */ InitRastPort (&trp); SetFont (&trp, font); D(bug("AsciiDataType_AsyncLayout: Temp RastPort initialized\n")); /* Calculate the nominal size */ nomheight = (ULONG) (24 * font->tf_YSize); nomwidth = (ULONG) (80 * font->tf_XSize); /* Calculate the tab space */ tabspace = font->tf_XSize * 8; /* We only need to perform layout if we are doing word wrap, or this * is the initial layout call */ D(bug("AsciiDataType_AsyncLayout: Checking if layout is needed\n")); if (wrap || gpl->gpl_Initial) { D(bug("AsciiDataType_AsyncLayout: Layout IS needed. Freeing old LineList\n")); /* Delete the old line list */ while ((line = (struct Line *) RemHead (linelist))) FreePooled (data->Pool, line, sizeof (struct Line)); D(bug("AsciiDataType_AsyncLayout. Old LineList freed\n")); /* Step through the text buffer */ for (i = offset = num = numtabs = 0; (i < bufferlen) && (bsig == 0) && !abort; i++) { /* Convert DOS and Mac line endings */ if (buffer[i] == '\r') { if (buffer[i + 1] == '\n') i++; else buffer[i] = '\n'; } /* Check for end of line */ if (buffer[i] == '\n') { newseg = linefeed = TRUE; newanchor = i + 1; } /* Check for end of page */ else if (buffer[i] == 12) { newseg = linefeed = TRUE; newanchor = i + 1; } /* Check for tab */ else if (buffer[i] == '\t') { /* See if we need to terminate a line segment */ if ((numtabs == 0) && num) { newseg = TRUE; } numtabs++; } else { /* See if we have any TABs that we need to finish out */ if (numtabs) { offset += (((offset / tabspace) + 1) * tabspace) - offset; num = numtabs = 0; anchor = i; } /* Compute the width of the line. */ swidth = TextLength(&trp, &buffer[anchor], num + 1); num++; } if (i == bufferlen - 1) newseg = TRUE; /* Time for a new text segment yet? */ if (newseg) { /* Allocate a new line segment from our memory pool */ if ((line = AllocPooled(data->Pool, sizeof(struct Line)))) { swidth = TextLength(&trp, &buffer[anchor], num); line->ln_Text = &buffer[anchor]; line->ln_TextLen = num; line->ln_XOffset = offset; line->ln_YOffset = yoffset + font->tf_Baseline; line->ln_Width = swidth; line->ln_Height = font->tf_YSize; line->ln_Flags = (linefeed) ? LNF_LF : 0; line->ln_FgPen = fgpen; line->ln_BgPen = bgpen; line->ln_Style = style; line->ln_Data = NULL; linelength = line->ln_Width + line->ln_XOffset; if (linelength > max_linelength) { max_linelength = linelength; } /* Add the line to the list */ AddTail(linelist, (struct Node *) line); /* Increment the line count */ if (linefeed) { yoffset += font->tf_YSize; offset = 0; total++; } else { /* Increment the offset */ offset += swidth; } } else { abort = TRUE; } /* Clear the variables */ newseg = linefeed = FALSE; anchor = newanchor; num = 0; /* Check to see if layout has been aborted */ bsig = CheckSignal (SIGBREAKF_CTRL_C); } /* if (newseg) */ } /* * check for last line */ D(bug("AsciiDataType_AsyncLayout: end textloop, anchor %ld\n",anchor)); #if 0 if (buffer[anchor]) { linefeed=TRUE; D(bug("AsciiDataType_AsyncLayout: add last line <%s>\n", &buffer[anchor])); /* Allocate a new line segment from our memory pool */ if ((line = AllocPooled(data->Pool, sizeof(struct Line)))) { swidth = TextLength(&trp, &buffer[anchor], num); line->ln_Text = &buffer[anchor]; line->ln_TextLen = num; line->ln_XOffset = offset; line->ln_YOffset = yoffset + font->tf_Baseline; line->ln_Width = swidth; line->ln_Height = font->tf_YSize; line->ln_Flags = (linefeed) ? LNF_LF : 0; line->ln_FgPen = fgpen; line->ln_BgPen = bgpen; line->ln_Style = style; line->ln_Data = NULL; linelength = line->ln_Width + line->ln_XOffset; if (linelength > max_linelength) { max_linelength = linelength; } /* Add the line to the list */ AddTail(linelist, (struct Node *) line); /* Increment the line count */ if (linefeed) { yoffset += font->tf_YSize; offset = 0; total++; } else { /* Increment the offset */ offset += swidth; } } else { abort = TRUE; } } #endif } /* if (wrap || gpl->gpl_Initial) */ else { /* No layout to perform */ total = si->si_TotVert; max_linelength = si->si_TotHoriz * si->si_HorizUnit; } DeinitRastPort(&trp); } /* if (buffer) */ /* Compute the lines and columns type information */ si->si_VertUnit = font->tf_YSize; si->si_VisVert = visible = domain->Height / si->si_VertUnit; si->si_TotVert = total; /* si->si_HorizUnit = hunit = 1; si->si_VisHoriz = (LONG) domain->Width / hunit; si->si_TotHoriz = domain->Width;*/ si->si_HorizUnit = hunit = font->tf_XSize; si->si_VisHoriz = domain->Width / hunit; si->si_TotHoriz = max_linelength / hunit; /* Release the global data lock */ ReleaseSemaphore (&si->si_Lock); /* Were we aborted? */ if (bsig == 0) { /* Not aborted, so tell the world of our newest attributes */ NotifyAttrChanges (o, gpl->gpl_GInfo, 0, GA_ID , G(o)->GadgetID, DTA_VisibleVert , visible , DTA_TotalVert , total , DTA_NominalVert , nomheight , DTA_VertUnit , font->tf_YSize , /* DTA_TopVert , si->si_TopVert , */ DTA_VisibleHoriz , (domain->Width / hunit) , DTA_TotalHoriz , max_linelength / hunit , DTA_NominalHoriz , nomwidth , DTA_HorizUnit , hunit , DTA_TopHoriz , si->si_TopHoriz , DTA_Title , (IPTR)title , DTA_Busy , FALSE , DTA_Sync , TRUE , TAG_DONE); } /* if (bsig == 0) */ } /* if GetDTAttrs(... */ D(bug("AsciiDataType_AsyncLayout: Done. Returning %d\n", total)); return (IPTR)total; }