home *** CD-ROM | disk | FTP | other *** search
- #include <owl.h>
- #include <window.h>
- #include <filedial.h>
- #include <string.h>
- #include <stdio.h>
- #include <mdi.h>
- #include <checkbox.h>
- #include <static.h>
- #include <edit.h>
- #include <button.h>
- #include <listbox.h>
- #include <combobox.h>
-
- #include "d4all.h"
-
-
- #define CM_COUNTCHILDREN 201
- #define ID_CLOSEBOX 101
-
- // Team Entry Window constants
- const ID_TEAMCOMBO = 101;
- const ID_GAMECOMBO = 102;
- const WORD ID_PLAYR1 = 201;
- const WORD ID_PLAYR2 = 202;
- const WORD ID_PLAYR3 = 203;
- const WORD ID_TEAMNAME = 204;
- const WORD ID_RRPOINTS = 205;
- const WORD ID_DKPOINTS = 206;
- const WORD ID_SCOREFROM = 207;
- const WORD ID_SCORETO = 208;
- const ID_ADDTEAM = 301;
- const ID_DELTEAM = 302;
-
- // Round Robin Generation Window constants
- const WORD ID_TGROUPS = 101;
- const ID_GROUPSCOMBO = 201;
- const ID_GROUPTEAMCOMBO = 202;
- const ID_GENERATERR = 301;
- const ID_CLOSERR = 302;
-
- // Round Robin Game Entry Window constants
- const WORD ID_HSCORE = 101;
- const WORD ID_VSCORE = 102;
- const WORD ID_HPOINTS = 103;
- const WORD ID_VPOINTS = 104;
-
-
-
- const WORD MAX_TEXTLEN = 50;
-
- extern unsigned _stklen = 15000 ;
-
- int teamsWindowOpen;
- int rrWindowOpen;
- int rgWindowOpen;
-
-
-
- FIELD4INFO teamFields[] =
- {
- { "TEAM_NUM", r4num, 6, 0 },
- { "TEAM_NAME", r4str, 10, 0 },
- { "PLAYR1", r4str, 15, 0 },
- { "PLAYR2", r4str, 15, 0 },
- { "PLAYR3", r4str, 15, 0 },
- { "RR_POINTS", r4num, 6, 0 },
- { "DK_POINTS", r4num, 6, 0 },
- { 0, 0, 0, 0 },
-
- };
-
- TAG4INFO teamTags[] =
- {
- { "TEAM_NAME", "TEAM_NAME", ".NOT. DELETED()", 0, 0 },
- { "TEAM_NUM", "TEAM_NUM", ".NOT. DELETED()", 0, 0 },
- { 0, 0, 0, 0, 0 },
- };
-
- FIELD4INFO gameFields[] =
- {
- { "TEAM_NUM", r4num, 4, 0 },
- { "GAME_TYPE", r4str, 1, 0 },
- { "GROUP_NAME", r4str, 15, 0 },
- { "GAME_NUM", r4num, 4, 0 },
- { "VS_TEAM", r4num, 4, 0 },
- { "HSCORE", r4num, 6, 0 },
- { "VSCORE", r4num, 6, 0 },
- { "POINTS", r4num, 6, 0 },
- { 0, 0, 0, 0 },
-
- };
-
- TAG4INFO gameTags[] =
- {
- { "TEAM_NUM", "TEAM_NUM", ".NOT. DELETED()", 0, 0 },
- { "GROUP_NAME", "GROUP_NAME", ".NOT. DELETED()", 0, 0 },
- { 0, 0, 0, 0, 0 },
- };
-
-
- class DartApplication : public TApplication
- {
- public:
- DartApplication(LPSTR AName, HINSTANCE hInstance, HINSTANCE hPrevInstance,
- LPSTR lpCmdLine, int nCmdShow)
- : TApplication(AName, hInstance, hPrevInstance, lpCmdLine, nCmdShow) {};
-
- virtual void InitMainWindow();
-
- CODE4 codeBase ;
- };
-
-
- ///////////////////////////////////////////////////////////////////////////////////
- //
- // MDI CHILD WINDOW CLASS / MEMBERS
- //
-
- class EditTeamWindow : public TWindow
- {
- public:
-
- TComboBox *TeamsCombo;
- TComboBox *GamesCombo;
- TEdit *Player1, *Player2, *Player3;
- TEdit *teamName, *rrpoints, *dkpoints;
- TEdit *scoreFrom, *scoreTo;
-
- EditTeamWindow(PTWindowsObject AParent, LPSTR ATitle, CODE4 *cbase5, DATA4 *teams, DATA4 *games);
-
- virtual void SetupWindow();
-
- virtual void HandleButton1Msg(RTMessage Msg) = [ID_FIRST + ID_ADDTEAM];
- virtual void HandleButton2Msg(RTMessage Msg) = [ID_FIRST + ID_DELTEAM];
- virtual void HandleListBoxMsg(RTMessage Msg) = [ID_FIRST + ID_TEAMCOMBO];
-
- virtual void WMDestroy( TMessage& ) = [WM_FIRST + WM_DESTROY];
-
- DATA4 *teams;
- DATA4 *games;
-
- CODE4 *cb ;
- };
-
- void EditTeamWindow::WMDestroy( TMessage& Message )
- {
- teamsWindowOpen = 0;
- TWindow::WMDestroy(Message);
- }
-
-
- EditTeamWindow::EditTeamWindow(PTWindowsObject AParent, LPSTR ATitle, CODE4 *cbase5, DATA4 *t, DATA4 *g)
- : TWindow(AParent, ATitle)
- {
- Attr.X = 50;
- Attr.Y = 50;
- Attr.W = 530;
- Attr.H = 285;
-
- cb = cbase5;
- teams = t;
- games = g;
-
- new TStatic(this, -1, "Team Name", 10, 10, 85, 20, 0);
- new TStatic(this, -1, "Lookup", 275, 10, 85, 20, 0);
- new TStatic(this, -1, "Players", 10, 40, 85, 20, 0);
- new TStatic(this, -1, "Game", 275, 45, 85, 20, 0);
- new TStatic(this, -1, "RR Points", 10, 130, 85, 20, 0);
- new TStatic(this, -1, "DK Points", 10, 160, 85, 20, 0);
- new TStatic(this, -1, "Score", 275, 100, 85, 20, 0);
- new TStatic(this, -1, "To", 400, 100, 85, 20, 0);
-
- teamName = new TEdit(this, ID_TEAMNAME, "", 100, 10, 150, 27, MAX_TEXTLEN, FALSE);
- teamName->Attr.Style |= ES_UPPERCASE;
- Player1 = new TEdit(this, ID_PLAYR1, "", 100, 40, 150, 27, MAX_TEXTLEN, FALSE);
- Player1->Attr.Style |= ES_UPPERCASE;
- Player2 = new TEdit(this, ID_PLAYR1, "", 100, 70, 150, 27, MAX_TEXTLEN, FALSE);
- Player2->Attr.Style |= ES_UPPERCASE;
- Player3 = new TEdit(this, ID_PLAYR1, "", 100, 100, 150, 27, MAX_TEXTLEN, FALSE);
- Player3->Attr.Style |= ES_UPPERCASE;
- rrpoints = new TEdit(this, ID_RRPOINTS, "", 100, 130, 150, 27, MAX_TEXTLEN, FALSE);
- rrpoints->Attr.Style |= ES_UPPERCASE;
- dkpoints = new TEdit(this, ID_DKPOINTS, "", 100, 160, 150, 27, MAX_TEXTLEN, FALSE);
- dkpoints->Attr.Style |= ES_UPPERCASE;
-
- TeamsCombo = new TComboBox(this, ID_TEAMCOMBO, 340, 10, 170, 300, CBS_DROPDOWNLIST, 0 );
- TeamsCombo->Attr.Style = WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWNLIST;
- GamesCombo = new TComboBox(this, ID_GAMECOMBO, 340, 45, 170, 400, CBS_DROPDOWNLIST, 1);
- GamesCombo->Attr.Style = WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWNLIST;
-
- scoreFrom = new TEdit(this, ID_SCOREFROM, "", 340, 100, 50, 27, MAX_TEXTLEN, FALSE);
- scoreFrom->Attr.Style |= ES_UPPERCASE;
- scoreTo = new TEdit(this, ID_SCORETO, "", 440, 100, 50, 27, MAX_TEXTLEN, FALSE);
- scoreTo->Attr.Style |= ES_UPPERCASE;
-
- new TButton(this, ID_ADDTEAM, "New Team", 10, 205, 110, 28, FALSE);
- new TButton(this, ID_DELTEAM, "Delete", 140, 205, 110, 28, FALSE);
-
- EnableKBHandler();
-
- }
-
-
- void EditTeamWindow::HandleListBoxMsg(RTMessage Msg)
- {
- char TheText[MAX_TEXTLEN];
- int curIndex, rc ;
-
- switch( Msg.LP.Hi )
- {
- case LBN_SELCHANGE:
-
- TeamsCombo->GetSelString( TheText, MAX_TEXTLEN-1 );
- d4tag_select( teams, d4tag(teams,"TEAM_NAME") );
- rc = d4seek( teams, TheText );
- if( rc == r4after || rc == 0 )
- {
- teamName->SetText( f4str(d4field(teams,"TEAM_NAME")) );
- Player1->SetText( f4str(d4field(teams,"PLAYR1")) );
- Player2->SetText( f4str(d4field(teams,"PLAYR2")) );
- Player3->SetText( f4str(d4field(teams,"PLAYR3")) );
- SetFocus( TeamsCombo->HWindow );
- }
- else
- {
- MessageBox( HWindow, "Problem", "Error in the d4seek()", MB_OK );
- }
- break;
-
- case LBN_DBLCLK:
-
- break;
-
- case LBN_SETFOCUS:
-
- break;
-
- }
- }
-
-
- void EditTeamWindow::SetupWindow()
- {
- int rc;
- FIELD4 *tName;
-
- TWindow::SetupWindow();
-
- d4tag_select( teams, d4tag(teams,"TEAM_NAME") );
- tName=d4field(teams,"TEAM_NAME");
- for( rc=d4top(teams); rc==r4success; rc=d4skip(teams,1L) )
- {
- TeamsCombo->AddString( f4str(tName) );
- }
- TeamsCombo->SetSelIndex( 0 ) ;
- d4tag_select( teams, d4tag(teams,"TEAM_NAME") );
- d4top( teams );
- teamName->SetText( f4str(d4field(teams,"TEAM_NAME")) );
- Player1->SetText( f4str(d4field(teams,"PLAYR1")) );
- Player2->SetText( f4str(d4field(teams,"PLAYR2")) );
- Player3->SetText( f4str(d4field(teams,"PLAYR3")) );
- SetFocus( TeamsCombo->HWindow );
- }
-
- void EditTeamWindow::HandleButton1Msg(RTMessage)
- {
- // Add a team to the roster
- char TheText[MAX_TEXTLEN];
-
- teamName->GetText(TheText, sizeof(TheText));
- if( TheText[0] <= 32 )
- return;
- TeamsCombo->AddString(TheText);
- TeamsCombo->SetSelIndex(TeamsCombo->FindString(TheText, 0) );
-
- d4append_blank(teams);
- teamName->GetText(TheText, sizeof(TheText));
- f4assign(d4field(teams,"TEAM_NAME"),TheText);
- Player1->GetText(TheText, sizeof(TheText));
- f4assign(d4field(teams,"PLAYR1"),TheText);
- Player2->GetText(TheText, sizeof(TheText));
- f4assign(d4field(teams,"PLAYR2"),TheText);
- Player3->GetText(TheText, sizeof(TheText));
- f4assign(d4field(teams,"PLAYR3"),TheText);
- f4assign_long(d4field(teams,"RR_POINTS"),0L);
- f4assign_long(d4field(teams,"DK_POINTS"),0L);
-
- SetFocus( TeamsCombo->HWindow );
- }
-
- void EditTeamWindow::HandleButton2Msg(RTMessage)
- {
- // Delete a team from the roster
- char TheText[MAX_TEXTLEN];
- int curIndex, rc ;
-
- TeamsCombo->GetSelString( TheText, MAX_TEXTLEN-1 );
- d4tag_select( teams, d4tag(teams,"TEAM_NAME") );
- rc = d4seek( teams, TheText );
- if( rc == r4after || rc == 0 )
- {
- d4delete( teams );
- }
- else
- {
- MessageBox( HWindow, "Problem", "Error in the d4seek(), delete failed", MB_OK );
- }
- curIndex = TeamsCombo->GetSelIndex();
- TeamsCombo->DeleteString( curIndex );
- if( TeamsCombo->GetCount() > 0 )
- {
- if( curIndex >= TeamsCombo->GetCount() )
- curIndex--;
- TeamsCombo->SetSelIndex( curIndex ) ;
- TeamsCombo->GetSelString( TheText, MAX_TEXTLEN-1 );
- d4tag_select( teams, d4tag(teams,"TEAM_NAME") );
- rc = d4seek( teams, TheText );
- if( rc == r4after || rc == 0 )
- {
- teamName->SetText( f4str(d4field(teams,"TEAM_NAME")) );
- Player1->SetText( f4str(d4field(teams,"PLAYR1")) );
- Player2->SetText( f4str(d4field(teams,"PLAYR2")) );
- Player3->SetText( f4str(d4field(teams,"PLAYR3")) );
- }
- }
- SetFocus( TeamsCombo->HWindow );
- }
-
-
- ///////////////////////////////////////////////////////////////////////////////////
- //
- // Round Robin Game Entry Window
- //
-
- class rgWindow : public TWindow
- {
- public:
-
- TComboBox *gameCombo;
- TEdit *hScore, *vScore;
- TEdit *hPoints, *vPoints;
-
- rgWindow(PTWindowsObject AParent, LPSTR ATitle, CODE4 *cbase5, DATA4 *teams, DATA4 *games, char *group, int tNum);
-
- virtual void SetupWindow();
-
- virtual void HandleCloseButtonMsg(RTMessage Msg) = [ID_FIRST + ID_CLOSERR];
- virtual void HandleCombo1Msg(RTMessage Msg) = [ID_FIRST + ID_GAMECOMBO];
-
- virtual void WMDestroy( TMessage& ) = [WM_FIRST + WM_DESTROY];
-
- char *groupName;
- int teamNum;
-
- DATA4 *teams;
- DATA4 *games;
- CODE4 *cb ;
- };
-
-
- void rgWindow::WMDestroy( TMessage& Message )
- {
- rgWindowOpen = 0;
- TWindow::WMDestroy(Message);
- }
-
-
- rgWindow::rgWindow(PTWindowsObject AParent, LPSTR ATitle, CODE4 *cbase5, DATA4 *t, DATA4 *g, char *group, int tNum)
- : TWindow(AParent, ATitle)
- {
- int rc;
-
- Attr.X = 50;
- Attr.Y = 50;
- Attr.W = 450;
- Attr.H = 250;
-
- cb = cbase5;
- teams = t;
- games = g;
- groupName = group;
- teamNum = tNum;
-
-
- gameCombo = new TComboBox(this, ID_GAMECOMBO, 100, 40, 250, 200, CBS_DROPDOWNLIST, 0 );
- gameCombo->Attr.Style = WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWNLIST;
-
- new TStatic(this, -1, "Group", 10, 10, 85, 20, 0);
- new TStatic(this, -1, "Game Type", 200, 10, 85, 20, 0);
- new TStatic(this, -1, "Game", 10, 40, 85, 20, 0);
- new TStatic(this, -1, "Team", 10, 70, 85, 20, 0);
- new TStatic(this, -1, "vs.", 200, 70, 85, 20, 0);
- new TStatic(this, -1, "Score", 10, 100, 85, 20, 0);
- new TStatic(this, -1, "To", 200, 100, 85, 20, 0);
- new TStatic(this, -1, "Points", 10, 130, 85, 20, 0);
-
- hScore = new TEdit(this, ID_HSCORE, "", 100, 100, 50, 27, MAX_TEXTLEN, FALSE);
- vScore = new TEdit(this, ID_VSCORE, "", 100, 100, 50, 27, MAX_TEXTLEN, FALSE);
- hPoints = new TEdit(this, ID_HPOINTS, "", 280, 130, 50, 27, MAX_TEXTLEN, FALSE);
- vPoints = new TEdit(this, ID_VPOINTS, "", 280, 130, 50, 27, MAX_TEXTLEN, FALSE);
-
- new TButton(this, ID_CLOSERR, "Close", 10, 180, 110, 28, FALSE);
-
-
- EnableKBHandler();
-
-
- }
-
-
- void rgWindow::HandleCombo1Msg(RTMessage Msg)
- {
- int curIndex, rc ;
-
- switch( Msg.LP.Hi )
- {
- case LBN_SELCHANGE:
- break;
-
- case LBN_DBLCLK:
-
- break;
-
- case LBN_SETFOCUS:
-
- break;
-
- }
- }
-
-
- void rgWindow::SetupWindow()
- {
- int rc;
- FIELD4 *teamName;
- FIELD4 *teamNumber;
- FIELD4 *grpName;
-
- char comboText[51];
- TWindow::SetupWindow();
-
- SetFocus( gameCombo->HWindow );
-
- // Count the total number of games
- d4tag_select( games, d4tag(games,"GROUP_NAME") );
- teamName=d4field(teams,"TEAM_NAME");
- grpName=d4field(games,"GROUP_NAME");
- teamNumber=d4field(games,"TEAM_NUM");
-
- d4tag_select( games, d4tag(games,"GROUP_NAME") );
- rc = d4seek( games, groupName );
- //if( rc != r4after && rc != 0 ) return;
- rc = r4success;
- gameCombo->ClearList();
-
- while( 1 )
- {
- if( teamNum == f4int(teamNumber) )
- break;
-
- rc=d4skip(games,1L);
- if( rc == r4eof ) break ;
- }
- if( rc==r4eof )
- return;
-
- for( ; rc==r4success; rc=d4skip(games,1L) )
- {
- if( memcmp(groupName,f4str(grpName), 7) )
- break;
- if( teamNum != f4int(teamNumber) )
- break;
- int gameNumber = f4int(d4field(games,"GAME_NUM"));
- int hTeam = f4int(d4field(games,"TEAM_NUM"));
- int vTeam = f4int(d4field(games,"VS_TEAM"));
- sprintf(comboText,"Game: %02d, Team %02d vs %02d", gameNumber, hTeam, vTeam );
- gameCombo->AddString( comboText );
- gameCombo->SetSelIndex(gameCombo->FindString(comboText, 0) );
- }
-
- gameCombo->SetSelIndex( 0 ) ;
- SetFocus( gameCombo->HWindow );
- }
-
- void rgWindow::HandleCloseButtonMsg(RTMessage)
- {
- CloseWindow();
- }
-
-
-
- ///////////////////////////////////////////////////////////////////////////////////
- //
- // Round Robin Generation Window
- //
-
- class rrWindow : public TWindow
- {
- public:
-
- TComboBox *groupsCombo;
- TComboBox *teamGroupCombo;
- TEdit *tGroups;
-
- rrWindow(PTWindowsObject AParent, LPSTR ATitle, CODE4 *cbase5, DATA4 *teams, DATA4 *games);
-
- virtual void SetupWindow();
-
- virtual void HandleGenButtonMsg(RTMessage Msg) = [ID_FIRST + ID_GENERATERR];
- virtual void HandleCloseButtonMsg(RTMessage Msg) = [ID_FIRST + ID_CLOSERR];
- virtual void HandleCombo1Msg(RTMessage Msg) = [ID_FIRST + ID_GROUPSCOMBO];
- virtual void HandleCombo2Msg(RTMessage Msg) = [ID_FIRST + ID_GROUPTEAMCOMBO];
-
- virtual void WMDestroy( TMessage& ) = [WM_FIRST + WM_DESTROY];
-
- long numGroups;
- char tTeams[35];
-
- DATA4 *teams;
- DATA4 *games;
-
- CODE4 *cb ;
- };
-
- void rrWindow::HandleGenButtonMsg(RTMessage)
- {
- int rc;
- long recNum, teamsPerGroup;
- long lCntr;
- char nGroupsText[35];
- char nText[35];
- ldiv_t lx;
-
-
- tGroups->GetText(nGroupsText, sizeof(nGroupsText));
- numGroups = atol( nGroupsText );
-
- d4tag_select( teams, d4tag(teams,"TEAM_NAME") );
-
- // Assign, in alphabeticle order, a team number to each team
- recNum = 1;
- for( rc=d4top(teams); rc==r4success; rc=d4skip(teams,1L) )
- f4assign_long(d4field(teams,"TEAM_NUM"), recNum++) ;
-
- d4tag_select( teams, d4tag(teams,"TEAM_NUM") );
- long tRecs = d4reccount(teams);
- d4top(teams);
- long groupRecStart = d4recno(teams);
-
- if( numGroups<1 || numGroups>=tRecs )
- {
- MessageBox( HWindow, "Invalid number of groups", "Entry Error", MB_OK );
- return;
- }
-
- lx = ldiv(tRecs, numGroups);
- // lx.quot
- // lx.rem
-
-
- d4zap(games,1L,d4reccount(games));
- d4top(games);
-
- int groupCounter = 1;
- int skipAnother = 0;
-
- groupsCombo->ClearList();
- teamGroupCombo->ClearList();
-
- while( 1 )
- {
- itoa( groupCounter++, nText, 10 );
- strcpy( nGroupsText, "GROUP " );
- strcat( nGroupsText, nText );
- groupsCombo->AddString(nGroupsText);
- groupsCombo->SetSelIndex(groupsCombo->FindString(nGroupsText, 0) );
-
- lCntr = 1;
- int extraTeamSwitch = 1;
- while( 1 )
- {
- long curTeamRec = d4recno(teams);
- long curTeam = f4long(d4field(teams,"TEAM_NUM"));
-
- teamsPerGroup = lx.quot;
- if( lx.rem ) teamsPerGroup++;
- d4go(teams,groupRecStart);
-
- int gameNum = 1;
- while( teamsPerGroup )
- {
- long thisTeam = f4long(d4field(teams,"TEAM_NUM"));
- if( curTeam != thisTeam )
- {
- d4append_blank( games );
- f4assign(d4field(games,"GROUP_NAME"), nGroupsText );
- f4assign_long(d4field(games,"TEAM_NUM"), curTeam );
- f4assign(d4field(games,"GAME_TYPE"), "R" );
- f4assign_int(d4field(games,"GAME_NUM"), gameNum );
- f4assign_long(d4field(games,"VS_TEAM"), thisTeam );
- gameNum++;
- }
- if( d4skip(teams, 1L) == r4eof )
- break;
- teamsPerGroup--;
- }
-
- d4go(teams, curTeamRec);
- if( d4skip(teams, 1L) == r4eof )
- break;
-
- lCntr++;
-
- if( lCntr>lx.quot )
- {
- if( lx.rem && extraTeamSwitch )
- {
- skipAnother = 1 ;
- lx.rem--;
- extraTeamSwitch = 0;
- }
- else
- {
- break;
- }
- }
- }
-
- d4go(teams,groupRecStart);
- if( d4skip( teams, lx.quot ) == r4eof )
- break;
- if( skipAnother )
- {
- skipAnother = 0;
- if( d4skip( teams, 1L ) == r4eof )
- break;
- }
-
- groupRecStart = d4recno(teams);
- }
-
- SetFocus( groupsCombo->HWindow );
- }
-
-
- void rrWindow::WMDestroy( TMessage& Message )
- {
- rrWindowOpen = 0;
- TWindow::WMDestroy(Message);
- }
-
-
- rrWindow::rrWindow(PTWindowsObject AParent, LPSTR ATitle, CODE4 *cbase5, DATA4 *t, DATA4 *g)
- : TWindow(AParent, ATitle)
- {
- int rc;
- long tTeamCntr = 0;
- FIELD4 *tName;
-
- Attr.X = 10;
- Attr.Y = 10;
- Attr.W = 450;
- Attr.H = 250;
-
- cb = cbase5;
- teams = t;
- games = g;
-
- // Count the total number of teams
- d4tag_select( teams, d4tag(teams,"TEAM_NAME") );
- tName=d4field(teams,"TEAM_NAME");
- d4pack(teams);
- for( rc=d4top(teams); rc==r4success; rc=d4skip(teams,1L) )
- {
- tTeamCntr++;
- }
- ltoa( d4reccount(teams), tTeams, 10);
-
- new TStatic(this, -1, "Total Teams", 10, 10, 85, 20, 0);
- new TStatic(this, -1, tTeams, 100, 10, 85, 20, 0);
- new TStatic(this, -1, "Groups", 175, 10, 85, 20, 0);
-
- new TStatic(this, -1, "# Groups", 10, 40, 85, 20, 0);
- new TStatic(this, -1, "Group Teams", 175, 45, 85, 20, 0);
-
- tGroups = new TEdit(this, ID_TGROUPS, "", 100, 40, 50, 27, MAX_TEXTLEN, FALSE);
-
- groupsCombo = new TComboBox(this, ID_GROUPSCOMBO, 240, 10, 170, 150, CBS_DROPDOWNLIST, 0 );
- groupsCombo->Attr.Style = WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWNLIST;
- teamGroupCombo = new TComboBox(this, ID_GROUPTEAMCOMBO, 240, 45, 170, 300, CBS_DROPDOWNLIST, 1);
- teamGroupCombo->Attr.Style = WS_CHILD | WS_VISIBLE | WS_GROUP | WS_TABSTOP | WS_VSCROLL | CBS_DROPDOWNLIST;
-
- new TButton(this, ID_GENERATERR, "Generate", 10, 150, 110, 28, FALSE);
- new TButton(this, ID_CLOSERR, "Close", 140, 150, 110, 28, FALSE);
-
- EnableKBHandler();
-
- }
-
-
- void rrWindow::HandleCombo1Msg(RTMessage Msg)
- {
- char TheText[MAX_TEXTLEN];
- int curIndex, rc ;
- long lastNum;
- FIELD4 *teamName;
- FIELD4 *teamNum;
- FIELD4 *groupName;
-
- switch( Msg.LP.Hi )
- {
- case LBN_SELCHANGE:
- teamNum=d4field(games,"TEAM_NUM");
- teamName=d4field(teams,"TEAM_NAME");
- groupName=d4field(games,"GROUP_NAME");
-
- d4tag_select( games, d4tag(games,"GROUP_NAME") );
- d4tag_select( teams, d4tag(teams,"TEAM_NUM") );
-
- teamGroupCombo->ClearList();
- groupsCombo->GetSelString( TheText, MAX_TEXTLEN-1 );
-
- rc = d4seek( games, TheText );
- if( rc != r4after && rc != 0 ) break;
-
- while( 1 )
- {
- lastNum = f4long(teamNum);
- rc = d4seek_double( teams, (double)f4long(teamNum) );
- if( rc != r4after && rc != 0 )
- break;
- if( memcmp(TheText,f4str(groupName), 7) )
- break;
- teamGroupCombo->AddString( f4str(teamName) );
-
- while( 1 )
- {
- rc=d4skip(games,1L);
- if( rc != r4success )
- break;
- if( lastNum != f4long(teamNum) )
- break;
- }
- if( rc != r4success ) break;
- }
- teamGroupCombo->SetSelIndex( 0 ) ;
- SetFocus( groupsCombo->HWindow );
- break;
-
- case LBN_DBLCLK:
-
- break;
-
- case LBN_SETFOCUS:
-
- break;
-
- }
- }
-
-
- void rrWindow::HandleCombo2Msg(RTMessage Msg)
- {
- char TheText[MAX_TEXTLEN];
- int curIndex, rc ;
- FIELD4 *teamName;
- FIELD4 *teamNum;
-
- switch( Msg.LP.Hi )
- {
- case LBN_SELCHANGE:
- d4tag_select( teams, d4tag(teams,"TEAM_NAME") );
- teamNum=d4field(teams,"TEAM_NUM");
- teamGroupCombo->GetSelString( TheText, MAX_TEXTLEN-1 );
- TheText[10] = 0;
- rc = d4seek( teams, TheText );
- if( rc != r4after && rc != 0 )
- {
- MessageBox( HWindow, "Seek on Team Name didn't work!", "Seeking Error", MB_OK );
- break;
- }
- groupsCombo->GetSelString( TheText, MAX_TEXTLEN-1 );
- GetApplication()->MakeWindow( new rgWindow(this, "Game Entry Window", cb, teams, games,TheText,f4int(teamNum)) );
- break;
-
- case LBN_DBLCLK:
- break;
-
- case LBN_SETFOCUS:
-
- break;
-
- }
- }
-
-
- void rrWindow::SetupWindow()
- {
- TWindow::SetupWindow();
-
- SetFocus( tGroups->HWindow );
- }
-
- void rrWindow::HandleCloseButtonMsg(RTMessage)
- {
- CloseWindow();
- }
-
-
- ///////////////////////////////////////////////////////////////////////////////////
- //
- // FRAME WINDOW CLASS / MEMBERS
- //
-
-
- _CLASSDEF(DartFrame)
-
- class DartFrame : public TMDIFrame
- {
- public:
- DartFrame(LPSTR ATitle, CODE4 *cbase5);
- void SetupWindow();
-
- virtual void RosterEntryWindow( RTMessage Msg ) = [CM_FIRST+1024];
- virtual void RoundRobinGenerate( RTMessage Msg ) = [CM_FIRST+1025];
-
- DATA4 *teams;
- DATA4 *games;
- CODE4 *cb;
- };
-
- DartFrame::DartFrame(LPSTR ATitle, CODE4 *cbase5)
- : TMDIFrame(ATitle, "COMMANDS")
- {
- ChildMenuPos = 2;
- cb = cbase5;
- teamsWindowOpen = 0;
-
- cb->open_error = 0;
- cb->safety = 0;
- teams = d4open( cb, "TEAMS.DBF" );
- if( teams == NULL )
- teams = d4create( cb, "TEAMS.DBF", teamFields, teamTags );
-
- games = d4open( cb, "GAMES.DBF" );
- if( games == NULL )
- games = d4create( cb, "GAMES.DBF", gameFields, gameTags );
-
- };
-
-
- // set up the TMDIFrame, creating its first child
- void DartFrame::SetupWindow()
- {
- TMDIFrame::SetupWindow();
- }
-
- void DartFrame::RosterEntryWindow( RTMessage Msg )
- {
- if( !teamsWindowOpen )
- {
- GetApplication()->MakeWindow( new EditTeamWindow(this, "Team Roster", cb, teams, games) );
- teamsWindowOpen = 1;
- }
- }
-
- void DartFrame::RoundRobinGenerate( RTMessage Msg )
- {
- if( !rrWindowOpen )
- {
- GetApplication()->MakeWindow( new rrWindow(this, "Round Robin Generation", cb, teams, games) );
- rrWindowOpen = 1;
- }
- }
-
-
-
- ///////////////////////////////////////////////////////////////////////////////////
-
-
-
- void DartApplication::InitMainWindow()
- {
- d4init( &codeBase ) ;
- MainWindow = new DartFrame( Name, &codeBase);
-
- }
-
- int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
- {
- DartApplication DartApp("Dart Tounament", hInstance, hPrevInstance, lpCmdLine, nCmdShow);
- DartApp.Run();
-
- d4close_all( &DartApp.codeBase );
-
- return DartApp.Status;
- }
-
-