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 :

Correction constructeur nickel


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 Correction constructeur nickel
    Je confirme avec beaucoup de retard que les modifs apportées sont parfaitement opérationnelles

    font.style nickel aussi...
    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
     
    unit UFont;
     
    interface
     
    uses Flash8;
     
    type
       TFontStyle =(fsBold,fsItalic,fsUnderline);//nickel
       TStyle = set of TFontStyle;    //nickel
     
     TFont=class
       private
        FStyle:TStyle;
        procedure SetName(value:string);
        procedure SetSize(value:number);
        procedure Setcolor(value:number);
        procedure SetStyle(value:TStyle);
        procedure SetBold(value:boolean);
        procedure SetItalic(value:boolean);
        procedure SetUnderline(value:boolean);
        procedure SetBullet(value:boolean);
        procedure Setalign(value:String);
       public
        FTextformat:TextFormat;
        constructor Create;
        property name:string read FTextFormat write SetName;
        property size:number read  FTextFormat write SetSize;
        property style:Tstyle read  FStyle write SetStyle;
        property Bold:Boolean read  FTextFormat write SetBold;
        property Italic:Boolean read  FTextFormat write SetItalic;
        property Underline:Boolean read FTextFormat write SetUnderline;
        property Color:number read  FTextFormat write Setcolor;
        property Align:String read  FTextFormat write SetAlign;
        property Bullet:boolean read  FTextFormat write SetBullet;  //point equivalent à un tiret
     end;
     
    implementation
     
    Constructor TFont.Create;
    begin
     FTextFormat:=TextFormat.Create('MS Sans Serif',8,0,false,false,false);
    end;
     
    procedure TFont.SetName(value:string);
    begin
     FTextFormat.font:=value;
    end;
     
    procedure TFont.Setsize(value:number);
    begin
      FTextFormat.size:=value;
    end;
     
    procedure TFont.SetStyle(value:TStyle);
    begin
     if [fsBold]*value=[fsBold] then FTextFormat.bold:=true;
     if [fsItalic]*value=[fsItalic] then FTextFormat.italic:=true;
     if [fsUnderline]*value=[fsUnderline] then FTextFormat.underline:=true;
    end;
     
    procedure TFont.SetBold(value:boolean);
    begin
     FTextFormat.bold:=value;
    end;
     
    procedure TFont.SetItalic(value:boolean);
    begin
     FTextFormat.italic:=value;
    end;
     
    procedure TFont.SetUnderline(value:boolean);
    begin
     FTextFormat.underline:=value;
    end;
     
    procedure TFont.Setcolor(value:number);
    begin
       FTextFormat.color:=value;
    end;
     
    procedure TFont.Setalign(value:String);
    begin
     FTextFormat.align:=value;
    end;
     
    procedure TFont.SetBullet(value:boolean);
    begin
     FTextFormat.Bullet:=value;
    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
    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
     
    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)//nickel!!!
      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)
     private
      autorisation:boolean;
     public
        xmin,xmax:number;
        orientation:string;
        xmouse,ymouse,trackmin,trackmax:number;
        xcur,ycur:Integer;
        downcur:Boolean;
        Procedure dessin;
        constructor Create(AOWNER:Movieclip;trmin,trmax:number);
        procedure onPress;override;
        procedure onMouseMove;override;
        procedure onMouseUp;override;
        procedure onRollOver;override;
        procedure onRollOut;override;
      end;
     
     TTrackBar=Class(movieClip)
     private
      w,h:integer;
      position:number;
      cur: TTrackcur;
      function GetLeft:number;
      function Gettop:number;
      function Getwidth:number;
      function Getheight:number;
      function Getcolor:number;
      procedure Setleft(value:number);
      procedure SetTop(value:number);
      procedure SetWidth(value:number);
      procedure SetHeight(value:number);
      procedure Setcolor(value:number);
     
     public
      constructor Create(parent:movieclip);
      procedure onChange;virtual;
      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 color:number read GetColor write SetColor;
     end; }
     
    //function arrondi(n:number):integer;
     
    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**    un commencement...  en construction événement onMouseWheel.....
    ************  // essai pour l'instant
     
    constructor TTrackbar.Create(parent:movieclip);
    begin
     inherited Create(parent,'Trackbar',movieclip(parent).getNextHighestDepth());
     w:=100;
     h:=20;
     left:=10;
     top:=10;
     color:=clred;
     lineto(w,0);
     lineto(w,h);
     lineto(0,h);
     beginFill($C0C0C0);
     moveto(w/15,h/4);
     lineto(w-w/15,h/4);
     lineto(w-w/15,h/4+2);
     lineto(w/15,h/4+2);
     lineto(w/15,h/4);
     
     cur:=TTrackcur.Create(self,0,100);
     with cur do
     begin
      _x:=w/15;
      _y:=h/4;
     end;
    end;
     
    procedure TTrackbar.Setleft(value:number);
    begin
      _x:=value;
    end;
     
    procedure TTrackbar.SetTop(value:number);
    begin
     _y:=value;
    end;
     
    procedure TTrackbar.SetWidth(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
     opaqueBackground:=value;
    end;
     
    procedure TTrackbar.onChange;
    begin
    end;
     
    Function TTrackbar.Getcolor:number;
    begin
     result:=opaqueBackground;
    end;
     
    Function  TTrackbar.GetWidth: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
    if  autorisation then
    begin
         tr:= TTrackbar(_parent);
     
         if downcur then
         if orientation='horizontal' 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
         else if orientation='vertical' then  //non réalisé
         begin
          _y:= _y +_ymouse -ymouse;
     
         end;
         tr.onChange;
    end;
    end;
     
     
     
    procedure  TTrackcur.onMouseUp;
    begin
     downcur:=false;
    end;
     
    procedure TTrackcur.onRollOver;
    begin
     autorisation:=true;
    end;
     
    procedure TTrackcur.onRollOut;
    begin
     autorisation:=false;
    end;
     
    constructor TTrackcur.create(AOWNER:Movieclip;trmin,trmax:number);
     var matrix: Flash8.Matrix;
    begin
      inherited Create(AOWNER,'cur',AOWNER.getNextHighestDepth);
      autorisation:=false;
      downcur:=false;
      xmouse:=0;
      ymouse:=0;
      matrix := Flash8.Matrix.Create();
      matrix.createBox(1,1,0,10,14);
      linestyle(1,$87B6B7);
      beginGradientFill('linear',[$008080,clwhite],[100,100],[0,14],matrix);
      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;
     
    Procedure TTrackcur.dessin;
    begin
     
    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
     
    program Project1;
     
    {$FRAME_WIDTH 700}
    {$FRAME_HEIGHT 600}
    {$FRAME_RATE 12}
    {$BACKGROUND $FFFFFF}
     
    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;
     
     TStringgrid1=class(TStringgrid)
      procedure onChange;override;
     end;
     
     
    var
     Button1: TButton1;
     Button2: TButton2;
     Label:TLabel;
     Edit1:TEdit1;
     grid:TStringGrid1;
     i,j:integer;
     
     
    procedure TButton1.onClick;
    begin
     label.caption:=grid.cells[1,2].texte;
    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];  //nickel !!!
      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;
     
    end.
    bravo et merci !

  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
    merci

    petite remarque tout de même, sous Delphi un "Set Of" accepte jusque 256 éléments, FlashPascal utilisant un entier doit en supporter 31 seulement (le 32ième bit étant utilisé pour le signe)
    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
    Citation Envoyé par Paul TOTH Voir le message
    sous Delphi un "Set Of" accepte jusque 256 éléments, FlashPascal utilisant un entier doit en supporter 31 seulement (le 32ième bit étant utilisé pour le signe)
    merci pour l'info... mais pourquoi chaque élément est codé sur 5 bits en flash et 8 bits en delphi... ? Curieux...

  4. #4
    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
    Citation Envoyé par Archimède Voir le message
    merci pour l'info... mais pourquoi chaque élément est codé sur 5 bits en flash et 8 bits en delphi... ? Curieux...
    non, 256 éléments ça fait 256 bits, un bit par élément Delphi utilise un array of byte de taille suffisante pour stocker les éléments, FlashPascal utilise juste un entier 32 bits.
    Developpez.com: Mes articles, forum FlashPascal
    Entreprise: Execute SARL
    Le Store Excute Store

  5. #5
    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
    non, 256 éléments ça fait 256 bits, un bit par élément Delphi utilise un array of byte de taille suffisante pour stocker les éléments, FlashPascal utilise juste un entier 32 bits.
    Ce n'est pas clair dans ma tête... un bit a deux états (0 et 1)...Donc si on parle d'un bit, on a deux possibiltés..
    256 = 2^8 soit un element sur 8 bits (ce qui fait 256 possibilités)
    32=2^5 soit un élément sur 5 bits voilà mon raisonnement au premier abord...

  6. #6
    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
    Citation Envoyé par Archimède Voir le message
    Ce n'est pas clair dans ma tête... un bit a deux états (0 et 1)...Donc si on parle d'un bit, on a deux possibiltés..
    256 = 2^8 soit un element sur 8 bits (ce qui fait 256 possibilités)
    32=2^5 soit un élément sur 5 bits voilà mon raisonnement au premier abord...
    oui mais, j'ai l'élément 1 = bit 0, l'élément 2 = bit 1, ... l'élément 256 = bit 255

    2^8 = 256 indique que le 9ième élément à pour valeur 256

    en binaire 111 = élement 1 + élément 2 + élément 3 = 1 + 2 + 4 = 7
    en binaire 100000000 = élément 9 tout seul = 256

    si je veux 256 éléments, il me faut 256 bits = 2^256 = beaucoup

    il ne faut pas confondre Ord(Element) et [Element], le premier est le numéro du bit, le second c'est "1 shl numéro_du_bit"
    Developpez.com: Mes articles, forum FlashPascal
    Entreprise: Execute SARL
    Le Store Excute Store

  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
    Citation Envoyé par Paul TOTH Voir le message
    oui mais, j'ai l'élément 1 = bit 0, l'élément 2 = bit 1, ... l'élément 256 = bit 255

    2^8 = 256 indique que le 9ième élément à pour valeur 256

    en binaire 111 = élement 1 + élément 2 + élément 3 = 1 + 2 + 4 = 7
    en binaire 100000000 = élément 9 tout seul = 256

    si je veux 256 éléments, il me faut 256 bits = 2^256 = beaucoup

    il ne faut pas confondre Ord(Element) et [Element], le premier est le numéro du bit, le second c'est "1 shl numéro_du_bit"
    Je pense avoir compris...
    En fait, dans un type énuméré, le numéro de l' élément correspond au poids du bit correspondant.

    merci

Discussions similaires

  1. Réponses: 13
    Dernier message: 09/01/2011, 23h33
  2. Réponses: 15
    Dernier message: 23/06/2006, 13h57
  3. pb constructeurs classes dérivant classe abstraite
    Par Cornell dans le forum Langage
    Réponses: 2
    Dernier message: 10/02/2003, 19h02

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