void YSongListItemUI::DoPaint(HDC hDC, const RECT& rcPaint) { if( !::IntersectRect(&m_rcPaint, &rcPaint, &m_rcItem) ) return; ASSERT(GetOwner()); // spSongInfoT spSong = thePlayCenter->GetCurrentPlayingSong(); // int nCurPlayListLocalId = thePlayCenter->GetListIndex(); spSongInfoT spSong = thePlayListMgr->GetCurSong(); spPlayListInfoT spList = thePlayListMgr->GetCurList(); if (spSong&&*spSong==*_spSongInfo&&spList&&spList->GetLocalId()==((CListUI*)GetOwner())->GetTag()) { if (SongItemExpHeight != GetFixedHeight()) { SetFixedHeight(SongItemExpHeight); _pNormalLayout->SetVisible(false); _pPushLayout->SetVisible(true); if (_spSongInfo) { _pPushDownLoad->SetVisible(!_spSongInfo->IsLocal()); _pPushShare->SetVisible(!_spSongInfo->IsLocal()); } } TListInfoUI* pInfo = m_pOwner->GetListInfo(); if(pInfo) { DWORD dwSelBkColor = ((CListUI*)GetOwner())->GetSelectedItemBkColor(); SetBkColor(dwSelBkColor); } ChangeIcon(thePlayer->GetStatus()); } else { if (IsSelected() && ((CListUI*)GetOwner())->GetSelCount() == 1) { _pPushLayout->SetVisible(false); _pNormalLayout->SetVisible(true); // _pNorButtonMenu->SetVisible(true); }else { _pPushLayout->SetVisible(false); _pNormalLayout->SetVisible(true); // _pNorButtonMenu->SetVisible(false); } if(SongItemHeight != GetFixedHeight()) SetFixedHeight(SongItemHeight); ChangeIcon(em_stop); } int nIndex = ((CListUI*)GetOwner())->GetItemIndex(this); _pNorLabelIndex->SetText(mci::ToString(nIndex+1)); _pPushLabelIndex->SetText(mci::ToString(nIndex+1)); __super::DoPaint(hDC,rcPaint); }
VOID CDUIIconTextItem::SetExpand(BOOL bExpand) { m_bExpand = bExpand; if(m_bExpand) { SetFixedHeight(m_nExpandHeight); } else { SetFixedHeight(m_nNormalHeight); } }
bool CBitmapControl::Refresh(Window* wnd, bool captrue, bool mirror) { int item_w = m_rcItem.right - m_rcItem.left; int item_h = m_rcItem.bottom - m_rcItem.top; if (auto_size_) { item_w = GetMaxWidth(); item_h = GetMaxHeight(); } bool ret = false; if (item_w > 0 && item_h > 0) { parent_wnd_ = wnd; data_.resize(item_w * item_h * 4); ret = video_frame_mng_->GetVideoFrame((captrue ? "" : account_), timestamp_, (char*)data_.c_str(), item_w, item_h, mirror); if (ret) { width_ = item_w; height_ = item_h; if (auto_size_) { SetFixedWidth(width_); SetFixedHeight(height_); } Invalidate(); } } return ret; }
SectionBar::SectionBar( Control& parent ) : Control( parent ), m_section( nullptr ) { SetObjectId( "IWSectionBar" ); SetFocusStyle( FocusStyle::NoFocus ); SetSizer( Global_Sizer ); Global_Sizer.AddSpacing( 1 ); Global_Sizer.Add( Title_Sizer ); Global_Sizer.AddSpacing( 1 ); Title_Sizer.AddSpacing( 4 ); Title_Sizer.Add( Title_Label ); Title_Sizer.AddStretch(); Title_Sizer.Add( Title_ToolButton ); Title_Sizer.AddSpacing( 4 ); Title_Label.SetText( String( 'M' ) ); Title_Label.SetTextAlignment( TextAlign::Left|TextAlign::VertCenter ); Title_Label.SetText( String() ); Title_ToolButton.SetIcon( Bitmap( ScaledResource( contract_icon ) ) ); Title_ToolButton.SetScaledFixedSize( 17, 17 ); Title_ToolButton.SetFocusStyle( FocusStyle::NoFocus ); Title_ToolButton.OnClick( (Button::click_event_handler)&SectionBar::ButtonClick, *this ); AdjustToContents(); SetFixedHeight(); OnMousePress( (Control::mouse_button_event_handler)&SectionBar::MousePress, *this ); OnShow( (Control::event_handler)&SectionBar::ControlShow, *this ); }
void CControlUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue) { if( _tcscmp(pstrName, _T("id")) == 0 ) SetID(_ttoi(pstrValue)); else if(_tcscmp(pstrName,_T("font")) == 0) SetFont(_ttoi(pstrValue)); else if(_tcscmp(pstrName, _T("name")) == 0) SetName(pstrValue); else if( _tcscmp(pstrName, _T("width")) == 0 ) SetFixedWidth(_ttoi(pstrValue)); else if( _tcscmp(pstrName, _T("height")) == 0 ) SetFixedHeight(_ttoi(pstrValue)); else if( _tcscmp(pstrName, _T("minwidth")) == 0 ) SetMinWidth(_ttoi(pstrValue)); else if( _tcscmp(pstrName, _T("minheight")) == 0 ) SetMinHeight(_ttoi(pstrValue)); else if( _tcscmp(pstrName, _T("maxwidth")) == 0 ) SetMaxWidth(_ttoi(pstrValue)); else if( _tcscmp(pstrName, _T("maxheight")) == 0 ) SetMaxHeight(_ttoi(pstrValue)); else if( _tcscmp(pstrName, _T("inset")) == 0) { RECT rcInset = { 0 }; LPTSTR pstr = NULL; rcInset.left = _tcstol(pstrValue, &pstr, 10); rcInset.top = _tcstol(pstr + 1, &pstr, 10); rcInset.right = _tcstol(pstr + 1, &pstr, 10); rcInset.bottom = _tcstol(pstr + 1, &pstr, 10); SetInset(rcInset); } else if(_tcscmp(pstrName, _T("visible")) == 0){ bool bVisible = _tcscmp(pstrValue, _T("true"))==0; SetVisible(bVisible); } else if(_tcscmp(pstrName, _T("display")) == 0) SetDisplayed(_tcscmp(pstrValue, _T("true"))==0); else{ #ifdef _DEBUG MessageBox(NULL, pstrValue, pstrName, MB_ICONEXCLAMATION); #endif } }
void CGifAnimUI::InitGifImage() { m_pGifImage = CRenderEngine::GdiplusLoadImage(GetBkImage()); if ( NULL == m_pGifImage ) return; UINT nCount = 0; nCount = m_pGifImage->GetFrameDimensionsCount(); GUID* pDimensionIDs = new GUID[ nCount ]; m_pGifImage->GetFrameDimensionsList( pDimensionIDs, nCount ); m_nFrameCount = m_pGifImage->GetFrameCount( &pDimensionIDs[0] ); if (m_nFrameCount > 1) { int nSize = m_pGifImage->GetPropertyItemSize(PropertyTagFrameDelay); m_pPropertyItem = (Gdiplus::PropertyItem*) malloc(nSize); m_pGifImage->GetPropertyItem(PropertyTagFrameDelay, nSize, m_pPropertyItem); } delete[] pDimensionIDs; pDimensionIDs = NULL; if (m_bIsAutoSize) { SetFixedWidth(m_pGifImage->GetWidth()); SetFixedHeight(m_pGifImage->GetHeight()); } if (m_bIsAutoPlay) { PlayGif(); } }
CUIProgress::CUIProgress() : m_bHorizontal(true), m_nMin(0), m_nMax(100), m_nValue(0), m_bStretchForeImage(true), m_nPadding(0) { m_uTextStyle = DT_SINGLELINE | DT_CENTER; SetFixedHeight(12); }
NumericEdit::NumericEdit( Control& parent ) : Control( parent ), m_value( 0 ), m_lowerBound( 0 ), m_upperBound( 1 ), m_precision( 6 ), m_real( true ), m_autoEditWidth( true ), m_scientific( false ), m_sciTriggerExp( -1 ) { SetSizer( sizer ); sizer.SetSpacing( 4 ); sizer.Add( label ); sizer.Add( edit ); label.SetTextAlignment( TextAlign::Right|TextAlign::VertCenter ); label.OnMousePress( (Control::mouse_button_event_handler)&NumericEdit::MousePress, *this ); edit.OnEditCompleted( (Edit::edit_event_handler)&NumericEdit::EditCompleted, *this ); edit.OnReturnPressed( (Edit::edit_event_handler)&NumericEdit::ReturnPressed, *this ); edit.OnGetFocus( (Control::event_handler)&NumericEdit::GetFocus, *this ); edit.OnLoseFocus( (Control::event_handler)&NumericEdit::LoseFocus, *this ); AdjustToContents(); SetFixedHeight(); SetBackgroundColor( 0 ); // transparent background SetChildToFocus( edit ); }
CDUITreeNode::CDUITreeNode(void) { m_bExpand = FALSE; m_nItemHeight = 30; SetFixedHeight(30); m_bSelected = FALSE; }
void CMenuElementUI::SetLineType() { m_bDrawLine = true; if (GetFixedHeight() == 0 || GetFixedHeight() == ITEM_DEFAULT_HEIGHT ) SetFixedHeight(DEFAULT_LINE_HEIGHT); SetMouseChildEnabled(false); SetMouseEnabled(false); SetEnabled(false); }
OpPersonalbar::OpPersonalbar(PrefsCollectionUI::integerpref prefs_setting) : OpToolbar(prefs_setting), m_is_inline(FALSE), m_listeners_set(FALSE), m_disable_indicator(FALSE) { SetListener(this); SetWrapping(OpBar::WRAPPING_OFF); SetShrinkToFit(TRUE); // Not use FIXED_HEIGHT_BUTTON_AND_EDIT since edit it too high SetFixedHeight(FIXED_HEIGHT_BUTTON); SetButtonType(OpButton::TYPE_LINK); SetStandardToolbar(FALSE); SetTabStop(TRUE); }
void CMusicListItemUI::SetPlaying(bool bPlay /*= true*/) { if (m_pMusicListTab == NULL) m_pMusicListTab = static_cast<CTabLayoutUI*>(m_pManager->FindSubControlByName(this, kMusicTabControlName)); if (m_pMusicListTab == NULL) return; if (bPlay) { TListInfoUI* pInfo = m_pOwner->GetListInfo(); m_pMusicListTab->SelectItem(1); SetFixedHeight(kMusicListItemActivatedHeight); SetBkImage(pInfo->sDisabledImage); m_pMusicListTab->SetFixedHeight(kMusicListItemActivatedHeight); } else { m_pMusicListTab->SelectItem(0); SetFixedHeight(kMusicListItemNormalHeight); SetBkImage(_T("")); m_pMusicListTab->SetFixedHeight(kMusicListItemNormalHeight); } }
void DrizzleIntegrationInterface::__ToggleSection( SectionBar& sender, Control& section, bool start ) { if ( start ) GUI->InputData_TreeBox.SetFixedHeight(); else { GUI->InputData_TreeBox.SetMinHeight( FILELIST_MINHEIGHT( Font() ) ); GUI->InputData_TreeBox.SetMaxHeight( int_max ); if ( GUI->InputData_Control.IsVisible() ) SetVariableHeight(); else SetFixedHeight(); } }
void HDRCompositionInterface::__ToggleSection( SectionBar& sender, Control& section, bool start ) { if ( start ) GUI->InputImages_TreeBox.SetFixedHeight(); else { GUI->InputImages_TreeBox.SetMinHeight( IMAGELIST_MINHEIGHT( Font() ) ); GUI->InputImages_TreeBox.SetMaxHeight( int_max ); if ( GUI->InputImages_Control.IsVisible() ) SetVariableHeight(); else SetFixedHeight(); } }
void CMenuElementUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue) { if( _tcsicmp(pstrName, _T("icon")) == 0){ SetIcon(pstrValue); } else if( _tcsicmp(pstrName, _T("iconsize")) == 0 ) { LPTSTR pstr = NULL; LONG cx = 0, cy = 0; cx = _tcstol(pstrValue, &pstr, 10); ASSERT(pstr); cy = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); SetIconSize(cx, cy); } else if( _tcsicmp(pstrName, _T("checkitem")) == 0 ) { SetCheckItem(_tcsicmp(pstrValue, _T("true")) == 0 ? true : false); } else if( _tcsicmp(pstrName, _T("ischeck")) == 0 ) { if (CMenuWnd::GetGlobalContextMenuObserver().GetMenuCheckInfo() != NULL && CMenuWnd::GetGlobalContextMenuObserver().GetMenuCheckInfo()->find(GetName()) == CMenuWnd::GetGlobalContextMenuObserver().GetMenuCheckInfo()->end()) { SetChecked(_tcsicmp(pstrValue, _T("true")) == 0 ? true : false); } } else if( _tcsicmp(pstrName, _T("linetype")) == 0){ if (_tcsicmp(pstrValue, _T("true")) == 0) SetLineType(); } else if( _tcsicmp(pstrName, _T("expland")) == 0 ) { SetShowExplandIcon(_tcsicmp(pstrValue, _T("true")) == 0 ? true : false); } else if( _tcsicmp(pstrName, _T("linecolor")) == 0){ if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue); LPTSTR pstr = NULL; SetLineColor(_tcstoul(pstrValue, &pstr, 16)); } else if( _tcsicmp(pstrName, _T("linepadding")) == 0 ) { RECT rcInset = { 0 }; LPTSTR pstr = NULL; rcInset.left = _tcstol(pstrValue, &pstr, 10); ASSERT(pstr); rcInset.top = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); rcInset.right = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); rcInset.bottom = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); SetLinePadding(rcInset); } else if ( _tcsicmp(pstrName, _T("height")) == 0){ SetFixedHeight(_ttoi(pstrValue)); } else CListContainerElementUI::SetAttribute(pstrName, pstrValue); }
DUI_BGN_NAMESPCE /////////////// CDUIIconTextItem ////////////////// CDUIIconTextItem::CDUIIconTextItem() { m_bSelect = FALSE; m_bExpand = FALSE; m_bGroup = FALSE; m_nIconIndex = 0; m_dwItemData = 0; m_nNormalHeight = 25; m_nExpandHeight = 50; SetFixedHeight(m_nNormalHeight); }
void FormWindow::Init(const FormDef& def) { if (def.GetRect().w > 0 && def.GetRect().h > 0) { // if form size is specified in def, and it is // smaller than the current screen size, // center the form on the display: Rect r = def.GetRect(); if (r.w < screen->Width()) { r.x = (screen->Width() - r.w) / 2; } else { r.x = 0; r.w = screen->Width(); } if (r.h < screen->Height()) { r.y = (screen->Height() - r.h) / 2; } else { r.y = 0; r.h = screen->Height(); } MoveTo(r); } SetMargins(def.GetMargins()); SetTextInsets(def.GetTextInsets()); SetCellInsets(def.GetCellInsets()); SetCells(def.GetCells()); SetFixedWidth(def.GetFixedWidth()); SetFixedHeight(def.GetFixedHeight()); UseLayout(def.GetLayout().x_mins, def.GetLayout().y_mins, def.GetLayout().x_weights, def.GetLayout().y_weights); if (def.GetTexture().length() > 0) { DataLoader* loader = DataLoader::GetLoader(); loader->SetDataPath("Screens/"); loader->LoadTexture(def.GetTexture(), texture); loader->SetDataPath(""); } SetBackColor(def.GetBackColor()); SetForeColor(def.GetForeColor()); Font* f = FontMgr::Find(def.GetFont()); if (f) SetFont(f); SetTransparent(def.GetTransparent()); ListIter<CtrlDef> ctrl = def.GetControls(); while (++ctrl) { switch (ctrl->GetType()) { case WIN_DEF_FORM: case WIN_DEF_LABEL: default: CreateDefLabel(*ctrl); break; case WIN_DEF_BUTTON: CreateDefButton(*ctrl); break; case WIN_DEF_COMBO: CreateDefCombo(*ctrl); break; case WIN_DEF_IMAGE: CreateDefImage(*ctrl); break; case WIN_DEF_EDIT: CreateDefEdit(*ctrl); break; case WIN_DEF_LIST: CreateDefList(*ctrl); break; case WIN_DEF_SLIDER: CreateDefSlider(*ctrl); break; case WIN_DEF_RICH: CreateDefRichText(*ctrl); break; } } RegisterControls(); DoLayout(); CalcGrid(); }
void FlexGrid::SetFixedSize(double w, double h) { SetFixedWidth(w); SetFixedHeight(h); }
void CControlUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue) { // ÊÇ·ñÑùʽ±í if(m_pManager != NULL) { LPCTSTR pStyle = m_pManager->GetStyle(pstrValue); if( pStyle != NULL) { ApplyAttributeList(pStyle); return; } } if( _tcsicmp(pstrName, _T("pos")) == 0 ) { RECT rcPos = { 0 }; LPTSTR pstr = NULL; rcPos.left = _tcstol(pstrValue, &pstr, 10); ASSERT(pstr); rcPos.top = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); rcPos.right = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); rcPos.bottom = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); SIZE szXY = {rcPos.left >= 0 ? rcPos.left : rcPos.right, rcPos.top >= 0 ? rcPos.top : rcPos.bottom}; SetFixedXY(szXY); SetFixedWidth(rcPos.right - rcPos.left); SetFixedHeight(rcPos.bottom - rcPos.top); } else if( _tcsicmp(pstrName, _T("float")) == 0 ) { CDuiString nValue = pstrValue; // ¶¯Ì¬¼ÆËãÏà¶Ô±ÈÀý if(nValue.Find(',') < 0) { SetFloat(_tcsicmp(pstrValue, _T("true")) == 0); } else { TPercentInfo piFloatPercent = { 0 }; LPTSTR pstr = NULL; piFloatPercent.left = _tcstod(pstrValue, &pstr); ASSERT(pstr); piFloatPercent.top = _tcstod(pstr + 1, &pstr); ASSERT(pstr); piFloatPercent.right = _tcstod(pstr + 1, &pstr); ASSERT(pstr); piFloatPercent.bottom = _tcstod(pstr + 1, &pstr); ASSERT(pstr); SetFloatPercent(piFloatPercent); SetFloat(true); } } else if( _tcsicmp(pstrName, _T("padding")) == 0 ) { RECT rcPadding = { 0 }; LPTSTR pstr = NULL; rcPadding.left = _tcstol(pstrValue, &pstr, 10); ASSERT(pstr); rcPadding.top = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); rcPadding.right = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); rcPadding.bottom = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); SetPadding(rcPadding); } else if( _tcsicmp(pstrName, _T("bkcolor")) == 0 || _tcsicmp(pstrName, _T("bkcolor1")) == 0 ) { while( *pstrValue > _T('\0') && *pstrValue <= _T(' ') ) pstrValue = ::CharNext(pstrValue); if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue); LPTSTR pstr = NULL; DWORD clrColor = _tcstoul(pstrValue, &pstr, 16); SetBkColor(clrColor); } else if( _tcsicmp(pstrName, _T("bkcolor2")) == 0 ) { while( *pstrValue > _T('\0') && *pstrValue <= _T(' ') ) pstrValue = ::CharNext(pstrValue); if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue); LPTSTR pstr = NULL; DWORD clrColor = _tcstoul(pstrValue, &pstr, 16); SetBkColor2(clrColor); } else if( _tcsicmp(pstrName, _T("bkcolor3")) == 0 ) { while( *pstrValue > _T('\0') && *pstrValue <= _T(' ') ) pstrValue = ::CharNext(pstrValue); if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue); LPTSTR pstr = NULL; DWORD clrColor = _tcstoul(pstrValue, &pstr, 16); SetBkColor3(clrColor); } else if( _tcsicmp(pstrName, _T("forecolor")) == 0 ) { while( *pstrValue > _T('\0') && *pstrValue <= _T(' ') ) pstrValue = ::CharNext(pstrValue); if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue); LPTSTR pstr = NULL; DWORD clrColor = _tcstoul(pstrValue, &pstr, 16); SetForeColor(clrColor); } else if( _tcsicmp(pstrName, _T("bordercolor")) == 0 ) { if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue); LPTSTR pstr = NULL; DWORD clrColor = _tcstoul(pstrValue, &pstr, 16); SetBorderColor(clrColor); } else if( _tcsicmp(pstrName, _T("focusbordercolor")) == 0 ) { if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue); LPTSTR pstr = NULL; DWORD clrColor = _tcstoul(pstrValue, &pstr, 16); SetFocusBorderColor(clrColor); } else if( _tcsicmp(pstrName, _T("colorhsl")) == 0 ) SetColorHSL(_tcsicmp(pstrValue, _T("true")) == 0); else if( _tcsicmp(pstrName, _T("bordersize")) == 0 ) { CDuiString nValue = pstrValue; if(nValue.Find(',') < 0) { SetBorderSize(_ttoi(pstrValue)); RECT rcPadding = {0}; SetBorderSize(rcPadding); } else { RECT rcPadding = { 0 }; LPTSTR pstr = NULL; rcPadding.left = _tcstol(pstrValue, &pstr, 10); ASSERT(pstr); rcPadding.top = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); rcPadding.right = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); rcPadding.bottom = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); SetBorderSize(rcPadding); } } else if( _tcsicmp(pstrName, _T("leftbordersize")) == 0 ) SetLeftBorderSize(_ttoi(pstrValue)); else if( _tcsicmp(pstrName, _T("topbordersize")) == 0 ) SetTopBorderSize(_ttoi(pstrValue)); else if( _tcsicmp(pstrName, _T("rightbordersize")) == 0 ) SetRightBorderSize(_ttoi(pstrValue)); else if( _tcsicmp(pstrName, _T("bottombordersize")) == 0 ) SetBottomBorderSize(_ttoi(pstrValue)); else if( _tcsicmp(pstrName, _T("borderstyle")) == 0 ) SetBorderStyle(_ttoi(pstrValue)); else if( _tcsicmp(pstrName, _T("borderround")) == 0 ) { SIZE cxyRound = { 0 }; LPTSTR pstr = NULL; cxyRound.cx = _tcstol(pstrValue, &pstr, 10); ASSERT(pstr); cxyRound.cy = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); SetBorderRound(cxyRound); } else if( _tcsicmp(pstrName, _T("bkimage")) == 0 ) SetBkImage(pstrValue); else if( _tcsicmp(pstrName, _T("foreimage")) == 0 ) SetForeImage(pstrValue); else if( _tcsicmp(pstrName, _T("width")) == 0 ) SetFixedWidth(_ttoi(pstrValue)); else if( _tcsicmp(pstrName, _T("height")) == 0 ) SetFixedHeight(_ttoi(pstrValue)); else if( _tcsicmp(pstrName, _T("minwidth")) == 0 ) SetMinWidth(_ttoi(pstrValue)); else if( _tcsicmp(pstrName, _T("minheight")) == 0 ) SetMinHeight(_ttoi(pstrValue)); else if( _tcsicmp(pstrName, _T("maxwidth")) == 0 ) SetMaxWidth(_ttoi(pstrValue)); else if( _tcsicmp(pstrName, _T("maxheight")) == 0 ) SetMaxHeight(_ttoi(pstrValue)); else if( _tcsicmp(pstrName, _T("name")) == 0 ) SetName(pstrValue); else if( _tcsicmp(pstrName, _T("drag")) == 0 ) SetDragEnable(_tcsicmp(pstrValue, _T("true")) == 0); else if( _tcsicmp(pstrName, _T("drop")) == 0 ) SetDropEnable(_tcsicmp(pstrValue, _T("true")) == 0); else if( _tcsicmp(pstrName, _T("resourcetext")) == 0 ) SetResourceText(_tcsicmp(pstrValue, _T("true")) == 0); else if( _tcsicmp(pstrName, _T("text")) == 0 ) SetText(pstrValue); else if( _tcsicmp(pstrName, _T("tooltip")) == 0 ) SetToolTip(pstrValue); else if( _tcsicmp(pstrName, _T("userdata")) == 0 ) SetUserData(pstrValue); else if( _tcsicmp(pstrName, _T("enabled")) == 0 ) SetEnabled(_tcsicmp(pstrValue, _T("true")) == 0); else if( _tcsicmp(pstrName, _T("mouse")) == 0 ) SetMouseEnabled(_tcsicmp(pstrValue, _T("true")) == 0); else if( _tcsicmp(pstrName, _T("keyboard")) == 0 ) SetKeyboardEnabled(_tcsicmp(pstrValue, _T("true")) == 0); else if( _tcsicmp(pstrName, _T("visible")) == 0 ) SetVisible(_tcsicmp(pstrValue, _T("true")) == 0); else if( _tcsicmp(pstrName, _T("float")) == 0 ) SetFloat(_tcsicmp(pstrValue, _T("true")) == 0); else if( _tcsicmp(pstrName, _T("shortcut")) == 0 ) SetShortcut(pstrValue[0]); else if( _tcsicmp(pstrName, _T("menu")) == 0 ) SetContextMenuUsed(_tcsicmp(pstrValue, _T("true")) == 0); else if( _tcsicmp(pstrName, _T("cursor")) == 0 && pstrValue) { if( _tcsicmp(pstrValue, _T("arrow")) == 0 ) SetCursor(DUI_ARROW); else if( _tcsicmp(pstrValue, _T("ibeam")) == 0 ) SetCursor(DUI_IBEAM); else if( _tcsicmp(pstrValue, _T("wait")) == 0 ) SetCursor(DUI_WAIT); else if( _tcsicmp(pstrValue, _T("cross")) == 0 ) SetCursor(DUI_CROSS); else if( _tcsicmp(pstrValue, _T("uparrow")) == 0 ) SetCursor(DUI_UPARROW); else if( _tcsicmp(pstrValue, _T("size")) == 0 ) SetCursor(DUI_SIZE); else if( _tcsicmp(pstrValue, _T("icon")) == 0 ) SetCursor(DUI_ICON); else if( _tcsicmp(pstrValue, _T("sizenwse")) == 0 ) SetCursor(DUI_SIZENWSE); else if( _tcsicmp(pstrValue, _T("sizenesw")) == 0 ) SetCursor(DUI_SIZENESW); else if( _tcsicmp(pstrValue, _T("sizewe")) == 0 ) SetCursor(DUI_SIZEWE); else if( _tcsicmp(pstrValue, _T("sizens")) == 0 ) SetCursor(DUI_SIZENS); else if( _tcsicmp(pstrValue, _T("sizeall")) == 0 ) SetCursor(DUI_SIZEALL); else if( _tcsicmp(pstrValue, _T("no")) == 0 ) SetCursor(DUI_NO); else if( _tcsicmp(pstrValue, _T("hand")) == 0 ) SetCursor(DUI_HAND); } else if( _tcsicmp(pstrName, _T("virtualwnd")) == 0 ) SetVirtualWnd(pstrValue); else if( _tcsicmp(pstrName, _T("innerstyle")) == 0 ) { CDuiString sXmlData = pstrValue; sXmlData.Replace(_T("""), _T("\"")); LPCTSTR pstrList = sXmlData.GetData(); CDuiString sItem; CDuiString sValue; while( *pstrList != _T('\0') ) { sItem.Empty(); sValue.Empty(); while( *pstrList != _T('\0') && *pstrList != _T('=') ) { LPTSTR pstrTemp = ::CharNext(pstrList); while( pstrList < pstrTemp) { sItem += *pstrList++; } } ASSERT( *pstrList == _T('=') ); if( *pstrList++ != _T('=') ) return; ASSERT( *pstrList == _T('\"') ); if( *pstrList++ != _T('\"') ) return; while( *pstrList != _T('\0') && *pstrList != _T('\"') ) { LPTSTR pstrTemp = ::CharNext(pstrList); while( pstrList < pstrTemp) { sValue += *pstrList++; } } ASSERT( *pstrList == _T('\"') ); if( *pstrList++ != _T('\"') ) return; SetAttribute(sItem, sValue); if( *pstrList++ != _T(' ') && *pstrList++ != _T(',') ) return; } } }
CPageUI::CPageUI() { SetFixedHeight(20); SetFixedWidth(186); m_nGoPage = 0; m_nCurPage = 0; m_nTotalPage = 0; m_pEditGoPage = new CEditUI; m_pEditGoPage->SetFixedWidth(40); m_pEditGoPage->SetAttribute(_T("textpadding"), _T("2,1,2,1")); m_pEditGoPage->SetAttribute(_T("bordersize"), _T("1")); m_pEditGoPage->SetAttribute(_T("bordercolor"), _T("#FFBFBFBF")); m_pEditGoPage->SetAttribute(_T("textcolor"), _T("#ff333333")); m_pEditGoPage->SetAttribute(_T("tipvalue"), _T("转至...")); m_pEditGoPage->SetAttribute(_T("tipvaluecolor"), _T("#ff888888")); m_pEditGoPage->OnNotify += MakeDelegate(this, &CPageUI::OnEditGoPageEnter); m_pBtnGoPage = new CButtonUI; m_pBtnGoPage->SetFixedWidth(20); m_pBtnGoPage->SetText(_T("go")); m_pBtnGoPage->SetAttribute(_T("textpadding"), _T("2,0,2,1")); m_pBtnGoPage->SetAttribute(_T("bordersize"), _T("1")); m_pBtnGoPage->SetAttribute(_T("bordercolor"), _T("#FFBFBFBF")); m_pBtnGoPage->SetTextColor(0xff333333); m_pBtnGoPage->SetHotTextColor(0xff0099cc); m_pBtnGoPage->OnNotify += MakeDelegate(this, &CPageUI::OnBtnGoPageClick); m_pBtnLeftPage = new CButtonUI; m_pBtnLeftPage->SetFixedWidth(16); m_pBtnLeftPage->SetAttribute(_T("padding"), _T("10,2,0,2")); m_pBtnLeftPage->OnNotify += MakeDelegate(this, &CPageUI::OnBtnLeftPageClick); m_pLabCurPage = new CLabelUI; //m_pLabCurPage->SetFixedWidth(16); m_pLabCurPage->SetAutoCalcWidth(true); m_pLabCurPage->SetTextColor(0xff333333); m_pBtnRightPage = new CButtonUI; m_pBtnRightPage->SetFixedWidth(16); m_pBtnRightPage->SetAttribute(_T("padding"), _T("0,2,0,2")); m_pBtnRightPage->OnNotify += MakeDelegate(this, &CPageUI::OnBtnRightPageClick); m_pBtnRefresh = new CButtonUI; m_pBtnRefresh->SetFixedWidth(16); m_pBtnRefresh->SetEnabled(false); m_pBtnRefresh->SetToolTip("刷新当前页"); m_pBtnRefresh->SetAttribute(_T("padding"), _T("4,2,0,2")); m_pBtnRefresh->OnNotify += MakeDelegate(this, &CPageUI::OnBtnRefreshClick); Add(m_pEditGoPage); Add(m_pBtnGoPage); Add(m_pBtnLeftPage); Add(m_pLabCurPage); Add(m_pBtnRightPage); Add(m_pBtnRefresh); SetTotalPage(m_nTotalPage); SetCurPage(m_nCurPage); }
void Text::UpdateText(bool onResize) { rowWidths_.clear(); printText_.clear(); if (font_) { FontFace* face = font_->GetFace(fontSize_); if (!face) return; rowHeight_ = face->GetRowHeight(); int width = 0; int height = 0; int rowWidth = 0; auto rowHeight = RoundToInt(rowSpacing_ * rowHeight_); // First see if the text must be split up if (!wordWrap_) { printText_ = unicodeText_; printToText_.resize(printText_.size()); for (unsigned i = 0; i < printText_.size(); ++i) printToText_[i] = i; } else { int maxWidth = GetWidth(); unsigned nextBreak = 0; unsigned lineStart = 0; printToText_.clear(); for (unsigned i = 0; i < unicodeText_.size(); ++i) { unsigned j; unsigned c = unicodeText_[i]; if (c != '\n') { bool ok = true; if (nextBreak <= i) { int futureRowWidth = rowWidth; for (j = i; j < unicodeText_.size(); ++j) { unsigned d = unicodeText_[j]; if (d == ' ' || d == '\n') { nextBreak = j; break; } const FontGlyph* glyph = face->GetGlyph(d); if (glyph) { futureRowWidth += glyph->advanceX_; if (j < unicodeText_.size() - 1) futureRowWidth += face->GetKerning(d, unicodeText_[j + 1]); } if (d == '-' && futureRowWidth <= maxWidth) { nextBreak = j + 1; break; } if (futureRowWidth > maxWidth) { ok = false; break; } } } if (!ok) { // If did not find any breaks on the line, copy until j, or at least 1 char, to prevent infinite loop if (nextBreak == lineStart) { while (i < j) { printText_.push_back(unicodeText_[i]); printToText_.push_back(i); ++i; } } // Eliminate spaces that have been copied before the forced break while (printText_.size() && printText_.back() == ' ') { printText_.pop_back(); printToText_.pop_back(); } printText_.push_back('\n'); printToText_.push_back(Min(i, unicodeText_.size() - 1)); rowWidth = 0; nextBreak = lineStart = i; } if (i < unicodeText_.size()) { // When copying a space, position is allowed to be over row width c = unicodeText_[i]; const FontGlyph* glyph = face->GetGlyph(c); if (glyph) { rowWidth += glyph->advanceX_; if (i < unicodeText_.size() - 1) rowWidth += face->GetKerning(c, unicodeText_[i + 1]); } if (rowWidth <= maxWidth) { printText_.push_back(c); printToText_.push_back(i); } } } else { printText_.push_back('\n'); printToText_.push_back(Min(i, unicodeText_.size() - 1)); rowWidth = 0; nextBreak = lineStart = i; } } } rowWidth = 0; for (unsigned i = 0; i < printText_.size(); ++i) { unsigned c = printText_[i]; if (c != '\n') { const FontGlyph* glyph = face->GetGlyph(c); if (glyph) { rowWidth += glyph->advanceX_; if (i < printText_.size() - 1) rowWidth += face->GetKerning(c, printText_[i + 1]); } } else { width = Max(width, rowWidth); height += rowHeight; rowWidths_.push_back(rowWidth); rowWidth = 0; } } if (rowWidth) { width = Max(width, rowWidth); height += rowHeight; rowWidths_.push_back(rowWidth); } // Set at least one row height even if text is empty if (!height) height = rowHeight; // Set minimum and current size according to the text size, but respect fixed width if set if (!IsFixedWidth()) { if (wordWrap_) SetMinWidth(0); else { SetMinWidth(width); SetWidth(width); } } SetFixedHeight(height); charLocationsDirty_ = true; } else { // No font, nothing to render pageGlyphLocations_.clear(); } // If wordwrap is on, parent may need layout update to correct for overshoot in size. However, do not do this when the // update is a response to resize, as that could cause infinite recursion if (wordWrap_ && !onResize) { UIElement* parent = GetParent(); if (parent && parent->GetLayoutMode() != LM_FREE) parent->UpdateLayout(); } }
void SearchLayout::Notify(TNotifyUI& msg) { if (msg.pSender == m_edit) { if (msg.sType == DUI_MSGTYPE_TEXTCHANGED && m_SearchResultList) { m_SearchResultList->RemoveAll(); CDuiString inputText = m_edit->GetText(); if (inputText.IsEmpty()) { SetFixedHeight(30); m_SearchResultList->SetVisible(false); } else { module::UserInfoEntityVec userList; module::getUserListModule()->getSearchUserNameListByShortName(inputText.GetData(), userList); _updateSearchResultList(userList,1); module::GroupVec gidList; module::getGroupListModule()->GetSearchGroupNameListByShortName(inputText.GetData(), gidList); _updateSearchResultList(gidList,2); if (0 != GetHeight()) { m_SearchResultList->SetVisible(true); SetFixedHeight(0); } m_SearchResultList->ExpandAll(); } //NeedParentUpdate(); } } else if (msg.pSender == m_btnSearch && msg.sType == DUI_MSGTYPE_CLICK) { APP_LOG(LOG_DEBUG, _T("搜索按钮消息")); module::getGroupListModule()->onCreateDiscussionGrpDialog(); } else if (msg.sType == DUI_MSGTYPE_ITEMACTIVATE &&m_SearchResultList && -1 != m_SearchResultList->GetItemIndex(msg.pSender) && 0 == _tcsicmp(msg.pSender->GetClass(), _T("ListContainerElementUI"))) { Node* node = (Node*)msg.pSender->GetTag(); if (!m_SearchResultList->CanExpand(node)&& node) { std::string sid = util::cStringToString(CString(node->data().sId)); logic::GetLogic()->asynNotifyObserver(module::KEY_SESSION_OPENNEWSESSION, sid);//通知主窗口创建会话 //m_pManager->SendNotify(this, IM_MSG_DBCLICK_OPENNEWSESSION, WPARAM(sid.c_str()));//通知主窗口创建会话 } } else if (msg.sType == DUI_MSGTYPE_ITEMCLICK &&m_SearchResultList && -1 != m_SearchResultList->GetItemIndex(msg.pSender) && 0 == _tcsicmp(msg.pSender->GetClass(), _T("ListContainerElementUI"))) { Node* node = (Node*)msg.pSender->GetTag(); if (m_SearchResultList->CanExpand(node)) { m_SearchResultList->SetChildVisible(node, !node->data().child_visible_); } } }
void Text::UpdateText() { int width = 0; int height = 0; rowWidths_.Clear(); printText_.Clear(); PODVector<unsigned> printToText; if (font_) { const FontFace* face = font_->GetFace(fontSize_); if (!face) return; rowHeight_ = face->rowHeight_; int rowWidth = 0; int rowHeight = (int)(rowSpacing_ * rowHeight_); // First see if the text must be split up if (!wordWrap_) { printText_ = unicodeText_; printToText.Resize(printText_.Size()); for (unsigned i = 0; i < printText_.Size(); ++i) printToText[i] = i; } else { int maxWidth = GetWidth(); unsigned nextBreak = 0; unsigned lineStart = 0; for (unsigned i = 0; i < unicodeText_.Size(); ++i) { unsigned j; unsigned c = unicodeText_[i]; if (c != '\n') { bool ok = true; if (nextBreak <= i) { int futureRowWidth = rowWidth; for (j = i; j < unicodeText_.Size(); ++j) { unsigned d = unicodeText_[j]; if (d == ' ' || d == '\n') { nextBreak = j; break; } const FontGlyph* glyph = face->GetGlyph(d); if (glyph) { futureRowWidth += glyph->advanceX_; if (j < unicodeText_.Size() - 1) futureRowWidth += face->GetKerning(d, unicodeText_[j + 1]); } if (d == '-' && futureRowWidth <= maxWidth) { nextBreak = j + 1; break; } if (futureRowWidth > maxWidth) { ok = false; break; } } } if (!ok) { // If did not find any breaks on the line, copy until j, or at least 1 char, to prevent infinite loop if (nextBreak == lineStart) { while (i < j) { printText_.Push(unicodeText_[i]); printToText.Push(i); ++i; } } printText_.Push('\n'); printToText.Push(Min((int)i, (int)unicodeText_.Size() - 1)); rowWidth = 0; nextBreak = lineStart = i; } if (i < unicodeText_.Size()) { // When copying a space, position is allowed to be over row width c = unicodeText_[i]; const FontGlyph* glyph = face->GetGlyph(c); if (glyph) { rowWidth += glyph->advanceX_; if (i < text_.Length() - 1) rowWidth += face->GetKerning(c, unicodeText_[i + 1]); } if (rowWidth <= maxWidth) { printText_.Push(c); printToText.Push(i); } } } else { printText_.Push('\n'); printToText.Push(Min((int)i, (int)unicodeText_.Size() - 1)); rowWidth = 0; nextBreak = lineStart = i; } } } rowWidth = 0; for (unsigned i = 0; i < printText_.Size(); ++i) { unsigned c = printText_[i]; if (c != '\n') { const FontGlyph* glyph = face->GetGlyph(c); if (glyph) { rowWidth += glyph->advanceX_; if (i < printText_.Size() - 1) rowWidth += face->GetKerning(c, printText_[i + 1]); } } else { width = Max(width, rowWidth); height += rowHeight; rowWidths_.Push(rowWidth); rowWidth = 0; } } if (rowWidth) { width = Max(width, rowWidth); height += rowHeight; rowWidths_.Push(rowWidth); } // Set row height even if text is empty if (!height) height = rowHeight; // Store position & size of each character charPositions_.Resize(unicodeText_.Size() + 1); charSizes_.Resize(unicodeText_.Size()); unsigned rowIndex = 0; int x = GetRowStartPosition(rowIndex); int y = 0; for (unsigned i = 0; i < printText_.Size(); ++i) { charPositions_[printToText[i]] = IntVector2(x, y); unsigned c = printText_[i]; if (c != '\n') { const FontGlyph* glyph = face->GetGlyph(c); charSizes_[printToText[i]] = IntVector2(glyph ? glyph->advanceX_ : 0, rowHeight_); if (glyph) { x += glyph->advanceX_; if (i < printText_.Size() - 1) x += face->GetKerning(c, printText_[i + 1]); } } else { charSizes_[printToText[i]] = IntVector2::ZERO; x = GetRowStartPosition(++rowIndex); y += rowHeight; } } // Store the ending position charPositions_[unicodeText_.Size()] = IntVector2(x, y); } // Set minimum and current size according to the text size, but respect fixed width if set if (!IsFixedWidth()) { SetMinWidth(wordWrap_ ? 0 : width); SetWidth(width); } SetFixedHeight(height); }
CProgressUI::CProgressUI() : m_bShowText(false), m_bHorizontal(true), m_nMin(0), m_nMax(100), m_nValue(0), m_bStretchForeImage(true) { m_uTextStyle = DT_SINGLELINE | DT_CENTER; SetFixedHeight(12); }
CProgressUI::CProgressUI() : m_bHorizontal(true), m_nMin(0), m_nMax(100), m_nValue(0) { m_uTextStyle = DT_SINGLELINE | DT_CENTER; SetFixedHeight(12); m_uTextStyle = DT_VCENTER|DT_SINGLELINE; }