Example #1
0
static void _setMyLLchar (CDKOBJS *object, chtype character)
{
   CDKALPHALIST *alphalist = (CDKALPHALIST *)object;

   setCDKScrollLLChar (alphalist->scrollField, character);
}
Example #2
0
File: fselect.c Project: dyne/MuSE
void setCDKFselectLLChar (CDKFSELECT *fselect, chtype character)
{
   setCDKScrollLLChar (fselect->scrollField, character);
}
Example #3
0
void setCDKAlphalistLLChar (CDKALPHALIST *alphalist, chtype character)
{
   setCDKScrollLLChar (alphalist->scrollField, character);
}
Example #4
0
void CDKScroll::llhook (chtype ch)
{
    setCDKScrollLLChar (scroll, ch);
}
bool ConfParams()
{
    param_entry_s *pFirstParam = NULL;
    std::vector<char *> ParamItems;

    for (std::list<command_entry_s *>::iterator p=InstallInfo.command_entries.begin();p!=InstallInfo.command_entries.end();
         p++)
    {
        for (std::map<std::string, param_entry_s *>::iterator p2=(*p)->parameter_entries.begin();
             p2!=(*p)->parameter_entries.end();p2++)
        {
            if (!pFirstParam) pFirstParam = p2->second;
            ParamItems.push_back(MakeCString(p2->first));
        }
    }

    if (!pFirstParam) return true; // No command entries...no need for this screen
    
    char *title = CreateText("<C></B/29>%s<!29!B>", GetTranslation("Configure parameters"));
    char *buttons[3] = { GetTranslation("Edit parameter"), GetTranslation("Continue"), GetTranslation("Cancel") };
    
    ButtonBar.Clear();
    ButtonBar.AddButton("TAB", "Next button");
    ButtonBar.AddButton("ENTER", "Activate button");
    ButtonBar.AddButton("Arrows", "Navigate menu");
    ButtonBar.AddButton("A", "About");
    ButtonBar.AddButton("ESC", "Exit program");
    ButtonBar.Draw();
    
    CCDKButtonBox ButtonBox(CDKScreen, CENTER, GetDefaultHeight()-1, 1, GetDefaultWidth(), 0, 1, 3, buttons, 3);
    ButtonBox.SetBgColor(5);

    CCDKScroll ScrollList(CDKScreen, getbegx(ButtonBox.GetBBox()->win), 2, getbegy(ButtonBox.GetBBox()->win)-1,
                          GetDefaultWidth()/2, RIGHT,
                          title, &ParamItems[0], ParamItems.size());
    ScrollList.SetBgColor(5);
    ScrollList.Bind('a', ShowAboutK);

    const int defh = 3;
    
    CCDKSWindow DescWindow(CDKScreen, (getbegx(ScrollList.GetScroll()->win) + getmaxx(ScrollList.GetScroll()->win))-1, 2,
                           getmaxy(ScrollList.GetScroll()->win)-defh-1, (GetDefaultWidth()/2)+1, CreateText("<C></B/29>%s<!29!B>",
                           GetTranslation("Description")), 30);
    DescWindow.SetBgColor(5);
    DescWindow.AddText(GetTranslation(pFirstParam->description));
    
    CCDKSWindow DefWindow(CDKScreen, (getbegx(ScrollList.GetScroll()->win) + getmaxx(ScrollList.GetScroll()->win))-1,
                          getmaxy(DescWindow.GetSWin()->win), defh, (GetDefaultWidth()/2)+1, NULL, 4);
    DefWindow.SetBgColor(5);
    
    const char *str = pFirstParam->defaultval.c_str();
    if (pFirstParam->param_type == PTYPE_BOOL)
    {
        if (!strcmp(str, "true")) str = GetTranslation("Enabled");
        else str = GetTranslation("Disabled");
    }
    
    DefWindow.AddText(CreateText("</B/29>%s:<!29!B> %s", GetTranslation("Default"), str), false);
    DefWindow.AddText(CreateText("</B/29>%s:<!29!B> %s", GetTranslation("Current"), str), false);

    setCDKScrollLLChar(ScrollList.GetScroll(), ACS_LTEE);
    setCDKScrollLRChar(ScrollList.GetScroll(), ACS_BTEE);
    setCDKScrollURChar(ScrollList.GetScroll(), ACS_TTEE);
    setCDKSwindowULChar(DescWindow.GetSWin(), ACS_TTEE);
    setCDKSwindowLLChar(DescWindow.GetSWin(), ACS_LTEE);
    setCDKSwindowLRChar(DescWindow.GetSWin(), ACS_RTEE);
    setCDKSwindowURChar(DefWindow.GetSWin(), ACS_RTEE);
    setCDKSwindowLRChar(DefWindow.GetSWin(), ACS_RTEE);
    setCDKButtonboxULChar(ButtonBox.GetBBox(), ACS_LTEE);
    setCDKButtonboxURChar(ButtonBox.GetBBox(), ACS_RTEE);
    
    ButtonBox.Draw();
    DescWindow.Draw();
    DefWindow.Draw();
    
    void *Data[4] = { &DescWindow, &DefWindow, &ScrollList, &ParamItems };
    setCDKScrollPreProcess(ScrollList.GetScroll(), ScrollParamMenuK, &Data);

    ScrollList.Bind(KEY_TAB, SwitchButtonK, ButtonBox.GetBBox());
    
    bool success = false;
    while(1)
    {
        int selection = ScrollList.Activate();
    
        if (ScrollList.ExitType() == vNORMAL)
        {
            if (ButtonBox.GetCurrent() == 1)
            {
                success = true;
                break;
            }
            else if (ButtonBox.GetCurrent() == 2)
            {
                success = false;
                break;
            }
            
            param_entry_s *pParam = GetParamByName(ParamItems[selection]);
            
            if (pParam->param_type == PTYPE_DIR)
            {
                CFileDialog filedialog(GetFirstValidDir(pParam->value),
                                       CreateText("<C>%s", GetTranslation("Select a directory")),  true, false);
                if (filedialog.Activate()) pParam->value = filedialog.Result();
                filedialog.Destroy();
                refreshCDKScreen(CDKScreen);
            }
            else if (pParam->param_type == PTYPE_STRING)
            {
                CCDKEntry entry(CDKScreen, CENTER, CENTER, GetTranslation("Please enter new value"), "", 40, 0, 256);
                entry.SetBgColor(26);
                entry.SetValue(pParam->value);
                
                const char *newval = entry.Activate();
                
                if ((entry.ExitType() == vNORMAL) && newval)
                    pParam->value = newval;
                
                // Restore screen
                entry.Destroy();
                refreshCDKScreen(CDKScreen);
            }
            else
            {
                std::vector<char *> chitems;
                int cur = 0;
                
                if (pParam->param_type == PTYPE_BOOL)
                {
                    chitems.push_back(GetTranslation("Disable"));
                    chitems.push_back(GetTranslation("Enable"));
                    cur = (pParam->value == "true") ? 1 : 0;
                }
                else
                {
                    int i = 0;
                    for (std::list<std::string>::iterator it=pParam->options.begin(); it!=pParam->options.end();it++, i++)
                    {
                        chitems.push_back(GetTranslation(MakeCString(*it)));
                        if (*it == pParam->value)
                            cur = i;
                    }
                }
                
                CCDKScroll chScrollList(CDKScreen, CENTER, CENTER, 6, 30, RIGHT,
                                        GetTranslation("Please choose new value"), &chitems[0], chitems.size());
                chScrollList.SetBgColor(26);
                chScrollList.SetCurrent(cur);
                
                int chsel = chScrollList.Activate();
                
                if (chScrollList.ExitType() == vNORMAL)
                {
                    if (pParam->param_type == PTYPE_BOOL)
                    {
                        if (!strcmp(chitems[chsel], GetTranslation("Enable"))) pParam->value = "true";
                        else pParam->value = "false";
                    }
                    else
                        pParam->value = chitems[chsel];
                }
                    
                chScrollList.Destroy();
                refreshCDKScreen(CDKScreen);
            }

            DefWindow.Clear();
            DefWindow.AddText(CreateText("</B/29>%s:<!29!B> %s", GetTranslation("Default"), GetParamDefault(pParam)),
                              false);
            DefWindow.AddText(CreateText("</B/29>%s:<!29!B> %s", GetTranslation("Current"), GetParamValue(pParam)),
                              false);
        }
        else
        {
            success = false;
            break;
        }
    }
    
    return success;
}