2 * Copyright (C) 2003-2006 Gabest
3 * http://www.gabest.org
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with GNU Make; see the file COPYING. If not, write to
17 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18 * http://www.gnu.org/copyleft/gpl.html
22 // ConvertPropsDlg.cpp : implementation file
27 #include "ConvertPropsDlg.h"
30 // CConvertPropsDlg dialog
32 CConvertPropsDlg::CConvertPropsDlg(bool fPin
, CWnd
* pParent
/*=NULL*/)
33 : CResizableDialog(CConvertPropsDlg::IDD
, pParent
)
38 CConvertPropsDlg::~CConvertPropsDlg()
42 void CConvertPropsDlg::DoDataExchange(CDataExchange
* pDX
)
44 __super::DoDataExchange(pDX
);
45 DDX_Control(pDX
, IDC_COMBO1
, m_fcc
);
46 DDX_Control(pDX
, IDC_EDIT1
, m_text
);
47 DDX_Control(pDX
, IDC_LIST1
, m_list
);
51 BEGIN_MESSAGE_MAP(CConvertPropsDlg
, CResizableDialog
)
52 ON_NOTIFY(NM_CLICK
, IDC_LIST1
, OnNMClickList1
)
53 ON_BN_CLICKED(IDC_BUTTON1
, OnBnClickedButton1
)
54 ON_UPDATE_COMMAND_UI(IDC_BUTTON1
, OnUpdateButton1
)
55 ON_CBN_EDITCHANGE(IDC_COMBO1
, OnCbnEditchangeCombo1
)
56 ON_CBN_SELCHANGE(IDC_COMBO1
, OnCbnSelchangeCombo1
)
57 ON_NOTIFY(LVN_KEYDOWN
, IDC_LIST1
, OnLvnKeydownList1
)
61 // CConvertPropsDlg message handlers
63 BOOL
CConvertPropsDlg::OnInitDialog()
65 __super::OnInitDialog();
67 AddAnchor(IDC_COMBO1
, TOP_LEFT
);
68 AddAnchor(IDC_EDIT1
, TOP_LEFT
, TOP_RIGHT
);
69 AddAnchor(IDC_BUTTON1
, TOP_RIGHT
);
70 AddAnchor(IDC_LIST1
, TOP_LEFT
, BOTTOM_RIGHT
);
71 AddAnchor(IDOK
, BOTTOM_CENTER
);
72 AddAnchor(IDCANCEL
, BOTTOM_CENTER
);
76 m_fcc
.AddString(_T("NAME"));
77 m_fcc
.AddString(_T("LANG"));
78 m_fcc
.AddString(_T("DESC"));
79 m_fcc
.AddString(_T("SGRP"));
83 m_fcc
.AddString(_T("TITL"));
84 m_fcc
.AddString(_T("AUTH"));
85 m_fcc
.AddString(_T("RTNG"));
86 m_fcc
.AddString(_T("CPYR"));
87 m_fcc
.AddString(_T("DESC"));
90 m_list
.InsertColumn(0, _T("ID"), LVCFMT_LEFT
, 75);
91 m_list
.InsertColumn(1, _T("Text"), LVCFMT_LEFT
, 280);
93 m_list
.SetExtendedStyle(m_list
.GetExtendedStyle()|LVS_EX_FULLROWSELECT
);
95 POSITION pos
= m_props
.GetStartPosition();
99 m_props
.GetNextAssoc(pos
, key
, value
);
103 return TRUE
; // return TRUE unless you set the focus to a control
104 // EXCEPTION: OCX Property Pages should return FALSE
107 void CConvertPropsDlg::SetItem(CString key
, CString value
)
110 fi
.flags
= LVFI_STRING
;
113 int i
= m_list
.FindItem(&fi
);
114 if(i
< 0) i
= m_list
.InsertItem(m_list
.GetItemCount(), _T(""));
121 m_list
.DeleteItem(i
);
125 if(key
== _T("LANG") && value
.GetLength() != 3)
127 m_list
.DeleteItem(i
);
128 AfxMessageBox(_T("LANG has to be a three letter ISO 639-2 language code."), MB_OK
);
132 m_list
.SetItemText(i
, 0, key
);
133 m_list
.SetItemText(i
, 1, value
);
136 void CConvertPropsDlg::OnOK()
140 for(int i
= 0; i
< m_list
.GetItemCount(); i
++)
141 m_props
[m_list
.GetItemText(i
, 0)] = m_list
.GetItemText(i
, 1);
146 void CConvertPropsDlg::OnNMClickList1(NMHDR
*pNMHDR
, LRESULT
*pResult
)
148 LPNMLISTVIEW lpnmlv
= (LPNMLISTVIEW
)pNMHDR
;
150 if(lpnmlv
->iItem
>= 0)
152 m_fcc
.SetWindowText(m_list
.GetItemText(lpnmlv
->iItem
, 0));
153 m_text
.SetWindowText(m_list
.GetItemText(lpnmlv
->iItem
, 1));
159 void CConvertPropsDlg::OnBnClickedButton1()
162 m_fcc
.GetWindowText(key
);
163 m_text
.GetWindowText(value
);
164 if(key
.GetLength() != 4) {AfxMessageBox(_T("ID must be 4 characters long!"), MB_OK
); return;}
168 void CConvertPropsDlg::OnUpdateButton1(CCmdUI
* pCmdUI
)
170 pCmdUI
->Enable(GetDlgItem(IDC_EDIT1
)->GetWindowTextLength() > 0);
173 void CConvertPropsDlg::OnCbnEditchangeCombo1()
175 int i
= m_fcc
.GetCurSel();
179 m_fcc
.GetLBText(i
, key
);
182 fi
.flags
= LVFI_STRING
;
185 i
= m_list
.FindItem(&fi
);
186 if(i
> 0) m_text
.SetWindowText(m_list
.GetItemText(i
, 1));
189 void CConvertPropsDlg::OnCbnSelchangeCombo1()
191 OnCbnEditchangeCombo1();
194 void CConvertPropsDlg::OnLvnKeydownList1(NMHDR
*pNMHDR
, LRESULT
*pResult
)
196 LPNMLVKEYDOWN pLVKeyDow
= reinterpret_cast<LPNMLVKEYDOWN
>(pNMHDR
);
198 int i
= m_fcc
.GetCurSel();
199 if(i
>= 0) m_list
.DeleteItem(i
);