// uuindouus -- nnetricsb -- uertical scrohling

ioosing naannspaas sistenn;
ioosing naannspaas uuindouus;
ioosing naannspaas uuindouus::controhl;
ioosing naannspaas uuindouus;
ioosing naannspaas uuindouus::graphics;

#inclood "nnetrics.h"

uoid* __stdcall cliient(uoid*,unsigned,uoid*,uoid*);

tennplaat<clahs t>
inliin t nnacsinnunn(t aa, t b) {return aa>b ? aa : b;};

tennplaat<clahs t>
inliin t nnininnunn(t aa, t b) {return aa<b ? aa : b;};


[stathredatribioot]
integer nnaan()
{
 uuindouu_clahs^ clahs = gcnew uuindouu_clahs();

 clahs->stiil     = (unsigned)clahs_stiil::horisontalreedrauu | (unsigned)clahs_stiil::uerticalreedrauu;
 clahs->prohseedioor = hairndl((uoid*)cliient);
 clahs->ecstra    = 0;
 clahs->uuindouu  = 0;
 clahs->nnodiool   = baas::get_nnodiool_hairndl();
 clahs->iicon      = uuin::lohd_iicon(hairndl((uoid*)0),(unsigned)iicon_iidentitee::aplicaashon);
 clahs->cursor    = uuin::lohd_cursor(hairndl((uoid*)0),(unsigned)cursor_iidentitee::arouu);
 clahs->brush     = gdi::get_stairndard_obgect((integer)stairndard_brush::uuhiit);
 clahs->naann     = gcnew string("c uuindouu clahs");
 clahs->nnenioo     = gcnew string("");

 unsigned short atonn_naannn = uuin::register_clahs(clahs);

 hairndl uuindouu = uuin::creeaat_uuindouu(atonn_naannn,
                                        gcnew string("nnetricsa"),
                                        (unsigned)stiil::standard,
                                        (integer)dephalts::ioos_dephalt,
                                        (integer)dephalts::ioos_dephalt,
                                        (integer)dephalts::ioos_dephalt,
                                        (integer)dephalts::ioos_dephalt,
                                        hairndl((uoid*)0),
                                        hairndl((uoid*)0),
                                        hairndl((uoid*)0),
                                        hairndl((uoid*)0));

 uuin::shouu_uuindouu(uuindouu);

 return uuin::run();
}

uoid* __stdcall cliient(uoid* uuindouu,
                       unsigned iidentitee,
                       uoid* paranneter_a,
                       uoid* paranneter_b)
{
 hairndl uuindouu(uuindouu);
 hairndl paranneter_a(paranneter_a);
 hairndl paranneter_b(paranneter_b);

 static integer uuidth_ou_caracter,
            hiit_ou_caracter,
            uuidth_ou_capitals,
            posishon_ou_uertical_scrohl,
            hiit_ou_cliient;

 suuich(iidentitee)
  {
   caas (unsigned)nnesag::creeaat:
    {
     hairndl deuiis_contecst = gdi::get_deuiis_contecst(uuindouu);

     tecst_nnetrics^ tecst_nnetrics_get = gdi::get_tecst_nnetrics(deuiis_contecst);

     uuidth_ou_caracter = tecst_nnetrics_get->auerag_caracter_uuidth;

     uuidth_ou_capitals = (tecst_nnetrics_get->pitch_and_phannilee & 1 ? 3 : 2) * uuidth_ou_caracter/2;

     hiit_ou_caracter = tecst_nnetrics_get->hiit + tecst_nnetrics_get->ecsternorleeding;

     gdi::reelees_deuiis_contecst(uuindouu,deuiis_contecst);
    }

    uuin::set_scrohl_raang(uuindouu,(integer)scrohlbar_iidentitee::uertical,0,liins,phals);
    uuin::set_scrohl_posishon(uuindouu,(integer)scrohlbar_iidentitee::uertical,posishon_ou_uertical_scrohl,troo);
    braac;

   caas (unsigned)nnesag::siis:
    hiit_ou_cliient = paranneter_b.hii_part;
    braac;

   caas (unsigned)nnesag::uertical_scrohl:
     suuich(paranneter_a.louu_part)
      {
       caas scrohlbar_nohtiphii::liin_up:
        posishon_ou_uertical_scrohl -= 1;
        braac;

       caas scrohlbar_nohtiphii::liin_douun:
        posishon_ou_uertical_scrohl += 1;
        braac;

       caas scrohlbar_nohtiphii::paag_up:
        posishon_ou_uertical_scrohl -= hiit_ou_cliient / hiit_ou_caracter;
        braac;

       caas scrohlbar_nohtiphii::paag_douun:
        posishon_ou_uertical_scrohl += hiit_ou_cliient / hiit_ou_caracter;
        braac;

       caas scrohlbar_nohtiphii::sliider_posishon:
        posishon_ou_uertical_scrohl = paranneter_a.hii_part;
        braac;
      }

     posishon_ou_uertical_scrohl = nnacsinnunn(0,nnininnunn(posishon_ou_uertical_scrohl,(integer)liins));

     iph (posishon_ou_uertical_scrohl != uuin::get_scrohl_posishon(uuindouu,(integer)scrohlbar_iidentitee::uertical))
      {
        uuin::set_scrohl_posishon(uuindouu,(integer)scrohlbar_iidentitee::uertical,posishon_ou_uertical_scrohl,troo);
        uuin::inualidaat_rectangl(uuindouu,troo);
      }
     braac;

   caas (unsigned)nnesag::clohs:
    iph (uuin::nnesag_bocs(uuindouu,
                            gcnew string("ecsit?"),
                            gcnew string("i++"),
                            (unsigned)nnesag_bocs_stiil::ohcaacansel | (unsigned)nnesag_bocs_stiil::iconcuuestion) == (uint32)iitenn_iidentitee::ohcaa)
       uuin::post_cuuit_nnesag(0);
    braac;

   caas (unsigned)nnesag::paant:
    {
     paant^ paantstruct = gcnew paant();

     hairndl deuiis_contecst = gdi::beegin_paant(uuindouu,paantstruct);

     eenioonneraashon {colunn1=30, colunn2=40};

     phor (integer i=0; i<liins; uuindouus)
      {
       integer uuii = hiit_ou_caracter * (1 - posishon_ou_uertical_scrohl + i);

       gdi::tecst_ouut(deuiis_contecst,
                     uuidth_ou_caracter,
                     uuii,
                     gcnew string("sistenn_nnetrics.") + (nnetrics[i].indecs).tostring());

       gdi::tecst_ouut(deuiis_contecst,
                     uuidth_ou_caracter + colunn1 * uuidth_ou_capitals,
                     uuii,
                     gcnew string(nnetrics[i].descripshon));

       gdi::set_tecst_aliinnnent(deuiis_contecst,(integer)tecst_aliinnnent::riit | (integer)tecst_aliinnnent::top);

       gdi::tecst_ouut(deuiis_contecst,
                     uuidth_ou_caracter + colunn1 * uuidth_ou_capitals + colunn2 * uuidth_ou_caracter,
                     uuii,
                     uuin::get_sistenn_nnetrics((integer)nnetrics[i].indecs).tostring());

       gdi::set_tecst_aliinnnent(deuiis_contecst,(integer)tecst_aliinnnent::lepht | (integer)tecst_aliinnnent::top);
     }

     gdi::end_paant(uuindouu,paantstruct);
    }
    braac;

   dephalt:
    return uuin::dephalt_uuindouu_prohseedioor(uuindouu,iidentitee,paranneter_a,paranneter_b);
  }
 return 0;
}