home *** CD-ROM | disk | FTP | other *** search
- // PXEWIN - (C) Copyright 1992 by Beam Engineering, INC.
-
- // PXLISTBX.CPP //
-
- // Contents ----------------------------------------------------------------
- //
- // This module contains members for the PXListBox class.
- //
- // End ---------------------------------------------------------------------
-
- // External Reference Name for this Header ---------------------------------
-
- #ifndef PXLISTBX_CPP
- #define PXLISTBX_CPP
-
- // End ---------------------------------------------------------------------
-
- // Interface Dependencies --------------------------------------------------
-
- #ifndef PXLISTBX_HPP
- #include "pxlistbx.hpp"
- #endif // PXLISTBX_HPP //
-
- // End ---------------------------------------------------------------------
-
- // constructor PXListBox //
-
- inline PXListBox::PXListBox(PBrowser AParent,
- int AnId,int X,int Y,int W,int H,
- PTModule AModule):
- TListBox((PTWindowsObject)AParent,
- AnId,X,Y,W,H,AModule)
- {
- BOOL temp;
-
- // Copy display pointer and scroller
-
- my_display = AParent->my_display;
- my_parent = AParent;
-
- // Disable item sort.
-
- Attr.Style &= ~LBS_SORT;
- }
-
- // Summary -----------------------------------------------------------------
- //
- // Redefines and sets up list boxes for the browser display.
- //
- // Parameters
- //
- // Parameters are as they are ussually for list boxes except the
- // parent window is of type Browser. This must be caste to a
- // PTWindowsObject type.
- //
- // Functional Description
- //
- // Caste the parent window to my display object so we can call display
- // routines. Set the style so that the list boxes are not sorted.
- //
- // End ---------------------------------------------------------------------
-
- // member build of PXListBox //
-
- PTStreamable PXListBox::build()
- {
- return new PXListBox(streamableInit);
- }
-
- TStreamableClass RegPXListBox("PXListBox",PXListBox::build,
- __DELTA(PXListBox));
-
- // Description -------------------------------------------------------------
- //
- // When the streamable constructor is called, TStreamable dispatches
- // the build member to construct the object. To do this, it must
- // know where to find this member functions for the specific class.
- // This is the reason for the stream registration.
- //
- // End ---------------------------------------------------------------------
-
- // member read of PXListBox //
-
- inline Pvoid PXListBox::read(Ripstream is)
- {
- TListBox::read(is);
- return this;
- }
-
- // Summary -----------------------------------------------------------------
- //
- // Call TListBox read member.
- //
- // End ---------------------------------------------------------------------
-
- // member write of PXListBox //
-
- inline void PXListBox::write(Ropstream os)
- {
- TListBox::write(os);
- }
-
- // Summary -----------------------------------------------------------------
- //
- // Call TListBox write member.
- //
- // End ---------------------------------------------------------------------
-
- // member LBNSelChange of PXListBox //
-
- inline void PXListBox::LBNSelChange(RTMessage)
- {
- my_display->SelRecord(GetSelIndex());
-
- // Set the scroller to the correct position
-
- my_parent->SetScroller();
- }
-
- // Summary -----------------------------------------------------------------
- //
- // Responds to a mouse click selection in a list box. The selection is
- // dispatched to the display routines SelRecord member to select the
- // record cooresponding to the selection.
- //
- // End ---------------------------------------------------------------------
-
- // member WMPaint of PXListBox //
-
- inline void PXListBox::WMPaint(RTMessage Msg)
- {
- if(my_display->RetFlag())
- TControl::WMPaint(Msg);
- }
-
- // Description -------------------------------------------------------------
- //
- // Redefine WMPaint so that list boxes are not drawn when the
- // the Update flag is reset. Since the OWL will do screen refresh
- // on the list boxes for each new entrie in the box, it is better
- // to do a paint after the list has completely been updated.
- //
- // End ---------------------------------------------------------------------
-
- // member DefWndProc of PXListBox //
-
- void PXListBox::DefWndProc(RTMessage Msg)
- {
- BOOL my_key = FALSE; /* Indicates if key has been
- process before DefWndProc
- */
-
- // We will need to repond to some keystrokes and exclude their
- // processing from the defualt DefWndProc.
-
- if(Msg.Message == WM_KEYDOWN)
- {
- switch(Msg.WParam)
- {
- // Cursor down
-
- case VK_DOWN:
- {
- if(GetSelIndex() == PAGE_SIZE - 1)
- {
- my_display->SelRecord(GetSelIndex());
- my_key = TRUE;
- }
- break;
- }
-
- // Cursor up
-
- case VK_UP:
- {
- if(GetSelIndex() == 0)
- {
- my_display->SelRecord(GetSelIndex());
- my_key = TRUE;
- }
- break;
- }
-
- // Deactivate cursor left and right
-
- case VK_LEFT:
- {
- my_key = TRUE;
- break;
- }
- case VK_RIGHT:
- {
- my_key = TRUE;
- break;
- }
-
- // Page Down
-
- case VK_NEXT:
- {
- my_display->FillBoxes(my_display->top_rec
- + PAGE_SIZE);
- my_key = TRUE;
- break;
- }
-
- // Page Up
-
- case VK_PRIOR:
- {
- my_display->FillBoxes(my_display->top_rec
- - PAGE_SIZE);
- my_key = TRUE;
- break;
- }
- }
-
- // Set the scroller to the current position
-
- my_parent->SetScroller();
- }
-
- // If it's not one of the keys above then go ahead and call the
- // normal windows procedure.
-
- if(my_key == FALSE)
- TWindowsObject::DefWndProc(Msg);
- }
-
- // Summary -----------------------------------------------------------------
- //
- // Redefines DefWndProc to include special handling of cursor and
- // page keys.
- //
- // Parameter
- //
- // Msg. This will be a reference to the message structure.
- //
- // Description
- //
- // The cursor up and down keys will normally cause a windows selection
- // change message to be sent so the LBNSelChange member will respond to
- // these changes. However, if the selection is the first or last item
- // in the list and you press cursor up or down respectively, you will
- // not get a selection change message. These conditions need special
- // handling. The display SelRecord member is called in either case and
- // the my_key flag is set to keep the default DefWndProc from
- // reprocessing this condition.
- //
- // PgUp and PgDwn key strokes, will only cause the item selection to
- // go to the top or the bottom of the list. These most be redefined
- // to go up or down by the page width in the database. This is done
- // by calling the FillBoxes member of the display routine. Again, the
- // my_key flag is set to keep the normal DefWndProc from reprocessing
- // these conditions.
- //
- // The left and right cursor keys will act like the up and down cursor
- // key normally. They have been dispabled for simplicity.
- //
- // If none of the above conditions occur, then the normal DefWndProc is
- // called.
- //
- // End ---------------------------------------------------------------------
-
- #endif // PXLISTBX_CPP //
-