示例#1
0
void CCreateEventDlg::OnNotify(NMHDR *pHdr)
{

    switch(pHdr->code)
    {
    case PSN_APPLY:
        OnOkay();
        break;
    case DTN_DATETIMECHANGE:
    {
        NMDATETIMECHANGE *pChange = reinterpret_cast<NMDATETIMECHANGE *>(pHdr);
        if(pChange->dwFlags == GDT_VALID)
        {
            if(pChange->st.wMinute % 15)
            {
                pChange->st.wMinute = ((pChange->st.wMinute / 15) + 1) * 15;
                if(pChange->st.wMinute > 45)
                {
                    pChange->st.wMinute = 0;
                    pChange->st.wHour += 1;
                }
                SYSTEMTIME *pST = &(pChange->st);
                SendMessage(pChange->nmhdr.hwndFrom, DTM_SETSYSTEMTIME, GDT_VALID, reinterpret_cast<LPARAM>(pST));
            }
        }
        SetWindowLongPtr(m_hwnd, DWLP_MSGRESULT, 0);
    }
    break;
    case DTN_WMKEYDOWN:
    {
        NMDATETIMEWMKEYDOWN *keyDown = reinterpret_cast<NMDATETIMEWMKEYDOWN *>(pHdr);
        OutputDebugString(keyDown->pszFormat);
        OutputDebugString(_T("\n"));
    }
    break;
    case UDN_DELTAPOS:
    {
        NMUPDOWN *updown = reinterpret_cast<NMUPDOWN *>(pHdr);
        int delta = updown->iDelta ;
    }
    break;
    default:
        ;
    }

    // All of the above notifications require the owner to return zero.

}
示例#2
0
INT_PTR CCreateEventDlg::PageProc(unsigned int msg, WPARAM wParam, LPARAM lParam)
{
    switch(msg)
    {
    case WM_CTLCOLORSTATIC:
        if(reinterpret_cast<HWND>(lParam) == m_pEstDuration->GetHWND())
        {
            HDC dc = reinterpret_cast<HDC>(wParam);
            SetDCBrushColor(dc, GetSysColor(COLOR_WINDOW));
            return reinterpret_cast<INT_PTR>(GetStockObject(DC_BRUSH));
        }
        return FALSE;
    case WM_CTLCOLOREDIT:
        if(reinterpret_cast<HWND>(lParam) == m_pEstDuration->GetHWND())
        {
            HDC dc = reinterpret_cast<HDC>(wParam);
            if(!m_pEstDuration->ValidData())
            {
                SetTextColor(dc, 0x006868ff);
            }
            else
            {
                SetTextColor(dc, GetSysColor(COLOR_WINDOWTEXT));
            }
            SetDCBrushColor(dc, GetSysColor(COLOR_WINDOW));
            return reinterpret_cast<INT_PTR>(GetStockObject(DC_BRUSH));
        }
        return FALSE;
    case WM_INITDIALOG:
        OnInitDialog();
        break;
    case WM_NOTIFY:
    {
        NMHDR *pHdr = reinterpret_cast<NMHDR *>(lParam);
        OnNotify(pHdr);
    }
    break;
    case WM_COMMAND:
        if (LOWORD(wParam) == IDOK)
        {
            OnOkay();
        }
        else if(LOWORD(wParam) == IDC_CREATE_EVENT_ADD_USER_BUTTON)
        {
            StringBuffer sb(1024);
            HWND edit = GetDlgItem(m_hwnd, IDC_CREATE_EVENT_ADD_USER_EDIT);
            if(edit)
            {
                GetWindowText(edit, sb, 1023);
                sb.setLength(_tcslen(sb));
                SetWindowText(edit, _T(""));
                HWND lb = GetDlgItem(m_hwnd, IDC_CREATE_EVENT_ATTENDEE_LIST);
                SendMessage(lb, LB_ADDSTRING, 0, reinterpret_cast<LPARAM>(sb.operator TCHAR *()));
                SetFocus(edit);
            }
        }
        break;

    default:
        return FALSE;
    }
    return TRUE;
}
示例#3
0
register_editor_dialog::register_editor_dialog(QWidget *parent, u32 _pc, const std::shared_ptr<cpu_thread>& _cpu, CPUDisAsm* _disasm)
	: QDialog(parent)
	, m_pc(_pc)
	, cpu(_cpu)
	, m_disasm(_disasm)
{
	setWindowTitle(tr("Edit registers"));
	setAttribute(Qt::WA_DeleteOnClose);
	setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);

	QVBoxLayout* vbox_panel = new QVBoxLayout();
	QHBoxLayout* hbox_panel = new QHBoxLayout();
	QVBoxLayout* vbox_left_panel = new QVBoxLayout();
	QVBoxLayout* vbox_right_panel = new QVBoxLayout();
	QHBoxLayout* hbox_button_panel = new QHBoxLayout();

	QLabel* t1_text = new QLabel(tr("Register:     "), this);
	QLabel* t2_text = new QLabel(tr("Value (Hex):"), this);

	QPushButton* button_ok = new QPushButton(tr("&Ok"));
	QPushButton* button_cancel = new QPushButton(tr("&Cancel"));
	button_ok->setFixedWidth(80);
	button_cancel->setFixedWidth(80);
	
	m_register_combo = new QComboBox(this);
	m_value_line = new QLineEdit(this);
	m_value_line->setFixedWidth(200);

	// Layouts
	vbox_left_panel->addWidget(t1_text);
	vbox_left_panel->addWidget(t2_text);

	vbox_right_panel->addWidget(m_register_combo);
	vbox_right_panel->addWidget(m_value_line);

	hbox_button_panel->addWidget(button_ok);
	hbox_button_panel->addWidget(button_cancel);
	hbox_button_panel->setAlignment(Qt::AlignCenter);

	switch (g_system)
	{
	case system_type::ps3:
	{
		if (_cpu->id_type() == 1)
		{
			for (int i = 0; i < 32; i++) m_register_combo->addItem(qstr(fmt::format("GPR[%d]", i)));
			for (int i = 0; i < 32; i++) m_register_combo->addItem(qstr(fmt::format("FPR[%d]", i)));
			for (int i = 0; i < 32; i++) m_register_combo->addItem(qstr(fmt::format("VR[%d]", i)));
			m_register_combo->addItem("CR");
			m_register_combo->addItem("LR");
			m_register_combo->addItem("CTR");
			//m_register_combo->addItem("XER");
			//m_register_combo->addItem("FPSCR");
		}
		else
		{
			for (int i = 0; i < 128; i++) m_register_combo->addItem(qstr(fmt::format("GPR[%d]", i)));
		}

		break;
	}

	default:
		QMessageBox::critical(this, tr("Error"), tr("Not supported thread."));
		return;
	}

	// Main Layout
	hbox_panel->addLayout(vbox_left_panel);
	hbox_panel->addSpacing(10);
	hbox_panel->addLayout(vbox_right_panel);
	vbox_panel->addLayout(hbox_panel);
	vbox_panel->addSpacing(10);
	vbox_panel->addLayout(hbox_button_panel);
	setLayout(vbox_panel);
	setModal(true);

	// Events
	connect(button_ok, &QAbstractButton::pressed, this, [=](){OnOkay(_cpu); accept();});
	connect(button_cancel, &QAbstractButton::pressed, this, &register_editor_dialog::reject);
	connect(m_register_combo, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &register_editor_dialog::updateRegister);
}
示例#4
0
register_editor_dialog::register_editor_dialog(QWidget *parent, u32 _pc, const std::shared_ptr<cpu_thread>& _cpu, CPUDisAsm* _disasm)
	: QDialog(parent)
	, m_pc(_pc)
	, cpu(_cpu)
	, m_disasm(_disasm)
{
	setWindowTitle(tr("Edit registers"));
	setAttribute(Qt::WA_DeleteOnClose);

	QVBoxLayout* vbox_panel = new QVBoxLayout();
	QHBoxLayout* hbox_panel = new QHBoxLayout();
	QVBoxLayout* vbox_left_panel = new QVBoxLayout();
	QVBoxLayout* vbox_right_panel = new QVBoxLayout();
	QHBoxLayout* hbox_button_panel = new QHBoxLayout();

	QLabel* t1_text = new QLabel(tr("Register:     "), this);
	QLabel* t2_text = new QLabel(tr("Value (Hex):"), this);

	QPushButton* button_ok = new QPushButton(tr("&Ok"));
	QPushButton* button_cancel = new QPushButton(tr("&Cancel"));
	button_ok->setFixedWidth(80);
	button_cancel->setFixedWidth(80);

	m_register_combo = new QComboBox(this);
	m_value_line = new QLineEdit(this);
	m_value_line->setFixedWidth(200);

	// Layouts
	vbox_left_panel->addWidget(t1_text);
	vbox_left_panel->addWidget(t2_text);

	vbox_right_panel->addWidget(m_register_combo);
	vbox_right_panel->addWidget(m_value_line);

	hbox_button_panel->addWidget(button_ok);
	hbox_button_panel->addWidget(button_cancel);
	hbox_button_panel->setAlignment(Qt::AlignCenter);

	if (1)
	{
		if (_cpu->id_type() == 1)
		{
			for (int i = 0; i < 32; i++) m_register_combo->addItem(qstr(fmt::format("GPR[%d]", i)));
			for (int i = 0; i < 32; i++) m_register_combo->addItem(qstr(fmt::format("FPR[%d]", i)));
			for (int i = 0; i < 32; i++) m_register_combo->addItem(qstr(fmt::format("VR[%d]", i)));
			m_register_combo->addItem("CR");
			m_register_combo->addItem("LR");
			m_register_combo->addItem("CTR");
			//m_register_combo->addItem("XER");
			//m_register_combo->addItem("FPSCR");
		}
		else
		{
			for (int i = 0; i < 128; i++) m_register_combo->addItem(qstr(fmt::format("GPR[%d]", i)));
		}
	}

	// Main Layout
	hbox_panel->addLayout(vbox_left_panel);
	hbox_panel->addSpacing(10);
	hbox_panel->addLayout(vbox_right_panel);
	vbox_panel->addLayout(hbox_panel);
	vbox_panel->addSpacing(10);
	vbox_panel->addLayout(hbox_button_panel);
	setLayout(vbox_panel);
	setModal(true);

	// Events
	connect(button_ok, &QAbstractButton::pressed, this, [=](){OnOkay(_cpu); accept();});
	connect(button_cancel, &QAbstractButton::pressed, this, &register_editor_dialog::reject);
	connect(m_register_combo, &QComboBox::currentTextChanged, this, &register_editor_dialog::updateRegister);

	updateRegister(m_register_combo->currentText());
}
示例#5
0
bool CGUIDialogSettingsBase::OnMessage(CGUIMessage &message)
{
  switch (message.GetMessage())
  {
    case GUI_MSG_WINDOW_INIT:
    {
      m_delayedSetting.reset();
      if (message.GetParam1() != WINDOW_INVALID)
      { // coming to this window first time (ie not returning back from some other window)
        // so we reset our section and control states
        m_iCategory = 0;
        ResetControlStates();
      }

      if (AllowResettingSettings())
      {
        m_resetSetting = new CSettingAction(SETTINGS_RESET_SETTING_ID);
        m_resetSetting->SetLabel(10041);
        m_resetSetting->SetHelp(10045);
        m_resetSetting->SetControl(CreateControl("button"));
      }

      m_dummyCategory = new CSettingCategory(SETTINGS_EMPTY_CATEGORY_ID);
      m_dummyCategory->SetLabel(10046);
      m_dummyCategory->SetHelp(10047);
      break;
    }

    case GUI_MSG_WINDOW_DEINIT:
    {
      // cancel any delayed changes
      if (m_delayedSetting != NULL)
      {
        m_delayedTimer.Stop();
        CGUIMessage message(GUI_MSG_UPDATE_ITEM, GetID(), m_delayedSetting->GetID());
        OnMessage(message);
      }
      
      CGUIDialog::OnMessage(message);
      FreeControls();
      return true;
    }
    
    case GUI_MSG_FOCUSED:
    {
      CGUIDialog::OnMessage(message);
      int focusedControl = GetFocusedControlID();

      // cancel any delayed changes
      if (m_delayedSetting != NULL && m_delayedSetting->GetID() != focusedControl)
      {
        m_delayedTimer.Stop();
        CGUIMessage message(GUI_MSG_UPDATE_ITEM, GetID(), m_delayedSetting->GetID(), 1); // param1 = 1 for "reset the control if it's invalid"
        g_windowManager.SendThreadMessage(message, GetID());
      }
      // update the value of the previous setting (in case it was invalid)
      else if (m_iSetting >= CONTROL_SETTINGS_START_CONTROL && m_iSetting < (int)(CONTROL_SETTINGS_START_CONTROL + m_settingControls.size()))
      {
        BaseSettingControlPtr control = GetSettingControl(m_iSetting);
        if (control != NULL && control->GetSetting() != NULL && !control->IsValid())
        {
          CGUIMessage message(GUI_MSG_UPDATE_ITEM, GetID(), m_iSetting, 1); // param1 = 1 for "reset the control if it's invalid"
          g_windowManager.SendThreadMessage(message, GetID());
        }
      }

      CVariant description;

      // check if we have changed the category and need to create new setting controls
      if (focusedControl >= CONTROL_SETTINGS_START_BUTTONS && focusedControl < (int)(CONTROL_SETTINGS_START_BUTTONS + m_categories.size()))
      {
        int categoryIndex = focusedControl - CONTROL_SETTINGS_START_BUTTONS;
        const CSettingCategory* category = m_categories.at(categoryIndex);
        if (categoryIndex != m_iCategory)
        {
          if (!category->CanAccess())
          {
            // unable to go to this category - focus the previous one
            SET_CONTROL_FOCUS(CONTROL_SETTINGS_START_BUTTONS + m_iCategory, 0);
            return false;
          }

          m_iCategory = categoryIndex;
          CreateSettings();
        }

        description = category->GetHelp();
      }
      else if (focusedControl >= CONTROL_SETTINGS_START_CONTROL && focusedControl < (int)(CONTROL_SETTINGS_START_CONTROL + m_settingControls.size()))
      {
        m_iSetting = focusedControl;
        CSetting *setting = GetSettingControl(focusedControl)->GetSetting();
        if (setting != NULL)
          description = setting->GetHelp();
      }

      // set the description of the currently focused category/setting
      if (description.isInteger() ||
          (description.isString() && !description.empty()))
        SetDescription(description);

      return true;
    }

    case GUI_MSG_CLICKED:
    {
      int iControl = message.GetSenderId();
      if (iControl == CONTROL_SETTINGS_OKAY_BUTTON)
      {
        OnOkay();
        Close();
        return true;
      }

      if (iControl == CONTROL_SETTINGS_CANCEL_BUTTON)
      {
        OnCancel();
        Close();
        return true;
      }

      BaseSettingControlPtr control = GetSettingControl(iControl);
      if (control != NULL)
        OnClick(control);

      break;
    }
    
    case GUI_MSG_UPDATE_ITEM:
    {
      if (m_delayedSetting != NULL && m_delayedSetting->GetID() == message.GetControlId())
      {
        // first get the delayed setting and reset its member variable
        // to avoid handling the delayed setting twice in case the OnClick()
        // performed later causes the window to be deinitialized (e.g. when
        // changing the language)
        BaseSettingControlPtr delayedSetting = m_delayedSetting;
        m_delayedSetting.reset();

        // if updating the setting fails and param1 has been specifically set
        // we need to call OnSettingChanged() to restore a valid value in the
        // setting control
        if (!delayedSetting->OnClick() && message.GetParam1() != 0)
          OnSettingChanged(delayedSetting->GetSetting());
        return true;
      }

      if (message.GetControlId() >= CONTROL_SETTINGS_START_CONTROL && message.GetControlId() < (int)(CONTROL_SETTINGS_START_CONTROL + m_settingControls.size()))
      {
        BaseSettingControlPtr settingControl = GetSettingControl(message.GetControlId());
        if (settingControl.get() != NULL && settingControl->GetSetting() != NULL)
        {
          settingControl->Update();
          return true;
        }
      }
      break;
    }
    
    case GUI_MSG_UPDATE:
    {
      if (IsActive() && HasID(message.GetSenderId()))
      {
        int focusedControl = GetFocusedControlID();
        CreateSettings();
        SET_CONTROL_FOCUS(focusedControl, 0);
      }
      break;
    }

    default:
      break;
  }

  return CGUIDialog::OnMessage(message);
}