void CDKScroll::setparm(char * title, int xpos, int ypos, int height, int width) { func ("CDKScroll::setparm()"); //count = CDKgetDirectoryContents ("finta/", &item); // playlist finta item = (char **) malloc (512); count = 0; scroll = newCDKScroll ( cdkscreen, xpos, ypos, LEFT, height, width, title, item, count, NUMBERS, A_REVERSE, TRUE, FALSE ); }
void mostrar_scroll(CDKSCREEN *cdkScreen) { char *lista[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}; // char** items[2]; // items[0]="asdf"; // items[1]="edfsdaf"; char *titulo="dios"; char salir; int elegido; /* CDKSCREEN * cdkscreen , int xpos , int ypos , int spos , int height , int width , char * title , char ** itemList , int items , boolean numbers , chtype highlight , boolean Box , boolean shadow ); */ CDKSCROLL *menucito; do { menucito=newCDKScroll(cdkScreen, CENTER, CENTER, RIGHT, 10, 15, titulo, lista, 7, FALSE, A_REVERSE, TRUE, FALSE); elegido=activateCDKScroll(menucito,0); // destroyCDKScroll (menucito); popupLabel(cdkScreen,&lista[elegido],1); // hacer(elegido); // break; } while((salir=(getch())!='q')); destroyCDKScroll (menucito); // mostrar_info(cdkScreen); // hacer(elegido); endCDK(); }
static int show_section (CmdConfig *cmd_config, CameraWidget *section) { CameraWidget *child, *parent; CameraWidgetType type; CDKSCROLL *scroll = NULL; const char *label; char *items[100]; int count, x, selection; char title[1024]; int show_parent = 0, show_child = 0; /* Create the scroll list */ gp_widget_get_type (section, &type); gp_widget_get_label (section, &label); snprintf (title, sizeof (title), "<C></5>%s", label); if (type == GP_WIDGET_WINDOW) items[0] = copyChar (_("Exit")); else items[0] = copyChar (_("Back")); count = gp_widget_count_children (section); for (x = 0; x < count; x++) { gp_widget_get_child (section, x, &child); gp_widget_get_label (child, &label); items[x + 1] = copyChar ((char *) label); } count++; scroll = newCDKScroll (cmd_config->screen, CENTER, CENTER, RIGHT, 10, 50, title, items, count, NUMBERS, A_REVERSE, TRUE, FALSE); if (!scroll) return (GP_ERROR); selection = activateCDKScroll (scroll, 0); if (scroll->exitType == vNORMAL) { if (selection) show_child = selection; else if (type != GP_WIDGET_WINDOW) show_parent = 1; } /* Clean up */ destroyCDKScroll (scroll); if (show_parent) { gp_widget_get_parent (section, &parent); show_widget (cmd_config, parent); } else if (show_child) { gp_widget_get_child (section, show_child - 1, &child); show_widget (cmd_config, child); } return (GP_OK); }
void CDKScroll::setparm(char * title, int xpos, int ypos, int height, int width, char **item, int count, bool numbers, chtype highlight) { scroll = newCDKScroll ( cdkscreen, xpos, ypos, LEFT, height, width, title, item, count, numbers, highlight, TRUE, FALSE ); }
Meta* BrowseCurses::browse(clc::List* meta) { const unsigned int nItems = meta->size(); char* items[nItems]; for (unsigned int i = 0; i < nItems; ++i) { Meta* m = (Meta*)meta->get(i); items[i] = m->relPath.c_str(); } CDKSCROLL* scroll = newCDKScroll(m_screen, LEFT, TOP, RIGHT, 0, 0, "Select a book...", items, nItems, 0, 0, 1, 1); int r = activateCDKScroll(scroll, NULL); destroyCDKScroll(scroll); if (r == -1) { return (Meta*)0; } else { return (Meta*)meta->get(r); } }
int Simpletui::choice(string text, vector<string> choices) { const char **choiceChars=new const char*[choices.size()]; unsigned int width=0; for(size_t i=0;i<choices.size();i++) { choiceChars[i]=choices[i].c_str(); if(choices[i].length()>width) width=choices[i].length(); } SplitString sText(text); CDKSCROLL *scroll=newCDKScroll(reinterpret_cast<CDKSCREEN*>(cdk),CENTER,CENTER,RIGHT,choices.size()+sText.getLength()+2,width,const_cast<char*>(text.c_str()),const_cast<char**>(choiceChars),choices.size(),FALSE,A_STANDOUT,TRUE,FALSE); int result=activateCDKScroll(scroll,NULL); if(scroll->exitType!=vNORMAL) { destroyCDKScroll(scroll); throw STActionAborted(); } destroyCDKScroll(scroll); delete[] choiceChars; // deep-delete unnecessary, references will be destroyed when strings are return result; }
/* * This creates the alphalist widget. */ CDKALPHALIST *newCDKAlphalist (CDKSCREEN *cdkscreen, int xplace, int yplace, int height, int width, char *title, char *label, char **list, int listSize, chtype fillerChar, chtype highlight, boolean Box, boolean shadow) { CDKALPHALIST *alphalist = 0; chtype *chtypeLabel = 0; int parentWidth = getmaxx (cdkscreen->window); int parentHeight = getmaxy (cdkscreen->window); int boxWidth = width; int boxHeight = height; int xpos = xplace; int ypos = yplace; int tempWidth = 0; int tempHeight = 0; int labelLen = 0; int x, junk2; static const struct { int from; int to; } bindings[] = { { CDK_BACKCHAR, KEY_PPAGE }, { CDK_FORCHAR, KEY_NPAGE }, }; if ((alphalist = newCDKObject (CDKALPHALIST, &my_funcs)) == 0 || !createList (alphalist, list, listSize)) { destroyCDKObject (alphalist); return (0); } setCDKAlphalistBox (alphalist, Box); /* * 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); /* Translate the label char *pointer to a chtype pointer. */ if (label != 0) { chtypeLabel = char2Chtype (label, &labelLen, &junk2); freeChtype (chtypeLabel); } /* Rejustify the x and y positions if we need to. */ alignxy (cdkscreen->window, &xpos, &ypos, boxWidth, boxHeight); /* Make the file selector window. */ alphalist->win = newwin (boxHeight, boxWidth, ypos, xpos); if (alphalist->win == 0) { destroyCDKObject (alphalist); return (0); } keypad (alphalist->win, TRUE); /* Set some variables. */ ScreenOf (alphalist) = cdkscreen; alphalist->parent = cdkscreen->window; alphalist->highlight = highlight; alphalist->fillerChar = fillerChar; alphalist->boxHeight = boxHeight; alphalist->boxWidth = boxWidth; initExitType (alphalist); alphalist->shadow = shadow; alphalist->shadowWin = 0; /* Do we want a shadow? */ if (shadow) { alphalist->shadowWin = newwin (boxHeight, boxWidth, ypos + 1, xpos + 1); } /* Create the entry field. */ tempWidth = (isFullWidth (width) ? FULL : boxWidth - 2 - labelLen); alphalist->entryField = newCDKEntry (cdkscreen, getbegx (alphalist->win), getbegy (alphalist->win), title, label, A_NORMAL, fillerChar, vMIXED, tempWidth, 0, 512, Box, FALSE); if (alphalist->entryField == 0) { destroyCDKObject (alphalist); return (0); } setCDKEntryLLChar (alphalist->entryField, ACS_LTEE); setCDKEntryLRChar (alphalist->entryField, ACS_RTEE); /* Set the key bindings for the entry field. */ bindCDKObject (vENTRY, alphalist->entryField, KEY_UP, adjustAlphalistCB, alphalist); bindCDKObject (vENTRY, alphalist->entryField, KEY_DOWN, adjustAlphalistCB, alphalist); bindCDKObject (vENTRY, alphalist->entryField, KEY_NPAGE, adjustAlphalistCB, alphalist); bindCDKObject (vENTRY, alphalist->entryField, KEY_PPAGE, adjustAlphalistCB, alphalist); bindCDKObject (vENTRY, alphalist->entryField, KEY_TAB, completeWordCB, alphalist); /* Set up the post-process function for the entry field. */ setCDKEntryPreProcess (alphalist->entryField, preProcessEntryField, alphalist); /* * Create the scrolling list. It overlaps the entry field by one line if * we are using box-borders. */ tempHeight = getmaxy (alphalist->entryField->win) - BorderOf (alphalist); tempWidth = (isFullWidth (width) ? FULL : boxWidth - 1); alphalist->scrollField = newCDKScroll (cdkscreen, getbegx (alphalist->win), getbegy (alphalist->entryField->win) + tempHeight, RIGHT, boxHeight - tempHeight, tempWidth, 0, list, listSize, NONUMBERS, A_REVERSE, Box, FALSE); setCDKScrollULChar (alphalist->scrollField, ACS_LTEE); setCDKScrollURChar (alphalist->scrollField, ACS_RTEE); /* Setup the key bindings. */ for (x = 0; x < (int) SIZEOF (bindings); ++x) bindCDKObject (vALPHALIST, alphalist, bindings[x].from, getcCDKBind, (void *)(long)bindings[x].to); registerCDKObject (cdkscreen, vALPHALIST, alphalist); return (alphalist); }
/* * 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); }
/* * This creates the alphalist widget. */ CDKALPHALIST *newCDKAlphalist (CDKSCREEN *cdkscreen, int xplace, int yplace, int height, int width, char *title, char *label, char *list[], int listSize, chtype fillerChar, chtype highlight, boolean Box, boolean shadow) { /* Set up some variables. */ CDKALPHALIST *alphalist = newCDKObject(CDKALPHALIST, &my_funcs); chtype *chtypeLabel = 0; 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 = 0; int labelLen = 0; int x, junk2; /* * 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); /* Translate the label char *pointer to a chtype pointer. */ if (label != 0) { chtypeLabel = char2Chtype (label, &labelLen, &junk2); freeChtype (chtypeLabel); } /* Rejustify the x and y positions if we need to. */ alignxy (cdkscreen->window, &xpos, &ypos, boxWidth, boxHeight); /* Make the file selector window. */ alphalist->win = newwin (boxHeight, boxWidth, ypos, xpos); if (alphalist->win == 0) { return (0); } keypad (alphalist->win, TRUE); /* Set some variables. */ ScreenOf(alphalist) = cdkscreen; alphalist->parent = cdkscreen->window; alphalist->highlight = highlight; alphalist->fillerChar = fillerChar; alphalist->boxHeight = boxHeight; alphalist->boxWidth = boxWidth; alphalist->exitType = vNEVER_ACTIVATED; ObjOf(alphalist)->box = Box; alphalist->shadow = shadow; alphalist->shadowWin = 0; /* Do we want a shadow? */ if (shadow) { alphalist->shadowWin = newwin (boxHeight, boxWidth, ypos + 1, xpos + 1); } /* We need to sort the list before we use it. */ sortList (list, listSize); /* Copy the list information. */ for (x=0; x < listSize; x++) { alphalist->list[x] = copyChar (list[x]); } alphalist->listSize = listSize; /* Create the entry field. */ entryWidth = boxWidth - (labelLen + 4); alphalist->entryField = newCDKEntry (cdkscreen, getbegx(alphalist->win) + 1, getbegy(alphalist->win) + 1, title, label, A_NORMAL, fillerChar, vMIXED, entryWidth, 0, 512, Box, FALSE); setCDKEntryLLChar (alphalist->entryField, ACS_LTEE); setCDKEntryLRChar (alphalist->entryField, ACS_RTEE); /* Set the key bindings for the entry field. */ bindCDKObject (vENTRY, alphalist->entryField, KEY_UP, adjustAlphalistCB, alphalist); bindCDKObject (vENTRY, alphalist->entryField, KEY_DOWN, adjustAlphalistCB, alphalist); bindCDKObject (vENTRY, alphalist->entryField, KEY_NPAGE, adjustAlphalistCB, alphalist); bindCDKObject (vENTRY, alphalist->entryField, CONTROL('F'), adjustAlphalistCB, alphalist); bindCDKObject (vENTRY, alphalist->entryField, KEY_PPAGE, adjustAlphalistCB, alphalist); bindCDKObject (vENTRY, alphalist->entryField, CONTROL('B'), adjustAlphalistCB, alphalist); bindCDKObject (vENTRY, alphalist->entryField, KEY_TAB, completeWordCB, alphalist); /* Set up the post-process function for the entry field. */ setCDKEntryPreProcess (alphalist->entryField, preProcessEntryField, alphalist); /* Create the scrolling list. */ alphalist->scrollField = newCDKScroll (cdkscreen, getbegx(alphalist->win) + 1, getbegy(alphalist->win) + (alphalist->entryField)->titleLines + 3, RIGHT, boxHeight-((alphalist->entryField)->titleLines + 3), boxWidth-3, 0, list, listSize, NONUMBERS, A_REVERSE, Box, FALSE); setCDKScrollULChar (alphalist->scrollField, ACS_LTEE); setCDKScrollURChar (alphalist->scrollField, ACS_RTEE); /* Register this baby. */ registerCDKObject (cdkscreen, vALPHALIST, alphalist); /* Return the file selector pointer. */ return (alphalist); }
int main(int argc, char *argv[]){ /* Read config file */ clit_config *config = malloc(sizeof(clit_config)); parse_config(config); printf("key:%s,secret:%s\n",config->key,config->secret); /* If no user info exists, intialize oauth process */ init_oauth(config->key,config->secret); create_filters(); home = malloc(sizeof(statuses)); home->count = 0; setlocale(LC_ALL,""); CDKSCREEN *cdkscreen = 0; CDKSCROLL *home_scroll = 0; WINDOW *cursesWin = 0; char *title = "<C><\5>Home"; char **home_items = 0; int selection,count; char *tmpfile = get_home(); count = load_timeline(tmpfile,home); printf("count:%d\n",count); home_items = malloc(count*sizeof(char *)); CDK_PARAMS params; CDKparseParams (argc, argv, ¶ms, "cs:t:" CDK_CLI_PARAMS); cursesWin = initscr(); cdkscreen = initCDKScreen(cursesWin); initCDKColor(); status *p = home->head; for(int i=0;i<count;++i){ if(p){ home_items[i] = p->text; p = p->next; } else break; } // count = CDKgetDirectoryContents (".", &home_items); home_scroll = newCDKScroll(cdkscreen, CDKparamValue (¶ms, 'X', CENTER), CDKparamValue (¶ms, 'Y', CENTER), CDKparsePosition(CDKparamString2(¶ms, 's', "RIGHT")), CDKparamValue (¶ms, 'H', 0), CDKparamValue (¶ms, 'W', 0), CDKparamString2(¶ms, 't', title), CDKparamNumber(¶ms, 'c') ? 0 : home_items, CDKparamNumber(¶ms, 'c') ? 0 : count, TRUE, A_REVERSE, CDKparamValue (¶ms, 'N', TRUE), CDKparamValue (¶ms, 'S', FALSE)); if(home_scroll == 0){ destroyCDKScreen(cdkscreen); endCDK(); exit(EXIT_FAILURE); } if (CDKparamNumber(¶ms, 'c')){ setCDKScrollItems (home_scroll, home_items, count, TRUE); } selection = activateCDKScroll (home_scroll, 0); char ch = '\0'; while((ch = getch()) != 'q'){ switch(ch){ case 'n': break; } } //CDKfreeStrings (home_items); destroyCDKScroll(home_scroll); destroyCDKScreen(cdkscreen); endCDK(); exit(EXIT_SUCCESS); }
void menu_scroll(CDKSCREEN *cdkScreen) { /* WINDOW *scrollwin; scrollwin=newwin(20,20,10,10); box(scrollwin,0,0); mvwaddstr(scrollwin,2,2,"dios"); wrefresh (scrollwin);*/ // refresh(); char *opciones[]={"Proveedores","Tecnicos","Clientes","salir"}; CDKSCROLL *scroll; int elegido; do{ scroll=newCDKScroll (cdkScreen, 2, 2, RIGHT,10, 20, "<C>Menu", opciones, 4, TRUE, A_REVERSE, TRUE, FALSE ); elegido=activateCDKScroll(scroll,0); //refreshCDKScreen(cdkScreen); // //refresh(); switch(elegido) { case 0: destroyCDKScroll(scroll); //unregisterCDKObject(vSCROLL,scroll); // refreshCDKScreen(cdkScreen); //getch(); proveedores(); // registerCDKObject(cdkScreen,vSCROLL,scroll); //produccion(); break; case 1: destroyCDKScroll(scroll); tecnicos(); //administracion(); break; case 2: // mvwaddstr(cdkScreen->window,2,2,"dios"); // wrefresh(cdkScreen->window); // getch(); clientes(); break; case 3: endCDK(); exit(0); } }while(elegido!=3); getch(); }
CCDKScroll::CCDKScroll(CDKSCREEN *pScreen, int x, int y, int h, int w, int sbpos, char *title, char **list, int lcount, bool box, bool numbers, bool shadow) : CBaseCDKWidget(box) { m_pScroll = newCDKScroll(CDKScreen, x, y, sbpos, h, w, title, list, lcount, numbers, A_REVERSE, box, shadow); if (!m_pScroll) throwerror(false, "Could not create scroll window"); }