dsrc isn't necessary for this repo
[client-tools.git] / src / external / 3rd / application / UiBuilder / ObjectInspector.cpp
blob8a9bad7acb3d8327af2c7a48b812f7aeae3c71f5
1 #include "FirstUiBuilder.h"
2 #include "ObjectInspector.h"
4 #include "UIBaseObject.h"
5 #include "UIWidget.h"
6 #include "UIPage.h"
7 #include "UIManager.h"
8 #include "UIUtils.h"
9 #include "UIImageStyle.h"
10 #include "UIImage.h"
12 #include "resource.h"
13 #include "AddPropertyDialogBox.h"
14 #include "EditPropertyDialogBox.h"
15 #include "SelectRegion.h"
17 #include <cstdio>
18 #include <commctrl.h>
19 #include <vector>
21 extern void CheckOutSelectedFile();
22 extern bool gDrawHighlightRect;
23 extern HWND gObjectTree;
24 extern HANDLE gFrameRenderingMutex;
25 extern UIBaseObject::UISmartObjectList gCurrentSelection;
28 HTREEITEM GetObjectInTreeControlFromHandle( HWND hTree, HTREEITEM hParentItem, UIBaseObject *o );
29 void SetSelection( UIBaseObject *NewSelection, bool pushHistory );
30 void LoadTopLevelObjectsToTabControl( void );
31 void ClearDefPushButtonLook( HWND hwndDlg, UINT nControlID );
33 extern const char * gVisualEditLockPropertyName;
35 void recordUndo(UIBaseObject * const object, bool force = false);
36 extern bool volatile s_UndoReady;
39 namespace
41 bool s_updateAllFromTextControl = true;
45 UINT CALLBACK ColorDialogHookProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
47 UI_UNREF (lParam);
48 UI_UNREF (wParam);
50 if( uMsg == WM_INITDIALOG )
52 RECT rcWindow;
53 RECT rcDesktop;
54 long WindowWidth;
55 long WindowHeight;
57 GetWindowRect( GetDesktopWindow(), &rcDesktop );
58 GetWindowRect( hwnd, &rcWindow );
60 WindowWidth = rcWindow.right - rcWindow.left;
61 WindowHeight = rcWindow.bottom - rcWindow.top;
63 rcWindow.left = (rcDesktop.right - rcDesktop.left) / 2 - WindowWidth / 2;
64 rcWindow.top = (rcDesktop.bottom - rcDesktop.top) / 2 - WindowHeight / 2;
66 MoveWindow( hwnd, rcWindow.left, rcWindow.top, WindowWidth, WindowHeight, TRUE );
68 return 0;
71 ObjectInspector::ObjectInspector( HWND hWnd )
73 HWND hParent = GetParent( hWnd );
74 mPropertyListbox = hWnd;
75 mObject = 0;
76 mTimerID = 1007;
78 SetWindowLong( mPropertyListbox, GWL_STYLE, GetWindowLong( mPropertyListbox, GWL_STYLE ) | WS_CLIPCHILDREN );
80 mOldWindowProc = (WNDPROC)GetWindowLong( hParent, GWL_WNDPROC );
81 SetProp( hParent, "ObjectInspector::this", this );
82 SetWindowLong( hParent, GWL_WNDPROC, (long)StaticWindowProc );
84 SetTimer( hParent, mTimerID, 100, 0 );
86 mTextOverlay = CreateWindowEx( WS_EX_TOPMOST, "Edit", "", WS_CHILD | WS_BORDER | ES_AUTOHSCROLL | ES_LEFT,
87 0, 0, 0, 0, mPropertyListbox, (HMENU)1001, GetModuleHandle(0), 0 );
89 // HFONT hFont = (HFONT)SendMessage( mPropertyListbox, WM_GETFONT, 0, 0 );
91 const int height = HIWORD (GetDialogBaseUnits ());
93 HFONT fixedFont = CreateFont (height * 3 / 4, 0,
94 0, 0,
95 0, 0, 0, 0,
96 ANSI_CHARSET,
97 OUT_DEFAULT_PRECIS,
98 CLIP_DEFAULT_PRECIS,
99 DEFAULT_QUALITY,
100 FF_DONTCARE,
101 "lucida console");
103 SendMessage (hWnd, WM_SETFONT, reinterpret_cast<WPARAM>(fixedFont), 1);
105 SendMessage( mTextOverlay, WM_SETFONT, (WPARAM)fixedFont, 0 );
107 SetProp( mTextOverlay, "ObjectInspector::this", this );
108 mOldTextboxWindowProc = (WNDPROC)GetWindowLong( mTextOverlay, GWL_WNDPROC );
109 SetWindowLong( mTextOverlay, GWL_WNDPROC, (long)StaticTextboxWindowProc );
111 UpdateButtonEnabledState();
114 ObjectInspector::~ObjectInspector( void )
116 HWND hParent = GetParent( mPropertyListbox );
118 assert( (WNDPROC)GetWindowLong( hParent, GWL_WNDPROC ) == StaticWindowProc );
120 KillTimer( hParent, mTimerID );
121 SetWindowLong( hParent, GWL_WNDPROC, (long)mOldWindowProc );
122 RemoveProp( hParent, "ObjectInspector::this" );
124 RemoveProp( mTextOverlay, "ObjectInspector::this" );
125 DestroyWindow( mTextOverlay );
128 //-----------------------------------------------------------------
130 void ObjectInspector::SetObject( UIBaseObject *o )
132 if( o != mObject )
134 s_updateAllFromTextControl = false;
135 UpdatePropertyFromTextControl();
136 mObject = o;
137 LoadListboxWithObjectProperties();
140 UpdateTextControlFromProperty();
143 //-----------------------------------------------------------------
145 UIBaseObject *ObjectInspector::GetObject( void ) const
147 return const_cast<UIBaseObject *>(mObject.pointer());
150 //-----------------------------------------------------------------
152 bool ObjectInspector::GetSelectedPropertyName( UINarrowString &Out )
154 long CurrentSelection = SendMessage( mPropertyListbox, LB_GETCURSEL, 0, 0 );
156 if( CurrentSelection != -1 )
158 int BufferSize = SendMessage( mPropertyListbox, LB_GETTEXTLEN, CurrentSelection, 0 );
159 char *PropertyName = new char[BufferSize+1];
161 SendMessage( mPropertyListbox, LB_GETTEXT, CurrentSelection, (LPARAM)PropertyName );
162 Out = PropertyName;
163 delete PropertyName;
164 return true;
167 return false;
170 void ObjectInspector::UpdateButtonEnabledState( void )
172 BOOL EnableAddButton = FALSE;
173 BOOL EnableRemoveButton = FALSE;
174 BOOL EnableLockButton = FALSE;
175 BOOL PressLockButton = FALSE;
177 if( mObject )
179 UINarrowString PropertyName;
181 EnableAddButton = TRUE;
183 if( GetSelectedPropertyName( PropertyName ) )
185 if( mObject->IsPropertyRemovable( UILowerString (PropertyName )))
186 EnableRemoveButton = TRUE;
189 if( mObject->IsA( TUIWidget ) )
190 EnableLockButton = TRUE;
192 if( mObject->HasProperty( UILowerString (gVisualEditLockPropertyName ) ))
193 PressLockButton = TRUE;
196 HWND hParent = GetParent( mPropertyListbox );
198 EnableWindow( GetDlgItem( hParent, IDC_ADDPROPERTY ), EnableAddButton );
199 EnableWindow( GetDlgItem( hParent, IDC_REMOVEPROPERTY ), EnableRemoveButton );
200 EnableWindow( GetDlgItem( hParent, IDC_LOCK), EnableLockButton );
202 if( PressLockButton )
203 CheckDlgButton( hParent, IDC_LOCK, BST_CHECKED );
204 else
205 CheckDlgButton( hParent, IDC_LOCK, BST_UNCHECKED );
208 void ObjectInspector::LoadListboxWithObjectProperties( void )
210 int Selection = SendMessage(mPropertyListbox, LB_GETCURSEL, 0, 0);
212 if( Selection == -1 )
213 Selection = 0;
215 SendMessage( mPropertyListbox, LB_RESETCONTENT, 0, 0 );
217 if( !mObject )
219 UpdateButtonEnabledState();
220 return;
223 UIBaseObject::UIPropertyNameVector PropertyNames;
224 mObject->GetPropertyNames( PropertyNames, false );
226 for( UIBaseObject::UIPropertyNameVector::const_iterator i = PropertyNames.begin(); i != PropertyNames.end(); ++i )
228 UILowerString const & lname = *i;
229 char const * const lnameStr = lname.c_str();
230 if (lname != UIBaseObject::PropertyName::SourceFile &&
231 (_stricmp( lname.c_str (), gVisualEditLockPropertyName ) != 0) &&
232 (lnameStr && *lnameStr != '!'))
233 SendMessage( mPropertyListbox, LB_ADDSTRING, 0, (long)lname.c_str () );
236 SendMessage( mPropertyListbox, LB_SETCURSEL, Selection, 0 );
238 HWND hParent = GetParent( mPropertyListbox );
240 char ObjectType[256];
241 sprintf(ObjectType, "%s", mObject->GetTypeName());
242 SetWindowText( GetDlgItem( hParent, IDC_OBJECTTYPE ), ObjectType );
244 UIString sourcePath;
245 if (UIManager::gUIManager().GetRootPage() == mObject)
247 sourcePath = Unicode::narrowToWide("ui_root");
249 else
251 mObject->GetProperty(UIBaseObject::PropertyName::SourceFile, sourcePath);
254 sprintf(ObjectType, "%s", Unicode::wideToNarrow(sourcePath).c_str(), mObject->GetTypeName());
255 SetWindowText(GetDlgItem( hParent, IDC_OBJECTPROPERTIES_LABEL), ObjectType);
257 UpdateButtonEnabledState();
260 LRESULT CALLBACK ObjectInspector::StaticWindowProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
262 ObjectInspector *pThis = reinterpret_cast<ObjectInspector *>( GetProp( hwnd, "ObjectInspector::this" ) );
263 return pThis->WindowProc( hwnd, uMsg, wParam, lParam );
266 LRESULT CALLBACK ObjectInspector::StaticTextboxWindowProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
268 ObjectInspector *pThis = reinterpret_cast<ObjectInspector *>( GetProp( hwnd, "ObjectInspector::this" ) );
270 if( pThis )
271 return pThis->TextboxWindowProc( hwnd, uMsg, wParam, lParam );
272 else
273 return 0;
276 //-----------------------------------------------------------------
278 namespace
280 void setPropertyOnSelection (const UILowerString & Name, const Unicode::String & Value)
282 for (UIBaseObject::UISmartObjectList::iterator it = gCurrentSelection.begin (); it != gCurrentSelection.end (); ++it)
284 recordUndo(*it, true);
285 (*it)->SetProperty (Name, Value);
289 void removePropertyOnSelection (const UILowerString & Name)
291 for (UIBaseObject::UISmartObjectList::iterator it = gCurrentSelection.begin (); it != gCurrentSelection.end (); ++it)
293 recordUndo(*it, true);
294 (*it)->RemoveProperty (Name);
299 //-----------------------------------------------------------------
301 LRESULT ObjectInspector::WindowProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
303 if( (uMsg == WM_DRAWITEM) && GetDlgItem( hwnd, wParam ) == mPropertyListbox )
306 LPDRAWITEMSTRUCT pdis = (LPDRAWITEMSTRUCT)lParam;
307 HBITMAP DoubleBufferBitmap, OldBitmap;
308 HDC DoubleBufferDC;
309 HFONT OldFont;
310 POINT ItemSize;
311 RECT rcFill;
312 RECT rcClip;
314 ItemSize.x = pdis->rcItem.right - pdis->rcItem.left;
315 ItemSize.y = pdis->rcItem.bottom - pdis->rcItem.top;
317 SetRect( &rcFill, 0, 0, ItemSize.x, ItemSize.y );
318 SetRect( &rcClip, 2, 0, ItemSize.x / 2, ItemSize.y );
320 DoubleBufferDC = CreateCompatibleDC( pdis->hDC );
321 DoubleBufferBitmap = CreateCompatibleBitmap( pdis->hDC, ItemSize.x, ItemSize.y );
323 OldBitmap = (HBITMAP)SelectObject( DoubleBufferDC, DoubleBufferBitmap );
324 OldFont = (HFONT)SelectObject( DoubleBufferDC, GetCurrentObject( pdis->hDC, OBJ_FONT ) );
326 if( pdis->itemState & ODS_SELECTED )
328 HWND hwndFocus = GetFocus();
330 if( (hwndFocus == mTextOverlay) || (hwndFocus == mPropertyListbox) )
332 FillRect( DoubleBufferDC, &rcFill, GetSysColorBrush( COLOR_HIGHLIGHT ) );
333 SetTextColor( DoubleBufferDC, GetSysColor( COLOR_HIGHLIGHTTEXT ) );
335 else
337 FillRect( DoubleBufferDC, &rcFill, GetSysColorBrush( COLOR_BTNFACE ) );
338 SetTextColor( DoubleBufferDC, GetSysColor( COLOR_BTNTEXT ) );
340 SetTextColor( DoubleBufferDC, GetSysColor( COLOR_HIGHLIGHTTEXT ) );
342 else
344 FillRect( DoubleBufferDC, &rcFill, GetSysColorBrush( COLOR_WINDOW ) );
345 SetTextColor( DoubleBufferDC, GetSysColor( COLOR_WINDOWTEXT ) );
348 SetBkMode( DoubleBufferDC, TRANSPARENT );
350 if( pdis->itemID != -1 )
352 char *PropertyName = new char[ SendMessage( mPropertyListbox, LB_GETTEXTLEN, pdis->itemID, 0 ) + 1 ];
353 SendMessage( mPropertyListbox, LB_GETTEXT, pdis->itemID, (long)PropertyName );
354 DrawText( DoubleBufferDC, PropertyName, -1, &rcClip, DT_SINGLELINE );
356 rcClip.left = rcClip.right;
357 rcClip.right = ItemSize.x;
359 UIString Value;
360 mObject->GetProperty( UILowerString (PropertyName), Value );
361 DrawText( DoubleBufferDC, UIUnicode::wideToNarrow (Value).c_str(), -1, &rcClip, DT_SINGLELINE );
363 delete PropertyName;
366 BitBlt( pdis->hDC, pdis->rcItem.left, pdis->rcItem.top, ItemSize.x, ItemSize.y, DoubleBufferDC, 0, 0, SRCCOPY );
368 SelectObject( DoubleBufferDC, OldFont );
369 SelectObject( DoubleBufferDC, OldBitmap );
370 DeleteObject( DoubleBufferBitmap );
371 DeleteDC( DoubleBufferDC );
372 return TRUE;
375 else if( (uMsg == WM_COMMAND) )
377 if( LOWORD( wParam ) == IDC_ADDPROPERTY && mObject )
379 AddPropertyDialogBox AddProp;
380 UINarrowString NewName;
381 UIString NewValue;
383 if( AddProp.GetNewProperty( hwnd, NewName, NewValue ) )
385 setPropertyOnSelection (UILowerString (NewName), NewValue );
386 LoadListboxWithObjectProperties();
389 SetFocus(mPropertyListbox);
390 ClearDefPushButtonLook( hwnd, IDC_ADDPROPERTY );
391 return TRUE;
393 else if( LOWORD( wParam ) == IDC_REMOVEPROPERTY && mObject )
395 long CurrentSelection;
396 long BufferSize;
397 char *SelectionText;
399 CurrentSelection = SendMessage( mPropertyListbox, LB_GETCURSEL, 0, 0 );
401 if( CurrentSelection >= 0 )
403 BufferSize = SendMessage( mPropertyListbox, LB_GETTEXTLEN, CurrentSelection, 0 );
405 SelectionText = new char[BufferSize+1];
406 SendMessage( mPropertyListbox, LB_GETTEXT, CurrentSelection, (LPARAM)SelectionText );
407 removePropertyOnSelection(UILowerString (SelectionText));
408 LoadListboxWithObjectProperties();
409 delete SelectionText;
412 SetFocus(mPropertyListbox);
413 ClearDefPushButtonLook( hwnd, IDC_REMOVEPROPERTY );
414 return TRUE;
416 else if( (LOWORD( wParam ) == IDC_CHECKOUT) && (HIWORD( wParam ) == BN_CLICKED) )
418 CheckOutSelectedFile();
419 return TRUE;
421 else if( LOWORD( wParam ) == IDC_LOCK && mObject )
423 if( mObject->HasProperty( UILowerString (gVisualEditLockPropertyName) ) )
424 removePropertyOnSelection(UILowerString (gVisualEditLockPropertyName));
425 else
426 setPropertyOnSelection (UILowerString (gVisualEditLockPropertyName), UI_UNICODE_T("true") );
428 LoadListboxWithObjectProperties();
429 SetFocus(mPropertyListbox);
430 ClearDefPushButtonLook( hwnd, IDC_REMOVEPROPERTY );
432 else if( (HWND)lParam == mPropertyListbox )
434 switch( HIWORD(wParam) )
436 case LBN_SELCHANGE:
437 s_updateAllFromTextControl = false;
438 UpdatePropertyFromTextControl();
439 UpdateTextControlFromProperty();
440 UpdateButtonEnabledState();
441 ShowTextControl();
442 SetFocus( mTextOverlay );
443 break;
444 case LBN_SETFOCUS:
445 ShowWindow( mTextOverlay, SW_HIDE );
446 break;
447 case LBN_DBLCLK:
449 long CurrentSelection;
450 long BufferSize;
451 char *SelectionText;
453 CurrentSelection = SendMessage( mPropertyListbox, LB_GETCURSEL, 0, 0 );
454 BufferSize = SendMessage( mPropertyListbox, LB_GETTEXTLEN, CurrentSelection, 0 );
456 SelectionText = new char[BufferSize+1];
457 SendMessage( mPropertyListbox, LB_GETTEXT, CurrentSelection, (LPARAM)SelectionText );
459 if( mObject )
461 UIString PropertyValue;
463 const UILowerString & lowerSelectionText = UILowerString (SelectionText);
465 if( mObject->GetProperty( lowerSelectionText, PropertyValue ) )
467 if( UIUnicode::icmp (PropertyValue, UI_UNICODE_T ("true")) == 0)
468 setPropertyOnSelection (lowerSelectionText, UI_UNICODE_T("false" ) );
469 else if( UIUnicode::icmp (PropertyValue, UI_UNICODE_T ("false")) == 0)
470 setPropertyOnSelection (lowerSelectionText, UI_UNICODE_T("true" ) );
471 else
473 UIBaseObject *NewObject = 0;
475 if( !PropertyValue.empty() )
476 NewObject = mObject->GetObjectFromPath( PropertyValue.c_str() );
478 if( NewObject )
480 SetSelection (NewObject, true);
481 HTREEITEM hItemToSelect = GetObjectInTreeControlFromHandle( gObjectTree, 0, NewObject );
482 TreeView_SelectItem( gObjectTree, hItemToSelect );
484 else
486 UIColor theColor;
488 if( !_stricmp( SelectionText, "SourceRect" ) )
490 // Show graphical source rect editor
491 bool UpdateProperty = false;
493 SelectRegionDialogBox SelectRegion;
495 if( mObject->IsA( TUIImageStyle ) )
497 UpdateProperty = SelectRegion.EditProperty(hwnd, UI_ASOBJECT(UIImageStyle, mObject), PropertyValue);
499 else if( mObject->IsA( TUIImageFragment ) )
501 UIBaseObject *obj = mObject;
503 while( obj && !obj->IsA( TUIImageStyle ) )
505 obj = obj->GetParent();
508 if( obj )
510 UpdateProperty = SelectRegion.EditProperty( hwnd, static_cast<UIImageStyle *>( obj ), PropertyValue );
513 else if( mObject->IsA( TUIImage ) )
515 UpdateProperty = SelectRegion.EditProperty(hwnd, UI_ASOBJECT(UIImage, mObject), PropertyValue);
518 if( UpdateProperty )
519 setPropertyOnSelection( lowerSelectionText, PropertyValue);
521 else if( UIUtils::ParseColor( PropertyValue, theColor ) )
523 static COLORREF CustomColors[16] = {0};
524 CHOOSECOLOR cc = { sizeof( cc ) };
526 cc.rgbResult = RGB( theColor.r, theColor.g, theColor.b );
527 cc.Flags = CC_FULLOPEN | CC_RGBINIT | CC_ANYCOLOR | CC_ENABLEHOOK;
528 cc.lpCustColors = CustomColors;
529 cc.lpfnHook = ColorDialogHookProc;
531 if( ChooseColor( &cc ) )
533 theColor.r = GetRValue( cc.rgbResult );
534 theColor.g = GetGValue( cc.rgbResult );
535 theColor.b = GetBValue( cc.rgbResult );
537 UIUtils::FormatColor( PropertyValue, theColor );
538 setPropertyOnSelection( lowerSelectionText, PropertyValue);
541 else
543 EditPropertyDialogBox EditProp;
545 if( EditProp.EditProperty( hwnd, SelectionText, PropertyValue ) )
546 setPropertyOnSelection( lowerSelectionText, PropertyValue);
551 delete [] SelectionText;
553 break;
556 return TRUE;
559 else if( (uMsg == WM_TIMER) && (wParam == mTimerID) )
561 if (GetFocus () != mTextOverlay)
562 InvalidateRect( mPropertyListbox, 0, FALSE );
563 return TRUE;
566 return CallWindowProc( mOldWindowProc, hwnd, uMsg, wParam, lParam );
569 //-----------------------------------------------------------------
571 LRESULT ObjectInspector::TextboxWindowProc( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
573 if( uMsg == WM_KILLFOCUS )
575 s_updateAllFromTextControl = false;
576 UpdatePropertyFromTextControl();
577 ShowWindow( hwnd, SW_HIDE );
579 else if( uMsg == WM_KEYDOWN )
581 if( wParam == VK_TAB )
583 SendMessage( GetParent( mPropertyListbox ), WM_NEXTDLGCTL, GetAsyncKeyState(VK_SHIFT) & 0x80000000, FALSE );
584 return 0;
586 else if( wParam == VK_ESCAPE )
587 UpdateTextControlFromProperty();
588 else if( (wParam == VK_UP) || (wParam == VK_DOWN) )
589 return SendMessage( mPropertyListbox, uMsg, wParam, lParam );
591 else if( uMsg == WM_KEYUP )
593 if( (wParam == VK_UP) || (wParam == VK_DOWN) )
594 return SendMessage( mPropertyListbox, uMsg, wParam, lParam );
596 else if( (uMsg == WM_CHAR) && (wParam == VK_RETURN) )
598 UpdatePropertyFromTextControl();
599 UpdateTextControlFromProperty();
600 ShowTextControl();
601 return TRUE;
603 else if( uMsg == WM_GETDLGCODE )
604 return DLGC_WANTALLKEYS | CallWindowProc( mOldTextboxWindowProc, hwnd, uMsg, wParam, lParam );
606 return CallWindowProc( mOldTextboxWindowProc, hwnd, uMsg, wParam, lParam );
609 void ObjectInspector::UpdateTextControlFromProperty( void )
611 if( mObject )
613 int itemID = SendMessage( mPropertyListbox, LB_GETCURSEL, 0, 0 );
615 if( itemID != -1 )
617 char *PropertyName = new char[ SendMessage( mPropertyListbox, LB_GETTEXTLEN, itemID, 0 ) + 1 ];
618 SendMessage( mPropertyListbox, LB_GETTEXT, itemID, (long)PropertyName );
620 mCurrentPropertyName = PropertyName;
622 UIString Value;
623 mObject->GetProperty( UILowerString (PropertyName), Value );
625 SetWindowText( mTextOverlay, UIUnicode::wideToNarrow (Value).c_str() );
627 delete PropertyName;
632 void ObjectInspector::ShowTextControl( void )
634 int itemID = SendMessage( mPropertyListbox, LB_GETCURSEL, 0, 0 );
636 if( itemID != -1 )
638 RECT itemRect;
639 POINT editSize;
641 SendMessage( mPropertyListbox, LB_GETITEMRECT, itemID, (LPARAM)&itemRect );
643 editSize.x = (itemRect.right - itemRect.left) / 2 + 3;
644 editSize.y = (itemRect.bottom - itemRect.top);
646 MoveWindow( mTextOverlay, (itemRect.right - itemRect.left) - editSize.x, itemRect.top, editSize.x, editSize.y, TRUE );
647 SendMessage( mTextOverlay, EM_SETSEL, 0, -1 );
648 ShowWindow( mTextOverlay, SW_SHOW );
652 void ObjectInspector::UpdatePropertyFromTextControl( void )
654 if( IsWindowVisible( mTextOverlay ) )
656 int itemID = SendMessage( mPropertyListbox, LB_GETCURSEL, 0, 0 );
658 if( itemID != -1 && !mCurrentPropertyName.empty() )
660 long TextLen = SendMessage( mTextOverlay, WM_GETTEXTLENGTH, 0, 0 );
662 char * const PropertyValue = new char[ TextLen + 1 ];
663 SendMessage( mTextOverlay, WM_GETTEXT, TextLen + 1, (LPARAM)PropertyValue );
665 WaitForSingleObject( gFrameRenderingMutex, INFINITE );
667 if (s_updateAllFromTextControl)
668 setPropertyOnSelection (UILowerString (mCurrentPropertyName), UIUnicode::narrowToWide (PropertyValue) );
669 else if (mObject)
671 recordUndo(mObject, true);
672 mObject->SetProperty (UILowerString (mCurrentPropertyName), UIUnicode::narrowToWide (PropertyValue) );
675 delete PropertyValue;
677 if( mCurrentPropertyName == UIBaseObject::PropertyName::Name.get ())
679 InvalidateRect( gObjectTree, NULL, TRUE );
681 if( mObject->IsA( TUIPage ) && (mObject->GetParent() == UIManager::gUIManager().GetRootPage() ) )
682 LoadTopLevelObjectsToTabControl();
685 ReleaseMutex( gFrameRenderingMutex );
689 s_updateAllFromTextControl = true;
692 void ObjectInspector::SendKeyDown( unsigned KeyCode )
694 ShowTextControl();
695 SetFocus( mTextOverlay );
697 BYTE keyboardstate[256];
698 WORD outchars;
700 GetKeyboardState( keyboardstate );
702 if( ToAscii( KeyCode, 0, keyboardstate, &outchars, 0 ) != 1 )
703 return;
705 char Keystroke = static_cast<char> (outchars & 0xFF);
707 SendMessage( mTextOverlay, WM_CHAR, Keystroke, 0 );