Example #1
0
bool ShapeKeyMatrix::Verify( QString &sErrors, const QList<class PinItem *> &pins, const QList<class PropertyValue *> &values ) const
{
    bool bSuccess = true;

    QSet<QString> pinsToCheck, notPinsToCheck;

    int nRows = GetPropertyValueInt( "Rows", values, 0 );
    int nColumns = GetPropertyValueInt( "Columns", values, 0 );

    for ( int i = 0; i < MAX_ROWS; i++ )
    {
        QString s = QString("R%1").arg(i);
        if ( i < nRows )
            pinsToCheck << s;
        else
            notPinsToCheck << s;
    }

    for ( int i = 0; i < MAX_COLUMNS; i++ )
    {
        QString s = QString("C%1").arg(i);
        if ( i < nColumns )
            pinsToCheck << s;
        else
            notPinsToCheck << s;
    }


    bSuccess = CheckPins( sErrors, pins, pinsToCheck );
    if ( !CheckNotPins( sErrors, pins, notPinsToCheck ) )
        bSuccess = false;

    return bSuccess;
}
Example #2
0
void ShapeKeyMatrix::populateProperties( QList<PropertyValue *> &values ) const
{
    Shape::populateProperties( values );
    // need to read the row/column values and set the row/column properties of the key names editor
    int nRows = GetPropertyValueInt( "Rows", values, 0 );
    int nColumns = GetPropertyValueInt( "Columns", values, 0 );

    ShapeProperty::m_keyMatrixNameFactory->setRows( nRows );
    ShapeProperty::m_keyMatrixNameFactory->setColumns( nColumns );
}
void ShapeSelectorSwitch::MakeControlsXML( QDomElement &elem, const QList<class PinItem *> &pins, const QList<PropertyValue *> &values  ) const
{
    int nBits = GetPropertyValueInt("Outputs",values,0);
    QStringList outputs;
    for ( int i = 0; i < nBits; i++ )
        outputs << GetPort( pins, QString::number( i+1 ) );

    MakeRotarySwitchControl( elem, 
                             GetPropertyValueString("Name",values,""),
                             GetPropertyValueUsagePage("Usage",values,1),
                             GetPropertyValueUsage("Usage",values,1),
                             GetPropertyValueBool("Pullup",values,true),
                             GetPropertyValueInt("DebounceMs",values,10),
                             false,
                             nBits,
                             outputs );
}
Example #4
0
void ShapeKeyMatrix::MakeControlsXML( QDomElement &elem, const QList<class PinItem *> &pins, const QList<PropertyValue *> &values  ) const
{
    int nRows = GetPropertyValueInt("Rows",values,0);
    int nCols = GetPropertyValueInt("Columns",values,0);

    QStringList rows, cols;
    for ( int i = 0; i < nRows; i++ )
        rows << GetPort(pins, QString("R%1").arg(i) );

    for ( int i = 0; i < nCols; i++ )
        cols << GetPort(pins, QString("C%1").arg(i) );

    MakeKeyMatrixControl( elem, 
                          GetPropertyValueString("Key Names",values,""),
                          GetPropertyValueUsagePage("Usage",values,1),
                          GetPropertyValueUsage("Usage",values,1),
                          GetPropertyValueInt("DebounceMs",values,10),
                          rows,
                          cols );
}
bool ShapeSelectorSwitch::Verify( QString &sErrors, const QList<class PinItem *> &pins, const QList<class PropertyValue *> &values ) const
{
    bool bSuccess = true;

    int nOutputs = GetPropertyValueInt( "Outputs", values, 0 );

    QSet<QString> pinsToCheck;
    for ( int i = 0; i < nOutputs; i++ )
        pinsToCheck << QString::number( i+1 );

    QSet<QString> notPinsToCheck;
    for ( int i = nOutputs; i < MAX_SELECTOR_PINS; i++ )
        notPinsToCheck << QString::number( i+1 );

    bSuccess = CheckPins( sErrors, pins, pinsToCheck );
    if ( !CheckNotPins( sErrors, pins, notPinsToCheck ) )
        bSuccess = false;

    return bSuccess;
}
Example #6
0
void Window::OnComputedPropertyValueChanged(PropertyValue* pPropertyVal, bool handled)
{
	if (pPropertyVal->m_dp == get_IsActiveProperty())
	{
		if (m_platformWindow)
		{
			bool isActive = get_IsActive();

			if (isActive)
			{
				SetForegroundWindow(m_platformWindow->get_Handle());
				//::SetWindowPos(m_platformWindow->get_Handle(), HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE/* | SWP_NOZORDER*/);
			}
		}
	}
	else if (pPropertyVal->m_dp == get_OpacityProperty())
	{
		if (m_platformWindow)
		{
			m_platformWindow->OnOpacityChanged();
		}
	}
	else if (pPropertyVal->m_dp == get_ClipProperty())
	{
		if (m_platformWindow)
		{
			m_platformWindow->OnClipChanged();
		}
	}
	else if (pPropertyVal->m_dp == get_TitleTextProperty())
	{
		if (m_platformWindow)
		{
			m_platformWindow->OnTitleTextChanged();
		}
	}
	else if (pPropertyVal->m_dp == get_CanMinimizeProperty())
	{
		if (m_platformWindow)
		{
			bool has = get_CanMaximize();

			DWORD style = GetWindowLongW(m_platformWindow->get_Handle(), GWL_STYLE);
			if (has)
				style |= WS_MINIMIZEBOX;
			else
				style &= ~WS_MINIMIZEBOX;

			SetWindowLongW(m_platformWindow->get_Handle(), GWL_STYLE, style);
		}
	}
	else if (pPropertyVal->m_dp == get_CanMaximizeProperty())
	{
		if (m_platformWindow)
		{
			bool has = get_CanMaximize();

			DWORD style = GetWindowLongW(m_platformWindow->get_Handle(), GWL_STYLE);
			if (has)
				style |= WS_MAXIMIZEBOX;
			else
				style &= ~WS_MAXIMIZEBOX;

			SetWindowLongW(m_platformWindow->get_Handle(), GWL_STYLE, style);
		}
	}
	else if (pPropertyVal->m_dp == get_HasContextHelpProperty())
	{
		if (m_platformWindow)
		{
			bool has = get_HasContextHelp();

			DWORD exstyle = GetWindowLongW(m_platformWindow->get_Handle(), GWL_EXSTYLE);
			if (has)
				exstyle |= WS_EX_CONTEXTHELP;
			else
				exstyle &= ~WS_EX_CONTEXTHELP;

			SetWindowLongW(m_platformWindow->get_Handle(), GWL_EXSTYLE, exstyle);
		}
	}
	else if (pPropertyVal->m_dp == get_ShowInTaskbarProperty())
	{
		if (m_platformWindow)
		{
			bool show = get_ShowInTaskbar();

			/*
			DWORD exstyle = GetWindowLongW(m_platformWindow->get_Handle(), GWL_EXSTYLE);
			if (show)
			{
				exstyle |= WS_EX_APPWINDOW;
				exstyle &= ~WS_EX_TOOLWINDOW;
			}
			else
			{
				exstyle &= ~WS_EX_APPWINDOW;
				exstyle |= WS_EX_TOOLWINDOW;
			}

			SetWindowLongW(m_platformWindow->get_Handle(), GWL_EXSTYLE, exstyle);
			*/

			if (show)
			{
				MS::Windows::Shell::Private::pTaskbarList->AddTab(m_platformWindow->get_Handle());
			}
			else
			{
				MS::Windows::Shell::Private::pTaskbarList->DeleteTab(m_platformWindow->get_Handle());
			}
		}
	}

	else if (pPropertyVal->m_dp == get_FontFamilyProperty() ||
			pPropertyVal->m_dp == get_FontSizeProperty() ||
			pPropertyVal->m_dp == get_FontWeightProperty() ||
			pPropertyVal->m_dp == get_FontStyleProperty())
	{
		if (m_platformWindow)
		{
			LOGFONT lf = {0};
			// TODO: Copy16
			wcscpy_s(lf.lfFaceName, get_FontFamily().c_strw_flen<LF_FACESIZE>());
			lf.lfHeight = -get_FontSize();
			lf.lfWeight = get_FontWeight();

			HFONT hFont = CreateFontIndirect(&lf);
			ASSERT(hFont);

			SendMessageW(m_platformWindow->get_Handle(), WM_SETFONT, (WPARAM)hFont, TRUE/*bRedraw*/);

			/*
			String titleText = get_TitleText();

			SetWindowTextW(m_platformWindow->get_Handle(), CStringw(titleText).c_str());
			*/
		}
	}
	else if (pPropertyVal->m_dp == get_TopmostProperty())
	{
		if (m_platformWindow)
		{
			bool topmost = get_Topmost();
			if (topmost)
				SetWindowPos(m_platformWindow->get_Handle(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
			else
				SetWindowPos(m_platformWindow->get_Handle(), HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
		}
	}
	else if (pPropertyVal->m_dp == get_StateProperty())
	{
		if (m_platformWindow)
		{
			int state = GetPropertyValueInt(get_StateProperty());
			switch (state)
			{
			case 0:
				::ShowWindow(m_platformWindow->get_Handle(), SW_RESTORE);
				break;

			case 1:
				::ShowWindow(m_platformWindow->get_Handle(), SW_MINIMIZE);
				break;

			case 2:
				::ShowWindow(m_platformWindow->get_Handle(), SW_MAXIMIZE);
				break;
			}
		}
	}
	else if (pPropertyVal->m_dp == get_IsEnabledProperty())
	{
		if (m_platformWindow)
		{
			bool isEnabled = get_IsEnabled();
			::EnableWindow(m_platformWindow->get_Handle(), isEnabled);
		}
	}
	else if (pPropertyVal->m_dp == get_CanCloseProperty())
	{
		if (m_platformWindow)
		{
			if (get_CanClose())
			{
			//	SetWindowLongPtr(m_platformWindow->get_Handle(), 
			}
			else
			{
			}
			/*
			ULONG_PTR classStyle = ::GetClassLongPtr(m_platformWindow->get_Handle(), GCL_STYLE);

			if (get_CanClose()) classStyle &= ~CS_NOCLOSE;
			else classStyle |= CS_NOCLOSE;

			::SetClassLongPtr(m_platformWindow->get_Handle(), GCL_STYLE, classStyle);
			*/
		}
	}
	else if (pPropertyVal->m_dp == get_LeftProperty() ||
			pPropertyVal->m_dp == get_TopProperty())
	{
		if (m_platformWindow)
		{
			int x = int(get_Left());
			int y = int(get_Top());
			int cx = int(get_ActualWidth());	// ceil??
			int cy = int(get_ActualHeight());	// ceil??

			if (!get_InSizeMove() && !m_inSizeMove)
			{
				::SetWindowPos(m_platformWindow->get_Handle(), nullptr, x, y, cx, cy,
					SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE/* |
					SWP_ASYNCWINDOWPOS	// ??*/
					);
			}
		}
	}
	else if (pPropertyVal->m_dp == get_ActualWidthProperty() ||
			pPropertyVal->m_dp == get_ActualHeightProperty())
	{
		if (m_platformWindow)
		{
			int x = int(get_Left());
			int y = int(get_Top());
			int cx = int(get_ActualWidth());	// ceil??
			int cy = int(get_ActualHeight());	// ceil??

			if (!get_InSizeMove() && !m_inSizeMove)
			{
				::SetWindowPos(m_platformWindow->get_Handle(), nullptr, x, y, cx, cy,
					SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE/* |
					SWP_ASYNCWINDOWPOS	// ??*/
					);
			}
		}
	}
	else if (pPropertyVal->m_dp == get_RTProperty())
	{
		if (m_platformWindow)
		{
			m_platformWindow->ChangeTech();
		}
	}
#if 0
	else if (pPropertyVal->m_dp == get_ChildProperty())
	{
		/*
		MessageBeep(-1);
		if (m_platformWindow)
		{
		}
		*/
		InvalidateVisual();
	}
#endif
	else if (pPropertyVal->m_dp == get_ShadowTreeProperty())
	{
		UIElement* uielement = get_ShadowTree();

		if (uielement)
		{
			uielement->SetRoot(this);	// This is different from default UIElement implementation
			uielement->set_ParentWindow(this);	// This is different from default UIElement implementation

			uielement->set_Parent(this);
			uielement->set_TemplatedOwner(this);	// ??

			InvalidateMeasure();
		//	// ??
		//	uielement->ArrangeCore(gm::SizeF(get_ActualWidth(), get_ActualHeight()));
		}

		handled = true;
	}
	else if (pPropertyVal->m_dp == get_OwnerProperty())
	{
		Window* owner = get_Owner();

		if (m_platformWindow && m_platformWindow->get_Handle())
		{
			if (owner)
			{
				if (owner->m_platformWindow && owner->m_platformWindow->get_Handle())
				{
					::SetParent(m_platformWindow->get_Handle(), owner->m_platformWindow->get_Handle());
				}
			}
			else
			{
				::SetParent(m_platformWindow->get_Handle(), nullptr);
			}
		}
	}
	else if (pPropertyVal->m_dp == get_TaskbarItemInfoProperty())
	{
		MS::Windows::Shell::TaskbarItemInfo* info = get_TaskbarItemInfo();

		if (m_platformWindow)
		{
			HWND hWnd = m_platformWindow->get_Handle();
			if (hWnd)
			{
				double progress = info->get_ProgressValue();
				const ULONGLONG totalProgress = 1000000ULL;

			//	TBPFLAG tbFlags;
			//	MS::Windows::Shell::Private::pTaskbarList3->SetProgressState(hWnd, tbpFlags);
				MS::Windows::Shell::Private::pTaskbarList3->SetProgressValue(hWnd, progress*totalProgress, totalProgress);
			}
		}
	}

	baseClass::OnComputedPropertyValueChanged(pPropertyVal, handled);
}