void SMCTreeCtrl::SetTreeWidth(int nWid) { m_nTreeWidth = nWid; m_nItemWid = -1; CalcItemWidth(0); CSize szView = GetViewSize(); szView.cx = m_nItemWid; SetViewSize(szView); Invalidate(); }
BOOL SMCTreeCtrl::SetColWidth(int iCol,int nWid) { if(iCol<0 || iCol>=m_arrColWidth.GetCount()) return FALSE; m_arrColWidth.SetAt(iCol,nWid); m_nItemWid = -1; CalcItemWidth(0); CSize szView = GetViewSize(); szView.cx = m_nItemWid; SetViewSize(szView); Invalidate(); return TRUE; }
void duTreeCtrl::GetViewSize(LPSIZE lpSize) { if (lpSize == NULL) return; lpSize->cx = lpSize->cy = 0; int nMaxWidth = 0; int nTotalHeight = 0; TreeCtrlItem *pItem = m_pRoot->pFirstChild; while (pItem) { int nItemWidth = CalcItemWidth(pItem); nMaxWidth = max(nMaxWidth, nItemWidth); nTotalHeight += m_nItemHeight; pItem = GetNextVisibleItem(pItem); } lpSize->cx = nMaxWidth; lpSize->cy = nTotalHeight; }
int SMCTreeCtrl::InsertColumn(int iCol,int nWid) { if(iCol < 0) iCol = m_arrColWidth.GetCount(); m_arrColWidth.InsertAt(iCol,nWid); HSTREEITEM hItem = GetRootItem(); while(hItem) { MCITEM *pMcItem = (MCITEM*)STreeCtrl::GetItemData(hItem); pMcItem->arrText.InsertAt(iCol,SStringT()); hItem = GetNextItem(hItem); } m_nItemWid = -1; CalcItemWidth(0); CSize szView = GetViewSize(); szView.cx = m_nItemWid; SetViewSize(szView); Invalidate(); return iCol; }
BOOL SMCTreeCtrl::DeleteColumn(int iCol) { if(iCol<0 || iCol>=m_arrColWidth.GetCount()) return FALSE; HSTREEITEM hItem = GetRootItem(); while(hItem) { MCITEM *pMcItem = (MCITEM*)STreeCtrl::GetItemData(hItem); pMcItem->arrText.RemoveAt(iCol); hItem = GetNextItem(hItem); } int nColWid = m_arrColWidth[iCol]; m_arrColWidth.RemoveAt(iCol); m_nItemWid = -1; CalcItemWidth(0); CSize szView = GetViewSize(); szView.cx = m_nItemWid; SetViewSize(szView); Invalidate(); return TRUE; }
bool ImGui::InputTextM(const char* label, std::string& text) { #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) bool ret = InputTextEx(label, &text[0], text.capacity(), ImVec2(0, 0), 0, 0, nullptr); return ret; #else ImGuiWindow* window = GetCurrentWindow(); if (window->SkipItems) return false; ImGuiContext& g = *GImGui; const ImGuiIO& io = g.IO; const ImGuiStyle& style = g.Style; //============================================ const ImGuiID id = window->GetID(label); const ImVec2 label_size = CalcTextSize(label, NULL, true); ImVec2 size = CalcItemSize(ImVec2(0, 0), CalcItemWidth(), label_size.y + style.FramePadding.y*2.0f); const ImRect frame_bb(window->DC.CursorPos, window->DC.CursorPos + size); const ImRect total_bb(frame_bb.Min, frame_bb.Max + ImVec2(label_size.x > 0.0f ? (style.ItemInnerSpacing.x + label_size.x) : 0.0f, 0.0f)); //============================================ ItemSize(total_bb, style.FramePadding.y); if (!ItemAdd(total_bb, &id)) return false; const bool hovered = IsHovered(frame_bb, id); if (hovered) { SetHoveredID(id); g.MouseCursor = ImGuiMouseCursor_TextInput; } ImGuiTextEditState& edit_state = g.InputTextState; const bool user_clicked = hovered && io.MouseClicked[0]; if (user_clicked) { if (g.ActiveId != id) { edit_state.CursorAnimReset(); } SetActiveID(id, window); FocusWindow(window); } else if (io.MouseClicked[0]) { // Release focus when we click outside if (g.ActiveId == id) SetActiveID(0, NULL); } if (g.ActiveId == id) { //window->DrawList->AddRectFilled(frame_bb.Min, frame_bb.Max, GetColorU32(ImGuiCol_TextSelectedBg), style.FrameRounding); RenderFrame(frame_bb.Min, frame_bb.Max, GetColorU32(ImGuiCol_TextSelectedBg), true, style.FrameRounding); ImRect frame_select(frame_bb); frame_select.Reduce(ImVec2(2, 2)); RenderFrame(frame_select.Min, frame_select.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding); }else { RenderFrame(frame_bb.Min, frame_bb.Max, GetColorU32(ImGuiCol_FrameBg), true, style.FrameRounding); } //============================================ int w = snprintf(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), "%s", text.c_str()); int tempSize = IM_ARRAYSIZE(g.TempBuffer); g.TempBuffer[tempSize - 1] = 0; const char* text_end = g.TempBuffer + ((w == -1) ? tempSize : w); // Render Text const ImVec4 clip_rect(frame_bb.Min.x, frame_bb.Min.y, frame_bb.Min.x + size.x, frame_bb.Min.y + size.y); // Not using frame_bb.Max because we have adjusted size ImVec2 render_pos = frame_bb.Min + style.FramePadding; window->DrawList->AddText(g.Font, g.FontSize, render_pos, GetColorU32(ImGuiCol_Text), g.TempBuffer, text_end, 0.0f, &clip_rect); if (label_size.x > 0) RenderText(ImVec2(frame_bb.Max.x + style.ItemInnerSpacing.x, frame_bb.Min.y + style.FramePadding.y), label); return user_clicked; #endif }