bool BattlefieldWG::SetupBattlefield() { InitStalker(BATTLEFIELD_WG_NPC_STALKER, WintergraspStalkerPos[0], WintergraspStalkerPos[1], WintergraspStalkerPos[2], WintergraspStalkerPos[3]); m_TypeId = BATTLEFIELD_WG; // See enum BattlefieldTypes m_BattleId = BATTLEFIELD_BATTLEID_WG; m_ZoneId = BATTLEFIELD_WG_ZONEID; m_MapId = BATTLEFIELD_WG_MAPID; m_Map = sMapMgr->FindMap(m_MapId, 0); m_Guid = MAKE_NEW_GUID((m_BattleId ^ 0x20000), 0, HIGHGUID_BATTLEGROUND); m_MaxPlayer = sWorld->getIntConfig(CONFIG_WINTERGRASP_PLR_MAX); m_IsEnabled = sWorld->getBoolConfig(CONFIG_WINTERGRASP_ENABLE); m_MinPlayer = sWorld->getIntConfig(CONFIG_WINTERGRASP_PLR_MIN); m_MinLevel = sWorld->getIntConfig(CONFIG_WINTERGRASP_PLR_MIN_LVL); m_BattleTime = sWorld->getIntConfig(CONFIG_WINTERGRASP_BATTLETIME) * MINUTE * IN_MILLISECONDS; //m_NoWarBattleTime = sWorld->getIntConfig(CONFIG_WINTERGRASP_NOBATTLETIME) * MINUTE * IN_MILLISECONDS; m_NoWarBattleTime = 10 * MINUTE * IN_MILLISECONDS; m_RestartAfterCrash = sWorld->getIntConfig(CONFIG_WINTERGRASP_RESTART_AFTER_CRASH) * MINUTE * IN_MILLISECONDS; m_TimeForAcceptInvite = 20; m_StartGroupingTimer = 5 * MINUTE * IN_MILLISECONDS; //original was 15 m_StartGrouping = false; m_tenacityStack = 0; KickPosition.Relocate(5728.117f, 2714.346f, 697.733f, 0); KickPosition.m_mapId = m_MapId; RegisterZone(m_ZoneId); m_Data32.resize(BATTLEFIELD_WG_DATA_MAX); m_saveTimer = 60000; // Init GraveYards SetGraveyardNumber(BATTLEFIELD_WG_GRAVEYARD_MAX); // Load from db if ((sWorld->getWorldState(BATTLEFIELD_WG_WORLD_STATE_ACTIVE) == 0) && (sWorld->getWorldState(BATTLEFIELD_WG_WORLD_STATE_DEFENDER) == 0) && (sWorld->getWorldState(ClockWorldState[0]) == 0)) { sWorld->setWorldState(BATTLEFIELD_WG_WORLD_STATE_ACTIVE, uint64(false)); sWorld->setWorldState(BATTLEFIELD_WG_WORLD_STATE_DEFENDER, uint64(urand(0, 1))); sWorld->setWorldState(ClockWorldState[0], uint64(m_NoWarBattleTime)); } m_isActive = bool(sWorld->getWorldState(BATTLEFIELD_WG_WORLD_STATE_ACTIVE)); m_DefenderTeam = TeamId(sWorld->getWorldState(BATTLEFIELD_WG_WORLD_STATE_DEFENDER)); m_Timer = sWorld->getWorldState(ClockWorldState[0]); if (m_isActive) { m_isActive = false; m_Timer = m_RestartAfterCrash; } for (uint8 i = 0; i < BATTLEFIELD_WG_GRAVEYARD_MAX; i++) { BfGraveyardWG* graveyard = new BfGraveyardWG(this); // When between games, the graveyard is controlled by the defending team if (WGGraveYard[i].startcontrol == TEAM_NEUTRAL) graveyard->Initialize(m_DefenderTeam, WGGraveYard[i].gyid); else graveyard->Initialize(WGGraveYard[i].startcontrol, WGGraveYard[i].gyid); graveyard->SetTextId(WGGraveYard[i].textid); m_GraveyardList[i] = graveyard; } // Spawn workshocreatures and gameobjects for (uint8 i = 0; i < WG_MAX_WORKSHOP; i++) { WGWorkshop* workshop = new WGWorkshop(this, i); if (i < BATTLEFIELD_WG_WORKSHOP_KEEP_WEST) workshop->GiveControlTo(GetAttackerTeam(), true); else workshop->GiveControlTo(GetDefenderTeam(), true); // Note: Capture point is added once the gameobject is created. WorkshopsList.insert(workshop); } // Spawn NPCs in the defender's keep, both Horde and Alliance for (uint8 i = 0; i < WG_MAX_KEEP_NPC; i++) { // Horde npc if (Creature* creature = SpawnCreature(WGKeepNPC[i].entryHorde, WGKeepNPC[i].x, WGKeepNPC[i].y, WGKeepNPC[i].z, WGKeepNPC[i].o, TEAM_HORDE)) KeepCreature[TEAM_HORDE].insert(creature->GetGUID()); // Alliance npc if (Creature* creature = SpawnCreature(WGKeepNPC[i].entryAlliance, WGKeepNPC[i].x, WGKeepNPC[i].y, WGKeepNPC[i].z, WGKeepNPC[i].o, TEAM_ALLIANCE)) KeepCreature[TEAM_ALLIANCE].insert(creature->GetGUID()); } // Hide NPCs from the Attacker's team in the keep for (GuidSet::const_iterator itr = KeepCreature[GetAttackerTeam()].begin(); itr != KeepCreature[GetAttackerTeam()].end(); ++itr) if (Creature* creature = GetCreature(*itr)) HideNpc(creature); // Spawn Horde NPCs outside the keep for (uint8 i = 0; i < WG_OUTSIDE_ALLIANCE_NPC; i++) if (Creature* creature = SpawnCreature(WGOutsideNPC[i].entryHorde, WGOutsideNPC[i].x, WGOutsideNPC[i].y, WGOutsideNPC[i].z, WGOutsideNPC[i].o, TEAM_HORDE)) OutsideCreature[TEAM_HORDE].insert(creature->GetGUID()); // Spawn Alliance NPCs outside the keep for (uint8 i = WG_OUTSIDE_ALLIANCE_NPC; i < WG_MAX_OUTSIDE_NPC; i++) if (Creature* creature = SpawnCreature(WGOutsideNPC[i].entryAlliance, WGOutsideNPC[i].x, WGOutsideNPC[i].y, WGOutsideNPC[i].z, WGOutsideNPC[i].o, TEAM_ALLIANCE)) OutsideCreature[TEAM_ALLIANCE].insert(creature->GetGUID()); // Hide units outside the keep that are defenders for (GuidSet::const_iterator itr = OutsideCreature[GetDefenderTeam()].begin(); itr != OutsideCreature[GetDefenderTeam()].end(); ++itr) if (Creature* creature = GetCreature(*itr)) HideNpc(creature); // Spawn turrets and hide them per default for (uint8 i = 0; i < WG_MAX_TURRET; i++) { Position towerCannonPos = WGTurret[i].GetPosition(); if (Creature* creature = SpawnCreature(NPC_WINTERGRASP_TOWER_CANNON, towerCannonPos, TEAM_ALLIANCE)) { CanonList.insert(creature->GetGUID()); HideNpc(creature); } } // Spawn all gameobjects for (uint8 i = 0; i < WG_MAX_OBJ; i++) { if (GameObject* go = SpawnGameObject(WGGameObjectBuilding[i].entry, WGGameObjectBuilding[i].x, WGGameObjectBuilding[i].y, WGGameObjectBuilding[i].z, WGGameObjectBuilding[i].o)) { BfWGGameObjectBuilding* b = new BfWGGameObjectBuilding(this); b->Init(go, WGGameObjectBuilding[i].type, WGGameObjectBuilding[i].WorldState, WGGameObjectBuilding[i].nameId); if (!IsEnabled() && go->GetEntry() == GO_WINTERGRASP_VAULT_GATE) go->SetDestructibleState(GO_DESTRUCTIBLE_DESTROYED); BuildingsInZone.insert(b); } } // Spawning portal defender for (uint8 i = 0; i < WG_MAX_TELEPORTER; i++) { if (GameObject* go = SpawnGameObject(WGPortalDefenderData[i].entry, WGPortalDefenderData[i].x, WGPortalDefenderData[i].y, WGPortalDefenderData[i].z, WGPortalDefenderData[i].o)) { DefenderPortalList.insert(go->GetGUID()); go->SetFaction(WintergraspFaction[GetDefenderTeam()]); } } UpdateCounterVehicle(true); return true; }
void CHorizontalLayoutUI::DoEvent(TEventUI& event) { if( m_iSepWidth != 0 ) { if( event.Type == UIEVENT_BUTTONDOWN && IsEnabled() ) { RECT rcSeparator = GetThumbRect(false); if( ::PtInRect(&rcSeparator, event.ptMouse) ) { m_uButtonState |= UISTATE_CAPTURED; ptLastMouse = event.ptMouse; m_rcNewPos = m_rcItem; if( !m_bImmMode && m_pManager ) m_pManager->AddPostPaint(this); return; } } if( event.Type == UIEVENT_BUTTONUP ) { if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) { m_uButtonState &= ~UISTATE_CAPTURED; m_rcItem = m_rcNewPos; if( !m_bImmMode && m_pManager ) m_pManager->RemovePostPaint(this); NeedParentUpdate(); return; } } if( event.Type == UIEVENT_MOUSEMOVE ) { if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) { LONG cx = event.ptMouse.x - ptLastMouse.x; ptLastMouse = event.ptMouse; RECT rc = m_rcNewPos; if( m_iSepWidth >= 0 ) { if( cx > 0 && event.ptMouse.x < m_rcNewPos.right - m_iSepWidth ) return; if( cx < 0 && event.ptMouse.x > m_rcNewPos.right ) return; rc.right += cx; if( rc.right - rc.left <= GetMinWidth() ) { if( m_rcNewPos.right - m_rcNewPos.left <= GetMinWidth() ) return; rc.right = rc.left + GetMinWidth(); } if( rc.right - rc.left >= GetMaxWidth() ) { if( m_rcNewPos.right - m_rcNewPos.left >= GetMaxWidth() ) return; rc.right = rc.left + GetMaxWidth(); } } else { if( cx > 0 && event.ptMouse.x < m_rcNewPos.left ) return; if( cx < 0 && event.ptMouse.x > m_rcNewPos.left - m_iSepWidth ) return; rc.left += cx; if( rc.right - rc.left <= GetMinWidth() ) { if( m_rcNewPos.right - m_rcNewPos.left <= GetMinWidth() ) return; rc.left = rc.right - GetMinWidth(); } if( rc.right - rc.left >= GetMaxWidth() ) { if( m_rcNewPos.right - m_rcNewPos.left >= GetMaxWidth() ) return; rc.left = rc.right - GetMaxWidth(); } } CDuiRect rcInvalidate = GetThumbRect(true); m_rcNewPos = rc; m_cxyFixed.cx = m_rcNewPos.right - m_rcNewPos.left; if( m_bImmMode ) { m_rcItem = m_rcNewPos; NeedParentUpdate(); } else { rcInvalidate.Join(GetThumbRect(true)); rcInvalidate.Join(GetThumbRect(false)); if( m_pManager ) m_pManager->Invalidate(rcInvalidate); } return; } } if( event.Type == UIEVENT_SETCURSOR ) { RECT rcSeparator = GetThumbRect(false); if( IsEnabled() && ::PtInRect(&rcSeparator, event.ptMouse) ) { ::SetCursor(::LoadCursor(NULL, MAKEINTRESOURCE(IDC_SIZEWE))); return; } } } CContainerUI::DoEvent(event); }
void CalendarControl::Draw(BRect r) { #ifdef __UNIVERSAL_INTERFACE if(interface==CC_ZETA_INTERFACE) { #endif #ifdef __ZETA_INTERFACE BRect rect1(Bounds()); rect1.bottom--; rect1.right=pb->Frame().left-2; BRect rect2(rect1); BPoint p1, p2; rgb_color color; if(IsEnabled()) { if(dtvc->IsFocus() && wc) // window is active and control is focused // (control is enabled) { SetHighColor(170,50,184,0); StrokeRect(rect1); rect1.left++; rect1.top++; rect1.right--; rect1.bottom--; StrokeRect(rect1); SetHighColor(255,255,255,0); rect1.left++; rect1.top++; rect1.right--; rect1.bottom--; StrokeLine(rect1.LeftBottom(),rect1.RightBottom()); StrokeLine(rect1.RightTop(),rect1.RightBottom()); SetHighColor(218,218,218,0); StrokeLine(rect1.LeftTop(),rect1.LeftBottom()); StrokeLine(rect1.LeftTop(),rect1.RightTop()); SetHighColor(114,114,114,0); StrokeLine(rect1.LeftTop(),rect1.LeftTop()); StrokeLine(rect1.LeftBottom(),rect1.LeftBottom()); StrokeLine(rect1.RightTop(),rect1.RightTop()); StrokeLine(rect1.RightBottom(),rect1.RightBottom()); // outward borders color.red=170+(uint8)((229-170)*(view_color.red-170)/(255-170)); color.green=50+(uint8)((194-50)*(view_color.green-50)/(255-50)); color.blue=184+(uint8)((233-184)*(view_color.blue-184)/(255-184)); color.alpha=255; SetHighColor(color); p1.Set(rect2.left,rect2.top+1); p2.Set(rect2.left+1,rect2.top); StrokeLine(p1,p2); p1.Set(rect2.right,rect2.top+1); p2.Set(rect2.right-1,rect2.top); StrokeLine(p1,p2); p1.Set(rect2.right,rect2.bottom-1); p2.Set(rect2.right-1,rect2.bottom); StrokeLine(p1,p2); p1.Set(rect2.left,rect2.bottom-1); p2.Set(rect2.left+1,rect2.bottom); StrokeLine(p1,p2); SetHighColor(view_color); StrokeLine(rect2.LeftTop(),rect2.LeftTop()); StrokeLine(rect2.LeftBottom(),rect2.LeftBottom()); StrokeLine(rect2.RightTop(),rect2.RightTop()); StrokeLine(rect2.RightBottom(),rect2.RightBottom()); } else // window is not active or control is unfocused (control is enabled) { SetHighColor(255,255,255,0); rect1.left++; rect1.top++; rect1.right--; rect1.bottom--; StrokeRect(rect1); rect1.left++; rect1.top++; rect1.right--; rect1.bottom--; StrokeRect(rect1); rect1=rect2; SetHighColor(0,0,0,0); StrokeRect(rect1); rect1.left++; rect1.top++; rect1.right--; rect1.bottom--; StrokeLine(rect1.LeftTop(),rect1.LeftTop()); StrokeLine(rect1.LeftBottom(),rect1.LeftBottom()); StrokeLine(rect1.RightTop(),rect1.RightTop()); StrokeLine(rect1.RightBottom(),rect1.RightBottom()); SetHighColor(180,180,180,0); p1.Set(rect2.left+2,rect2.top+1); p2.Set(rect2.right-2,rect2.top+1); StrokeLine(p1,p2); p1.Set(rect2.left+1,rect2.top+2); p2.Set(rect2.left+1,rect2.bottom-2); StrokeLine(p1,p2); p1.Set(rect2.left+2,rect2.top+2); StrokeLine(p1,p1); SetHighColor(218,218,218,0); p1.Set(rect2.left+2,rect2.top+3); p2.Set(rect2.left+2,rect2.bottom-1); StrokeLine(p1,p2); p1.Set(rect2.left+3,rect2.top+2); p2.Set(rect2.right-1,rect2.top+2); StrokeLine(p1,p2); // outward borders color.red=(uint8)(218*view_color.red/255); color.green=(uint8)(218*view_color.green/255); color.blue=(uint8)(218*view_color.blue/255); color.alpha=255; SetHighColor(color); p1.Set(rect2.left,rect2.top+1); p2.Set(rect2.left+1,rect2.top); StrokeLine(p1,p2); p1.Set(rect2.right,rect2.top+1); p2.Set(rect2.right-1,rect2.top); StrokeLine(p1,p2); p1.Set(rect2.right,rect2.bottom-1); p2.Set(rect2.right-1,rect2.bottom); StrokeLine(p1,p2); p1.Set(rect2.left,rect2.bottom-1); p2.Set(rect2.left+1,rect2.bottom); StrokeLine(p1,p2); SetHighColor(view_color); StrokeLine(rect2.LeftTop(),rect2.LeftTop()); StrokeLine(rect2.LeftBottom(),rect2.LeftBottom()); StrokeLine(rect2.RightTop(),rect2.RightTop()); StrokeLine(rect2.RightBottom(),rect2.RightBottom()); } } else // control is disabled { if(dtvc->IsFocus() && wc) // window is active and control is focused // (control is disabled) { SetHighColor(255,255,255,0); rect1.left+=2; rect1.top+=2; rect1.right-=2; rect1.bottom-=2; StrokeRect(rect1); rect1=rect2; SetHighColor(231,198,235,0); StrokeRect(rect1); rect1.left++; rect1.top++; rect1.right--; rect1.bottom--; StrokeRect(rect1); rect1.left++; rect1.top++; rect1.right--; rect1.bottom--; StrokeLine(rect1.LeftTop(),rect1.LeftTop()); StrokeLine(rect1.LeftBottom(),rect1.LeftBottom()); StrokeLine(rect1.RightTop(),rect1.RightTop()); StrokeLine(rect1.RightBottom(),rect1.RightBottom()); // outward borders color.red=231+(uint8)((251-231)*(view_color.red-231)/(255-231)); color.green=198+(uint8)((246-198)*(view_color.green-198)/(255-198)); color.blue=235+(uint8)((251-235)*(view_color.blue-235)/(255-235)); color.alpha=255; SetHighColor(color); p1.Set(rect2.left,rect2.top+1); p2.Set(rect2.left+1,rect2.top); StrokeLine(p1,p2); p1.Set(rect2.right,rect2.top+1); p2.Set(rect2.right-1,rect2.top); StrokeLine(p1,p2); p1.Set(rect2.right,rect2.bottom-1); p2.Set(rect2.right-1,rect2.bottom); StrokeLine(p1,p2); SetHighColor(view_color); p1.Set(rect2.left,rect2.bottom-1); p2.Set(rect2.left+1,rect2.bottom); StrokeLine(p1,p2); StrokeLine(rect2.LeftTop(),rect2.LeftTop()); StrokeLine(rect2.LeftBottom(),rect2.LeftBottom()); StrokeLine(rect2.RightTop(),rect2.RightTop()); StrokeLine(rect2.RightBottom(),rect2.RightBottom()); } else // window is not active or control is unfocused (control is disabled) { SetHighColor(255,255,255,0); rect1.left++; rect1.top++; rect1.right--; rect1.bottom--; StrokeRect(rect1); rect1.left++; rect1.top++; rect1.right--; rect1.bottom--; StrokeRect(rect1); rect1=rect2; SetHighColor(185,185,185,0); StrokeRect(rect1); rect1.left++; rect1.top++; rect1.right--; rect1.bottom--; StrokeLine(rect1.LeftTop(),rect1.LeftTop()); StrokeLine(rect1.LeftBottom(),rect1.LeftBottom()); StrokeLine(rect1.RightTop(),rect1.RightTop()); StrokeLine(rect1.RightBottom(),rect1.RightBottom()); // outward borders color.red=185+(uint8)((245-185)*(view_color.red-185)/(255-185)); color.green=185+(uint8)((245-185)*(view_color.green-185)/(255-185)); color.blue=185+(uint8)((245-185)*(view_color.blue-185)/(255-185)); color.alpha=255; SetHighColor(color); p1.Set(rect2.left,rect2.top+1); p2.Set(rect2.left+1,rect2.top); StrokeLine(p1,p2); p1.Set(rect2.right,rect2.top+1); p2.Set(rect2.right-1,rect2.top); StrokeLine(p1,p2); p1.Set(rect2.right,rect2.bottom-1); p2.Set(rect2.right-1,rect2.bottom); StrokeLine(p1,p2); SetHighColor(view_color); p1.Set(rect2.left,rect2.bottom-1); p2.Set(rect2.left+1,rect2.bottom); StrokeLine(p1,p2); StrokeLine(rect2.LeftTop(),rect2.LeftTop()); StrokeLine(rect2.LeftBottom(),rect2.LeftBottom()); StrokeLine(rect2.RightTop(),rect2.RightTop()); StrokeLine(rect2.RightBottom(),rect2.RightBottom()); } } #endif #ifdef __UNIVERSAL_INTERFACE } else // interface==CC_BEOS_INTERFACE { #endif #ifdef __BEOS_INTERFACE BRect rect1(Bounds()),rect2(Bounds()); rect1.bottom--; rect1.right=pb->Frame().left-1; rect2.top++; rect2.left++; rect2.bottom-=2; rect2.right=rect1.right-1; if(IsEnabled()) SetHighColor(255,255,255,255); else SetHighColor(239,239,239,255); StrokeLine(rect1.LeftBottom(),rect1.RightBottom()); StrokeLine(rect1.RightTop(),rect1.RightBottom()); if(IsEnabled()) SetHighColor(184,184,184,0); else SetHighColor(216,216,216,0); StrokeLine(rect1.LeftTop(),rect1.RightTop()); StrokeLine(rect1.LeftTop(),rect1.LeftBottom()); if(dtvc->IsFocus() && wc) { SetHighColor(0,0,229,0); StrokeRect(rect2); } else { SetHighColor(216,216,216,0); StrokeLine(rect2.LeftBottom(),rect2.RightBottom()); StrokeLine(rect2.RightTop(),rect2.RightBottom()); if(IsEnabled()) SetHighColor(96,96,96,0); else SetHighColor(152,152,152,0); StrokeLine(rect2.LeftTop(),rect2.RightTop()); StrokeLine(rect2.LeftTop(),rect2.LeftBottom()); } if(IsEnabled()) SetHighColor(255,255,255,255); else SetHighColor(239,239,239,255); rect2.top++; rect2.left++; rect2.right--; rect2.bottom--; StrokeRect(rect2); #endif #ifdef __UNIVERSAL_INTERFACE } #endif }
UINT CSliderUI::GetControlFlags() const { if( IsEnabled() ) return UIFLAG_SETCURSOR; else return 0; }
UINT CTextUI::GetControlFlags() const { if( IsEnabled() && m_nLinks > 0 ) return UIFLAG_SETCURSOR; else return 0; }
int ccp_ReportStatus(struct cmdargs const *arg) { struct ccp_opt **o; struct link *l; struct ccp *ccp; int f; l = command_ChooseLink(arg); ccp = &l->ccp; prompt_Printf(arg->prompt, "%s: %s [%s]\n", l->name, ccp->fsm.name, State2Nam(ccp->fsm.state)); if (ccp->fsm.state == ST_OPENED) { prompt_Printf(arg->prompt, " My protocol = %s, His protocol = %s\n", protoname(ccp->my_proto), protoname(ccp->his_proto)); prompt_Printf(arg->prompt, " Output: %ld --> %ld, Input: %ld --> %ld\n", ccp->uncompout, ccp->compout, ccp->compin, ccp->uncompin); } if (ccp->in.algorithm != -1) prompt_Printf(arg->prompt, "\n Input Options: %s\n", (*algorithm[ccp->in.algorithm]->Disp)(&ccp->in.opt)); if (ccp->out.algorithm != -1) { o = &ccp->out.opt; for (f = 0; f < ccp->out.algorithm; f++) if (IsEnabled(ccp->cfg.neg[algorithm[f]->Neg])) o = &(*o)->next; prompt_Printf(arg->prompt, " Output Options: %s\n", (*algorithm[ccp->out.algorithm]->Disp)(&(*o)->val)); } prompt_Printf(arg->prompt, "\n Defaults: "); prompt_Printf(arg->prompt, "FSM retry = %us, max %u Config" " REQ%s, %u Term REQ%s\n", ccp->cfg.fsm.timeout, ccp->cfg.fsm.maxreq, ccp->cfg.fsm.maxreq == 1 ? "" : "s", ccp->cfg.fsm.maxtrm, ccp->cfg.fsm.maxtrm == 1 ? "" : "s"); prompt_Printf(arg->prompt, " deflate windows: "); prompt_Printf(arg->prompt, "incoming = %d, ", ccp->cfg.deflate.in.winsize); prompt_Printf(arg->prompt, "outgoing = %d\n", ccp->cfg.deflate.out.winsize); #ifndef NODES prompt_Printf(arg->prompt, " MPPE: "); if (ccp->cfg.mppe.keybits) prompt_Printf(arg->prompt, "%d bits, ", ccp->cfg.mppe.keybits); else prompt_Printf(arg->prompt, "any bits, "); switch (ccp->cfg.mppe.state) { case MPPE_STATEFUL: prompt_Printf(arg->prompt, "stateful"); break; case MPPE_STATELESS: prompt_Printf(arg->prompt, "stateless"); break; case MPPE_ANYSTATE: prompt_Printf(arg->prompt, "any state"); break; } prompt_Printf(arg->prompt, "%s\n", ccp->cfg.mppe.required ? ", required" : ""); #endif prompt_Printf(arg->prompt, "\n DEFLATE: %s\n", command_ShowNegval(ccp->cfg.neg[CCP_NEG_DEFLATE])); prompt_Printf(arg->prompt, " PREDICTOR1: %s\n", command_ShowNegval(ccp->cfg.neg[CCP_NEG_PRED1])); prompt_Printf(arg->prompt, " DEFLATE24: %s\n", command_ShowNegval(ccp->cfg.neg[CCP_NEG_DEFLATE24])); #ifndef NODES prompt_Printf(arg->prompt, " MPPE: %s\n", command_ShowNegval(ccp->cfg.neg[CCP_NEG_MPPE])); #endif return 0; }
/* static */ bool MP4Decoder::CanHandleMediaType(const nsACString& aMIMETypeExcludingCodecs, const nsAString& aCodecs) { if (!IsEnabled()) { return false; } // Whitelist MP4 types, so they explicitly match what we encounter on // the web, as opposed to what we use internally (i.e. what our demuxers // etc output). const bool isMP4Audio = aMIMETypeExcludingCodecs.EqualsASCII("audio/mp4") || aMIMETypeExcludingCodecs.EqualsASCII("audio/x-m4a"); const bool isMP4Video = // On B2G, treat 3GPP as MP4 when Gonk PDM is available. #ifdef MOZ_GONK_MEDIACODEC aMIMETypeExcludingCodecs.EqualsASCII(VIDEO_3GPP) || #endif aMIMETypeExcludingCodecs.EqualsASCII("video/mp4") || aMIMETypeExcludingCodecs.EqualsASCII("video/x-m4v"); if (!isMP4Audio && !isMP4Video) { return false; } nsTArray<nsCString> codecMimes; if (aCodecs.IsEmpty()) { // No codecs specified. Assume AAC/H.264 if (isMP4Audio) { codecMimes.AppendElement(NS_LITERAL_CSTRING("audio/mp4a-latm")); } else { MOZ_ASSERT(isMP4Video); codecMimes.AppendElement(NS_LITERAL_CSTRING("video/avc")); } } else { // Verify that all the codecs specified are ones that we expect that // we can play. nsTArray<nsString> codecs; if (!ParseCodecsString(aCodecs, codecs)) { return false; } for (const nsString& codec : codecs) { if (IsAACCodecString(codec)) { codecMimes.AppendElement(NS_LITERAL_CSTRING("audio/mp4a-latm")); continue; } if (codec.EqualsLiteral("mp3")) { codecMimes.AppendElement(NS_LITERAL_CSTRING("audio/mpeg")); continue; } // Note: Only accept H.264 in a video content type, not in an audio // content type. if (IsWhitelistedH264Codec(codec) && isMP4Video) { codecMimes.AppendElement(NS_LITERAL_CSTRING("video/avc")); continue; } // Some unsupported codec. return false; } } // Verify that we have a PDM that supports the whitelisted types. PDMFactory::Init(); RefPtr<PDMFactory> platform = new PDMFactory(); for (const nsCString& codecMime : codecMimes) { if (!platform->SupportsMimeType(codecMime)) { return false; } } return true; }
void CDateTimeUI::DoEvent(TEventUI& event) { if (!IsMouseEnabled() && event.Type > UIEVENT__MOUSEBEGIN && event.Type < UIEVENT__MOUSEEND) { if (m_pParent != NULL) m_pParent->DoEvent(event); else CLabelUI::DoEvent(event); return; } if (event.Type == UIEVENT_SETCURSOR && IsEnabled()) { ::SetCursor(::LoadCursor(NULL, MAKEINTRESOURCE(IDC_IBEAM))); return; } if (event.Type == UIEVENT_WINDOWSIZE) { if (m_pWindow != NULL) m_pManager->SetFocusNeeded(this); } if (event.Type == UIEVENT_SCROLLWHEEL) { if (m_pWindow != NULL) return; } if (event.Type == UIEVENT_SETFOCUS && IsEnabled()) { if (m_pWindow) return; m_pWindow = new CDateTimeWnd(); ASSERT(m_pWindow); m_pWindow->Init(this); m_pWindow->ShowWindow(); } if (event.Type == UIEVENT_KILLFOCUS && IsEnabled()) { Invalidate(); } if (event.Type == UIEVENT_BUTTONDOWN || event.Type == UIEVENT_DBLCLICK || event.Type == UIEVENT_RBUTTONDOWN) { if (IsEnabled()) { GetManager()->ReleaseCapture(); if (IsFocused() && m_pWindow == NULL) { m_pWindow = new CDateTimeWnd(); ASSERT(m_pWindow); } if (m_pWindow != NULL) { m_pWindow->Init(this); m_pWindow->ShowWindow(); } } return; } if (event.Type == UIEVENT_MOUSEMOVE) { return; } if (event.Type == UIEVENT_BUTTONUP) { return; } if (event.Type == UIEVENT_CONTEXTMENU) { return; } if (event.Type == UIEVENT_MOUSEENTER) { return; } if (event.Type == UIEVENT_MOUSELEAVE) { return; } CLabelUI::DoEvent(event); }
void Slider::Layout() { const auto &size = GetSize(); double w = size.x; const auto &s = display.styles; background->SetSize(size); double scale = w / (max - min); double offset, len; if (min > 0) { len = (value - min) * scale; offset = 0; } else if (max < 0) { len = -(value - max) * scale; offset = w - len; } else { double zeroPoint = -min * scale; zeroLine->SetLength(size.y); zeroLine->SetPos(zeroPoint, 0); if (value < 0) { len = -value * scale; offset = zeroPoint - len; } else if (value > 0) { len = value * scale; offset = zeroPoint; } else { len = 0; offset = zeroPoint; } } indicator->SetPos(offset, 0); indicator->SetSize(len, size.y); if (!IsEnabled()) { background->SetColor(s.buttonDisabledBg); indicator->SetColor(s.buttonDisabledBg); } else if (IsPressed()) { background->SetColor(s.buttonPressedBg); indicator->SetColor(s.buttonPressedBg); } else { background->SetColor(s.buttonBg); indicator->SetColor(s.buttonBg); } if (IsFocused()) { background->SetBorder(4); background->SetBorderColor(s.buttonFocusedBg); } else { background->SetBorder(0); } }
void CUIVerticalLayout::DoEvent(TEventUI& event) { if( m_iSepHeight != 0 ) { if( event.Type == UIEVENT_BUTTONDOWN && IsEnabled() ){ CUIRect rcSeparator = GetThumbRect(false); if(rcSeparator.IsPtIn(event.ptMouse)) { m_uButtonState |= UISTATE_CAPTURED; ptLastMouse = event.ptMouse; m_rcNewPos = m_rcItem; if(!m_bImmMode /*&& m_pManager*/) /*m_pManager->AddPostPaint(this);*/ return; } } if( event.Type == UIEVENT_BUTTONUP ){ if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) { m_uButtonState &= ~UISTATE_CAPTURED; m_rcItem = m_rcNewPos; if( !m_bImmMode /*&& m_pManager*/ ) /*m_pManager->RemovePostPaint(this);*/ NeedParentUpdate(); return; } } if( event.Type == UIEVENT_MOUSEMOVE ){ if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) { LONG cy = event.ptMouse.y - ptLastMouse.y; ptLastMouse = event.ptMouse; RECT rc = m_rcNewPos; if( m_iSepHeight >= 0 ) { if( cy > 0 && event.ptMouse.y < m_rcNewPos.bottom + m_iSepHeight ) return; if( cy < 0 && event.ptMouse.y > m_rcNewPos.bottom ) return; rc.bottom += cy; if( rc.bottom - rc.top <= GetMinHeight() ) { if( m_rcNewPos.bottom - m_rcNewPos.top <= GetMinHeight() ) return; rc.bottom = rc.top + GetMinHeight(); } if( rc.bottom - rc.top >= GetMaxHeight() ) { if( m_rcNewPos.bottom - m_rcNewPos.top >= GetMaxHeight() ) return; rc.bottom = rc.top + GetMaxHeight(); } }else{ if( cy > 0 && event.ptMouse.y < m_rcNewPos.top ) return; if( cy < 0 && event.ptMouse.y > m_rcNewPos.top + m_iSepHeight ) return; rc.top += cy; if( rc.bottom - rc.top <= GetMinHeight() ) { if( m_rcNewPos.bottom - m_rcNewPos.top <= GetMinHeight() ) return; rc.top = rc.bottom - GetMinHeight(); } if( rc.bottom - rc.top >= GetMaxHeight() ) { if( m_rcNewPos.bottom - m_rcNewPos.top >= GetMaxHeight() ) return; rc.top = rc.bottom - GetMaxHeight(); } } CUIRect rcInvalidate = GetThumbRect(true); m_rcNewPos = rc; m_cxyFixed.cy = m_rcNewPos.bottom - m_rcNewPos.top; if( m_bImmMode ) { m_rcItem = m_rcNewPos; NeedParentUpdate(); }else{ rcInvalidate.Join(GetThumbRect(true)); rcInvalidate.Join(GetThumbRect(false)); if(m_Window) m_Window->Invalidate(rcInvalidate); } return; } } if( event.Type == UIEVENT_SETCURSOR ) { CUIRect rcSeparator = GetThumbRect(false); if( IsEnabled() && rcSeparator.IsPtIn(event.ptMouse)) { // // TODO: SetCursor // //::SetCursor(::LoadCursor(NULL, MAKEINTRESOURCE(IDC_SIZENS))); return; } } } CUIContainer::DoEvent(event); }
void SToolBarButton::onPaint(wxPaintEvent& e) { wxPaintDC dc(this); // Get system colours needed wxColour col_background = Drawing::getMenuBarBGColour(); wxColour col_hilight = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); // Draw background dc.SetBackground(wxBrush(col_background)); dc.Clear(); // Create graphics context wxGraphicsContext* gc = wxGraphicsContext::Create(dc); if (!gc) return; // Draw toggled border/background if (action->isToggled()) { // Use greyscale version of hilight colour uint8_t r = col_hilight.Red(); uint8_t g = col_hilight.Green(); uint8_t b = col_hilight.Blue(); wxColour::MakeGrey(&r, &g, &b); wxColour col_toggle(r, g, b, 255); wxColour col_trans(r, g, b, 150); if (toolbar_button_flat) { // Draw border col_trans.Set(col_trans.Red(), col_trans.Green(), col_trans.Blue(), 80); gc->SetBrush(col_trans); gc->SetPen(wxPen(Drawing::darkColour(col_toggle, 5.0f))); gc->DrawRectangle(1, 1, 20, 20); } else { // Draw border gc->SetBrush(col_trans); gc->SetPen(wxPen(Drawing::lightColour(col_toggle, 5.0f), 1)); gc->DrawRoundedRectangle(2, 2, 18, 18, 2); // Draw outer border gc->SetBrush(wxBrush(col_toggle, wxBRUSHSTYLE_TRANSPARENT)); gc->SetPen(wxPen(Drawing::darkColour(col_toggle, 5.0f))); gc->DrawRoundedRectangle(1, 1, 20, 20, 2); } } // Draw border on mouseover if (state == STATE_MOUSEOVER || state == STATE_MOUSEDOWN) { // Determine transparency level int trans = 160; if (state == STATE_MOUSEDOWN) trans = 200; // Create semitransparent hilight colour wxColour col_trans(col_hilight.Red(), col_hilight.Green(), col_hilight.Blue(), trans); if (toolbar_button_flat) { // Draw border col_trans.Set(col_trans.Red(), col_trans.Green(), col_trans.Blue(), 80); gc->SetBrush(col_trans); gc->SetPen(wxPen(col_hilight)); gc->DrawRectangle(1, 1, 20, 20); } else { // Draw border gc->SetBrush(col_trans); gc->SetPen(wxPen(Drawing::lightColour(col_hilight, 5.0f), 1)); gc->DrawRoundedRectangle(2, 2, 18, 18, 2); // Draw outer border gc->SetBrush(wxBrush(col_hilight, wxBRUSHSTYLE_TRANSPARENT)); gc->SetPen(wxPen(Drawing::darkColour(col_hilight, 5.0f))); gc->DrawRoundedRectangle(1, 1, 20, 20, 2); } } // Draw disabled icon if disabled if (!IsEnabled()) { // Determine toolbar background brightness uint8_t r,g,b; r = col_background.Red(); g = col_background.Green(); b = col_background.Blue(); wxColor::MakeGrey(&r, &g, &b); // Draw disabled icon gc->DrawBitmap(icon.ConvertToDisabled(r), 3, 3, 16, 16); } // Otherwise draw normal icon else gc->DrawBitmap(icon, 3, 3, 16, 16); delete gc; }
bool CControlUI::Activate() { if( !IsVisible() ) return false; if( !IsEnabled() ) return false; return true; }
void CLabelUI::PaintText(HDC hDC) { if( m_dwTextColor == 0 ) m_dwTextColor = m_pManager->GetDefaultFontColor(); if( m_dwDisabledTextColor == 0 ) m_dwDisabledTextColor = m_pManager->GetDefaultDisabledColor(); RECT rc = m_rcItem; rc.left += m_rcTextPadding.left; rc.right -= m_rcTextPadding.right; rc.top += m_rcTextPadding.top; rc.bottom -= m_rcTextPadding.bottom; if(!GetEnabledEffect()) { if( m_sText.IsEmpty() ) return; int nLinks = 0; if( IsEnabled() ) { if( m_bShowHtml ) CRenderEngine::DrawHtmlText(hDC, m_pManager, rc, m_sText, m_dwTextColor, \ NULL, NULL, nLinks, m_uTextStyle); else CRenderEngine::DrawText(hDC, m_pManager, rc, m_sText, m_dwTextColor, \ m_iFont, m_uTextStyle); } else { if( m_bShowHtml ) CRenderEngine::DrawHtmlText(hDC, m_pManager, rc, m_sText, m_dwDisabledTextColor, \ NULL, NULL, nLinks, DT_SINGLELINE | m_uTextStyle); else CRenderEngine::DrawText(hDC, m_pManager, rc, m_sText, m_dwDisabledTextColor, \ m_iFont, DT_SINGLELINE | m_uTextStyle); } } else { Font nFont(hDC,m_pManager->GetFont(GetFont())); Graphics nGraphics(hDC); nGraphics.SetTextRenderingHint(TextRenderingHintAntiAlias); StringFormat format; StringAlignment sa = StringAlignment::StringAlignmentNear; if ((m_uTextStyle & DT_VCENTER) != 0) sa = StringAlignment::StringAlignmentCenter; else if( (m_uTextStyle & DT_BOTTOM) != 0) sa = StringAlignment::StringAlignmentFar; format.SetAlignment((StringAlignment)sa); sa = StringAlignment::StringAlignmentNear; if ((m_uTextStyle & DT_CENTER) != 0) sa = StringAlignment::StringAlignmentCenter; else if( (m_uTextStyle & DT_RIGHT) != 0) sa = StringAlignment::StringAlignmentFar; format.SetLineAlignment((StringAlignment)sa); RectF nRc((float)rc.left,(float)rc.top,(float)rc.right-rc.left,(float)rc.bottom-rc.top); RectF nShadowRc = nRc; nShadowRc.X += m_ShadowOffset.X; nShadowRc.Y += m_ShadowOffset.Y; int nGradientLength = GetGradientLength(); if(nGradientLength == 0) nGradientLength = (rc.bottom-rc.top); LinearGradientBrush nLineGrBrushA(Point(GetGradientAngle(), 0),Point(0,nGradientLength),ARGB2Color(GetTextShadowColorA()),ARGB2Color(GetTextShadowColorB() == -1?GetTextShadowColorA():GetTextShadowColorB())); LinearGradientBrush nLineGrBrushB(Point(GetGradientAngle(), 0),Point(0,nGradientLength),ARGB2Color(GetTextColor()),ARGB2Color(GetTextColor1() == -1?GetTextColor():GetTextColor1())); if (GetEnabledLuminous()) { // from http://bbs.csdn.net/topics/390346428 int iFuzzyWidth = (int)(nRc.Width/GetLuminousFuzzy()); if (iFuzzyWidth < 1) iFuzzyWidth = 1; int iFuzzyHeight = (int)(nRc.Height/GetLuminousFuzzy()); if (iFuzzyHeight < 1) iFuzzyHeight = 1; RectF nTextRc(0.0f, 0.0f, nRc.Width, nRc.Height); Bitmap Bit1((INT)nRc.Width, (INT)nRc.Height); Graphics g1(&Bit1); g1.SetSmoothingMode(SmoothingModeAntiAlias); g1.SetTextRenderingHint(TextRenderingHintAntiAlias); g1.SetCompositingQuality(CompositingQualityAssumeLinear); Bitmap Bit2(iFuzzyWidth, iFuzzyHeight); Graphics g2(&Bit2); g2.SetInterpolationMode(InterpolationModeHighQualityBicubic); g2.SetPixelOffsetMode(PixelOffsetModeNone); FontFamily ftFamily; nFont.GetFamily(&ftFamily); int iLen = wcslen(m_pWideText); g1.DrawString(m_pWideText,iLen,&nFont,nRc,&format,&nLineGrBrushB); g2.DrawImage(&Bit1, 0, 0, (int)iFuzzyWidth, (int)iFuzzyHeight); g1.Clear(Color(0)); g1.DrawImage(&Bit2, (int)m_ShadowOffset.X, (int)m_ShadowOffset.Y, (int)nRc.Width, (int)nRc.Height); g1.SetTextRenderingHint(TextRenderingHintAntiAlias); nGraphics.DrawImage(&Bit1, nRc.X, nRc.Y); } if(GetEnabledStroke() && GetStrokeColor() > 0) { LinearGradientBrush nLineGrBrushStroke(Point(GetGradientAngle(),0),Point(0,rc.bottom-rc.top+2),ARGB2Color(GetStrokeColor()),ARGB2Color(GetStrokeColor())); #ifdef _UNICODE nRc.Offset(-1,0); nGraphics.DrawString(m_sText,m_sText.GetLength(),&nFont,nRc,&format,&nLineGrBrushStroke); nRc.Offset(2,0); nGraphics.DrawString(m_sText,m_sText.GetLength(),&nFont,nRc,&format,&nLineGrBrushStroke); nRc.Offset(-1,-1); nGraphics.DrawString(m_sText,m_sText.GetLength(),&nFont,nRc,&format,&nLineGrBrushStroke); nRc.Offset(0,2); nGraphics.DrawString(m_sText,m_sText.GetLength(),&nFont,nRc,&format,&nLineGrBrushStroke); nRc.Offset(0,-1); #else int iLen = wcslen(m_pWideText); nRc.Offset(-1,0); nGraphics.DrawString(m_pWideText,iLen,&nFont,nRc,&format,&nLineGrBrushStroke); nRc.Offset(2,0); nGraphics.DrawString(m_pWideText,iLen,&nFont,nRc,&format,&nLineGrBrushStroke); nRc.Offset(-1,-1); nGraphics.DrawString(m_pWideText,iLen,&nFont,nRc,&format,&nLineGrBrushStroke); nRc.Offset(0,2); nGraphics.DrawString(m_pWideText,iLen,&nFont,nRc,&format,&nLineGrBrushStroke); nRc.Offset(0,-1); #endif } #ifdef _UNICODE if(GetEnabledShadow() && (GetTextShadowColorA() > 0 || GetTextShadowColorB() > 0)) nGraphics.DrawString(m_sText,m_sText.GetLength(),&nFont,nShadowRc,&format,&nLineGrBrushA); nGraphics.DrawString(m_sText,m_sText.GetLength(),&nFont,nRc,&format,&nLineGrBrushB); #else int iLen = wcslen(m_pWideText); if(GetEnabledShadow() && (GetTextShadowColorA() > 0 || GetTextShadowColorB() > 0)) nGraphics.DrawString(m_pWideText,iLen,&nFont,nShadowRc,&format,&nLineGrBrushA); nGraphics.DrawString(m_pWideText,iLen,&nFont,nRc,&format,&nLineGrBrushB); #endif } }
bool CZClip::Enable(bool bOnOff) { m_bEnabled = !m_bEnabled; return IsEnabled(); }
void CLEDEntity::SetEnabled(bool b_enabled) { CEntity::SetEnabled(b_enabled); if(IsEnabled()) { m_cColor = m_cInitColor; } }
void TAbstractWindow::_updateChildren() { if (IsEnabled() == false) { return; } parent_type::_updateChildren(); }
void CFadeButtonUI::PaintStatusImage(HDC hDC) { if( IsFocused() ) m_uButtonState |= UISTATE_FOCUSED; else m_uButtonState &= ~ UISTATE_FOCUSED; if( !IsEnabled() ) m_uButtonState |= UISTATE_DISABLED; else m_uButtonState &= ~ UISTATE_DISABLED; if( (m_uButtonState & UISTATE_DISABLED) != 0 ) { if( !m_sDisabledImage.IsEmpty() ) { if( !DrawImage(hDC, (LPCTSTR)m_sDisabledImage) ) {} else return; } } else if( (m_uButtonState & UISTATE_PUSHED) != 0 ) { if( !m_sPushedImage.IsEmpty() ) { if( !DrawImage(hDC, (LPCTSTR)m_sPushedImage) ) {} else return; } } else if( (m_uButtonState & UISTATE_FOCUSED) != 0 ) { if( !m_sFocusedImage.IsEmpty() ) { if( !DrawImage(hDC, (LPCTSTR)m_sFocusedImage) ) {} else return; } } if( !m_sNormalImage.IsEmpty() ) { if( IsAnimationRunning(FADE_IN_ID) || IsAnimationRunning(FADE_OUT_ID)) { if( m_bMouseHove ) { m_bMouseHove = FALSE; m_sLastImage = m_sHotImage; if( !DrawImage(hDC, (LPCTSTR)m_sNormalImage) ) {} return; } if( m_bMouseLeave ) { m_bMouseLeave = FALSE; m_sLastImage = m_sNormalImage; if( !DrawImage(hDC, (LPCTSTR)m_sHotImage) ) {} return; } m_sOldImage = m_sNormalImage; m_sNewImage = m_sHotImage; if( IsAnimationRunning(FADE_OUT_ID) ) { m_sOldImage = m_sHotImage; m_sNewImage = m_sNormalImage; } CDuiString sFadeOut, sFadeIn; sFadeOut.Format(_T("fade='%d'"), 255 - m_bFadeAlpha); sFadeIn.Format(_T("fade='%d'"), m_bFadeAlpha); if( !DrawImage(hDC, (LPCTSTR)m_sOldImage, sFadeOut) ) {} if( !DrawImage(hDC, (LPCTSTR)m_sNewImage, sFadeIn) ) {} return; } else { if(m_sLastImage.IsEmpty()) m_sLastImage = m_sNormalImage; if( !DrawImage(hDC, (LPCTSTR)m_sLastImage) ) {} return; } } }
bool wxCheckBox::MSWOnDraw(WXDRAWITEMSTRUCT *item) { DRAWITEMSTRUCT *dis = (DRAWITEMSTRUCT *)item; if ( !IsOwnerDrawn() || dis->CtlType != ODT_BUTTON ) return wxCheckBoxBase::MSWOnDraw(item); // calculate the rectangles for the check mark itself and the label HDC hdc = dis->hDC; RECT& rect = dis->rcItem; RECT rectCheck, rectLabel; rectCheck.top = rectLabel.top = rect.top; rectCheck.bottom = rectLabel.bottom = rect.bottom; const int checkSize = GetBestSize().y; const int MARGIN = 3; const bool isRightAligned = HasFlag(wxALIGN_RIGHT); if ( isRightAligned ) { rectCheck.right = rect.right; rectCheck.left = rectCheck.right - checkSize; rectLabel.right = rectCheck.left - MARGIN; rectLabel.left = rect.left; } else // normal, left-aligned checkbox { rectCheck.left = rect.left; rectCheck.right = rectCheck.left + checkSize; rectLabel.left = rectCheck.right + MARGIN; rectLabel.right = rect.right; } // show we draw a focus rect? const bool isFocused = m_isPressed || FindFocus() == this; // draw the checkbox itself wxDCTemp dc(hdc); int flags = 0; if ( !IsEnabled() ) flags |= wxCONTROL_DISABLED; switch ( Get3StateValue() ) { case wxCHK_CHECKED: flags |= wxCONTROL_CHECKED; break; case wxCHK_UNDETERMINED: flags |= wxCONTROL_PRESSED; break; default: wxFAIL_MSG( wxT("unexpected Get3StateValue() return value") ); // fall through case wxCHK_UNCHECKED: // no extra styles needed break; } if ( wxFindWindowAtPoint(wxGetMousePosition()) == this ) flags |= wxCONTROL_CURRENT; wxRendererNative::Get(). DrawCheckBox(this, dc, wxRectFromRECT(rectCheck), flags); // draw the text const wxString& label = GetLabel(); // first we need to measure it UINT fmt = DT_NOCLIP; // drawing underlying doesn't look well with focus rect (and the native // control doesn't do it) if ( isFocused ) fmt |= DT_HIDEPREFIX; if ( isRightAligned ) fmt |= DT_RIGHT; // TODO: also use DT_HIDEPREFIX if the system is configured so // we need to get the label real size first if we have to draw a focus rect // around it if ( isFocused ) { if ( !::DrawText(hdc, label.wx_str(), label.length(), &rectLabel, fmt | DT_CALCRECT) ) { wxLogLastError(wxT("DrawText(DT_CALCRECT)")); } } if ( !IsEnabled() ) { ::SetTextColor(hdc, ::GetSysColor(COLOR_GRAYTEXT)); } if ( !::DrawText(hdc, label.wx_str(), label.length(), &rectLabel, fmt) ) { wxLogLastError(wxT("DrawText()")); } // finally draw the focus if ( isFocused ) { rectLabel.left--; rectLabel.right++; if ( !::DrawFocusRect(hdc, &rectLabel) ) { wxLogLastError(wxT("DrawFocusRect()")); } } return true; }
/* Called when CCP has reached the OPEN state */ static int CcpLayerUp(struct fsm *fp) { /* We're now up */ struct ccp *ccp = fsm2ccp(fp); struct ccp_opt **o; unsigned f, fail; for (f = fail = 0; f < NALGORITHMS; f++) if (IsEnabled(ccp->cfg.neg[algorithm[f]->Neg]) && (*algorithm[f]->Required)(&ccp->fsm) && (ccp->in.algorithm != (int)f || ccp->out.algorithm != (int)f)) { /* Blow it all away - we haven't negotiated a required algorithm */ log_Printf(LogWARN, "%s: Failed to negotiate (required) %s\n", fp->link->name, protoname(algorithm[f]->id)); fail = 1; } if (fail) { ccp->his_proto = ccp->my_proto = -1; fsm_Close(fp); fsm_Close(&fp->link->lcp.fsm); return 0; } log_Printf(LogCCP, "%s: LayerUp.\n", fp->link->name); if (ccp->in.state == NULL && ccp->in.algorithm >= 0 && ccp->in.algorithm < (int)NALGORITHMS) { ccp->in.state = (*algorithm[ccp->in.algorithm]->i.Init) (fp->bundle, &ccp->in.opt); if (ccp->in.state == NULL) { log_Printf(LogERROR, "%s: %s (in) initialisation failure\n", fp->link->name, protoname(ccp->his_proto)); ccp->his_proto = ccp->my_proto = -1; fsm_Close(fp); return 0; } } o = &ccp->out.opt; if (ccp->out.algorithm > 0) for (f = 0; f < (unsigned)ccp->out.algorithm; f++) if (IsEnabled(ccp->cfg.neg[algorithm[f]->Neg])) o = &(*o)->next; if (ccp->out.state == NULL && ccp->out.algorithm >= 0 && ccp->out.algorithm < (int)NALGORITHMS) { ccp->out.state = (*algorithm[ccp->out.algorithm]->o.Init) (fp->bundle, &(*o)->val); if (ccp->out.state == NULL) { log_Printf(LogERROR, "%s: %s (out) initialisation failure\n", fp->link->name, protoname(ccp->my_proto)); ccp->his_proto = ccp->my_proto = -1; fsm_Close(fp); return 0; } } fp->more.reqs = fp->more.naks = fp->more.rejs = ccp->cfg.fsm.maxreq * 3; log_Printf(LogCCP, "%s: Out = %s[%d], In = %s[%d]\n", fp->link->name, protoname(ccp->my_proto), ccp->my_proto, protoname(ccp->his_proto), ccp->his_proto); return 1; }
void Robot::OperatorControl() //teleop code { driveTrain.SetSafetyEnabled(false); bool updateThreadRun = true; //std::thread updateThread(updateThreadFunction, &updateThreadRun, &driveStick, &position); float throttle; float leftMoveValue; float rightMoveValue; float rotateValue; float distToTower; float angleToShoot; float angleToTower; bool readyToShoot = false; bool shooterPreparing = false; bool PWMTested = false; SmartDashboard::PutNumber("auto_startPos", 5); SmartDashboard::PutNumber("auto_seconds", 2.5); SmartDashboard::PutNumber("auto_speed", 0.75); SmartDashboard::PutNumber("adjustSpeed", 1.0); shooter.Enable(); driveTrain.Enable(); while (IsOperatorControl() && IsEnabled()) { throttle = (((driveStick.GetRawAxis(Constants::driveL2)) + 1.0)/4.0) + 0.5; //[1, .5] leftMoveValue = .90 * throttle * driveStick.GetRawAxis(1); rightMoveValue = -throttle * driveStick.GetRawAxis(5); if (driveStick.GetRawButton(8)) { leftMoveValue = -1 * leftMoveValue; rightMoveValue = -1 * rightMoveValue; } driveTrain.TankDrive(leftMoveValue, rightMoveValue, false); /*if (shooterPreparing) { readyToShoot = (abs(shooter.WheelSpeed() - 1.0) < 0.01) && (abs(shooter.Angle() - angleToTower) < 0.1); if (readyToShoot) { shooterPreparing = false; } } */ if (driveStick.GetRawButton(Constants::calibrateButton)) { //position.Calibrate(); } if (operatorStick.GetRawButton(Constants::prepareToShootButton)) { //angleToTower = position.AngleToTower(); //driveTrain.TurnToAngle(angleToTower); //Wait(2.0); angleToTower = aimer.GetAngleToTower(); driveTrain.TurnToRelativeAngle(angleToTower); } if (operatorStick.GetRawButton(Constants::shootButton)) { if (readyToShoot) { readyToShoot = false; shooter.Shoot(); } } if (operatorStick.GetRawButton(5)) { //angleToTower = aimer.GetAngleToTower(); //driveTrain.TurnToAngle(angleToTower); angleToShoot = aimer.GetAngleToShoot(); shooter.SetAngle(angleToShoot); } if (operatorStick.GetRawButton(Constants::xButton)) { shooter.Shoot(); } float shooterAngleInput = -operatorStick.GetRawAxis(1); shooterAngleInput = abs(shooterAngleInput) > 0.005 ? shooterAngleInput : 0.0; shooter.Move(shooterAngleInput); if (operatorStick.GetRawButton(Constants::stopShooterWheels)) { shooter.SetSpeed(0); } if (operatorStick.GetPOV() == 0) { shooter.SetSpeed(1); } if (operatorStick.GetPOV() == 270) { shooter.SetSpeed(.5); } if (operatorStick.GetPOV() == 180) { shooter.LoadBall(); } if (operatorStick.GetPOV() == 90) { shooter.SetSpeed(.75); } if (operatorStick.GetRawButton(Constants::ejectButton)) { shooter.SetSpeed(.5); Wait(.5); shooter.Shoot(); Wait(.5); shooter.SetSpeed(0); } /*if (operatorStick.GetRawButton(5)) { shooter.SetAngle(20); } if (operatorStick.GetRawButton(6)) { shooter.SetAngle(50); }*/ /*if (operatorStick.GetRawButton(3)) { driveTrain.TurnToAngle(40); std::cout << "Button Pressed"; } if (operatorStick.GetRawButton(4)) { driveTrain.TurnToRelativeAngle(30); }*/ SmartDashboard::PutNumber("Pot Value", shooter.ReadPot()); SmartDashboard::PutNumber("getPOV", operatorStick.GetPOV()); SmartDashboard::PutString("Version", "1.1"); SmartDashboard::PutBoolean("Has Ball", shooter.HasBall()); SmartDashboard::PutBoolean("Target Acquired", aimer.GetAge() < 3); SmartDashboard::PutBoolean("Aimed", abs(aimer.GetAngleToTower()) < 3.0); SmartDashboard::PutBoolean("Angled", abs(shooter.Angle() - aimer.GetAngleToShoot()) < 5.0); SmartDashboard::PutNumber("Shooter Angle", shooter.Angle()); SmartDashboard::PutNumber("Recommended Shooter Angle", aimer.GetAngleToShoot()); SmartDashboard::PutNumber("Angle to Tower", aimer.GetAngleToTower()); SmartDashboard::PutNumber("Rotation", position.GetAngleDegrees()); SmartDashboard::PutBoolean("Close Enough to Shoot", aimer.GetAngleToShoot() < 48 && aimer.GetAngleToShoot() > 32); } shooter.Disable(); driveTrain.Disable(); updateThreadRun = false; //updateThread.join(); driveTrain.SetSafetyEnabled(true); }
//----------------------------------------------------------------------- void CVehiclePartLight::Update(const float frameTime) { if (IsEnabled()) UpdateLight(frameTime); }
// CONSIDER: if player in water state, autoset and underwater soundscape? void CEnvSoundscape::UpdateForPlayer( ss_update_t &update ) { if ( !IsEnabled() ) { if ( update.pCurrentSoundscape == this ) { update.pCurrentSoundscape = NULL; update.currentDistance = 0; update.bInRange = false; } return; } // calc range from sound entity to player Vector target = EarPosition(); float range = (update.playerPosition - target).Length(); if ( update.pCurrentSoundscape == this ) { update.currentDistance = range; update.bInRange = false; if ( m_flRadius > range || m_flRadius == -1 ) { trace_t tr; update.traceCount++; UTIL_TraceLine( target, update.playerPosition, MASK_SOLID_BRUSHONLY|MASK_WATER, update.pPlayer, COLLISION_GROUP_NONE, &tr ); if ( tr.fraction == 1 && !tr.startsolid ) { update.bInRange = true; } } } else { if ( (!update.bInRange || range < update.currentDistance ) && (m_flRadius > range || m_flRadius == -1) ) { trace_t tr; update.traceCount++; UTIL_TraceLine( target, update.playerPosition, MASK_SOLID_BRUSHONLY|MASK_WATER, update.pPlayer, COLLISION_GROUP_NONE, &tr ); if ( tr.fraction == 1 && !tr.startsolid ) { audioparams_t &audio = update.pPlayer->GetAudioParams(); WriteAudioParamsTo( audio ); update.pCurrentSoundscape = this; update.bInRange = true; update.currentDistance = range; } } } if ( soundscape_debug.GetBool() ) { // draw myself NDebugOverlay::Box(GetAbsOrigin(), Vector(-10,-10,-10), Vector(10,10,10), 255, 0, 255, 64, NDEBUG_PERSIST_TILL_NEXT_SERVER ); if ( update.pPlayer ) { audioparams_t &audio = update.pPlayer->GetAudioParams(); if ( audio.ent.Get() != this ) { if ( InRangeOfPlayer( update.pPlayer ) ) { NDebugOverlay::Line( GetAbsOrigin(), update.pPlayer->WorldSpaceCenter(), 255, 255, 255, true, NDEBUG_PERSIST_TILL_NEXT_SERVER ); } else { NDebugOverlay::Line( GetAbsOrigin(), update.pPlayer->WorldSpaceCenter(), 255, 0, 0, true, NDEBUG_PERSIST_TILL_NEXT_SERVER ); } } else { if ( InRangeOfPlayer( update.pPlayer ) ) { NDebugOverlay::Line( GetAbsOrigin(), update.pPlayer->WorldSpaceCenter(), 0, 255, 0, true, NDEBUG_PERSIST_TILL_NEXT_SERVER ); } else { NDebugOverlay::Line( GetAbsOrigin(), update.pPlayer->WorldSpaceCenter(), 255, 170, 0, true, NDEBUG_PERSIST_TILL_NEXT_SERVER ); } // also draw lines to each sound position. // we don't store the number of local sound positions, just a bitvector of which ones are on. unsigned int soundbits = audio.localBits.Get(); float periodic = 2.0f * sin((fmod(gpGlobals->curtime,2.0f) - 1.0f) * M_PI); // = -4f .. 4f for (int ii = 0 ; ii < NUM_AUDIO_LOCAL_SOUNDS ; ++ii ) { if ( soundbits & (1 << ii) ) { const Vector &soundLoc = audio.localSound.Get(ii); NDebugOverlay::Line( GetAbsOrigin(), soundLoc, 0, 32 , 255 , false, NDEBUG_PERSIST_TILL_NEXT_SERVER ); NDebugOverlay::Cross3D( soundLoc, 16.0f + periodic, 0, 0, 255, false, NDEBUG_PERSIST_TILL_NEXT_SERVER ); } } } } NDebugOverlay::EntityTextAtPosition( GetAbsOrigin(), 0, STRING(m_soundscapeName), NDEBUG_PERSIST_TILL_NEXT_SERVER ); } }
void _HYPullDown::Deactivate (void) { _HYComponent::Deactivate(); if (IsEnabled()) _MarkForUpdate(); }
UINT CEditUI::GetControlFlags() const { if( !IsEnabled() ) return CControlUI::GetControlFlags(); return UIFLAG_SETCURSOR | UIFLAG_TABSTOP; }
void CTextUI::DoEvent(TEventUI& event) { if( !IsMouseEnabled() && event.Type > UIEVENT__MOUSEBEGIN && event.Type < UIEVENT__MOUSEEND ) { if( m_pParent != NULL ) m_pParent->DoEvent(event); else CLabelUI::DoEvent(event); return; } if( event.Type == UIEVENT_SETCURSOR ) { for( int i = 0; i < m_nLinks; i++ ) { if( ::PtInRect(&m_rcLinks[i], event.ptMouse) ) { ::SetCursor(::LoadCursor(NULL, MAKEINTRESOURCE(IDC_HAND))); return; } } } if( event.Type == UIEVENT_BUTTONDOWN || event.Type == UIEVENT_DBLCLICK && IsEnabled() ) { for( int i = 0; i < m_nLinks; i++ ) { if( ::PtInRect(&m_rcLinks[i], event.ptMouse) ) { Invalidate(); return; } } } if( event.Type == UIEVENT_BUTTONUP && IsEnabled() ) { for( int i = 0; i < m_nLinks; i++ ) { if( ::PtInRect(&m_rcLinks[i], event.ptMouse) ) { m_pManager->SendNotify(this, DUI_MSGTYPE_LINK, i); return; } } } if( event.Type == UIEVENT_CONTEXTMENU ) { return; } // When you move over a link if( m_nLinks > 0 && event.Type == UIEVENT_MOUSEMOVE && IsEnabled() ) { int nHoverLink = -1; for( int i = 0; i < m_nLinks; i++ ) { if( ::PtInRect(&m_rcLinks[i], event.ptMouse) ) { nHoverLink = i; break; } } if(m_nHoverLink != nHoverLink) { m_nHoverLink = nHoverLink; Invalidate(); return; } } if( event.Type == UIEVENT_MOUSELEAVE ) { if( m_nLinks > 0 && IsEnabled() ) { if(m_nHoverLink != -1) { m_nHoverLink = -1; Invalidate(); return; } } } CLabelUI::DoEvent(event); }
void CEditUI::DoEvent(TEventUI& event) { if( !IsMouseEnabled() && event.Type > UIEVENT__MOUSEBEGIN && event.Type < UIEVENT__MOUSEEND ) { if( m_pParent != NULL ) m_pParent->DoEvent(event); else CLabelUI::DoEvent(event); return; } if( event.Type == UIEVENT_SETCURSOR && IsEnabled() ) { ::SetCursor(::LoadCursor(NULL, IDC_IBEAM)); return; } if( event.Type == UIEVENT_WINDOWSIZE ) { if( m_pWindow != NULL ) m_pManager->SetFocusNeeded(this); } if( event.Type == UIEVENT_SCROLLWHEEL ) { if( m_pWindow != NULL ) return; } if( event.Type == UIEVENT_SETFOCUS && IsEnabled() ) { if( m_pWindow ) return; m_pWindow = new CEditWnd(); ASSERT(m_pWindow); m_pWindow->Init(this); Invalidate(); } if( event.Type == UIEVENT_KILLFOCUS && IsEnabled() ) { Invalidate(); } if( event.Type == UIEVENT_BUTTONDOWN || event.Type == UIEVENT_DBLCLICK || event.Type == UIEVENT_RBUTTONDOWN) { if( IsEnabled() ) { GetManager()->ReleaseCapture(); if( IsFocused() && m_pWindow == NULL ) { m_pWindow = new CEditWnd(); ASSERT(m_pWindow); m_pWindow->Init(this); if( PtInRect(&m_rcItem, event.ptMouse) ) { int nSize = GetWindowTextLength(*m_pWindow); if( nSize == 0 ) nSize = 1; Edit_SetSel(*m_pWindow, 0, nSize); } } else if( m_pWindow != NULL ) { #if 1 int nSize = GetWindowTextLength(*m_pWindow); if( nSize == 0 ) nSize = 1; Edit_SetSel(*m_pWindow, 0, nSize); #else POINT pt = event.ptMouse; pt.x -= m_rcItem.left + m_rcTextPadding.left; pt.y -= m_rcItem.top + m_rcTextPadding.top; ::SendMessage(*m_pWindow, WM_LBUTTONDOWN, event.wParam, MAKELPARAM(pt.x, pt.y)); #endif } } return; } if( event.Type == UIEVENT_MOUSEMOVE ) { return; } if( event.Type == UIEVENT_BUTTONUP ) { return; } if( event.Type == UIEVENT_CONTEXTMENU ) { return; } if( event.Type == UIEVENT_MOUSEENTER ) { if( IsEnabled() ) { m_uButtonState |= UISTATE_HOT; Invalidate(); } return; } if( event.Type == UIEVENT_MOUSELEAVE ) { if( IsEnabled() ) { m_uButtonState &= ~UISTATE_HOT; Invalidate(); } return; } CLabelUI::DoEvent(event); }
UINT CHorizontalLayoutUI::GetControlFlags() const { if( IsEnabled() && m_iSepWidth != 0 ) return UIFLAG_SETCURSOR; else return 0; }
bool DriverStation::IsDisabled() { return !IsEnabled(); }
void CSliderUI::DoEvent(TEventUI& event) { if( !IsMouseEnabled() && event.Type > UIEVENT__MOUSEBEGIN && event.Type < UIEVENT__MOUSEEND ) { if( m_pParent != NULL ) m_pParent->DoEvent(event); else CProgressUI::DoEvent(event); return; } if( event.Type == UIEVENT_BUTTONDOWN || event.Type == UIEVENT_DBLCLICK ) { if( IsEnabled() ) { RECT rcThumb = GetThumbRect(); if( ::PtInRect(&rcThumb, event.ptMouse) ) { m_uButtonState |= UISTATE_CAPTURED; } } return; } if( event.Type == UIEVENT_BUTTONUP ) { if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) { m_uButtonState &= ~UISTATE_CAPTURED; } if( m_bHorizontal ) { if( event.ptMouse.x >= m_rcItem.right - m_szThumb.cx / 2 ) m_nValue = m_nMax; else if( event.ptMouse.x <= m_rcItem.left + m_szThumb.cx / 2 ) m_nValue = m_nMin; else m_nValue = m_nMin + (m_nMax - m_nMin) * (event.ptMouse.x - m_rcItem.left - m_szThumb.cx / 2 ) / (m_rcItem.right - m_rcItem.left - m_szThumb.cx); } else { if( event.ptMouse.y >= m_rcItem.bottom - m_szThumb.cy / 2 ) m_nValue = m_nMin; else if( event.ptMouse.y <= m_rcItem.top + m_szThumb.cy / 2 ) m_nValue = m_nMax; else m_nValue = m_nMin + (m_nMax - m_nMin) * (m_rcItem.bottom - event.ptMouse.y - m_szThumb.cy / 2 ) / (m_rcItem.bottom - m_rcItem.top - m_szThumb.cy); } m_pManager->SendNotify(this, DUI_MSGTYPE_VALUECHANGED); Invalidate(); return; } if( event.Type == UIEVENT_CONTEXTMENU ) { return; } if( event.Type == UIEVENT_SCROLLWHEEL ) { switch( LOWORD(event.wParam) ) { case SB_LINEUP: SetValue(GetValue() + GetChangeStep()); m_pManager->SendNotify(this, DUI_MSGTYPE_VALUECHANGED); return; case SB_LINEDOWN: SetValue(GetValue() - GetChangeStep()); m_pManager->SendNotify(this, DUI_MSGTYPE_VALUECHANGED); return; } } if( event.Type == UIEVENT_MOUSEMOVE ) { if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) { if( m_bHorizontal ) { if( event.ptMouse.x >= m_rcItem.right - m_szThumb.cx / 2 ) m_nValue = m_nMax; else if( event.ptMouse.x <= m_rcItem.left + m_szThumb.cx / 2 ) m_nValue = m_nMin; else m_nValue = m_nMin + (m_nMax - m_nMin) * (event.ptMouse.x - m_rcItem.left - m_szThumb.cx / 2 ) / (m_rcItem.right - m_rcItem.left - m_szThumb.cx); } else { if( event.ptMouse.y >= m_rcItem.bottom - m_szThumb.cy / 2 ) m_nValue = m_nMin; else if( event.ptMouse.y <= m_rcItem.top + m_szThumb.cy / 2 ) m_nValue = m_nMax; else m_nValue = m_nMin + (m_nMax - m_nMin) * (m_rcItem.bottom - event.ptMouse.y - m_szThumb.cy / 2 ) / (m_rcItem.bottom - m_rcItem.top - m_szThumb.cy); } Invalidate(); } return; } if( event.Type == UIEVENT_SETCURSOR ) { RECT rcThumb = GetThumbRect(); if( IsEnabled() && ::PtInRect(&rcThumb, event.ptMouse) ) { ::SetCursor(::LoadCursor(NULL, MAKEINTRESOURCE(IDC_HAND))); return; } } if( event.Type == UIEVENT_MOUSEENTER ) { if( IsEnabled() ) { m_uButtonState |= UISTATE_HOT; Invalidate(); } return; } if( event.Type == UIEVENT_MOUSELEAVE ) { if( IsEnabled() ) { m_uButtonState &= ~UISTATE_HOT; Invalidate(); } return; } CControlUI::DoEvent(event); }
UINT CVerticalLayoutUI::GetControlFlags() const { if( IsEnabled() && m_iSepHeight != 0 ) return UIFLAG_SETCURSOR; else return 0; }