//*****************************************************************************
CSpinButtonCtrl* CCxNDArrayDimItem::CreateSpinControl (CRect rectSpin)
{
	ASSERT_VALID (this);
	ASSERT_VALID (m_pGridRow);

	CCxNDArrayDimGrid* pWndList = (CCxNDArrayDimGrid*)((CCxNDArrayDimRow*)m_pGridRow)->m_pWndList;
	ASSERT_VALID (pWndList);

	CSpinButtonCtrl* pWndSpin = new CCxBCGPSpinButtonCtrl;

	if (!pWndSpin->Create (
		WS_CHILD | WS_VISIBLE | UDS_ARROWKEYS | UDS_SETBUDDYINT | UDS_NOTHOUSANDS,
		rectSpin, pWndList, BCGPGRIDCTRL_ID_INPLACE))
	{
		return NULL;
	}

	pWndSpin->SetBuddy (m_pWndInPlace);

	//if (m_nMinValue != 0 || m_nMaxValue != 0)
	{
		pWndSpin->SetRange32 (m_nMinValue, m_nMaxValue);
	}

	return pWndSpin;
}
Beispiel #2
0
BOOL COpPropertyDlg::Create (COperatorWin *opWindow, const NLTEXGEN::ITexGenOperator *op)
{
	// Save operator parameters
	_OpWindow = opWindow;
	_Op = op;

	// Create the dialog
	if (CDialog::Create (IDD_OP_PROPERTY, theApp.m_pMainWnd))
	{
		// The client RECT
		RECT client;
		GetClientRect (&client);
		client.top = DIALOG_MARGIN;
		client.left = DIALOG_MARGIN;

		// Create each widget
		uint i;
		std::string currentCategory;
		for (i=0; i<_Op->getNumParameter(); i++)
		{
			// The parameter
			const CParameter &param = _Op->getParameter(i);

			// New category ?
			if ((i == 0) || (currentCategory != param.Category))
			{
				if (i != 0)
					endCategory (client, currentCategory.c_str ());
				currentCategory = param.Category;
				beginCategory (client);
			}
			else
			{
				client.top += WIDGET_SPACE;
			}
			

			// Type ?
			switch (param.Type)
			{
			case CParameter::TypeEnum:
				{
					if (param.EnumString)
					{
						// Add label
						client.bottom = client.top + LABEL_HEIGHT;
						client.right = client.left + LABEL_WIDTH;
						addLabel(client, (param.Name+string(":")).c_str());

						client.right = WIDGET_RIGHT;
						client.top = client.bottom;
						client.bottom = client.top + COMBO_WINDOW_HEIGHT;
						CExtComboBox *comboBox = new CExtComboBox;
						comboBox->Create (WS_TABSTOP|CBS_DROPDOWNLIST|WS_VISIBLE|WS_CHILD|WS_VSCROLL|CBS_DISABLENOSCROLL, client, this, i+FirstID);
						client.bottom = client.top + COMBO_HEIGHT;
						comboBox->SetFont (GetFont());
						Widgets.push_back(comboBox);
						int j;
						for (j=0; j<param.IntegerMax; j++)
							comboBox->AddString(param.EnumString[j]);
					}
					else
						Widgets.push_back (NULL);
				}
				break;
			case CParameter::TypeColor:
				{
					// Add label
					client.bottom = client.top + LABEL_HEIGHT;
					client.right = client.left + LABEL_WIDTH;
					addLabel(client, (param.Name+string(":")).c_str());

					client.top = client.bottom;
					client.bottom += COLOR_HEIGHT;
					client.right = WIDGET_RIGHT;
					CColorBox *colorBox = new CColorBox;
					colorBox->Create (WS_TABSTOP|WS_VISIBLE|WS_CHILD, client, this, i+FirstID);
					colorBox->SetFont (GetFont());
					Widgets.push_back(colorBox);
				}
				break;
			case CParameter::TypeGradient:
				{
					// Add label
					client.bottom = client.top + LABEL_HEIGHT;
					client.right = client.left + LABEL_WIDTH;
					addLabel(client, (param.Name+string(":")).c_str());

					client.right = WIDGET_RIGHT;
					client.top = client.bottom;
					client.bottom = client.top+GRADIENT_HEIGHT;
					CGradientRectWnd *gradient = new CGradientRectWnd (true);
					gradient->Create (WS_TABSTOP|WS_VISIBLE|WS_CHILD|/*WS_BORDER*/0, client, this, i+FirstID);
					Widgets.push_back(gradient);
				}
				break;
			/*case CParameter::TypeFloat:
				{
					// Add label
					client.bottom = client.top + LABEL_HEIGHT;
					client.right = client.left + LABEL_WIDTH;
					addLabel(client, (param.Name+string(":")).c_str());

					client.right = WIDGET_RIGHT;
					client.top = client.bottom;
					client.bottom = client.top+SLIDER_HEIGHT;
					CSliderCtrl *slider = new CSliderCtrl;
					slider->Create (WS_TABSTOP|TBS_HORZ|WS_VISIBLE|WS_CHILD, client, this, i+FirstID);
					slider->SetRange(SPINNER_MIN, SPINNER_MAX);
					slider->SetFont (GetFont());
					Widgets.push_back(slider);
				}
				break;*/
			case CParameter::TypeFloat:
				{
					client.right = client.left + ROT_BUTTON_WIDTH;
					client.bottom = client.top+ROT_BUTTON_HEIGHT;
					CRotButton *rotButton = new CRotButton;
					rotButton->Create (WS_TABSTOP|WS_VISIBLE|WS_CHILD, client, this, i+FirstID);
					rotButton->init (param.Setup);
					Widgets.push_back(rotButton);

					// Add label
					RECT clientBox = client;
					clientBox.top --;
					clientBox.left = clientBox.right + ROT_BUTTON_LEFT_MARGIN;
					clientBox.bottom = clientBox.top + LABEL_HEIGHT;
					clientBox.right = clientBox.left + LABEL_WIDTH;
					addLabel(clientBox, (param.Name+string(":")).c_str());

					clientBox = client;
					clientBox.left = clientBox.right + ROT_BUTTON_LEFT_MARGIN;
					clientBox.right = clientBox.left + EDIT_WIDTH;
					clientBox.top = clientBox.bottom - EDIT_HEIGHT;
					CMyEdit *edit = new CMyEdit;
					edit->Create (/*WS_BORDER*/0|WS_TABSTOP|ES_LEFT|WS_VISIBLE|WS_CHILD, clientBox, this, i+FirstID);
					edit->SetFont (GetFont());
					Others.push_back(edit);
					rotButton->setEditBox (edit);

					clientBox.left = clientBox.right + ROT_BUTTON_LABEL_MARGIN;
					clientBox.right = clientBox.left + LABEL_WIDTH;
					clientBox.top = clientBox.bottom - EDIT_HEIGHT;
					addLabel(clientBox, param.Setup.Unit);
				}
				break;
			case CParameter::TypeInt:
				{
					// Add label
					client.bottom = client.top + LABEL_HEIGHT;
					client.right = client.left + LABEL_WIDTH;
					addLabel(client, (param.Name+string(":")).c_str());

					client.top = client.bottom;
					client.bottom += EDIT_HEIGHT;
					client.right = client.left+EDIT_WIDTH;
					CMyEdit *edit = new CMyEdit;
					edit->Create (/*WS_BORDER*/0|WS_TABSTOP|ES_LEFT|ES_NUMBER|WS_VISIBLE|WS_CHILD, client, this, i+FirstID);
					edit->SetFont (GetFont());
					Widgets.push_back(edit);

					RECT clientBox = client;
					clientBox.left = clientBox.right;
					clientBox.right = clientBox.left+SPIN_WIDTH;
					CSpinButtonCtrl *spin = new CSpinButtonCtrl;
					spin->Create (/*WS_BORDER*/0|WS_TABSTOP|UDS_WRAP|UDS_ARROWKEYS|WS_VISIBLE|WS_CHILD, clientBox, this, i+FirstID);
					spin->SetRange32( param.IntegerMin, param.IntegerMax);
					Others.push_back(spin);
				}
				break;
			case CParameter::TypeString:
				{
					// Add label
					client.bottom = client.top + LABEL_HEIGHT;
					client.right = client.left + LABEL_WIDTH;
					addLabel(client, (param.Name+string(":")).c_str());

					client.top = client.bottom;
					client.bottom += param.Integer?EDIT_MULTI_LINE_HEIGHT:EDIT_HEIGHT;
					client.right = WIDGET_RIGHT;
					CExtEdit *edit;
					if (param.Integer)
					{
						edit = new CExtEdit;
						edit->Create (WS_VSCROLL|ES_OEMCONVERT|ES_MULTILINE|ES_WANTRETURN|WS_CHILD|WS_VISIBLE|WS_TABSTOP|ES_AUTOHSCROLL|ES_AUTOVSCROLL, client, this, i+FirstID);
					}
					else
					{
						edit = new CMyEdit;
						edit->Create (/*WS_BORDER*/0|WS_TABSTOP|ES_LEFT|WS_VISIBLE|WS_CHILD, client, this, i+FirstID);
					}
					edit->SetFont (GetFont());
					Widgets.push_back(edit);
				}
				break;
			case CParameter::TypeBool:
				{
					client.right = WIDGET_RIGHT;
					client.bottom = client.top+CHECKBOX_HEIGHT;
					CExtBtnOnFlat *edit = new CExtBtnOnFlat;
					string tmp = param.Name;
					tmp[0] = toupper (tmp[0]);
					edit->Create (tmp.c_str(), WS_TABSTOP|BS_AUTOCHECKBOX|WS_VISIBLE|WS_CHILD, client, this, i+FirstID);
					//edit->SetFlat (FALSE);
					edit->SetFont (GetFont());
					Widgets.push_back(edit);
				}
				break;
			default:
				Widgets.push_back (NULL);
			}
		
			client.top = client.bottom;
		}

		if (_Op->getNumParameter())
			endCategory (client, currentCategory.c_str ());
		client.bottom = client.top + DIALOG_MARGIN;
		client.top = 0;
		client.left = 0;
		client.right = DIALOG_CLIENT_WIDTH;

		// Resize the client window
		RECT window;
		RECT realClient;
		GetWindowRect (&window);
		GetClientRect (&realClient);
		SetWindowPos (NULL, 0, 0, 
			(window.right-window.left)+(client.right-client.left)-(realClient.right-realClient.left),
			(window.bottom-window.top)+(client.bottom-client.top)-(realClient.bottom-realClient.top),
			SWP_NOMOVE|SWP_NOZORDER);

		_Initialized = true;

		// Set the name
		updateData();

		return TRUE;
	}
	return FALSE;
}