aboutsummaryrefslogtreecommitdiff
path: root/sp/src/vgui2/vgui_controls/InputDialog.cpp
diff options
context:
space:
mode:
authorJørgen P. Tjernø <[email protected]>2013-12-02 19:31:46 -0800
committerJørgen P. Tjernø <[email protected]>2013-12-02 19:46:31 -0800
commitf56bb35301836e56582a575a75864392a0177875 (patch)
treede61ddd39de3e7df52759711950b4c288592f0dc /sp/src/vgui2/vgui_controls/InputDialog.cpp
parentMark some more files as text. (diff)
downloadsource-sdk-2013-f56bb35301836e56582a575a75864392a0177875.tar.xz
source-sdk-2013-f56bb35301836e56582a575a75864392a0177875.zip
Fix line endings. WHAMMY.
Diffstat (limited to 'sp/src/vgui2/vgui_controls/InputDialog.cpp')
-rw-r--r--sp/src/vgui2/vgui_controls/InputDialog.cpp472
1 files changed, 236 insertions, 236 deletions
diff --git a/sp/src/vgui2/vgui_controls/InputDialog.cpp b/sp/src/vgui2/vgui_controls/InputDialog.cpp
index 2e1e0624..ca7cf704 100644
--- a/sp/src/vgui2/vgui_controls/InputDialog.cpp
+++ b/sp/src/vgui2/vgui_controls/InputDialog.cpp
@@ -1,236 +1,236 @@
-//========= Copyright Valve Corporation, All rights reserved. ============//
-//
-// Purpose:
-//
-//=============================================================================//
-
-#include <vgui_controls/InputDialog.h>
-#include <vgui_controls/Label.h>
-#include <vgui_controls/Button.h>
-#include <vgui_controls/TextEntry.h>
-#include "tier1/KeyValues.h"
-#include "vgui/IInput.h"
-
-// memdbgon must be the last include file in a .cpp file!!!
-#include <tier0/memdbgon.h>
-
-using namespace vgui;
-
-
-//-----------------------------------------------------------------------------
-// Purpose: Constructor
-//-----------------------------------------------------------------------------
-BaseInputDialog::BaseInputDialog( vgui::Panel *parent, const char *title ) :
- BaseClass( parent, NULL )
-{
- m_pContextKeyValues = NULL;
-
- SetDeleteSelfOnClose( true );
- SetTitle(title, true);
- SetSize(320, 180);
- SetSizeable( false );
-
- m_pCancelButton = new Button(this, "CancelButton", "#VGui_Cancel");
- m_pOKButton = new Button(this, "OKButton", "#VGui_OK");
- m_pCancelButton->SetCommand("Cancel");
- m_pOKButton->SetCommand("OK");
- m_pOKButton->SetAsDefaultButton( true );
-
- if ( parent )
- {
- AddActionSignalTarget( parent );
- }
-}
-
-BaseInputDialog::~BaseInputDialog()
-{
- CleanUpContextKeyValues();
-}
-
-//-----------------------------------------------------------------------------
-// Purpose: Cleans up the keyvalues
-//-----------------------------------------------------------------------------
-void BaseInputDialog::CleanUpContextKeyValues()
-{
- if ( m_pContextKeyValues )
- {
- m_pContextKeyValues->deleteThis();
- m_pContextKeyValues = NULL;
- }
-}
-
-//-----------------------------------------------------------------------------
-// Purpose:
-//-----------------------------------------------------------------------------
-void BaseInputDialog::DoModal( KeyValues *pContextKeyValues )
-{
- CleanUpContextKeyValues();
- m_pContextKeyValues = pContextKeyValues;
- BaseClass::DoModal();
-}
-
-//-----------------------------------------------------------------------------
-// Purpose: lays out controls
-//-----------------------------------------------------------------------------
-void BaseInputDialog::PerformLayout()
-{
- BaseClass::PerformLayout();
-
- int w, h;
- GetSize( w, h );
-
- // lay out all the controls
- int topy = IsSmallCaption() ? 15 : 30;
- int halfw = w / 2;
-
- PerformLayout( 12, topy, w - 24, h - 100 );
-
- m_pOKButton->SetBounds( halfw - 84, h - 30, 72, 24 );
- m_pCancelButton->SetBounds( halfw + 12, h - 30, 72, 24 );
-}
-
-
-//-----------------------------------------------------------------------------
-// Purpose: handles button commands
-//-----------------------------------------------------------------------------
-void BaseInputDialog::OnCommand(const char *command)
-{
- KeyValues *kv = NULL;
- if ( !stricmp( command, "OK" ) )
- {
- kv = new KeyValues( "InputCompleted" );
- kv->SetPtr( "dialog", this );
- }
- else if ( !stricmp( command, "Cancel" ) )
- {
- kv = new KeyValues( "InputCanceled" );
- }
- else
- {
- BaseClass::OnCommand( command );
- return;
- }
-
- if ( m_pContextKeyValues )
- {
- kv->AddSubKey( m_pContextKeyValues );
- m_pContextKeyValues = NULL;
- }
- PostActionSignal( kv );
- CloseModal();
-}
-
-
-//-----------------------------------------------------------------------------
-// Purpose: Utility dialog, used to ask yes/no questions of the user
-//-----------------------------------------------------------------------------
-InputMessageBox::InputMessageBox( vgui::Panel *parent, const char *title, char const *prompt )
-: BaseClass( parent, title )
-{
- SetSize( 320, 120 );
-
- m_pPrompt = new Label( this, "Prompt", prompt );
-}
-
-InputMessageBox::~InputMessageBox()
-{
-}
-
-void InputMessageBox::PerformLayout( int x, int y, int w, int h )
-{
- m_pPrompt->SetBounds( x, y, w, 24 );
-}
-
-
-//-----------------------------------------------------------------------------
-// Purpose: Constructor
-//-----------------------------------------------------------------------------
-InputDialog::InputDialog(vgui::Panel *parent, const char *title, char const *prompt, char const *defaultValue /*=""*/ ) :
- BaseClass(parent, title)
-{
- SetSize( 320, 120 );
-
- m_pPrompt = new Label( this, "Prompt", prompt );
-
- m_pInput = new TextEntry( this, "Text" );
- m_pInput->SetText( defaultValue );
- m_pInput->SelectAllText( true );
- m_pInput->RequestFocus();
-}
-
-
-InputDialog::~InputDialog()
-{
-}
-
-
-//-----------------------------------------------------------------------------
-// Sets the dialog to be multiline
-//-----------------------------------------------------------------------------
-void InputDialog::SetMultiline( bool state )
-{
- m_pInput->SetMultiline( state );
- m_pInput->SetCatchEnterKey( state );
-}
-
-
-//-----------------------------------------------------------------------------
-// Allow numeric input only
-//-----------------------------------------------------------------------------
-void InputDialog::AllowNumericInputOnly( bool bOnlyNumeric )
-{
- if ( m_pInput )
- {
- m_pInput->SetAllowNumericInputOnly( bOnlyNumeric );
- }
-}
-
-
-//-----------------------------------------------------------------------------
-// Purpose: lays out controls
-//-----------------------------------------------------------------------------
-void InputDialog::PerformLayout( int x, int y, int w, int h )
-{
- m_pPrompt->SetBounds( x, y, w, 24 );
- m_pInput ->SetBounds( x, y + 30, w, m_pInput->IsMultiline() ? h - 30 : 24 );
-}
-
-
-//-----------------------------------------------------------------------------
-// Purpose: handles button commands
-//-----------------------------------------------------------------------------
-void InputDialog::OnCommand(const char *command)
-{
- // overriding OnCommand for backwards compatability
- // it'd be nice at some point to find all uses of InputDialog and just use BaseInputDialog's OnCommand
-
- if (!stricmp(command, "OK"))
- {
- int nTextLength = m_pInput->GetTextLength() + 1;
- char* txt = (char*)_alloca( nTextLength * sizeof(char) );
- m_pInput->GetText( txt, nTextLength );
- KeyValues *kv = new KeyValues( "InputCompleted", "text", txt );
- if ( m_pContextKeyValues )
- {
- kv->AddSubKey( m_pContextKeyValues );
- m_pContextKeyValues = NULL;
- }
- PostActionSignal( kv );
- CloseModal();
- }
- else if (!stricmp(command, "Cancel"))
- {
- KeyValues *kv = new KeyValues( "InputCanceled" );
- if ( m_pContextKeyValues )
- {
- kv->AddSubKey( m_pContextKeyValues );
- m_pContextKeyValues = NULL;
- }
- PostActionSignal( kv );
- CloseModal();
- }
- else
- {
- BaseClass::OnCommand(command);
- }
-}
+//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+//=============================================================================//
+
+#include <vgui_controls/InputDialog.h>
+#include <vgui_controls/Label.h>
+#include <vgui_controls/Button.h>
+#include <vgui_controls/TextEntry.h>
+#include "tier1/KeyValues.h"
+#include "vgui/IInput.h"
+
+// memdbgon must be the last include file in a .cpp file!!!
+#include <tier0/memdbgon.h>
+
+using namespace vgui;
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Constructor
+//-----------------------------------------------------------------------------
+BaseInputDialog::BaseInputDialog( vgui::Panel *parent, const char *title ) :
+ BaseClass( parent, NULL )
+{
+ m_pContextKeyValues = NULL;
+
+ SetDeleteSelfOnClose( true );
+ SetTitle(title, true);
+ SetSize(320, 180);
+ SetSizeable( false );
+
+ m_pCancelButton = new Button(this, "CancelButton", "#VGui_Cancel");
+ m_pOKButton = new Button(this, "OKButton", "#VGui_OK");
+ m_pCancelButton->SetCommand("Cancel");
+ m_pOKButton->SetCommand("OK");
+ m_pOKButton->SetAsDefaultButton( true );
+
+ if ( parent )
+ {
+ AddActionSignalTarget( parent );
+ }
+}
+
+BaseInputDialog::~BaseInputDialog()
+{
+ CleanUpContextKeyValues();
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: Cleans up the keyvalues
+//-----------------------------------------------------------------------------
+void BaseInputDialog::CleanUpContextKeyValues()
+{
+ if ( m_pContextKeyValues )
+ {
+ m_pContextKeyValues->deleteThis();
+ m_pContextKeyValues = NULL;
+ }
+}
+
+//-----------------------------------------------------------------------------
+// Purpose:
+//-----------------------------------------------------------------------------
+void BaseInputDialog::DoModal( KeyValues *pContextKeyValues )
+{
+ CleanUpContextKeyValues();
+ m_pContextKeyValues = pContextKeyValues;
+ BaseClass::DoModal();
+}
+
+//-----------------------------------------------------------------------------
+// Purpose: lays out controls
+//-----------------------------------------------------------------------------
+void BaseInputDialog::PerformLayout()
+{
+ BaseClass::PerformLayout();
+
+ int w, h;
+ GetSize( w, h );
+
+ // lay out all the controls
+ int topy = IsSmallCaption() ? 15 : 30;
+ int halfw = w / 2;
+
+ PerformLayout( 12, topy, w - 24, h - 100 );
+
+ m_pOKButton->SetBounds( halfw - 84, h - 30, 72, 24 );
+ m_pCancelButton->SetBounds( halfw + 12, h - 30, 72, 24 );
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: handles button commands
+//-----------------------------------------------------------------------------
+void BaseInputDialog::OnCommand(const char *command)
+{
+ KeyValues *kv = NULL;
+ if ( !stricmp( command, "OK" ) )
+ {
+ kv = new KeyValues( "InputCompleted" );
+ kv->SetPtr( "dialog", this );
+ }
+ else if ( !stricmp( command, "Cancel" ) )
+ {
+ kv = new KeyValues( "InputCanceled" );
+ }
+ else
+ {
+ BaseClass::OnCommand( command );
+ return;
+ }
+
+ if ( m_pContextKeyValues )
+ {
+ kv->AddSubKey( m_pContextKeyValues );
+ m_pContextKeyValues = NULL;
+ }
+ PostActionSignal( kv );
+ CloseModal();
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Utility dialog, used to ask yes/no questions of the user
+//-----------------------------------------------------------------------------
+InputMessageBox::InputMessageBox( vgui::Panel *parent, const char *title, char const *prompt )
+: BaseClass( parent, title )
+{
+ SetSize( 320, 120 );
+
+ m_pPrompt = new Label( this, "Prompt", prompt );
+}
+
+InputMessageBox::~InputMessageBox()
+{
+}
+
+void InputMessageBox::PerformLayout( int x, int y, int w, int h )
+{
+ m_pPrompt->SetBounds( x, y, w, 24 );
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: Constructor
+//-----------------------------------------------------------------------------
+InputDialog::InputDialog(vgui::Panel *parent, const char *title, char const *prompt, char const *defaultValue /*=""*/ ) :
+ BaseClass(parent, title)
+{
+ SetSize( 320, 120 );
+
+ m_pPrompt = new Label( this, "Prompt", prompt );
+
+ m_pInput = new TextEntry( this, "Text" );
+ m_pInput->SetText( defaultValue );
+ m_pInput->SelectAllText( true );
+ m_pInput->RequestFocus();
+}
+
+
+InputDialog::~InputDialog()
+{
+}
+
+
+//-----------------------------------------------------------------------------
+// Sets the dialog to be multiline
+//-----------------------------------------------------------------------------
+void InputDialog::SetMultiline( bool state )
+{
+ m_pInput->SetMultiline( state );
+ m_pInput->SetCatchEnterKey( state );
+}
+
+
+//-----------------------------------------------------------------------------
+// Allow numeric input only
+//-----------------------------------------------------------------------------
+void InputDialog::AllowNumericInputOnly( bool bOnlyNumeric )
+{
+ if ( m_pInput )
+ {
+ m_pInput->SetAllowNumericInputOnly( bOnlyNumeric );
+ }
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: lays out controls
+//-----------------------------------------------------------------------------
+void InputDialog::PerformLayout( int x, int y, int w, int h )
+{
+ m_pPrompt->SetBounds( x, y, w, 24 );
+ m_pInput ->SetBounds( x, y + 30, w, m_pInput->IsMultiline() ? h - 30 : 24 );
+}
+
+
+//-----------------------------------------------------------------------------
+// Purpose: handles button commands
+//-----------------------------------------------------------------------------
+void InputDialog::OnCommand(const char *command)
+{
+ // overriding OnCommand for backwards compatability
+ // it'd be nice at some point to find all uses of InputDialog and just use BaseInputDialog's OnCommand
+
+ if (!stricmp(command, "OK"))
+ {
+ int nTextLength = m_pInput->GetTextLength() + 1;
+ char* txt = (char*)_alloca( nTextLength * sizeof(char) );
+ m_pInput->GetText( txt, nTextLength );
+ KeyValues *kv = new KeyValues( "InputCompleted", "text", txt );
+ if ( m_pContextKeyValues )
+ {
+ kv->AddSubKey( m_pContextKeyValues );
+ m_pContextKeyValues = NULL;
+ }
+ PostActionSignal( kv );
+ CloseModal();
+ }
+ else if (!stricmp(command, "Cancel"))
+ {
+ KeyValues *kv = new KeyValues( "InputCanceled" );
+ if ( m_pContextKeyValues )
+ {
+ kv->AddSubKey( m_pContextKeyValues );
+ m_pContextKeyValues = NULL;
+ }
+ PostActionSignal( kv );
+ CloseModal();
+ }
+ else
+ {
+ BaseClass::OnCommand(command);
+ }
+}