IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Flash Pascal Discussion :

Limites du trackbar avec onMouseWheel [Flash Pascal]


Sujet :

Flash Pascal

  1. #1
    Membre chevronné
    Avatar de Archimède
    Homme Profil pro
    Enseignant
    Inscrit en
    Avril 2005
    Messages
    1 644
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 58
    Localisation : France, Charente Maritime (Poitou Charente)

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2005
    Messages : 1 644
    Points : 1 975
    Points
    1 975
    Par défaut Limites du trackbar avec onMouseWheel
    Voici le trackbar intégré que j'ai continué à faire en mode vertical cet après midi :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    685
    686
    687
    688
    689
    690
    691
    692
    693
    694
    695
    696
    697
    698
    699
    700
    701
    702
    703
    704
    705
    706
    707
    708
    709
    710
    711
    712
    713
    714
    715
    716
    717
    718
    719
    720
    721
    722
    723
    724
    725
    726
    727
    728
    729
    730
    731
    732
    733
    734
    735
    736
    737
    738
    739
    740
    741
    742
    743
    744
    745
    746
    747
    748
    749
    750
    751
    752
    753
    754
    755
    756
    757
    758
    759
    760
    761
    762
    763
    764
    765
    766
    767
    768
    769
    770
    771
    772
    773
    774
    775
    776
    777
    778
    779
    780
    781
    782
    783
    784
    785
    786
    787
    788
    789
    790
    791
    792
    793
    794
    795
    796
    797
    798
    799
    800
    801
    802
    803
    804
    805
    806
    807
    808
    809
    810
    811
    812
    813
    814
    815
    816
    817
    818
     
    unit UFlash8CL;
     
    interface
     
    uses Flash8,UFont;
     
    const
      distance=1;
      angleInDegrees=45;
      coul1=$808080;
      highlightAlpha=0.8;
      coul2=$646464;
      shadowAlpha=0.9;
      blurX=5;
      blurY=5;
      strength=5;
      quality=3;
      typ='inner';
     
    type
     
     TLabel=Class(TextField)
      Private
       first:Boolean;
       FLeft,FTop,FWidth,FHeight:number;
       Function  GetCaption:string;
       Function getLeft:number;
       Function getTop:number;
       Function getwidth:number;
       Function getHeight:number;
       procedure SetLeft(value:number);
       procedure SetTop(value:number);
       procedure SetWidth(value:number);
       procedure SetHeight(value:number);
       procedure SetCaption(value:string);
      Public
       Font:Tfont;
       constructor Create(parent:movieclip);
       property Left:number read getLeft write SetLeft;
       property Top:number read getTop write SetTop;
       property width:number read getWidth write SetWidth;
       property height:number read getHeight write SetHeight;
       property caption:string read getCaption write setCaption;
    end;
     
    {*********
    **Edit****
    **********}
     
     TEdit=Class(TLabel)
      Private
       first:Boolean;
       Function getText:string;
       procedure SetText(value:string);
       procedure onChanged(Ed:TEdit);override;
      Public
       Font:Tfont;
       constructor Create(parent:movieclip);
       procedure onChange;virtual;
       property texte:string read getText write setText;
    end;
     
     
    {*********
    **Button**
    **********}
     
     
     TButton=class(movieclip)
     
     private
      click,First:Boolean;
      skin1,skin2:movieclip;
      w,h:number;
      bevel1,bevel2:BevelFilter;
      myfilterArray:TArray;
      Title:TextField;
      Function getLeft:number;
      Function getTop:number;
      Function getwidth:number;
      Function getHeight:number;
      Function getCaption:String;
      procedure skin;
      procedure SetCaption(value:string);
      procedure SetLeft(value:number);
      procedure SetTop(value:number);
      procedure SetWidth(value:number);
      procedure SetHeight(value:number);
      procedure onPress;override;
      procedure onMouseUp;override;
     public
      Font:Tfont;
      procedure onClick;virtual;
      constructor create(parent:movieclip);
      property Caption:string read GetCaption write SetCaption;
      property Left:number read GetLeft write SetLeft;
      property Top:number read GetTop write SetTop;
      property width:number read GetWidth write SetWidth;
      property height:number read GetHeight write SetHeight;
     end;
     
    {***********
    **StringGrid*
    ************}
     
    TCell=class(TEdit)
      procedure onChanged(Cell:TEdit);
    end;
     
    TStringGrid=class(movieclip)
     private
      Function getLeft:number;
      Function getTop:number;
      Function getwidth:number;
      Function getHeight:number;
      procedure SetLeft(value:number);
      procedure SetTop(value:number);
      procedure SetWidth(value:number);
      procedure SetHeight(value:number);
     public
      val:string;
      colcount,rowcount:integer;
      Cells:array[0..200,0..200] of TCell;
      constructor Create(parent:MovieClip);
      procedure Init(colcnt,rowcnt,width,height:integer);
      procedure onChange;virtual;
      procedure Font(Fname:string;Fsize:number;Fbold,Fitalic:boolean;algn:string);
      property Left:number read GetLeft write SetLeft;
      property Top:number read GetTop write SetTop;
      property width:number read GetWidth write SetWidth;
      property height:number read GetHeight write SetHeight;
    end;
     
    {***********
    **TrackBar**
    ************}
     TTrackcur=class(MovieClip)
        xmin,xmax:number;
        xmouse,ymouse:number;
        trackmin,trackmax:integer;
        xcur,ycur:Integer;
        downcur:Boolean;
        constructor Create(AOWNER:Movieclip;trmin,trmax:integer);
        procedure onPress;override;
        procedure onMouseMove;override;
        procedure onMouseUp;override;
      end;
     
     
     TTrackBar=Class(movieClip)
     private
      w,h:integer;
      valorientation:string;
      bevel:BevelFilter;
      myfilterArray:TArray;
      cur: TTrackcur;
      mc:movieclip;
      function GetLeft:number;
      function Gettop:number;
      function GetTaille:number;
      function Getheight:number;
      function Getcolor:number;
      function Getmin:integer;
      function Getmax:integer;
      function GetOrientation:string;
      function GetPosition:integer;
      procedure Setleft(value:number);
      procedure SetTop(value:number);
      procedure SetTaille(value:number);
      procedure SetHeight(value:number);
      procedure Setcolor(value:number);
      procedure Setmin(value:integer);
      procedure Setmax(value:integer);
      procedure setposition(value:integer);
      procedure setorientation(value:string);
      procedure onMouseWheel(delta: Number;scrolltarget:TObject);
     public
      constructor Create(parent:movieclip);
      procedure onChange;virtual;
      procedure graduation;
      property Left:number read GetLeft write SetLeft;
      property Top:number read GetTop write SetTop;
      property Taille:number read GetTaille write SetTaille;
      property height:number read GetHeight write SetHeight;
      property color:number read GetColor write SetColor;
      property position:integer read GetPosition write Setposition;
      property min:integer read GetMin write SetMin;
      property max:integer read GetMax write SetMax;
      property orientation:string read GetOrientation write SetOrientation;
     end;
     
     
    implementation
     
    function arrondi(n:number):integer;
    begin
      if n-trunc(n)<0.5 then result:=trunc(n) else result:=trunc(n)+1;
    end;
     
    Constructor TLabel.Create(parent:movieclip);
    begin
     Inherited Create(Parent,'',parent.getNextHighestDepth(),0,0,100,100);
     Font:=TFont.Create;
     with Font do
     begin
      name:='arial';
      size:=14;
     end;
     first:=true;
    end;
     
    procedure TLabel.Setleft(value:number);
    begin
       _x:=value;
    end;
     
    Function TLabel.GetLeft:number;
    begin
     result:=_x;
    end;
     
    procedure TLabel.SetTop(value:number);
    begin
       _y:=value;
    end;
     
    Function TLabel.GetTop:number;
    begin
     result:=_y;
    end;
     
    procedure TLabel.SetWidth(value:number);
    begin
       _width:=value;
    end;
     
    Function TLabel.GetWidth:number;
    begin
     result:=_width;
    end;
     
    procedure TLabel.SetHeight(value:number);
    begin
       _height:=value;
    end;
     
    Function TLabel.GetHeight:number;
    begin
     result:=_height;
    end;
     
     
    procedure TLabel.SetCaption(value:string);
    begin
     if first then
     begin
      setNewTextFormat(Font.FTextFormat);
      first:=false;
     end;
     text:=value;
    end;
     
    Function TLabel.GetCaption:string;
    begin
     result:=text;
    end;
     
    {*********
    **Edit****
    **********}
     
     
    Constructor TEdit.Create(parent:movieclip);
    begin
     Inherited Create(Parent);
     type:='input';
     first:=true;
    end;
     
    Procedure TEdit.onChanged(Ed:TEdit);
    begin
     onchange;
    end;
     
     
     
    procedure TEdit.SetText(value:string);
    begin
     if first then
     begin
      setNewTextFormat(Font.FTextFormat);
      first:=false;
     end;
     text:=value;
    end;
     
    Function TEdit.getText:string;
    begin
     result:= text;
    end;
     
     
     
    Procedure TEdit.onChange;
    begin
    end;
     
     
    {*********
    **Button**
    **********}
     
    constructor TButton.Create(parent:movieclip);
    begin
     inherited Create(parent,'button',movieclip(parent).getNextHighestDepth());
     w:=90;
     h:=30;
     left:=10;
     top:=10;
     myfilterArray:=TArray.Create();
     
     Font:=TFont.Create;
     with Font do
     begin
      name:='arial';
      size:=14;
      align:='center';
     end;
     
     skin1:=movieclip.create(self,'',1);
     skin2:=movieclip.create(self,'',2);
     
     with skin1 do
     begin
      bevel1:=BevelFilter.create(distance,angleInDegrees,coul1,highlightAlpha,coul2,shadowAlpha,blurX,blurY,strength,quality,typ);
      myfilterArray.Push(bevel1);
      filters := myfilterArray;
      BeginFill($F0F0F0);
      lineto(w,0);
      lineto(w,h);
      lineto(0,h);
     end;
     
     with skin2 do
     begin
      bevel2:=BevelFilter.create(distance,angleInDegrees,coul2,highlightAlpha,coul1,shadowAlpha,blurX,blurY,strength,quality,typ);
      myfilterArray.Push(bevel2);
      filters := myfilterArray;
      BeginFill($F0F0F0);
      lineto(w,0);
      lineto(w,h);
      lineto(0,h);
     end;
     
     First:=true;
     click:=false;
     skin;
     
     Title:=TextField.Create(self,'',getNextHighestDepth(),0,0,w,h);
     with Font do
     begin
      name:='arial';
      size:=20;
     end;
    end;
     
    procedure TButton.skin;
    begin
     if not click then
     begin
      skin1._visible:=true;
      skin2._visible:=false;
     end else
     begin
      skin1._visible:=false;
      skin2._visible:=true;
     end;
    end;
     
    procedure TButton.SetCaption(Value: string);
    begin
     with title do
     begin
      if first then
      begin
       setNewTextFormat(Font.FTextFormat);
       first:=false;
      end;
      text:=value;
     end;
    end;
     
    Function TButton.GetCaption:string;
    begin
     result:=title.text;
    end;
     
     
    procedure TButton.onClick;
    begin
    end;
     
    procedure TButton.onPress;
    begin
     click:=true;
     skin;
     onClick;
    end;
     
    procedure TButton.onMouseUp;
    begin
     click:=false;
     skin;
    end;
     
    procedure TButton.Setleft(value:number);
    begin
     _x:=value;
    end;
     
    procedure TButton.SetTop(value:number);
    begin
     _y:=value;
    end;
     
    procedure TButton.SetWidth(value:number);
    begin
       _xscale:=100*value/w;
       _yscale:=_xscale;
    end;
     
    procedure TButton.SetHeight(value:number);
    begin
      _yscale:=100*value/h;
    end;
     
     
    Function TButton.GetLeft:number;
    begin
     result:=_x;
    end;
     
     
     
    Function TButton.GetTop:number;
    begin
     result:=_y;
    end;
     
     
    Function TButton.GetWidth:number;
    begin
     result:=_width;
    end;
     
     
     
    Function TButton.GetHeight:number;
    begin
     result:=_height;
    end;
     
    {***********
    **TrackBar**
    ************}
     
    constructor TTrackbar.Create(parent:movieclip);
    begin
     inherited Create(parent,'Trackbar'+floattostr(parent.getNextHighestDepth()),parent.getNextHighestDepth());
     left:=10;
     top:=10;
     w:=100;
     h:=20;
     color:=clred;
     
     mc:=movieclip.create(self,'mc',0);
     bevel:=BevelFilter.create(0.3,45,$c0c0c0,0.8,clblack,0.9,5,5,5,3,'inner');
     cur:=TTrackcur.Create(self,0,100);
     myfilterArray:=TArray.Create();
     myfilterArray.Push(bevel);
     
     beginFill(color);
     lineto(w,0);
     lineto(w,h);
     lineto(0,h);
     endFill();
     
     filters := myfilterArray;
     lineto(w,0);
     lineto(w,h);
     lineto(0,h);
     
      with mc do
      begin
       filters := myfilterArray;
       beginFill(clcream);
       moveto(w/15,h/4);
       lineto(w-w/15,h/4);
       lineto(w-w/15,h/4+3);
       lineto(w/15,h/4+3);
       lineto(w/15,h/4);
       endFill();
       linestyle(1,$c0c0c0);
       moveto(w/15,h/4+5);
       lineto(w/15,h/4+5.5);
       moveto(w-w/15,h/4+5);
       lineto(w-w/15,h/4+5.5);
      end;
     
      with cur do
      begin
       _x:=w/15;
       _y:=h/3.3;
      end;
     
     mouse.addlistener(self);
    end;
     
    procedure TTrackbar.onMouseWheel(delta: Number;scrolltarget:TObject);
    var posi:integer;
    begin
     if (scrolltarget<>self) and (scrolltarget<>cur)  and (scrolltarget<>mc) then exit;
     posi:=position;
     if delta >0 then delta := 1 else delta := -1;
     position:=position+delta;
     if  (position>=min) and (position<=max)then
     begin
      cur._x:=w/15+(position-min)*(w-2*w/15)/(max-min);   //modif ici
      onChange;
     end else position:=posi;
    end;
     
    Function TTrackbar.GetPosition:integer;
    begin
      result:=arrondi((cur._x-w/15)*(cur.trackmax-cur.trackmin)/(w-2*w/15)+cur.trackmin);
    end;
     
    Function TTrackbar.Getmin:integer;
    begin
      result:=cur.trackmin;
    end;
     
    Function TTrackbar.Getmax:integer;
    begin
      result:=cur.trackmax;
    end;
     
    function TTrackbar.GetOrientation:string;
    begin
     result:=valorientation;
    end;
     
    procedure TTrackbar.SetMax(value:integer);
    begin
      cur.trackmax:=value;
    end;
     
    procedure TTrackbar.SetMin(value:integer);
    begin
      cur.trackmin:=value;
    end;
     
    procedure TTrackbar.SetPosition(value:integer);
    begin
       cur._x:=w/15+abs(value-cur.trackmin)*(w-2*w/15)/(cur.trackmax-cur.trackmin);
    end;
     
    procedure TTrackbar.Setleft(value:number);
    begin
      _x:=value;
    end;
     
    procedure TTrackbar.SetTop(value:number);
    begin
     _y:=value;
    end;
     
    procedure TTrackbar.SetTaille(value:number);
    begin
     _xscale:=100*value/w;
     _yscale:=_xscale;
    end;
     
    procedure TTrackbar.SetHeight(value:number);
    begin
     _yscale:=100*value/h;
    end;
     
    procedure TTrackbar.Setcolor(value:number);
    begin
     clear;
     beginFill(value);
     lineto(w,0);
     lineto(w,h);
     lineto(0,h);
     endFill();
    end;
     
    procedure TTrackbar.setOrientation(value:string);
    begin
     if value='vertical' then
     begin
      _rotation:=-90;
      _y:=_y+_height;
     end;
     valorientation:=value;
    end;
     
    procedure TTrackbar.graduation;
    var l,grad:number;
        i,nbgrad:integer;
    begin
     l:=13*w/15;
     nbgrad:=cur.trackmax-cur.trackmin;
     grad:=l/nbgrad;
     linestyle(1,$c0c0c0);
     for i:=1 to  nbgrad do
     begin
      moveto(w/15+grad*i,h/4+5);
      lineto(w/15+grad*i,h/4+5.25);
     end;
    end;
     
    procedure TTrackbar.onChange;
    begin
    end;
     
    Function TTrackbar.Getcolor:number;
    begin
     result:=opaquebackground;
    end;
     
    Function  TTrackbar.GetTaille:number;
    begin
     result:=_width;
    end;
     
    Function  TTrackbar.Getheight:number;
    begin
     result:=_height;
    end;
     
    Function  TTrackbar.GetLeft:number;
    begin
     result:=_x;
    end;
     
    Function  TTrackbar.GetTop:number;
    begin
     result:=_y;
    end;
     
    procedure  TTrackcur.onPress;
    begin
     downcur:=true;
     xmouse:=_xmouse;
     ymouse:=_ymouse;
    end;
     
    procedure  TTrackcur.onMouseMove;
    var tr:TTrackbar;
    begin
         tr:= TTrackbar(_parent);
         if downcur then
         begin
          _x:= _x + _xmouse -xmouse;
          if _x<tr.w/15 then _x:=tr.w/15;
          if _x>tr.w-tr.w/15 then _x:=tr.w-tr.w/15;
          tr.position:=arrondi((_x-tr.w/15)*(trackmax-trackmin)/(tr.w-2*tr.w/15)+trackmin);
         end;
         tr.onChange;
    end;
     
     
     
    procedure  TTrackcur.onMouseUp;
    begin
     downcur:=false;
    end;
     
     
    constructor TTrackcur.create(AOWNER:Movieclip;trmin,trmax:integer);
     var matrix: Flash8.Matrix;
    begin
      inherited Create(AOWNER,'cur',AOWNER.getNextHighestDepth);
      downcur:=false;
      xmouse:=0;
      ymouse:=0;
      matrix := Flash8.Matrix.Create();
      matrix.createGradientBox(4,4,0,-1,0);
      beginGradientFill('linear', [$f5f5f5,$f0f0f0,$c0c0c0], [100, 100,100], [0,2,210], matrix);
      linestyle(0.75,clblack);
      moveto(-2,-2);
      lineto(2,-2);
      lineto(2,0);
      lineto(0,4);
      lineto(-2,0);
      lineto(-2,-2);
      downcur:=false;
      xmouse:=0;
      ymouse:=0;
      trackmin:=trmin;
      trackmax:=trmax;
    end;
     
    {***********
    **StringGrid*
    ************}
     
    procedure TCell.onChanged(Cell:TEdit);
    begin
     TStringgrid(_parent).val:=texte;
     TStringgrid(_parent).onChange;
    end;
     
    constructor TStringGrid.Create(parent:movieclip);
    begin
     Inherited Create(Parent,'StringGrid',parent.getNextHighestDepth());
     left:=10;
     top:=100;
     opaquebackground:=$cecece;
    end;
     
     
    procedure TStringGrid.Setleft(value:number);
    begin
       _x:=value;
    end;
     
    Function TStringGrid.GetLeft:number;
    begin
     result:=_x;
    end;
     
    procedure TStringGrid.SetTop(value:number);
    begin
       _y:=value;
    end;
     
    Function TStringGrid.GetTop:number;
    begin
     result:=_y;
    end;
     
    procedure TStringGrid.SetWidth(value:number);
    begin
       _width:=value;
    end;
     
    Function TStringGrid.GetWidth:number;
    begin
     result:=_width;
    end;
     
    procedure TStringGrid.SetHeight(value:number);
    begin
       _height:=value;
    end;
     
    Function TStringGrid.GetHeight:number;
    begin
     result:=_height;
    end;
     
    procedure TStringgrid.Init(colcnt,rowcnt,width,height:integer);
    var  i,j:integer;
         espace:number;
    begin
      colcount:=colcnt;
      rowcount:=rowcnt;
      espace:=width/200;
      for i:=0 to colcount-1 do
      for j:=0 to rowcount-1 do
      begin
       cells[i,j]:=TCell.Create(self);
       cells[i,j].background:=true;
       cells[i,j].width:=(width-(colcount+1)*espace)/colcount;
       cells[i,j].height:=(height-(rowcount+1)*espace)/rowcount;
       cells[i,j].left:=espace*(i+1)+i*cells[i,j].width;
       cells[i,j].top:=espace*(j+1)+j*cells[i,j].height;;
     
     
       cells[i,j].border:=true;
       cells[i,j].text:='';
      end;
     
      linestyle(1,0);
      moveto(0,0);
      lineto(width,0);
      lineto(width,height);
      lineto(0,height);
      lineto(0,0);
    end;
     
     procedure TStringgrid.Font(Fname:string;Fsize:number;Fbold,Fitalic:boolean;algn:string);
     var i,j:integer;
     begin
      for i:=0 to colcount-1 do
      for j:=0 to rowcount-1 do
      begin
       with cells[i,j].font do
       begin
        name:=Fname;
        size:=Fsize;
        bold:=FBold;
        italic:=Fitalic;
        align:=algn;
       end;
       cells[i,j].texte:='';
      end;
     end;
     
    procedure TStringgrid.onChange;
    begin
    end;
     
    end.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
     
    program Project1;
     
    {$FRAME_WIDTH 750}
    {$FRAME_HEIGHT 600}
    {$FRAME_RATE 12}
    {$BACKGROUND $c0c0c0}
     
    uses
      Flash8,UFlash8CL;
     
    Type
     
     TButton1=class(TButton)
      procedure onClick;override;
     end;
     
     TButton2=class(TButton)
      procedure onClick;override;
     end;
     
     TEdit1=class(TEdit)
      procedure onChange;override;
     end;
     
     TTrack=class(TTrackbar)
      procedure onChange;override;
     end;
     
     TTrack2=class(TTrackbar)
      procedure onChange;override;
     end;
     
     TStringgrid1=class(TStringgrid)
      procedure onChange;override;
     end;
     
     
    var
     Button1: TButton1;
     Button2: TButton2;
     Label:TLabel;
     Edit1:TEdit1;
     Track:TTrack;
     Track2:TTrack2;
     grid:TStringGrid1;
     i,j:integer;
     
    procedure TTrack.onChange;
    begin
      grid.cells[2,2].texte:=inttostr(position);
    end;
     
    procedure TTrack2.onChange;
    begin
      grid.cells[2,3].texte:=inttostr(position);
    end;
     
     
    procedure TButton1.onClick;
    begin
     label.caption:='Button1'
    end;
     
    procedure TEdit1.onChange;
    begin
     label.caption:=texte;
    end;
     
    procedure TButton2.onClick;
    begin
     label.caption:='Button2';
    end;
     
    procedure TStringgrid1.onchange;
    begin
     label.caption:=val; //modif ici
    end;
     
    begin
     
     Label:=TLabel.Create(_root);
     with Label do
     begin
      with Font do
      begin
       name:='arial';
       size:=40;
       color:=clred;
       style:=[fsbold,fsItalic];
      end;
      caption:="J'attends la modification";
      left:=15;
      top:=150;
      width:=500;
     end;
     
     Edit1:=TEdit1.Create(_root);
     with Edit1 do
     begin
      border:=true;
      with Font do
      begin
       name:='arial';
       size:=40;
      end;
      left:=250;
      top:=5;
      width:=200;
      height:=50;
      texte:='';
     end;
     
     Button1:=TButton1.create(_root);
     with Button1 do
     begin
      caption:='Button1';
      left:=15;
      top:=10;
      width:=120;
     end;
     
     Button2:=TButton2.create(_root);
     with Button2 do
     begin
      caption:='Button2';
      left:=15;
      top:=65;
      width:=120;
     end;
     
     
     grid:=TStringGrid1.Create(_root);
     with grid do
     begin
      left:=15;
      top:=200;
      Init(10,10,600,300); //nb de colonnes,nb de lignes,largeur,hauteur
      Font('arial',15,true,false,'center'); //name,size,bold,italic,align
      cells[1,0].texte:='red';
      cells[1,1].backgroundcolor:=clred;//cells[x,y]
      cells[2,0].texte:='green';
      cells[2,1].backgroundcolor:=clgreen;
      cells[3,0].texte:='blue';
      cells[3,1].backgroundcolor:=clblue;
      end;
     
      track:=TTrack.Create(_root);
      with track do
      begin
       left:=200;
       top:=70;
       Taille:=300;
       position:=0;
       color:=clblue;
       orientation:='horizontal';
       min:=0;
       max:=20;
       graduation;
      end;
     
      track2:=TTrack2.Create(_root);
      with track2 do
      begin
       left:=650;
       top:=20;
       Taille:=300;
       position:=0;
       color:=clred;
       orientation:='vertical';
       min:=0;
       max:=30;
       graduation;
      end;
    end.program Project1;
     
    {$FRAME_WIDTH 750}
    {$FRAME_HEIGHT 600}
    {$FRAME_RATE 12}
    {$BACKGROUND $c0c0c0}
     
    uses
      Flash8,UFlash8CL;
     
    Type
     
     TButton1=class(TButton)
      procedure onClick;override;
     end;
     
     TButton2=class(TButton)
      procedure onClick;override;
     end;
     
     TEdit1=class(TEdit)
      procedure onChange;override;
     end;
     
     TTrack=class(TTrackbar)
      procedure onChange;override;
     end;
     
     TTrack2=class(TTrackbar)
      procedure onChange;override;
     end;
     
     TStringgrid1=class(TStringgrid)
      procedure onChange;override;
     end;
     
     
    var
     Button1: TButton1;
     Button2: TButton2;
     Label:TLabel;
     Edit1:TEdit1;
     Track:TTrack;
     Track2:TTrack2;
     grid:TStringGrid1;
     i,j:integer;
     
    procedure TTrack.onChange;
    begin
      grid.cells[2,2].texte:=inttostr(position);
    end;
     
    procedure TTrack2.onChange;
    begin
      grid.cells[2,3].texte:=inttostr(position);
    end;
     
     
    procedure TButton1.onClick;
    begin
     label.caption:='Button1'
    end;
     
    procedure TEdit1.onChange;
    begin
     label.caption:=texte;
    end;
     
    procedure TButton2.onClick;
    begin
     label.caption:='Button2';
    end;
     
    procedure TStringgrid1.onchange;
    begin
     label.caption:=val; //modif ici
    end;
     
    begin
     
     Label:=TLabel.Create(_root);
     with Label do
     begin
      with Font do
      begin
       name:='arial';
       size:=40;
       color:=clred;
       style:=[fsbold,fsItalic];
      end;
      caption:="J'attends la modification";
      left:=15;
      top:=150;
      width:=500;
     end;
     
     Edit1:=TEdit1.Create(_root);
     with Edit1 do
     begin
      border:=true;
      with Font do
      begin
       name:='arial';
       size:=40;
      end;
      left:=250;
      top:=5;
      width:=200;
      height:=50;
      texte:='';
     end;
     
     Button1:=TButton1.create(_root);
     with Button1 do
     begin
      caption:='Button1';
      left:=15;
      top:=10;
      width:=120;
     end;
     
     Button2:=TButton2.create(_root);
     with Button2 do
     begin
      caption:='Button2';
      left:=15;
      top:=65;
      width:=120;
     end;
     
     
     grid:=TStringGrid1.Create(_root);
     with grid do
     begin
      left:=15;
      top:=200;
      Init(10,10,600,300); //nb de colonnes,nb de lignes,largeur,hauteur
      Font('arial',15,true,false,'center'); //name,size,bold,italic,align
      cells[1,0].texte:='red';
      cells[1,1].backgroundcolor:=clred;//cells[x,y]
      cells[2,0].texte:='green';
      cells[2,1].backgroundcolor:=clgreen;
      cells[3,0].texte:='blue';
      cells[3,1].backgroundcolor:=clblue;
      end;
     
      track:=TTrack.Create(_root);
      with track do
      begin
       left:=200;
       top:=70;
       Taille:=300;
       position:=0;
       color:=clblue;
       orientation:='horizontal';
       min:=0;
       max:=20;
       graduation;
      end;
     
      track2:=TTrack2.Create(_root);
      with track2 do
      begin
       left:=650;
       top:=20;
       Taille:=300;
       position:=0;
       color:=clred;
       orientation:='vertical';
       min:=0;
       max:=30;
       graduation;
      end;
    end.
    ma question: comment éviter le fait que lorsque le curseur est en bout de course (au minimum) en mode roulette, en continuant de reculer le curseur avance de 1... ?

  2. #2
    Expert éminent sénior
    Avatar de Paul TOTH
    Homme Profil pro
    Freelance
    Inscrit en
    Novembre 2002
    Messages
    8 964
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Freelance
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2002
    Messages : 8 964
    Points : 28 430
    Points
    28 430
    Par défaut
    à mon avis tu as un pb d'arrondi

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
     
    type
      TTrackBar = class(MovieClip)
      private
        FPosition: Integer;
      // function GetPosition: Integer;
      ..
      property position:integer read FPosition write Setposition;
    ..
     
    procedure TTrackbar.SetPosition(value:integer);
    begin
      if FPosition <> Value then
      begin
        FPosition := Value;
        cur._x:=w/15+abs(value-cur.trackmin)*(w-2*w/15)/(cur.trackmax-cur.trackmin);
      end;
    end;
    Developpez.com: Mes articles, forum FlashPascal
    Entreprise: Execute SARL
    Le Store Excute Store

  3. #3
    Membre chevronné
    Avatar de Archimède
    Homme Profil pro
    Enseignant
    Inscrit en
    Avril 2005
    Messages
    1 644
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 58
    Localisation : France, Charente Maritime (Poitou Charente)

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2005
    Messages : 1 644
    Points : 1 975
    Points
    1 975
    Par défaut
    Merci pour ta réponse pertinente qui m'a bien débloqué la situation.

    Il fallait aussi faire la modif dans getPosition...

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    Function TTrackbar.GetPosition:integer;
    begin
      result:=FPosition;
    end;
    Maintenant ce prob est réglé.

    Autre et dernier souci je pense... :

    Lorsque je désire mettre position à une valeur différente de min, le curseur ne se positionne pas :
    Pourtant dans le create de TTrackbar, j'ai ajouté :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
       cur:=TTrackcur.Create(self,0,100);
      with cur do
      begin
       _x:=self.w/15+(self.position-self.min)*(self.w-2*self.w/15)/(self.max-self.min); //ici pour une position qui soit initialisée...
       _y:=h/3.3;
      end;
     
    //j'ai mis des selfs puisque je suis dans with cur...
    curieux...

    je réfléchis...

    code complet avec modif :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    685
    686
    687
    688
    689
    690
    691
    692
    693
    694
    695
    696
    697
    698
    699
    700
    701
    702
    703
    704
    705
    706
    707
    708
    709
    710
    711
    712
    713
    714
    715
    716
    717
    718
    719
    720
    721
    722
    723
    724
    725
    726
    727
    728
    729
    730
    731
    732
    733
    734
    735
    736
    737
    738
    739
    740
    741
    742
    743
    744
    745
    746
    747
    748
    749
    750
    751
    752
    753
    754
    755
    756
    757
    758
    759
    760
    761
    762
    763
    764
    765
    766
    767
    768
    769
    770
    771
    772
    773
    774
    775
    776
    777
    778
    779
    780
    781
    782
    783
    784
    785
    786
    787
    788
    789
    790
    791
    792
    793
    794
    795
    796
    797
    798
    799
    800
    801
    802
    803
    804
    805
    806
    807
    808
    809
    810
    811
    812
    813
    814
    815
    816
    817
    818
    819
    820
    821
    822
    823
    824
    825
    826
     
    unit UFlash8CL;
     
    interface
     
    uses Flash8,UFont;
     
    const
      distance=1;
      angleInDegrees=45;
      coul1=$808080;
      highlightAlpha=0.8;
      coul2=$646464;
      shadowAlpha=0.9;
      blurX=5;
      blurY=5;
      strength=5;
      quality=3;
      typ='inner';
     
    type
     
     TLabel=Class(TextField)
      Private
       first:Boolean;
       FLeft,FTop,FWidth,FHeight:number;
       Function  GetCaption:string;
       Function getLeft:number;
       Function getTop:number;
       Function getwidth:number;
       Function getHeight:number;
       procedure SetLeft(value:number);
       procedure SetTop(value:number);
       procedure SetWidth(value:number);
       procedure SetHeight(value:number);
       procedure SetCaption(value:string);
      Public
       Font:Tfont;
       constructor Create(parent:movieclip);
       property Left:number read getLeft write SetLeft;
       property Top:number read getTop write SetTop;
       property width:number read getWidth write SetWidth;
       property height:number read getHeight write SetHeight;
       property caption:string read getCaption write setCaption;
    end;
     
    {*********
    **Edit****
    **********}
     
     TEdit=Class(TLabel)
      Private
       first:Boolean;
       Function getText:string;
       procedure SetText(value:string);
       procedure onChanged(Ed:TEdit);override;
      Public
       Font:Tfont;
       constructor Create(parent:movieclip);
       procedure onChange;virtual;
       property texte:string read getText write setText;
    end;
     
     
    {*********
    **Button**
    **********}
     
     
     TButton=class(movieclip)
     
     private
      click,First:Boolean;
      skin1,skin2:movieclip;
      w,h:number;
      bevel1,bevel2:BevelFilter;
      myfilterArray:TArray;
      Title:TextField;
      Function getLeft:number;
      Function getTop:number;
      Function getwidth:number;
      Function getHeight:number;
      Function getCaption:String;
      procedure skin;
      procedure SetCaption(value:string);
      procedure SetLeft(value:number);
      procedure SetTop(value:number);
      procedure SetWidth(value:number);
      procedure SetHeight(value:number);
      procedure onPress;override;
      procedure onMouseUp;override;
     public
      Font:Tfont;
      procedure onClick;virtual;
      constructor create(parent:movieclip);
      property Caption:string read GetCaption write SetCaption;
      property Left:number read GetLeft write SetLeft;
      property Top:number read GetTop write SetTop;
      property width:number read GetWidth write SetWidth;
      property height:number read GetHeight write SetHeight;
     end;
     
    {***********
    **StringGrid*
    ************}
     
    TCell=class(TEdit)
      procedure onChanged(Cell:TEdit);
    end;
     
    TStringGrid=class(movieclip)
     private
      Function getLeft:number;
      Function getTop:number;
      Function getwidth:number;
      Function getHeight:number;
      procedure SetLeft(value:number);
      procedure SetTop(value:number);
      procedure SetWidth(value:number);
      procedure SetHeight(value:number);
     public
      val:string;
      colcount,rowcount:integer;
      Cells:array[0..200,0..200] of TCell;
      constructor Create(parent:MovieClip);
      procedure Init(colcnt,rowcnt,width,height:integer);
      procedure onChange;virtual;
      procedure Font(Fname:string;Fsize:number;Fbold,Fitalic:boolean;algn:string);
      property Left:number read GetLeft write SetLeft;
      property Top:number read GetTop write SetTop;
      property width:number read GetWidth write SetWidth;
      property height:number read GetHeight write SetHeight;
    end;
     
    {***********
    **TrackBar**
    ************}
     TTrackcur=class(MovieClip)
        xmin,xmax:number;
        xmouse,ymouse:number;
        trackmin,trackmax:integer;
        xcur,ycur:Integer;
        downcur:Boolean;
        constructor Create(AOWNER:Movieclip;trmin,trmax:integer);
        procedure onPress;override;
        procedure onMouseMove;override;
        procedure onMouseUp;override;
      end;
     
     
     TTrackBar=Class(movieClip)
     private
      w,h:integer;
      FPosition:integer;
      valorientation:string;
      bevel:BevelFilter;
      myfilterArray:TArray;
      cur: TTrackcur;
      mc:movieclip;
      function GetLeft:number;
      function Gettop:number;
      function GetTaille:number;
      function Getheight:number;
      function Getcolor:number;
      function Getmin:integer;
      function Getmax:integer;
      function GetOrientation:string;
      function GetPosition:integer;
      procedure Setleft(value:number);
      procedure SetTop(value:number);
      procedure SetTaille(value:number);
      procedure SetHeight(value:number);
      procedure Setcolor(value:number);
      procedure Setmin(value:integer);
      procedure Setmax(value:integer);
      procedure setposition(value:integer);
      procedure setorientation(value:string);
      procedure onMouseWheel(delta: Number;scrolltarget:TObject);
     public
      constructor Create(parent:movieclip);
      procedure onChange;virtual;
      procedure graduation;
      property Left:number read GetLeft write SetLeft;
      property Top:number read GetTop write SetTop;
      property Taille:number read GetTaille write SetTaille;
      property height:number read GetHeight write SetHeight;
      property color:number read GetColor write SetColor;
      property position:integer read GetPosition write Setposition;
      property min:integer read GetMin write SetMin;
      property max:integer read GetMax write SetMax;
      property orientation:string read GetOrientation write SetOrientation;
     end;
     
     
     
    implementation
     
    function arrondi(n:number):integer;
    begin
      if n-trunc(n)<0.5 then result:=trunc(n) else result:=trunc(n)+1;
    end;
     
    Constructor TLabel.Create(parent:movieclip);
    begin
     Inherited Create(Parent,'',parent.getNextHighestDepth(),0,0,100,100);
     Font:=TFont.Create;
     with Font do
     begin
      name:='arial';
      size:=14;
     end;
     first:=true;
    end;
     
    procedure TLabel.Setleft(value:number);
    begin
       _x:=value;
    end;
     
    Function TLabel.GetLeft:number;
    begin
     result:=_x;
    end;
     
    procedure TLabel.SetTop(value:number);
    begin
       _y:=value;
    end;
     
    Function TLabel.GetTop:number;
    begin
     result:=_y;
    end;
     
    procedure TLabel.SetWidth(value:number);
    begin
       _width:=value;
    end;
     
    Function TLabel.GetWidth:number;
    begin
     result:=_width;
    end;
     
    procedure TLabel.SetHeight(value:number);
    begin
       _height:=value;
    end;
     
    Function TLabel.GetHeight:number;
    begin
     result:=_height;
    end;
     
     
    procedure TLabel.SetCaption(value:string);
    begin
     if first then
     begin
      setNewTextFormat(Font.FTextFormat);
      first:=false;
     end;
     text:=value;
    end;
     
    Function TLabel.GetCaption:string;
    begin
     result:=text;
    end;
     
    {*********
    **Edit****
    **********}
     
     
    Constructor TEdit.Create(parent:movieclip);
    begin
     Inherited Create(Parent);
     type:='input';
     first:=true;
    end;
     
    Procedure TEdit.onChanged(Ed:TEdit);
    begin
     onchange;
    end;
     
     
     
    procedure TEdit.SetText(value:string);
    begin
     if first then
     begin
      setNewTextFormat(Font.FTextFormat);
      first:=false;
     end;
     text:=value;
    end;
     
    Function TEdit.getText:string;
    begin
     result:= text;
    end;
     
     
     
    Procedure TEdit.onChange;
    begin
    end;
     
     
    {*********
    **Button**
    **********}
     
    constructor TButton.Create(parent:movieclip);
    begin
     inherited Create(parent,'button',movieclip(parent).getNextHighestDepth());
     w:=90;
     h:=30;
     left:=10;
     top:=10;
     myfilterArray:=TArray.Create();
     
     Font:=TFont.Create;
     with Font do
     begin
      name:='arial';
      size:=14;
      align:='center';
     end;
     
     skin1:=movieclip.create(self,'',1);
     skin2:=movieclip.create(self,'',2);
     
     with skin1 do
     begin
      bevel1:=BevelFilter.create(distance,angleInDegrees,coul1,highlightAlpha,coul2,shadowAlpha,blurX,blurY,strength,quality,typ);
      myfilterArray.Push(bevel1);
      filters := myfilterArray;
      BeginFill($F0F0F0);
      lineto(w,0);
      lineto(w,h);
      lineto(0,h);
     end;
     
     with skin2 do
     begin
      bevel2:=BevelFilter.create(distance,angleInDegrees,coul2,highlightAlpha,coul1,shadowAlpha,blurX,blurY,strength,quality,typ);
      myfilterArray.Push(bevel2);
      filters := myfilterArray;
      BeginFill($F0F0F0);
      lineto(w,0);
      lineto(w,h);
      lineto(0,h);
     end;
     
     First:=true;
     click:=false;
     skin;
     
     Title:=TextField.Create(self,'',getNextHighestDepth(),0,0,w,h);
     with Font do
     begin
      name:='arial';
      size:=20;
     end;
    end;
     
    procedure TButton.skin;
    begin
     if not click then
     begin
      skin1._visible:=true;
      skin2._visible:=false;
     end else
     begin
      skin1._visible:=false;
      skin2._visible:=true;
     end;
    end;
     
    procedure TButton.SetCaption(Value: string);
    begin
     with title do
     begin
      if first then
      begin
       setNewTextFormat(Font.FTextFormat);
       first:=false;
      end;
      text:=value;
     end;
    end;
     
    Function TButton.GetCaption:string;
    begin
     result:=title.text;
    end;
     
     
    procedure TButton.onClick;
    begin
    end;
     
    procedure TButton.onPress;
    begin
     click:=true;
     skin;
     onClick;
    end;
     
    procedure TButton.onMouseUp;
    begin
     click:=false;
     skin;
    end;
     
    procedure TButton.Setleft(value:number);
    begin
     _x:=value;
    end;
     
    procedure TButton.SetTop(value:number);
    begin
     _y:=value;
    end;
     
    procedure TButton.SetWidth(value:number);
    begin
       _xscale:=100*value/w;
       _yscale:=_xscale;
    end;
     
    procedure TButton.SetHeight(value:number);
    begin
      _yscale:=100*value/h;
    end;
     
     
    Function TButton.GetLeft:number;
    begin
     result:=_x;
    end;
     
     
     
    Function TButton.GetTop:number;
    begin
     result:=_y;
    end;
     
     
    Function TButton.GetWidth:number;
    begin
     result:=_width;
    end;
     
     
     
    Function TButton.GetHeight:number;
    begin
     result:=_height;
    end;
     
    {***********
    **TrackBar**
    ************}
     
    constructor TTrackbar.Create(parent:movieclip);
    begin
     inherited Create(parent,'Trackbar'+floattostr(parent.getNextHighestDepth()),parent.getNextHighestDepth());
     left:=10;
     top:=10;
     w:=100;
     h:=20;
     color:=clred;
     
     mc:=movieclip.create(self,'mc',0);
     bevel:=BevelFilter.create(0.3,45,$c0c0c0,0.8,clblack,0.9,5,5,5,3,'inner');
     myfilterArray:=TArray.Create();
     myfilterArray.Push(bevel);
     
     beginFill(color);
     lineto(w,0);
     lineto(w,h);
     lineto(0,h);
     endFill();
     
     filters := myfilterArray;
     lineto(w,0);
     lineto(w,h);
     lineto(0,h);
     
      with mc do
      begin
       filters := myfilterArray;
       beginFill(clcream);
       moveto(w/15,h/4);
       lineto(w-w/15,h/4);
       lineto(w-w/15,h/4+3);
       lineto(w/15,h/4+3);
       lineto(w/15,h/4);
       endFill();
       linestyle(1,$c0c0c0);
       moveto(w/15,h/4+5);
       lineto(w/15,h/4+5.5);
       moveto(w-w/15,h/4+5);
       lineto(w-w/15,h/4+5.5);
      end;
     
     
      cur:=TTrackcur.Create(self,0,100);
      with cur do
      begin
       _x:=self.w/15+(self.position-self.min)*(self.w-2*self.w/15)/(self.max-self.min);
       _y:=h/3.3;
      end;
     
     mouse.addlistener(self);
    end;
     
    procedure TTrackbar.onMouseWheel(delta: Number;scrolltarget:TObject);
    var posi:integer;
    begin
     if (scrolltarget<>self) and (scrolltarget<>cur)  and (scrolltarget<>mc) then exit;
     posi:=position;
     if delta >0 then delta := 1 else delta := -1;
     position:=position+delta;
     if  (position>=min) and (position<=max)then
     begin
      cur._x:=w/15+(position-min)*(w-2*w/15)/(max-min);
      onChange;
     end else position:=posi;
    end;
     
     
     
    Function TTrackbar.GetPosition:integer;
    begin
      result:=FPosition;
    end;
     
    Function TTrackbar.Getmin:integer;
    begin
      result:=cur.trackmin;
    end;
     
    Function TTrackbar.Getmax:integer;
    begin
      result:=cur.trackmax;
    end;
     
    function TTrackbar.GetOrientation:string;
    begin
     result:=valorientation;
    end;
     
    procedure TTrackbar.SetMax(value:integer);
    begin
      cur.trackmax:=value;
    end;
     
    procedure TTrackbar.SetMin(value:integer);
    begin
      cur.trackmin:=value;
    end;
     
    procedure TTrackbar.SetPosition(value:integer);
    begin
     if FPosition <> Value then
     begin
       FPosition:=value;
       cur._x:=w/15+(value-cur.trackmin)*(w-2*w/15)/(cur.trackmax-cur.trackmin);
     end;
    end;
     
    procedure TTrackbar.Setleft(value:number);
    begin
      _x:=value;
    end;
     
    procedure TTrackbar.SetTop(value:number);
    begin
     _y:=value;
    end;
     
    procedure TTrackbar.SetTaille(value:number);
    begin
     _xscale:=100*value/w;
     _yscale:=_xscale;
    end;
     
    procedure TTrackbar.SetHeight(value:number);
    begin
     _yscale:=100*value/h;
    end;
     
    procedure TTrackbar.Setcolor(value:number);
    begin
     clear;
     beginFill(value);
     lineto(w,0);
     lineto(w,h);
     lineto(0,h);
     endFill();
    end;
     
    procedure TTrackbar.setOrientation(value:string);
    begin
     if value='vertical' then
     begin
      _rotation:=-90;
      _y:=_y+_height;
     end;
     valorientation:=value;
    end;
     
    procedure TTrackbar.graduation;
    var l,grad:number;
        i,nbgrad:integer;
    begin
     l:=13*w/15;
     nbgrad:=cur.trackmax-cur.trackmin;
     grad:=l/nbgrad;
     linestyle(1,$c0c0c0);
     for i:=1 to  nbgrad do
     begin
      moveto(w/15+grad*i,h/4+5);
      lineto(w/15+grad*i,h/4+5.25);
     end;
    end;
     
    procedure TTrackbar.onChange;
    begin
    end;
     
    Function TTrackbar.Getcolor:number;
    begin
     result:=opaquebackground;
    end;
     
    Function  TTrackbar.GetTaille:number;
    begin
     result:=_width;
    end;
     
    Function  TTrackbar.Getheight:number;
    begin
     result:=_height;
    end;
     
    Function  TTrackbar.GetLeft:number;
    begin
     result:=_x;
    end;
     
    Function  TTrackbar.GetTop:number;
    begin
     result:=_y;
    end;
     
    procedure  TTrackcur.onPress;
    begin
     downcur:=true;
     xmouse:=_xmouse;
     ymouse:=_ymouse;
    end;
     
    procedure  TTrackcur.onMouseMove;
    var tr:TTrackbar;
    begin
         tr:= TTrackbar(_parent);
         if downcur then
         begin
          _x:= _x + _xmouse -xmouse;
          if _x<tr.w/15 then _x:=tr.w/15;
          if _x>tr.w-tr.w/15 then _x:=tr.w-tr.w/15;
          tr.position:=arrondi((_x-tr.w/15)*(trackmax-trackmin)/(tr.w-2*tr.w/15)+trackmin);
         end;
         tr.onChange;
    end;
     
     
     
    procedure  TTrackcur.onMouseUp;
    begin
     downcur:=false;
    end;
     
     
    constructor TTrackcur.create(AOWNER:Movieclip;trmin,trmax:integer);
     var matrix: Flash8.Matrix;
    begin
      inherited Create(AOWNER,'cur',AOWNER.getNextHighestDepth);
      downcur:=false;
      xmouse:=0;
      ymouse:=0;
      matrix := Flash8.Matrix.Create();
      matrix.createGradientBox(4,4,0,-1,0);
      beginGradientFill('linear', [$f5f5f5,$f0f0f0,$c0c0c0], [100, 100,100], [0,2,210], matrix);
      linestyle(0.75,clblack);
      moveto(-2,-2);
      lineto(2,-2);
      lineto(2,0);
      lineto(0,4);
      lineto(-2,0);
      lineto(-2,-2);
      downcur:=false;
      xmouse:=0;
      ymouse:=0;
      trackmin:=trmin;
      trackmax:=trmax;
    end;
     
     
    {***********
    **StringGrid*
    ************}
     
    procedure TCell.onChanged(Cell:TEdit);
    begin
     TStringgrid(_parent).val:=texte;
     TStringgrid(_parent).onChange;
    end;
     
    constructor TStringGrid.Create(parent:movieclip);
    begin
     Inherited Create(Parent,'StringGrid',parent.getNextHighestDepth());
     left:=10;
     top:=100;
     opaquebackground:=$cecece;
    end;
     
     
    procedure TStringGrid.Setleft(value:number);
    begin
       _x:=value;
    end;
     
    Function TStringGrid.GetLeft:number;
    begin
     result:=_x;
    end;
     
    procedure TStringGrid.SetTop(value:number);
    begin
       _y:=value;
    end;
     
    Function TStringGrid.GetTop:number;
    begin
     result:=_y;
    end;
     
    procedure TStringGrid.SetWidth(value:number);
    begin
       _width:=value;
    end;
     
    Function TStringGrid.GetWidth:number;
    begin
     result:=_width;
    end;
     
    procedure TStringGrid.SetHeight(value:number);
    begin
       _height:=value;
    end;
     
    Function TStringGrid.GetHeight:number;
    begin
     result:=_height;
    end;
     
    procedure TStringgrid.Init(colcnt,rowcnt,width,height:integer);
    var  i,j:integer;
         espace:number;
    begin
      colcount:=colcnt;
      rowcount:=rowcnt;
      espace:=width/200;
      for i:=0 to colcount-1 do
      for j:=0 to rowcount-1 do
      begin
       cells[i,j]:=TCell.Create(self);
       cells[i,j].background:=true;
       cells[i,j].width:=(width-(colcount+1)*espace)/colcount;
       cells[i,j].height:=(height-(rowcount+1)*espace)/rowcount;
       cells[i,j].left:=espace*(i+1)+i*cells[i,j].width;
       cells[i,j].top:=espace*(j+1)+j*cells[i,j].height;
       cells[i,j].border:=true;
       cells[i,j].text:='';
      end;
     
      linestyle(1,0);
      moveto(0,0);
      lineto(width,0);
      lineto(width,height);
      lineto(0,height);
      lineto(0,0);
    end;
     
     procedure TStringgrid.Font(Fname:string;Fsize:number;Fbold,Fitalic:boolean;algn:string);
     var i,j:integer;
     begin
      for i:=0 to colcount-1 do
      for j:=0 to rowcount-1 do
      begin
       with cells[i,j].font do
       begin
        name:=Fname;
        size:=Fsize;
        bold:=FBold;
        italic:=Fitalic;
        align:=algn;
       end;
       cells[i,j].texte:='';
      end;
     end;
     
    procedure TStringgrid.onChange;
    begin
    end;
     
    end.

  4. #4
    Membre chevronné
    Avatar de Archimède
    Homme Profil pro
    Enseignant
    Inscrit en
    Avril 2005
    Messages
    1 644
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 58
    Localisation : France, Charente Maritime (Poitou Charente)

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2005
    Messages : 1 644
    Points : 1 975
    Points
    1 975
    Par défaut
    Déja, il faut initialiser FPosition (un oubli capital) dans TTracbar.Create...

    Une grosse valeur par exemple pour qu'elle soit différente de value sinon on n'affecte pas setposition...
    si bien que le _x de cur ne subit pas de modif...au départ.

    Ou on simplifie Setposition puisque la condition n'est pas nécessaire (ça marche très bien sans) :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
     FPosition:=value;
     cur._x:=.....
    je regarde...

  5. #5
    Expert éminent sénior
    Avatar de Paul TOTH
    Homme Profil pro
    Freelance
    Inscrit en
    Novembre 2002
    Messages
    8 964
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Freelance
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2002
    Messages : 8 964
    Points : 28 430
    Points
    28 430
    Par défaut
    tu n'as pas vu la modif, la propréité Position utilise FPosition dans le READ, donc plus besoin de GetPosition

    le constructor initialiser les entiers à 0 automatiquement.
    Developpez.com: Mes articles, forum FlashPascal
    Entreprise: Execute SARL
    Le Store Excute Store

  6. #6
    Membre chevronné
    Avatar de Archimède
    Homme Profil pro
    Enseignant
    Inscrit en
    Avril 2005
    Messages
    1 644
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 58
    Localisation : France, Charente Maritime (Poitou Charente)

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2005
    Messages : 1 644
    Points : 1 975
    Points
    1 975
    Par défaut
    Citation Envoyé par Paul TOTH Voir le message
    tu n'as pas vu la modif, la propréité Position utilise FPosition dans le READ, donc plus besoin de GetPosition
    e constructor initialiser les entiers à 0 automatiquement.
    Oui excuse, je n'avais pas vu la modif sur :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
      property position:integer read FPosition write Setposition;
    En effet, je fais l'économie de Getposition...

    Le prob de position initiale du curseur n'est toujours pas réglé cependant...
    l

  7. #7
    Membre chevronné
    Avatar de Archimède
    Homme Profil pro
    Enseignant
    Inscrit en
    Avril 2005
    Messages
    1 644
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 58
    Localisation : France, Charente Maritime (Poitou Charente)

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2005
    Messages : 1 644
    Points : 1 975
    Points
    1 975
    Par défaut
    C'est bon, je n'avais pas regardé dans mon programme d'essai...il faut placer les propriétés min, max et taille avant position...sinon évidemment ça ne le fait pas...

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
    619
    620
    621
    622
    623
    624
    625
    626
    627
    628
    629
    630
    631
    632
    633
    634
    635
    636
    637
    638
    639
    640
    641
    642
    643
    644
    645
    646
    647
    648
    649
    650
    651
    652
    653
    654
    655
    656
    657
    658
    659
    660
    661
    662
    663
    664
    665
    666
    667
    668
    669
    670
    671
    672
    673
    674
    675
    676
    677
    678
    679
    680
    681
    682
    683
    684
    685
    686
    687
    688
    689
    690
    691
    692
    693
    694
    695
    696
    697
    698
    699
    700
    701
    702
    703
    704
    705
    706
    707
    708
    709
    710
    711
    712
    713
    714
    715
    716
    717
    718
    719
    720
    721
    722
    723
    724
    725
    726
    727
    728
    729
    730
    731
    732
    733
    734
    735
    736
    737
    738
    739
    740
    741
    742
    743
    744
    745
    746
    747
    748
    749
    750
    751
    752
    753
    754
    755
    756
    757
    758
    759
    760
    761
    762
    763
    764
    765
    766
    767
    768
    769
    770
    771
    772
    773
    774
    775
    776
    777
    778
    779
    780
    781
    782
    783
    784
    785
    786
    787
    788
    789
    790
    791
    792
    793
    794
    795
    796
    797
    798
    799
    800
    801
    802
    803
    804
    805
    806
    807
    808
    809
    810
    811
    812
    813
    814
    815
    816
    817
    818
    819
     
    unit UFlash8CL;
     
    interface
     
    uses Flash8,UFont;
     
    const
      distance=1;
      angleInDegrees=45;
      coul1=$808080;
      highlightAlpha=0.8;
      coul2=$646464;
      shadowAlpha=0.9;
      blurX=5;
      blurY=5;
      strength=5;
      quality=3;
      typ='inner';
     
    type
     
     TLabel=Class(TextField)
      Private
       first:Boolean;
       FLeft,FTop,FWidth,FHeight:number;
       Function  GetCaption:string;
       Function getLeft:number;
       Function getTop:number;
       Function getwidth:number;
       Function getHeight:number;
       procedure SetLeft(value:number);
       procedure SetTop(value:number);
       procedure SetWidth(value:number);
       procedure SetHeight(value:number);
       procedure SetCaption(value:string);
      Public
       Font:Tfont;
       constructor Create(parent:movieclip);
       property Left:number read getLeft write SetLeft;
       property Top:number read getTop write SetTop;
       property width:number read getWidth write SetWidth;
       property height:number read getHeight write SetHeight;
       property caption:string read getCaption write setCaption;
    end;
     
    {*********
    **Edit****
    **********}
     
     TEdit=Class(TLabel)
      Private
       first:Boolean;
       Function getText:string;
       procedure SetText(value:string);
       procedure onChanged(Ed:TEdit);override;
      Public
       Font:Tfont;
       constructor Create(parent:movieclip);
       procedure onChange;virtual;
       property texte:string read getText write setText;
    end;
     
     
    {*********
    **Button**
    **********}
     
     
     TButton=class(movieclip)
     
     private
      click,First:Boolean;
      skin1,skin2:movieclip;
      w,h:number;
      bevel1,bevel2:BevelFilter;
      myfilterArray:TArray;
      Title:TextField;
      Function getLeft:number;
      Function getTop:number;
      Function getwidth:number;
      Function getHeight:number;
      Function getCaption:String;
      procedure skin;
      procedure SetCaption(value:string);
      procedure SetLeft(value:number);
      procedure SetTop(value:number);
      procedure SetWidth(value:number);
      procedure SetHeight(value:number);
      procedure onPress;override;
      procedure onMouseUp;override;
     public
      Font:Tfont;
      procedure onClick;virtual;
      constructor create(parent:movieclip);
      property Caption:string read GetCaption write SetCaption;
      property Left:number read GetLeft write SetLeft;
      property Top:number read GetTop write SetTop;
      property width:number read GetWidth write SetWidth;
      property height:number read GetHeight write SetHeight;
     end;
     
    {***********
    **StringGrid*
    ************}
     
    TCell=class(TEdit)
      procedure onChanged(Cell:TEdit);
    end;
     
    TStringGrid=class(movieclip)
     private
      Function getLeft:number;
      Function getTop:number;
      Function getwidth:number;
      Function getHeight:number;
      procedure SetLeft(value:number);
      procedure SetTop(value:number);
      procedure SetWidth(value:number);
      procedure SetHeight(value:number);
     public
      val:string;
      colcount,rowcount:integer;
      Cells:array[0..200,0..200] of TCell;
      constructor Create(parent:MovieClip);
      procedure Init(colcnt,rowcnt,width,height:integer);
      procedure onChange;virtual;
      procedure Font(Fname:string;Fsize:number;Fbold,Fitalic:boolean;algn:string);
      property Left:number read GetLeft write SetLeft;
      property Top:number read GetTop write SetTop;
      property width:number read GetWidth write SetWidth;
      property height:number read GetHeight write SetHeight;
    end;
     
    {***********
    **TrackBar**
    ************}
     TTrackcur=class(MovieClip)
        xmin,xmax:number;
        xmouse,ymouse:number;
        trackmin,trackmax:integer;
        xcur,ycur:Integer;
        downcur:Boolean;
        constructor Create(AOWNER:Movieclip;trmin,trmax:integer);
        procedure onPress;override;
        procedure onMouseMove;override;
        procedure onMouseUp;override;
      end;
     
     
     TTrackBar=Class(movieClip)
     private
      w,h:integer;
      FPosition:integer;
      FOrientation:string;
      valorientation:string;
      bevel:BevelFilter;
      myfilterArray:TArray;
      cur: TTrackcur;
      mc:movieclip;
      function GetLeft:number;
      function Gettop:number;
      function GetTaille:number;
      function Getheight:number;
      function Getcolor:number;
      function Getmin:integer;
      function Getmax:integer;
     // function GetOrientation:string;  inutile
      procedure Setleft(value:number);
      procedure SetTop(value:number);
      procedure SetTaille(value:number);
      procedure SetHeight(value:number);
      procedure Setcolor(value:number);
      procedure Setmin(value:integer);
      procedure Setmax(value:integer);
      procedure setposition(value:integer);
      procedure setorientation(value:string);
      procedure onMouseWheel(delta: Number;scrolltarget:TObject);
     public
      constructor Create(parent:movieclip);
      procedure onChange;virtual;
      procedure graduation;
      property Left:number read GetLeft write SetLeft;
      property Top:number read GetTop write SetTop;
      property Taille:number read GetTaille write SetTaille;
      property height:number read GetHeight write SetHeight;
      property color:number read GetColor write SetColor;
      property position:integer read FPosition write Setposition;
      property min:integer read GetMin write SetMin;
      property max:integer read GetMax write SetMax;
      property orientation:string read FOrientation write SetOrientation; //modif
     end;
     
     
     
    implementation
     
    function arrondi(n:number):integer;
    begin
      if n-trunc(n)<0.5 then result:=trunc(n) else result:=trunc(n)+1;
    end;
     
    Constructor TLabel.Create(parent:movieclip);
    begin
     Inherited Create(Parent,'',parent.getNextHighestDepth(),0,0,100,100);
     Font:=TFont.Create;
     with Font do
     begin
      name:='arial';
      size:=14;
     end;
     first:=true;
    end;
     
    procedure TLabel.Setleft(value:number);
    begin
       _x:=value;
    end;
     
    Function TLabel.GetLeft:number;
    begin
     result:=_x;
    end;
     
    procedure TLabel.SetTop(value:number);
    begin
       _y:=value;
    end;
     
    Function TLabel.GetTop:number;
    begin
     result:=_y;
    end;
     
    procedure TLabel.SetWidth(value:number);
    begin
       _width:=value;
    end;
     
    Function TLabel.GetWidth:number;
    begin
     result:=_width;
    end;
     
    procedure TLabel.SetHeight(value:number);
    begin
       _height:=value;
    end;
     
    Function TLabel.GetHeight:number;
    begin
     result:=_height;
    end;
     
     
    procedure TLabel.SetCaption(value:string);
    begin
     if first then
     begin
      setNewTextFormat(Font.FTextFormat);
      first:=false;
     end;
     text:=value;
    end;
     
    Function TLabel.GetCaption:string;
    begin
     result:=text;
    end;
     
    {*********
    **Edit****
    **********}
     
     
    Constructor TEdit.Create(parent:movieclip);
    begin
     Inherited Create(Parent);
     type:='input';
     first:=true;
    end;
     
    Procedure TEdit.onChanged(Ed:TEdit);
    begin
     onchange;
    end;
     
     
     
    procedure TEdit.SetText(value:string);
    begin
     if first then
     begin
      setNewTextFormat(Font.FTextFormat);
      first:=false;
     end;
     text:=value;
    end;
     
    Function TEdit.getText:string;
    begin
     result:= text;
    end;
     
     
     
    Procedure TEdit.onChange;
    begin
    end;
     
     
    {*********
    **Button**
    **********}
     
    constructor TButton.Create(parent:movieclip);
    begin
     inherited Create(parent,'button',movieclip(parent).getNextHighestDepth());
     w:=90;
     h:=30;
     left:=10;
     top:=10;
     myfilterArray:=TArray.Create();
     
     Font:=TFont.Create;
     with Font do
     begin
      name:='arial';
      size:=14;
      align:='center';
     end;
     
     skin1:=movieclip.create(self,'',1);
     skin2:=movieclip.create(self,'',2);
     
     with skin1 do
     begin
      bevel1:=BevelFilter.create(distance,angleInDegrees,coul1,highlightAlpha,coul2,shadowAlpha,blurX,blurY,strength,quality,typ);
      myfilterArray.Push(bevel1);
      filters := myfilterArray;
      BeginFill($F0F0F0);
      lineto(w,0);
      lineto(w,h);
      lineto(0,h);
     end;
     
     with skin2 do
     begin
      bevel2:=BevelFilter.create(distance,angleInDegrees,coul2,highlightAlpha,coul1,shadowAlpha,blurX,blurY,strength,quality,typ);
      myfilterArray.Push(bevel2);
      filters := myfilterArray;
      BeginFill($F0F0F0);
      lineto(w,0);
      lineto(w,h);
      lineto(0,h);
     end;
     
     First:=true;
     click:=false;
     skin;
     
     Title:=TextField.Create(self,'',getNextHighestDepth(),0,0,w,h);
     with Font do
     begin
      name:='arial';
      size:=20;
     end;
    end;
     
    procedure TButton.skin;
    begin
     if not click then
     begin
      skin1._visible:=true;
      skin2._visible:=false;
     end else
     begin
      skin1._visible:=false;
      skin2._visible:=true;
     end;
    end;
     
    procedure TButton.SetCaption(Value: string);
    begin
     with title do
     begin
      if first then
      begin
       setNewTextFormat(Font.FTextFormat);
       first:=false;
      end;
      text:=value;
     end;
    end;
     
    Function TButton.GetCaption:string;
    begin
     result:=title.text;
    end;
     
     
    procedure TButton.onClick;
    begin
    end;
     
    procedure TButton.onPress;
    begin
     click:=true;
     skin;
     onClick;
    end;
     
    procedure TButton.onMouseUp;
    begin
     click:=false;
     skin;
    end;
     
    procedure TButton.Setleft(value:number);
    begin
     _x:=value;
    end;
     
    procedure TButton.SetTop(value:number);
    begin
     _y:=value;
    end;
     
    procedure TButton.SetWidth(value:number);
    begin
       _xscale:=100*value/w;
       _yscale:=_xscale;
    end;
     
    procedure TButton.SetHeight(value:number);
    begin
      _yscale:=100*value/h;
    end;
     
     
    Function TButton.GetLeft:number;
    begin
     result:=_x;
    end;
     
     
     
    Function TButton.GetTop:number;
    begin
     result:=_y;
    end;
     
     
    Function TButton.GetWidth:number;
    begin
     result:=_width;
    end;
     
     
     
    Function TButton.GetHeight:number;
    begin
     result:=_height;
    end;
     
    {***********
    **TrackBar**
    ************}
     
    constructor TTrackbar.Create(parent:movieclip);
    begin
     inherited Create(parent,'Trackbar'+floattostr(parent.getNextHighestDepth()),parent.getNextHighestDepth());
     left:=10;
     top:=10;
     w:=100;
     h:=20;
     color:=clred;
     
     mc:=movieclip.create(self,'mc',0);
     bevel:=BevelFilter.create(0.3,45,$c0c0c0,0.8,clblack,0.9,5,5,5,3,'inner');
     myfilterArray:=TArray.Create();
     myfilterArray.Push(bevel);
     
     beginFill(color);
     lineto(w,0);
     lineto(w,h);
     lineto(0,h);
     endFill();
     
     filters := myfilterArray;
     lineto(w,0);
     lineto(w,h);
     lineto(0,h);
     
      with mc do
      begin
       filters := myfilterArray;
       beginFill(clcream);
       moveto(w/15,h/4);
       lineto(w-w/15,h/4);
       lineto(w-w/15,h/4+3);
       lineto(w/15,h/4+3);
       lineto(w/15,h/4);
       endFill();
       linestyle(1,$c0c0c0);
       moveto(w/15,h/4+5);
       lineto(w/15,h/4+5.5);
       moveto(w-w/15,h/4+5);
       lineto(w-w/15,h/4+5.5);
      end;
     
     
      cur:=TTrackcur.Create(self,0,100);
      with cur do
      begin
       _x:=w/15+(position-min)*(taille-2*taille/15)/(max-min);
       _y:=h/3.3;
      end;
     
     mouse.addlistener(self);
    end;
     
    procedure TTrackbar.onMouseWheel(delta: Number;scrolltarget:TObject);
    var posi:integer;
    begin
     if (scrolltarget<>self) and (scrolltarget<>cur)  and (scrolltarget<>mc) then exit;
     posi:=position;
     if delta >0 then delta := 1 else delta := -1;
     position:=position+delta;
     if  (position>=min) and (position<=max)then
     begin
      cur._x:=w/15+(position-min)*(w-2*w/15)/(max-min);
      onChange;
     end else position:=posi;
    end;
     
     
     
     
    Function TTrackbar.Getmin:integer;
    begin
      result:=cur.trackmin;
    end;
     
    Function TTrackbar.Getmax:integer;
    begin
      result:=cur.trackmax;
    end;
     
    {function TTrackbar.GetOrientation:string;
    begin
     result:=valorientation;
    end;} 
     
    procedure TTrackbar.SetMax(value:integer);
    begin
      cur.trackmax:=value;
    end;
     
    procedure TTrackbar.SetMin(value:integer);
    begin
      cur.trackmin:=value;
    end;
     
    procedure TTrackbar.SetPosition(value:integer);
    begin
       FPosition:=value;
       cur._x:=w/15+(value-cur.trackmin)*(w-2*w/15)/(cur.trackmax-cur.trackmin);
    end;
     
    procedure TTrackbar.Setleft(value:number);
    begin
      _x:=value;
    end;
     
    procedure TTrackbar.SetTop(value:number);
    begin
     _y:=value;
    end;
     
    procedure TTrackbar.SetTaille(value:number);
    begin
     _xscale:=100*value/w;
     _yscale:=_xscale;
    end;
     
    procedure TTrackbar.SetHeight(value:number);
    begin
     _yscale:=100*value/h;
    end;
     
    procedure TTrackbar.Setcolor(value:number);
    begin
     clear;
     beginFill(value);
     lineto(w,0);
     lineto(w,h);
     lineto(0,h);
     endFill();
    end;
     
    procedure TTrackbar.setOrientation(value:string);
    begin
     if value='vertical' then
     begin
      _rotation:=-90;
      _y:=_y+_height;
     end;
     FOrientation:=value;
    end;
     
    procedure TTrackbar.graduation;
    var l,grad:number;
        i,nbgrad:integer;
    begin
     l:=13*w/15;
     nbgrad:=cur.trackmax-cur.trackmin;
     grad:=l/nbgrad;
     linestyle(1,$c0c0c0);
     for i:=1 to  nbgrad do
     begin
      moveto(w/15+grad*i,h/4+5);
      lineto(w/15+grad*i,h/4+5.25);
     end;
    end;
     
    procedure TTrackbar.onChange;
    begin
    end;
     
    Function TTrackbar.Getcolor:number;
    begin
     result:=opaquebackground;
    end;
     
    Function  TTrackbar.GetTaille:number;
    begin
     result:=_width;
    end;
     
    Function  TTrackbar.Getheight:number;
    begin
     result:=_height;
    end;
     
    Function  TTrackbar.GetLeft:number;
    begin
     result:=_x;
    end;
     
    Function  TTrackbar.GetTop:number;
    begin
     result:=_y;
    end;
     
    procedure  TTrackcur.onPress;
    begin
     downcur:=true;
     xmouse:=_xmouse;
     ymouse:=_ymouse;
    end;
     
    procedure  TTrackcur.onMouseMove;
    var tr:TTrackbar;
    begin
         tr:= TTrackbar(_parent);
         if downcur then
         begin
          _x:= _x + _xmouse -xmouse;
          if _x<tr.w/15 then _x:=tr.w/15;
          if _x>tr.w-tr.w/15 then _x:=tr.w-tr.w/15;
          tr.position:=arrondi((_x-tr.w/15)*(trackmax-trackmin)/(tr.w-2*tr.w/15)+trackmin);
         end;
         tr.onChange;
    end;
     
     
     
    procedure  TTrackcur.onMouseUp;
    begin
     downcur:=false;
    end;
     
     
    constructor TTrackcur.create(AOWNER:Movieclip;trmin,trmax:integer);
     var matrix: Flash8.Matrix;
    begin
      inherited Create(AOWNER,'cur',AOWNER.getNextHighestDepth);
      downcur:=false;
      xmouse:=0;
      ymouse:=0;
      matrix := Flash8.Matrix.Create();
      matrix.createGradientBox(4,4,0,-1,0);
      beginGradientFill('linear', [$f5f5f5,$f0f0f0,$c0c0c0], [100, 100,100], [0,2,210], matrix);
      linestyle(0.75,clblack);
      moveto(-2,-2);
      lineto(2,-2);
      lineto(2,0);
      lineto(0,4);
      lineto(-2,0);
      lineto(-2,-2);
      downcur:=false;
      xmouse:=0;
      ymouse:=0;
      trackmin:=trmin;
      trackmax:=trmax;
    end;
     
     
    {***********
    **StringGrid*
    ************}
     
    procedure TCell.onChanged(Cell:TEdit);
    begin
     TStringgrid(_parent).val:=texte;
     TStringgrid(_parent).onChange;
    end;
     
    constructor TStringGrid.Create(parent:movieclip);
    begin
     Inherited Create(Parent,'StringGrid',parent.getNextHighestDepth());
     left:=10;
     top:=100;
     opaquebackground:=$cecece;
    end;
     
     
    procedure TStringGrid.Setleft(value:number);
    begin
       _x:=value;
    end;
     
    Function TStringGrid.GetLeft:number;
    begin
     result:=_x;
    end;
     
    procedure TStringGrid.SetTop(value:number);
    begin
       _y:=value;
    end;
     
    Function TStringGrid.GetTop:number;
    begin
     result:=_y;
    end;
     
    procedure TStringGrid.SetWidth(value:number);
    begin
       _width:=value;
    end;
     
    Function TStringGrid.GetWidth:number;
    begin
     result:=_width;
    end;
     
    procedure TStringGrid.SetHeight(value:number);
    begin
       _height:=value;
    end;
     
    Function TStringGrid.GetHeight:number;
    begin
     result:=_height;
    end;
     
    procedure TStringgrid.Init(colcnt,rowcnt,width,height:integer);
    var  i,j:integer;
         espace:number;
    begin
      colcount:=colcnt;
      rowcount:=rowcnt;
      espace:=width/200;
      for i:=0 to colcount-1 do
      for j:=0 to rowcount-1 do
      begin
       cells[i,j]:=TCell.Create(self);
       cells[i,j].background:=true;
       cells[i,j].width:=(width-(colcount+1)*espace)/colcount;
       cells[i,j].height:=(height-(rowcount+1)*espace)/rowcount;
       cells[i,j].left:=espace*(i+1)+i*cells[i,j].width;
       cells[i,j].top:=espace*(j+1)+j*cells[i,j].height;
       cells[i,j].border:=true;
       cells[i,j].text:='';
      end;
     
      linestyle(1,0);
      moveto(0,0);
      lineto(width,0);
      lineto(width,height);
      lineto(0,height);
      lineto(0,0);
    end;
     
     procedure TStringgrid.Font(Fname:string;Fsize:number;Fbold,Fitalic:boolean;algn:string);
     var i,j:integer;
     begin
      for i:=0 to colcount-1 do
      for j:=0 to rowcount-1 do
      begin
       with cells[i,j].font do
       begin
        name:=Fname;
        size:=Fsize;
        bold:=FBold;
        italic:=Fitalic;
        align:=algn;
       end;
       cells[i,j].texte:='';
      end;
     end;
     
    procedure TStringgrid.onChange;
    begin
    end;
     
    end.
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
     
    program Project1;
     
    {$FRAME_WIDTH 750}
    {$FRAME_HEIGHT 600}
    {$FRAME_RATE 12}
    {$BACKGROUND $c0c0c0}
     
    uses
      Flash8,UFlash8CL;
     
    Type
     
     TButton1=class(TButton)
      procedure onClick;override;
     end;
     
     TButton2=class(TButton)
      procedure onClick;override;
     end;
     
     TEdit1=class(TEdit)
    procedure onChange;override;
     end;
     
     TTrack=class(TTrackbar)
      procedure onChange;override;
     end;
     
     TTrack2=class(TTrackbar)
      procedure onChange;override;
     end;
     
     TStringgrid1=class(TStringgrid)
      procedure onChange;override;
     end;
     
     
    var
     Button1: TButton1;
     Button2: TButton2;
     Label:TLabel;
     Edit1:TEdit1;
     Track:TTrack;
     Track2:TTrack2;
     grid:TStringGrid1;
     i,j:integer;
     
    procedure TTrack.onChange;
    begin
      grid.cells[2,2].texte:=inttostr(position);
    end;
     
    procedure TTrack2.onChange;
    begin
      grid.cells[2,3].texte:=inttostr(position);
    end;
     
     
    procedure TButton1.onClick;
    begin
     label.caption:='Button1'
    end;
     
    procedure TEdit1.onChange;
    begin
     label.caption:=texte;
    end;
     
    procedure TButton2.onClick;
    begin
     label.caption:='Button2';
    end;
     
    procedure TStringgrid1.onchange;
    begin
     label.caption:=val; //modif ici
    end;
     
    begin
     
     Label:=TLabel.Create(_root);
     with Label do
     begin
      with Font do
      begin
       name:='arial';
       size:=40;
       color:=clred;
       style:=[fsbold,fsItalic];
      end;
      caption:="J'attends la modification";
      left:=15;
      top:=150;
      width:=500;
     end;
     
     Edit1:=TEdit1.Create(_root);
     with Edit1 do
     begin
      border:=true;
      background:=true;
      backgroundColor:=clwhite;
      with Font do
      begin
       name:='arial';
       size:=40;
      end;
      left:=250;
      top:=5;
      width:=200;
      height:=50;
      texte:='';
     end;
     
     Button1:=TButton1.create(_root);
     with Button1 do
     begin
      caption:='Button1';
      left:=15;
      top:=10;
      width:=120;
     end;
     
     Button2:=TButton2.create(_root);
     with Button2 do
     begin
      caption:='Button2';
      left:=15;
      top:=65;
      width:=120;
     end;
     
     
     grid:=TStringGrid1.Create(_root);
     with grid do
     begin
      left:=15;
      top:=200;
      Init(10,10,600,300); //nb de colonnes,nb de lignes,largeur,hauteur
      Font('arial',15,true,false,'center'); //name,size,bold,italic,align
      cells[1,0].texte:='red';
      cells[1,1].backgroundcolor:=clred;//cells[x,y]
      cells[2,0].texte:='green';
      cells[2,1].backgroundcolor:=clgreen;
      cells[3,0].texte:='blue';
      cells[3,1].backgroundcolor:=clblue;
      end;
     
      track:=TTrack.Create(_root);
      with track do
      begin
       left:=200;
       top:=70;
          min:=0;
       max:=20;
       Taille:=300;
       position:=10;
       color:=clblue;
       orientation:='horizontal';
     
       graduation;
      end;
     
      track2:=TTrack2.Create(_root);
      with track2 do
      begin
       left:=650;
       top:=20;
       min:=-250;
       max:=1000;
       Taille:=300;
       position:=0;
       color:=clred;
       orientation:='vertical';
       graduation;
      end;
    end.
    Merci, ça marche, je pense...

  8. #8
    Rédacteur/Modérateur

    Avatar de Roland Chastain
    Homme Profil pro
    Enseignant
    Inscrit en
    Décembre 2011
    Messages
    4 072
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Décembre 2011
    Messages : 4 072
    Points : 15 462
    Points
    15 462
    Billets dans le blog
    9
    Par défaut
    Je vois que l'unité Flash8CL progresse. Les "trackbars" ont l'air d'être vraiment bien au point.

    J'ai parcouru l'ensemble du code mais je me suis arrêté plus longuement sur l'objet StringGrid. J'ai essayé une ou deux modifications : notamment supprimé l'espace entre les cellules, et changé la façon de calculer les dimensions des cellules, pour éviter des irrégularités (qui avec l'espace sont imperceptibles, mais existent). Au lieu d'être réparti (théoriquement) entre toutes les cellules, le reste de la division est rejeté en bas et à droite : la grille est plus petite que ce qui est demandé, mais toutes les cellules ont la même taille.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    {$FRAME_WIDTH 420}
    {$FRAME_HEIGHT 594}
     
    program CompareFormules;
     
    { Essai du type TStringGrid de l'unité UFlash8CL.
     
      Un commerçant propose deux formules promotionnelles :
      1° un article acheté, le second à moitié prix ;
      2° deux articles achetés, le troisième offert.
      
      On cherche à savoir quelle est la formule la plus avantageuse pour tel nombre
      d'articles. }
     
    uses
      Flash8,
      //UFlash8CL,
      UFlash8CLExtract;
     
    var
      Grid1: TStringGrid;
     
    { -- Exercice ---------------------------------------------------------------- }
     
    type
      tFormule = record
                   a: integer; // acheté
                   p: number;  // payé
                 end;
     
    var
      F1, F2: tFormule;
     
    procedure Calcul;
    var
      i: integer;
      p1, p2, m: number;
    begin
      for i := 1 to 20 do
      begin
        p1 := F1.p * (i div F1.a) + i mod F1.a;
        p2 := F2.p * (i div F2.a) + i mod F2.a;
        m := p1; if p2 < m then m := p2;
        Grid1.cells[0, i].texte := IntToStr(i);
        Grid1.cells[1, i].texte := FloatToStr(p1);
        Grid1.cells[2, i].texte := FloatToStr(p2);
        Grid1.cells[3, i].texte := FloatToStr(m);
      end;
    end;
     
    { -- Fin exercice ------------------------------------------------------------ }
     
    begin
      Grid1 := TStringGrid.Create(_root);
      with Grid1 do
      begin
        left := 10;
        top := 10;
        Init(4, 21, 400, 574); // nb de colonnes, nb de lignes, largeur, hauteur
        Font('Courier', 20, FALSE, FALSE, 'center'); // name, size, bold, italic, align
        cells[0, 0].texte := 'A';  // acheté
        cells[1, 0].texte := 'F1'; // payé formule 1
        cells[2, 0].texte := 'F2'; // payé formule 2
        cells[3, 0].texte := 'M';  // meilleur prix
      end;
     
      F1.a := 2;
      F1.p := 1 + 1/2;
      F2.a := 3;
      F2.p := 2.0;
     
      Calcul;
    end.
    Mon programme fonctionne à moitié, je ne sais pas pourquoi. J'ai un résultat valide, l'autre non, alors que le code est le même (si je ne me trompe).
    Fichiers attachés Fichiers attachés
    Mon site personnel consacré à MSEide+MSEgui : msegui.net

  9. #9
    Expert éminent sénior
    Avatar de Paul TOTH
    Homme Profil pro
    Freelance
    Inscrit en
    Novembre 2002
    Messages
    8 964
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Freelance
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2002
    Messages : 8 964
    Points : 28 430
    Points
    28 430
    Par défaut
    ok, petit bug dans le compilateur, F1 n'est pas initialisé

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    var
      F1: tFormule;
      F2: tFormule;
     
    // et non F1, F2: tFormule;
    Developpez.com: Mes articles, forum FlashPascal
    Entreprise: Execute SARL
    Le Store Excute Store

  10. #10
    Membre chevronné
    Avatar de Archimède
    Homme Profil pro
    Enseignant
    Inscrit en
    Avril 2005
    Messages
    1 644
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 58
    Localisation : France, Charente Maritime (Poitou Charente)

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2005
    Messages : 1 644
    Points : 1 975
    Points
    1 975
    Par défaut
    Merci Roland pour ton aide... Tout seul, ce n'est pas simple. Le trackbar, j'ai galéré...(surtout avec le onMouseWheel-> heureusement que Paul a débloqué la situation...)

    Je regarde tes modifs...

    Dans la foulée, il manque une scrollbar, quand j'aurai le temps ou si tu te sens d'attaque pour en réaliser une.

    Pour les movieclips qui dépassent la hauteur du navigateur, ce serait bien d'avoir des barres de défilements.
    La fin de l'année, c'est là que je suis le plus occupé. pas évident...

    l'edit et le label, il faut ajouter une propriété color...ce serait bien d'avoir un parent.font aussi...pour éviter de se répéter...

    bonne fin de WE

  11. #11
    Membre chevronné
    Avatar de Archimède
    Homme Profil pro
    Enseignant
    Inscrit en
    Avril 2005
    Messages
    1 644
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 58
    Localisation : France, Charente Maritime (Poitou Charente)

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2005
    Messages : 1 644
    Points : 1 975
    Points
    1 975
    Par défaut
    D'ailleurs, ajoute ta modif sur stringgrid dans UFlash8CL, elle est bien venue ...

    merci

  12. #12
    Rédacteur/Modérateur

    Avatar de Roland Chastain
    Homme Profil pro
    Enseignant
    Inscrit en
    Décembre 2011
    Messages
    4 072
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Décembre 2011
    Messages : 4 072
    Points : 15 462
    Points
    15 462
    Billets dans le blog
    9
    Par défaut
    Citation Envoyé par Archimède Voir le message
    Dans la foulée, il manque une scrollbar, quand j'aurai le temps ou si tu te sens d'attaque pour en réaliser une.

    Pour les movieclips qui dépassent la hauteur du navigateur, ce serait bien d'avoir des barres de défilements.
    La fin de l'année, c'est là que je suis le plus occupé. pas évident...

    l'edit et le label, il faut ajouter une propriété color...ce serait bien d'avoir un parent.font aussi...pour éviter de se répéter...
    C'est déjà bien, ce que tu as fait. En tout cas moi j'ai appris pas mal de choses en lisant ton code.

    @Paul

    C'était donc ça. Merci !
    Mon site personnel consacré à MSEide+MSEgui : msegui.net

  13. #13
    Rédacteur/Modérateur

    Avatar de Roland Chastain
    Homme Profil pro
    Enseignant
    Inscrit en
    Décembre 2011
    Messages
    4 072
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Décembre 2011
    Messages : 4 072
    Points : 15 462
    Points
    15 462
    Billets dans le blog
    9
    Par défaut
    Citation Envoyé par Archimède Voir le message
    D'ailleurs, ajoute ta modif sur stringgrid dans UFlash8CL, elle est bien venue ...
    Ça marche !
    Mon site personnel consacré à MSEide+MSEgui : msegui.net

  14. #14
    Membre chevronné
    Avatar de Archimède
    Homme Profil pro
    Enseignant
    Inscrit en
    Avril 2005
    Messages
    1 644
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 58
    Localisation : France, Charente Maritime (Poitou Charente)

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2005
    Messages : 1 644
    Points : 1 975
    Points
    1 975
    Par défaut
    Citation Envoyé par Roland Chastain Voir le message
    Ça marche !
    Merci, tu peux dépoussiérer tout ce que tu veux. Moi, j'ai de l'intuition mais je suis souvent très brouillon...le contraire de toi !

    Alors avec ton organisation et ta rigueur, ça ne peut que se bonifier.

    anthony

  15. #15
    Membre chevronné
    Avatar de Archimède
    Homme Profil pro
    Enseignant
    Inscrit en
    Avril 2005
    Messages
    1 644
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 58
    Localisation : France, Charente Maritime (Poitou Charente)

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2005
    Messages : 1 644
    Points : 1 975
    Points
    1 975
    Par défaut
    Regarde Roland si tu ne peux pas encore améliorer le rendu de la grille car elle supporte mal le redimensionnement...Tu es un bon matheux.
    On est en vectoriel et ça devrait être nickel.

    ci-joint photo :
    Images attachées Images attachées  

  16. #16
    Rédacteur/Modérateur

    Avatar de Roland Chastain
    Homme Profil pro
    Enseignant
    Inscrit en
    Décembre 2011
    Messages
    4 072
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Décembre 2011
    Messages : 4 072
    Points : 15 462
    Points
    15 462
    Billets dans le blog
    9
    Par défaut
    Citation Envoyé par Archimède Voir le message
    Regarde Roland si tu ne peux pas encore améliorer le rendu de la grille car elle supporte mal le redimensionnement...
    Oui, j'ai remarqué ce défaut (quand j'ai exécuté l'animation dans mon navigateur). La conclusion que j'en ai tiré pour le moment, c'est qu'il fallait interdire le redimensionnement.

    En fait, je doute qu'il y ait une autre solution, mais quoiqu'il en soit je vais travailler encore sur le sujet.
    Mon site personnel consacré à MSEide+MSEgui : msegui.net

  17. #17
    Membre chevronné
    Avatar de Archimède
    Homme Profil pro
    Enseignant
    Inscrit en
    Avril 2005
    Messages
    1 644
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 58
    Localisation : France, Charente Maritime (Poitou Charente)

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2005
    Messages : 1 644
    Points : 1 975
    Points
    1 975
    Par défaut
    Je ne me souviens plus très bien, mais il me semble que j'avais volontairement placé des petits écarts entre chaque cellule pour éviter ce désagrément...

    je n'ai pas regardé de près ton code mais je présume que tu as fait ce qu'il fallait...

    a+


  18. #18
    Expert éminent sénior
    Avatar de Paul TOTH
    Homme Profil pro
    Freelance
    Inscrit en
    Novembre 2002
    Messages
    8 964
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 54
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Freelance
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2002
    Messages : 8 964
    Points : 28 430
    Points
    28 430
    Par défaut
    j'ai tenté une autre approche mais pas mieux...j'avais déjà vu avec la FlashCL qu'il était difficile d'avoir un résultat au pixel près

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
     
    procedure TStringGrid.Init(colcnt, rowcnt, width, height: integer);
    var
      i, j: integer;
      w, h: Number;
    begin
      colcount := colcnt;
      rowcount := rowcnt;
     
      w := Trunc(width / colcount);
      h := Trunc(height / rowcount);
     
      opaqueBackground := LightSteelBlue;
     
      for i := 0 to colcount-1 do
        for j := 0 to rowcount-1 do
        begin
          cells[i,j] := TCell.Create(self);
          cells[i,j].background := true;
          cells[i,j].backgroundColor := white;
          cells[i,j].width := w - 1;
          cells[i,j].height := h - 1;
     
          cells[i,j].left := 1 + i * w;
          cells[i,j].top := 1 + j * h;
          cells[i,j].text := '';
        end;
    end;
    Developpez.com: Mes articles, forum FlashPascal
    Entreprise: Execute SARL
    Le Store Excute Store

  19. #19
    Membre chevronné
    Avatar de Archimède
    Homme Profil pro
    Enseignant
    Inscrit en
    Avril 2005
    Messages
    1 644
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 58
    Localisation : France, Charente Maritime (Poitou Charente)

    Informations professionnelles :
    Activité : Enseignant
    Secteur : Enseignement

    Informations forums :
    Inscription : Avril 2005
    Messages : 1 644
    Points : 1 975
    Points
    1 975
    Par défaut
    Effet, ce n'est pas mieux...On est condamné aux espaces..

  20. #20
    Rédacteur/Modérateur

    Avatar de Roland Chastain
    Homme Profil pro
    Enseignant
    Inscrit en
    Décembre 2011
    Messages
    4 072
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 50
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activité : Enseignant

    Informations forums :
    Inscription : Décembre 2011
    Messages : 4 072
    Points : 15 462
    Points
    15 462
    Billets dans le blog
    9
    Par défaut
    Citation Envoyé par Archimède Voir le message
    Je ne me souviens plus très bien, mais il me semble que j'avais volontairement placé des petits écarts entre chaque cellule pour éviter ce désagrément...
    Effectivement c'est aussi une solution.

    Voici la version corrigée de mon animation, en mode "no scale" et insérée dans une page HTML. Personnellement, ça me plaît comme ça. La page HTML se redimensionne, mais l'objet SWF ne bouge pas. Sécurité absolue !

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
     
    {$FRAME_WIDTH 420}
    {$FRAME_HEIGHT 594}
     
    program CompareFormules;
     
    { Essai du type TStringGrid de l'unité UFlash8CL.
     
      Un commerçant propose deux formules promotionnelles :
      1° un article acheté, le second à moitié prix ;
      2° deux articles achetés, le troisième offert.
      
      On cherche à savoir quelle est la formule la plus avantageuse pour tel nombre
      d'articles. }
     
    uses
      Flash8,
      //UFlash8CL,
      UFlash8CLExtract;
     
    var
      Grid1: TStringGrid;
     
    { -- Exercice ---------------------------------------------------------------- }
     
    type
      tFormule = record
                   a: integer; // acheté
                   p: number;  // payé
                 end;
     
    var
      F1: tFormule;
      F2: tFormule;
     
    function Comparaison(n1, n2: number): string;
    begin
      if n1 = n2 then
        Result := '='
      else
        if n1 > n2 then
          Result := 'F1'
        else
          Result := 'F2';
    end;
     
    procedure Calcul;
    var
      i: integer;
      p1, p2: number;
    begin
      for i := 1 to 20 do
      begin
        p1 := F1.p * (i div F1.a) + i mod F1.a;
        p2 := F2.p * (i div F2.a) + i mod F2.a;
        Grid1.cells[0, i].texte := IntToStr(i);
        Grid1.cells[1, i].texte := FloatToStr(p1);
        Grid1.cells[2, i].texte := FloatToStr(p2);
        Grid1.cells[3, i].texte := Comparaison(p1, p2);
      end;
    end;
     
    { -- Fin exercice ------------------------------------------------------------ }
     
    begin
      Grid1 := TStringGrid.Create(_root);
     
      with Grid1 do
      begin
        left := 10; top := 10;
        Init(4, 21, 400, 574); // nb de colonnes, nb de lignes, largeur, hauteur
        Font('Courier', 18, FALSE, FALSE, 'center'); // name, size, bold, italic, align
     
        cells[0, 0].texte := 'A';  // acheté
        cells[1, 0].texte := 'F1'; // payé formule 1
        cells[2, 0].texte := 'F2'; // payé formule 2
        cells[3, 0].texte := 'M';  // meilleur prix
      end;
     
      F1.a := 2;
      F1.p := 1 + 1/2;
      F2.a := 3;
      F2.p := 2.0;
     
      Calcul;
     
      stage.scaleMode := 'noScale';
    end.
    Fichiers attachés Fichiers attachés
    Mon site personnel consacré à MSEide+MSEgui : msegui.net

+ Répondre à la discussion
Cette discussion est résolue.
Page 1 sur 2 12 DernièreDernière

Discussions similaires

  1. Limitation de taille avec XMLTYPE
    Par lilas14 dans le forum SQL
    Réponses: 9
    Dernier message: 24/03/2014, 15h26
  2. Réponses: 4
    Dernier message: 18/12/2006, 21h43
  3. Limite de contour avec la souris
    Par MarKo04 dans le forum Delphi
    Réponses: 6
    Dernier message: 23/08/2006, 12h21
  4. LIMIT calcul mal avec des JOIN
    Par FMaz dans le forum Requêtes
    Réponses: 21
    Dernier message: 12/07/2006, 03h37
  5. Simulation de la fonction LIMIT de MySQL avec SQL Server
    Par Le Pharaon dans le forum MS SQL Server
    Réponses: 6
    Dernier message: 15/11/2005, 10h43

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo