Интерфейс пользователя при построении системного ПО. Структура системы меню, страница 3

              if (strlen(F)>0) //Add new item

              {

                     t->Item = new Menu_Item(NULL, F, cx, cy, ths, 0, t, 1);

                     t->next = Children;

                     Children->prev = t;

              }else

              if (t->prev)

              {

                     t = t->prev;

                     t->next = Children;

                     Children->prev = t;

              } else

                     Children = NULL;

       } else Children = NULL;

}

//==================Main_Menu====================

Main_Menu :: Main_Menu(char *Str)

{

       item_list *t;

       t = new item_list;

       t->next = NULL; t->prev = NULL;

       items = t;

       int o,c,i,cx,cy;

       cx = 0; cy = 0;

       char aN[NS], aT[NS];

       char *F, *T, *N;

       N = &aN[0];   F = &aN[0];   T = &aT[0];

       for(i=0;i<NS;i++){aN[i]='\0';aT[i]='\0';}

       while (strlen(Str)>0)

       {

              if (*Str=='{')

              {

                     for(i=0;i<NS;i++)aT[i]='\0';

                     strcpy(T, F);

                     for(i=0;i<NS;i++)aN[i]='\0';

                     N = &aN[0]; F = &aN[0];

                     o=1; c=0; *N = *Str;

                     Str++; N++;

                     while (o!=c)

                     {

                            if (*Str == '{') o++;

                            else

                            if (*Str == '}') c++;

                            *N = *Str; Str++; N++;

                     }

                     N--; *N='\0'; F++; //Add new item

                     t->Item = new Menu_Item(F, T, cx, cy, NULL, 1, t, 0);

                     t->next = new item_list;

                     t->next->prev = t;

                     t = t->next;

                     t->next = NULL;      cx += W;

                     for(i=0;i<NS;i++)aN[i]='\0';

                     N = &aN[0];   F = &aN[0];

              } else

              if (*Str==',')

              {

                     N++; *N='\0';//Add new item

                     t->Item = new Menu_Item(NULL, F, cx, cy, NULL, 1, t, 0);

                     t->next = new item_list;

                     t->next->prev = t;

                     t = t->next;

                     t->next = NULL; cx += W;

                     for(i=0;i<NS;i++)aN[i]='\0';

                     N = &aN[0];   F = &aN[0];

              } else

              { *N = *Str; N++;}

              if (strlen(Str)>0) Str++;

       }

       N++; *N='\0';

       if (strlen(F)>0)

              t->Item = new Menu_Item(NULL, F, cx, cy, NULL, 1, t, 0);

       else

              t = t->prev;

       t->next = items; items->prev = t; Cur = items;

}

void Main_Menu :: Paint_Item(Menu_Item *I)

{ //Paint one menu item

       if (I->Selected)

       {

              setfillstyle (1,SlctClr);

              setcolor(SlctTxtClr);

       }

       else

       {

              setfillstyle (1,FillClr);

              setcolor(TxtClr);

       }

       bar(I->x, I->y, I->x+W, I->y+H);

       rectangle(I->x, I->y, I->x+W, I->y+H);

       outtextxy(I->x+5, I->y+5, I->Name);

}

void Main_Menu :: Erase_Item(Menu_Item *I)

{

       setfillstyle(0,0);

       bar(I->x, I->y, I->x+W, I->y+H);

}

void Main_Menu :: Erase_Tree(item_list *I)

{

       item_list *t; t = I;

       do

       {

              Erase_Item(t->Item);

              t = t->next;

       } while (t!=I);

       if (I->Item->Parent)

       Erase_Tree(I->Item->Parent);

}

void Main_Menu :: Paint_Tree(item_list *I)

{

       item_list *t; t = I;

       do

       {

              Paint_Item(t->Item);

              t = t->next;

       } while (t!=I);

       if (I->Item->Parent)

       Paint_Tree(I->Item->Parent);

}

void Main_Menu :: Process()

{ //main function for process keypressing

       int key, good_key;

       item_list *old;

       Cur->Item->Selected = 1;

       setbkcolor(BkClr);

       Paint_Tree(Cur);

       setcolor(SlctTxtClr);

       line(0,440,640,440);

       outtextxy(12,445,"Simple menu by Durkin Dmitry, PM-12");