// WM_SIZE処理
LRESULT CFuncKeyWnd::OnSize( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
	int			nButtonWidth;
	int			nButtonHeight;
	int			i;
	int			nX;
//	RECT		rc;
	int			nButtonNum;
	RECT		rcParent;

	if( NULL == GetHwnd() ){
		return 0L;
	}

	nButtonNum = _countof( m_hwndButtonArr );

	/* ボタンのサイズを計算 */
	nButtonWidth = CalcButtonSize();

	::GetWindowRect( GetHwnd(), &rcParent );
	nButtonHeight = rcParent.bottom - rcParent.top - 2;

	nX = 1;
	for( i = 0; i < nButtonNum; ++i ){
		if( 0 < i  && 0 == ( i % m_nButtonGroupNum ) ){
			nX += 12;
		}
		::MoveWindow( m_hwndButtonArr[i], nX, 1, nButtonWidth, nButtonHeight, TRUE );
		nX += nButtonWidth + 1;
	}
	::InvalidateRect( GetHwnd(), NULL, TRUE );	//再描画してね。	//@@@ 2003.06.11 MIK
	return 0L;
}
Пример #2
0
void CDxMonthPicker::AdjustLayout(CRect rcClient)
{
    m_dtToday = COleDateTime::GetCurrentTime();

    m_rcControl = rcClient;

    CSize szMonth(0, 0);
    CRect rcMonth(0, 0, 0, 0);

    //get button size
    CSize szButton(CalcButtonSize());

    m_rcGrid.CopyRect(&m_rcControl);

    //COLORREF m_clrStaticBorder = RGB(255,255,0);
    //dc.Draw3dRect(0, 0, m_rcGrid.Width(), m_rcGrid.Height(), m_clrStaticBorder, m_clrStaticBorder);

    m_rcGrid.bottom -= (szButton.cy + 2);

    szMonth.cx = m_rcGrid.Width();
    szMonth.cy = m_rcGrid.Height();

    CalcButtonBandRect();

    int nIndex = 0;
    rcMonth = CRect(CPoint(m_rcGrid.left, m_rcGrid.top), szMonth);
    rcMonth.DeflateRect(1, 1);
    // adjust internal month layout
    m_monthPicker->AdjustLayout(rcMonth);
}
void pawsShortcutWindow::CalcMatrixSize(size_t & matrixWidth, size_t & matrixHeight)
{
    CalcButtonSize();
    matrixWidth   = (screenFrame.Width()   - 2*WINDOW_PADDING - SCROLLBAR_SIZE/2) / (buttonWidth  + BUTTON_SPACING);
    matrixHeight  = (screenFrame.Height()  - 2*WINDOW_PADDING)                  / (buttonHeight + BUTTON_SPACING);

    matrixWidth   = MAX(matrixWidth,  1);
    matrixHeight  = MIN(MAX(matrixHeight, 1), CalcTotalRowsNeeded(matrixWidth));
}
Пример #4
0
void CDxMonthPicker::SetButtonRect()
{
    CSize szButton(CalcButtonSize());

    int nGap = 10;

    int nButtonLen = szButton.cx + nGap;
    int nVisibleCount = 1;

    int nLeft = m_rcGrid.CenterPoint().x - (nButtonLen * nVisibleCount - nGap)/2;

    m_btnToday->m_rcButton = CRect(CPoint(nLeft, m_rcGrid.bottom + 1), szButton);
    nLeft += nButtonLen;
}
// bool pawsShortcutWindow::OnButtonPressed( int mouseButton, int keyModifier, pawsWidget* widget )
bool pawsShortcutWindow::OnButtonReleased( int mouseButton, int keyModifier, pawsWidget* widget )
{
    if (!subWidget)
        subWidget = PawsManager::GetSingleton().FindWidget("ShortcutEdit");

    if (!labelBox)
        labelBox = dynamic_cast <pawsEditTextBox*> (subWidget->FindWidget("LabelBox"));

    if (!textBox)
        textBox = dynamic_cast <pawsMultilineEditTextBox*> (subWidget->FindWidget("CommandBox"));

    if (!shortcutText)
        shortcutText = dynamic_cast <pawsTextBox*> (subWidget->FindWidget("ShortcutText"));


    // These should not be NULL
    CS_ASSERT(subWidget); CS_ASSERT(labelBox); CS_ASSERT(textBox); CS_ASSERT(shortcutText);

    BringToTop(this);

    // Finished Configuring command button
    switch ( widget->GetID() )
    {
        case DONE_BUTTON:
        {
            if (!labelBox->GetText() || *(labelBox->GetText()) == '\0')
            {
                if (textBox->GetText() && *(textBox->GetText()) != '\0')
                {
                    //no name but a command was specified.  
                    psSystemMessage msg(0,MSG_ERROR,PawsManager::GetSingleton().Translate("Please specify a name when creating a shortcut."));
                    msg.FireEvent();
                    return true;
                }
                else //shortcut is empty and will be removed. Also remove possible key binding.
                {
                    csString editedCmd;
                    editedCmd.Format("Shortcut %d",edit+1);
                    psengine->GetCharControl()->RemapTrigger(editedCmd,psControl::NONE,0,0);
                }
            }
            // Otherwise save the label and command as it is
            names[edit] = labelBox->GetText();
            cmds[edit] = textBox->GetText();
        
            CalcButtonSize();
            UpdateMatrix();
            LayoutMatrix();
            SetWindowSizeToFitMatrix();

            PawsManager::GetSingleton().SetModalWidget(NULL);
            PawsManager::GetSingleton().SetCurrentFocusedWidget(this);
            subWidget->Hide();

            pawsWidget * configKeyAsWidget = PawsManager::GetSingleton().FindWidget("ConfigKeys");
        
            pawsConfigKeys * configKey = dynamic_cast<pawsConfigKeys*>
                (configKeyAsWidget);
                
            if (configKey)
            {
                configKey->UpdateNicks();
            }                

            SaveCommands();
            return true;
        }
        case CLEAR_BUTTON:
        {
            labelBox->Clear();
            textBox->Clear();
            return true;
        }
        case CANCEL_BUTTON:
        {
            PawsManager::GetSingleton().SetModalWidget(NULL);
            PawsManager::GetSingleton().SetCurrentFocusedWidget(this);
            subWidget->Hide();
            return true;
        }
        case SETKEY_BUTTON:
        {
            pawsWidget * fingWndAsWidget;

            fingWndAsWidget = PawsManager::GetSingleton().FindWidget("FingeringWindow");
            if (fingWndAsWidget == NULL)
            {
                Error1("Could not find widget FingeringWindow");
                return false;
            }
            pawsFingeringWindow * fingWnd = dynamic_cast<pawsFingeringWindow *>(fingWndAsWidget);
            if (fingWnd == NULL)
            {
                Error1("FingeringWindow is not pawsFingeringWindow");
                return false;
            }
            fingWnd->ShowDialog(this, labelBox->GetText());
            
            return true;
        }
    }            // switch( ... )

    // Execute clicked on button
    if ( mouseButton == csmbLeft && !(keyModifier & CSMASK_CTRL))
        ExecuteCommand( widget->GetID() - SHORTCUT_BUTTON_OFFSET, false );
    // Configure the button that was clicked on
    else if ( mouseButton == csmbRight || (mouseButton == csmbLeft && (keyModifier & CSMASK_CTRL)) )
    {
        edit = widget->GetID() - SHORTCUT_BUTTON_OFFSET;
        if ( edit < 0 || edit >= NUM_SHORTCUTS )
            return false;

        if (!subWidget || !labelBox || !textBox || !shortcutText)
            return false;

        if ( names[edit] && names[edit].Length() )
            labelBox->SetText( names[edit].GetData() );
        else
            labelBox->Clear();

        if ( cmds[edit] && cmds[edit].Length() )
        {
            textBox->SetText( cmds[edit].GetData() );
            shortcutText->SetText( GetTriggerText(edit) );
        }
        else
        {
            textBox->Clear();
            shortcutText->SetText("");
        }

        subWidget->Show();
        PawsManager::GetSingleton().SetCurrentFocusedWidget(textBox);
    }
    else
    {
        return false;
    }
    return true;
}