Garmin Fleet Management Controller  2.19.0
CAutoArrivalDlg.cpp
Go to the documentation of this file.
1 /*********************************************************************
2 *
3 * MODULE NAME:
4 * CAutoArrivalDlg.cpp
5 *
6 * Copyright 2008-2009 by Garmin Ltd. or its subsidiaries.
7 *---------------------------------------------------------------------
8 * $NoKeywords$
9 *********************************************************************/
10 #include "stdafx.h"
11 #include "CAutoArrivalDlg.h"
12 
13 IMPLEMENT_DYNAMIC( CAutoArrivalDlg, CDialog )
14 
15 BEGIN_MESSAGE_MAP( CAutoArrivalDlg, CDialog )
16  ON_BN_CLICKED( IDC_AUTOARR_CHK_ENABLED, OnBnClickedEnabled )
17  ON_EN_CHANGE( IDC_AUTOARR_EDIT_TIME, OnEnChangeEditBox )
18  ON_EN_CHANGE( IDC_AUTOARR_EDIT_DISTANCE, OnEnChangeEditBox )
19  ON_BN_CLICKED( IDOK, OnBnClickedOk )
20 END_MESSAGE_MAP()
21 
22 //----------------------------------------------------------------------
26 //----------------------------------------------------------------------
27 CAutoArrivalDlg::CAutoArrivalDlg
28  (
29  CWnd * aParent,
30  FmiApplicationLayer & aCom
31  )
32  : CDialog( IDD_AUTO_ARRIVAL, aParent )
33  , mCom( aCom )
34  , mAutoArrivalEnabled( FALSE )
35  , mMinimumStopTime( _T("") )
36  , mMinimumStopDistance( _T("") )
37 {
38 }
39 
40 //----------------------------------------------------------------------
42 //----------------------------------------------------------------------
44 {
45 }
46 
47 //----------------------------------------------------------------------
50 //----------------------------------------------------------------------
52  (
53  CDataExchange * aDataExchange
54  )
55 {
56  CDialog::DoDataExchange( aDataExchange );
57 
58  DDX_Check( aDataExchange, IDC_AUTOARR_CHK_ENABLED, mAutoArrivalEnabled );
59  DDX_Text( aDataExchange, IDC_AUTOARR_EDIT_TIME, mMinimumStopTime );
60  DDX_Text( aDataExchange, IDC_AUTOARR_EDIT_DISTANCE, mMinimumStopDistance );
61 }
62 
63 //----------------------------------------------------------------------
68 //----------------------------------------------------------------------
70 {
71  CDialog::OnInitDialog();
72 
73  mAutoArrivalEnabled = TRUE; //doesn't have to be checked, looks better though
74  UpdateData( FALSE );
75 
76  return TRUE;
77 } /* OnInitDialog() */
78 
79 //----------------------------------------------------------------------
86 //----------------------------------------------------------------------
88 {
89  UpdateData( TRUE );
91  {
92  if( mMinimumStopTime != "" && mMinimumStopDistance != "" )
93  {
94  GetDlgItem( IDOK )->EnableWindow( TRUE );
95  }
96  else
97  {
98  GetDlgItem( IDOK )->EnableWindow( FALSE );
99  }
100  GetDlgItem( IDC_AUTOARR_EDIT_TIME )->EnableWindow( TRUE );
101  GetDlgItem( IDC_AUTOARR_EDIT_DISTANCE )->EnableWindow( TRUE );
102  }
103  else
104  {
105  mMinimumStopTime.Format( _T("") );
106  mMinimumStopDistance.Format( _T("") );
107  UpdateData( FALSE );
108  GetDlgItem( IDC_AUTOARR_EDIT_TIME )->EnableWindow( FALSE );
109  GetDlgItem( IDC_AUTOARR_EDIT_DISTANCE )->EnableWindow( FALSE );
110  GetDlgItem( IDOK )->EnableWindow( TRUE );
111  }
112 } /* OnBnClickedEnable() */
113 
114 //----------------------------------------------------------------------
119 //----------------------------------------------------------------------
121 {
122  UpdateData( TRUE );
123  if( mMinimumStopTime != "" && mMinimumStopDistance != "" )
124  {
125  GetDlgItem( IDOK )->EnableWindow( TRUE );
126  }
127  else
128  {
129  GetDlgItem( IDOK )->EnableWindow( FALSE );
130  }
131 } /* OnEnChangeEditBox() */
132 
133 //----------------------------------------------------------------------
140 //----------------------------------------------------------------------
142 {
143  UpdateData( TRUE );
144  if( mAutoArrivalEnabled )
145  {
147  (
148  _ttoi( mMinimumStopTime.GetBuffer() ),
149  _ttoi( mMinimumStopDistance.GetBuffer() )
150  );
151  }
152  else
153  {
155  }
156  OnOK();
157 } /* OnBnClickedOk() */
void sendAutoArrival(uint32 aArrivalTime, uint32 aArrivalDistance)
Send a request to update the auto-arrival preferences.
BOOL OnInitDialog()
This function is called when the window is created.
virtual void DoDataExchange(CDataExchange *aDataExchange)
Perform dialog data exchange and validation.
#define IDC_AUTOARR_EDIT_TIME
Definition: resource.h:150
#define FALSE
Definition: garmin_types.h:46
BOOL mAutoArrivalEnabled
The state of the Enabled check box.
CString mMinimumStopDistance
The minimum distance for a stop to be considered done by the client.
#define TRUE
Definition: garmin_types.h:45
#define INVALID32
Placeholder for an invalid 32-bit value.
Definition: fmi.h:139
Serial communication controller for Garmin and FMI packets.
#define IDC_AUTOARR_EDIT_DISTANCE
Definition: resource.h:149
CString mMinimumStopTime
The minimum stop time for a stop to be considered done by the client.
virtual ~CAutoArrivalDlg()
Destructor.
#define IDD_AUTO_ARRIVAL
Definition: resource.h:16
afx_msg void OnEnChangeEditBox()
Edit handler for the edit boxes on this dialog.
#define IDC_AUTOARR_CHK_ENABLED
Definition: resource.h:148
afx_msg void OnBnClickedOk()
Button handler for the OK button on this dialog.
FmiApplicationLayer & mCom
Reference to the FMI communication controller that this dialog uses.
afx_msg void OnBnClickedEnabled()
Button handler for the Enabled check box.
Dialog allowing the user to change the auto-arrival options.