Slider::Slider( CDXUTDialog& dialog, int id, int& y, const wchar_t* label, int min, int max, int& value ) : m_Value( value ), m_szLabel( label ) { dialog.AddStatic( id + 1000000, L"", AMD::HUD::iElementOffset, y += AMD::HUD::iElementDelta, AMD::HUD::iElementWidth, AMD::HUD::iElementHeight, false, &m_pLabel ); dialog.AddSlider( id, AMD::HUD::iElementOffset, y += AMD::HUD::iElementDelta, AMD::HUD::iElementWidth, AMD::HUD::iElementHeight, min, max, m_Value, false, &m_pSlider ); dialog.AddControl( this ); OnGuiEvent(); }
//-------------------------------------------------------------------------------------- // Initialize the app //-------------------------------------------------------------------------------------- void InitApp() { // Initialize dialogs g_SettingsDlg.Init( &g_DialogResourceManager ); g_HUD.Init( &g_DialogResourceManager ); g_SampleUI.Init( &g_DialogResourceManager ); g_HUD.SetCallback( OnGUIEvent ); int iY = 10; g_HUD.AddButton( IDC_TOGGLEFULLSCREEN, L"Toggle full screen", 35, iY, 125, 22 ); g_HUD.AddButton( IDC_TOGGLEREF, L"Toggle REF (F3)", 35, iY += 24, 125, 22 ); g_HUD.AddButton( IDC_CHANGEDEVICE, L"Change device (F2)", 35, iY += 24, 125, 22, VK_F2 ); g_SampleUI.SetCallback( OnGUIEvent ); g_SampleUI.SetFont( 1, L"Comic Sans MS", 24, FW_NORMAL ); g_SampleUI.SetFont( 2, L"Courier New", 16, FW_NORMAL ); // Static g_SampleUI.AddStatic( IDC_STATIC, L"This is a static control.", 0, 0, 200, 30 ); g_SampleUI.AddStatic( IDC_OUTPUT, L"This static control provides feedback for your action. It will change as you interact with the UI controls.", 20, 50, 620, 300 ); g_SampleUI.GetStatic( IDC_OUTPUT )->SetTextColor( D3DCOLOR_ARGB( 255, 255, 0, 0 ) ); // Change color to red g_SampleUI.GetStatic( IDC_STATIC )->SetTextColor( D3DCOLOR_ARGB( 255, 0, 255, 0 ) ); // Change color to green g_SampleUI.GetControl( IDC_OUTPUT )->GetElement( 0 )->dwTextFormat = DT_LEFT | DT_TOP | DT_WORDBREAK; g_SampleUI.GetControl( IDC_OUTPUT )->GetElement( 0 )->iFont = 2; g_SampleUI.GetControl( IDC_STATIC )->GetElement( 0 )->dwTextFormat = DT_CENTER | DT_VCENTER | DT_WORDBREAK; // Buttons g_SampleUI.AddButton( IDC_ENABLEIME, L"Enable (I)ME", 30, 390, 80, 35, L'I' ); g_SampleUI.AddButton( IDC_DISABLEIME, L"Disable I(M)E", 30, 430, 80, 35, L'M' ); // Edit box g_SampleUI.AddEditBox( IDC_EDITBOX1, L"Edit control with default styles. Type text here and press Enter", 20, 440, 600, 32 ); // IME-enabled edit box CDXUTIMEEditBox* pIMEEdit; CDXUTIMEEditBox::InitDefaultElements( &g_SampleUI ); if( SUCCEEDED( CDXUTIMEEditBox::CreateIMEEditBox( &g_SampleUI, IDC_EDITBOX2, L"IME-capable edit control with custom styles. Type and press Enter", 20, 390, 600, 45, false, &pIMEEdit ) ) ) { g_SampleUI.AddControl( pIMEEdit ); pIMEEdit->GetElement( 0 )->iFont = 1; pIMEEdit->GetElement( 1 )->iFont = 1; pIMEEdit->GetElement( 9 )->iFont = 1; pIMEEdit->GetElement( 0 )->TextureColor.Init( D3DCOLOR_ARGB( 128, 255, 255, 255 ) ); // Transparent center pIMEEdit->SetBorderWidth( 7 ); pIMEEdit->SetTextColor( D3DCOLOR_ARGB( 255, 64, 64, 64 ) ); pIMEEdit->SetCaretColor( D3DCOLOR_ARGB( 255, 64, 64, 64 ) ); pIMEEdit->SetSelectedTextColor( D3DCOLOR_ARGB( 255, 255, 255, 255 ) ); pIMEEdit->SetSelectedBackColor( D3DCOLOR_ARGB( 255, 40, 72, 72 ) ); } // Slider g_SampleUI.AddSlider( IDC_SLIDER, 200, 450, 200, 24, 0, 100, 50, false ); // Checkbox g_SampleUI.AddCheckBox( IDC_CHECKBOX, L"This is a checkbox with hotkey. Press 'C' to toggle the check state.", 170, 450, 350, 24, false, L'C', false ); g_SampleUI.AddCheckBox( IDC_CLEAREDIT, L"This checkbox controls whether edit control text is cleared when Enter is pressed. (T)", 170, 460, 450, 24, false, L'T', false ); // Combobox CDXUTComboBox* pCombo; g_SampleUI.AddComboBox( IDC_COMBOBOX, 0, 0, 200, 24, L'O', false, &pCombo ); if( pCombo ) { pCombo->SetDropHeight( 100 ); pCombo->AddItem( L"Combobox item (O)", ( LPVOID )0x11111111 ); pCombo->AddItem( L"Placeholder (O)", ( LPVOID )0x12121212 ); pCombo->AddItem( L"One more (O)", ( LPVOID )0x13131313 ); pCombo->AddItem( L"I can't get enough (O)", ( LPVOID )0x14141414 ); pCombo->AddItem( L"Ok, last one, I promise (O)", ( LPVOID )0x15151515 ); } // Radio buttons g_SampleUI.AddRadioButton( IDC_RADIO1A, 1, L"Radio group 1 Amy (1)", 0, 50, 220, 24, false, L'1' ); g_SampleUI.AddRadioButton( IDC_RADIO1B, 1, L"Radio group 1 Brian (2)", 0, 50, 220, 24, false, L'2' ); g_SampleUI.AddRadioButton( IDC_RADIO1C, 1, L"Radio group 1 Clark (3)", 0, 50, 220, 24, false, L'3' ); g_SampleUI.AddRadioButton( IDC_RADIO2A, 2, L"Single (4)", 0, 50, 90, 24, false, L'4' ); g_SampleUI.AddRadioButton( IDC_RADIO2B, 2, L"Double (5)", 0, 50, 90, 24, false, L'5' ); g_SampleUI.AddRadioButton( IDC_RADIO2C, 2, L"Triple (6)", 0, 50, 90, 24, false, L'6' ); // List box g_SampleUI.AddListBox( IDC_LISTBOX, 30, 400, 200, 150, 0 ); for( int i = 0; i < 15; ++i ) { WCHAR wszText[50]; swprintf_s( wszText, 50, L"Single-selection listbox item %d", i ); g_SampleUI.GetListBox( IDC_LISTBOX )->AddItem( wszText, ( LPVOID )( size_t )i ); } g_SampleUI.AddListBox( IDC_LISTBOXM, 30, 400, 200, 150, CDXUTListBox::MULTISELECTION ); for( int i = 0; i < 30; ++i ) { WCHAR wszText[50]; swprintf_s( wszText, 50, L"Multi-selection listbox item %d", i ); g_SampleUI.GetListBox( IDC_LISTBOXM )->AddItem( wszText, ( LPVOID )( size_t )i ); } }