PropagateEvent EditText::OnEvent(const SDL_Event &evt) { // Obtain the absolute X and Y based on the parent position. SDL_Rect absoluteRect = GetAbsRect(); switch (evt.type) { case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: case SDL_MOUSEMOTION: case SDL_MOUSEWHEEL: { const SDL_MouseButtonEvent *mbe = reinterpret_cast<SDL_MouseButtonEvent*>((SDL_Event*)&evt); // Get the point of click or touch. SDL_Point point = { mbe->x, mbe->y }; if (SDL_PointInRect(&point, &absoluteRect)) { return PropagateEvent::PROPAGATE_NO; } } break; } return PropagateEvent::PROPAGATE_YES; }
/** * @brief gets scrollcar info * @retval None */ void jddex_scrollbar::GetScrollBarInfo(JC_RECT *pstScrollBar) { JC_RECT stAbsRect; GetAbsRect(&stAbsRect); *pstScrollBar = stAbsRect ; }
/** * @brief displays a scroll bar * @retval None * displays a scroll bar */ void jddex_scrollbar::Show() { JC_RECT stAbsRect; GetAbsRect(&stAbsRect); JC_DOUBLE dScrollCarPos ; JC_DOUBLE dScrollCarHieght ; JC_DOUBLE uiActualheight; mmi_trace(1,(PCSTR)"jddex_scrollbar::Show"); if(m_stScrollInfo.uiMaxPos == 0 || \ m_stScrollInfo.uiMaxPos <= m_stScrollInfo.uiPageSize) { JC_RECT stTempCarRect; mmi_trace(1,(PCSTR)"if condition [%d] [%d] ", m_stScrollInfo.uiMaxPos, m_stScrollInfo.uiPageSize); stTempCarRect = stAbsRect; stTempCarRect.iTop = jddex_GetDevicePropTop()+ jwap_GetScrollbarbarArrowHight() ; stTempCarRect.uiHeight = jddex_GetDeviceRenderHeight() - (2*jwap_GetScrollbarbarArrowHight()); jddex_DrawScrollBarControl(stAbsRect, stTempCarRect ); return; } uiActualheight = m_stScrollInfo.uiPageSize - (2*jwap_GetScrollbarbarArrowHight()); m_stScrollCar.iLeft = stAbsRect.iLeft; dScrollCarHieght = (JC_DOUBLE) (uiActualheight*m_stScrollInfo.uiPageSize) / (double) (m_stScrollInfo.uiMaxPos) ; m_stScrollCar.uiHeight = jdd_MiscCeil(dScrollCarHieght); dScrollCarPos = ((JC_DOUBLE)uiActualheight/(JC_DOUBLE)m_stScrollInfo.uiMaxPos)*(double)m_stScrollInfo.uiCurrPos ; m_stScrollCar.iTop = dScrollCarPos + jddex_GetDevicePropTop()+ jwap_GetScrollbarbarArrowHight() ; if(m_stScrollCar.uiHeight < SCROLL_CAR_MIN_HEIGHT) { m_stScrollCar.uiHeight = SCROLL_CAR_MIN_HEIGHT; m_stScrollCar.iTop -= SCROLL_CAR_MIN_HEIGHT; if(m_stScrollCar.iTop < CST_TITLE_HEIGHT) m_stScrollCar.iTop = CST_TITLE_HEIGHT; } //error condition shouldnt occur if((m_stScrollCar.uiHeight+m_stScrollCar.iTop) > \ (jwap_GetScrollbarbarArrowHight()+uiActualheight+jddex_GetDevicePropTop())) { m_stScrollCar.uiHeight = (JC_UINT32)(jwap_GetScrollbarbarArrowHight()+uiActualheight + jddex_GetDevicePropTop()- m_stScrollCar.iTop ); } jddex_DrawScrollBarControl(stAbsRect, m_stScrollCar ); }
void Sprite::Invalidate() { // 0指针访问 不挂是因为x64系统一个bug 记得打开调试中的Win32异常断点 HostWindow *wnd = GetHostWindow(); if (wnd) { RECT rc; Gdiplus::RectF rf = GetAbsRect(); rc.left = (LONG)(rf.GetLeft() - 0.5f); rc.top = (LONG)(rf.GetTop() - 0.5f); // TODO FIXME 这个值是试出来的 不知其所以然 rc.right = (LONG)(rf.GetRight() + 1.5f); // 缩小窗口TabCtrl会有拖影 这里改成2 就可以消除拖影现象 rc.bottom = (LONG)(rf.GetBottom() + 1.5f); // 很诡异 可能是因为GdiPlus认为x取大的 width也取大的 ::InvalidateRect(wnd->GetHWND(), &rc, TRUE); } }
/** * @brief dispalys a listbox * @retval None * displays the listbox based on its state */ void jddex_listbox::Show() { JC_RECT stAbsRect, stTextRect, stIconRect; JC_INT32 iBorderColor ; JC_UINT32 uiVisibleRows = 0; JC_UINT32 uiWidth = 0, uiHeight = 0 ; JDDEX_LIST_ITEM * pstListItems = *m_stJddexListBox.pstListItems; GetAbsRect(&stAbsRect); if(m_stListBox.uiVisibleRows == 0) uiVisibleRows = m_stListBox.uiNumberItems; else uiVisibleRows = m_stListBox.uiVisibleRows; if(m_bIsFocussed) { iBorderColor = JDDEX_DEFAULT_BLUE; } else { iBorderColor = JDDEX_DEFAULT_BLACK ; } jddex_DrawFormattedRect(&stAbsRect,iBorderColor, JDDEX_DEFAULT_WHITE, JDDEX_DEFAULT_LISTBOX_BORDER_WIDTH); jddex_GetListBoxIConDimensions(&uiWidth, &uiHeight); stTextRect = stAbsRect; stTextRect.uiWidth -= uiWidth; if(m_stListBox.uiNumberItems > 0) { //display the first selcted if any or dispaly the 1st list item jddex_FormattedDrawTextEx(pstListItems[GetFirstSelection()].psText, stTextRect, m_stControlStyle, E_JDDEX_LEFT_ALLIGN|E_JDDEX_MIDDLE_ALLIGN); } stIconRect.uiWidth = uiWidth; // width of the icon stIconRect.uiHeight = uiHeight; // height of the icon stIconRect.iLeft = stAbsRect.iLeft + stAbsRect.uiWidth - uiWidth; stIconRect.iTop = stAbsRect.iTop; //draw the icon at the end of the box jddex_DrawFormattedListBoxIcon(&stIconRect); }
/** * @brief dispalys a object text * @retval None * displays the object text */ void jddex_audio::Show() { JC_RECT stAbsRect; GetAbsRect(&stAbsRect); if(stAbsRect.uiWidth == 0 || stAbsRect.uiHeight== 0) { return; } if(ALTOBJECT_RECT_WIDTH < stAbsRect.uiWidth && ALTOBJECT_RECT_HEIGHT < stAbsRect.uiHeight ) { jddex_DrawFormattedRect(&stAbsRect,JDDEX_DEFAULT_BLACK, JDDEX_DEFAULT_RED, JDDEX_IMAGE_BORDER_WIDTH); } stAbsRect.iLeft += ALTOBJECT_RECT_WIDTH+ALTOBJECT_RECT_MARGIN; // jddex_FormattedDrawText(m_pszText, stAbsRect, m_stControlStyle); }
void EditText::OnDraw() { SDL_Rect absRect = GetAbsRect(); if (m_drawBackground) { // Draw a rectangle as a containing "field" SDL_SetRenderDrawColor(m_renderer, m_bgColor.r, m_bgColor.g, m_bgColor.b, m_bgColor.a); SDL_RenderFillRect(m_renderer, &absRect); } if (m_drawBorder) { SDL_SetRenderDrawColor(m_renderer, m_textColor.r, m_textColor.g, m_textColor.b, m_textColor.a); SDL_RenderDrawRect(m_renderer, &absRect); } if (!m_font || m_text.empty()) return; // If the tecture (that contines the string) is null -> create it! if (m_texture == nullptr) m_texture = NewTextTexture(m_text.c_str(), m_font, m_textColor, 64, m_renderer, absRect.w); // If the texture was not created, so, do not display it! Doh...! if (m_texture == nullptr) return; //Get the texture w/h so we can center it in the screen int iW, iH; SDL_QueryTexture(m_texture, NULL, NULL, &iW, &iH); int _x = absRect.x; int _y = absRect.y;// +(GetRect().h / 2 - iH / 2); absRect.x = 0; absRect.y = 0; absRect.w = (absRect.w > iW) ? iW : absRect.w; absRect.h = (absRect.h > iH) ? iH : absRect.h; RenderTexture(m_texture, m_renderer, _x, _y, &absRect); }