bool JoystickInfo::PollButtons(u32 &pkey) { // MAKE sure to look for changes in the state!! for (int i = 0; i < GetNumButtons(); ++i) { int but = SDL_JoystickGetButton(GetJoy(), i); if (but != GetButtonState(i)) { if (!but) // released, we don't really want this { continue; } // Pressure sensitive button are detected as both button (digital) and axes (analog). So better // drop the button to emulate the pressure sensiblity of the ds2 :) -- Gregory u32 pkey_dummy; if (PollAxes(pkey_dummy)) return false; pkey = button_to_key(i); return true; } } return false; }
bool wxJoystick::GetButtonState(unsigned id) const { if (id > sizeof(int) * 8) return false; return (GetButtonState() & (1 << id)) != 0; }
void InputFilter::ButtonPressed( const DeviceInput &di ) { LockMut(*queuemutex); if( di.ts.IsZero() ) LOG->Warn( "InputFilter::ButtonPressed: zero timestamp is invalid" ); ASSERT_M( di.device < NUM_InputDevice, ssprintf("Invalid device %i", di.device) ); ASSERT_M( di.button < NUM_DeviceButton, ssprintf("Invalid button %i", di.button) ); ButtonState &bs = GetButtonState( di ); // Flush any delayed input, like Update() (in case Update() isn't being called). RageTimer now; CheckButtonChange( bs, di, now ); bs.m_DeviceInput = di; bool Down = di.bDown; if( bs.m_BeingHeld != Down ) { bs.m_BeingHeld = Down; bs.m_BeingHeldTime = di.ts; } // Try to report presses immediately. MakeButtonStateList( g_CurrentState ); CheckButtonChange( bs, di, now ); }
bool JoystickInfo::PollButtons(u32 &pkey) { // MAKE sure to look for changes in the state!! for (int i = 0; i < GetNumButtons(); ++i) { int but = SDL_JoystickGetButton(GetJoy(), i); if (but != GetButtonState(i)) { // Pressure sensitive button are detected as both button (digital) and axes (analog). So better // drop the button to emulate the pressure sensiblity of the ds2 :) // Trick: detect the release of the button. It avoid all races condition between axes and buttons :) // If the button support pressure it will be detected as an axis when it is pressed. if (but) { SetButtonState(i, but); return false; } pkey = button_to_key(i); return true; } } return false; }
bool CScraper::GetButtonState(int button_index) { CString l_button_state = ""; if (button_index<=9) { if (p_symbol_engine_casino->ConnectedToManualMode() && button_index == 5) { // Don't MakeLower our mm_network symbol l_button_state = p_table_state->_SCI._button_state[button_index]; } else { // Default l_button_state = p_table_state->_SCI._button_state[button_index].MakeLower(); } return GetButtonState(l_button_state); } else if (button_index>=860) { l_button_state = p_table_state->_SCI._i86X_button_state[button_index-860]; return GetButtonState(l_button_state); } return false; }
static void OnDbService() { bDbOn = GetButtonState(hDlg, IDC_DB_SERVICE) == BST_CHECKED; CheckEnableBak(); CheckEnableSc(); ShowServiceStates(); }
void QmlMitkRenderWindowItem::wheelEvent(QWheelEvent *we) { mitk::Point2D mousePosition = GetMousePosition(we); mitk::MouseWheelEvent::Pointer mWheelEvent = mitk::MouseWheelEvent::New(mitk::RenderWindowBase::GetRenderer(), mousePosition, GetButtonState(we), GetModifiers(we), we->delta()); mitk::RenderWindowBase::HandleEvent(mWheelEvent.GetPointer()); QVTKQuickItem::wheelEvent(we); }
void QmlMitkRenderWindowItem::mouseMoveEvent(QMouseEvent* me) { mitk::Point2D mousePosition = GetMousePosition(me); //mousePosition[1] = this->GetRenderer()->GetSizeY() - mousePosition[1]; mitk::MouseMoveEvent::Pointer mMoveEvent = mitk::MouseMoveEvent::New(mitk::RenderWindowBase::GetRenderer(), mousePosition, GetButtonState(me), GetModifiers(me)); mitk::RenderWindowBase::HandleEvent(mMoveEvent.GetPointer()); QVTKQuickItem::mouseMoveEvent(me); }
void OnCompose() { if (m_pHero) { iRect rc = GetScrRect(); SpriteId sid = m_pHero->Proto()->m_icn48; gGfxMgr.Blit(sid,gApp.Surface(), rc); ButtonFrame(gApp.Surface(),rc,GetButtonState()); if (!IsEnabled()) gApp.Surface().Darken25Rect(rc); rc.InflateRect(1); gApp.Surface().FrameRect(rc,cColor_Black); } }
void GetDialogFields() { int i= 0; MADB_Dsn *Dsn= (MADB_Dsn *)GetWindowLongPtr(GetParent(hwndTab[0]), DWLP_USER); while (DsnMap[i].Key) { switch (DsnMap[i].Key->Type) { case DSN_TYPE_STRING: case DSN_TYPE_COMBO: { char **p= (char **)((char *)Dsn + DsnMap[i].Key->DsnOffset); if (Dsn->isPrompt != 0 && Dsn->free != NULL) { Dsn->free(*p); } *p= GetFieldStrVal(DsnMap[i].Page, DsnMap[i].Item, Dsn->allocator && Dsn->isPrompt ? Dsn->allocator : NULL); } break; case DSN_TYPE_INT: *(int *)((char *)Dsn + DsnMap[i].Key->DsnOffset)= GetFieldIntVal(DsnMap[i].Page, DsnMap[i].Item); break; case DSN_TYPE_BOOL: *(my_bool *)((char *)Dsn + DsnMap[i].Key->DsnOffset)= GetButtonState(DsnMap[i].Page, DsnMap[i].Item); } ++i; } i= 0; Dsn->Options= 0; while (OptionsMap[i].Item != 0) { if (GetButtonState(OptionsMap[i].Page, OptionsMap[i].Item)) Dsn->Options|= OptionsMap[i].value; i++; } }
void I_UpdateJoystick(void) { if (joystick != NULL) { event_t ev; ev.type = ev_joystick; ev.data1 = GetButtonState(); ev.data2 = GetAxisState(joystick_x_axis, joystick_x_invert); ev.data3 = GetAxisState(joystick_y_axis, joystick_y_invert); ev.data4 = GetAxisState(joystick_strafe_axis, joystick_strafe_invert); D_PostEvent(&ev); } }
void QmitkRenderWindow::mousePressEvent(QMouseEvent *me) { //Get mouse position in vtk display coordinate system. me contains qt display infos... mitk::Point2D displayPos = GetMousePosition(me); mitk::MousePressEvent::Pointer mPressEvent = mitk::MousePressEvent::New(m_Renderer, displayPos, GetButtonState(me), GetModifiers(me), GetEventButton(me)); if (!this->HandleEvent(mPressEvent.GetPointer())) { QVTKWidget::mousePressEvent(me); } if (m_ResendQtEvents) me->ignore(); }
void QmitkRenderWindow::mousePressEvent(QMouseEvent *me) { mitk::Point2D displayPos = GetMousePosition(me); mitk::Point3D worldPos = m_Renderer->Map2DRendererPositionTo3DWorldPosition(GetMousePosition(me)); mitk::MousePressEvent::Pointer mPressEvent = mitk::MousePressEvent::New(m_Renderer, displayPos, worldPos, GetButtonState(me), GetModifiers(me), GetEventButton(me)); if (!this->HandleEvent(mPressEvent.GetPointer())) { // TODO: INTERACTION_LEGACY mitk::MouseEvent myevent(QmitkEventAdapter::AdaptMouseEvent(m_Renderer, me)); this->mousePressMitkEvent(&myevent); QVTKWidget::mousePressEvent(me); } if (m_ResendQtEvents) me->ignore(); }
void InputFilter::ButtonPressed( const DeviceInput &di ) { LockMut(*queuemutex); if( di.ts.IsZero() ) LOG->Warn( "InputFilter::ButtonPressed: zero timestamp is invalid" ); // Filter out input that is beyond the range of the current system. if(di.device >= NUM_InputDevice) { LOG->Trace("InputFilter::ButtonPressed: Invalid device %i", di.device); return; } if(di.button >= NUM_DeviceButton) { LOG->Trace("InputFilter::ButtonPressed: Invalid button %i", di.button); return; } ButtonState &bs = GetButtonState( di ); // Flush any delayed input, like Update() (in case Update() isn't being called). RageTimer now; CheckButtonChange( bs, di, now ); bs.m_DeviceInput = di; bool Down = di.bDown; if( bs.m_BeingHeld != Down ) { bs.m_BeingHeld = Down; bs.m_BeingHeldTime = di.ts; } // Try to report presses immediately. MakeButtonStateList( g_CurrentState ); CheckButtonChange( bs, di, now ); }
static BOOL SavePartitionInfo(BOOL bValidate) { if (bCantCreate) return TRUE; if (GetButtonState(hDlg, IDC_CREATE_PARTITION) != BST_CHECKED) { g_CfgData.szPartitionName[0] = 0; bAutoSetPartitionName = TRUE; } else { GetWindowText(GetDlgItem(hDlg, IDC_PARTITION_NAME), g_CfgData.szPartitionName, MAX_PARTITION_NAME_LEN); if (bValidate && !Validation_IsValid(g_CfgData.szPartitionName, VALID_AFS_PARTITION_NAME)) return FALSE; } if (hSelectedItem == 0) g_CfgData.chDeviceName = 0; else { LPCTSTR pDrive = FastList_GetItemText(hDriveList, hSelectedItem, 0); g_CfgData.chDeviceName = pDrive[0]; } return TRUE; }
void OnCompose() { // gApp.Surface().Darken50Rect(GetScrRect()); // Compose outer frame iRect rect = GetScrRect(); rect.InflateRect(1); iDibFont::ComposeProps props = iDibFont::ComposeProps(iGradient(menuBtnText,15), cColor_Black, iDibFont::DecBorder); uint32 state = GetButtonState(); if ( state & iButton::Disabled ) { props = iDibFont::ComposeProps(RGB16(255,160,80), cColor_Black, iDibFont::DecBorder); } else if ( state & iButton::Pressed ) { props = iDibFont::ComposeProps(RGB16(255,255,255), cColor_Black, iDibFont::DecBorder); uint16 cColor_Grey = RGB16(32,32,32); gApp.Surface().HLine(iPoint(rect.x+2, rect.y), rect.x+rect.w-3, cColor_Grey); gApp.Surface().HLine(iPoint(rect.x+2, rect.y+rect.h-1), rect.x+rect.w-3, cColor_Grey); gApp.Surface().VLine(iPoint(rect.x,rect.y+2), rect.y+rect.h-2, cColor_Grey); gApp.Surface().VLine(iPoint(rect.x+rect.w-1,rect.y+2), rect.y+rect.h-2, cColor_Grey); gApp.Surface().Darken50Rect(GetScrRect()); } iTextComposer::FontConfig fc(iTextComposer::FS_LARGE, props ); gTextComposer.TextOut(fc, gApp.Surface(), iPoint(), gTextMgr[m_TextKey], GetScrRect(), AlignCenter); }
void CPopupFrame::DrawButtons(CDC* pDC, LPRECT pRects, int nBtn) { if (!m_bControlBox) return; if (m_hTheme != NULL) { if (nBtn == -1 || nBtn == 0) m_pfnDrawThemeBackground(m_hTheme, pDC->GetSafeHdc(), WP_CLOSEBUTTON, GetButtonState(0), &pRects[0], NULL); // if (nBtn == -1 || nBtn == 1) // m_pfnDrawThemeBackground(m_hTheme, pDC->GetSafeHdc(), WP_MAXBUTTON, (m_nBtnPressed == 1) ? RBS_PUSHED : RBS_NORMAL, &pRects[1], NULL); // if (nBtn == -1 || nBtn == 2) // m_pfnDrawThemeBackground(m_hTheme, pDC->GetSafeHdc(), WP_MINBUTTON, (m_nBtnPressed == 2) ? MINBS_PUSHED : MINBS_NORMAL, &pRects[2], NULL); } else { if (nBtn == -1 || nBtn == 0) pDC->DrawFrameControl(&pRects[0], DFC_CAPTION, DFCS_CAPTIONCLOSE | ((m_nBtnPressed == 0) ? DFCS_PUSHED : 0)); // if (nBtn == -1 || nBtn == 1) // pDC->DrawFrameControl(&pRects[1], DFC_CAPTION, DFCS_CAPTIONRESTORE | ((m_nBtnPressed == 1) ? DFCS_PUSHED : 0)); // if (nBtn == -1 || nBtn == 2) // pDC->DrawFrameControl(&pRects[2], DFC_CAPTION, DFCS_CAPTIONMIN | ((m_nBtnPressed == 2) ? DFCS_PUSHED : 0)); } }
// /// Paint Text // void TButtonTextGadget::PaintText(TDC& dc, TRect& rect, const tstring& text) { dc.SelectObject(GetFont()); TColor textColor = TColor::SysBtnText; if(!GetEnabled()) textColor = TColor::Sys3dHilight; else if((GetGadgetWindow()->GetFlatStyle()&TGadgetWindow::FlatHotText) && IsHaveMouse()) textColor = TColor::LtBlue; TColor oldTxColor = dc.SetTextColor(textColor); uint format = DT_SINGLELINE|DT_NOCLIP|DT_END_ELLIPSIS; switch(Align){ case aLeft: format |= DT_LEFT; break; case aRight: format |= DT_RIGHT; break; case aCenter: format |= DT_CENTER; break; } switch(LayoutStyle){ case lTextLeft: case lTextRight: format |= DT_VCENTER; break; case lTextTop: format |= DT_VCENTER;//DT_BOTTOM; break; case lTextBottom: format |= DT_VCENTER;//DT_TOP; break; } // Create a UI Face object for this button & let it paint the button face // TPoint dstPt(rect.TopLeft()); if (GetButtonState() == Down && GetEnabled() && GetGadgetWindow()->GetFlatStyle()&TGadgetWindow::FlatStandard) { if(IsHaveMouse()) { if(IsPressed()) { const int dx = (format & DT_CENTER) ? 2 : 1; const int dy = (format & DT_VCENTER) ? 2 : 1; rect.Offset(dx, dy); } TUIFace(rect, text, TColor::Sys3dFace,format).Paint(dc, dstPt, TUIFace::Normal, true, true); } else { TUIFace face(rect, text, TColor::Sys3dFace,format); if(GetGadgetWindow()->GadgetGetCaptured()==this) face.Paint(dc, dstPt, TUIFace::Normal, true); else face.Paint(dc, dstPt, TUIFace::Down, IsPressed(), false); } } else { TUIFace face(rect, text, TColor::Sys3dFace,format); if (!GetEnabled()) face.Paint(dc, dstPt, TUIFace::Disabled, false, false); else if (GetButtonState() == Indeterminate) face.Paint(dc, dstPt, TUIFace::Indeterm, IsPressed(), false); else if (GetButtonState() == Down) // Down and not flat face.Paint(dc, dstPt, TUIFace::Down, IsPressed(), false); else face.Paint(dc, dstPt, TUIFace::Normal, IsPressed(), false); } dc.SetTextColor(oldTxColor); dc.RestoreFont(); }
static void ShowServiceStates() { // FS if (bFsOn) { if (bFsRunning) SetWndText(hDlg, IDC_FS_ACTION_MSG, IDS_FS_HOW_TO_STOP); else SetWndText(hDlg, IDC_FS_ACTION_MSG, IDS_FS_WILL_RUN); } else { if (bFsRunning) SetWndText(hDlg, IDC_FS_ACTION_MSG, IDS_FS_WILL_STOP); else SetWndText(hDlg, IDC_FS_ACTION_MSG, IDS_FS_HOW_TO_RUN); } // DB switch (GetButtonState(hDlg, IDC_DB_SERVICE)) { case BST_CHECKED: if (bDbRunning) SetWndText(hDlg, IDC_DB_ACTION_MSG, IDS_DB_HOW_TO_STOP); else SetWndText(hDlg, IDC_DB_ACTION_MSG, IDS_DB_WILL_RUN); break; case BST_UNCHECKED: if (bDbRunning) SetWndText(hDlg, IDC_DB_ACTION_MSG, IDS_DB_WILL_STOP); else SetWndText(hDlg, IDC_DB_ACTION_MSG, IDS_DB_HOW_TO_RUN); break; case BST_INDETERMINATE: SetWndText(hDlg, IDC_DB_ACTION_MSG, IDS_DB_DETAILS); break; } // For the ones below, in addition to setting the action message, we also // set the status message. This is because the status can change to the // disabled state depending on how other servers are configured. The // servers before this cannot have their status change except by re- // configuring them. // BK if (bDbOn) { if (IsButtonChecked(hDlg, IDC_BK_SERVICE)) { if (bBakRunning) { SetWndText(hDlg, IDC_BK_STATUS_MSG, IDS_BK_RUNNING); SetWndText(hDlg, IDC_BK_ACTION_MSG, IDS_BK_HOW_TO_STOP); } else { SetWndText(hDlg, IDC_BK_STATUS_MSG, IDS_BK_STOPPED); SetWndText(hDlg, IDC_BK_ACTION_MSG, IDS_BK_WILL_RUN); } } else { if (bBakRunning) { SetWndText(hDlg, IDC_BK_STATUS_MSG, IDS_BK_RUNNING); SetWndText(hDlg, IDC_BK_ACTION_MSG, IDS_BK_WILL_STOP); } else { SetWndText(hDlg, IDC_BK_STATUS_MSG, IDS_BK_STOPPED); SetWndText(hDlg, IDC_BK_ACTION_MSG, IDS_BK_HOW_TO_RUN); } } } CheckEnableBak(); // SC Server if (bFsOn || bDbOn && !bSccOn) { if (bScsOn) { if (bScsRunning) { SetWndText(hDlg, IDC_SCS_STATUS_MSG, IDS_SCS_RUNNING); SetWndText(hDlg, IDC_SCS_ACTION_MSG, IDS_SCS_HOW_TO_STOP); } else { SetWndText(hDlg, IDC_SCS_STATUS_MSG, IDS_SCS_STOPPED); SetWndText(hDlg, IDC_SCS_ACTION_MSG, IDS_SCS_WILL_RUN); } } else { if (bScsRunning) { SetWndText(hDlg, IDC_SCS_STATUS_MSG, IDS_SCS_RUNNING); SetWndText(hDlg, IDC_SCS_ACTION_MSG, IDS_SCS_WILL_STOP); } else { SetWndText(hDlg, IDC_SCS_STATUS_MSG, IDS_SCS_STOPPED); SetWndText(hDlg, IDC_SCS_ACTION_MSG, IDS_SCS_HOW_TO_RUN); } } } // SC Client if (bFsOn || bDbOn && !bScsOn) { if (bSccOn) { if (bSccRunning) { SetWndText(hDlg, IDC_SCC_STATUS_MSG, IDS_SCC_RUNNING); SetWndText(hDlg, IDC_SCC_ACTION_MSG, IDS_SCC_HOW_TO_STOP); } else { SetWndText(hDlg, IDC_SCC_STATUS_MSG, IDS_SCC_STOPPED); SetWndText(hDlg, IDC_SCC_ACTION_MSG, IDS_SCC_WILL_RUN); } } else { if (bSccRunning) { SetWndText(hDlg, IDC_SCC_STATUS_MSG, IDS_SCC_RUNNING); SetWndText(hDlg, IDC_SCC_ACTION_MSG, IDS_SCC_WILL_STOP); } else { SetWndText(hDlg, IDC_SCC_STATUS_MSG, IDS_SCC_STOPPED); SetWndText(hDlg, IDC_SCC_ACTION_MSG, IDS_SCC_HOW_TO_RUN); } } } CheckEnableSc(); }
void QmitkRenderWindow::mouseReleaseEvent(QMouseEvent *me) { mitk::Point2D displayPos = GetMousePosition(me); mitk::MouseReleaseEvent::Pointer mReleaseEvent = mitk::MouseReleaseEvent::New(m_Renderer, displayPos, GetButtonState(me), GetModifiers(me), GetEventButton(me)); if (!this->HandleEvent(mReleaseEvent.GetPointer())) { QVTKWidget::mouseReleaseEvent(me); } if (m_ResendQtEvents) me->ignore(); }
void QmitkRenderWindow::wheelEvent(QWheelEvent *we) { mitk::Point2D displayPos = GetMousePosition(we); mitk::Point3D worldPos = m_Renderer->Map2DRendererPositionTo3DWorldPosition(GetMousePosition(we)); mitk::MouseWheelEvent::Pointer mWheelEvent = mitk::MouseWheelEvent::New(m_Renderer, displayPos,worldPos, GetButtonState(we), GetModifiers(we), GetDelta(we)); if (!this->HandleEvent(mWheelEvent.GetPointer())) { // TODO: INTERACTION_LEGACY mitk::WheelEvent myevent(QmitkEventAdapter::AdaptWheelEvent(m_Renderer, we)); this->wheelMitkEvent(&myevent); QVTKWidget::wheelEvent(we); } if (m_ResendQtEvents) we->ignore(); }
void QmitkRenderWindow::mouseMoveEvent(QMouseEvent *me) { mitk::Point2D displayPos = GetMousePosition(me); mitk::Point3D worldPos = m_Renderer->Map2DRendererPositionTo3DWorldPosition(GetMousePosition(me)); this->AdjustRenderWindowMenuVisibility(me->pos()); mitk::MouseMoveEvent::Pointer mMoveEvent = mitk::MouseMoveEvent::New(m_Renderer, displayPos, worldPos, GetButtonState(me), GetModifiers(me)); if (!this->HandleEvent(mMoveEvent.GetPointer())) { // TODO: INTERACTION_LEGACY mitk::MouseEvent myevent(QmitkEventAdapter::AdaptMouseEvent(m_Renderer, me)); this->mouseMoveMitkEvent(&myevent); QVTKWidget::mouseMoveEvent(me); } }
void QmitkRenderWindow::mouseMoveEvent(QMouseEvent *me) { mitk::Point2D displayPos = GetMousePosition(me); this->AdjustRenderWindowMenuVisibility(me->pos()); mitk::MouseMoveEvent::Pointer mMoveEvent = mitk::MouseMoveEvent::New(m_Renderer, displayPos, GetButtonState(me), GetModifiers(me)); if (!this->HandleEvent(mMoveEvent.GetPointer())) { QVTKWidget::mouseMoveEvent(me); } }
void QmitkRenderWindow::wheelEvent(QWheelEvent *we) { mitk::Point2D displayPos = GetMousePosition(we); mitk::MouseWheelEvent::Pointer mWheelEvent = mitk::MouseWheelEvent::New(m_Renderer, displayPos, GetButtonState(we), GetModifiers(we), GetDelta(we)); if (!this->HandleEvent(mWheelEvent.GetPointer())) { QVTKWidget::wheelEvent(we); } if (m_ResendQtEvents) we->ignore(); }
void InputFilter::SetButtonComment( const DeviceInput &di, const RString &sComment ) { LockMut(*queuemutex); ButtonState &bs = GetButtonState( di ); bs.m_sComment = sComment; }
u8 JGE::GetAnalogY() { if (GetButtonState(JGE_BTN_UP)) return 0; if (GetButtonState(JGE_BTN_DOWN)) return 0xff; return 0x80; }
u8 JGE::GetAnalogX() { if (GetButtonState(JGE_BTN_LEFT)) return 0; if (GetButtonState(JGE_BTN_RIGHT)) return 0xff; return 0x80; }
void CTTCheckBtnGroup::OnPaint() { CPaintDC dc(this); CRect clientRect; GetClientRect(clientRect); if (clientRect.Width() <= 0 || clientRect.Height() <= 0) return; CMemDC memDC(dc, clientRect); CDC* pDC = &memDC.GetDC(); DrawThemeParentBackground(GetSafeHwnd(), memDC.GetDC().GetSafeHdc(), clientRect); Graphics graphics(pDC->GetSafeHdc()); graphics.SetSmoothingMode(SmoothingModeAntiAlias); graphics.SetInterpolationMode(InterpolationModeHighQualityBicubic); graphics.SetTextRenderingHint(TextRenderingHintSingleBitPerPixel); // clear background CRgn bkgndRgn; CRect bkgndRect(clientRect); bkgndRect.left += 1; bkgndRect.top += 1; CreateRectRgnInDevicePoints(pDC, &bkgndRgn, bkgndRect, m_CornerRadius); pDC->SelectClipRgn(&bkgndRgn); pDC->FillSolidRect(&clientRect, RGB(255, 255, 255)); CRgn clientRgn; CreateRectRgnInDevicePoints(pDC, &clientRgn, clientRect); pDC->SelectClipRgn(&clientRgn); // Whole border Gdiplus::Rect borderRect(clientRect.left, clientRect.top, clientRect.Width(), clientRect.Height()); borderRect.Inflate(-1, -1); if (m_Buttons.size() == 0) { COLORREF borderColor = m_ColorMap.GetColor(Normal, Border); DrawRectArea(borderRect, graphics, borderColor, m_CornerRadius, m_BorderPenWidth); } for (int btnId = 0; btnId < m_Buttons.size(); ++btnId) { BtnInfo* pBtnInfo = &m_Buttons[btnId]; CRgn btnRgn; CRect t(pBtnInfo->m_rect); t.right += 1; t.bottom += 1; CreateRectRgnInDevicePoints(pDC, &btnRgn, t); btnRgn.CombineRgn(&btnRgn, &bkgndRgn, RGN_AND); pDC->SelectClipRgn(&btnRgn); ControlState buttonState = GetButtonState(pBtnInfo); // Highlight if (buttonState != Press) pDC->FillSolidRect(pBtnInfo->m_rect, m_ColorMap.GetColor(buttonState, BorderLight)); // Border graphics.SetClip(btnRgn); COLORREF borderColor = m_ColorMap.GetColor(buttonState, Border); DrawRectArea(borderRect, graphics, borderColor, m_CornerRadius, m_BorderPenWidth); graphics.ResetClip(); CRgn offsetRgn1; offsetRgn1.CreateRectRgn(0, 0, 0, 0); offsetRgn1.CopyRgn(&btnRgn); offsetRgn1.OffsetRgn(m_BorderPenWidth + 1, m_BorderPenWidth + 1); CRgn offsetRgn2; offsetRgn2.CreateRectRgn(0, 0, 0, 0); offsetRgn2.CopyRgn(&btnRgn); offsetRgn2.OffsetRgn(-(m_BorderPenWidth + 1), -(m_BorderPenWidth + 1)); CRgn backRgn; backRgn.CreateRectRgn(0, 0, 0, 0); backRgn.CombineRgn(&offsetRgn1, &offsetRgn2, RGN_AND); pDC->SelectClipRgn(&backRgn); if (buttonState != Mouseover) { DrawGradient(pDC, t); /*Draw4ColorsGradientRect(t, *pDC, m_ColorMap.GetColor(buttonState, BackgroundTopGradientStart), m_ColorMap.GetColor(buttonState, BackgroundTopGradientFinish), m_ColorMap.GetColor(buttonState, BackgroundBottomGradientStart), m_ColorMap.GetColor(buttonState, BackgroundBottomGradientFinish), m_CornerRadius, TRUE);*/ } COLORREF textColor = RGB(80,80,80);//COLOR_GRAYTEXT;//COLOR_BTNTEXT; /*if (buttonState == Press) textColor = RGB(0, 122, 224);*/ pDC->SelectClipRgn(&btnRgn); CFont* pFont = GetFont(); int nFormat = DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS; CTTButton::DrawCaptionText(pDC, &pBtnInfo->m_rect, &pBtnInfo->m_rect, pBtnInfo->m_text, nFormat, pFont, textColor); } pDC->SelectClipRgn(&clientRgn); for (int btnId = 1; btnId < m_Buttons.size(); ++btnId) { BtnInfo* pPrevBtnInfo = &m_Buttons[btnId - 1]; BtnInfo* pCurBtnInfo = &m_Buttons[btnId]; ControlState prevBtnState = GetButtonState(pPrevBtnInfo); ControlState curBtnState = GetButtonState(pCurBtnInfo); ControlState state = Normal; if (prevBtnState == Press || curBtnState == Press) state = Press; else if (prevBtnState == Mouseover || curBtnState == Mouseover) state = Mouseover; COLORREF borderColor = m_ColorMap.GetColor(state, Border); CPen borderPen(PS_SOLID, m_BorderPenWidth, borderColor); pDC->SelectObject(borderPen); pDC->MoveTo(pPrevBtnInfo->m_rect.right, pPrevBtnInfo->m_rect.top); pDC->LineTo(pPrevBtnInfo->m_rect.right, pPrevBtnInfo->m_rect.bottom); } }
std::string mitk::EventFactory::EventToXML(mitk::InteractionEvent *event) { InternalEvent* ie = dynamic_cast<InternalEvent*> (event); if (ie != NULL) return ""; std::string eventClass = event->GetNameOfClass(); std::string eventXML = "<" + InteractionEventConst::xmlTagEventVariant() + " " + InteractionEventConst::xmlParameterEventClass() + "=\""; std::transform(eventClass.cbegin(), eventClass.cend(), eventClass.begin(), ::toupper); eventXML += eventClass + "\" >\n"; // here follow event specific attributes if (eventClass == "MOUSEPRESSEVENT" || eventClass == "MOUSERELEASEEVENT" || eventClass == "MOUSEDOUBLECLICKEVENT" || eventClass == "MOUSEMOVEEVENT" || eventClass == "MOUSEWHEELEVENT") { if (!(eventClass == "MOUSEMOVEEVENT") && !(eventClass == "MOUSEWHEELEVENT")) { // EventButton eventXML += " <" + InteractionEventConst::xmlTagAttribute() +" " + InteractionEventConst::xmlParameterName() + "=\"" + InteractionEventConst::xmlEventPropertyEventButton() + "\" "; eventXML += InteractionEventConst::xmlParameterValue() + "=\""; eventXML += GetEventButton(event); eventXML += "\"/>\n"; } // ButtonState if (GetButtonState(event) != "") { eventXML += " <" + InteractionEventConst::xmlTagAttribute() +" " + InteractionEventConst::xmlParameterName() + "=\"" + InteractionEventConst::xmlEventPropertyButtonState() + "\" "; eventXML += InteractionEventConst::xmlParameterValue() + "=\""; eventXML += GetButtonState(event); eventXML += "\"/>\n"; } // Modifiers if (GetModifierState(event) != "") { eventXML += " <" + InteractionEventConst::xmlTagAttribute() +" " + InteractionEventConst::xmlParameterName() + "=\"" + InteractionEventConst::xmlEventPropertyModifier() + "\" "; eventXML += InteractionEventConst::xmlParameterValue() + "=\""; eventXML += GetModifierState(event); eventXML += "\"/>\n"; } // Position on Screen eventXML += " <" + InteractionEventConst::xmlTagAttribute() +" " + InteractionEventConst::xmlParameterName() + "=\"" + InteractionEventConst::xmlEventPropertyPositionOnScreen() + "\" "; eventXML += InteractionEventConst::xmlParameterValue() + "=\""; eventXML += GetPositionOnScreen(event); eventXML += "\"/>\n"; // Position in World eventXML += " <" + InteractionEventConst::xmlTagAttribute() +" " + InteractionEventConst::xmlParameterName() + "=\"" + InteractionEventConst::xmlEventPropertyPositionInWorld() + "\" "; eventXML += InteractionEventConst::xmlParameterValue() + "=\""; eventXML += GetPositionInWorld(event); eventXML += "\"/>\n"; } else if (eventClass == "INTERACTIONKEYEVENT") { mitk::InteractionKeyEvent* ke = dynamic_cast<mitk::InteractionKeyEvent*>(event); // key eventXML += " <" + InteractionEventConst::xmlTagAttribute() +" " + InteractionEventConst::xmlParameterName() + "=\"" + InteractionEventConst::xmlEventPropertyKey() + "\" "; eventXML += InteractionEventConst::xmlParameterValue() + "=\""; eventXML += ke->GetKey(); eventXML += "\"/>\n"; } else { MITK_WARN << "Event not recognized, discarding event of type " << event->GetNameOfClass(); } if (eventClass == "MOUSEWHEELEVENT") { MouseWheelEvent* we = dynamic_cast<MouseWheelEvent*> (event); int delta = we->GetWheelDelta(); std::stringstream ss; ss << delta; eventXML += " <" + InteractionEventConst::xmlTagAttribute() +" " + InteractionEventConst::xmlParameterName() + "=\"" + InteractionEventConst::xmlEventPropertyWheelDelta() + "\" "; eventXML += InteractionEventConst::xmlParameterValue() + "=\""; eventXML += ss.str(); eventXML += "\"/>\n"; eventXML += " <" + InteractionEventConst::xmlTagAttribute() +" " + InteractionEventConst::xmlParameterName() + "=\"" + InteractionEventConst::xmlEventPropertyScrollDirection() + "\" "; eventXML += InteractionEventConst::xmlParameterValue() + "=\""; eventXML += delta < 0 ? "DOWN" : "UP"; eventXML += "\"/>\n"; } // Renderer name eventXML += " <" + InteractionEventConst::xmlTagAttribute() +" " + InteractionEventConst::xmlParameterName() + "=\"" + InteractionEventConst::xmlEventPropertyRendererName() + "\" "; eventXML += InteractionEventConst::xmlParameterValue() + "=\""; eventXML += event->GetSender()->GetName(); eventXML += "\"/>\n"; // closing tag: eventXML += "</" + InteractionEventConst::xmlTagEventVariant() + ">"; return eventXML; }