/*================================================== * delete_array_obj - Delete element from array * This of course is somewhat expensive, as the array must be shifted down *================================================*/ BOOLEAN delete_array_obj (ARRAY array, INT i) { if (i<0 || i>ASize(array)) return FALSE; while (i<ASize(array)) { AData(array)[i] = AData(array)[i+1]; ++i; } --ASize(array); return TRUE; }
char *XEEventIDToString(register CARD8 id, XETC *tc) { int i; if (id < ASize(eventName)) return(eventName[id]); /* either erroneous or an extension event */ if (numExtension < 0) { /* * This is unfortunate, but necessary. The client * program has requested the string identifier for * an extension request/event. Since there's no Xlib * equivalent for this, we have to query *all* the * extensions looking for a match. Chances are * if a client wants one, it'll want them all, * so just go through and initialize the extension * list once. */ loadExtStrings(tc); } /* Find id within extensionData */ for (i=0; i<numExtension; i++) { if (extensionData[i].extEvent == id) return(extensionData[i].extName); } return(unknown); }
/*========================================================= * set_array_obj -- Set element (object) in array * grow if necessary *=======================================================*/ void set_array_obj (ARRAY array, INT i, OBJECT obj) { ASSERT(i>=0); ASSERT(i< 0x1000000); /* 16,777,216 */ if (i>=AMax(array)) { enlarge_array(array, i); } if (i>=ASize(array)) { int j; for (j=ASize(array); j<i; ++j) AData(array)[j] = 0; ASize(array)=i+1; } AData(array)[i] = obj; }
void sort_array (ARRAY array, OBJCMPFNC cmp, VPTR param) { struct tag_sort_array_info info; info.cmp = cmp; info.param = param; partition_sort((SORTEL *)&AData(array)[0], ASize(array), array_comparator, &info); }
ASize GetPaperSize(APageSize sz) { switch(sz) { case APageSize::Letter: return ASize(8.5, 11, AMeasurementUnit::INCH); default: throw std::invalid_argument("Unsupported page size"); break; } }
/*========================================================= * destroy_array -- Delete array (releasing all elements) *=======================================================*/ void destroy_array (ARRAY array) { int i; for (i=0; i<ASize(array); ++i) { OBJECT obj = (OBJECT)AData(array)[i]; delete_obj(obj); } stdfree(AData(array)); AData(array) = 0; stdfree(array); }
/*========================================================= * create_array_objval -- Create array (which holds objects) *=======================================================*/ ARRAY create_array_objval (INT size) { ARRAY array = 0; if (!size) size=20; ASSERT(size >= 1); array = (ARRAY)stdalloc(sizeof(*array)); memset(array, 0, sizeof(*array)); array->vtable = &vtable_for_array; ASize(array) = 0; AMax(array) = size; AData(array) = (void **)stdalloc(size * sizeof(AData(array)[0])); return array; }
/*========================================================= * enlarge_array -- Make array large enough for [space] elements *=======================================================*/ void enlarge_array (ARRAY array, INT space) { int newsize = AMax(array); void ** ptr; int i; while (newsize <= space) newsize <<= 2; if (newsize<AMax(array)) return; ptr = (void **)stdalloc(newsize * sizeof(AData(array)[0])); for (i = 0; i < ASize(array); i++) ptr[i] = AData(array)[i]; stdfree(AData(array)); AData(array) = ptr; AMax(array) = newsize; }
char *XERequestIDToExtString(register CARD8 id, XETC *tc) { int extid; extid = id - ASize(requestName); if (numExtension < 0) { /* * This is unfortunate, but necessary. The client * program has requested the string identifier for * an extension request/event. Since there's no Xlib * equivalent for this, we have to query *all* the * extensions looking for a match. Chances are * if a client wants one, it'll want them all, * so just go through and initialize the extension * list once. */ loadExtStrings(tc); } return((extid >=0 && extid < numExtension) ? extensionData[extid].extName : unknown); }
INT16 XERequestStringToID(register char *string) { return(_StringToID(string,requestName,ASize(requestName))); }
INT16 XEEventStringToID(register char *string) { return(_StringToID(string,eventName,ASize(eventName))); }
ASize ACanvasSkia::MeasureText(const AString& sText) { _SetPaint_Font(); int x = m_Paint.measureText(sText.Text(),sText.Length()*sizeof(ACHAR)); return ASize(x,GetFont()->GetSize()); }
/*========================================================= * get_array_size -- Return size of array (# of elements) *=======================================================*/ INT get_array_size (ARRAY array) { return ASize(array); }
/*========================================================= * get_array_obj -- Get element (object) from array *=======================================================*/ OBJECT get_array_obj (ARRAY array, INT i) { if (i<0 || i>ASize(array)) return 0; return (OBJECT)AData(array)[i]; }
AImageList::AImageList(AComponent* pOwner):AInvisibleControl(pOwner) { Size = ASize(16,16);//ȱʡ´óС }
char *XERequestIDToString(register CARD8 id, XETC *tc) { return((id < ASize(requestName)) ? requestName[id] : XERequestIDToExtString(id,tc)); }
/*========================================================= * add_array_obj -- Append object to end of array *=======================================================*/ void add_array_obj (ARRAY array, OBJECT obj) { set_array_obj(array, ASize(array), obj); }