Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.3 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. #include "dme_controls/AttributeBasePickerPanel.h"
  9. #include "filesystem.h"
  10. #include "vgui_controls/Button.h"
  11. #include "vgui_controls/FileOpenDialog.h"
  12. #include "dme_controls/AttributeTextEntry.h"
  13. // memdbgon must be the last include file in a .cpp file!!!
  14. #include "tier0/memdbgon.h"
  15. using namespace vgui;
  16. //-----------------------------------------------------------------------------
  17. // Constructor
  18. //-----------------------------------------------------------------------------
  19. CAttributeBasePickerPanel::CAttributeBasePickerPanel( vgui::Panel *parent, const AttributeWidgetInfo_t &info ) :
  20. BaseClass( parent, info )
  21. {
  22. m_pOpen = new vgui::Button( this, "Open", "...", this, "open" );
  23. }
  24. void CAttributeBasePickerPanel::OnCommand( char const *cmd )
  25. {
  26. if ( !Q_stricmp( cmd, "open" ) )
  27. {
  28. ShowPickerDialog();
  29. }
  30. else
  31. {
  32. BaseClass::OnCommand( cmd );
  33. }
  34. }
  35. void CAttributeBasePickerPanel::PerformLayout()
  36. {
  37. BaseClass::PerformLayout();
  38. int x, y, w, h;
  39. m_pType->GetBounds( x, y, w, h );
  40. int inset = 25;
  41. m_pType->SetWide( w - inset );
  42. x += w;
  43. x -= inset;
  44. h -= 2;
  45. m_pOpen->SetBounds( x, y, inset, h );
  46. }