Window View Interface

Below is a technical introduction to the Window View GUI of the HOOPScheduler application. This page also describes the code changes made by Lee Long, previously described on a seperate page that was lost. The Window View GUI consists of the Main Frame class, the Document class and three View classes.

Main Frame

The Frame Window is is defined by the class MainFrm.cpp. This class controls the current view, creates and manages the toolbar, and controls activation of application commands. MainFrm consists of the following members.

  • CToolBar m_ToolBar
    an instance of a toolbar that is assigned the value of our application toolbar and created when the Frame Window is open
  • enum eView {APP = 1, HELP = 2, PREVIEW = 3}
    an enumeration that defines an integer value for each view in our application
  • int OnCreate (LPCREATESTRUCT lpCreateStruct)
    creates and enables the application toolbar
  • void SwitchToView (eView nView)
    changes the Frame Window to display the view specified by the enumeration value nView
  • void OnHelpViewhelpfiles ()
    changes the current view to the Browser View
  • void OnHelpClosehelpfiles ()
    closes the Browser View and changes the current view to the Main View
  • void OnPreviewLeagueschedules ()
    changes the current view to the Schedule View
  • void OnPreviewCloseschedules ()
    closes the Schedule View and changes the current view to the Main View

There are also several update UI command functions, one for each application command, whose purpose is to enable or disable a command depending on the value of the current view.


Document

The Document is defined by the class HOOPSDoc.cpp. Besides normal Document functionality, we use this class to support the Schedule View. It uses the following members to store data that Schedule View displays.

  • CStringArray m_LineTable
    used to store lines of text that are publicly accessible
  • void Serialize (CArchive& ar)
    serializes the member variable m_LineTable
  • void DeleteContents ()
    clears all lines from m_LineTable
  • void OnPreviewSelectschedule ()
    stores league information, specified by LeagueSelect.m_LeagueName, as lines of text in m_LineTable

Main View

The Main View Window is defined by the class HOOPSView.cpp. The purpose of this view is to allow the user to create new camps, open existing camps, save the current camp, edit the current camp, view league schedules, and open the help files. The following members perform these tasks.

  • CBitmap m_Bitmap
    an instance of a bitmap that is assigned the value of our application bitmap and created when the Main View Window is displayed
  • int m_BitmapHeight
    the vertical length of m_Bitmap
  • int m_BitmapWidth
    the horizontal length of m_Bitmap
  • void OnDraw (CDC* pDC)
    displays the application bitmap, the name of the current camp, and the start and end dates of the current camp
  • void OnFileNew ()
    destroys the current camp and creates a new one
  • void OnFileOpen ()
    destroys the current camp and opens one specified by the user
  • void OnFileSave ()
    saves the current camp through object serialization
  • void OnEditCamp ()
    creates an instance of and opens the tabbed-style dialog box camp editor

Schedule View

The Schedule View Window is defined by the class ScheduleView.cpp. The purpose of this view is to allow the user to open and display, print preview, and print league schedules. This view was added as the result of a final requirement by the client that he be able to print league schedules on a single page. The print preview dialog in the camp editor did not facilitate this because of the grid control. Several classes, including the Document class, assist in the implementation of this view. They are described below.

This dialog box lets the user select a league from the drop down menu whose schedule will be displayed to the screen. The following members are defined.

  • CString m_LeagueName
    stores the name of the league selected from the drop down menu
  • BOOL OnInitDialog ()
    populates the drop down menu with the names of the leagues in the current camp
  • void OnSelchangeSelectLeagues ()
    stores the name of the league that the user selects in m_LeagueName

The driving class supporting this view is ScheduleView.cpp. The following members are defined.

  • CRect m_rectPrint
    defines the area on the screen where text can be displayed
  • void OnInitUpdate ()
    validates the drawing area and clears the view window
  • void OnDraw (CDC* pDC)
    creates a font and displays the lines of text stored in HOOPSDoc.m_LineTable,
  • void OnKeyDown (UINT nChar, UINT nRepCnt, UINT nFlags)
    defines some key scrolling capabilities for the user
  • BOOL OnPreparePrinting (CPrintInfo* pInfo)
    sets maximum pages to one validates the drawing area and clears the view window
  • void OnPrint (CDC* pDC, CPrintInfo* pInfo)
    allows the user to print to almost any printer
  • void OnUpdate (CView* pSender, LPARAM lHint, CObject* pHint)
    redraws text in the current window, Schedule View or Print Preview

The print preview screen has the basic functionality provided by MFC print preview with nothing added. I found the class LogScrollView and use it to correctly display and print the text within Schedule View. Without this class the text displayed in the print preview screen is significantly smaller than what is displayed within Schedule View and what gets printed is something else. LogScrollView coordinates the three devices to interpret the font the same.


Browser View

The Browser View Window is defined by the class BrowserView.cpp. The purpose of this view is to allow the user to view html files in a local directory so that he may have a quick resource that explains the fuctionality of our application. The html files that will be included are the same as our online user manual. I used the ActiveX control webbrowser in the implementation of this view. The following members are defined.

  • char m_manual
    defines where the html index page is located, this is hard coded
  • CWebBrowser m_helpfiles
    an instance of a webbrowser that is created when the Browser View Window is displayed
  • int OnCreate (LPCREATESTRUCT lpCreateStruct)
    instantiates m_helpfiles and navigates to the specified page
  • void OnSize (UINT nType, int cx, int cy)
    validates the drawing area so that m_helpfiles can be loaded
  • void OnBeforeNavigateExplorer1 (...)
    opens the specified html page in m_helpfiles
  • void OnTitleChangeExplorer2 (LPCTSTR Text)
    displays the title of the curent page in the title bar, however, the title is overwritten by Main Frame when the view is loaded