void CHexEdit::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) { nFlags; nRepCnt; BOOL bShift = GetKeyState(VK_SHIFT) & 0x80000000; BOOL bac = m_bNoAddressChange; m_bNoAddressChange = TRUE; switch(nChar) { case VK_DOWN: if(bShift) { if(!IsSelected()) { m_selStart = m_currentAddress; } Move(0,1); m_selEnd = m_currentAddress; if(m_currentMode == EDIT_HIGH || m_currentMode == EDIT_LOW) m_selEnd++; RedrawWindow(); break; } else SetSel(-1, -1); Move(0,1); break; case VK_UP: if(bShift) { if(!IsSelected()) { m_selStart = m_currentAddress; } Move(0,-1); m_selEnd = m_currentAddress; RedrawWindow(); break; } else SetSel(-1, -1); Move(0,-1); break; case VK_LEFT: if(bShift) { if(!IsSelected()) { m_selStart = m_currentAddress; } Move(-1,0); m_selEnd = m_currentAddress; RedrawWindow(); break; } else SetSel(-1, -1); Move(-1,0); break; case VK_RIGHT: if(bShift) { if(!IsSelected()) { m_selStart = m_currentAddress; } Move(1,0); m_selEnd = m_currentAddress; if(m_currentMode == EDIT_HIGH || m_currentMode == EDIT_LOW) m_selEnd++; RedrawWindow(); break; } else SetSel(-1, -1); Move(1,0); break; case VK_PRIOR: if(bShift) { if(!IsSelected()) { m_selStart = m_currentAddress; } OnVScroll(SB_PAGEUP, 0, NULL); Move(0,0); m_selEnd = m_currentAddress; RedrawWindow(); break; } else SetSel(-1, -1); OnVScroll(SB_PAGEUP, 0, NULL); Move(0,0); break; case VK_NEXT: if(bShift) { if(!IsSelected()) { m_selStart = m_currentAddress; } OnVScroll(SB_PAGEDOWN, 0, NULL); Move(0,0); m_selEnd = m_currentAddress; RedrawWindow(); break; } else SetSel(-1, -1); OnVScroll(SB_PAGEDOWN, 0, NULL); Move(0,0); break; case VK_HOME: if(bShift) { if(!IsSelected()) { m_selStart = m_currentAddress; } if(GetKeyState(VK_CONTROL) & 0x80000000) { OnVScroll(SB_THUMBTRACK, 0, NULL); Move(0,0); } else { m_currentAddress /= m_bpr; m_currentAddress *= m_bpr; Move(0,0); } m_selEnd = m_currentAddress; RedrawWindow(); break; } else SetSel(-1, -1); if(GetKeyState(VK_CONTROL) & 0x80000000) { OnVScroll(SB_THUMBTRACK, 0, NULL); m_currentAddress = 0; Move(0,0); } else { m_currentAddress /= m_bpr; m_currentAddress *= m_bpr; Move(0,0); } break; case VK_END: if(bShift) { if(!IsSelected()) { m_selStart = m_currentAddress; } if(GetKeyState(VK_CONTROL) & 0x80000000) { m_currentAddress = m_length-1; OnVScroll(SB_THUMBTRACK, ((m_length+(m_bpr/2)) / m_bpr) - m_lpp, NULL); Move(0,0); } else { m_currentAddress /= m_bpr; m_currentAddress *= m_bpr; m_currentAddress += m_bpr - 1; if(m_currentAddress > m_length) m_currentAddress = m_length-1; Move(0,0); } m_selEnd = m_currentAddress; RedrawWindow(); break; } else SetSel(-1, -1); if(GetKeyState(VK_CONTROL) & 0x80000000) { m_currentAddress = m_length-1; if(m_bHalfPage) OnVScroll(SB_THUMBTRACK, 0, NULL); else OnVScroll(SB_THUMBTRACK, ((m_length+(m_bpr/2)) / m_bpr) - m_lpp, NULL); Move(0,0); } else { m_currentAddress /= m_bpr; m_currentAddress *= m_bpr; m_currentAddress += m_bpr - 1; if(m_currentAddress > m_length) m_currentAddress = m_length-1; Move(0,0); } break; case VK_INSERT: SelInsert(m_currentAddress, max(1, m_selEnd-m_selStart)); RedrawWindow(); break; case VK_DELETE: if(IsSelected()) { OnEditClear(); } else { SelDelete(m_currentAddress, m_currentAddress+1); RedrawWindow(); } break; case '\t': switch(m_currentMode) { case EDIT_NONE: m_currentMode = EDIT_HIGH; break; case EDIT_HIGH: case EDIT_LOW: m_currentMode = EDIT_ASCII; break; case EDIT_ASCII: m_currentMode = EDIT_HIGH; break; } Move(0,0); break; } m_bNoAddressChange = bac; }
void wxListBox::SetString( int N , const wxString& rsString ) { wxCHECK_RET( N >= 0 && N < m_nNumItems, wxT("invalid index in wxListBox::SetString") ); // // Remember the state of the item // bool bWasSelected = IsSelected(N); void* pOldData = NULL; wxClientData* pOldObjData = NULL; if (m_clientDataItemsType == wxClientData_Void) pOldData = GetClientData(N); else if (m_clientDataItemsType == wxClientData_Object) pOldObjData = GetClientObject(N); // // Delete and recreate it // ::WinSendMsg( GetHwnd() ,LM_DELETEITEM ,(MPARAM)N ,(MPARAM)0 ); int nNewN = N; if (N == m_nNumItems - 1) nNewN = -1; ::WinSendMsg( GetHwnd() ,LM_INSERTITEM ,(MPARAM)nNewN ,(MPARAM)rsString.c_str() ); // // Restore the client data // if (pOldData) SetClientData( N ,pOldData ); else if (pOldObjData) SetClientObject( N ,pOldObjData ); // // We may have lost the selection // if (bWasSelected) Select(N); #if wxUSE_OWNER_DRAWN if (m_windowStyle & wxLB_OWNERDRAW) // // Update item's text // m_aItems[N]->SetName(rsString); #endif //USE_OWNER_DRAWN } // end of wxListBox::SetString
void CVisualNode::Draw(CVisualDrawContext & Ctx) { RECT rect; size_t n; Ctx.SelectSmallFont(); if(IsSelected()) { Ctx.SelectPen(m_clrSelectedBorder, 2); } else { Ctx.SelectPen(m_clrLine, 1); } // select colors Ctx.SelectSolidBrush(m_clrFill); // draw rect Ctx.MapRect(m_Rect, rect); Rectangle(Ctx.DC(), rect.left, rect.top, rect.right, rect.bottom); if(!m_strLabel.IsEmpty()) { COLORREF oldColor = SetTextColor(Ctx.DC(), m_clrLine); Ctx.SelectSolidBrush(RGB(0, 0, 0)); SetBkColor(Ctx.DC(), m_clrFill); rect.left += 5; rect.right -= 5; rect.top +=5; DrawText(Ctx.DC(), m_strLabel, m_strLabel.GetLength(), &rect, DT_WORDBREAK); SetTextColor(Ctx.DC(), oldColor); } if(m_fTopoError) { COLORREF oldColor = SetTextColor(Ctx.DC(), m_clrErrorText); rect.top += 10; CAtlStringW errString = LoadAtlString(IDS_E_TOPO_RESOLUTION); DrawText(Ctx.DC(), errString, errString.GetLength(), &rect, DT_WORDBREAK); SetTextColor(Ctx.DC(), oldColor); } Ctx.PushState(); Ctx.ShiftCoordinates(m_Rect.x(), m_Rect.y()); // draw pins for(n = 0; n < m_InputPins.GetCount(); n++) { m_InputPins.GetAt(n)->Draw(Ctx); } for(n = 0; n < m_OutputPins.GetCount(); n++) { m_OutputPins.GetAt(n)->Draw(Ctx); } Ctx.PopState(); Ctx.DeselectSmallFont(); }
void DriveItem::DrawItem(BView* owner, BRect frame, bool complete) { owner->PushState(); owner->SetDrawingMode(B_OP_ALPHA); if (IsSelected() || complete) { if (IsSelected()) { owner->SetHighColor(tint_color(owner->LowColor(), B_DARKEN_2_TINT)); owner->SetLowColor(owner->HighColor()); } else owner->SetHighColor(owner->LowColor()); owner->FillRect(frame); } rgb_color black = {0, 0, 0, 255}; if (!IsEnabled()) owner->SetHighColor(tint_color(black, B_LIGHTEN_2_TINT)); else owner->SetHighColor(black); // icon owner->MovePenTo(frame.left + 4, frame.top + 1); owner->DrawBitmap(fIcon); // device owner->MovePenTo(frame.left + 8 + fIcon->Bounds().Width(), frame.top + fSecondBaselineOffset); owner->DrawString(fPath.Path()); // size owner->MovePenTo(frame.right - 4 - fSizeWidth, frame.top + fBaselineOffset); owner->DrawString(fSize.String()); // name BFont boldFont; owner->GetFont(&boldFont); boldFont.SetFace(B_BOLD_FACE); owner->SetFont(&boldFont); owner->MovePenTo(frame.left + 8 + fIcon->Bounds().Width(), frame.top + fBaselineOffset); owner->DrawString(fName.String()); if (fCanBeInstalled != B_OK) { owner->SetHighColor(140, 0, 0); owner->MovePenBy(fBaselineOffset, 0); const char* message; switch (fCanBeInstalled) { case B_PARTITION_TOO_SMALL: message = B_TRANSLATE_COMMENT("No space available!", "Cannot install"); break; case B_ENTRY_NOT_FOUND: message = B_TRANSLATE_COMMENT("Incompatible format!", "Cannot install"); break; default: message = B_TRANSLATE_COMMENT("Cannot access!", "Cannot install"); break; } owner->DrawString(message); } owner->PopState(); }
BOOL NodeSimpleShape::DoBecomeA(BecomeA* pBecomeA) { // Check for a NULL entry param ERROR2IF_PF(pBecomeA == NULL,FALSE,("pBecomeA is NULL")); // This lump checks that the Reason is one that we understand // It also makes sure that we don't have a NULL UndoOp ptr BOOL ValidReason = (pBecomeA->GetReason() == BECOMEA_REPLACE || pBecomeA->GetReason() == BECOMEA_PASSBACK); ERROR2IF_PF(!ValidReason,FALSE,("Unkown BecomeA reason %d",pBecomeA->GetReason())); // pBecomeA->Reason is one that we understand. BOOL Success = TRUE; // Our success flag (Important that this defaults to TRUE) NodePath* pNewNodePath = NULL; // Ptr to a new NodePath, if we get to make one. if (pBecomeA->BAPath()) { // We need to create a new NodePath, no matter what the reason. // Allocate a new NodePath node ALLOC_WITH_FAIL(pNewNodePath, (new NodePath), pBecomeA->GetUndoOp()); Success = (pNewNodePath != NULL); // Initialise the path if (Success) CALL_WITH_FAIL(pNewNodePath->InkPath.Initialise(InkPath.GetNumCoords(),12), pBecomeA->GetUndoOp(), Success); if (Success) CALL_WITH_FAIL(pNewNodePath->InkPath.CopyPathDataFrom(&InkPath), pBecomeA->GetUndoOp(), Success); // If Success is TRUE, then we now have a new NodePath object that contains this shape's path if (Success) { switch (pBecomeA->GetReason()) { case BECOMEA_REPLACE : { // It's a BECOMEA_REPLACE, so replace this node with the new NodePath in an undoable way // Can't do it in an undoable way without an Undo Op ERROR2IF_PF(pBecomeA->GetUndoOp() == NULL,FALSE,("GetUndoOp() returned NULL")); // Firstly, hide this node NodeHidden* pNodeHidden; Success = pBecomeA->GetUndoOp()->DoHideNode(this, TRUE, &pNodeHidden); if (Success) { // Insert the new NodePath into the tree, next to the hidden node pNewNodePath->AttachNode(pNodeHidden,NEXT); // Copy the node's attributes CALL_WITH_FAIL(CopyChildrenTo(pNewNodePath), pBecomeA->GetUndoOp(), Success); if (Success) { // Set the bounds pNewNodePath->InvalidateBoundingRect(); pNewNodePath->SetSelected(IsSelected()); // Create a hide node action to hide the node when we undo HideNodeAction* UndoHideNodeAction; Success = (HideNodeAction::Init(pBecomeA->GetUndoOp(), pBecomeA->GetUndoOp()->GetUndoActionList(), pNewNodePath, TRUE, // Include subtree size ( Action**)(&UndoHideNodeAction)) != AC_FAIL); } } if (Success) pBecomeA->PassBack(pNewNodePath, this); } break; case BECOMEA_PASSBACK : Success = pBecomeA->PassBack(pNewNodePath,this); break; default: break; } } } if (!Success) { if (pNewNodePath != NULL) { // Delete all the NodePath's children (if it has any) and unlink it from the tree (if it's linked) // This is all done by CascadeDelete() pNewNodePath->CascadeDelete(); delete pNewNodePath; pNewNodePath = NULL; } } return Success; }
bool CCheckBoxUI::GetCheck() const { return IsSelected(); }
void LIB_TEXT::drawGraphic( EDA_DRAW_PANEL* aPanel, wxDC* aDC, const wxPoint& aOffset, int aColor, int aDrawMode, void* aData, const TRANSFORM& aTransform ) { int color = GetDefaultColor(); if( aColor < 0 ) // Used normal color or selected color { if( IsSelected() ) color = g_ItemSelectetColor; } else { color = aColor; } GRSetDrawMode( aDC, aDrawMode ); /* Calculate the text orientation, according to the component * orientation/mirror (needed when draw text in schematic) */ int orient = m_Orient; if( aTransform.y1 ) // Rotate component 90 degrees. { if( orient == TEXT_ORIENT_HORIZ ) orient = TEXT_ORIENT_VERT; else orient = TEXT_ORIENT_HORIZ; } /* Calculate the text justification, according to the component * orientation/mirror this is a bit complicated due to cumulative * calculations: * - numerous cases (mirrored or not, rotation) * - the DrawGraphicText function recalculate also H and H justifications * according to the text orientation. * - When a component is mirrored, the text is not mirrored and * justifications are complicated to calculate * so the more easily way is to use no justifications ( Centered text ) * and use GetBoundaryBox to know the text coordinate considered as centered */ EDA_RECT bBox = GetBoundingBox(); wxPoint txtpos = bBox.Centre(); // Calculate pos accordint to mirror/rotation. txtpos = aTransform.TransformCoordinate( txtpos ) + aOffset; DrawGraphicText( aPanel, aDC, txtpos, (EDA_Colors) color, m_Text, orient, m_Size, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_CENTER, GetPenSize(), m_Italic, m_Bold ); /* Enable this to draw the bounding box around the text field to validate * the bounding box calculations. */ #if 0 EDA_RECT grBox; grBox.SetOrigin( aTransform.TransformCoordinate( bBox.GetOrigin() ) ); grBox.SetEnd( aTransform.TransformCoordinate( bBox.GetEnd() ) ); grBox.Move( aOffset ); GRRect( aPanel->GetClipBox(), aDC, grBox, 0, LIGHTMAGENTA ); #endif }
//------------------------------------------------------------------------- void CTinyCadDoc::SaveXML(CXMLWriter &xml, drawingCollection &drawing, BOOL Details, BOOL SaveSelect, BOOL SaveResources ) { // Write the objects to the file try { xml.addTag(GetXMLTag()); // If necessary write the header stamp if (Details) { xml.addTag(_T("NAME")); xml.addChildData( m_sheet_name ); xml.closeTag(); xml.addTag(_T("DETAILS")); m_oDetails.WriteXML( xml ); m_snap.SaveXML( xml ); xml.closeTag(); } if (SaveResources) { // Find out which resources are in use for( drawingIterator i = drawing.begin(); i != drawing.end(); i++ ) { (*i)->TagResources(); } // Save the resource details details theOptions.SaveFontsXML(xml); theOptions.SaveStylesXML(xml); theOptions.SaveFillStylesXML(xml); theOptions.SaveMetaFilesXML(xml); } // Only save the symbols if we are not saving // to a library or the header... if (Details) { theOptions.SaveSymbolsXML(xml); } if (Details) { theOptions.WriteXML( xml) ; } for( drawingIterator i = drawing.begin(); i != drawing.end(); i++ ) { CDrawingObject* obj = *i; if (obj->GetType() != xError && (Details || !obj->IsConstruction()) && (!SaveSelect || IsSelected( obj )) ) { // Now save the actual object data obj->SaveXML(xml); } } xml.closeTag(); } catch ( CException *e) { // Could not save the file properly e->ReportError(); e->Delete(); } }
void MimeTypeItem::DrawItem(BView* owner, BRect frame, bool complete) { BFont font; if (IsSupertypeOnly()) { owner->GetFont(&font); BFont boldFont(font); boldFont.SetFace(B_BOLD_FACE); owner->SetFont(&boldFont); } BRect rect = frame; if (fFlat) { // This is where the latch would be - yet can freely consider this // as an ugly hack rect.left -= 11.0f; } if (fShowIcon) { rgb_color highColor = owner->HighColor(); rgb_color lowColor = owner->LowColor(); if (IsSelected() || complete) { if (IsSelected()) owner->SetLowColor(tint_color(lowColor, B_DARKEN_2_TINT)); owner->FillRect(rect, B_SOLID_LOW); } BBitmap bitmap(BRect(0, 0, B_MINI_ICON - 1, B_MINI_ICON - 1), B_RGBA32); BMimeType mimeType(fType.String()); status_t status = icon_for_type(mimeType, bitmap, B_MINI_ICON); if (status < B_OK) { // get default generic/application icon BMimeType genericType(fApplicationMode ? B_ELF_APP_MIME_TYPE : B_FILE_MIME_TYPE); status = icon_for_type(genericType, bitmap, B_MINI_ICON); } if (status == B_OK) { BPoint point(rect.left + 2.0f, rect.top + (rect.Height() - B_MINI_ICON) / 2.0f); owner->SetDrawingMode(B_OP_ALPHA); owner->DrawBitmap(&bitmap, point); } owner->SetDrawingMode(B_OP_COPY); owner->MovePenTo(rect.left + B_MINI_ICON + 8.0f, frame.top + fBaselineOffset); owner->SetHighColor(0, 0, 0); owner->DrawString(Text()); owner->SetHighColor(highColor); owner->SetLowColor(lowColor); } else BStringItem::DrawItem(owner, rect, complete); if (IsSupertypeOnly()) owner->SetFont(&font); }
void ColorListItem::DrawItem(BView* owner, BRect itemRect, bool drawEverything) { BRect textRect = itemRect; BRect colorRect = fColorFrame; colorRect.top = itemRect.top + 1; colorRect.bottom = itemRect.bottom - 1; textRect.right = textRect.right - (fColorFrame.Width()); colorRect.left++; colorRect.OffsetBy(textRect.Width(), 0); switch (fColorFrameAlign) { case B_ALIGN_LEFT: { textRect.OffsetBy(fColorFrame.Width(), 0); colorRect.OffsetBy(-textRect.Width(), 0); break; } default: break; } // center color rect vertically // colorRect.OffsetTo(colorRect.left, (itemRect.Height()-colorRect.Height())/2); if (IsEnabled()) { if (IsSelected()) { owner->SetHighColor(EnabledSelectedBackgroundColor); } else { owner->SetHighColor(EnabledDeselectedBackgroundColor); } } else { if (IsSelected()) { owner->SetHighColor(DisabledSelectedBackgroundColor); } else { owner->SetHighColor(DisabledDeselectedBackgroundColor); } } owner->FillRect(itemRect); owner->SetHighColor(fFrameColor); owner->StrokeRect(colorRect); colorRect.InsetBy(1, 1); owner->SetHighColor(fColor); owner->FillRect(colorRect); if (IsEnabled()) { if (IsSelected()) { owner->SetHighColor(EnabledSelectedTextColor); owner->SetLowColor(EnabledSelectedBackgroundColor); } else { owner->SetHighColor(EnabledDeselectedTextColor); owner->SetLowColor(EnabledDeselectedBackgroundColor); } } else { if (IsSelected()) { owner->SetHighColor(DisabledSelectedTextColor); owner->SetLowColor(DisabledSelectedBackgroundColor); } else { owner->SetHighColor(DisabledDeselectedTextColor); owner->SetLowColor(DisabledDeselectedBackgroundColor); } } font_height fh; owner->GetFontHeight(&fh); owner->DrawString(Text(), BPoint(textRect.left + 3, textRect.bottom - fh.descent)); // BStringItem::DrawItem(owner, itemRect, drawEverything); }
//------------------------------------------------------------------------ void CDebugGun::Update( SEntityUpdateContext& ctx, int update) { if (!IsSelected()) return; static float drawColor[4] = {1,1,1,1}; static const int dx = 5; static const int dy = 15; static const float font = 1.2f; static const float fontLarge = 1.4f; IRenderer* pRenderer = gEnv->pRenderer; IRenderAuxGeom* pAuxGeom = pRenderer->GetIRenderAuxGeom(); pAuxGeom->SetRenderFlags(e_Def3DPublicRenderflags); pRenderer->Draw2dLabel(pRenderer->GetWidth()/5.f, pRenderer->GetHeight()-35, fontLarge, drawColor, false, "Firemode: %s (%.1f)", m_fireModes[m_fireMode].first.c_str(), m_fireModes[m_fireMode].second); ray_hit rayhit; int hits = 0; unsigned int flags = rwi_stop_at_pierceable|rwi_colltype_any; if (m_fireModes[m_fireMode].first == "pierceability") { flags = (unsigned int)m_fireModes[m_fireMode].second & rwi_pierceability_mask; } // use cam, no need for firing pos/dir CCamera& cam = GetISystem()->GetViewCamera(); if (hits = gEnv->pPhysicalWorld->RayWorldIntersection(cam.GetPosition()+cam.GetViewdir(), cam.GetViewdir()*HIT_RANGE, ent_all, flags, &rayhit, 1)) { IMaterialManager* pMatMan = gEnv->p3DEngine->GetMaterialManager(); IActorSystem* pActorSystem = g_pGame->GetIGameFramework()->GetIActorSystem(); IVehicleSystem* pVehicleSystem = g_pGame->GetIGameFramework()->GetIVehicleSystem(); int x = (int)(pRenderer->GetWidth() *0.5f) + dx; int y = (int)(pRenderer->GetHeight()*0.5f) + dx - dy; // draw normal ColorB colNormal(200,0,0,128); Vec3 end = rayhit.pt + 0.75f*rayhit.n; pAuxGeom->DrawLine(rayhit.pt, colNormal, end, colNormal); pAuxGeom->DrawCone(end, rayhit.n, 0.1f, 0.2f, colNormal); IEntity * pEntity = (IEntity*)rayhit.pCollider->GetForeignData(PHYS_FOREIGN_ID_ENTITY); if(pEntity) { pRenderer->Draw2dLabel(x, y+=dy, fontLarge, drawColor, false, pEntity->GetName()); } // material const char* matName = pMatMan->GetSurfaceType(rayhit.surface_idx)->GetName(); if (matName[0]) pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "%s (%i)", matName, rayhit.surface_idx); pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "%.1f m", rayhit.dist); if (pEntity) { IScriptTable* pScriptTable = pEntity->GetScriptTable(); // physics if (IPhysicalEntity* pPhysEnt = pEntity->GetPhysics()) { pe_status_dynamics status; if (pPhysEnt->GetStatus(&status)) { if (status.mass > 0.f) pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "%.1f kg", status.mass); pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "pe_type: %i", pPhysEnt->GetType()); if (status.submergedFraction > 0.f) pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "%.2f submerged", status.submergedFraction); if (status.v.len2() > 0.0001f) pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "%.2f m/s", status.v.len()); } } if (pScriptTable) { HSCRIPTFUNCTION func = 0; if (pScriptTable->GetValue("GetFrozenAmount", func) && func) { float frozen = 0.f; Script::CallReturn(gEnv->pScriptSystem, func, pScriptTable, frozen); gEnv->pScriptSystem->ReleaseFunc(func); if (frozen > 0.f) pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "Frozen: %.2f", frozen); } } // class-specific stuff if (IActor* pActor = pActorSystem->GetActor(pEntity->GetId())) { pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "%i health", pActor->GetHealth()); } else if (IVehicle* pVehicle = pVehicleSystem->GetVehicle(pEntity->GetId())) { const SVehicleStatus& status = pVehicle->GetStatus(); pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "%.0f%% health", 100.f*status.health); pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "%i passengers", status.passengerCount); if (pVehicle->GetMovement() && pVehicle->GetMovement()->IsPowered()) { pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "Running"); } } else { if (pScriptTable) { HSCRIPTFUNCTION func = 0; if (pScriptTable->GetValue("GetHealth", func) && func) { float health = 0.f; if (Script::CallReturn(gEnv->pScriptSystem, func, pScriptTable, health)) { pRenderer->Draw2dLabel(x, y+=dy, font, drawColor, false, "%.0f health", health); } gEnv->pScriptSystem->ReleaseFunc(func); } } } } } }
void InterfaceListItem::DrawItem(BView* owner, BRect /*bounds*/, bool complete) { BListView* list = dynamic_cast<BListView*>(owner); if (!list) return; owner->PushState(); BRect bounds = list->ItemFrame(list->IndexOf(this)); rgb_color black = {0, 0, 0, 255}; if (IsSelected() || complete) { if (IsSelected()) { list->SetHighColor(tint_color(list->ViewColor(), B_HIGHLIGHT_BACKGROUND_TINT)); } else { list->SetHighColor(list->LowColor()); } list->FillRect(bounds); } BString interfaceState; BBitmap* stateIcon(NULL); if (fSettings->IsDisabled()) { interfaceState << "disabled"; stateIcon = fIconOffline; } else if (!fInterface.HasLink()) { interfaceState << "no link"; stateIcon = fIconOffline; } else if ((fSettings->IPAddr(AF_INET).IsEmpty() && fSettings->IPAddr(AF_INET6).IsEmpty()) && (fSettings->AutoConfigure(AF_INET) || fSettings->AutoConfigure(AF_INET6))) { interfaceState << "connecting" B_UTF8_ELLIPSIS; stateIcon = fIconPending; } else { interfaceState << "connected"; stateIcon = fIconOnline; } // Set the initial bounds of item contents BPoint iconPt = bounds.LeftTop(); BPoint namePt = bounds.LeftTop(); BPoint v4addrPt = bounds.LeftTop(); BPoint v6addrPt = bounds.LeftTop(); BPoint statePt = bounds.RightTop(); iconPt += BPoint(4, 4); statePt += BPoint(0, fFirstlineOffset); namePt += BPoint(ICON_SIZE + 12, fFirstlineOffset); v4addrPt += BPoint(ICON_SIZE + 12, fSecondlineOffset); v6addrPt += BPoint(ICON_SIZE + 12, fThirdlineOffset); statePt -= BPoint(be_plain_font->StringWidth(interfaceState.String()), 0); if (fSettings->IsDisabled()) { list->SetDrawingMode(B_OP_ALPHA); list->SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY); list->SetHighColor(0, 0, 0, 32); } else list->SetDrawingMode(B_OP_OVER); list->DrawBitmapAsync(fIcon, iconPt); list->DrawBitmapAsync(stateIcon, iconPt); if (fSettings->IsDisabled()) list->SetHighColor(tint_color(black, B_LIGHTEN_1_TINT)); else list->SetHighColor(black); list->SetFont(be_bold_font); list->DrawString(Name(), namePt); list->SetFont(be_plain_font); list->DrawString(interfaceState, statePt); if (!fSettings->IsDisabled()) { // Render IPv4 Address BString v4str("IPv4: "); if (fSettings->IPAddr(AF_INET).IsEmpty()) v4str << "none"; else { v4str << fSettings->IP(AF_INET); } if (fSettings->AutoConfigure(AF_INET)) v4str << " (DHCP)"; else v4str << " (static)"; list->DrawString(v4str.String(), v4addrPt); // Render IPv6 Address (if present) if (!fSettings->IPAddr(AF_INET6).IsEmpty()) { BString v6str("IPv6: "); v6str << fSettings->IP(AF_INET6); list->DrawString(v6str, v6addrPt); } } owner->PopState(); }
void CMultiSelTreeCtrl::OnLButtonDown(UINT nFlags, CPoint point) { // update shift and control flags m_CtrlDown= nFlags & MK_CONTROL ? TRUE : FALSE; m_ShiftDown= nFlags & MK_SHIFT ? TRUE : FALSE; // find out what was hit TV_HITTESTINFO ht; ht.pt=point; m_LastLButtonDown=HitTest( &ht ); if(m_LastLButtonDown==NULL) return; BOOL success; m_PendingDeselect=FALSE; if(m_LastLButtonDown != TVI_ROOT && (ht.flags & TVHT_ONITEM )) { // Select nothing so there is no focus rect SelectItem(NULL); // Add the item to the selection set if(nFlags & MK_CONTROL) { // Make sure its a valid selection if( !OKToAddSelection( m_LastLButtonDown ) ) return; // If not in set, add it if(!IsSelected(m_LastLButtonDown)) success=SetSelectState(m_LastLButtonDown, TRUE); else // removing from set, or possibly re-clicking for drag success=m_PendingDeselect=TRUE; } else if(nFlags & MK_SHIFT) { success=RangeSelect(m_LastLButtonDown); } else { if(!IsSelected(m_LastLButtonDown)) { UnselectAll(); success=SetSelectState(m_LastLButtonDown, TRUE); ASSERT(GetSelectedCount()); } else { success= TRUE; m_PendingDeselect= TRUE; } } // wait at least 20 secs before autopolling for updates MainFrame()->WaitAWhileToPoll(); if(!success) return; // Store the clicked item m_DragFromItem=m_LastLButtonDown; // Force the stinking item to repaint, because new select atts seem to // be lost in commctl32.dll occasionally SetAppearance(FALSE, TRUE, FALSE); GetItemRect(m_LastLButtonDown, &m_DragSourceRect, TRUE); RedrawWindow( m_DragSourceRect, NULL, RDW_UPDATENOW ); // Then create a suitably small drag rect around the cursor CPoint pt= point; ClientToScreen(&pt); m_DragSourceRect.SetRect( max(0, pt.x - 2), max(0, pt.y - 2), max(0, pt.x + 2), max(0, pt.y + 2) ); // The drag drop attempt will clear m_PendingDeselect if a drag is attempted TryDragDrop( m_LastLButtonDown ); if( m_PendingDeselect ) { if( nFlags & MK_CONTROL ) SetSelectState(m_LastLButtonDown, FALSE); else { UnselectAll(); success=SetSelectState(m_LastLButtonDown, TRUE); } } // Make sure selection set is properly displayed SetAppearance(FALSE, TRUE, FALSE); } else { if(ht.flags & TVHT_ONITEM && (nFlags & MK_CONTROL || nFlags & MK_SHIFT) ) return; else { if (ht.flags & TVHT_ONITEM && m_ViewIsActive ) { // Select just the one item UnselectAll(); SetSelectState(m_LastLButtonDown, TRUE); } // Clicked on something other than a bimap or item text, so just call // the default hanlder and make sure nothing gets selected CTreeCtrl::OnLButtonDown(nFlags, point); SelectItem( NULL); } } }
// User mouse-keyed a request to expand the current selection. Note that // the selection set can actually shrink if the already selected items are // not contiguous - per Exploder convention void CMultiSelTreeCtrl::ExpandSelection( int linesToExpand ) { ASSERT( m_SelectionSet.GetSize() > 0 ); if( m_AnchorItem == NULL ) { ASSERT(0); return; } MainFrame()->WaitAWhileToPoll(); // wait at least 20 secs before autopolling for updates HTREEITEM currentItem= m_AnchorItem; if( linesToExpand > 0 ) { // Scrolling up for( int i=0; i < linesToExpand; i++ ) { HTREEITEM lastGoodItem= currentItem; currentItem= GetPrevSiblingItem(currentItem); if( currentItem == NULL ) { currentItem= lastGoodItem; break; } else { if( m_PendingKeyedDeselect ) DoKeyedDeselect( FALSE ); if( IsSelected( currentItem ) ) SetSelectState( lastGoodItem, FALSE ); // Selection shrinking else if( OKToAddSelection( currentItem ) ) SetSelectState( currentItem, TRUE ); // Selection growing else break; } } } else { // Scrolling down for( int i=0; i < (-linesToExpand); i++ ) { HTREEITEM lastGoodItem= currentItem; currentItem= GetNextSiblingItem(currentItem); if( currentItem == NULL ) { currentItem= lastGoodItem; break; } else { if( m_PendingKeyedDeselect ) DoKeyedDeselect( TRUE ); if( IsSelected( currentItem ) ) SetSelectState( lastGoodItem, FALSE ); // Selection shrinking else if( OKToAddSelection( currentItem ) ) SetSelectState( currentItem, TRUE ); // Selection growing else break; } } } m_AnchorItem= currentItem; EnsureVisible( m_AnchorItem ); }
/***************************************************************************** * PlaylistItem::DrawItem *****************************************************************************/ void PlaylistItem::Draw( BView *owner, BRect frame, bool tintedLine, uint32 mode, bool active, bool playing ) { rgb_color color = (rgb_color){ 255, 255, 255, 255 }; if ( tintedLine ) color = tint_color( color, 1.04 ); // background if ( IsSelected() ) color = tint_color( color, B_DARKEN_2_TINT ); owner->SetLowColor( color ); owner->FillRect( frame, B_SOLID_LOW ); // label owner->SetHighColor( 0, 0, 0, 255 ); font_height fh; owner->GetFontHeight( &fh ); const char* text = Text(); switch ( mode ) { case DISPLAY_NAME: if ( fName.CountChars() > 0 ) text = fName.String(); break; case DISPLAY_PATH: default: break; } BString truncatedString( text ); owner->TruncateString( &truncatedString, B_TRUNCATE_MIDDLE, frame.Width() - TEXT_OFFSET - 4.0 ); owner->DrawString( truncatedString.String(), BPoint( frame.left + TEXT_OFFSET, frame.top + fh.ascent + 1.0 ) ); // playmark if ( active ) { rgb_color black = (rgb_color){ 0, 0, 0, 255 }; rgb_color green = (rgb_color){ 0, 255, 0, 255 }; BRect r( 0.0, 0.0, 10.0, 10.0 ); r.OffsetTo( frame.left + 4.0, ceilf( ( frame.top + frame.bottom ) / 2.0 ) - 5.0 ); if ( !playing ) green = tint_color( color, B_DARKEN_1_TINT ); rgb_color lightGreen = tint_color( green, B_LIGHTEN_2_TINT ); rgb_color darkGreen = tint_color( green, B_DARKEN_2_TINT ); BPoint arrow[3]; arrow[0] = r.LeftTop(); arrow[1] = r.LeftBottom(); arrow[2].x = r.right; arrow[2].y = ( r.top + r.bottom ) / 2.0; owner->BeginLineArray( 6 ); // black outline owner->AddLine( arrow[0], arrow[1], black ); owner->AddLine( BPoint( arrow[1].x + 1.0, arrow[1].y - 1.0 ), arrow[2], black ); owner->AddLine( arrow[0], arrow[2], black ); // inset arrow arrow[0].x += 1.0; arrow[0].y += 2.0; arrow[1].x += 1.0; arrow[1].y -= 2.0; arrow[2].x -= 2.0; // highlights and shadow owner->AddLine( arrow[1], arrow[2], darkGreen ); owner->AddLine( arrow[0], arrow[2], lightGreen ); owner->AddLine( arrow[0], arrow[1], lightGreen ); owner->EndLineArray(); // fill green arrow[0].x += 1.0; arrow[0].y += 1.0; arrow[1].x += 1.0; arrow[1].y -= 1.0; arrow[2].x -= 2.0; owner->SetHighColor( green ); owner->FillPolygon( arrow, 3 ); } }
void CSoundItem::GlDraw2D(CZ_ed2View* pV) { int i; char ax = pV->_vt; SceItem::GlDraw2D(pV); glPushMatrix(); Ta.Disable(); glTranslatef(_t.x,_t.y,_t.z); int texIdx = GetHtex(GUtex); if(0==_specAngle) { switch(ax) { case 'x': glRotatef(-90,0,1,0); texIdx+=1; break; case 'y': glRotatef(-90,1,0,0); texIdx+=2; break; case 'z': texIdx+=3; break; } } /* do{ glColor4ubv(CLR_SELECT); glEnable(GL_COLOR_MATERIAL); Ta.BindTexture(texIdx); glBegin(GL_POLYGON); for(int i=0;i<4;++i) { glVertex3f(_Vtci[i]._xyz.x, _Vtci[i]._xyz.y, _Vtci[i]._xyz.z); glTexCoord2f(_Vtci[i]._uv[GUtex].u, _Vtci[i]._uv[GUtex].v); } glEnd(); }while(0); */ if(_flags & BRSH_NEW) glColor4ubv(CLR_NEW_BRITEM); else { if(!IsSelected()) glColor4ub(_colorD.r/3, _colorD.g/3, _colorD.b/3, 255); else { glColor4ub(_colorD.r, _colorD.g, _colorD.b, 255); glColor4ubv(CLR_SELECT); } } if(_specAngle == 0) { REAL step = 0; // draw a circle from 30 x 30 degreees on xoy xoz zoy V3 cirpctX[12]; V3 cirpctY[12]; V3 cirpctZ[12]; for(i=0;i<12;i++) { cirpctX[i].z = _radius * sinf(step); cirpctX[i].y = _radius * cosf(step); cirpctY[i].x = _radius * sinf(step); cirpctY[i].z = _radius * cosf(step); cirpctZ[i].x = _radius * sinf(step); cirpctZ[i].y = _radius * cosf(step); step+=PIPE6; } glBegin(GL_LINE_LOOP); for(i=0;i<12;i++) glVertex3f(cirpctZ[i].x, cirpctZ[i].y, cirpctZ[i].z); glEnd(); } else { REAL deg = G2R(_specAngle); V3 endQuad[4]; REAL dHV = tanf(deg/2.0) * _radius; // piramide endQuad[0] = -VZ * _radius + VY * dHV - VX * dHV; endQuad[1] = -VZ * _radius + VY * dHV + VX * dHV; endQuad[2] = -VZ * _radius - VY * dHV + VX * dHV; endQuad[3] = -VZ * _radius - VY * dHV - VX * dHV; // already translated _euler.y ? glRotatef(R2G(_euler.y), 0.0,1.0,0.0):(void)0; _euler.x ? glRotatef(R2G(_euler.x), 1.0,0.0,0.0):(void)0; _euler.z ? glRotatef(R2G(_euler.z), 0.0,0.0,1.0):(void)0; glBegin(GL_LINES); for( i=0;i<4;i++) { glVertex3f(0,0,0); glVertex3f(endQuad[i].x,endQuad[i].y,endQuad[i].z); } glEnd(); glBegin(GL_LINE_LOOP); for(i=0;i<4;i++)glVertex3f(endQuad[i].x,endQuad[i].y,endQuad[i].z); glEnd(); } Ta.Restore(); glPopMatrix(); }
bool CListBox::HandleMessage(CMessage* pMessage) { bool bHandled = false; if (pMessage) { switch(pMessage->MessageType()) { case CMessage::KEYBOARD_KEYDOWN: { CKeyboardMessage* pKeyMsg = dynamic_cast<CKeyboardMessage*>(pMessage); if (pKeyMsg && pMessage->Destination() == this) { switch (pKeyMsg->Key) { case SDLK_DOWN: { if (m_iFocusedItem + 1 < Size()) { m_iFocusedItem++; int diff = m_iFocusedItem - m_pVScrollbar->GetValue(); if (m_iItemHeight * (m_pVScrollbar->GetValue() + diff + 1) > m_ClientRect.Height()) { m_pVScrollbar->SetValue(m_pVScrollbar->GetValue() + 1); } Draw(); bHandled = true; } break; } case SDLK_UP: { if ( m_iFocusedItem > 0 ) { m_iFocusedItem--; if (m_iFocusedItem < m_pVScrollbar->GetValue()) { m_pVScrollbar->SetValue(m_pVScrollbar->GetValue() - 1); } Draw(); bHandled = true; } break; } case SDLK_PAGEDOWN: { unsigned int nSize = Size() - 1; unsigned int nItemsPerPage = m_ClientRect.Height() / m_iItemHeight; if (m_iFocusedItem + nItemsPerPage < nSize) { m_iFocusedItem += nItemsPerPage; } else { m_iFocusedItem = nSize; } m_pVScrollbar->SetValue(m_iFocusedItem); Draw(); bHandled=true; break; } case SDLK_PAGEUP: { int nItemsPerPage = m_ClientRect.Height() / m_iItemHeight; if (m_iFocusedItem - nItemsPerPage > 0) { m_iFocusedItem -= nItemsPerPage; } else { m_iFocusedItem = 0; } m_pVScrollbar->SetValue(m_iFocusedItem); Draw(); bHandled=true; break; } case SDLK_SPACE: { if (! m_Items.empty()) { SetSelection(m_iFocusedItem, !IsSelected(m_iFocusedItem)); Draw(); } bHandled = true; break; } default: { bHandled=false; break; } } } break; } case CMessage::CTRL_VALUECHANGE: case CMessage::CTRL_VALUECHANGING: { if (pMessage->Source() == m_pVScrollbar) { Draw(); bHandled = true; } break; } default : bHandled = CWindow::HandleMessage(pMessage); break; } } return bHandled; }
void idListWindow::Draw(int time, float x, float y) { idVec4 color; idStr work; int count = listItems.Num(); idRectangle rect = textRect; float scale = textScale; float lineHeight = GetMaxCharHeight(); float bottom = textRect.Bottom(); float width = textRect.w; if ( scroller->GetHigh() > 0.0f ) { if ( horizontal ) { bottom -= sizeBias; } else { width -= sizeBias; rect.w = width; } } if ( noEvents || !Contains(gui->CursorX(), gui->CursorY()) ) { hover = false; } for (int i = top; i < count; i++) { if ( IsSelected( i ) ) { rect.h = lineHeight; dc->DrawFilledRect(rect.x, rect.y + pixelOffset, rect.w, rect.h, borderColor); if ( flags & WIN_FOCUS ) { idVec4 color = borderColor; color.w = 1.0f; dc->DrawRect(rect.x, rect.y + pixelOffset, rect.w, rect.h, 1.0f, color ); } } rect.y ++; rect.h = lineHeight - 1; if ( hover && !noEvents && Contains(rect, gui->CursorX(), gui->CursorY()) ) { color = hoverColor; } else { color = foreColor; } rect.h = lineHeight + pixelOffset; rect.y --; if ( tabInfo.Num() > 0 ) { int start = 0; int tab = 0; int stop = listItems[i].Find('\t', 0); while ( start < listItems[i].Length() ) { if ( tab >= tabInfo.Num() ) { common->Warning( "idListWindow::Draw: gui '%s' window '%s' tabInfo.Num() exceeded", gui->GetSourceFile(), name.c_str() ); break; } listItems[i].Mid(start, stop - start, work); rect.x = textRect.x + tabInfo[tab].x; rect.w = (tabInfo[tab].w == -1) ? width - tabInfo[tab].x : tabInfo[tab].w; dc->PushClipRect( rect ); if ( tabInfo[tab].type == TAB_TYPE_TEXT ) { dc->DrawText(work, scale, tabInfo[tab].align, color, rect, false, -1); } else if (tabInfo[tab].type == TAB_TYPE_ICON) { const idMaterial **hashMat; const idMaterial *iconMat; // leaving the icon name empty doesn't draw anything if ( work[0] != '\0' ) { if ( iconMaterials.Get(work, &hashMat) == false ) { iconMat = declManager->FindMaterial("_default"); } else { iconMat = *hashMat; } idRectangle iconRect; iconRect.w = tabInfo[tab].iconSize.x; iconRect.h = tabInfo[tab].iconSize.y; if(tabInfo[tab].align == idDeviceContext::ALIGN_LEFT) { iconRect.x = rect.x; } else if (tabInfo[tab].align == idDeviceContext::ALIGN_CENTER) { iconRect.x = rect.x + rect.w/2.0f - iconRect.w/2.0f; } else if (tabInfo[tab].align == idDeviceContext::ALIGN_RIGHT) { iconRect.x = rect.x + rect.w - iconRect.w; } if(tabInfo[tab].valign == 0) { //Top iconRect.y = rect.y + tabInfo[tab].iconVOffset; } else if(tabInfo[tab].valign == 1) { //Center iconRect.y = rect.y + rect.h/2.0f - iconRect.h/2.0f + tabInfo[tab].iconVOffset; } else if(tabInfo[tab].valign == 2) { //Bottom iconRect.y = rect.y + rect.h - iconRect.h + tabInfo[tab].iconVOffset; } dc->DrawMaterial(iconRect.x, iconRect.y, iconRect.w, iconRect.h, iconMat, idVec4(1.0f,1.0f,1.0f,1.0f), 1.0f, 1.0f); } } dc->PopClipRect(); start = stop + 1; stop = listItems[i].Find('\t', start); if ( stop < 0 ) { stop = listItems[i].Length(); } tab++; } rect.x = textRect.x; rect.w = width; } else { dc->DrawText(listItems[i], scale, 0, color, rect, false, -1); } rect.y += lineHeight; if ( rect.y > bottom ) { break; } } }
/* ................................................................ * Handle button clicks on object `obj' in form `tree'. * Set `pobj' to 0 if editable, or * |= 0x8000 if double clicked TOUCHEXIT. * Return FALSE if `obj' was an exit object, else TRUE to continue. */ BOOLEAN fm_button( OBJECT *tree, WORD obj, WORD clicks, WORD *pobj ) { WORD state, flags, parent, tobj; BOOLEAN cont; MRETS m; cont = TRUE; flags = ObFlags(obj); state = ObState(obj); if( flags & TOUCHEXIT ) /* don't wait for button up */ cont = FALSE; /* * SELECTABLE * Handle it, and wait for button up, if it's not TOUCHEXIT */ if( (flags & SELECTABLE) && !(state & DISABLED) ) { /* * Radio button, turn off the currently selected button, * by finding a selected child of obj's parent. * In the mean time, select obj. * NOTE: this assumes that obj is NOT the root object! */ if( flags & RBUTTON ) { parent = obj; do { tobj = parent; parent = ObNext(tobj); } while( ObTail(parent) != tobj ); for( tobj = ObHead(parent); tobj != parent; tobj = ObNext(tobj) ) { state = ObState(tobj); if( (ObFlags(tobj) & RBUTTON) && ( (state & SELECTED) || (tobj == obj) ) ) { if( tobj == obj ) state |= SELECTED; else state &= ~SELECTED; Objc_change( tree, tobj, &w.work, state, TRUE ); } } } else { /* not an RBUTTON */ graf_watchbox( tree, obj, state^SELECTED, state ); } if( cont && (flags & (SELECTABLE|EDITABLE)) ) Evnt_button( 1, 1, 0, &m ); } /* SELECTABLE */ /* * Now, find out if we're outta here, * if editable field was clicked, or * if a touchexit was doubleclicked */ if( IsSelected(obj) && (flags & EXIT) ) cont = FALSE; if( cont && !( flags & EDITABLE ) ) obj = 0; if( (flags & TOUCHEXIT) && (clicks == 2) ) obj |= 0x8000; *pobj = obj; return cont; }
const char *idListWindow::HandleEvent(const sysEvent_t *event, bool *updateVisuals) { // need to call this to allow proper focus and capturing on embedded children const char *ret = idWindow::HandleEvent(event, updateVisuals); float vert = GetMaxCharHeight(); int numVisibleLines = textRect.h / vert; int key = event->evValue; if ( event->evType == SE_KEY ) { if ( !event->evValue2 ) { // We only care about key down, not up return ret; } if ( key == K_MOUSE1 || key == K_MOUSE2 ) { // If the user clicked in the scroller, then ignore it if ( scroller->Contains(gui->CursorX(), gui->CursorY()) ) { return ret; } } if ( ( key == K_ENTER || key == K_KP_ENTER ) ) { RunScript( ON_ENTER ); return cmd; } if ( key == K_MWHEELUP ) { key = K_UPARROW; } else if ( key == K_MWHEELDOWN ) { key = K_DOWNARROW; } if ( key == K_MOUSE1) { if (Contains(gui->CursorX(), gui->CursorY())) { int cur = ( int )( ( gui->CursorY() - actualY - pixelOffset ) / vert ) + top; if ( cur >= 0 && cur < listItems.Num() ) { if ( multipleSel && idKeyInput::IsDown( K_CTRL ) ) { if ( IsSelected( cur ) ) { ClearSelection( cur ); } else { AddCurrentSel( cur ); } } else { if ( IsSelected( cur ) && ( gui->GetTime() < clickTime + doubleClickSpeed ) ) { // Double-click causes ON_ENTER to get run RunScript(ON_ENTER); return cmd; } SetCurrentSel( cur ); clickTime = gui->GetTime(); } } else { SetCurrentSel( listItems.Num() - 1 ); } } } else if ( key == K_UPARROW || key == K_PGUP || key == K_DOWNARROW || key == K_PGDN ) { int numLines = 1; if ( key == K_PGUP || key == K_PGDN ) { numLines = numVisibleLines / 2; } if ( key == K_UPARROW || key == K_PGUP ) { numLines = -numLines; } if ( idKeyInput::IsDown( K_CTRL ) ) { top += numLines; } else { SetCurrentSel( GetCurrentSel() + numLines ); } } else { return ret; } } else if ( event->evType == SE_CHAR ) { if ( !idStr::CharIsPrintable(key) ) { return ret; } if ( gui->GetTime() > typedTime + 1000 ) { typed = ""; } typedTime = gui->GetTime(); typed.Append( key ); for ( int i=0; i<listItems.Num(); i++ ) { if ( idStr::Icmpn( typed, listItems[i], typed.Length() ) == 0 ) { SetCurrentSel( i ); break; } } } else { return ret; } if ( GetCurrentSel() < 0 ) { SetCurrentSel( 0 ); } if ( GetCurrentSel() >= listItems.Num() ) { SetCurrentSel( listItems.Num() - 1 ); } if ( scroller->GetHigh() > 0.0f ) { if ( !idKeyInput::IsDown( K_CTRL ) ) { if ( top > GetCurrentSel() - 1 ) { top = GetCurrentSel() - 1; } if ( top < GetCurrentSel() - numVisibleLines + 2 ) { top = GetCurrentSel() - numVisibleLines + 2; } } if ( top > listItems.Num() - 2 ) { top = listItems.Num() - 2; } if ( top < 0 ) { top = 0; } scroller->SetValue(top); } else { top = 0; scroller->SetValue(0.0f); } if ( key != K_MOUSE1 ) { // Send a fake mouse click event so onAction gets run in our parents const sysEvent_t ev = sys->GenerateMouseButtonEvent( 1, true ); idWindow::HandleEvent(&ev, updateVisuals); } if ( currentSel.Num() > 0 ) { for ( int i = 0; i < currentSel.Num(); i++ ) { gui->SetStateInt( va( "%s_sel_%i", listName.c_str(), i ), currentSel[i] ); } } else { gui->SetStateInt( va( "%s_sel_0", listName.c_str() ), 0 ); } gui->SetStateInt( va( "%s_numsel", listName.c_str() ), currentSel.Num() ); return ret; }
void CMenuTool::DrawTool( BView *owner, BRect toolRect) { D_HOOK(("CMenuTool::DrawTool()\n")); BRect bitmapRect = toolRect; bitmapRect.right -= 8; BRect menuRect = toolRect; menuRect.left = bitmapRect.right; m_popUpOffset = menuRect.LeftTop(); // remember offset of the popup menu if (IsEnabled() && (IsSelected() || Value())) { if (Value() == B_CONTROL_ON) { StdBevels::DrawBorderBevel(owner, bitmapRect, StdBevels::DEPRESSED_BEVEL); if (IsSelected()) { StdBevels::DrawBorderBevel(owner, menuRect, StdBevels::DEPRESSED_BEVEL); } } else { StdBevels::DrawBorderBevel(owner, bitmapRect, StdBevels::NORMAL_BEVEL); StdBevels::DrawBorderBevel(owner, menuRect, StdBevels::NORMAL_BEVEL); } if (IsSelected()) { BRect arrowRect = menuRect; arrowRect.InsetBy(1.0, arrowRect.Height() / 2.0 - 1.0); rgb_color gray = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_2_TINT); owner->BeginLineArray(3); owner->AddLine(arrowRect.LeftTop(), arrowRect.RightTop(), gray); arrowRect.InsetBy(1.0, 0.0); arrowRect.top += 1.0; owner->AddLine(arrowRect.LeftTop(), arrowRect.RightTop(), gray); arrowRect.InsetBy(1.0, 0.0); arrowRect.top += 1.0; owner->AddLine(arrowRect.LeftTop(), arrowRect.RightTop(), gray); owner->EndLineArray(); } } else { owner->SetDrawingMode(B_OP_COPY); owner->SetLowColor(ToolBar()->ViewColor()); owner->FillRect(toolRect, B_SOLID_LOW); } if (IsEnabled()) { owner->SetDrawingMode(B_OP_OVER); owner->DrawBitmapAsync(m_bitmap, toolRect.LeftTop() + BPoint(BORDER_WIDTH, BORDER_HEIGHT)); } else { owner->SetDrawingMode(B_OP_OVER); owner->DrawBitmapAsync(m_disabledBitmap, toolRect.LeftTop() + BPoint(BORDER_WIDTH, BORDER_HEIGHT)); } }
void CVarView::OnUpdateVarProperty(CCmdUI* pCmdUI) { // TODO: この位置に command update UI ハンドラ用のコードを追加してください pCmdUI->Enable(IsSelected()); }
bool CBaseContainerNode::VguiDraw( bool bShadow ) { #define TITEL_INSET_X NODE_DRAW_TITLE_SPACE if ( !ShouldSimpleDrawObject( pNodeView, pNodeView, m_vecBounds ) ) return false; if ( !pNodeView ) return false; Vector2D title_min = GetBoundsTitleMin(); Vector2D title_max = GetBoundsTitleMax(); title_max.x -= TITEL_INSET_X; Vector2D box_min = GetBoundsBoxMin(); Vector2D box_max = GetBoundsBoxMax(); pNodeView->ToPanelSpace( title_min ); pNodeView->ToPanelSpace( title_max ); pNodeView->ToPanelSpace( box_min ); pNodeView->ToPanelSpace( box_max ); float flZoom = pNodeView->GetZoomScalar(); float flO = NODE_DRAW_SHADOW_DELTA * flZoom; Vector2D offset( flO, flO ); if ( bShadow ) { title_min += offset; title_max += offset; box_min += offset; box_max += offset; } const bool bSelected = IsSelected(); if ( bShadow ) surface()->DrawSetColor( NODE_DRAW_COLOR_SHADOW ); else { Color colTitleNoShadow = NODE_DRAW_COLOR_TITLE; if ( GetNumContainers() ) colTitleNoShadow = NODE_DRAW_COLOR_HASCONTAINER_TITLE; else if ( bSelected ) colTitleNoShadow = NODE_DRAW_COLOR_SELECTED_TITLE; surface()->DrawSetColor( colTitleNoShadow ); } surface()->DrawFilledRect( title_min.x, title_min.y, title_max.x, title_max.y ); if ( !bShadow ) { Color boxNoShadow = NODE_DRAW_COLOR_BOX; if ( bSelected ) boxNoShadow = NODE_DRAW_COLOR_SELECTED_BOX; else if ( GetNumSolvers() && !HasDummySolvers() ) boxNoShadow = NODE_DRAW_COLOR_HASSOLVER_BOX; surface()->DrawSetColor( boxNoShadow ); } surface()->DrawFilledRect( box_min.x, box_min.y, box_max.x, box_max.y ); //Vector2D r0_min = GetContainerBorderMin( CBORDER_TOP_LEFT ); //Vector2D r0_max = GetContainerBorderMax( CBORDER_TOP_RIGHT ); //Vector2D r1_min = GetContainerBorderMin( CBORDER_RIGHT ); //Vector2D r1_max = GetContainerBorderMax( CBORDER_RIGHT ); //Vector2D r2_min = GetContainerBorderMin( CBORDER_BOTTOM_LEFT ); //Vector2D r2_max = GetContainerBorderMax( CBORDER_BOTTOM_RIGHT ); //Vector2D r3_min = GetContainerBorderMin( CBORDER_RIGHT ); //Vector2D r3_max = GetContainerBorderMax( CBORDER_RIGHT ); Vector2D rects_[8] = { GetContainerBorderMin( CBORDER_TOP_LEFT ), GetContainerBorderMax( CBORDER_TOP_RIGHT ), GetContainerBorderMin( CBORDER_RIGHT ), GetContainerBorderMax( CBORDER_RIGHT ), GetContainerBorderMin( CBORDER_BOTTOM_LEFT ), GetContainerBorderMax( CBORDER_BOTTOM_RIGHT ), GetContainerBorderMin( CBORDER_LEFT ), GetContainerBorderMax( CBORDER_LEFT ), }; for ( int i = 0; i < 8; i++ ) pNodeView->ToPanelSpace( rects_[i] ); if ( bShadow ) { for ( int i = 0; i < 8; i++ ) rects_[i] += offset; } for ( int i = 0; i < 4; i++ ) surface()->DrawFilledRect( rects_[i*2].x, rects_[i*2+1].y, rects_[i*2+1].x, rects_[i*2].y ); if ( bShadow ) { VguiDraw_Jacks( true ); } else { VguiDraw_Jacks( false ); Color borderCol = NODE_DRAW_COLOR_BORDER; if ( GetErrorLevel() == ERRORLEVEL_UNDEFINED ) borderCol = DRAWCOLOR_ERRORLEVEL_UNDEFINED; else if ( GetErrorLevel() == ERRORLEVEL_FAIL ) borderCol = DRAWCOLOR_ERRORLEVEL_FAIL; else if ( IsAllocating() ) borderCol = NODE_DRAW_COLOR_HASSOLVER_BOX_ALLOC; surface()->DrawSetColor( borderCol ); int borderSize = 1; surface()->DrawFilledRect( title_min.x, title_min.y, title_max.x, title_min.y + borderSize ); surface()->DrawFilledRect( title_min.x, title_max.y - borderSize, title_max.x, title_max.y ); surface()->DrawFilledRect( title_min.x, title_min.y, title_min.x + borderSize, title_max.y ); surface()->DrawFilledRect( title_max.x - borderSize, title_min.y, title_max.x, title_max.y ); surface()->DrawFilledRect( box_min.x, box_min.y, box_max.x, box_min.y + borderSize ); surface()->DrawFilledRect( box_min.x, box_max.y - borderSize, box_max.x, box_max.y ); surface()->DrawFilledRect( box_min.x, box_min.y, box_min.x + borderSize, box_max.y ); //surface()->DrawFilledRect( box_max.x - borderSize, box_min.y, box_max.x, box_max.y ); surface()->DrawFilledRect( box_max.x, rects_[1].y, box_max.x + borderSize, box_min.y + borderSize ); surface()->DrawFilledRect( box_max.x, box_max.y - borderSize, box_max.x + borderSize, rects_[4].y ); surface()->DrawFilledRect( rects_[7].x-borderSize, rects_[7].y, rects_[7].x, rects_[6].y ); surface()->DrawFilledRect( rects_[2].x, rects_[3].y, rects_[2].x+borderSize, rects_[2].y ); surface()->DrawFilledRect( rects_[3].x-borderSize, rects_[1].y, rects_[3].x, rects_[4].y ); surface()->DrawFilledRect( rects_[0].x, rects_[1].y, rects_[1].x, rects_[1].y+borderSize ); surface()->DrawFilledRect( rects_[4].x, rects_[4].y-borderSize, rects_[5].x, rects_[4].y ); surface()->DrawFilledRect( rects_[7].x-borderSize, rects_[0].y-borderSize, rects_[2].x+borderSize, rects_[0].y ); surface()->DrawFilledRect( rects_[7].x-borderSize, rects_[5].y, rects_[2].x+borderSize, rects_[5].y+borderSize ); } Vector2D titleMid = ( title_max - title_min ) * 0.5f + title_min; wchar_t szconverted[ 1024 ]; int fontWide, fontTall; if ( !bShadow ) { bool bDraw; vgui::HFont hFont_Small = pNodeView->GetFontScaled(12,bDraw); if ( bDraw ) { g_pVGuiLocalize->ConvertANSIToUnicode( szOpName, szconverted, sizeof(szconverted) ); surface()->DrawSetTextFont( hFont_Small ); surface()->GetTextSize( hFont_Small, szconverted, fontWide, fontTall ); surface()->DrawSetTextPos( titleMid.x - fontWide * 0.5f, titleMid.y - fontTall * 0.5f ); surface()->DrawSetTextColor( bSelected ? NODE_DRAW_COLOR_SELECTED_TEXT_OP : NODE_DRAW_COLOR_TEXT_OP ); surface()->DrawPrintText( szconverted, wcslen( szconverted ) ); } //VguiDraw_Preview(); DrawGrabIcon(); } if ( Q_strlen( szNodeName ) > 1 ) { surface()->DrawSetTextColor( bShadow ? NODE_DRAW_COLOR_SHADOW : NODE_DRAW_COLOR_CUSTOMTITLE ); bool bDraw; vgui::HFont hFont_Small = pNodeView->GetFontScaled(18,bDraw); if ( bDraw ) { g_pVGuiLocalize->ConvertANSIToUnicode( szNodeName, szconverted, sizeof(szconverted) ); surface()->DrawSetTextFont( hFont_Small ); surface()->GetTextSize( hFont_Small, szconverted, fontWide, fontTall ); surface()->DrawSetTextPos( title_min.x, title_min.y - fontTall - 3 * pNodeView->GetZoomScalar() ); surface()->DrawPrintText( szconverted, wcslen( szconverted ) ); } } return true; }
void UUnrealEdEngine::UpdatePivotLocationForSelection( bool bOnChange ) { // Pick a new common pivot, or not. AActor* SingleActor = nullptr; USceneComponent* SingleComponent = nullptr; if (GetSelectedComponentCount() > 0) { for (FSelectedEditableComponentIterator It(*GetSelectedComponents()); It; ++It) { UActorComponent* Component = CastChecked<UActorComponent>(*It); AActor* ComponentOwner = Component->GetOwner(); if (ComponentOwner != nullptr) { auto SelectedActors = GetSelectedActors(); const bool bIsOwnerSelected = SelectedActors->IsSelected(ComponentOwner); check(bIsOwnerSelected); if (ComponentOwner->GetWorld() == GWorld) { SingleActor = ComponentOwner; if (Component->IsA<USceneComponent>()) { SingleComponent = CastChecked<USceneComponent>(Component); } const bool IsTemplate = ComponentOwner->IsTemplate(); const bool LevelLocked = !FLevelUtils::IsLevelLocked(ComponentOwner->GetLevel()); check(IsTemplate || LevelLocked); } } } } else { for (FSelectionIterator It(GetSelectedActorIterator()); It; ++It) { AActor* Actor = static_cast<AActor*>(*It); checkSlow(Actor->IsA(AActor::StaticClass())); if (Actor->GetWorld() == GWorld) { const bool IsTemplate = Actor->IsTemplate(); const bool LevelLocked = !FLevelUtils::IsLevelLocked(Actor->GetLevel()); check(IsTemplate || LevelLocked); SingleActor = Actor; } } } if (SingleComponent != NULL) { SetPivot(SingleComponent->GetComponentLocation(), false, true); } else if( SingleActor != NULL ) { // For geometry mode use current pivot location as it's set to selected face, not actor FEditorModeTools& Tools = GLevelEditorModeTools(); if( Tools.IsModeActive(FBuiltinEditorModes::EM_Geometry) == false || bOnChange == true ) { // Set pivot point to the actor's location FVector PivotPoint = SingleActor->GetActorLocation(); // If grouping is active, see if this actor is part of a locked group and use that pivot instead if(GEditor->bGroupingActive) { AGroupActor* ActorGroupRoot = AGroupActor::GetRootForActor(SingleActor, true, true); if(ActorGroupRoot) { PivotPoint = ActorGroupRoot->GetActorLocation(); } } SetPivot( PivotPoint, false, true ); } } else { ResetPivot(); } }
void TestResultItem::DrawItem(BView *owner, BRect itemRect, bool drawEverthing) { owner->SetDrawingMode(B_OP_COPY); owner->PushState(); if (IsSelected()) { rgb_color lowColor = owner->LowColor(); owner->SetHighColor(tint_color(lowColor, B_DARKEN_2_TINT)); } else if (fOk) { // green background color on success owner->SetHighColor(200, 255, 200); } else { // red background color on failure owner->SetHighColor(255, 200, 200); } owner->FillRect(itemRect); owner->PopState(); itemRect.InsetBy(1, 1); owner->MovePenTo(itemRect.left+1, itemRect.top+1); if (fDirectBitmap != NULL) { owner->DrawBitmap(fDirectBitmap); } owner->MovePenBy(fBitmapSize.Width() + distance, 0); if (fOriginalBitmap != NULL) { owner->DrawBitmap(fOriginalBitmap); } owner->MovePenBy(fBitmapSize.Width() + distance, 0); if (fArchivedBitmap != NULL) { owner->DrawBitmap(fArchivedBitmap); } owner->MovePenBy(fBitmapSize.Width() + distance, 0); owner->DrawBitmap(fDirectBitmap); owner->SetDrawingMode(B_OP_SUBTRACT); owner->DrawBitmap(fOriginalBitmap); owner->MovePenBy(fBitmapSize.Width() + distance, 0); owner->SetDrawingMode(B_OP_OVER); BFont font; owner->GetFont(&font); // vertically center text float baseLine = itemRect.top + (itemRect.IntegerHeight() / 2 + font.Size() / 2); owner->MovePenTo(owner->PenLocation().x, baseLine); owner->DrawString(fName.String()); if (fErrorMessage.Length() == 0) return; owner->PushState(); font.SetFace(B_ITALIC_FACE); owner->SetFont(&font); owner->SetHighColor(255, 0, 0); owner->MovePenBy(distance, 0); owner->DrawString(fErrorMessage.String()); owner->PopState(); }
void MemoryBarMenuItem::DrawBar(bool force) { // only draw anything if something has changed if (!force && fWriteMemory == fLastWrite && fAllMemory == fLastAll && fCommittedMemory == fLastCommitted) return; bool selected = IsSelected(); BRect frame = Frame(); BMenu* menu = Menu(); // draw the bar itself BRect rect(frame.right - kMargin - kBarWidth, frame.top + 5, frame.right - kMargin, frame.top + 13); if (fWriteMemory < 0) return; if (fGrenze1 < 0) force = true; if (force) { if (selected) menu->SetHighColor(gFrameColorSelected); else menu->SetHighColor(gFrameColor); menu->StrokeRect(rect); } rect.InsetBy(1, 1); BRect r = rect; double grenze1 = rect.left + (rect.right - rect.left) * float(fWriteMemory) / fCommittedMemory; double grenze2 = rect.left + (rect.right - rect.left) * float(fAllMemory) / fCommittedMemory; if (grenze1 > rect.right) grenze1 = rect.right; if (grenze2 > rect.right) grenze2 = rect.right; r.right = grenze1; if (!force) r.left = fGrenze1; if (r.left < r.right) { if (selected) menu->SetHighColor(gKernelColorSelected); else menu->SetHighColor(gKernelColor); menu->FillRect(r); } r.left = grenze1; r.right = grenze2; if (!force) { if (fGrenze2 > r.left && r.left >= fGrenze1) r.left = fGrenze2; if (fGrenze1 < r.right && r.right <= fGrenze2) r.right = fGrenze1; } if (r.left < r.right) { if (selected) menu->SetHighColor(gUserColorSelected); else menu->SetHighColor(gUserColor); menu->FillRect(r); } r.left = grenze2; r.right = rect.right; if (!force) r.right = fGrenze2; if (r.left < r.right) { if (selected) menu->SetHighColor(gWhiteSelected); else menu->SetHighColor(kWhite); menu->FillRect(r); } menu->SetHighColor(kBlack); fGrenze1 = grenze1; fGrenze2 = grenze2; fLastCommitted = fCommittedMemory; // Draw the values if necessary; if only fCommitedMemory changes, only // the bar might have to be updated if (!force && fWriteMemory == fLastWrite && fAllMemory == fLastAll) return; if (selected) menu->SetLowColor(gMenuBackColorSelected); else menu->SetLowColor(gMenuBackColor); BRect textRect(rect.left - kMargin - gMemoryTextWidth, frame.top, rect.left - kMargin, frame.bottom); menu->FillRect(textRect, B_SOLID_LOW); fLastWrite = fWriteMemory; fLastAll = fAllMemory; menu->SetHighColor(kBlack); char infos[128]; string_for_size(fWriteMemory * 1024.0, infos, sizeof(infos)); BPoint loc(rect.left - kMargin - gMemoryTextWidth / 2 - menu->StringWidth(infos), rect.bottom + 1); menu->DrawString(infos, loc); string_for_size(fAllMemory * 1024.0, infos, sizeof(infos)); loc.x = rect.left - kMargin - menu->StringWidth(infos); menu->DrawString(infos, loc); }
/* ** Chop the wood. ** Return TRUE if ready, otherwise FALSE. */ local int ChopWood(Unit* unit) { Unit* destu; int flags; extern Animation PeonAttack[]; flags=UnitShowAnimation(unit,PeonAttack); if( (flags&AnimationSound) ) { PlayUnitSound(unit,VoiceTreeChopping); } if( unit->Reset ) { DebugCheck( unit->Wait!=1 ); // // This a work around the bug: "lumber bug" // We give a worker a new command and in the next cycle // the worker is ready chopping. // #if 0 // FIXME: johns+cade: this didn't work with the current code if( unit->NextCommand[0].Action==UnitActionHarvest || unit->NextCommand[0].Action==UnitActionMineGold ) { unit->SubAction=0; return 0; } #endif // // Wood gone while chopping? // if( !ForestOnMap(unit->Command.Data.Move.DX ,unit->Command.Data.Move.DY) ) { if( FindWoodInSight(unit ,&unit->Command.Data.Move.DX ,&unit->Command.Data.Move.DY) ) { unit->Command.Data.Move.Fast=1; unit->Command.Data.Move.Goal=NoUnitP; unit->Command.Data.Move.Range=0; // FIXME: shouldn't it be range=1 ?? DebugCheck( unit->Command.Action!=UnitActionHarvest ); unit->SubAction=0; } else { unit->Command.Action=UnitActionStill; unit->SubAction=0; DebugLevel3("NO-WOOD in sight range\n"); } return 0; } // // Ready chopping wood? // if( !(unit->WoodToHarvest = --unit->Value) ) { // Have wood if( unit->Type->Type==UnitPeon ) { unit->Type=&UnitTypes[UnitPeonWithWood]; } else if( unit->Type->Type==UnitPeasant ) { unit->Type=&UnitTypes[UnitPeasantWithWood]; } else { DebugLevel0("Wrong unit for chopping wood %d\n" ,unit->Type->Type); } // // Update the display. // if( UnitVisible(unit) ) { MustRedraw|=RedrawMap; } if( IsSelected(unit) ) { UpdateBottomPanel(); MustRedraw|=RedrawBottomPanel; } // // Update the map. // MapRemoveWood(unit->Command.Data.Move.DX ,unit->Command.Data.Move.DY); // // Find place to return wood. // unit->Command.Data.Move.SX=unit->X; unit->Command.Data.Move.SY=unit->Y; if( !(destu=FindWoodDeposit(unit->Player,unit->X,unit->Y)) ) { unit->Command.Action=UnitActionStill; unit->SubAction=0; } else { unit->Command.Data.Move.Fast=1; unit->Command.Data.Move.Range=1; unit->Command.Data.Move.Goal=destu; #if 1 // Fast movement need this?? NearestOfUnit(destu,unit->X,unit->Y ,&unit->Command.Data.Move.DX ,&unit->Command.Data.Move.DY); #else unit->Command.Data.Move.DX=destu->X; unit->Command.Data.Move.DY=destu->Y; #endif DebugLevel3("Return to %Zd=%d,%d\n" ,destu-UnitsPool ,unit->Command.Data.Move.DX ,unit->Command.Data.Move.DY); DebugCheck( unit->Command.Action!=UnitActionHarvest ); return 1; } } } return 0; }
//------------------------------------------------------------------------ bool CItem::SetGeometry(int slot, const ItemString& name, const ItemString& material, bool useParentMaterial, const Vec3& poffset, const Ang3& aoffset, float scale, bool forceReload) { assert(slot >= 0 && slot < eIGS_Last); bool changedfp=false; switch(slot) { case eIGS_Owner: break; case eIGS_FirstPerson: case eIGS_ThirdPerson: default: { if (name.empty() || forceReload) { GetEntity()->FreeSlot(slot); #ifndef ITEM_USE_SHAREDSTRING m_geometry[slot].resize(0); #else m_geometry[slot].reset(); #endif } DestroyAttachmentHelpers(slot); if (!name.empty()) { if (m_geometry[slot] != name) { const char* ext = PathUtil::GetExt(name.c_str()); if ((stricmp(ext, "chr") == 0) || (stricmp(ext, "cdf") == 0) || (stricmp(ext, "cga") == 0) ) GetEntity()->LoadCharacter(slot, name.c_str(), 0); else GetEntity()->LoadGeometry(slot, name.c_str(), 0, 0); changedfp=slot==eIGS_FirstPerson; } CreateAttachmentHelpers(slot); } /* if (slot == eIGS_FirstPerson) { ICharacterInstance *pCharacter = GetEntity()->GetCharacter(eIGS_FirstPerson); if (pCharacter) { pCharacter->SetFlags(pCharacter->GetFlags()&(~CS_FLAG_UPDATE)); } } else */if (slot == eIGS_Destroyed) DrawSlot(eIGS_Destroyed, false); } break; } Matrix34 slotTM; slotTM = Matrix34::CreateRotationXYZ(aoffset); slotTM.ScaleColumn(Vec3(scale, scale, scale)); slotTM.SetTranslation(poffset); GetEntity()->SetSlotLocalTM(slot, slotTM); if (changedfp && m_stats.mounted) { if (m_sharedparams->pMountParams && !m_sharedparams->pMountParams->pivot.empty()) { Matrix34 tm=GetEntity()->GetSlotLocalTM(eIGS_FirstPerson, false); Vec3 pivot = GetSlotHelperPos(eIGS_FirstPerson, m_sharedparams->pMountParams->pivot.c_str(), false); tm.AddTranslation(pivot); GetEntity()->SetSlotLocalTM(eIGS_FirstPerson, tm); } GetEntity()->InvalidateTM(); } m_geometry[slot] = name ? name : ItemString(); ReAttachAccessories(); IEntity* pParentEntity = gEnv->pEntitySystem->GetEntity(GetParentId()); IMaterial* pOverrideMaterial = 0; if (!material.empty()) { pOverrideMaterial = gEnv->p3DEngine->GetMaterialManager()->LoadMaterial(material.c_str()); } else if (useParentMaterial && pParentEntity) { ICharacterInstance* pParentCharacter = pParentEntity->GetCharacter(slot); IEntityRenderProxy* pParentRenderProxy = static_cast<IEntityRenderProxy*>(pParentEntity->GetProxy(ENTITY_PROXY_RENDER)); if (pParentCharacter) pOverrideMaterial = pParentCharacter->GetIMaterial(); else if (pParentRenderProxy) pOverrideMaterial = pParentRenderProxy->GetSlotMaterial(slot); } if (pOverrideMaterial) { ICharacterInstance* pCharacter = GetEntity()->GetCharacter(slot); IEntityRenderProxy* pRenderProxy = static_cast<IEntityRenderProxy*>(GetEntity()->GetProxy(ENTITY_PROXY_RENDER)); OverrideAttachmentMaterial(pOverrideMaterial, this, slot); if (pCharacter) pCharacter->SetIMaterial_Instance(pOverrideMaterial); else if (pRenderProxy) pRenderProxy->SetSlotMaterial(slot, pOverrideMaterial); } if(slot == eIGS_FirstPerson && IsSelected()) { CActor* pOwnerActor = GetOwnerActor(); IActionController *pActionController = GetActionController(); if(pActionController && pOwnerActor && pOwnerActor->IsClient()) { UpdateScopeContexts(pActionController); } } return true; }
int TriggerLogic::GetSelected() const { return IsSelected(); }
void CHexEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags) { nFlags;nRepCnt; if(!m_pData) return; if(nChar == '\t') return; if(GetKeyState(VK_CONTROL) & 0x80000000) { switch(nChar) { case 0x03: if(IsSelected()) OnEditCopy(); return; case 0x16: OnEditPaste(); return; case 0x18: if(IsSelected()) OnEditCut(); return; case 0x1a: OnEditUndo(); return; } } if(nChar == 0x08) { if(m_currentAddress > 0) { m_currentAddress--; SelDelete(m_currentAddress, m_currentAddress+1); RepositionCaret(m_currentAddress); RedrawWindow(); } return; } SetSel(-1, -1); switch(m_currentMode) { case EDIT_NONE: return; case EDIT_HIGH: case EDIT_LOW: if((nChar >= '0' && nChar <= '9') || (nChar >= 'a' && nChar <= 'f')) { UINT b = nChar - '0'; if(b > 9) b = 10 + nChar - 'a'; if(m_currentMode == EDIT_HIGH) { m_pData[m_currentAddress] = (unsigned char)((m_pData[m_currentAddress] & 0x0f) | (b << 4)); } else { m_pData[m_currentAddress] = (unsigned char)((m_pData[m_currentAddress] & 0xf0) | b); } Move(1,0); } break; case EDIT_ASCII: m_pData[m_currentAddress] = (unsigned char)nChar; Move(1,0); break; } RedrawWindow(); }