2 ===========================================================================
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
26 ===========================================================================
29 #include "../../idlib/precompiled.h"
34 #include "mediapreviewdlg.h"
37 // CMediaPreviewDlg dialog
39 IMPLEMENT_DYNAMIC(CMediaPreviewDlg, CDialog)
40 CMediaPreviewDlg::CMediaPreviewDlg(CWnd* pParent /*=NULL*/)
41 : CDialog(CMediaPreviewDlg::IDD, pParent)
47 void CMediaPreviewDlg::SetMedia(const char *_media) {
52 void CMediaPreviewDlg::Refresh() {
54 const idMaterial *mat = declManager->FindMaterial("guisurfs/guipreview");
56 drawMaterial.setMedia("guisurfs/guipreview");
57 drawMaterial.setScale( 4.4f );
59 drawMaterial.setMedia(media);
60 drawMaterial.setScale( 1.0f );
62 wndPreview.setDrawable(&drawMaterial);
63 wndPreview.Invalidate();
64 wndPreview.RedrawWindow();
68 CMediaPreviewDlg::~CMediaPreviewDlg()
72 void CMediaPreviewDlg::DoDataExchange(CDataExchange* pDX)
74 CDialog::DoDataExchange(pDX);
75 DDX_Control(pDX, IDC_PREVIEW, wndPreview);
79 BEGIN_MESSAGE_MAP(CMediaPreviewDlg, CDialog)
88 // CMediaPreviewDlg message handlers
90 BOOL CMediaPreviewDlg::OnInitDialog()
92 CDialog::OnInitDialog();
94 wndPreview.setDrawable(&testDrawable);
96 LONG lSize = sizeof(rct);
97 if (LoadRegistryInfo("Radiant::EditPreviewWindow", &rct, &lSize)) {
98 SetWindowPos(NULL, rct.left, rct.top, rct.Width(), rct.Height(), SWP_SHOWWINDOW);
102 int h = (mode == GUIS) ? (rct.Width() - 8) / 1.333333f : rct.Height() - 8;
103 wndPreview.SetWindowPos(NULL, 4, 4, rct.Width() - 8, h, SWP_SHOWWINDOW);
105 return TRUE; // return TRUE unless you set the focus to a control
106 // EXCEPTION: OCX Property Pages should return FALSE
109 void CMediaPreviewDlg::OnSize(UINT nType, int cx, int cy)
111 CDialog::OnSize(nType, cx, cy);
112 if (wndPreview.GetSafeHwnd() == NULL) {
117 //int h = (mode == GUIS) ? (rect.Width() - 8) / 1.333333f : rect.Height() - 8;
118 int h = rect.Height() - 8;
119 wndPreview.SetWindowPos(NULL, 4, 4, rect.Width() - 8, h, SWP_SHOWWINDOW);
122 void CMediaPreviewDlg::OnDestroy()
127 SaveRegistryInfo("Radiant::EditPreviewWindow", &rct, sizeof(rct));
130 CDialog::OnDestroy();
133 void CMediaPreviewDlg::OnLButtonDown(UINT nFlags, CPoint point)
136 idUserInterface *gui = uiManager->FindGui( media );
139 memset( &ev, 0, sizeof( ev ) );
141 ev.evValue = K_MOUSE1;
143 gui->HandleEvent(&ev,0);
146 CDialog::OnLButtonDown(nFlags, point);
149 void CMediaPreviewDlg::OnLButtonUp(UINT nFlags, CPoint point)
152 idUserInterface *gui = uiManager->FindGui( media );
155 memset( &ev, 0, sizeof( ev ) );
157 ev.evValue = K_MOUSE1;
159 gui->HandleEvent(&ev,0);
162 CDialog::OnLButtonUp(nFlags, point);
165 void CMediaPreviewDlg::OnMouseMove(UINT nFlags, CPoint point)
168 idUserInterface *gui = uiManager->FindGui( media );
171 wndPreview.GetClientRect(rct);
173 memset( &ev, 0, sizeof( ev ) );
174 ev.evType = SE_MOUSE;
175 ev.evValue = (point.x / rct.Width()) * 640.0f;
176 ev.evValue2 = (point.y / rct.Height()) * 480.0f;
177 gui->HandleEvent(&ev, 0);
180 CDialog::OnMouseMove(nFlags, point);