Linux multi-monitor fullscreen support
[ryzomcore.git] / nel / tools / logic / logic_editor_dll / VariablePage.cpp
blobef87443b61847c967ebba4c3611f162a5d033222
1 // VariablePage.cpp : implementation file
2 //
4 #include "stdafx.h"
5 #include "logic_editor.h"
6 #include "VariablePage.h"
8 #include "ChildFrm.h"
9 #include "MainFrm.h"
10 #include "logic_editorDoc.h"
12 #include "EditorFormView.h"
14 #ifdef _DEBUG
15 #define new DEBUG_NEW
16 #undef THIS_FILE
17 static char THIS_FILE[] = __FILE__;
18 #endif
20 /////////////////////////////////////////////////////////////////////////////
21 // CVariablePage property page
23 IMPLEMENT_DYNCREATE(CVariablePage, CPropertyPage)
25 CVariablePage::CVariablePage() : CPropertyPage(CVariablePage::IDD)
27 //{{AFX_DATA_INIT(CVariablePage)
28 m_sVarName = _T("");
29 //}}AFX_DATA_INIT
32 CVariablePage::~CVariablePage()
36 void CVariablePage::DoDataExchange(CDataExchange* pDX)
38 CPropertyPage::DoDataExchange(pDX);
39 //{{AFX_DATA_MAP(CVariablePage)
40 DDX_Control(pDX, IDC_LIST_VARIABLES, m_listVariables);
41 DDX_Text(pDX, IDC_EDIT_VARIABLE_NAME, m_sVarName);
42 //}}AFX_DATA_MAP
46 BEGIN_MESSAGE_MAP(CVariablePage, CPropertyPage)
47 //{{AFX_MSG_MAP(CVariablePage)
48 ON_BN_CLICKED(IDC_BUTTON_ADD, OnButtonAdd)
49 ON_LBN_SELCHANGE(IDC_LIST_VARIABLES, OnSelchangeListVariables)
50 ON_BN_CLICKED(IDC_BUTTON_VAR_DELETE, OnButtonVarDelete)
51 ON_BN_CLICKED(IDC_BUTTON_VAR_APPLY, OnButtonVarApply)
52 //}}AFX_MSG_MAP
53 END_MESSAGE_MAP()
55 /////////////////////////////////////////////////////////////////////////////
56 // CVariablePage message handlers
58 BOOL CVariablePage::OnInitDialog()
60 CPropertyPage::OnInitDialog();
62 // TODO: Add extra initialization here
64 return TRUE; // return TRUE unless you set the focus to a control
65 // EXCEPTION: OCX Property Pages should return FALSE
69 //---------------------------------------------------------
70 // addVariable
72 //---------------------------------------------------------
73 void CVariablePage::addVariable( CLogic_editorDoc *pDoc, CString varName )
75 // check if a var or a counter with the same name already exist in the page
76 if( m_listVariables.FindStringExact(0,varName) == LB_ERR )
78 // add the variable in the page
79 m_listVariables.AddString( varName );
82 // if the doc has not been loaded from file, the variable is not yet in doc
83 //void * pointer;
84 if( (pDoc->m_variables.Find(varName) == NULL) )//|| (pDoc->m_counters.Lookup(varName, pointer) == FALSE) )
86 pDoc->m_variables.AddTail( varName );
89 // update page
90 UpdateData(FALSE);
92 } // addVariable //
96 void CVariablePage::OnButtonAdd()
98 UpdateData();
100 if ( m_sVarName.IsEmpty() )
101 return;
103 CMainFrame *pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;
104 // Get the active MDI child window.
105 CChildFrame *pChild = (CChildFrame *) pFrame->GetActiveFrame();
107 CLogic_editorDoc *pDoc = static_cast<CLogic_editorDoc *> (pChild->GetActiveDocument());
108 ASSERT_VALID(pDoc);
110 addVariable( pDoc, m_sVarName );
115 void CVariablePage::OnSelchangeListVariables()
117 const int sel = m_listVariables.GetCurSel();
119 // set the text in the edit box
120 m_listVariables.GetText( sel, m_sVarName );
121 UpdateData(FALSE);
124 void CVariablePage::OnButtonVarDelete()
126 // get the selected variable if any
127 const int sel = m_listVariables.GetCurSel();
129 if (sel != LB_ERR)
131 CString txt;
132 m_listVariables.GetText( sel, txt );
134 m_listVariables.DeleteString( sel );
136 CMainFrame *pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;
137 // Get the active MDI child window.
138 CChildFrame *pChild = (CChildFrame *) pFrame->GetActiveFrame();
140 CLogic_editorDoc *pDoc = static_cast<CLogic_editorDoc *> (pChild->GetActiveDocument());
141 ASSERT_VALID(pDoc);
143 // delete var in doc
144 pDoc->deleteVar( txt );
146 else
148 AfxMessageBox(_T("No variable selected ! Choose a variable first"));
153 void CVariablePage::OnButtonVarApply()
155 UpdateData();
157 // get the selected variable if any
158 const int sel = m_listVariables.GetCurSel();
160 if (sel != LB_ERR)
162 CString txt;
163 m_listVariables.GetText( sel, txt );
165 CMainFrame *pFrame = (CMainFrame*)AfxGetApp()->m_pMainWnd;
166 // Get the active MDI child window.
167 CChildFrame *pChild = (CChildFrame *) pFrame->GetActiveFrame();
169 CLogic_editorDoc *pDoc = static_cast<CLogic_editorDoc *> (pChild->GetActiveDocument());
170 ASSERT_VALID(pDoc);
172 // delete var in doc
173 if ( pDoc->changeVarName( txt, m_sVarName ) == TRUE)
175 m_listVariables.DeleteString( sel );
176 m_listVariables.AddString( m_sVarName );
179 else
181 AfxMessageBox(_T("No variable selected ! Choose a variable first"));