28 #include "../../idlib/precompiled.h"
37 ON_NOTIFY_REFLECT(LVN_ITEMCHANGED, OnLvnItemchanged)
38 ON_NOTIFY_REFLECT(LVN_DELETEALLITEMS, OnLvnDeleteallitems)
39 ON_NOTIFY_REFLECT(LVN_BEGINDRAG, OnLvnBegindrag)
42 ON_NOTIFY_REFLECT(NM_RCLICK, OnNMRclick)
55 ON_NOTIFY_REFLECT(LVN_BEGINLABELEDIT, OnLvnBeginlabeledit)
56 ON_NOTIFY_REFLECT(LVN_ENDLABELEDIT, OnLvnEndlabeledit)
63 StageView::StageView() {
64 currentMaterial =
NULL;
66 internalChange =
false;
92 CListCtrl& list = GetListCtrl();
96 for(
int i = 1;
i < list.GetItemCount();
i++) {
109 CListCtrl& list = GetListCtrl();
113 int index = list.InsertItem(stageNum+1, name.
c_str());
123 CListCtrl& list = GetListCtrl();
124 list.DeleteItem(stageNum+1);
139 CListCtrl& list = GetListCtrl();
143 ZeroMemory(&lvi,
sizeof(LV_ITEM));
144 lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE | LVIF_PARAM;
145 lvi.stateMask = LVIS_DROPHILITED | LVIS_FOCUSED | LVIS_SELECTED;
146 lvi.pszText = szLabel;
148 lvi.cchTextMax = 255;
152 list.DeleteItem(from);
156 list.InsertItem(&lvi);
187 CListCtrl& list = GetListCtrl();
197 CListCtrl& list = GetListCtrl();
198 POSITION pos = list.GetFirstSelectedItemPosition();
201 nItem = list.GetNextSelectedItem(pos);
229 CListCtrl& list = GetListCtrl();
230 POSITION pos = list.GetFirstSelectedItemPosition();
233 nItem = list.GetNextSelectedItem(pos);
246 CListCtrl& list = GetListCtrl();
248 POSITION pos = list.GetFirstSelectedItemPosition();
251 nItem = list.GetNextSelectedItem(pos);
269 CListCtrl& list = GetListCtrl();
271 POSITION pos = list.GetFirstSelectedItemPosition();
272 int selectedItem = -1;
274 selectedItem = list.GetNextSelectedItem(pos);
276 list.DeleteAllItems();
281 list.InsertItem(0,
"Material");
286 for(
int i = 0;
i < stageCount;
i++) {
289 int itemNum = list.InsertItem(list.GetItemCount(),
name);
298 if(selectedItem < 0) {
300 list.SetItemState(0, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
302 list.SetItemState(selectedItem, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
324 LPNMLISTVIEW pNMLV =
reinterpret_cast<LPNMLISTVIEW
>(pNMHDR);
329 if(pNMLV->uChanged && LVIF_STATE && pNMLV->uNewState & LVIS_SELECTED) {
333 if(pNMLV->iItem >= 0) {
334 if(pNMLV->iItem == 0)
352 if(pNMLV->uChanged && LVIF_STATE && pNMLV->uOldState & LVIS_SELECTED && !(pNMLV->uNewState & LVIS_SELECTED)) {
355 CListCtrl& list = GetListCtrl();
356 POSITION pos = list.GetFirstSelectedItemPosition();
368 LPNMLISTVIEW pNMLV =
reinterpret_cast<LPNMLISTVIEW
>(pNMHDR);
380 LPNMLISTVIEW pNMLV =
reinterpret_cast<LPNMLISTVIEW
>(pNMHDR);
382 CListCtrl& list = GetListCtrl();
385 if(pNMLV->iItem > 0) {
391 list.ModifyStyle(LVS_OWNERDRAWFIXED, 0);
399 dragImage->DragEnter(GetDesktopWindow(), pNMLV->ptAction);
402 list.ModifyStyle(0, LVS_OWNERDRAWFIXED);
425 dragImage->DragLeave(GetDesktopWindow());
439 ToggleListView::OnLButtonUp(nFlags, point);
459 ToggleListView::OnMouseMove(nFlags, point);
467 CListCtrl& list = GetListCtrl();
469 DWORD dwPos = GetMessagePos();
471 CPoint pt( LOWORD( dwPos ), HIWORD ( dwPos ) );
474 list.ScreenToClient( &spt );
486 CListCtrl& list = GetListCtrl();
487 POSITION pos = list.GetFirstSelectedItemPosition();
490 nItem = list.GetNextSelectedItem(pos);
491 list.EditLabel(nItem);
500 CListCtrl& list = GetListCtrl();
501 POSITION pos = list.GetFirstSelectedItemPosition();
504 nItem = list.GetNextSelectedItem(pos);
506 int result = MessageBox(
"Are you sure you want to delete this stage?",
"Delete?", MB_ICONQUESTION | MB_YESNO);
507 if(result == IDYES) {
520 int result = MessageBox(
"Are you sure you want to delete all stages?",
"Delete?", MB_ICONQUESTION | MB_YESNO);
521 if(result == IDYES) {
568 CListCtrl& list = GetListCtrl();
570 POSITION pos = list.GetFirstSelectedItemPosition();
573 nItem = list.GetNextSelectedItem(pos);
593 int existingIndex = material->
FindStage(type, name);
598 if(MessageBox(
va(
"Do you want to replace '%s' stage?", name.
c_str()),
"Replace?", MB_ICONQUESTION | MB_YESNO) == IDYES) {
610 NMLVDISPINFO *pDispInfo =
reinterpret_cast<NMLVDISPINFO*
>(pNMHDR);
613 int index = pDispInfo->item.iItem;
639 NMLVDISPINFO *pDispInfo =
reinterpret_cast<NMLVDISPINFO*
>(pNMHDR);
641 if(pDispInfo->item.pszText) {
644 material->
SetAttribute(pDispInfo->item.iItem-1,
"name", pDispInfo->item.pszText);
656 if(nChar == 3 && GetKeyState(VK_CONTROL)) {
660 if(nChar == 22 && GetKeyState(VK_CONTROL)) {
665 ToggleListView::OnChar(nChar, nRepCnt, nFlags);
673 CListCtrl& list = GetListCtrl();
674 if (pMsg->hwnd == list.GetSafeHwnd()) {
676 if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_DELETE) {
688 cs.style &= ~LVS_TYPEMASK;
689 cs.style |= LVS_SINGLESEL | LVS_EDITLABELS;
699 if(material && index > 0) {
714 CListCtrl& list = GetListCtrl();
721 CMenu* pPopupMenu = FloatingMenu.GetSubMenu (0);
722 ASSERT(pPopupMenu !=
NULL);
724 POSITION pos = list.GetFirstSelectedItemPosition();
727 nItem = list.GetNextSelectedItem(pos);
733 pPopupMenu->EnableMenuItem(
ID_STAGEPOPUP_CUT, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
734 pPopupMenu->EnableMenuItem(
ID_STAGEPOPUP_COPY, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
759 pPopupMenu->TrackPopupMenu (TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt->x, pt->y, &list);
766 CListCtrl& list = GetListCtrl();
793 ZeroMemory(&lvi,
sizeof(LV_ITEM));
794 lvi.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_STATE | LVIF_PARAM;
795 lvi.stateMask = LVIS_DROPHILITED | LVIS_FOCUSED | LVIS_SELECTED;
796 lvi.pszText = szLabel;
798 lvi.cchTextMax = 255;
803 list.InsertItem(&lvi);
virtual void MV_OnMaterialAttributeChanged(MaterialDoc *pMaterial, int stage, const char *attribName)
Called when an attribute is changed.
virtual void MV_OnMaterialSelectionChange(MaterialDoc *pMaterial)
Called when the selected material has changed.
void EnableStage(int stage, bool enabled)
Specifies the enabled state of a single stage.
bool IsCopyStage()
Returns true if there is a stage in the copy buffer.
afx_msg void OnPaste()
Performs a paste operation when the user selects the menu option.
int FindStage(int stageType, const char *name)
Returns the index of the stage with the specified type and name or -1 if the stage does not exist...
CONST PIXELFORMATDESCRIPTOR UINT
virtual void MV_OnMaterialStageDelete(MaterialDoc *pMaterial, int stageNum)
Called when a stage is deleted.
afx_msg void OnAddDiffuseStage()
Adds a new diffusemap stage when the user selects the menu option.
void PopupMenu(CPoint *pt)
Dispalys the popup menu with the appropriate menu items enabled.
virtual BOOL PreCreateWindow(CREATESTRUCT &cs)
Sets some window styles before the window is created.
void SetPropertyListType(int listType, int stageNum=-1)
Initializes the list of properties based on the type (material, stage, special stage).
#define ID_STAGEPOPUP_DELETEALLSTAGES
#define ID_STAGEPOPUP_PASTE
afx_msg void OnLvnItemchanged(NMHDR *pNMHDR, LRESULT *pResult)
Called when the user changes the selection in the list box.
void SetToggleState(int index, int toggleState, bool notify=false)
Sets the state of an item in the list.
void GetCopyStageInfo(int &type, idStr &name)
Returns information about the stage in the copy buffer.
bool CanDelete()
Returns true if the current state of the stage view will allow a delete operation.
void DropItemOnList()
Performs the stage move when the user has dragged and dropped a stage.
afx_msg void OnLvnDeleteallitems(NMHDR *pNMHDR, LRESULT *pResult)
Notifies the property view that all stages have been removed.
GLuint GLuint GLsizei GLenum type
afx_msg void OnAddStage()
Adds a new stage when the user selects the menu option.
void MoveStage(int from, int to, bool addUndo=true)
Moves a stage from one location to another.
#define ID_STAGEPOPUP_ADDSTAGE
void SetToggleIcons(LPCSTR disabled=NULL, LPCSTR on=NULL, LPCSTR off=NULL)
Sets the tree icons to dispay for each of the three states.
void RemoveStage(int stage, bool addUndo=true)
Removes a stage from the material.
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct)
Called by the MFC framework when the view is being created.
afx_msg void OnCopy()
Performs a copy operation when the user selects the menu option.
void SetAttribute(int stage, const char *attribName, const char *value, bool addUndo=true)
Sets an attribute string in the material or a stage.
MaterialPropTreeView * m_propView
virtual ~StageView()
Destructor for StageView.
Responsible for managing a single material that is being viewed and/or edited.
afx_msg void OnAddBumpmapStage()
Adds a new bumpmap stage when the user selects the menu option.
afx_msg void OnNMRclick(NMHDR *pNMHDR, LRESULT *pResult)
Displays the popup menu when the user performs a right mouse click.
virtual void MV_OnMaterialSaved(MaterialDoc *pMaterial)
Called when the material changes have been saved.
View that handles managing the material stages.
void CopyStage(MaterialDoc *materialDoc, int stageNum)
Prepares a material stage for a copy/paste operation.
void AddStage(int stageType, const char *stageName, bool addUndo=true)
Adds a stage to the material.
#define ID_STAGEPOPUP_CUT
afx_msg void OnLvnBeginlabeledit(NMHDR *pNMHDR, LRESULT *pResult)
Determines is a label edit can be performed on the selected stage.
afx_msg void OnLButtonUp(UINT nFlags, CPoint point)
Finishes a stage drag operation of the user was dragging a stage.
int GetStageCount()
Returns the number of stages in this material.
int GetAttributeInt(int stage, const char *attribName, const char *defaultString="0")
Returns an attribute int from the material or a stage.
afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
Handles keyboard shortcuts for copy and paste operations.
afx_msg void OnLvnEndlabeledit(NMHDR *pNMHDR, LRESULT *pResult)
Performs the stage name change after the label edit is done.
void PasteStage(MaterialDoc *materialDoc)
Performs a paste operation of the stage in the copy buffer.
#define ID_STAGEPOPUP_COPY
#define ID_STAGEPOPUP_ADDSPECULAR
#define ID_STAGEPOPUP_ADDBUMPMAP
afx_msg void OnLvnBegindrag(NMHDR *pNMHDR, LRESULT *pResult)
Starts the stage drag operation.
const char * GetAttribute(int stage, const char *attribName, const char *defaultString="")
Returns an attribute string from the material or a stage.
virtual void MV_OnMaterialStageMove(MaterialDoc *pMaterial, int from, int to)
Called when a stage is moved.
afx_msg void OnMouseMove(UINT nFlags, CPoint point)
Handles drawing the drag image when a user is draging a stage.
void RefreshStageList()
Rebuilds the list of stages based on the currently selected material.
afx_msg void OnDeleteStage()
Deletes the selected stage when the user selects the delete menu option.
#define ID_STAGEPOPUP_DELETESTAGE
virtual void MV_OnMaterialStageAdd(MaterialDoc *pMaterial, int stageNum)
Called when a stage is added.
IMPLEMENT_DYNCREATE(CCamWnd, CWnd)
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct)
Called as the window is being created and initializes icons and window styles.
MaterialDocManager * materialDocManager
virtual void OnStateChanged(int index, int toggleState)
Called by the ToggleListView when the toggle state has changed.
afx_msg void OnRenameStage()
Begins a label edit when the user selects the rename menu option.
afx_msg void OnAddSpecualarStage()
Adds a new specularmap stage when the user selects the menu option.
#define IDI_ME_DISABLED_ICON
const char * c_str(void) const
virtual BOOL PreTranslateMessage(MSG *pMsg)
Handles keyboard shortcut for the delete operations.
afx_msg void OnDeleteAllStages()
Conforms the user wants to delete all stages and then performs the operation.
char * va(const char *fmt,...)
MaterialDoc * GetCurrentMaterialDoc()
A simple list view that supports a toggle button.
bool IsStageEnabled(int stage)
Returns the enabled state of a stage.
#define ID_STAGEPOPUP_RENAMESTAGE
bool CanRename()
Returns true if the current state of the stage view will allow a rename operation.
MaterialDoc * currentMaterial
virtual BOOL PreCreateWindow(CREATESTRUCT &cs)
Sets window styles before the window is created.
void ClearStages()
Removes all stages from the material.
bool CanCopy()
Returns true if the current state of the stage view will allow a copy operation.
bool CanCut()
Cut is not supported for stages.
#define ID_STAGEPOPUP_ADDDIFFUSEMAP
#define IDR_ME_STAGELIST_POPUP
bool CanPaste()
Returns true if the current state of the stage view will allow a paste operation. ...