unit uMenuDef;

{==========================================================}
{                                                          }
{  unit uMenuDef                       2005-09-23          }
{                                      Verze 1.0           }
{                                                          }
{  Skelet aplikace pro TOUCH51                             }
{                                                          }
{  Definice stromu komponent aplikace                      }
{                                                          }
{                                                          }
{  (C)2005, SofCon, Stresovicka 49, 160 00 Praha 6         }
{                                                          }
{                                                          }
{==========================================================}

interface

{$I SETS.INC}

uses
  Objects,    { Standardni knihovna             }
  IoDrv,      { Obecne I/O ovladace terminalu   }
  Bitmaps,    { Spravce bitmap                  }
  Controls,   { Zakladni komponenty             }
  GrCtrls,    { Graficke komponenty             }
  T51Setup,   { Setup pro terminal T51          }
  extgr,
  foss20
  ;


{-------------------------
{ CreateAppPages
{--
{ Procedura pro vytvoreni vsech stranek aplikace
{--
}

procedure CreateAppPages;

{-------------------------
{ AppCustomizeProc
{--
{ Aplikacni konfiguracni procedura komponent
{--
}

procedure AppCustomizeProc( AControl: PControl; AClass: Word );


implementation

{-----------------------------------------------------------------------}
{ Identifikatory komponent                                              }
{-----------------------------------------------------------------------}

const

  cidPageCtrl          = 1;    { Hlavni komponenta TPageControl         }

  cidMainPage          = 100;  { Hlavni stranka                         }
  cidMainPageTitle     = 101;  { Titulek hlavni stranky                 }
  cidMainPageImage     = 102;  { Uvodni obrazek na hlavni strance       }
  cidMainPageNavig     = 103;  { Navigator na hlavni strance            }

  cidDemoPage1         = 200;  { Dalsi stranka                          }
  cidOtherPageTitle    = 201;  { Titulek na dalsi strance               }
  cidOtherPageNavig    = 202;  { Navigator na dalsi strance             }
  cidImageListBox      = 203;  { Image ListBox                          }


{-----------------------------------------------------------------------}
{ Odkazy na instance komponent ve stromu aplikace                       }
{-----------------------------------------------------------------------}

var

  Tree :
  record
    PageCtrl : PPageControl;  { Instance hlavni komponenty TPageControl }

    MainPage : record         { Hlavni stranka                          }
      Title   : PStaticText;  { Titulek stranky                         }
      Navig   : PNavigator;   { Navigator stranky                       }
    end;

    DemoPage1 : record        { Dalsi stranka                           }
      Title   : PStaticText;  { Titulek stranky                         }
      Navig   : PNavigator;   { Navigator stranky                       }
      ScrollBar:PScrollBar;
      ListBox :PListBox;
      Image   :PBigImage;
      Text    :PStaticText;
      TextShow:boolean;
    end;

  end;

{-----------------------------------------------------------------------}
{ Vlastni tridy nastaveni komponent                                     }
{-----------------------------------------------------------------------}

const

  ccStaticTextXXX  = ccStaticText + 16;
  ccEditXXX        = ccEdit       + 16;


{-----------------------------------------------------------------------}
{-----------------------------------------------------------------------}
{ Vlastni konfiguracni procedura pro vytvarene komponenty               }
{-----------------------------------------------------------------------}

{-------------------------
{ AppCustomizeProc
{--
{ Aplikacni konfiguracni procedura komponent
{--
}

procedure AppCustomizeProc( AControl: PControl; AClass: Word );
begin

  { Vyber podle tridy }
  case AClass and ccGeneralMask of

    ccStaticText: { Komponenta TStaticText }
    begin
      { Vyber podle podtridy }
      case AClass of

        ccStaticTextXXX:
        begin
          { ... }
        end;

      end;
    end;

    ccEdit: { Komponenta TEdit }
    begin
      { Vyber podle podtridy }
      case AClass of

        ccEditXXX:
        begin
          { ... }
        end;

      end;
    end;

    { ... }

  end;
end;


{-----------------------------------------------------------------------}
{ Hlavni stranka                                                        }
{-----------------------------------------------------------------------}



procedure PagePaintFrame( AControl: PControl; ACanvas: PCanvas ); far;
var
  R : TRect;
begin
  { Vykresleni okraje ve vnitrni casti stranky }
  AControl^.GetExtent( R );
  ACanvas^.Pen.Color := clBlack;
  ACanvas^.DrawRect( R.A.X + 1, R.A.Y + 21, R.B.X - 2, R.B.Y - 22 );
end;


{-------------------------
{ MainPageNotify
{--
{ Obsluha oznameni komponent v hlavni strance
{--
}

procedure MainPageNotify( var N: TNotification ); far;
begin
{ case N.Control^.Id of

    cidXXX:
    begin
      case N.Code of
        nmXXX:
        begin
          ClearNotification( N );
        end;

        nmYYY:
        begin
          ClearNotification( N );
        end;
      end;
    end;

    cidYYY:
    begin
      case N.Code of
        nmXXX:
        begin
          ClearNotification( N );
        end;

        nmYYY:
        begin
          ClearNotification( N );
        end;
      end;
    end;

  end;}
end;
{-------------------------
{ CreateMainPage
{--
{ Vytvoreni a inicializace hlavni stranky
{--
}

procedure CreateMainPage;
var
  Page : PPage;
  R    : TRect;
begin
  Page := Tree.PageCtrl^.NewPage( cidMainPage );
  Page^.Customize( ccPage );
  Page^.AfterNotify := MainPageNotify;
  Page^.AfterPaint := PagePaintFrame;

  with Tree.MainPage do
  begin
    { Titulek }
    R.Assign( 1, 1, Application^.DisplayDriver^.width-1, 20 );
    Title := New( PStaticText, Init( R, 'Main page' ) );
    Title^.Customize( ccStaticTextTitle );
    Page^.Insert( Title );

    { Navigator }
    R.Assign( 1, Application^.DisplayDriver^.height-20, Application^.DisplayDriver^.width-1,
                 Application^.DisplayDriver^.height-1 );
    Navig := New( PNavigator, Init( R, Tree.PageCtrl,
      NewTextPanel( 'Setup', Ord('S'), -4, npfDivider or npfCall, cidTermSetupPage,
      NewTextPanel( 'Other', Ord('O'), -4, npfDivider or npfGoto, cidDemoPage1,

      nil))
    ));
    Navig^.Customize( ccNavigator );
    Page^.Insert( Navig );

    { Zde bude incializace dalsich komponent na strance }

    { ... }

  end;

  Tree.PageCtrl^.Insert( Page );
end;






{-------------------------
{ DemoPage1
{--
{ Obsluha oznameni komponent v dalsi strance
{--
}

procedure DemoPage1Notify( var N: TNotification ); far;
var Page:PPage;
    itm:integer;
begin
{ case N.Control^.Id of

    cidXXX:
    begin
      case N.Code of
        nmXXX:
        begin
          ClearNotification( N );
        end;

        nmYYY:
        begin
          ClearNotification( N );
        end;
      end;
    end;

    cidYYY:
    begin
      case N.Code of
        nmXXX:
        begin
          ClearNotification( N );
        end;

        nmYYY:
        begin
          ClearNotification( N );
        end;
      end;
    end;

  end;}
end;

{-------------------------
{ CreateOtherPage
{--
{ Vytvoreni a inicializace dalsi stranky
{--
}

procedure CreateDemoPage1;
var
  Page : PPage;
  R    : TRect;
begin
  Page := Tree.PageCtrl^.NewPage( cidDemoPage1 );
  Page^.Customize( ccPage );
  Page^.AfterNotify := DemoPage1Notify;
  Page^.AfterPaint := PagePaintFrame;

  with Tree.DemoPage1 do
  begin
    { Titulek }
    R.Assign( 1, 1, Application^.DisplayDriver^.width-1, 20 );
    Title := New( PStaticText, Init( R, 'Other Page' ));
    Title^.Customize( ccStaticTextTitle );
    Page^.Insert( Title );

    { Navigator }
    R.Assign( 1, Application^.DisplayDriver^.height-20,
              Application^.DisplayDriver^.width-1,Application^.DisplayDriver^.height-1 );
    Navig := New( PNavigator, Init( R, Tree.PageCtrl,
      NewTextPanel( 'Main', kbEsc, -4, npfDivider or npfGoto, cidMainPage,
      nil)
    ));
    Navig^.Customize( ccNavigator );
    Page^.Insert( Navig );

    { Zde bude incializace dalsich komponent na strance }


  end;

  Tree.PageCtrl^.Insert( Page );
end;




{-------------------------
{ CreateAppPages
{--
{ Vytvoreni vsech stranek aplikace
{--
}

procedure CreateAppPages;
var
  R : TRect;
begin
  { Inicializace hlavni komponenty TPageControl }

  R.Assign( 0, 0, Application^.DisplayDriver^.width, Application^.DisplayDriver^.height );
  Tree.PageCtrl := New( PPageControl, Init( R ) );
  Tree.PageCtrl^.Customize( ccPageControl );
  Tree.PageCtrl^.Id := cidPageCtrl;

  { Vytvoreni jednotlivych stranek aplikace }
  CreateMainPage;
  CreateDemoPage1;{}

  { Vytvoreni stranek setupu terminalu T51, knihovna T11Setup }
  CreateT51SetupPages( Tree.PageCtrl );

  { Nastaveni prvni zobrazene stranky po startu aplikace }
  Tree.PageCtrl^.GotoPage( cidMainPage );{}

  { Vlozeni komponenty TPageControl do aplikace }
  Application^.Insert( Tree.PageCtrl );
end;

begin
end.
