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 :

Héritage : Tlabel vers TEdit, les propriétés héritées sont reconnues mais non effectives


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 Héritage : Tlabel vers TEdit, les propriétés héritées sont reconnues mais non effectives
    Je ne comprends pas qu'en faisant dériver un Tlabel pour obtenir un TEdit, les propriétés héritées sont reconnues mais non effectives...
    ci-joint et rien ne s'affiche

    je rappelle UFont :
    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);  le type énuméré ne fonctionne pas.
    // TStyle = set of TFontStyle;
     
     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.
    ULabel complétée UFlashVCL pour la renommer :

    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
     
    unit UFlashVCL;
     
    interface
     
    uses Flash8,UFont;
     
    type
     TLabel=Class
      Private
       FBorder,FwordWrap,Fautosize,FBackground,FBackgroundcolor,Fmultiline,first:Boolean;
       FLeft,FTop,FWidth,FHeight,FBordercolor,Frotation:number;
       FCaption:string;
       FTextfield:TextField;
       procedure SetLeft(value:number);
       procedure SetTop(value:number);
       procedure SetWidth(value:number);
       procedure SetHeight(value:number);
       procedure SetBorder(value:boolean);
       procedure SetborderColor(value: Number);
       procedure SetwordWrap(value:boolean);
       procedure SetAutosize(value:boolean);
       procedure SetBackground(value:Boolean);
       procedure SetBackgroundColor(value:number);
       procedure Setmultiline(value: Boolean);
       procedure Setrotation(value: Number);
       procedure SetCaption(value:string);
      Public
       Font:Tfont;
       constructor Create(parent:movieclip);
       property Left:number read FLeft write SetLeft;
       property Top:number read FTop write SetTop;
       property width:number read FWidth write SetWidth;
       property height:number read FHeight write SetHeight;
       property Border:Boolean read FBorder write SetBorder;
       property BorderColor:number read FBordercolor write SetBordercolor;
       property wordWrap:boolean read FwordWrap write SetwordWrap;
       property autosize:boolean read Fautosize write Setautosize;
       property Background:boolean read FBackground write SetBackground;
       property Backgroundcolor:number read FBackgroundcolor write SetBackgroundcolor;
       property multiline:boolean read Fmultiline write Setmultiline;
       property rotation:number read Frotation write Setrotation;
       property caption:string read FCaption write setCaption;
    end;
     
    {*********
    **Edit****
    **********}
     
     TEdit=class(TLabel)
      private
       FText:String;
       procedure SetText(value:string);
       procedure onKeyDown;
      public
       constructor Create(parent:movieclip);
       procedure onChange;virtual;
       property text:string read Ftext write settext;
     end;
     
     
    implementation
     
    Constructor TLabel.Create(parent:movieclip);
    begin
     FTextfield:=TextField.Create(Parent,'',parent.getNextHighestDepth(),0,0,100,100);
     Font:=TFont.Create;
     first:=true;
    end;
     
    procedure TLabel.Setleft(value:number);
    begin
       FTextfield._x:=value;
    end;
     
    procedure TLabel.SetTop(value:number);
    begin
       FTextfield._y:=value;
    end;
     
    procedure TLabel.SetWidth(value:number);
    begin
       FTextfield._width:=value;
    end;
     
    procedure TLabel.SetHeight(value:number);
    begin
       FTextfield._height:=value;
    end;
     
    procedure TLabel.SetBorder(value:boolean);
    begin
       FTextfield.border:=value;
    end;
     
    procedure TLabel.SetBordercolor(value:number);
    begin
       FTextfield.bordercolor:=value;
    end;
     
    procedure TLabel.SetwordWrap(value:Boolean);
    begin
     FTextfield.wordWrap:=value;
    end;
     
    procedure TLabel.Setautosize(value:boolean);
    begin
     if value then FTextfield.autosize:='center';
    end;
     
    procedure TLabel.SetBackground(value:Boolean);
    begin
     FTextfield.background:=value;
    end;
     
    procedure TLabel.SetBackgroundcolor(value:number);
    begin
     FTextfield.backgroundcolor:=value;
    end;
     
    procedure TLabel.Setmultiline(value:Boolean);
    begin
     FTextfield.multiline:=value;
    end;
     
    procedure TLabel.Setrotation(value:number);
    begin
     FTextfield._rotation:=value;
    end;
     
     
    procedure TLabel.SetCaption(value:string);
    begin
     if first then
     begin
      FTextfield.setNewTextFormat(Font.FTextFormat);
      first:=false;
     end;
     FTextfield.text:=value;
    end;
     
    {*********
    **Edit****
    **********}
     
    Constructor TEdit.Create(parent:movieclip);
    begin
     inherited Create(parent);
     FTextfield.type:='input';
     Key.Addlistener(self);
    end;
     
    procedure TEdit.SetText(value:string);
    begin
     if first then
     begin
      FTextfield.setNewTextFormat(Font.FTextFormat);
      first:=false;
     end;
     FTextfield.text:=value;
    end;
     
    procedure TEdit.onKeyDown;
    begin
     onChange;
    end;
     
    Procedure TEdit.onChange;
    begin
    end;
     
     
    end.
    la tentative de création d'instance :

    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
     
    program Project1;
     
    {$FRAME_WIDTH 550}
    {$FRAME_HEIGHT 400}
    {$FRAME_RATE 12}
    {$BACKGROUND $FFFFFF}
     
     
     
    uses
      Flash8,UFlashVCL;
     
    Type
     TEdit1=class(Tedit)
        procedure onChange;override;
      end;
     
    var
        Edit1:TEdit1;
     
     
    procedure TEdit1.onChange;
    begin
    end;
     
    begin
     
     Edit1:=TEdit1.create(_root);
     with Edit1 do
     begin
      border:=true;
      font.name:='arial';
      font.size:=40;
      font.color:=clblue;
      left:=150;
      top:=10;
      width:=200;
      height:=50;
     end;
     
    end.
    Les units sont Ok mais c'est comme si les property étaient transparentes...

  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 445
    Points
    28 445
    Par défaut
    oups, en effet il y a un bug

    mais je suis en train de voir qu'il va être difficile de faire ce genre de choses:

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    constructor TMonObject.Create;
    begin
      FChamp := Valeur;
      inherited Create(Param);
    end;
    en effet, sous Delphi, l'allocation de l'objet se fait par InitInstance, le constructor est invoqué après coup, le champ FChamp existe donc déjà.

    actuellement FlashPacal crée l'objet directement via le constructor, donc "Self" n'existe qu'après l'appel au constructor hérité.

    il va falloir que je modifie tout cela, le constructor sera alors une simple méthode invoquée pour initialiser un objet déjà créé.

    NB: le problème ne se pose pas sur une classe héritée d'une classe externe car dans ce cas l'inherited est rendu obligatoire en première instruction...ce qui ne serait plus forcément le cas d'ailleurs à la réflexion...

    je vais repenser tout cela
    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
    Ok, je me doutais bien du problème, mais je voulais ta confirmation...
    a+

    anthony

Discussions similaires

  1. Réponses: 7
    Dernier message: 24/03/2015, 11h53
  2. Réponses: 2
    Dernier message: 22/10/2008, 23h44
  3. Les propriétés personnalisés ne sont pas indexées
    Par rafikfareh dans le forum SharePoint
    Réponses: 1
    Dernier message: 30/06/2008, 19h55
  4. Réponses: 19
    Dernier message: 29/05/2007, 16h21
  5. [héritage] Redonner les propriétés de l'ancêtre
    Par Manopower dans le forum EDI
    Réponses: 5
    Dernier message: 23/08/2005, 14h08

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