Index: trunk/SophyaPI/PIext/piacmd.cc
===================================================================
--- trunk/SophyaPI/PIext/piacmd.cc	(revision 324)
+++ trunk/SophyaPI/PIext/piacmd.cc	(revision 330)
@@ -24,7 +24,12 @@
 		PIAHelpWind(PIStdImgApp* par, PIACmd* piacmd);
   virtual	~PIAHelpWind();
+  virtual void  Show();
   virtual void  Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
+  inline  void  AddHelpGroup(const char * hgrp, int gid)
+                    { hgrpom->AppendItem(hgrp, 20000+gid); }
+  inline  void  ClearHelpList() 
+                    { mNitem=0; hitemlist->DeleteAllItems(); }
   inline  void	AddHelpItem(const char * hitem) 
-			{ mNitem++;  hitemlist->AppendItem(hitem, 1000+mNitem); }
+		    { mNitem++;  hitemlist->AppendItem(hitem, 100+mNitem); }
 protected :
   PIStdImgApp* dap;
@@ -32,4 +37,5 @@
   int mNitem;
   PIList* hitemlist;
+  PIOptMenu* hgrpom;
   PIButton * mBut;
   PILabel * mLab;
@@ -44,5 +50,5 @@
 piac = piacmd;
 mNitem = 0;
-SetMsg(777);
+SetMsg(77);
 
 int bsx, bsy;
@@ -53,5 +59,7 @@
 tsx = 10*bsx+2*spx;  tsy = 7*bsy+3*spy;
 SetSize(tsx,tsy);
-hitemlist = new PIList(this, "hitemlist", bsx*2.0, tsy-2*spy, spx/2, spy);
+hgrpom = new PIOptMenu(this, "hgrpoptmen", bsx*2.0, bsy, spx/2, spy);
+hgrpom->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
+hitemlist = new PIList(this, "hitemlist", bsx*2.0, tsy-3*spy-bsy, spx/2, 2*spy+bsy);
 hitemlist->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
 // hitemlist->SetBorderWidth(2);
@@ -65,5 +73,5 @@
 mLab->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
 mLab->SetLabel("");
-mBut = new PIButton(this, "Close", 700, bsx, bsy, tsx-bsx*1.5-spx, tsy-spy-bsy);
+mBut = new PIButton(this, "Close", 70, bsx, bsy, tsx-bsx*1.5-spx, tsy-spy-bsy);
 mBut->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
 }
@@ -72,4 +80,5 @@
 PIAHelpWind::~PIAHelpWind()
 {
+delete hgrpom;
 delete hitemlist;
 delete mTxt;
@@ -82,9 +91,14 @@
 {
 PIMessage um = UserMsg(msg);
-if (((um == 777) && (ModMsg(msg) == PIMsg_Close)) || (um == 700) ) {
+if (((um == 77) && (ModMsg(msg) == PIMsg_Close)) || (um == 70) ) {
   Hide();
   return;
   }
-else if ( (um > 1000) && (sender == hitemlist)) {
+else if ( (um >= 20000) && (sender == hgrpom)) {  // Selection de groupe de Help
+  mTxt->SetText("");
+  mLab->SetLabel("");
+  piac->UpdateHelpList(this, um-20000);
+}
+else if ( (um > 100) && (sender == hitemlist) && (ModMsg(msg) == PIMsg_Select) ) {
   string s = hitemlist->GetSelectionStr();
   mTxt->SetText(piac->GetUsage(s));
@@ -93,4 +107,13 @@
 }
 
+/* --Methode-- */
+void PIAHelpWind::Show()
+{
+hgrpom->SetValue(20000);   // Groupe All
+mTxt->SetText("");
+mLab->SetLabel("");
+piac->UpdateHelpList(this, 0); 
+PIWindow::Show();
+}
 
 static PIACmd* curpiacmd = NULL;
@@ -105,5 +128,10 @@
 gltimer = NULL;
 
+cmdhgrp["All"] = 0;
+cmdgrpid = 1;
+cmdhgrp["Commands"] = 1;
 helpwin = new PIAHelpWind(app, this);
+helpwin->AddHelpGroup("All", 0);
+helpwin->AddHelpGroup("Commands", 1);
 
 string kw = "piacmd";
@@ -120,5 +148,6 @@
 usage += "  > help <command_name>  # <command_name> usage info \n"; 
 usage += "  > helpwindow           # Displays help window \n";
-RegisterCommand(kw, usage, NULL);
+string grp = "Commands";
+RegisterHelp(kw, usage, grp);
 
 basexec = new PIABaseExecutor(this, omg, app);
@@ -156,12 +185,56 @@
 
 /* --Methode-- */
-void PIACmd::RegisterCommand(string& keyw, string& usage, CmdExecutor * ce)
-{
-  // if (!ce) return;
+void PIACmd::RegisterCommand(string& keyw, string& usage, CmdExecutor * ce, string grp)
+{
+if (!ce) { 
+  RegisterHelp(keyw, usage, grp);
+  return;
+  }
+int gid = CheckHelpGrp(grp);
 cmdex cme;
+cme.group = gid;
 cme.us = usage;
 cme.cex = ce;
 cmdexmap[keyw] = cme;
-if (helpwin) helpwin->AddHelpItem(keyw.c_str());
+}
+
+/* --Methode-- */
+void PIACmd::RegisterHelp(string& keyw, string& usage, string& grp)
+{
+int gid = CheckHelpGrp(grp);
+cmdex cme;
+cme.group = gid;
+cme.us = usage;
+cme.cex = NULL;
+helpexmap[keyw] = cme;
+}
+
+/* --Methode-- */
+int PIACmd::CheckHelpGrp(string& grp)
+{
+int gid=0;
+CmdHGroup::iterator it = cmdhgrp.find(grp);
+if (it == cmdhgrp.end()) {
+  cmdgrpid++;   gid = cmdgrpid;
+  cmdhgrp[grp] = gid;
+  helpwin->AddHelpGroup(grp.c_str(), gid);
+  }
+else gid = (*it).second;
+return(gid);
+}
+
+/* --Methode-- */
+void PIACmd::UpdateHelpList(PIAHelpWind* hw, int gid)
+{
+helpwin->ClearHelpList();
+CmdExmap::iterator it;
+for(it = helpexmap.begin(); it != helpexmap.end(); it++) {
+  if ( (gid != 0) && ((*it).second.group != gid) ) continue;
+  helpwin->AddHelpItem((*it).first.c_str());
+  }
+for(it = cmdexmap.begin(); it != cmdexmap.end(); it++) {
+  if ( (gid != 0) && ((*it).second.group != gid) ) continue;
+  helpwin->AddHelpItem((*it).first.c_str());
+  }
 }
 
@@ -252,25 +325,10 @@
 if (kw == "helpwindow") ShowHelpWindow();
 else if (kw == "help") {
-  if (tokens.size() > 0) {
-    CmdExmap::iterator it = cmdexmap.find(tokens[0]);
-    if (it == cmdexmap.end())  cout << "Nothing known about " << tokens[0] << " ?? " << endl;
-    else cout << (*it).second.us << endl;
+  if (tokens.size() > 0) cout << GetUsage(tokens[0]) << endl;
+  else {  
+    string kwh = "piacmd";
+    cout << GetUsage(kwh) << endl;
     }
-  else {  
-    cout << "\n -------- PIACmd::Interpret() ::::: Help ------------ \n";
-    cout << ">>> Interpreter's keywords : \n";
-    cout << "  timingon  timingoff traceon  traceoff \n";
-    cout << "  set unset listvar listcommands exec shell \n";
-    cout << "  > set varname 'string'   # To set a variable, $varname \n";
-    cout << "  > unset varname          # clear variable definition \n";
-    cout << "  > listvars   # List of variable names and values \n";
-    cout << "  > listcommands # List of all known commands \n";
-    cout << "  > exec filename  # Execute commands from file \n";
-    cout << "  > shell comand_string  # Execute shell command \n";
-    cout << "  > help <command_name>  # <command_name> usage info \n"; 
-    cout << "  > helpwindow           # Displays help window \n" << endl;
-    }
-  }
-
+  }
 
 else if (kw == "set") {
@@ -292,5 +350,5 @@
   }
 else if (kw == "listvars") {
-  cout << "---- PIACmd::Interpret()  Command keyword  List ----- \n";
+  cout << "---- PIACmd::Interpret()  Command Variable List ----- \n";
   CmdExmap::iterator it;
   int kc = 0;
@@ -376,10 +434,17 @@
 string& PIACmd::GetUsage(const string& kw)
 {
+bool fndok = false;
 CmdExmap::iterator it = cmdexmap.find(kw);
-if (it == cmdexmap.end()) {  
-  if (videstr == NULL) videstr = new string("");
-  return(*videstr);
-  }
-else return( (*it).second.us ); 
+if (it == cmdexmap.end()) {
+  it = helpexmap.find(kw);
+  if (it != helpexmap.end())  fndok = true;
+  }
+  else  fndok = true; 
+if (fndok)   return( (*it).second.us ); 
+// Keyword pas trouve
+if (videstr == NULL) videstr = new string("");
+*videstr =  "Nothing known about " + kw + " ?? ";
+return(*videstr);
+ 
 }
 
