Created
November 13, 2009 08:58
-
-
Save DasLampe/233689 to your computer and use it in GitHub Desktop.
Informatikunterricht - Sieben Segment Anzeige
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unit cFlexPanel; | |
interface | |
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, | |
Dialogs, ExtCtrls, StdCtrls; | |
type | |
TFlexPanel = class(TPanel) | |
private | |
public | |
constructor create(AOwner: TComponent; col: TColor; xpos, ypos, xx, yy:integer); virtual; | |
end; | |
implementation | |
constructor TFlexPanel.create(AOwner: TComponent; col: TColor; xpos,ypos, xx, yy: integer); | |
begin | |
inherited create(AOwner); | |
color := clyellow; | |
left := xpos; | |
top := ypos; | |
width := xx; | |
height := yy; | |
end; | |
end. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unit cSiebSeg; | |
interface | |
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, | |
Dialogs, ExtCtrls, StdCtrls, cFlexPanel; | |
type | |
TSiebSeg = class(TComponent) | |
constructor create(AOwner: TForm; x,y, xx,yy: integer); virtual; | |
private | |
main: TForm; | |
public | |
paoben, paloben, paroben, pamitte, parunten, palunten, paunten: TFlexPanel; | |
procedure setNumber(number:integer); | |
end; | |
implementation | |
constructor TSiebSeg.create(AOwner: TForm; x,y, xx, yy: integer); | |
var b,h,d: integer; | |
begin | |
inherited create(AOwner); | |
b := xx; | |
h := yy; | |
d := 20; | |
paoben := TFlexPanel.create(AOwner, clblack, x, y, b, d); | |
paoben.Parent := AOwner; | |
pamitte := TFlexPanel.create(AOwner, clblack, x, y+(h-d) div 2, b, d); | |
pamitte.Parent := AOwner; | |
paunten := TFlexPanel.create(AOwner, clblack, x, y+h-d, b, d); | |
paunten.Parent := AOwner; | |
paloben := TFlexPanel.create(AOwner, clblack, x, y, d, (h+d) div 2); | |
paloben.Parent := AOwner; | |
palunten := TFlexPanel.create(AOwner, clblack, x, y+(h-d) div 2, d, (h+d) div 2); | |
palunten.Parent := AOwner; | |
paroben := TFlexPanel.create(AOwner, clblack, x+b-d, y, d, (h+d) div 2); | |
paroben.Parent := AOwner; | |
parunten := TFlexPanel.create(AOwner, clblack, x+b-d, y+(h-d) div 2, d, (h+d) div 2); | |
parunten.Parent := AOwner; | |
end; | |
procedure TSiebSeg.setNumber(number: integer); | |
begin | |
case number of | |
0: | |
begin | |
paoben.visible := true; | |
pamitte.visible := false; | |
paunten.visible := true; | |
paloben.visible := true; | |
paroben.visible := true; | |
palunten.visible := true; | |
parunten.visible :=true; | |
end; | |
1: | |
begin | |
paoben.visible := false; | |
pamitte.visible := false; | |
paunten.visible := false; | |
paloben.visible := false; | |
paroben.visible := true; | |
palunten.visible := false; | |
parunten.visible := true; | |
end; | |
2: | |
begin | |
paoben.visible := true; | |
pamitte.visible := true; | |
paunten.visible := true; | |
paloben.visible := false; | |
paroben.visible := true; | |
palunten.visible := true; | |
parunten.visible := false; | |
end; | |
3: | |
begin | |
paoben.visible := true; | |
pamitte.visible := true; | |
paunten.visible := true; | |
paloben.visible := false; | |
paroben.visible := true; | |
palunten.visible := false; | |
parunten.visible := true; | |
end; | |
4: | |
begin | |
paoben.visible := false; | |
pamitte.visible := true; | |
paunten.visible := false; | |
paloben.visible := true; | |
paroben.visible := true; | |
palunten.visible := false; | |
parunten.visible := true; | |
end; | |
5: | |
begin | |
paoben.visible := true; | |
pamitte.visible := true; | |
paunten.visible := true; | |
paloben.visible := true; | |
paroben.visible := false; | |
palunten.visible := false; | |
parunten.visible := true; | |
end; | |
6: | |
begin | |
paoben.visible := true; | |
pamitte.visible := true; | |
paunten.visible := true; | |
paloben.visible := true; | |
paroben.visible := false; | |
palunten.visible := true; | |
parunten.visible := true; | |
end; | |
7: | |
begin | |
paoben.visible := true; | |
pamitte.visible := false; | |
paunten.visible := false; | |
paloben.visible := false; | |
paroben.visible := true; | |
palunten.visible := false; | |
parunten.visible := true; | |
end; | |
8: | |
begin | |
paoben.visible := true; | |
pamitte.visible := true; | |
paunten.visible := true; | |
paloben.visible := true; | |
paroben.visible := true; | |
palunten.visible := true; | |
parunten.visible := true; | |
end; | |
9: | |
begin | |
paoben.visible := true; | |
pamitte.visible := true; | |
paunten.visible := true; | |
paloben.visible := true; | |
paroben.visible := true; | |
palunten.visible := false; | |
parunten.visible := true; | |
end; | |
end; | |
end; | |
end. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unit sibseg; | |
interface | |
uses | |
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, | |
Dialogs, ExtCtrls, StdCtrls, cSiebSeg; | |
type | |
Tmain = class(TForm) | |
procedure FormCreate(Sender: TObject); | |
private | |
{ Private-Deklarationen } | |
public | |
{ Public-Deklarationen } | |
//FlexPanel: TFlexPanel; | |
// | |
hunderter, zehner, einer: TSiebSeg; | |
end; | |
var | |
main: Tmain; | |
implementation | |
{$R *.dfm} | |
procedure Tmain.FormCreate(Sender: TObject); | |
begin | |
Randomize; | |
hunderter := TSiebSeg.create(main, 100,100,110,150); | |
hunderter.setNumber(random(9)); | |
zehner := TSiebSeg.create(main, 230, 100, 110,150); | |
zehner.setNumber(random(9)); | |
einer := TSiebSeg.create(main, 350, 100, 110, 150); | |
einer.setNumber(random(9)); | |
end; | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment