home *** CD-ROM | disk | FTP | other *** search
- // -------------------------------------------------------------------------
- // Copyright @ 1997 TCK Software, Incorporated
- // All Rights Reserved
- // -------------------------------------------------------------------------
-
- #include "stdafx.h"
- #include "pictVf.h"
- #include "resource.h"
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- #define ANIM_TIMER 101
-
- // Static Data Members
-
- // -------------------------------------------------------------------------
- // CPictHdr Constructor
- // -------------------------------------------------------------------------
- CPictHdr::CPictHdr(CPictVf* pForm)
- {
- Height(35);
-
- m_pictBtn1.Init(this, ID_PVF_PICTBTN1, pForm->GetBtnImgList(), 5,5,24,22);
- m_pictBtn2.Init(this, ID_PVF_PICTBTN2, pForm->GetBtnImgList(), 30,5,24,22);
- m_pictBtn3.Init(this, ID_PVF_PICTBTN3, pForm->GetBtnImgList(), 55,5,24,22);
- m_pictBtn4.Init(this, ID_PVF_PICTBTN4, pForm->GetBtnImgList(), 80,5,24,22);
- m_pictBtn5.Init(this, ID_PVF_PICTBTN5, pForm->GetBtnImgList(), 105,5,24,22);
- m_cycle1.Init(this, ID_PVF_CYCLE1, pForm->GetSwitchImg(), 130,7,22,22);
- m_hdrText.Init(this, -1, _T("Click on the animated Buttons!"), 155,7,200,20);
- m_pictBtn6.Init(this, ID_PVF_PICTBTN6, pForm->GetBtnImgList(), 350,5,24,22);
- m_pictBtn7.Init(this, ID_PVF_PICTBTN7, pForm->GetBtnImgList(), 375,5,24,22);
- m_cycle2.Init(this, ID_PVF_CYCLE2, pForm->GetLightedBtnImg(), 420,2,28,28);
-
- m_anim1.Init(this, ID_PVF_ANIM1, pForm->GetPrintAnimImg(), 550,2,32,32);
- m_anim1.Index(0); // Default Picture
- m_anim1.AnimIndex(1,6); // Animation Sequence
- m_anim2.Init(this, ID_PVF_ANIM2, pForm->GetSolodexAnimImg(), 630,2,32,32);
- m_anim2.Index(0); // Default Picture
- m_anim2.AnimIndex(1,5); // Animation Sequence
-
- // m_pictCycle1.Init(this, ID_PVF_PICTCYCLE1, pForm->GetCycleImgList(), 410,5,16,16);
- // m_pictCycle1.PictCount(5);
-
-
- m_pictBtn1.UpIdx(0);
- m_pictBtn1.DownIdx(1);
- m_pictBtn2.UpIdx(2);
- m_pictBtn2.DownIdx(3);
- m_pictBtn3.UpIdx(4);
- m_pictBtn3.DownIdx(5);
- m_pictBtn4.UpIdx(6);
- m_pictBtn4.DownIdx(7);
- m_pictBtn5.UpIdx(8);
- m_pictBtn5.DownIdx(9);
- m_pictBtn6.UpIdx(10);
- m_pictBtn6.DownIdx(11);
- m_pictBtn7.UpIdx(12);
- m_pictBtn7.DownIdx(13);
-
-
- AddCtl(&m_pictBtn1);
- AddCtl(&m_pictBtn2);
- AddCtl(&m_pictBtn3);
- AddCtl(&m_pictBtn4);
- AddCtl(&m_pictBtn5);
- AddCtl(&m_cycle1);
- AddCtl(&m_hdrText);
- AddCtl(&m_pictBtn6);
- AddCtl(&m_pictBtn7);
- AddCtl(&m_cycle2);
- AddCtl(&m_anim1);
- AddCtl(&m_anim2);
- }
-
-
- // -------------------------------------------------------------------------
- // CPictRow Constructor
- // -------------------------------------------------------------------------
- CPictRow::CPictRow()
- {
- m_nameLbl.Init(this, -1, _T("Name"), 10,7,65,20);
- m_name.Init( this, IDPVF_NAME, _T("xxx"), 75,5,150,20);
- m_phoneLbl.Init(this, -1, _T("Phone"), 10,32,65,20);
- m_phone.Init(this, IDPVF_PHONE, _T("xxx"), 75,30,100,20);
- m_addr1Lbl.Init(this, -1, _T("Address 1"), 10,57,65,20);
- m_addr1.Init(this, IDPVF_ADDR1, _T("xxx"), 75,55,250,20);
- m_addr2Lbl.Init(this, -1, _T("Address 2"), 10,82,65,20);
- m_addr2.Init(this, IDPVF_ADDR2, _T("xxx"), 75,80,250,20);
- m_cityLbl.Init(this, -1, _T("City"), 10,107,65,20);
- m_city.Init( this, IDPVF_CITY, _T("xxx"), 75,105,100,20);
- m_stateLbl.Init(this, -1, _T("State"), 180,107,30,20);
- m_state.Init(this, IDPVF_STATE, _T("xxx"), 215,105,30,20);
- m_zipLbl.Init(this, -1, _T("Zip"), 255,107,25,20);
- m_zip.Init( this, IDPVF_ZIP, _T("xxx"), 275,105,50,20);
- m_note.Init( this, IDPVF_NOTE, _T("xxx"), 340,5,350,150);
-
- m_name.LimitText(45); // Set max chars for name
- m_phone.Type(TCKEDIT_MASK);
- m_phone.Mask(_T("(###)###-####Z")); // Set phone mask
- m_zip.Type(TCKEDIT_MASK);
- m_zip.Mask(_T("#####Z")); // Set zip mask
- m_note.LimitText(5000); // Set max chars for note
- m_note.MultiLine(TRUE); // Use a multiline control for the text
-
- AddCtl(&m_nameLbl);
- AddCtl(&m_name);
- AddCtl(&m_phoneLbl);
- AddCtl(&m_phone);
- AddCtl(&m_addr1Lbl);
- AddCtl(&m_addr1);
- AddCtl(&m_addr2Lbl);
- AddCtl(&m_addr2);
- AddCtl(&m_cityLbl);
- AddCtl(&m_city);
- AddCtl(&m_stateLbl);
- AddCtl(&m_state);
- AddCtl(&m_zipLbl);
- AddCtl(&m_zip);
- AddCtl(&m_note);
- SetStyle(VROW_BG_DEFAULT);
- }
-
- // -------------------------------------------------------------------------
- // CPictData Constructor
- // -------------------------------------------------------------------------
- CPictData::CPictData()
- {
- m_name = _T("Gregory Hanks");
- m_phone = _T("(555)435-6789");
- m_addr1 = _T("200 West Striker Lane");
- m_addr2 = _T("Suite 5040");
- m_city = _T("Los Angeles");
- m_state = _T("CA");
- m_zip = _T("60345");
- m_note = _T("This is a Multi-Line Edit field\r\n\r\n");
- m_note += _T("You may place as many lines of text\r\n");
- m_note += _T("here as you would like.\r\n\r\n");
- m_note += _T("Note that the arrow keys will be used by\r\n");
- m_note += _T("the multi-line edit control while you are in it.\r\n");
- m_note += _T("If you need to leave the edit control - use the tab key\r\n");
- m_note += _T("or click on another control with the mouse.\r\n\r\n");
- m_note += _T("Hopefully, this setup give us the best of both worlds!\r\n");
- }
-
- // IMPLEMENT_DYNCREATE(CPictVf, VForm)
-
- BEGIN_MESSAGE_MAP(CPictVf, VForm)
- //{{AFX_MSG_MAP(CPictVf)
- ON_WM_CREATE()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
- // -------------------------------------------------------------------------
- // CPictVf Constructor
- // -------------------------------------------------------------------------
- CPictVf::CPictVf()
- {
- m_pFont = 0; // use default font
- m_nRowHeight = 160; // Big row height
- m_nRowWidth = 690;
- m_nRows = 1; // Just 1 rows
- // AllowAdd(FALSE);
-
- // NOTE - image lists must be created BEFORE they are use (by header)
- if(!m_imgBtnList.Create(IDB_IMG_BTNS, 24, 0, RGB(0,255,255)))
- TRACE(_T("CPictVf could not create image list\n"));
- if(!m_imgCycleList.Create(IDB_IMG_CYCLES, 16, 0, RGB(0,255,255)))
- TRACE(_T("CPictVf could not create cycle image list\n"));
- if(!m_imgPrintAnim.Create(IDB_IMG_BIGPRINT_ANIM, 32, 0, RGB(0,255,255)))
- TRACE(_T("CPictVf could not create print animation image list\n"));
- if(!m_imgSwitch.Create(IDB_IMG_SWITCH, 22, 0, RGB(0,255,255)))
- TRACE(_T("CPictVf could not create switch image list\n"));
- if(!m_imgLightedBtn.Create(IDB_IMG_LIGHTEDBTN, 28, 0, RGB(0,255,255)))
- TRACE(_T("CPictVf could not create lighted button image list\n"));
- if(!m_imgSolodexAnim.Create(IDB_IMG_SOLODEX, 32, 0, RGB(0,255,255)))
- TRACE(_T("CPictVf could not create solodex image list\n"));
-
-
- CPictHdr *pHdr = new CPictHdr(this);
- SetHeader(pHdr, FALSE);
- // SetFooter(pHdr, FALSE); // lets put the header at the bottom
-
- m_pFont = GetFonts()->GetOrAdd(_T("Arial"), 100);
- }
-
- // -------------------------------------------------------------------------
- // Function to create a CPictRow
- // -------------------------------------------------------------------------
- VRow* CPictVf::InitRow()
- {
- CPictRow *pRow = new CPictRow();
- return(pRow);
- }
-
- // -------------------------------------------------------------------------
- // Called when a row needs to be put on the screen
- // -------------------------------------------------------------------------
- BOOL CPictVf::OnGetRow(VRow *pRow)
- {
- CPictRow *r = (CPictRow*) pRow;
- long idx = r->RowId();
- CPictData *pData = &m_data[idx];
-
- r->m_name.Text(pData->m_name);
- r->m_phone.Text(pData->m_phone);
- r->m_addr1.Text(pData->m_addr1);
- r->m_addr2.Text(pData->m_addr2);
- r->m_city.Text(pData->m_city);
- r->m_state.Text(pData->m_state);
- r->m_zip.Text(pData->m_zip);
- r->m_note.Text(pData->m_note);
-
- return TRUE;
- }
-
- // -------------------------------------------------------------------------
- // Called when a row needs to be saved (in the data)
- // -------------------------------------------------------------------------
- BOOL CPictVf::OnSaveRow(VRow *pRow)
- {
- CPictRow *r = (CPictRow*) pRow;
- long idx;
- CPictData *data;
-
- idx = r->RowId();
- data = &m_data[idx];
-
- data->m_name = r->m_name.Text();
- data->m_phone = r->m_phone.Text();
- data->m_addr1 = r->m_addr1.Text();
- data->m_addr2 = r->m_addr2.Text();
- data->m_city = r->m_city.Text();
- data->m_state = r->m_state.Text();
- data->m_zip = r->m_zip.Text();
- data->m_note = r->m_note.Text();
-
- return TRUE;
- }
-
- // -------------------------------------------------------------------------
- // OnAddRow
- // -------------------------------------------------------------------------
- BOOL CPictVf::OnAddRow(VRow *pRow)
- {
- CPictRow *r = (CPictRow*) pRow;
- long idx;
- CPictData *data;
-
- idx = r->RowId();
- data = &m_data[idx];
-
- data->m_name = r->m_name.Text();
- data->m_phone = r->m_phone.Text();
- data->m_addr1 = r->m_addr1.Text();
- data->m_addr2 = r->m_addr2.Text();
- data->m_city = r->m_city.Text();
- data->m_state = r->m_state.Text();
- data->m_zip = r->m_zip.Text();
- data->m_note = r->m_note.Text();
-
- return TRUE;
- }
-
- // -------------------------------------------------------------------------
- // OnStartAdd
- // -------------------------------------------------------------------------
- void CPictVf::OnStartAdd(VRow *pRow)
- {
- CPictRow *r = (CPictRow*) pRow;
- long idx = r->RowId();
- CPictData *data = &m_data[idx];
-
- r->m_name.Text(_T(""));
- r->m_phone.Text(_T(""));
- r->m_addr1.Text(_T(""));
- r->m_addr2.Text(_T(""));
- r->m_city.Text(_T(""));
- r->m_state.Text(_T(""));
- r->m_zip.Text(_T(""));
- r->m_note.Text(_T("- New Customer -"));
- }
-
- // -------------------------------------------------------------------------
- // Called when row(s) needs to be deleted from the data
- // -------------------------------------------------------------------------
- BOOL CPictVf::OnDelete()
- {
- CString s1, s2;
- int i;
-
- long nNumSelected = m_selectedList.Count();
- long nRowId = m_selectedList.First();
-
- s1.Format(_T("You have selected to delete %ld rows"), nNumSelected);
- s1 += _T("\n(*delete is not implemented for this screen)");
- for(i=0; i<nNumSelected; i++)
- {
- if(i > 9)
- {
- s1 += _T("\n too many to list...");
- break;
- }
- s2.Format(_T("\n %ld"), nRowId);
- s1 += s2;
- nRowId = m_selectedList.Next();
- }
- AfxMessageBox(s1);
-
- return TRUE;
- }
-
-
- // -------------------------------------------------------------------------
- // Called when a button is clicked
- // -------------------------------------------------------------------------
- void CPictVf::OnClick(VRow *pRow, int nId)
- {
- CPictRow *r = (CPictRow*) pRow;
- CPictHdr *pHdr = (CPictHdr *)Header();
-
- switch(nId)
- {
- case ID_PVF_PICTBTN1:
- // AfxMessageBox(this, _T("Got a Click 1"));
- break;
- case ID_PVF_PICTBTN2:
- // AfxMessageBox(this, _T("Got a Click 2"));
- break;
- case ID_PVF_PICTBTN3:
- // AfxMessageBox(this, _T("Got a Click 3"));
- break;
- case ID_PVF_PICTBTN4:
- // AfxMessageBox(this, _T("Got a Click 4"));
- break;
- case ID_PVF_PICTBTN5:
- // AfxMessageBox(this, _T("Got a Click 4"));
- break;
- case ID_PVF_ANIM1:
- pHdr->m_anim1.Animate(2); // Run animation sequence 2 times
- break;
- case ID_PVF_ANIM2:
- pHdr->m_anim2.Animate(2); // Run animation sequence 2 times
- break;
- }
- }
-
- // -------------------------------------------------------------------------
- // Start a timer for the form
- // -------------------------------------------------------------------------
- int CPictVf::OnCreate(LPCREATESTRUCT lpCreateStruct)
- {
- if (VForm::OnCreate(lpCreateStruct) == -1)
- return -1;
-
- m_nTimerId = SetTimer(ANIM_TIMER, 150, NULL);
- if(m_nTimerId == 0)
- {
- TRACE(_T("CPictVf::OnCreate - Unable to SetTimer\n"));
- }
-
- return 0;
- }
-
-