home *** CD-ROM | disk | FTP | other *** search
- $PBExportHeader$tictactoe_gui.srw
- $PBExportComments$Generated by ObjectTeam
- forward
- global type tictactoe_gui from window
- end type
- type cellbutton1 from commandbutton within tictactoe_gui
- end type
- type cellbutton2 from commandbutton within tictactoe_gui
- end type
- type cellbutton3 from commandbutton within tictactoe_gui
- end type
- type cellbutton4 from commandbutton within tictactoe_gui
- end type
- type cellbutton5 from commandbutton within tictactoe_gui
- end type
- type cellbutton6 from commandbutton within tictactoe_gui
- end type
- type cellbutton7 from commandbutton within tictactoe_gui
- end type
- type cellbutton8 from commandbutton within tictactoe_gui
- end type
- type cellbutton9 from commandbutton within tictactoe_gui
- end type
- type result from statictext within tictactoe_gui
- end type
- type board from groupbox within tictactoe_gui
- end type
- end forward
-
- shared variables
- // User defined attributes
-
- // Non modeled user defined attributes
-
- end variables
-
- global type tictactoe_gui from window
- WindowType WindowType = main!
- string MenuName = "TicTacToe_MainMenu"
- int X = 1
- int Y = 1
- int Width = 1098
- int Height = 1241
- boolean TitleBar = true
- string Title = "Tic Tac Toe"
- long BackColor = 0
- boolean ControlMenu = true
- boolean MinBox = true
- boolean ToolBarVisible = false
- string Icon = ".\TicTacToe.ico"
- cellbutton1 cellbutton1
- cellbutton2 cellbutton2
- cellbutton3 cellbutton3
- cellbutton4 cellbutton4
- cellbutton5 cellbutton5
- cellbutton6 cellbutton6
- cellbutton7 cellbutton7
- cellbutton8 cellbutton8
- cellbutton9 cellbutton9
- result result
- board board
- end type
- global tictactoe_gui tictactoe_gui
-
- type variables
- // User defined attributes
-
- // Association attributes
- public tictactoe_computer computer
- public tictactoe_game game
- private classdict cellButtonDict
-
- // Non modeled user defined attributes
-
- // Control to class mappings
- // tictactoe_gui --> TicTacToe_GUI
- // cellbutton1 --> TicTacToe_CellButton
- // cellbutton2 --> TicTacToe_CellButton
- // cellbutton3 --> TicTacToe_CellButton
- // cellbutton4 --> TicTacToe_CellButton
- // cellbutton5 --> TicTacToe_CellButton
- // cellbutton6 --> TicTacToe_CellButton
- // cellbutton7 --> TicTacToe_CellButton
- // cellbutton8 --> TicTacToe_CellButton
- // cellbutton9 --> TicTacToe_CellButton
- // result --> TicTacToe_Result
- // board --> TicTacToe_Board
- end variables
-
- forward prototypes
- public subroutine disableBoard ()
- public subroutine enableBoard ()
- public subroutine clearBoard ()
- public subroutine displayResult (string text)
- public subroutine cellButtonClick (integer index)
- public subroutine removeComputer ()
- public subroutine setComputer (tictactoe_computer newComputer)
- public function tictactoe_computer getComputer ()
- public subroutine removeGame ()
- public subroutine setGame (tictactoe_game newGame)
- public function tictactoe_game getGame ()
- public function commandbutton getCellButton (integer index)
- public subroutine setCellButton (integer index, commandbutton newCellButton)
- public subroutine removeCellButton (integer index)
- end prototypes
-
- public subroutine disableBoard ();// disables all cells of board
- integer i
- commandbutton cb
- FOR i = 1 TO 9
- cb = getCellButton(i)
- cb.Enabled = False
- NEXT
- end subroutine
-
- public subroutine enableBoard ();// enables all cells of board
- integer i
- commandbutton cb
- FOR i = 1 TO 9
- cb = getCellButton(i)
- cb.Enabled = True
- NEXT
- end subroutine
-
- public subroutine clearBoard ();// clears all cells of board
- integer i
- commandbutton cb
- FOR i = 1 TO 9
- cb = getCellButton(i)
- cb.Text = ' '
- NEXT
- end subroutine
-
- public subroutine displayResult (string text);// sets result
- result.Text = text
- end subroutine
-
- public subroutine cellButtonClick (integer index);commandbutton cb
- cb = getCellButton(index)
-
- IF cb.Enabled THEN
- cb.Enabled = False
- cb.Text = game.getActivePlayer()
- game.selectCell(index)
- computer.checkTurn();
- END IF
- end subroutine
-
- public subroutine removeComputer ();// Association accessor method
- if not isNull(computer) then
- setNull(computer.gui)
- end if
- setNull(computer)
- end subroutine
-
- public subroutine setComputer (tictactoe_computer newComputer);// Association accessor method
- if not isNull(computer) then
- setNull(computer.gui)
- end if
- if not isNull(newComputer) then
- TicTacToe_GUI nullRef
- setNull(nullRef)
- newComputer.setGui(nullRef)
- newComputer.gui = this
- end if
- computer = newComputer
- end subroutine
-
- public function tictactoe_computer getComputer ();// Association accessor method
- return computer
- end function
-
- public subroutine removeGame ();// Association accessor method
- if not isNull(game) then
- setNull(game.gui)
- end if
- setNull(game)
- end subroutine
-
- public subroutine setGame (tictactoe_game newGame);// Association accessor method
- if not isNull(game) then
- setNull(game.gui)
- end if
- if not isNull(newGame) then
- TicTacToe_GUI nullRef
- setNull(nullRef)
- newGame.setGui(nullRef)
- newGame.gui = this
- end if
- game = newGame
- end subroutine
-
- public function tictactoe_game getGame ();// Association accessor method
- return game
- end function
-
- public function commandbutton getCellButton (integer index);// Association accessor method
- return cellButtonDict.get(index)
- end function
-
- public subroutine setCellButton (integer index, commandbutton newCellButton);// Association accessor method
- if isNull(newCellButton) then
- return
- end if
- cellButtonDict.set(index, newCellButton)
- end subroutine
-
- public subroutine removeCellButton (integer index);// Association accessor method
- powerobject object
- object = cellButtonDict.get(index)
- if isNull(object) then
- return
- end if
- cellButtonDict.remove(index)
- end subroutine
-
- on tictactoe_gui.create
- if this.MenuName = "TicTacToe_MainMenu" then this.MenuID = create TicTacToe_MainMenu
- this.cellbutton1=create cellbutton1
- this.cellbutton2=create cellbutton2
- this.cellbutton3=create cellbutton3
- this.cellbutton4=create cellbutton4
- this.cellbutton5=create cellbutton5
- this.cellbutton6=create cellbutton6
- this.cellbutton7=create cellbutton7
- this.cellbutton8=create cellbutton8
- this.cellbutton9=create cellbutton9
- this.result=create result
- this.board=create board
- this.Control[]={ this.cellbutton1,&
- this.cellbutton2,&
- this.cellbutton3,&
- this.cellbutton4,&
- this.cellbutton5,&
- this.cellbutton6,&
- this.cellbutton7,&
- this.cellbutton8,&
- this.cellbutton9,&
- this.result,&
- this.board}
- end on
-
- on tictactoe_gui.destroy
- if IsValid(MenuID) then destroy(MenuID)
- destroy(this.cellbutton1)
- destroy(this.cellbutton2)
- destroy(this.cellbutton3)
- destroy(this.cellbutton4)
- destroy(this.cellbutton5)
- destroy(this.cellbutton6)
- destroy(this.cellbutton7)
- destroy(this.cellbutton8)
- destroy(this.cellbutton9)
- destroy(this.result)
- destroy(this.board)
- end on
-
- event open;TriggerEvent (this, "constructor")
- // Start user code section
-
- // End user code section
- end event
-
- event constructor;setNull(computer)
- setNull(game)
- cellButtonDict = create classdict
- // Start user code section
- tictactoe_game newGame
- newGame = create tictactoe_game
- setgame(newGame)
-
- tictactoe_computer newComp
- newComp = create tictactoe_computer
- newComp.setgame(this.game)
- setcomputer(newComp)
-
- setCellButton(1,cellbutton1)
- setCellButton(2,cellbutton2)
- setCellButton(3,cellbutton3)
- setCellButton(4,cellbutton4)
- setCellButton(5,cellbutton5)
- setCellButton(6,cellbutton6)
- setCellButton(7,cellbutton7)
- setCellButton(8,cellbutton8)
- setCellButton(9,cellbutton9)
- Width=1098
- Height=1241
-
- game.startGame()
- // End user code section
- end event
-
- event close;TriggerEvent (this, "destructor")
- // Start user code section
-
- // End user code section
- end event
-
- event destructor;// Start user code section
- // End user code section
- if not isNull(computer) then
- setNull(computer.gui)
- end if
- setNull(computer)
- if not isNull(game) then
- setNull(game.gui)
- end if
- setNull(game)
- destroy(cellButtonDict)
- setNull(cellButtonDict)
- end event
-
- type cellbutton1 from commandbutton within tictactoe_gui
- int X = 142
- int Y = 141
- int Width = 270
- int Height = 193
- int TabOrder = 10
- string Text = " "
- int TextSize = -24
- int Weight = 700
- string FaceName = "Arial"
- FontFamily FontFamily = Swiss!
- FontPitch FontPitch = Variable!
- end type
-
- event clicked;parent.cellbuttonclick(1)
- end event
-
- type cellbutton2 from commandbutton within tictactoe_gui
- int X = 412
- int Y = 141
- int Width = 270
- int Height = 193
- int TabOrder = 20
- string Text = " "
- int TextSize = -24
- int Weight = 700
- string FaceName = "Arial"
- FontFamily FontFamily = Swiss!
- FontPitch FontPitch = Variable!
- end type
-
- event clicked;parent.cellbuttonclick(2)
- end event
-
- type cellbutton3 from commandbutton within tictactoe_gui
- int X = 682
- int Y = 141
- int Width = 270
- int Height = 193
- int TabOrder = 30
- string Text = " "
- int TextSize = -24
- int Weight = 700
- string FaceName = "Arial"
- FontFamily FontFamily = Swiss!
- FontPitch FontPitch = Variable!
- end type
-
- event clicked;parent.cellbuttonclick(3)
- end event
-
- type cellbutton4 from commandbutton within tictactoe_gui
- int X = 142
- int Y = 333
- int Width = 270
- int Height = 193
- int TabOrder = 40
- string Text = " "
- int TextSize = -24
- int Weight = 700
- string FaceName = "Arial"
- FontFamily FontFamily = Swiss!
- FontPitch FontPitch = Variable!
- end type
-
- event clicked;parent.cellbuttonclick(4)
- end event
-
- type cellbutton5 from commandbutton within tictactoe_gui
- int X = 412
- int Y = 333
- int Width = 270
- int Height = 193
- int TabOrder = 50
- string Text = " "
- int TextSize = -24
- int Weight = 700
- string FaceName = "Arial"
- FontFamily FontFamily = Swiss!
- FontPitch FontPitch = Variable!
- end type
-
- event clicked;parent.cellbuttonclick(5)
- end event
-
- type cellbutton6 from commandbutton within tictactoe_gui
- int X = 682
- int Y = 333
- int Width = 270
- int Height = 193
- int TabOrder = 60
- string Text = " "
- int TextSize = -24
- int Weight = 700
- string FaceName = "Arial"
- FontFamily FontFamily = Swiss!
- FontPitch FontPitch = Variable!
- end type
-
- event clicked;parent.cellbuttonclick(6)
- end event
-
- type cellbutton7 from commandbutton within tictactoe_gui
- int X = 142
- int Y = 525
- int Width = 270
- int Height = 185
- int TabOrder = 70
- string Text = " "
- int TextSize = -24
- int Weight = 700
- string FaceName = "Arial"
- FontFamily FontFamily = Swiss!
- FontPitch FontPitch = Variable!
- end type
-
- event clicked;parent.cellbuttonclick(7)
- end event
-
- type cellbutton8 from commandbutton within tictactoe_gui
- int X = 412
- int Y = 525
- int Width = 270
- int Height = 185
- int TabOrder = 80
- string Text = " "
- int TextSize = -24
- int Weight = 700
- string FaceName = "Arial"
- FontFamily FontFamily = Swiss!
- FontPitch FontPitch = Variable!
- end type
-
- event clicked;parent.cellbuttonclick(8)
- end event
-
- type cellbutton9 from commandbutton within tictactoe_gui
- int X = 682
- int Y = 525
- int Width = 270
- int Height = 185
- int TabOrder = 90
- string Text = " "
- int TextSize = -24
- int Weight = 700
- string FaceName = "Arial"
- FontFamily FontFamily = Swiss!
- FontPitch FontPitch = Variable!
- end type
-
- event clicked;parent.cellbuttonclick(9)
- end event
-
- type result from statictext within tictactoe_gui
- int X = 5
- int Y = 897
- int Width = 1098
- int Height = 149
- string Text = "O is the winner!!!"
- Alignment Alignment = Center!
- long TextColor = 65535
- long BackColor = 0
- int TextSize = -18
- int Weight = 700
- string FaceName = "Arial"
- FontFamily FontFamily = Swiss!
- FontPitch FontPitch = Variable!
- end type
-
- type board from groupbox within tictactoe_gui
- int Width = 1093
- int Height = 825
- boolean Enabled = false
- BorderStyle BorderStyle = StyleRaised!
- long BackColor = 0
- end type
-
-