2012-05-29 13:31:11 +00:00
|
|
|
// Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
|
|
|
|
// Copyright (C) 2010 Winch Gate Property Limited
|
|
|
|
//
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU Affero General Public License as
|
|
|
|
// published by the Free Software Foundation, either version 3 of the
|
|
|
|
// License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU Affero General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
// dfn_dialog.cpp : implementation file
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "georges_edit.h"
|
|
|
|
#include "georges_edit_view.h"
|
|
|
|
#include "georges_edit_doc.h"
|
|
|
|
#include "dfn_dialog.h"
|
|
|
|
#include "left_view.h"
|
|
|
|
#include "action.h"
|
|
|
|
|
|
|
|
#include "nel/misc/path.h"
|
|
|
|
#include "nel/georges/type.h"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace NLMISC;
|
|
|
|
using namespace NLGEORGES;
|
|
|
|
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
CDfnDialog::CDfnDialog () : CBaseDialog (IDR_MAINFRAME)
|
|
|
|
{
|
|
|
|
//{{AFX_DATA_INIT(CDfnDialog)
|
|
|
|
// NOTE: the ClassWizard will add member initialization here
|
|
|
|
//}}AFX_DATA_INIT
|
|
|
|
View = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
void CDfnDialog::DoDataExchange(CDataExchange* pDX)
|
|
|
|
{
|
|
|
|
CDialog::DoDataExchange(pDX);
|
|
|
|
//{{AFX_DATA_MAP(CDfnDialog)
|
|
|
|
// NOTE: the ClassWizard will add DDX and DDV calls here
|
|
|
|
//}}AFX_DATA_MAP
|
|
|
|
}
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CDfnDialog, CDialog)
|
|
|
|
//{{AFX_MSG_MAP(CDfnDialog)
|
|
|
|
ON_WM_SIZE()
|
|
|
|
//}}AFX_MSG_MAP
|
|
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
void CDfnDialog::OnSize(UINT nType, int cx, int cy)
|
|
|
|
{
|
|
|
|
CBaseDialog::OnSize(nType, cx, cy);
|
|
|
|
|
|
|
|
// TODO: Add your message handler code here
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
BOOL CDfnDialog::OnInitDialog()
|
|
|
|
{
|
|
|
|
CBaseDialog::OnInitDialog();
|
|
|
|
|
|
|
|
RECT viewRect;
|
|
|
|
View->GetClientRect (&viewRect);
|
|
|
|
uint virtualWidth = std::max ((uint)MinViewWidth, (uint)(viewRect.right-viewRect.left));
|
|
|
|
|
|
|
|
// Refresh sizes
|
|
|
|
CBaseDialog::resizeWidgets (virtualWidth, 0);
|
|
|
|
|
|
|
|
// Get first item coordinate
|
|
|
|
RECT currentPos;
|
|
|
|
getFirstItemPos (currentPos);
|
|
|
|
|
|
|
|
// Create the type combo
|
|
|
|
setStaticSize (currentPos);
|
2016-11-22 11:39:44 +00:00
|
|
|
LabelParents.Create (_T("Parents:"), WS_VISIBLE, currentPos, this);
|
2012-05-29 13:31:11 +00:00
|
|
|
initWidget (LabelParents);
|
|
|
|
getNextPosLabel (currentPos);
|
|
|
|
|
|
|
|
setListSize (currentPos, SmallWidget, ParentHeight);
|
|
|
|
Parents.create (WS_TABSTOP, currentPos, this, LtParents);
|
|
|
|
Parents.insertColumn (0, "Parent Dfn");
|
|
|
|
Parents.Dialog = this;
|
|
|
|
Parents.recalcColumn ();
|
|
|
|
initWidget (Parents);
|
|
|
|
getNextPos (currentPos);
|
|
|
|
|
|
|
|
|
|
|
|
// Create the type combo
|
|
|
|
setStaticSize (currentPos);
|
2016-11-22 11:39:44 +00:00
|
|
|
LabelStruct.Create (_T("Structure:"), WS_VISIBLE, currentPos, this);
|
2012-05-29 13:31:11 +00:00
|
|
|
initWidget (LabelStruct);
|
|
|
|
getNextPosLabel (currentPos);
|
|
|
|
|
|
|
|
setListSize (currentPos, Width, DfnHeight);
|
|
|
|
Struct.create (WS_TABSTOP, currentPos, this, LtStruct);
|
|
|
|
Struct.insertColumn (0, "Name");
|
|
|
|
Struct.insertColumn (1, "Type");
|
|
|
|
Struct.insertColumn (2, "Value");
|
|
|
|
Struct.insertColumn (3, "Default");
|
|
|
|
Struct.insertColumn (4, "FilenameExt");
|
|
|
|
Struct.Dialog = this;
|
|
|
|
Struct.recalcColumn ();
|
|
|
|
initWidget (Struct);
|
|
|
|
getNextPos (currentPos);
|
|
|
|
|
|
|
|
registerLastControl ();
|
|
|
|
|
|
|
|
resizeWidgets ();
|
|
|
|
|
|
|
|
UpdateData (FALSE);
|
|
|
|
|
|
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
|
|
// EXCEPTION: OCX Property Pages should return FALSE
|
|
|
|
}
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
void CDfnDialog::OnOK ()
|
|
|
|
{
|
|
|
|
Parents.UpdateData ();
|
|
|
|
Struct.UpdateData ();
|
|
|
|
|
|
|
|
CWnd *focusWnd = CWnd::GetFocus ();
|
|
|
|
if (focusWnd)
|
|
|
|
{
|
|
|
|
focusWnd = focusWnd->GetParent ();
|
|
|
|
if (focusWnd)
|
|
|
|
{
|
|
|
|
if (focusWnd->m_hWnd == Parents.m_hWnd)
|
|
|
|
{
|
|
|
|
Parents.onOK ();
|
|
|
|
}
|
|
|
|
else if (focusWnd->m_hWnd == Struct.m_hWnd)
|
|
|
|
{
|
|
|
|
Struct.onOK ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
void CDfnDialog::OnCancel ()
|
|
|
|
{
|
|
|
|
CWnd *focusWnd = CWnd::GetFocus ();
|
|
|
|
if (focusWnd)
|
|
|
|
{
|
|
|
|
focusWnd = focusWnd->GetParent ();
|
|
|
|
if (focusWnd)
|
|
|
|
{
|
|
|
|
if (focusWnd->m_hWnd == Parents.m_hWnd)
|
|
|
|
{
|
|
|
|
Parents.onCancel ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if (focusWnd->m_hWnd == Struct.m_hWnd)
|
|
|
|
{
|
|
|
|
Struct.onCancel ();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CBaseDialog::OnCancel ();
|
|
|
|
}
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
void CDfnDialog::getFromDocument (const NLGEORGES::CFormDfn &dfn)
|
|
|
|
{
|
|
|
|
if (View)
|
|
|
|
{
|
|
|
|
// Add the parents
|
|
|
|
Parents.ListCtrl.DeleteAllItems ();
|
|
|
|
uint parent;
|
|
|
|
for (parent=0; parent<dfn.getNumParent (); parent++)
|
|
|
|
{
|
|
|
|
// Add the label and value
|
2016-11-22 12:07:52 +00:00
|
|
|
Parents.ListCtrl.InsertItem (parent, utf8ToTStr(dfn.getParentFilename (parent)));
|
2012-05-29 13:31:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Add the struct element
|
|
|
|
Struct.ListCtrl.DeleteAllItems ();
|
|
|
|
uint elm;
|
|
|
|
for (elm=0; elm<dfn.getNumEntry (); elm++)
|
|
|
|
{
|
|
|
|
// Add the label and value
|
2016-11-22 12:07:52 +00:00
|
|
|
Struct.ListCtrl.InsertItem (elm, utf8ToTStr(dfn.getEntry (elm).getName()));
|
2012-05-29 13:31:11 +00:00
|
|
|
switch (elm, dfn.getEntry (elm).getType ())
|
|
|
|
{
|
|
|
|
case UFormDfn::EntryType:
|
2016-11-22 12:07:52 +00:00
|
|
|
Struct.ListCtrl.SetItemText (elm, 1, dfn.getEntry (elm).getArrayFlag () ? _T("Type array") : _T("Type"));
|
|
|
|
Struct.ListCtrl.SetItemText (elm, 4, utf8ToTStr(dfn.getEntry (elm).getFilenameExt ()));
|
2012-05-29 13:31:11 +00:00
|
|
|
break;
|
|
|
|
case UFormDfn::EntryDfn:
|
2016-11-22 11:39:44 +00:00
|
|
|
Struct.ListCtrl.SetItemText (elm, 1, dfn.getEntry (elm).getArrayFlag () ? _T("Dfn array") : _T("Dfn"));
|
2012-05-29 13:31:11 +00:00
|
|
|
break;
|
|
|
|
case UFormDfn::EntryVirtualDfn:
|
2016-11-22 11:39:44 +00:00
|
|
|
Struct.ListCtrl.SetItemText (elm, 1, _T("Virtual Dfn"));
|
2012-05-29 13:31:11 +00:00
|
|
|
break;
|
|
|
|
}
|
2016-11-22 12:07:52 +00:00
|
|
|
Struct.ListCtrl.SetItemText (elm, 2, utf8ToTStr(dfn.getEntry (elm).getFilename()));
|
|
|
|
Struct.ListCtrl.SetItemText (elm, 3, utf8ToTStr(dfn.getEntry (elm).getDefault()));
|
2012-05-29 13:31:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
void CDfnDialog::setParentsToDocument ()
|
|
|
|
{
|
|
|
|
CGeorgesEditDoc *doc = View->GetDocument ();
|
|
|
|
if (doc)
|
|
|
|
{
|
|
|
|
// Build a vector of string
|
|
|
|
vector<string> vectValue (Parents.ListCtrl.GetItemCount ());
|
|
|
|
|
|
|
|
// For each string
|
|
|
|
uint parent;
|
|
|
|
for (parent=0; parent<(uint)Parents.ListCtrl.GetItemCount (); parent++)
|
|
|
|
{
|
|
|
|
// Add the label and value
|
|
|
|
CString str = Parents.ListCtrl.GetItemText ( parent, 0);
|
2016-11-22 12:07:52 +00:00
|
|
|
vectValue[parent] = tStrToUtf8(str);
|
2012-05-29 13:31:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Modify the document
|
|
|
|
if (!doc->modify (new CActionStringVector (IAction::DfnParents, vectValue, *doc, "", doc->getLeftView ()->getCurrentSelectionId (), 0)))
|
|
|
|
getFromDocument (*doc->getDfnPtr ());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
void CDfnDialog::setStructToDocument ()
|
|
|
|
{
|
|
|
|
CGeorgesEditDoc *doc = View->GetDocument ();
|
|
|
|
if (doc)
|
|
|
|
{
|
|
|
|
// Add the entries
|
|
|
|
vector<vector<string> > stringVector (Struct.ListCtrl.GetItemCount ());
|
|
|
|
uint elm;
|
|
|
|
for (elm=0; elm<stringVector.size (); elm++)
|
|
|
|
{
|
|
|
|
// Resize the array
|
|
|
|
stringVector[elm].resize (5);
|
|
|
|
|
|
|
|
uint subElm;
|
|
|
|
for (subElm = 0; subElm<5; subElm++)
|
|
|
|
{
|
|
|
|
// Get the name
|
|
|
|
CString name= Struct.ListCtrl.GetItemText (elm, subElm);
|
2016-11-22 12:07:52 +00:00
|
|
|
stringVector[elm][subElm] = tStrToUtf8(name);
|
2012-05-29 13:31:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
doc->modify (new CActionStringVectorVector (IAction::DfnStructure, stringVector, *doc, doc->getLeftView ()->getCurrentSelectionId (), 0));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
LRESULT CDfnDialog::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
switch (message)
|
|
|
|
{
|
|
|
|
case LC_CHANGE:
|
|
|
|
if (wParam == LtParents)
|
|
|
|
setParentsToDocument ();
|
|
|
|
else
|
|
|
|
setStructToDocument ();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return CDialog::WindowProc(message, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
CEditListCtrl::TItemEdit CDfnEditListCtrl::getItemEditMode (uint item, uint subItem)
|
|
|
|
{
|
|
|
|
if (subItem == 0)
|
|
|
|
return CEditListCtrl::EditMemCombo;
|
|
|
|
else if (subItem == 1)
|
|
|
|
return CEditListCtrl::EditFixedCombo;
|
|
|
|
else if (subItem == 2)
|
|
|
|
{
|
2016-11-22 12:07:52 +00:00
|
|
|
string type = tStrToUtf8(ListCtrl.GetItemText (item, 1));
|
2012-05-29 13:31:11 +00:00
|
|
|
if (type != "Virtual Dfn")
|
|
|
|
return CEditListCtrl::EditMemCombo;
|
|
|
|
}
|
|
|
|
else if (subItem == 3)
|
|
|
|
{
|
2016-11-22 12:07:52 +00:00
|
|
|
string type = tStrToUtf8(ListCtrl.GetItemText (item, 1));
|
2012-05-29 13:31:11 +00:00
|
|
|
if ((type == "Type") || (type == "Type array"))
|
|
|
|
return CEditListCtrl::EditMemCombo;
|
|
|
|
}
|
|
|
|
else if (subItem == 4)
|
|
|
|
{
|
2016-11-22 12:07:52 +00:00
|
|
|
string type = tStrToUtf8(ListCtrl.GetItemText (item, 1));
|
2012-05-29 13:31:11 +00:00
|
|
|
if ((type == "Type") || (type == "Type array"))
|
|
|
|
return CEditListCtrl::EditMemCombo;
|
|
|
|
}
|
|
|
|
return CEditListCtrl::NoEdit;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
void CDfnEditListCtrl::getComboBoxStrings (uint item, uint subItem, std::vector<std::string> &retStrings)
|
|
|
|
{
|
|
|
|
if (subItem == 1)
|
|
|
|
{
|
|
|
|
retStrings.reserve (5);
|
|
|
|
retStrings.push_back ("Type");
|
|
|
|
retStrings.push_back ("Dfn");
|
|
|
|
retStrings.push_back ("Virtual Dfn");
|
|
|
|
retStrings.push_back ("Type array");
|
|
|
|
retStrings.push_back ("Dfn array");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
void CDfnEditListCtrl::getMemComboBoxProp (uint item, uint subItem, std::string ®Adr, bool &browse)
|
|
|
|
{
|
|
|
|
if (subItem == 0)
|
|
|
|
{
|
|
|
|
browse = false;
|
|
|
|
regAdr = GEORGES_EDIT_BASE_REG_KEY"\\Label MemCombo";
|
|
|
|
}
|
|
|
|
else if (subItem == 2)
|
|
|
|
{
|
|
|
|
browse = true;
|
|
|
|
|
|
|
|
// Get type string
|
2016-11-22 12:07:52 +00:00
|
|
|
string type = tStrToUtf8(ListCtrl.GetItemText (item, 1));
|
2012-05-29 13:31:11 +00:00
|
|
|
if ((type == "Type") || (type == "Type array"))
|
|
|
|
regAdr = GEORGES_EDIT_BASE_REG_KEY"\\Type MemCombo";
|
|
|
|
else if ((type == "Dfn") || (type == "Dfn array"))
|
|
|
|
regAdr = GEORGES_EDIT_BASE_REG_KEY"\\Dfn MemCombo";
|
|
|
|
}
|
|
|
|
else if (subItem == 3)
|
|
|
|
{
|
|
|
|
browse = false;
|
|
|
|
regAdr = GEORGES_EDIT_BASE_REG_KEY"\\Default MemCombo";
|
|
|
|
}
|
|
|
|
else if (subItem == 3)
|
|
|
|
{
|
|
|
|
browse = false;
|
|
|
|
regAdr = GEORGES_EDIT_BASE_REG_KEY"\\FilenameExt MemCombo";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
void CDfnEditListCtrl::getNewItemText (uint item, uint subItem, std::string &ret)
|
|
|
|
{
|
|
|
|
if (subItem == 0)
|
|
|
|
ret = "new";
|
|
|
|
else if (subItem == 1)
|
|
|
|
ret = "Type";
|
|
|
|
else if (subItem == 2)
|
|
|
|
ret = theApp.DefaultType;
|
|
|
|
else if (subItem == 3)
|
2016-11-20 13:49:13 +00:00
|
|
|
ret.clear();
|
2012-05-29 13:31:11 +00:00
|
|
|
else if (subItem == 4)
|
2016-11-20 13:49:13 +00:00
|
|
|
ret.clear();
|
2012-05-29 13:31:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
void CDfnEditListCtrl::getBrowseInfo (uint item, uint subItem, std::string &defExt, std::string &defFilename, std::string &defDir, std::string &filter)
|
|
|
|
{
|
|
|
|
if (subItem == 2)
|
|
|
|
{
|
|
|
|
// Get type string
|
2016-11-22 12:07:52 +00:00
|
|
|
string type = tStrToUtf8(ListCtrl.GetItemText (item, 1));
|
2012-05-29 13:31:11 +00:00
|
|
|
if ((type == "Type") || (type == "Type array"))
|
|
|
|
{
|
|
|
|
filter = TypeFilter;
|
|
|
|
defDir = theApp.RootSearchPath;
|
|
|
|
defFilename = "*.typ";
|
|
|
|
defExt = "*.typ";
|
|
|
|
}
|
|
|
|
else if ((type == "Dfn") || (type == "Dfn array"))
|
|
|
|
{
|
|
|
|
filter = DfnFilter;
|
|
|
|
defDir = theApp.RootSearchPath;
|
|
|
|
defFilename = "*.dfn";
|
|
|
|
defExt = "*.dfn";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
void CDfnEditListCtrl::onItemChanged (uint item, uint subItem)
|
|
|
|
{
|
|
|
|
if (subItem == 1)
|
|
|
|
{
|
|
|
|
// Get type string
|
2016-11-22 12:07:52 +00:00
|
|
|
string type = tStrToUtf8(ListCtrl.GetItemText (item, 1));
|
2012-05-29 13:31:11 +00:00
|
|
|
if ((type == "Type") || (type == "Type array"))
|
|
|
|
{
|
|
|
|
CString str;
|
|
|
|
str = Dialog->Struct.ListCtrl.GetItemText (item, 2);
|
2016-11-22 18:34:43 +00:00
|
|
|
std::string ext = NLMISC::CFile::getExtension(tStrToUtf8(str));
|
|
|
|
if (ext == "typ")
|
|
|
|
Dialog->Struct.ListCtrl.SetItemText (item, 2, utf8ToTStr(theApp.DefaultType));
|
2012-05-29 13:31:11 +00:00
|
|
|
}
|
|
|
|
else if ((type == "Dfn") || (type == "Dfn array"))
|
|
|
|
{
|
|
|
|
CString str;
|
|
|
|
str = Dialog->Struct.ListCtrl.GetItemText (item, 2);
|
2016-11-22 18:34:43 +00:00
|
|
|
std::string ext = NLMISC::CFile::getExtension(tStrToUtf8(str));
|
|
|
|
if (ext == "dfn")
|
|
|
|
Dialog->Struct.ListCtrl.SetItemText (item, 2, utf8ToTStr(theApp.DefaultDfn));
|
2012-05-29 13:31:11 +00:00
|
|
|
|
|
|
|
// Clear default value
|
2016-11-22 11:39:44 +00:00
|
|
|
Dialog->Struct.ListCtrl.SetItemText (item, 3, _T(""));
|
2012-05-29 13:31:11 +00:00
|
|
|
}
|
|
|
|
else if (type == "Virtual Dfn")
|
|
|
|
{
|
|
|
|
// Clear the value
|
2016-11-22 11:39:44 +00:00
|
|
|
Dialog->Struct.ListCtrl.SetItemText (item, 2, _T(""));
|
2012-05-29 13:31:11 +00:00
|
|
|
|
|
|
|
// Clear default value
|
2016-11-22 11:39:44 +00:00
|
|
|
Dialog->Struct.ListCtrl.SetItemText (item, 3, _T(""));
|
2012-05-29 13:31:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
void CDfnDialog::onOpenSelected ()
|
|
|
|
{
|
|
|
|
Parents.UpdateData ();
|
|
|
|
Struct.UpdateData ();
|
|
|
|
|
|
|
|
CWnd *focusWnd = CWnd::GetFocus ();
|
|
|
|
if (focusWnd)
|
|
|
|
{
|
|
|
|
focusWnd = focusWnd->GetParent ();
|
|
|
|
if (focusWnd)
|
|
|
|
{
|
|
|
|
if (focusWnd->m_hWnd == Parents.m_hWnd)
|
|
|
|
{
|
|
|
|
// For each selected
|
|
|
|
POSITION pos = Parents.ListCtrl.GetFirstSelectedItemPosition();
|
|
|
|
while (pos)
|
|
|
|
{
|
|
|
|
int nItem = Parents.ListCtrl.GetNextSelectedItem(pos);
|
|
|
|
|
|
|
|
// Get the string
|
2016-11-22 12:07:52 +00:00
|
|
|
std::string str = tStrToUtf8(Parents.ListCtrl.GetItemText (nItem, 0));
|
|
|
|
if (!str.empty())
|
2012-05-29 13:31:11 +00:00
|
|
|
{
|
|
|
|
// Look for the file
|
2016-11-22 12:07:52 +00:00
|
|
|
string name = CPath::lookup (str, false, false);
|
2012-05-29 13:31:11 +00:00
|
|
|
if (name.empty ())
|
|
|
|
name = str;
|
|
|
|
|
|
|
|
// Open the file
|
2016-11-22 12:07:52 +00:00
|
|
|
theApp.OpenDocumentFile (utf8ToTStr(name));
|
2012-05-29 13:31:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (focusWnd->m_hWnd == Struct.m_hWnd)
|
|
|
|
{
|
|
|
|
// For each selected
|
|
|
|
POSITION pos = Struct.ListCtrl.GetFirstSelectedItemPosition();
|
|
|
|
while (pos)
|
|
|
|
{
|
|
|
|
int nItem = Struct.ListCtrl.GetNextSelectedItem(pos);
|
|
|
|
|
|
|
|
// Get the string
|
2016-11-22 12:07:52 +00:00
|
|
|
std::string str = tStrToUtf8(Struct.ListCtrl.GetItemText (nItem, 2));
|
|
|
|
if (!str.empty())
|
2012-05-29 13:31:11 +00:00
|
|
|
{
|
|
|
|
// Look for the file
|
2016-11-22 12:07:52 +00:00
|
|
|
string name = CPath::lookup (str, false, false);
|
2012-05-29 13:31:11 +00:00
|
|
|
if (name.empty ())
|
|
|
|
name = str;
|
|
|
|
|
|
|
|
// Open the file
|
2016-11-22 12:07:52 +00:00
|
|
|
theApp.OpenDocumentFile (utf8ToTStr(name));
|
2012-05-29 13:31:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
void CDfnDialog::OnSetFocus(CWnd* pOldWnd)
|
|
|
|
{
|
|
|
|
CBaseDialog::OnSetFocus(pOldWnd);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
CWnd* CDfnDialog::GetNextDlgTabItem( CWnd* pWndCtl, BOOL bPrevious) const
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
void CDfnDialog::onFirstFocus ()
|
|
|
|
{
|
|
|
|
View->SetFocus ();
|
|
|
|
}
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
void CDfnDialog::onLastFocus ()
|
|
|
|
{
|
|
|
|
View->setFocusLeftView ();
|
|
|
|
}
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
void CDfnDialog::resizeWidgets ()
|
|
|
|
{
|
|
|
|
RECT viewRect;
|
|
|
|
View->GetClientRect (&viewRect);
|
|
|
|
uint virtualWidth = std::max ((uint)MinViewWidth, (uint)(viewRect.right-viewRect.left));
|
|
|
|
|
|
|
|
// Refresh sizes
|
|
|
|
CBaseDialog::resizeWidgets (virtualWidth, 0);
|
|
|
|
|
|
|
|
// Get first item coordinate
|
|
|
|
RECT currentPos;
|
|
|
|
getFirstItemPos (currentPos);
|
|
|
|
setStaticSize (currentPos);
|
|
|
|
getNextPosLabel (currentPos);
|
|
|
|
setListSize (currentPos, SmallWidget, ParentHeight);
|
|
|
|
getNextPos (currentPos);
|
|
|
|
setStaticSize (currentPos);
|
|
|
|
getNextPosLabel (currentPos);
|
|
|
|
setListSize (currentPos, Width, DfnHeight);
|
|
|
|
getNextPos (currentPos);
|
|
|
|
|
|
|
|
// Refresh sizes
|
|
|
|
CBaseDialog::resizeWidgets (virtualWidth, currentPos.bottom);
|
|
|
|
|
|
|
|
// Get first item coordinate
|
|
|
|
currentPos;
|
|
|
|
getFirstItemPos (currentPos);
|
|
|
|
|
|
|
|
// Create the type combo
|
|
|
|
setStaticSize (currentPos);
|
|
|
|
LabelParents.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left,
|
|
|
|
currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER);
|
|
|
|
getNextPosLabel (currentPos);
|
|
|
|
|
|
|
|
setListSize (currentPos, SmallWidget, ParentHeight);
|
|
|
|
Parents.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left,
|
|
|
|
currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER);
|
|
|
|
Parents.recalcColumn ();
|
|
|
|
getNextPos (currentPos);
|
|
|
|
|
|
|
|
// Create the type combo
|
|
|
|
setStaticSize (currentPos);
|
|
|
|
LabelStruct.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left,
|
|
|
|
currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER);
|
|
|
|
getNextPosLabel (currentPos);
|
|
|
|
|
|
|
|
setListSize (currentPos, Width, DfnHeight + AdjusteHeight);
|
|
|
|
Struct.SetWindowPos (NULL, currentPos.left, currentPos.top, currentPos.right - currentPos.left,
|
|
|
|
currentPos.bottom - currentPos.top, SWP_NOZORDER|SWP_NOOWNERZORDER);
|
|
|
|
Struct.recalcColumn ();
|
|
|
|
getNextPos (currentPos);
|
|
|
|
|
|
|
|
// Resize the current view
|
|
|
|
View->setViewSize (
|
|
|
|
virtualWidth,
|
|
|
|
currentPos.bottom+CGeorgesEditView::WidgetTopMargin+CGeorgesEditView::WidgetBottomMargin);
|
|
|
|
}
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
// CDfnParentEditListCtrl
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
CEditListCtrl::TItemEdit CDfnParentEditListCtrl::getItemEditMode (uint item, uint subItem)
|
|
|
|
{
|
|
|
|
return CEditListCtrl::EditMemCombo;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
void CDfnParentEditListCtrl::getMemComboBoxProp (uint item, uint subItem, std::string ®Adr, bool &browse)
|
|
|
|
{
|
|
|
|
browse = true;
|
|
|
|
regAdr = GEORGES_EDIT_BASE_REG_KEY"\\Dfn MemCombo";
|
|
|
|
}
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
void CDfnParentEditListCtrl::getNewItemText (uint item, uint subItem, std::string &ret)
|
|
|
|
{
|
|
|
|
ret = theApp.DefaultDfn;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ***************************************************************************
|
|
|
|
|
|
|
|
void CDfnParentEditListCtrl::getBrowseInfo (uint item, uint subItem, std::string &defExt, std::string &defFilename, std::string &defDir, std::string &filter)
|
|
|
|
{
|
|
|
|
filter = DfnFilter;
|
|
|
|
defDir = theApp.RootSearchPath;
|
|
|
|
defFilename = "*.dfn";
|
|
|
|
defExt = "*.dfn";
|
|
|
|
}
|