Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/ogre/Tools/3dsmaxExport/LEXIExporter/LexiExport/Sources/LexiDialogPoseProperties.cpp @ 45

Last change on this file since 45 was 6, checked in by anonymous, 18 years ago

=…

File size: 6.0 KB
Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of LEXIExporter
4
5Copyright 2006 NDS Limited
6
7Author(s):
8Mark Folkenberg,
9Bo Krohn
10Lasse Tassing
11
12This program is free software; you can redistribute it and/or modify it under
13the terms of the GNU Lesser General Public License as published by the Free Software
14Foundation; either version 2 of the License, or (at your option) any later
15version.
16
17This program is distributed in the hope that it will be useful, but WITHOUT
18ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
20
21You should have received a copy of the GNU Lesser General Public License along with
22this program; if not, write to the Free Software Foundation, Inc., 59 Temple
23Place - Suite 330, Boston, MA 02111-1307, USA, or go to
24http://www.gnu.org/copyleft/lesser.txt.
25-----------------------------------------------------------------------------
26*/
27
28#include "LexiStdAfx.h"
29#include "LexiMaxExport.h"
30#include "LexiDialogPoseProperties.h"
31#include "LexiExportObject.h"
32#include "LexiDialogSelectNode.h"
33
34#include "..\Res\resource.h"
35
36#define _PRINT_DEBUG_INFO_
37//
38
39CPosePropertiesDlg::CPosePropertiesDlg(Window* pParent) : Dialog(IDD_DIALOG_POSEPROPERTIES, DlgProc, pParent)
40{
41        memset(&m_OrgClientRect, 0, sizeof(RECT));     
42        m_pMetaCtrl=0;
43        m_pObj=0;
44        m_pData=0;
45}
46
47CPosePropertiesDlg::~CPosePropertiesDlg()
48{
49        // Destroy meta windows
50        m_pMetaCtrl->Detach();
51        ::DestroyWindow(m_hMetaWnd);
52        delete m_pMetaCtrl;
53}
54
55// Initialize controls from object
56void CPosePropertiesDlg::Init(CDDObject *pMeta, const char *pszDefExt)
57{
58        // Hookup data
59        m_sDefExt=pszDefExt;
60
61        if(!m_pMetaCtrl)
62        {
63                RECT mainrc;
64                GetClientRect(mainrc);
65                ClientToScreen(mainrc);
66
67                // -- animation list created
68
69                RECT childrc;
70
71                GetDlgItem(IDC_OBJECT_CHILD_POSE)->GetClientRect(childrc);
72                GetDlgItem(IDC_OBJECT_CHILD_POSE)->ClientToScreen(childrc);
73
74                int iChildWidth = childrc.right - childrc.left;
75                int iChildHeight = childrc.bottom - childrc.top;
76
77                int iChildX = childrc.left - mainrc.left;
78                int iChildY = childrc.top - mainrc.top;
79
80                m_hMetaWnd = ::CreateWindow("MetaControl", NULL, WS_TABSTOP | WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN, iChildX, iChildY, iChildWidth, iChildHeight, m_hWnd, NULL, CExporter::m_hInstance, NULL);
81
82                m_pMetaCtrl = new GDI::MetaControl;
83                m_pMetaCtrl->Attach(m_hMetaWnd);
84                m_pMetaCtrl->SetDataNotify(this);
85        }
86
87        // Setup meta data and object data
88        m_pMetaCtrl->CreateFromMeta(pMeta);                     
89
90        // Select default control       
91        GotoDlgCtrl(IDC_NAME);
92}
93
94void CPosePropertiesDlg::SetInstance(CDDObject *pData, CExportObject* pObj)
95{
96        m_pData=pData;
97        m_pObj=pObj;
98
99        // Setup defaults
100        GetDlgItem(IDC_NAME)->SetWindowText(pData->GetString("Name", "<unnamed>"));
101        m_pMetaCtrl->SetData(m_pData);
102}
103
104//
105INT_PTR CALLBACK CPosePropertiesDlg::DlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
106{
107        CPosePropertiesDlg* pThis = (CPosePropertiesDlg*)Window::GetMapping(hWnd);
108
109        switch(message)
110        {
111                case WM_INITDIALOG:
112                {
113                        pThis = (CPosePropertiesDlg*)lParam;
114                        Window::AddMapping(pThis, hWnd);               
115                        pThis->OnInitDialog();
116                }       return 0;
117
118                case WM_SIZE:
119                {
120                        pThis->OnSize();
121                } break;               
122
123                case WM_COMMAND:
124                {
125                        switch(LOWORD(wParam))
126                        {
127                                case IDC_NAME:
128                                        if(HIWORD(wParam)==EN_CHANGE)
129                                                pThis->OnNameChange();
130                                        break;
131                        }
132                }       break;
133        }
134        return 0;
135}
136
137//
138void CPosePropertiesDlg::OnInitDialog()
139{
140        GetClientRect(m_OrgClientRect);
141}
142
143void CPosePropertiesDlg::OnSize()
144{
145        // Check if have initialized dialog
146        if(m_OrgClientRect.right==0) return;
147
148        RECT rNewMain;
149        GetClientRect(rNewMain);
150        int iDeltaY=rNewMain.bottom-m_OrgClientRect.bottom;
151        int iDeltaX=rNewMain.right-m_OrgClientRect.right;
152
153        // Get original client rect in screen coordinates
154        RECT rScreenRect;
155        memcpy(&rScreenRect, &m_OrgClientRect, sizeof(RECT));
156        ClientToScreen(rScreenRect);   
157
158        // Begin resize/move of all the controls
159        HDWP hdwp=::BeginDeferWindowPos(8);
160
161        RECT rTemp;
162        Window *pItem;
163        m_pMetaCtrl->GetWindowRect(rTemp);
164        hdwp=::DeferWindowPos(hdwp, m_pMetaCtrl->m_hWnd, NULL, 0, 0, (rTemp.right-rTemp.left)+iDeltaX, (rTemp.bottom-rTemp.top)+iDeltaY, SWP_NOZORDER|SWP_NOMOVE);     
165
166        // Resize object property frame
167        pItem=GetDlgItem(IDC_GROUPBOX_TITLE);
168        pItem->GetWindowRect(rTemp);
169        hdwp=::DeferWindowPos(hdwp, pItem->m_hWnd, NULL, 0, 0, (rTemp.right-rTemp.left)+iDeltaX, (rTemp.bottom-rTemp.top)+iDeltaY, SWP_NOZORDER|SWP_NOMOVE);
170
171        if(iDeltaX!=0)
172        {
173                // Move browse node button
174                //pItem=GetDlgItem(IDC_BROWSENODE);
175                //pItem->GetWindowRect(rTemp);
176                //ScreenToClient(rTemp);
177                //hdwp=::DeferWindowPos(hdwp, pItem->m_hWnd, NULL, rTemp.left+iDeltaX, rTemp.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE);
178
179                //// Move browse filename button
180                //pItem=GetDlgItem(IDC_BROWSEFILE);
181                //pItem->GetWindowRect(rTemp);
182                //ScreenToClient(rTemp);
183                //hdwp=::DeferWindowPos(hdwp, pItem->m_hWnd, NULL, rTemp.left+iDeltaX, rTemp.top, 0, 0, SWP_NOZORDER|SWP_NOSIZE);
184
185                //// Resize node window
186                //pItem=GetDlgItem(IDC_NODE);
187                //pItem->GetWindowRect(rTemp);
188                //hdwp=::DeferWindowPos(hdwp, pItem->m_hWnd, NULL, 0, 0, (rTemp.right-rTemp.left)+iDeltaX, (rTemp.bottom-rTemp.top), SWP_NOZORDER|SWP_NOMOVE);
189
190                // Resize name window
191                pItem=GetDlgItem(IDC_NAME);
192                pItem->GetWindowRect(rTemp);
193                hdwp=::DeferWindowPos(hdwp, pItem->m_hWnd, NULL, 0, 0, (rTemp.right-rTemp.left)+iDeltaX, (rTemp.bottom-rTemp.top), SWP_NOZORDER|SWP_NOMOVE);
194
195                //// Resize filename window
196                //pItem=GetDlgItem(IDC_FILENAME);
197                //pItem->GetWindowRect(rTemp);
198                //hdwp=::DeferWindowPos(hdwp, pItem->m_hWnd, NULL, 0, 0, (rTemp.right-rTemp.left)+iDeltaX, (rTemp.bottom-rTemp.top), SWP_NOZORDER|SWP_NOMOVE);
199        }
200       
201        ::EndDeferWindowPos(hdwp);
202        memcpy(&m_OrgClientRect, &rNewMain, sizeof(RECT));
203}
204
205//
206void CPosePropertiesDlg::OnNameChange()
207{
208        std::string sValue=GetDlgItem(IDC_NAME)->GetWindowText();
209        m_pData->SetString("Name", sValue.c_str());
210}
211
212//
213void CPosePropertiesDlg::OnChanged(const CDDObject *pInstance, const char *pszKey)
214{
215        ::SendMessage(m_hParent, WM_NOTIFY_MESSAGE_ID, 0, 0);
216}
Note: See TracBrowser for help on using the repository browser.