Changeset 2465 in Sophya for trunk/SophyaPI/PIext/piacmd.cc


Ignore:
Timestamp:
Nov 27, 2003, 11:51:58 AM (22 years ago)
Author:
ansari
Message:

Suite modification/adaptations a la classe PIACmd qui herite maintenent de SOPHYA::Commander - Reza 27/11/2003

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaPI/PIext/piacmd.cc

    r2463 r2465  
    4343  inline  void  AddHelpGroup(const char * hgrp, int gid)
    4444                    { hgrpom->AppendItem(hgrp, 20000+gid); }
     45  inline  void  AddHelpGroup(string const & hgrp, int gid)
     46                    { hgrpom->AppendItem(hgrp.c_str(), 20000+gid); }
    4547  inline  void  ClearHelpList()
    4648                    { mNitem=0; hitemlist->DeleteAllItems(); }
    4749  inline  void  AddHelpItem(const char * hitem)
    4850                    { mNitem++;  hitemlist->AppendItem(hitem, 100+mNitem); }
     51  inline  void  SetHelpTextLabel(string const & htxt, string const & hlab)
     52                    { mTxt->SetText(htxt); mLab->SetLabel(hlab); }
     53
    4954protected :
    5055  PIStdImgApp* dap;
     
    144149mObjMgr = omg;
    145150mImgApp = app;
    146 
    147 //MOVE if (mImgApp) mImgApp->GetConsole()->SetPrompt(spromptmul);
    148 //?? cmdhgrp["All"] = 0;
    149 //?? cmdgrpid = 1;
    150 //?? cmdhgrp["PIACmd"] = 1;
    151151helpwin = new PIAHelpWind(app, this);
    152 helpwin->AddHelpGroup("All", 0);
    153 // helpwin->AddHelpGroup("PIACmd", 1);
     152helpwin_initdone = false;
    154153
    155154string kw = "exitpiapp";
    156155string grp = "PIACmd";
     156string gdesc = "piapp interpreter (class PIACmd) additional builtin commands";
     157AddHelpGroup(grp, gdesc);
     158
    157159string usage = "To end the piapp session ";
    158160RegisterCommand(kw, usage, NULL, grp);
     
    175177cxxexwin  = new  CxxExecWind(app, cxxe);
    176178
     179InitializeHelpWindowMenu();
    177180}
    178181
     
    192195
    193196/* --Methode-- */
    194 int PIACmd::CheckHelpGrp(string& grp)
    195 {
    196 int gid=0;
    197 CmdHGroup::iterator it = cmdhgrp.find(grp);
    198 if (it == cmdhgrp.end()) {
    199   cmdgrpid++;   gid = cmdgrpid;
    200   cmdhgrp[grp] = gid;
    201   helpwin->AddHelpGroup(grp.c_str(), gid);
    202   }
    203 else gid = (*it).second;
    204 return(gid);
     197bool PIACmd::CheckHelpGrp(string& grp, int& gid, string& desc)
     198{
     199bool fgnewgrp = Commander::CheckHelpGrp(grp, gid, desc);
     200if (helpwin_initdone && fgnewgrp) helpwin->AddHelpGroup(grp.c_str(), gid);
     201return fgnewgrp;
    205202}
    206203
     
    209206{
    210207helpwin->ClearHelpList();
     208if (gid == 0) {
     209  string htxt = "All registered commands";
     210  string hlab = "All (HelpGroup)";
     211  helpwin->SetHelpTextLabel(htxt, hlab);
     212}
     213else {
     214  CmdHGroup::iterator ith;
     215  for(ith = cmdhgrp.begin(); ith != cmdhgrp.end(); ith++) {
     216    if ((*ith).second.gid == gid) {
     217      string hlab = (*ith).first;
     218      hlab += " (HelpGroup)";
     219      helpwin->SetHelpTextLabel((*ith).second.desc, hlab);
     220      break;
     221    }
     222  }
     223}
    211224CmdExmap::iterator it;
    212225for(it = helpexmap.begin(); it != helpexmap.end(); it++) {
     
    220233}
    221234
     235/* --Methode-- */
     236void PIACmd::InitializeHelpWindowMenu()
     237{
     238  helpwin->AddHelpGroup("All", 0);
     239  CmdHGroup::iterator it;
     240  for(it = cmdhgrp.begin(); it != cmdhgrp.end(); it++)
     241    helpwin->AddHelpGroup((*it).first, (*it).second.gid);
     242  helpwin_initdone = true;
     243}
    222244
    223245/* Fonction */
     
    247269
    248270// >>>>>>>>>>> Commande d'interpreteur
    249 if (kw == "helpwindow") ShowHelpWindow();
     271if (kw == "helpwindow") {
     272  ShowHelpWindow();
     273  return 0;
     274}
    250275// ----> Sortie d'application
    251276else if (kw == "exitpiapp") {
    252277  mImgApp->Stop();
    253   return(0);
     278  return 0;
    254279}
    255280else return Commander::ExecuteCommandLine(kw, tokens, toks);
    256 
     281return 0;
    257282}
    258283
Note: See TracChangeset for help on using the changeset viewer.