//////////////////////////////////////////////////////////////////////// // FUNCTION: CategorySetName // // DESCRIPTION: This routine set the category name and rename bits. // A NULL pointer removes the category name. // // PARAMETERS: (DmOpenRef) db - Opened database containing category info. // (UInt16) index - Index of category to set. // (const char *) name - A Category name (null-terminated) or // NULL pointe to remove the category. // // RETURNED: Returns nothing. // // REVISION HISTORY: // Name Date Description // ---- ---- ----------- // Jerry 3/27/01 Initial Revision //////////////////////////////////////////////////////////////////////// void CategorySetName (DmOpenRef db, UInt16 index, const char *name) { if ( index < catList->numItems ) { // change current item to new text catList->itemsText[index] = (char *) Vrealloc (catList->itemsText[index], Vstrlen(name)+1); Vstrcpy (catList->itemsText[index], name); } else if ( Vstrlen(name) ) { // add a new item text catList->itemsText = (Char **) Vrealloc (catList->itemsText, sizeof(Char *)*(catList->numItems+1)); catList->itemsText[catList->numItems] = (char *) Vmalloc(Vstrlen(name)+1); Vstrcpy (catList->itemsText[catList->numItems], name); catList->numItems++; } VCategorySetName (db, index, name); /* UInt16 size=0; Char word[16]; UInt16 maxlength = 0; // UInt16 *category = VGetRecord (db, index, 0); while ( VGetCategoryName (db, catList->numItems, word) ) { catList->itemsText = (Char **) Vrealloc (catList->itemsText, sizeof(Char *)*(catList->numItems+1)); size += (UInt16)(Vstrlen(word)+1); catList->itemsText[catList->numItems] = (char *) Vmalloc(size); Vstrcpy (catList->itemsText[catList->numItems], word); if ( Vstrlen (word) > maxlength ) { maxlength = (UInt16) Vstrlen(word); } catList->numItems++; }; // if ( *category == dmAllCategories ) { // *category = 0; // } Vstrcpy (catList->itemsText[index], name); */ }
static void mal(cpu *pcpu) { organismo *phijo = pcpu->pcel->hijo; pcpu->ip++; //if (pcpu->cx!=45 && pcpu->cx!=80) return; //TEMPORAL: solo 2 hijos por ronda if ((pcpu->pcel)->ronda_hijos > 2) return; //si ya tuve un hijo y este es independiente ó si no tuve hijos if (phijo==NULL) { if (pcpu->cx > 19 && pcpu->cx < MAX_CLASS) { organismo *pcel = organismo_new(); phijo = pcel; phijo->size = pcpu->cx; //printf("%d\n",phijo->size); //pthread_mutex_lock(&maloc); phijo->mem = Vmalloc(phijo->size); if (phijo->mem != EMALLOC) { pcpu->ax = phijo->mem; phijo->pcpu->ip = pcpu->ax; (pcpu->pcel)->hijo = phijo; } else { pcel->die(pcel); } //pthread_mutex_unlock(&maloc); } } }
//////////////////////////////////////////////////////////////////////// // FUNCTION: CategoryCreateList // // DESCRIPTION: This routine read a database's categories and store them // in a list. // // PARAMETERS: (DmOpenRef) db - Opened database containing category info. // (ListType *) listP - A pointer to the list of category // names. // (UInt16) currentCategory - Category to select // (Boolean) showAll - true to have an "ALL" categories // (Boolean) showUneditables - true to show uneditable // categories. // (UInt8) numUneditableCategories - This is the number of // categories, starting with the first one // at zero. // (UInt32) editingStrID - The resource ID os a string to // use with the "Edit Categories" list item. // (Boolean) resizeList - true to resize the list to the // number of categories. Set to true for // pop-ups, false otherwise // // RETURNED: Nothing // // REVISION HISTORY: // Name Date Description // ---- ---- ----------- // Jerry 3/13/01 Initial Revision //////////////////////////////////////////////////////////////////////// void CategoryCreateList (DmOpenRef db, ListType *listP, UInt16 currentCategory, Boolean showAll, Boolean showUneditables, UInt8 numUneditableCategories, UInt32 editingStrID, Boolean resizeList) { UInt16 index=0, k, offset=0; Char word[16]; if ( !VGetCategoryName (db, 0, word) ) { for ( ; index < listP->numItems; index++ ) { VWriteCategory ( db, index, listP->itemsText[index], Vstrlen(listP->itemsText[index]) ) ; } } else { // release old listP text memory for ( k = 0; k < listP->numItems; k++ ) { if ( listP->itemsText[k]); Vfree (listP->itemsText[k]); } if ( listP->itemsText ) Vfree (listP->itemsText); listP->itemsText = NULL; // if showAll, add the "ALL" item to the list listP->itemsText = (Char **) Vrealloc (listP->itemsText, (sizeof(Char *)*(listP->numItems+1))); if (showAll) { listP->itemsText[index] = (Char*) Vmalloc (4); Vstrcpy (listP->itemsText[index++], "All"); offset = 1; } do { listP->itemsText[index] = (Char*) Vmalloc (Vstrlen(word)+1); Vstrcpy (listP->itemsText[index++], word); } while ( VGetCategoryName (db, (UInt16)(index-offset), word) ); listP->numItems = index; if ( resizeList ) { listP->bounds.extent.y = listP->numItems*FntLineHeight(); } } }
//////////////////////////////////////////////////////////////////////// // FUNCTION: WCategoryInitialize (Wiscore used only) // // DESCRIPTION: This routine initialize the category names, IDs, and flags // // PARAMETERS: (AppInfoPtr) appInfoP - Application info pointer. // // RETURNED: Returns nothing. // // REVISION HISTORY: // Name Date Description // ---- ---- ----------- // Jerry 5/14/01 Initial Revision // Jerry 10/09/01 Remove category position hardcore //////////////////////////////////////////////////////////////////////// void WCategoryInitialize (AppInfoPtr appInfoP) { catList = (ListType *) Vmalloc (sizeof(ListType)); Vmemset (catList, 0, sizeof (ListType)); catList->numItems = 0; catList->bounds.topLeft.x = CATEGORYSTARTX; catList->bounds.topLeft.y = CATEGORYSTARTY; catList->bounds.extent.x = CATEGORYWIDTH; catList->bounds.extent.y = CATEGORYHEIGHT; }
//////////////////////////////////////////////////////////////////////// // FUNCTION: SysHandleEvent // // DESCRIPTION: This routine return the next available event. // // PARAMETERS: (EventType *) event - Pointer to the structure to hold // the event returned. // // RETURNED: Returns nothing // // REVISION HISTORY: // Name Date Description // ---- ---- ----------- // Jerry 2/14/01 Initial Revision // Jerry 7/04/01 Add push button control handler // Jerry 8/03/01 Add popSelectEvent // Jerry 8/07/01 Modify popSelectEvent to get the correct List // Jerry 8/08/01 Complete event->data.popSelect event // Jerry 8/09/01 Add frmListObj option // Jerry 8/28/01 Processing frmCloseEvent, blinking field cursor // Jerry 9/03/01 Clear control before redraw it // Jerry 9/12/01 Fixed push button showing problem // Jerry 9/13/01 Put the string on the center of control //////////////////////////////////////////////////////////////////////// Boolean SysHandleEvent(EventType *event) { if ( MenuActive || (!ActiveForm) || (ActiveObjIndex == -1) ) return 0; // if current active control is fieldtype, draw cursor if editable if ( (ActiveForm->objects[ActiveObjIndex].objectType == frmFieldObj) && (ActiveForm->objects[ActiveObjIndex].object.field->attr.editable) ) { VDrawCursor ( (Coord)(ActiveForm->objects[ActiveObjIndex].object.field->insPtXPos), (Coord)(ActiveForm->objects[ActiveObjIndex].object.field->insPtYPos+2), CUR_DRAW); VDrawGrafState (TRUE); } else { VDrawGrafState (FALSE); } // close current form, free all allocate memory on this form. if ( event->eType == ctlSelectEvent ) { if ( (ActiveForm->objects[ActiveObjIndex].objectType == frmControlObj) ) { if (ActiveForm->objects[ActiveObjIndex].object.control->style == checkboxCtl) { // CHECKBOX Style[0] is used for checked message ControlType *ctlP = ActiveForm->objects[ActiveObjIndex].object.control; // VSetCheckBox (ctlP, ctlP->attr.on); ctlP->attr.on = ~ctlP->attr.on; VRedrawControl (ActiveForm->objects[ActiveObjIndex]); } else if (ActiveForm->objects[ActiveObjIndex].object.control->style == pushButtonCtl) { // Press on push button, invert the push button ControlType *ctlP = ActiveForm->objects[ActiveObjIndex].object.control; RectangleType rect; int strWidth; if ( !ctlP->attr.on ) { int i; rect.topLeft.x = (ctlP->bounds.topLeft.x+1); rect.topLeft.y = (ctlP->bounds.topLeft.y+1); // get the width of string strWidth = FntCharsWidth (ctlP->text, (Int16)Vstrlen(ctlP->text)); if ( ctlP->bounds.extent.x == -1 ) { rect.extent.x = (UInt16)strWidth+2; } else { rect.extent.x = (ctlP->bounds.extent.x-3); } if ( ctlP->bounds.extent.y == -1 ) { rect.extent.y = FntCharHeight()-3; } else { rect.extent.y = (ctlP->bounds.extent.y-4); } VDrawRect (&rect, PS_SOLID, 0, CL_FOREGROUND, COORD_STRETCH, DRAW_XOR); /* VDrawRect (&rect, PS_SOLID, 0, CL_FOREGROUND, COORD_STRETCH, DRAW_SET); // calculate string width (put the string on the center of control) VDrawString ((Coord)(ctlP->bounds.topLeft.x+((ctlP->bounds.extent.x-strWidth)/2)), (ctlP->bounds.topLeft.y), ctlP->text, Vstrlen(ctlP->text), SINGLELINE, CL_BACKGROUND, COORD_STRETCH); */ ctlP->attr.on = 1; for ( i = 0; i < ActiveForm->numObjects; i++ ) { // if other same group push button is on, off it if ( (i != ActiveObjIndex) && (ActiveForm->objects[i].objectType == frmControlObj) && (ActiveForm->objects[i].object.control->style == pushButtonCtl) && (ActiveForm->objects[i].object.control->attr.on) ) { ctlP = ActiveForm->objects[i].object.control; rect.topLeft.x = (ctlP->bounds.topLeft.x+1); rect.topLeft.y = (ctlP->bounds.topLeft.y+1); // get the width of string strWidth = FntCharsWidth (ctlP->text, (Int16)Vstrlen(ctlP->text)); if ( ctlP->bounds.extent.x == -1 ) { rect.extent.x = strWidth+2; } else { rect.extent.x = (ctlP->bounds.extent.x-3); } if ( ctlP->bounds.extent.y == -1 ) { rect.extent.y = FntCharHeight()-3; } else { rect.extent.y = (ctlP->bounds.extent.y-4); } VDrawRect (&rect, PS_SOLID, 0, CL_FOREGROUND, COORD_STRETCH, DRAW_XOR); /* VDrawRect (&rect, PS_SOLID, 0, CL_FOREGROUND, COORD_STRETCH, DRAW_SET); VDrawString ((Coord)(ctlP->bounds.topLeft.x+((ctlP->bounds.extent.x-strWidth)/2)), (ctlP->bounds.topLeft.y), ctlP->text, Vstrlen(ctlP->text), SINGLELINE, CL_FOREGROUND, COORD_STRETCH); */ ctlP->attr.on = 0; } } } } } // end of if ( (ActiveForm->objects[ActiveObjIndex].objectType == frmControlObj) ) { /* } else if ( event->eType == popSelectEvent ) { Int16 theIndex, i, listObjIndex = -1; UInt16 hitObjIndex = ActiveObjIndex; UInt16 popupID = ActiveForm->objects[ActiveObjIndex].object.control->id; UInt16 listID=0; event->data.popSelect.controlP = (ControlType *)ActiveForm->objects[ActiveObjIndex].object.control; for ( i = 0; i < ActiveForm->numObjects; i++ ) { if ( (ActiveForm->objects[i].objectType == frmPopupObj) && (popupID == ActiveForm->objects[i].object.popup->controlID) ) { listID = ActiveForm->objects[i].object.popup->listID; break; } } if ( listID ) { event->data.popSelect.listID = listID; for ( i = 0; i < ActiveForm->numObjects; i++ ) { if ( (ActiveForm->objects[i].objectType == frmListObj) && (listID == ActiveForm->objects[i].object.list->id) ) { listObjIndex = i; event->data.popSelect.listP = ActiveForm->objects[ActiveObjIndex].object.list; break; } } if ( listObjIndex >= 0 ) { ListType *listP = (ListType *)ActiveForm->objects[listObjIndex].object.list; event->data.popSelect.priorSelection = LstGetSelection (listP); theIndex = LstPopupList(listP); if (theIndex >= 0) { RectangleType rect; ControlType *controlP; int strWidth; event->data.popSelect.selection = theIndex; ActiveObjIndex = hitObjIndex; controlP = (ControlType *)ActiveForm->objects[ActiveObjIndex].object.control; // clear the control first Vmemcpy (&rect, &(controlP->bounds), sizeof(RectangleType)); strWidth = FntCharsWidth (controlP->text, (Int16)Vstrlen(controlP->text)); // recalculate size if attribute is AUTO if ( controlP->bounds.extent.x == -1 ) { rect.extent.x = strWidth; if ( controlP->style == popupTriggerCtl ) rect.extent.x += ArrowWidth; } if ( controlP->bounds.extent.y == -1 ) { rect.extent.y = FntCharHeight(); } VDrawRect (&rect, PS_SOLID, 0, CL_BACKGROUND, COORD_STRETCH, DRAW_SET); // draw control CtlSetLabel (ActiveForm->objects[ActiveObjIndex].object.control, LstGetSelectionText(listP,theIndex)); } } } */ } else if ( event->eType == keyDownEvent ) { // CHECKBOX Style[0] is used for checked message FormObjListType object = ActiveForm->objects[ActiveObjIndex]; switch (object.objectType) { case frmTableObj: { TableType *tableP = object.object.table; UInt16 index = tableP->currentRow*tableP->numColumns+tableP->currentColumn; if ( !tableP->attr.editable ) return false; if ( tableP->items[index].ptr == NULL ) { tableP->items[index].ptr = (char *) Vmalloc(1); tableP->items[index].ptr[0] = 0; } tableP->items[index].ptr = (char *) Vrealloc(tableP->items[index].ptr, Vstrlen(tableP->items[index].ptr)+2); VAppendStr (tableP->items[index].ptr, (UInt16)event->data.keyDown.keyCode); VRedrawControl (object); } break; case frmFieldObj: { FieldType *fldP = object.object.field; if ( !fldP->attr.editable ) return false; FldInsert (fldP, (char*)&(event->data.keyDown.chr), 1); // VRedrawControl (object); break; } default : { /* ControlType *ctlP = object.object.control; if ( !ctlP->attr.enabled ) return false; if ( ctlP->text == NULL ) { ctlP->text = (char *) Vmalloc(1); ctlP->text[0] = 0; } ctlP->text = (char *) Vrealloc(ctlP->text, Vstrlen(ctlP->text)+2); VAppendStr (ctlP->text, (UInt16)event->data.keyDown.keyCode); VRedrawControl (object); */ break; } } } return 0; }
EXPORT void* malloc( size_t size ) { return Vmalloc(size); }