/* * This function destroys the scale widget. */ void destroyCDKFScale (CDKFSCALE *scale) { int x; /* Erase the object. */ eraseCDKFScale (scale); /* Clean up the char pointers. */ freeChtype (scale->label); for (x=0; x < scale->titleLines; x++) { freeChtype (scale->title[x]); } /* Clean up the windows. */ deleteCursesWindow (scale->fieldWin); deleteCursesWindow (scale->labelWin); deleteCursesWindow (scale->shadowWin); deleteCursesWindow (scale->win); /* Unregister this object. */ unregisterCDKObject (vFSCALE, scale); /* Finish cleaning up. */ free (scale); }
/* * This destroys the file selector. */ void destroyCDKFselect (CDKFSELECT *fselect) { /* Erase the file selector. */ eraseCDKFselect (fselect); /* Free up the character pointers. */ freeChar (fselect->pwd); freeChar (fselect->pathname); freeChar (fselect->dirAttribute); freeChar (fselect->fileAttribute); freeChar (fselect->linkAttribute); freeChar (fselect->sockAttribute); freeCharList (fselect->dirContents, fselect->fileCounter); /* Destroy the other Cdk objects. */ destroyCDKScroll (fselect->scrollField); destroyCDKEntry (fselect->entryField); /* Free up the window pointers. */ deleteCursesWindow (fselect->shadowWin); deleteCursesWindow (fselect->win); /* Unregister the object. */ unregisterCDKObject (vFSELECT, fselect); /* Free up the object pointer. */ free (fselect); }
/* * This function destroys the dialog widget. */ void destroyCDKDialog (CDKDIALOG *dialog) { /* Declare local variables. */ int x = 0; /* Erase the object. */ eraseCDKDialog (dialog); /* Clean up the char pointers. */ for (x=0; x < dialog->messageRows ; x++) { freeChtype (dialog->info[x]); } for (x=0; x < dialog->buttonCount; x++) { freeChtype (dialog->buttonLabel[x]); } /* Clean up the windows. */ deleteCursesWindow (dialog->win); deleteCursesWindow (dialog->shadowWin); /* Unregister this object. */ unregisterCDKObject (vDIALOG, dialog); /* Finish cleaning up. */ free (dialog); }
/* * This destroys the widget. */ static void _destroyCDKMarquee (CDKOBJS *object) { if (object != 0) { CDKMARQUEE *widget = (CDKMARQUEE *)object; /* Clean up the windows. */ deleteCursesWindow (widget->shadowWin); deleteCursesWindow (widget->win); /* Clean the key bindings. */ cleanCDKObjectBindings (vMARQUEE, widget); /* Unregister this object. */ unregisterCDKObject (vMARQUEE, widget); } }
/* * This destroys the button object pointer. */ static void _destroyCDKButton (CDKOBJS *object) { if (object != 0) { CDKBUTTON *button = (CDKBUTTON *)object; /* Free up the character pointers. */ freeChtype (button->info); /* Free up the window pointers. */ deleteCursesWindow (button->shadowWin); deleteCursesWindow (button->win); /* Clean the key bindings. */ cleanCDKObjectBindings (vBUTTON, button); /* Unregister the object. */ unregisterCDKObject (vBUTTON, button); } }
/* * This destroys the file selector. */ void destroyCDKAlphalist (CDKALPHALIST *alphalist) { /* Erase the file selector. */ eraseCDKAlphalist (alphalist); freeCharList (alphalist->list, alphalist->listSize); /* Destroy the other Cdk objects. */ destroyCDKEntry (alphalist->entryField); destroyCDKScroll (alphalist->scrollField); /* Free up the window pointers. */ deleteCursesWindow (alphalist->shadowWin); deleteCursesWindow (alphalist->win); /* Unregister the object. */ unregisterCDKObject (vALPHALIST, alphalist); /* Free up the object pointer. */ free (alphalist); }
/* * This destroys the file selector. */ static void _destroyCDKAlphalist (CDKOBJS *object) { if (object != 0) { CDKALPHALIST *alphalist = (CDKALPHALIST *)object; destroyInfo (alphalist); /* Clean the key bindings. */ cleanCDKObjectBindings (vALPHALIST, alphalist); destroyCDKEntry (alphalist->entryField); destroyCDKScroll (alphalist->scrollField); /* Free up the window pointers. */ deleteCursesWindow (alphalist->shadowWin); deleteCursesWindow (alphalist->win); /* Unregister the object. */ unregisterCDKObject (vALPHALIST, alphalist); } }
/* * This function destroys the widget. */ static void _destroyCDKUScale (CDKOBJS *object) { if (object != 0) { CDKUSCALE *widget = (CDKUSCALE *)object; cleanCdkTitle (object); freeChtype (widget->label); /* Clean up the windows. */ deleteCursesWindow (widget->fieldWin); deleteCursesWindow (widget->labelWin); deleteCursesWindow (widget->shadowWin); deleteCursesWindow (widget->win); /* Clean the key bindings. */ cleanCDKObjectBindings (vUSCALE, widget); /* Unregister this object. */ unregisterCDKObject (vUSCALE, widget); } }
/* * This function destroys */ static void _destroyCDKScroll (CDKOBJS *object) { if (object != 0) { CDKSCROLL *scrollp = (CDKSCROLL *)object; cleanCdkTitle (object); CDKfreeChtypes (scrollp->item); freeChecked (scrollp->itemPos); freeChecked (scrollp->itemLen); /* Clean up the windows. */ deleteCursesWindow (scrollp->scrollbarWin); deleteCursesWindow (scrollp->shadowWin); deleteCursesWindow (scrollp->listWin); deleteCursesWindow (scrollp->win); /* Clean the key bindings. */ cleanCDKObjectBindings (vSCROLL, scrollp); /* Unregister this object. */ unregisterCDKObject (vSCROLL, scrollp); } }
/* * This creates a file selection widget. */ CDKFSELECT *newCDKFselect (CDKSCREEN *cdkscreen, int xplace, int yplace, int height, int width, char *title, char *label, chtype fieldAttribute, chtype fillerChar, chtype highlight, char *dAttribute, char *fAttribute, char *lAttribute, char *sAttribute, boolean Box, boolean shadow) { /* Set up some variables. */ CDKFSELECT *fselect = newCDKObject(CDKFSELECT, &my_funcs); int parentWidth = getmaxx(cdkscreen->window) - 1; int parentHeight = getmaxy(cdkscreen->window) - 1; int boxWidth = width; int boxHeight = height; int xpos = xplace; int ypos = yplace; int entryWidth, x, labelLen, junk; chtype *chtypeString; /* * If the height is a negative value, the height will * be ROWS-height, otherwise, the height will be the * given height. */ boxHeight = setWidgetDimension (parentHeight, height, 0); /* * If the width is a negative value, the width will * be COLS-width, otherwise, the width will be the * given width. */ boxWidth = setWidgetDimension (parentWidth, width, 0); /* Rejustify the x and y positions if we need to. */ alignxy (cdkscreen->window, &xpos, &ypos, boxWidth, boxHeight); /* Make sure the box isn't too small. */ boxWidth = (boxWidth < 15 ? 15 : boxWidth); boxHeight = (boxHeight < 6 ? 6 : boxHeight); /* Make the file selector window. */ fselect->win = newwin (boxHeight, boxWidth, ypos, xpos); /* Is the window null? */ if (fselect->win == 0) { return (0); } keypad (fselect->win, TRUE); /* Set some variables. */ ScreenOf(fselect) = cdkscreen; fselect->parent = cdkscreen->window; fselect->dirAttribute = copyChar (dAttribute); fselect->fileAttribute = copyChar (fAttribute); fselect->linkAttribute = copyChar (lAttribute); fselect->sockAttribute = copyChar (sAttribute); fselect->highlight = highlight; fselect->fillerCharacter = fillerChar; fselect->fieldAttribute = fieldAttribute; fselect->boxHeight = boxHeight; fselect->boxWidth = boxWidth; fselect->fileCounter = 0; fselect->pwd = 0; fselect->exitType = vNEVER_ACTIVATED; ObjOf(fselect)->box = Box; fselect->shadow = shadow; fselect->shadowWin = 0; /* Zero out the contents of the directory listing. */ for (x=0; x < MAX_ITEMS; x++) { fselect->dirContents[x] = 0; } /* Get the present working directory. */ setPWD(fselect); /* Get the contents of the current directory. */ setCDKFselectDirContents (fselect); /* Create the entry field in the selector. */ chtypeString = char2Chtype (label, &labelLen, &junk); freeChtype (chtypeString); entryWidth = boxWidth - labelLen - 3; fselect->entryField = newCDKEntry (cdkscreen, getbegx(fselect->win), getbegy(fselect->win), title, label, fieldAttribute, fillerChar, vMIXED, entryWidth, 0, 512, Box, FALSE); /* Make sure the widget was created. */ if (fselect->entryField == 0) { /* Clean up. */ freeCharList (fselect->dirContents, MAX_ITEMS); freeChar (fselect->pwd); freeChar (fselect->dirAttribute); freeChar (fselect->fileAttribute); freeChar (fselect->linkAttribute); freeChar (fselect->sockAttribute); deleteCursesWindow (fselect->win); return (0); } /* Set the lower left/right characters of the entry field. */ setCDKEntryLLChar (fselect->entryField, ACS_LTEE); setCDKEntryLRChar (fselect->entryField, ACS_RTEE); /* Define the callbacks for the entry field. */ bindCDKObject (vENTRY, fselect->entryField, KEY_UP, fselectAdjustScrollCB, fselect); bindCDKObject (vENTRY, fselect->entryField, KEY_PPAGE, fselectAdjustScrollCB, fselect); bindCDKObject (vENTRY, fselect->entryField, CONTROL('B'), fselectAdjustScrollCB, fselect); bindCDKObject (vENTRY, fselect->entryField, KEY_DOWN, fselectAdjustScrollCB, fselect); bindCDKObject (vENTRY, fselect->entryField, KEY_NPAGE, fselectAdjustScrollCB, fselect); bindCDKObject (vENTRY, fselect->entryField, CONTROL('F'), fselectAdjustScrollCB, fselect); bindCDKObject (vENTRY, fselect->entryField, KEY_TAB, completeFilenameCB, fselect); bindCDKObject (vENTRY, fselect->entryField, CONTROL('^'), displayFileInfoCB, fselect); /* Put the current working directory in the entry field. */ setCDKEntryValue (fselect->entryField, fselect->pwd); /* Create the scrolling list in the selector. */ fselect->scrollField = newCDKScroll (cdkscreen, getbegx(fselect->win), getbegy(fselect->win) + (fselect->entryField)->titleLines + 2, RIGHT, boxHeight - (fselect->entryField)->titleLines - 3, boxWidth-2, 0, fselect->dirContents, fselect->fileCounter, NONUMBERS, fselect->highlight, Box, FALSE); /* Set the lower left/right characters of the entry field. */ setCDKScrollULChar (fselect->scrollField, ACS_LTEE); setCDKScrollURChar (fselect->scrollField, ACS_RTEE); /* Do we want a shadow? */ if (shadow) { fselect->shadowWin = newwin (boxHeight, boxWidth, ypos + 1, xpos + 1); } /* Register this baby. */ registerCDKObject (cdkscreen, vFSELECT, fselect); /* Return the file selector pointer. */ return (fselect); }