Beispiel #1
0
bool DropDownPopup::ProcessLeftDown( wxMouseEvent &event )
{
    m_mouse = event.GetPosition();
    //wxPrintf(wxT("DropDownPopup::ProcessLeftDown %d %d\n"), m_mouse.x, m_mouse.y); fflush(stdout);

    if (m_popped_handler) return true; // shouldn't ever get here, but just in case

    StopTimer();

    // don't let the click on the dropdown button actually press it
    wxCustomButton *dropBut = m_owner->GetDropDownButton();
    if (dropBut)
    {
        wxPoint dropMousePt = dropBut->ScreenToClient(ClientToScreen(m_mouse));
        if (dropBut->HitTest(dropMousePt) == wxHT_WINDOW_INSIDE)
        {
            m_ignore_popup = true;
            Dismiss();
            return true;
        }
    }

    if (GetClientRect().Contains(m_mouse))
        return false;

    Dismiss();
    return true;
}
Beispiel #2
0
void Pet::Update(uint32 time)
{
    Creature::Update(time); // passthrough

    if(bHasLoyalty)
    {
        if(m_LoyaltyTimer == 0)
        {
            // Update loyalty.....
            uint32 val = GetUInt32Value(UNIT_FIELD_POWER5);
            if(PET_LOYALTY_UPDATE_VALUE > val)
                val = 0;
            else
                val -= PET_LOYALTY_UPDATE_VALUE;
            
            // Set the value
            SetUInt32Value(UNIT_FIELD_POWER5, val);

            if(val <= 0)
            {
                Dismiss();
                return;
            }

            // reset timer
            m_LoyaltyTimer = PET_LOYALTY_UPDATE_TIMER;
        } else {
            if(time > m_LoyaltyTimer)
                m_LoyaltyTimer = 0;
            else
                m_LoyaltyTimer -= time;
        }
    }

    if(bExpires)
    {
        if(m_ExpireTime == 0)
        {
            // remove
            Dismiss(false);
            return;
        } else {
            if(time > m_ExpireTime)
            {
                m_ExpireTime = 0;
            } else {
                m_ExpireTime -= time;
            }
        }
    }
}
void ContentAssistantPopup::UpdateResults()
{
  wxString partial = m_editor->GetSelectionString();
  m_completions = m_autocomplete->CompleteSymbol(partial, m_type);
  m_completions.Sort();

  switch(m_completions.GetCount())
  {
  case 1:
    m_editor->ReplaceSelection(
      m_editor->GetSelectionString(),
      m_completions[0]
      );
  case 0:
    m_editor->ClearSelection();
    this->GetParent()->GetParent()->Refresh();
    if(!m_editor->IsActive())
      m_editor->ActivateCell();
    Dismiss();
    break;
  default:
    m_autocompletions->Set(m_completions);
    m_autocompletions->SetSelection(0);    
  }
}
Beispiel #4
0
void HSWDisplay::Enable(bool enable)
{
    Enabled = enable;

    if(!enable && Displayed) // If it's visible but should not be...
        Dismiss();
}
void wxTreeViewComboPopup::OnMouseClick(wxMouseEvent& event)
{
    m_bClicked = true;
    wxTreeItemId ItemId = GetSelection();
	if(ItemId.IsOk())
    {
        if(m_PrewItemId.IsOk())
        {
            CollapseAllChildren(GetItemParent(m_PrewItemId));
        }
        if(ItemId != GetRootItem())
        {
            CollapseAllChildren(ItemId);
        }
        else
        {
            CollapseAll();
            Expand(GetRootItem());
        }

	    wxGxTreeItemData* pData = (wxGxTreeItemData*)GetItemData(ItemId);
	    if(pData != NULL)
	    {
            SelectItem(ItemId);
		    m_pSelection->Select(pData->m_nObjectID, false, GetId());
            m_PrewItemId = ItemId;
	    }
    }
    Dismiss();

    event.Skip(true);
}
long TabStops :: PushButtonCommand(wCommandMsg m)
{
	if (m.usCmd() == TAB_OK)
	{
		ushort tmp = (ushort)spin->GetValue();
		if (tmp > 200)
			tmp = 200;
		if (tmp < 1)
			tmp = 1;
		Dismiss(tmp);
	}
	if (m.usCmd() == TAB_CANCEL)
		Dismiss(0);

	return FALSE;
}
Status MigrationSourceManager::startClone(OperationContext* txn) {
    invariant(!txn->lockState()->isLocked());
    invariant(_state == kCreated);
    auto scopedGuard = MakeGuard([&] { cleanupOnError(txn); });

    grid.catalogClient(txn)->logChange(txn,
                                       "moveChunk.start",
                                       _args.getNss().ns(),
                                       BSON("min" << _args.getMinKey() << "max" << _args.getMaxKey()
                                                  << "from"
                                                  << _args.getFromShardId()
                                                  << "to"
                                                  << _args.getToShardId()));

    _cloneDriver = stdx::make_unique<MigrationChunkClonerSourceLegacy>(
        _args, _committedMetadata->getKeyPattern());

    {
        // Register for notifications from the replication subsystem
        ScopedTransaction scopedXact(txn, MODE_IX);
        AutoGetCollection autoColl(txn, _args.getNss(), MODE_IX, MODE_X);

        auto css = CollectionShardingState::get(txn, _args.getNss().ns());
        css->setMigrationSourceManager(txn, this);
    }

    Status startCloneStatus = _cloneDriver->startClone(txn);
    if (!startCloneStatus.isOK()) {
        return startCloneStatus;
    }

    _state = kCloning;
    scopedGuard.Dismiss();
    return Status::OK();
}
Beispiel #8
0
void wxVListBoxComboPopup::OnKey(wxKeyEvent& event)
{
    // Hide popup if certain key or key combination was pressed
    if ( m_combo->IsKeyPopupToggle(event) )
    {
        StopPartialCompletion();
        Dismiss();
    }
    else if ( event.AltDown() )
    {
        // On both wxGTK and wxMSW, pressing Alt down seems to
        // completely freeze things in popup (ie. arrow keys and
        // enter won't work).
        return;
    }
    // Select item if ENTER is pressed
    else if ( event.GetKeyCode() == WXK_RETURN || event.GetKeyCode() == WXK_NUMPAD_ENTER )
    {
        DismissWithEvent();
    }
    else
    {
        int comboStyle = m_combo->GetWindowStyle();
        int keycode = event.GetKeyCode();
        // Process partial completion key codes here, but not the arrow keys as the base class will do that for us
        if ((comboStyle & wxCB_READONLY) &&
            (keycode >= WXK_SPACE) && (keycode <=255) && (keycode != WXK_DELETE) && wxIsprint(keycode))
        {
            OnComboKeyEvent(event);
            SetSelection(m_value); // ensure the highlight bar moves
        }
        else
            event.Skip();
    }
}
Beispiel #9
0
/*
void MerryFrame::OnActivateEvent(wxActivateEvent& e)
{
#ifndef DEBUG_ALWAYS_SHOW
	if (!e.GetActive() && !this->IsShownOnScreen())
		this->Hide();
#endif
}
*/
void MerryFrame::OnShowEvent(wxShowEvent& e)
{
	MerryTextCtrl* textCtrl = m_mainPanel->GetTextCtrl();
	assert(textCtrl);
	if (e.IsShown())
	{
		if (g_config->get(PlayPopupNotify))//ÊÇ·ñ²¥·ÅÌáʾÒô
			wxSound("Popup.wav").Play();
		textCtrl->ChangeValue(wxT(""));
		this->CentreOnce();
		m_listBoxPanel->Dismiss();
		this->Raise();
		g_controller->SetWindowPos(this->GetHWND(),HWND_TOPMOST,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE);
		ActiveWindow(this->GetHWND());
//		textCtrl->SetFocus();
#ifdef __WXMSW__
		textCtrl->SetEnInputMode();
#endif
		if (g_config->get(AutoPopup))
			textCtrl->AppendText(wxT(""));
	}
	else
		textCtrl->ChangeValue(wxT(""));

	textCtrl->EnterArgs = 0;
}
    // static
    std::shared_ptr<CanvasImageSourceDrawingSessionAdapter> CanvasImageSourceDrawingSessionAdapter::Create(
        ISurfaceImageSourceNativeWithD2D* sisNative,
        const RECT& updateRect,
        float dpi,
        ID2D1DeviceContext1** outDeviceContext)
    {
        //
        // ISurfaceImageSourceNativeWithD2D needs exactly the right IID passed
        // in, so we first ask for a ID2D1DeviceContext and we'll then take the
        // resulting interface and QI for ID2D1DeviceContext1.
        //
        ComPtr<ID2D1DeviceContext> deviceContext;
        POINT offset;
        ThrowIfFailed(sisNative->BeginDraw(
            updateRect,
            IID_PPV_ARGS(&deviceContext),
            &offset));

        //
        // If this function fails then we need to call EndDraw
        //
        auto endDrawWarden = MakeScopeWarden([&] { sisNative->EndDraw(); });

        ThrowIfFailed(deviceContext.CopyTo(outDeviceContext));

        //
        // ISurfaceImageSourceNativeWithD2D is operating in batched mode.  This
        // means that BeginDraw() has returned a device context set up to render
        // to an atlased surface (ie a surface containing multiple images).  The
        // image that we wish to render to appears at some offset in this
        // surface -- and this is what has been given to us in offset.  This
        // call sets the transform on the device context to compensate for this,
        // so when we ask to render to (0,0) we actually render to the
        // appropriate location in the atlased surface.
        //
        const D2D1_POINT_2F renderingSurfaceOffset = D2D1::Point2F(
            static_cast<float>(offset.x),
            static_cast<float>(offset.y));       

        auto adapter = std::make_shared<CanvasImageSourceDrawingSessionAdapter>(
            sisNative,
            renderingSurfaceOffset);

        //
        // TODO #2140 Use a separate code path, responsible for resetting  
        // transforms for non-SiS drawing sessions.
        //
        deviceContext->SetTransform(D2D1::Matrix3x2F::Translation(
            renderingSurfaceOffset.x,
            renderingSurfaceOffset.y));

        deviceContext->SetDpi(dpi, dpi);

        //
        // This function can't fail now, so we can dismiss the end draw warden.
        //
        endDrawWarden.Dismiss();

        return adapter;
    }
Beispiel #11
0
void CDlgOldNewsPost::OnClose( )
	{
	if ( IDYES != m_pServerDialog->DisplayMessageBox( "Cancel post ?", MB_YESNO | MB_ICONQUESTION ) )
		return;

	Dismiss( );
	}
Beispiel #12
0
void wxVListBoxComboPopup::OnKey(wxKeyEvent& event)
{
    // Hide popup if certain key or key combination was pressed
    if ( m_combo->IsKeyPopupToggle(event) )
    {
        StopPartialCompletion();
        Dismiss();
    }
    else if ( event.AltDown() )
    {
        // On both wxGTK and wxMSW, pressing Alt down seems to
        // completely freeze things in popup (ie. arrow keys and
        // enter won't work).
        return;
    }
    // Select item if ENTER is pressed
    else if ( event.GetKeyCode() == WXK_RETURN || event.GetKeyCode() == WXK_NUMPAD_ENTER )
    {
        DismissWithEvent();
    }
    else
    {
        // completion is handled in OnChar() below
        event.Skip();
    }
}
Beispiel #13
0
void wxInfoBar::GTKResponse(int btnid)
{
    wxCommandEvent event(wxEVT_BUTTON, btnid);
    event.SetEventObject(this);

    if ( !HandleWindowEvent(event) )
        Dismiss();
}
Beispiel #14
0
//##ModelId=526529FC0399
void ListViewTab::RedrawWithOrder(List<Uint32> order)
{
    if (curSpecialIndex != -1)
        HideSpecialButton();
    sortOrder = order;
    Dismiss();
    Display();
}
Beispiel #15
0
void CDlgFiles::OnClose( )
	{
	m_RemoteList.SetImageList( NULL, LVSIL_SMALL );
	m_LocalList.SetImageList( NULL, LVSIL_SMALL );
	m_pServerDialog->m_pFiles = NULL;
	m_pServerDialog->m_bFileRequestSent = false;
	Dismiss( );
	}
Status MigrationChunkClonerSourceLegacy::startClone(OperationContext* txn) {
    invariant(!txn->lockState()->isLocked());
    auto scopedGuard = MakeGuard([&] { cancelClone(txn); });

    // Resolve the donor and recipient shards and their connection string

    {
        auto donorShardStatus = grid.shardRegistry()->getShard(txn, _args.getFromShardId());
        if (!donorShardStatus.isOK()) {
            return donorShardStatus.getStatus();
        }
        _donorCS = donorShardStatus.getValue()->getConnString();
    }

    {
        auto recipientShardStatus = grid.shardRegistry()->getShard(txn, _args.getToShardId());
        if (!recipientShardStatus.isOK()) {
            return recipientShardStatus.getStatus();
        }
        auto recipientShard = recipientShardStatus.getValue();

        auto shardHostStatus = recipientShard->getTargeter()->findHost(
            ReadPreferenceSetting{ReadPreference::PrimaryOnly});
        if (!shardHostStatus.isOK()) {
            return shardHostStatus.getStatus();
        }

        _recipientHost = std::move(shardHostStatus.getValue());
    }

    // Prepare the currently available documents
    Status status = _storeCurrentLocs(txn);
    if (!status.isOK()) {
        return status;
    }

    // Tell the recipient shard to start cloning
    BSONObjBuilder cmdBuilder;
    StartChunkCloneRequest::appendAsCommand(&cmdBuilder,
                                            _args.getNss(),
                                            _sessionId,
                                            _args.getConfigServerCS(),
                                            _donorCS,
                                            _args.getFromShardId(),
                                            _args.getToShardId(),
                                            _args.getMinKey(),
                                            _args.getMaxKey(),
                                            _shardKeyPattern.toBSON(),
                                            _args.getSecondaryThrottle());

    auto responseStatus = _callRecipient(cmdBuilder.obj());
    if (!responseStatus.isOK()) {
        return responseStatus.getStatus();
    }

    scopedGuard.Dismiss();
    return Status::OK();
}
Beispiel #17
0
void Vehicle::Update(uint32 diff)
{
    Creature::Update(diff);
    if(despawn)
    {
        m_spawnduration -= diff;
        if(m_spawnduration < 0)
            Dismiss();
        despawn = false;
    }
}
Beispiel #18
0
void Vehicle::setDeathState(DeathState s)                       // overwrite virtual Creature::setDeathState and Unit::setDeathState
{
    Creature::setDeathState(s);
    if(s == JUST_DIED)
    {
        if(GetVehicleFlags() & VF_DESPAWN_NPC)
            Dismiss();
        else
            RemoveAllPassengers();
    }
}
Beispiel #19
0
// On mouse left, set the value and close the popup
void wxRichTextStyleComboPopup::OnMouseClick(wxMouseEvent& WXUNUSED(event))
{
    if (m_itemHere >= 0)
        m_value = m_itemHere;

    // Ordering is important, so we don't dismiss this popup accidentally
    // by setting the focus elsewhere e.g. in ApplyStyle
    Dismiss();

    if (m_itemHere >= 0)
        wxRichTextStyleListBox::ApplyStyle(m_itemHere);
}
Beispiel #20
0
 // On mouse left, set the value and close the popup
 void OnMouseClick(wxMouseEvent& event)
 {
     int resFlags;
     wxTreeItemId itemHere = HitTest(event.GetPosition(),resFlags);
     if ( itemHere.IsOk() && (resFlags & wxTREE_HITTEST_ONITEMLABEL) )
     {
         m_itemHere = itemHere;
         m_value = itemHere;
         Dismiss();
         // TODO: Send event
     }
     event.Skip();
 }
Beispiel #21
0
void Pet::DelayedRemove(bool bTime, bool bDeath)
{
    m_Owner = World::GetPlayer(m_OwnerGuid);
    if(bTime)
    {
        if(GetUInt32Value(UNIT_CREATED_BY_SPELL) > 0 || bDeath)
            Dismiss(true);  // remove us..
        else
            Remove(true, true);
    }
    else
        sEventMgr.AddEvent(this, &Pet::DelayedRemove, true, bDeath, EVENT_PET_DELAYED_REMOVE, PET_DELAYED_REMOVAL_TIME, 1);
}
Beispiel #22
0
void CDlgOldNewsPost::OnSend( )
	{
	UpdateData( );

	if ( m_sNewsPost.IsEmpty( ) )
		{
		m_pServerDialog->DisplayMessageBox( "Empty post !", MB_OK | MB_ICONSTOP );
		return;
		}
	ConvertStringToHL( m_sNewsPost );
	m_pServerDialog->GetConnection( )->PostOldNews( m_sNewsPost );

	Dismiss( );
	}
Beispiel #23
0
void WiredTigerSnapshotManager::beginTransactionOnLocalSnapshot(WT_SESSION* session,
                                                                bool ignorePrepare) const {
    invariantWTOK(
        session->begin_transaction(session, (ignorePrepare) ? "ignore_prepare=true" : nullptr));
    auto rollbacker =
        MakeGuard([&] { invariant(session->rollback_transaction(session, nullptr) == 0); });

    stdx::lock_guard<stdx::mutex> lock(_localSnapshotMutex);
    invariant(_localSnapshot);

    LOG(3) << "begin_transaction on local snapshot " << _localSnapshot.get().toString();
    auto status = setTransactionReadTimestamp(_localSnapshot.get(), session);
    fassert(50775, status);
    rollbacker.Dismiss();
}
Beispiel #24
0
Timestamp WiredTigerSnapshotManager::beginTransactionOnCommittedSnapshot(
    WT_SESSION* session) const {
    invariantWTOK(session->begin_transaction(session, nullptr));
    auto rollbacker =
        MakeGuard([&] { invariant(session->rollback_transaction(session, nullptr) == 0); });

    stdx::lock_guard<stdx::mutex> lock(_committedSnapshotMutex);
    uassert(ErrorCodes::ReadConcernMajorityNotAvailableYet,
            "Committed view disappeared while running operation",
            _committedSnapshot);

    auto status = setTransactionReadTimestamp(_committedSnapshot.get(), session);
    fassert(30635, status);
    rollbacker.Dismiss();
    return *_committedSnapshot;
}
Status MigrationSourceManager::awaitToCatchUp(OperationContext* txn) {
    invariant(!txn->lockState()->isLocked());
    invariant(_state == kCloning);
    auto scopedGuard = MakeGuard([&] { cleanupOnError(txn); });

    // Block until the cloner deems it appropriate to enter the critical section.
    Status catchUpStatus = _cloneDriver->awaitUntilCriticalSectionIsAppropriate(
        txn, kMaxWaitToEnterCriticalSectionTimeout);
    if (!catchUpStatus.isOK()) {
        return catchUpStatus;
    }

    _state = kCloneCaughtUp;
    scopedGuard.Dismiss();
    return Status::OK();
}
Beispiel #26
0
void WiredTigerSnapshotManager::beginTransactionOnOplog(WiredTigerOplogManager* oplogManager,
                                                        WT_SESSION* session) const {
    invariantWTOK(session->begin_transaction(session, nullptr));
    auto rollbacker =
        MakeGuard([&] { invariant(session->rollback_transaction(session, nullptr) == 0); });

    auto allCommittedTimestamp = oplogManager->getOplogReadTimestamp();
    invariant(Timestamp(static_cast<unsigned long long>(allCommittedTimestamp)).asULL() ==
              allCommittedTimestamp);
    auto status = setTransactionReadTimestamp(
        Timestamp(static_cast<unsigned long long>(allCommittedTimestamp)),
        session,
        true /* roundToOldest */);

    fassert(50771, status);
    rollbacker.Dismiss();
}
Beispiel #27
0
        static std::shared_ptr<CanvasSwapChainDrawingSessionAdapter> Create(
            ICanvasDevice* owner,
            IDXGISwapChain1* swapChainResource,
            D2D1_COLOR_F const& clearColor,
            float dpi,
            ID2D1DeviceContext1** outDeviceContext)
        {
            auto deviceContext = As<ICanvasDeviceInternal>(owner)->CreateDeviceContextForDrawingSession();

            DXGI_SWAP_CHAIN_DESC1 swapChainDescription;
            ThrowIfFailed(swapChainResource->GetDesc1(&swapChainDescription));

            ComPtr<IDXGISurface2> backBufferSurface;
            ThrowIfFailed(swapChainResource->GetBuffer(0, IID_PPV_ARGS(&backBufferSurface)));

            ComPtr<ID2D1Bitmap1> d2dTargetBitmap;
            D2D1_BITMAP_PROPERTIES1 bitmapProperties = D2D1::BitmapProperties1();
            bitmapProperties.bitmapOptions = D2D1_BITMAP_OPTIONS_TARGET | D2D1_BITMAP_OPTIONS_CANNOT_DRAW;
            bitmapProperties.pixelFormat.format = swapChainDescription.Format;
            bitmapProperties.pixelFormat.alphaMode = ConvertDxgiAlphaModeToD2DAlphaMode(swapChainDescription.AlphaMode);
            ThrowIfFailed(deviceContext->CreateBitmapFromDxgiSurface(backBufferSurface.Get(), &bitmapProperties, &d2dTargetBitmap));

            deviceContext->SetTarget(d2dTargetBitmap.Get());

            deviceContext->BeginDraw();

            //
            // If this function fails then we need to call EndDraw
            //
            auto endDrawWarden = MakeScopeWarden([&] { ThrowIfFailed(deviceContext->EndDraw()); });

            ThrowIfFailed(deviceContext.CopyTo(outDeviceContext));

            auto adapter = std::make_shared<CanvasSwapChainDrawingSessionAdapter>();

            deviceContext->Clear(&clearColor);

            deviceContext->SetDpi(dpi, dpi);

            //
            // This function can't fail now, so we can dismiss the end draw warden.
            //
            endDrawWarden.Dismiss();

            return adapter;
        }
Beispiel #28
0
void wxVListBoxComboPopup::DismissWithEvent()
{
    StopPartialCompletion();

    int selection = wxVListBox::GetSelection();

    if ( selection != wxNOT_FOUND )
        m_stringValue = m_strings[selection];
    else
        m_stringValue.clear();

    m_value = selection;

    Dismiss();

    SendComboBoxEvent(selection);
}
void ContentAssistantPopup::OnClick(wxCommandEvent& event)
{
  if(m_completions.GetCount()>0)
  {
    int selection = event.GetSelection();
    if(selection > 0)
    {
      m_editor->ReplaceSelection(
        m_editor->GetSelectionString(),
        m_completions[selection]
        );
      this->GetParent()->GetParent()->Refresh();
    }
    this->GetParent()->GetParent()->Refresh();
    if(!m_editor->IsActive())
      m_editor->ActivateCell();
    Dismiss();
  }
}
Beispiel #30
0
void Vehicle::Update(uint32 diff)
{
    Creature::Update(diff);

    if(despawn)
    {
        m_spawnduration -= diff;
        if(m_spawnduration < 0)
            Dismiss();
        despawn = false;
    }

    if(m_regenTimer <= diff)
    {
        RegeneratePower(getPowerType());
        m_regenTimer = 4000;
    }
    else
        m_regenTimer -= diff;
}