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

Contribuez Pascal Discussion :

Source d'une scrollbar


Sujet :

Contribuez 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 Source d'une scrollbar
    Ci-joint une scrollbar pour me refaire la main en flashpascal...

    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
     
    unit UScrollbar;
     
    interface
     
    uses Flash8;
     
      const  bgColorup = $F0F0F0;
    	const bgColorsurvol = $D6EEFB;
      const bgColordown= $42A1D4;
     
     
    type
     TState =(normal,survol,click);
               {  *********************
                  ***  ScrollButton  **
                  ********************* }
     
     TScrollButton=Class(movieclip)
      private
       etat:TState;
       tail:number;
       Ffonction:String;
       procedure skin(size:number);
       procedure onPress;override;
       procedure onRelease;override;
       procedure onReleaseOutside;override;
       procedure onRollOver;override;
       procedure onRollOut;override;
       procedure onEnterFrame;override;
      public
       constructor Create(parent:movieclip;size:number);
       Property Fonction:String read Ffonction write Ffonction;
      end;
               {  *********************
                  ***   Curseur      **
                  ********************* }
     
      TCurseur=Class(movieclip)
       private
    	   procedure draw(val:integer);
     
    	 public
          Click:boolean;
          constructor Create(parent:movieclip);
          procedure onRollOver;override;
          procedure onRollOut;override;
          procedure onPress;override;
          procedure onReleaseOutside;override;
          procedure onRelease;override;
    	 end;
                {  *********************
                  ***    ScrollBar    **
                  ********************* }
     
    	 TScrollbar=Class(movieclip)
    	  private
         taille,w,ymouse:number;
         Fmin,Fmax,Fposition:integer;
         Forientation:string;
         but1,but2:TScrollButton;
         cur:TCurseur;
         procedure setPosition(value:integer);
         procedure setOrientation(value:string);
         procedure docurmove;
         procedure onMouseWheel(Delta: Number; target: Variant);
    	  public
         constructor Create(parent:movieclip;size:number);
         procedure onChange;virtual;
         property position:integer read Fposition write Setposition;
         property min:integer read FMin write FMin;
         property max:integer read FMax write FMax;
         property orientation:string read FOrientation write SetOrientation;
       end;
     
     
    implementation
     
    procedure DrawRect(x,y,w,h:number;mc:movieclip);
    begin
     with mc do
     begin
      moveto(x,y);
      lineto(x+w,y);
      lineto(x+w,y+h);
      lineto(x,y+h);
      lineto(x,y);
     end;
    end;
     
    //************************************
    //****** -|    Scrollbutton     |*****
    //************************************
     
    constructor TScrollButton.Create(parent:movieclip;size:number);
    begin
     inherited Create(parent,'ScrollButton',movieclip(parent).getNextHighestDepth());
     etat:=normal;
     tail:=size;
     skin(size);
    end;
     
    procedure TScrollButton.Skin(size:number);
    begin
     if etat=normal then beginFill(bgColorup)
     else if etat=survol then  beginFill(bgColorsurvol)
     else if etat=click then beginFill(bgColordown);
     linestyle(1,0);
     drawRect(-size/2, -size/2,size, size,self);
     endFill();
     beginFill(0);
     moveTo(0, -size/2+size/3);
     lineTo(size/2-size/3,size/2-size/3);
     lineTo(-size/2+size/3,size/2-size/3);
     lineTo(0, -size/2+size/3);
     endFill();
    end;
     
    procedure TScrollButton.onEnterFrame;
    begin
     if etat=click then
     begin
      if (Fonction = 'Add') and (TscrollBar(_parent).Position <TscrollBar(_parent).Max) then tscrollBar(_parent).Position :=TscrollBar(_parent).Position+ 1
      else if (Fonction = 'Substract') and (TscrollBar(_parent).Position >TscrollBar(_parent).Min) then TscrollBar(_parent).Position:=TscrollBar(_parent).Position- 1;
      TScrollBar(_parent).onChange();
     end else exit;
    end;
     
    procedure TScrollButton.onPress;
    begin
     etat:=click;
     clear;
     skin(tail);
    end;
     
    procedure TScrollButton.onRollOver;
    begin
     etat:=survol;
     clear();
     skin(tail);
    end;
     
    procedure TScrollButton.onRollOut;
    begin
      etat:=normal;
      clear();
      skin(tail);
    end;
     
    procedure TScrollButton.onRelease;
    begin
      etat:=survol;
      clear();
      skin(tail);
    end;
     
    procedure TScrollButton.onReleaseOutside;
    begin
       etat:=normal;
       clear();
       skin(tail);
    end;
     
     
     
    //************************************
    //****** -|    Curseur      |*********
    //************************************
     
     
     
    constructor TCurseur.Create(parent:movieclip);
    begin
     inherited Create(parent,'Curseur',movieclip(parent).getNextHighestDepth());
     draw(1);
    end;
     
    procedure TCurseur.onRollOver;
    begin
     clear();
     draw(2);
    end;
     
    procedure TCurseur.onRollOut;
    begin
     clear;
     draw(1);
    end;
     
    procedure TCurseur.draw(val:integer);
    var  M:Matrix;
    begin
     M:=Matrix.create();
     M.createGradientBox(5,40,0,0,0);
     case val of
      1:  begin
            lineStyle(1,$949494);
            beginGradientFill('linear',[$FCFCFC, $dcdcdc],[100, 100],[0,255],M);
    		    drawRect( -7, -20, 13.5, 40,self);
    		    endFill();
    		    beginFill($B1B1B1);
    		    lineStyle(1, $727171);
    		   end;
    	 2:  begin
            lineStyle(1,$949494);
            beginGradientFill('linear',[$E3F4FC,$9CCAE3],[100, 100],[0,255],M);
            drawRect( -7, -20, 13.5, 40,self);
            endFill();
            beginFill($58A2C2);
            lineStyle(1, $62A8CA)
           end;
       end;
    	 drawRect( -4, -5, 8, 2,self);
       drawRect( -4, -1, 8, 2,self);
    	 drawRect( -4, 3, 8, 2,self);
       endFill();
    end;
     
    procedure TCurseur.onPress;
    begin
     click:=true;
     TScrollbar(_parent).ymouse:=_Ymouse;
    end;
     
    procedure TCurseur.onReleaseOutside;
    begin
     draw(1);
     click:=false;
    end;
     
    procedure TCurseur.onRelease;
    begin
     click:=false;
    end;
     
     
    //************************************
    //******  |    Scrollbar    |*********
    //************************************
     
     
    constructor TScrollbar.Create(parent:movieclip;size:number);
    begin
     inherited Create(parent,'ScrollBar'+floattostr(parent.getNextHighestDepth()),parent.getNextHighestDepth());
     taille := size;
     w := taille-70;//30 ->15+15 +  40->2x20 taille 2x bouton+curseur
     lineStyle(1, $E7E7E7);
     beginFill($F0F0F0);
     drawRect( -7.5, 0, 15, taille,self);
     endFill();
     
     but1:=TScrollButton.Create(self,15);
     but2:=TScrollButton.Create(self,15);
     cur:=TCurseur.Create(self);
     but1._y := 7.5;
     but1.Fonction := 'Substract';
     
     but2._y := taille-7.5;
     but2._rotation := 180;
     but2.Fonction := 'Add';
     
     cur.onMouseMove:=docurmove;
     mouse.addlistener(self);
    end;
     
    procedure TScrollBar.docurmove;
    begin
      if cur.Click then
      begin
       cur._y:= cur._y + cur._Ymouse -ymouse;
       if cur._y<35 then cur._y:=35;
       if cur._y>taille-35 then cur._y:=taille-35;
       Position:=round((cur._y-35)*(max-min)/w+min);
       onChange();
      end;
    end;
     
    procedure TScrollBar.onMouseWheel(Delta: Number; target: Variant);
    var temppos:integer;
    begin
     if Orientation = 'vertical' then
     begin
      temppos := Position;
      if Delta > 0 then  Delta := 1 else Delta := -1;
      Position:=Position-Delta;
      if (Position >= min) and (Position <= max) then cur._y := 35 + (Position - min) * w  / (max - min) else Position := temppos;
      onChange();
      end;
    end;
     
    procedure TScrollBar.onChange;
    begin
    end;
     
     
    procedure TScrollBar.SetPosition(value:integer);
    begin
     cur._y :=35+ abs(value -min) * w / (max - min);
     Fposition := value;
    end;
     
    procedure TScrollBar.setOrientation(value:string);
    begin
     if value='horizontal'  then
     begin
      _rotation := -90;
      _y := _y +but1._height/2;
     end
     else if value= 'vertical' then _x := _x +but1._width / 2;
     FOrientation := value;
    end;
     
    end.
    et un essai :

    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
     
    program PScrollBar;
     
    {$FRAME_WIDTH 1000}
    {$FRAME_HEIGHT 500}
    {$FRAME_RATE 32}
    {$BACKGROUND 0}
    {$JPEG img 'developpez.jpg'} //1152x864
     
    uses
      Flash8,UScrollBar;
     
      Type
       TScrollBar1=Class(TScrollBar)
        procedure onChange;override;
       end;
     
      TScrollBar2=Class(TScrollBar)
       procedure onChange;override;
      end;
     
      TExemple=class(movieclip)
        container:Movieclip;
        fenetre:movieclip;
        scroll1,scroll2:TscrollBar1;
        im: BitmapData;
        constructor Create(parent:movieclip);
      end;
     
     
     constructor TExemple.Create(parent:movieclip);
     var Mat:Matrix;
     begin
       inherited Create(parent,'developpez',0);
       Mat:=Matrix.Create();
       Mat.createBox(1, 1, 0, -1152/2, - 864 / 2);
     
       container:=movieclip.Create(self,'container',0);
       fenetre:=movieclip.Create(self,'fenetre',1);
       im:=BitmapData.create(1152,864);
       im:= loadBitmap('img');
     
       with container do
       begin
        _x:=stage.width/2;
        _y:=stage.height/2;
        beginBitmapFill(im,Mat);
        uScrollBar.drawRect( - 1152/2, - 864 / 2, 1152, 864,container);
        endFill();
       end;
     
       with fenetre do
       begin
        _x:=container._x-576/2;
        _y:=container._y-432/2;
         beginFill(0);
         UScrollBar.DrawRect(0,0,576+15,432+15,fenetre);
       end;
     
       setMask(fenetre);
     
       scroll1:=TScrollBar1.Create(self,432);
       with scroll1 do
       begin
        _x:=stage.width/2+576/2;
        _y:=stage.height/2-432/2;
        Orientation := 'vertical';
        Min := -216;
        Max := 216;
        Position :=0;
       end;
     
      scroll2:=TScrollBar2.Create(self,576+15); //15 epaisseur de la scrollbar
      with scroll2 do
      begin
       _x:=stage.width/2-576/2;
       _y:=stage.height/2+432/2;
       Orientation := 'horizontal';
       Min := -288;
       Max := 288;
       Position :=0;
      end;
     
     end;
     
     
     
      procedure TScrollBar1.onChange;
      begin
        TExemple(_parent).container._y:=stage.height/2+position;
      end;
     
      procedure TScrollBar2.onChange;
      begin
         TExemple(_parent).container._x:=stage.width/2+position;
      end;
     
    begin
      TExemple.Create(_Root);
    end.
    ça manquait dans les outils...

    J'en ai fait une version as3... si flashpascal3 voit le jour, il y aura la possibilité de l'adapter facilement.

    anthony
    Images attachées Images attachées  
    Fichiers attachés Fichiers attachés

Discussions similaires

  1. [Juridique] Comment réutiliser le code source d'une classe ?
    Par mathieu dans le forum Général Java
    Réponses: 8
    Dernier message: 17/05/2004, 13h40
  2. Source attachée à une classe
    Par Lyr7in3 dans le forum Eclipse Java
    Réponses: 3
    Dernier message: 12/05/2004, 14h44
  3. [JScrollPane]Comment savoir quand une scrollbar apparait ?
    Par FrigoAcide dans le forum Composants
    Réponses: 4
    Dernier message: 29/04/2004, 10h10
  4. [VB6] Source D'une erreur
    Par krest dans le forum VB 6 et antérieur
    Réponses: 6
    Dernier message: 16/07/2003, 17h33
  5. Recuperation du source d'une page - envoi de param
    Par ulysse66x dans le forum Web & réseau
    Réponses: 3
    Dernier message: 15/06/2003, 17h31

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