Пример #1
0
LRESULT CommandDlg::OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{
	updateContext();
	if (wID == IDOK)
	{
		if (type != 0 &&
		        (ctrlName.GetWindowTextLength() == 0 || ctrlCommand.GetWindowTextLength() == 0))
		{
			MessageBox(CTSTRING(NAME_COMMAND_EMPTY));
			return 0;
		}
		
		GET_TEXT(IDC_NAME, name);
		GET_TEXT(IDC_HUB, hub);
		
		if (type != 0)
		{
			type = (ctrlOnce.GetCheck() == BST_CHECKED) ? 2 : 1;
		}
	}
	EndDialog(wID);
	return 0;
}
Пример #2
0
void ewol::resource::Shader::reload() {
	etk::FSNode file(m_name);
	if (false == file.exist()) {
		EWOL_ERROR("File does not Exist : '" << file << "' : '" << file.getFileSystemName() << "'");
		return;
	}
	
	int64_t fileSize = file.fileSize();
	if (0 == fileSize) {
		EWOL_ERROR("This file is empty : " << file);
		return;
	}
	if (false == file.fileOpenRead()) {
		EWOL_ERROR("Can not open the file : " << file);
		return;
	}
	// remove previous data ...
	if (nullptr != m_fileData) {
		delete[] m_fileData;
		m_fileData = 0;
	}
	// allocate data
	m_fileData = new char[fileSize+5];
	if (nullptr == m_fileData) {
		EWOL_ERROR("Error Memory allocation size=" << fileSize);
		return;
	}
	memset(m_fileData, 0, (fileSize+5)*sizeof(char));
	// load data from the file :
	file.fileRead(m_fileData, 1, fileSize);
	// close the file:
	file.fileClose();
	
	// now change the OGL context ...
	removeContext();
	updateContext();
}
void CXTPCalendarWeekView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
	CSelectionChangedContext selChanged(this);

	TBase::OnKeyDown(nChar, nRepCnt, nFlags);

	if (nChar == VK_LEFT || nChar == VK_RIGHT || nChar == VK_UP || nChar == VK_DOWN ||
			nChar == VK_PRIOR || nChar == VK_NEXT)
	{
		CXTPCalendarControl::CUpdateContext updateContext(m_pControl, xtpCalendarUpdateRedraw);

		BOOL bVKShift = (GetKeyState(VK_SHIFT)  < 0);
		COleDateTimeSpan spDay(1, 0, 0, 0);
		COleDateTimeSpan spWeek(7, 0, 0, 0);

		int nDVCount = GetViewDayCount();
		BOOL bSelReseted = !m_selectedBlock.dtEnd.GetStatus() == COleDateTime::valid;

		COleDateTime dtLastSelDay = GetLastSelectedDate();
		int nLastSelDayIdx = (dtLastSelDay.GetDayOfWeek() - m_nFirstDayOfWeekIndex + 7) % 7;

		COleDateTime dtNewSelDay = dtLastSelDay;

		int nSatDayIdx = 7 - m_nFirstDayOfWeekIndex;
		int nNewIdx = nLastSelDayIdx + 3;
		int nHalfShift = nNewIdx > nSatDayIdx && nLastSelDayIdx <= nSatDayIdx ||
			nNewIdx > nSatDayIdx + 7 && nLastSelDayIdx <= nSatDayIdx + 7 ? 4 : 3;

		COleDateTimeSpan spHalfWeekPlus(nHalfShift, 0, 0, 0);
		COleDateTimeSpan spHalfWeekMinus(7 - nHalfShift, 0, 0, 0);

		CXTPDrawHelpers::KeyToLayout(m_pControl, nChar);

		if (nChar == VK_LEFT)
		{
			dtNewSelDay -= spHalfWeekMinus;
		}
		else if (nChar == VK_RIGHT)
		{
			dtNewSelDay += spHalfWeekPlus;
		}
		else if (nChar == VK_UP)
		{
			dtNewSelDay -= spDay;
		}
		else if (nChar == VK_DOWN)
		{
			dtNewSelDay += spDay;
		}
		else if (nChar == VK_PRIOR)
		{
			dtNewSelDay -= spWeek;
		}
		else if (nChar == VK_NEXT)
		{
			dtNewSelDay += spWeek;
		}
		//---------------------------------------------------------------------------
		COleDateTime dtFirstDay = GetViewDayDate(0);
		COleDateTime dtLastDay = GetViewDayDate(nDVCount-1);

		BOOL bNeedScroll = dtNewSelDay < dtFirstDay || dtNewSelDay > dtLastDay;
		if (bNeedScroll && !m_bScrollV_Disabled)
		{
			if (dtNewSelDay < dtFirstDay)
			{
				ScrollV(m_nCurrPos-1, m_nCurrPos-1);
				bSelReseted = TRUE;
				CXTPCalendarControl::CUpdateContext updateContext1(m_pControl, xtpCalendarUpdateScrollBar);
			}
			if (dtNewSelDay > dtLastDay)
			{
				ScrollV(m_nCurrPos + 1, m_nCurrPos + 1);
				bSelReseted = TRUE;
				CXTPCalendarControl::CUpdateContext updateContext1(m_pControl, xtpCalendarUpdateScrollBar);
			}
		}

		//---------------------------------------------------------------------------
		if (!bNeedScroll || !m_bScrollV_Disabled)
		{
			if (bVKShift && !bSelReseted)
			{
				SelectDays(dtNewSelDay);
			}
			else
			{
				SelectDay(dtNewSelDay);
			}
		}
	}
}
Пример #4
0
void main()
{
	assert(line_line(line(vec2(0, 0), vec2(5, 5)), line(vec2(0, 5), vec2(5, 0))).result == true);
	assert(line_line(line(vec2(2.5, 0), vec2(2.5, 5)), line(vec2(0, 2.5), vec2(2.5, 5))).result == true);


	assert(line_rect(line(vec2(0,1),vec2(5,1)),rect(vec2(5,1),vec2(2,2))).result == true);


	assert(line_rect(line(vec2(1, 0), vec2(1, 5)), rect(vec2(1, 5), vec2(2, 2))).result == true);

	srand(time(NULL));
	auto w = openContext(1280, 800); //size of window
	auto m = mat4::ortho(-25, 1280, -25, 800, 0, 100); //size of drawing area 
	//drawing area is shrunk or stretchd to the size of the window



	Graph *g = Graph::genGrid(32,32,1280,800, 5);

	Solver dfs(g->getNumNodes(), g->getadjacencyMatrix(), g->getPos());
	Entity e(200, g->getPos()[0]);

	Entity lala(100, vec2(400, 400));

	float dt, current, total = 0;
	glfwSetTime(0);
	int lastGoal = 0;
	int newGoal = 0;
	bool newPath = true;

	std::vector<rect> obstacles; //used to keep track of the obstacles in the graph
	obstacles.push_back(rect(vec2( 165, 325), vec2(  50, 300))); //left side
	obstacles.push_back(rect(vec2(1115, 325), vec2(  50, 300))); //right top
	obstacles.push_back(rect(vec2( 640, 200), vec2(1000,  50))); //bottom
	obstacles.push_back(rect(vec2( 640, 800), vec2( 300, 300))); //top box
	obstacles.push_back(rect(vec2( 640,   0), vec2( 300, 150))); //bottom box
	
	for each(auto o in obstacles)
	g->addObstacle(o.min(), o.max());


	//opens the game loop
	while (updateContext(w)) //calls the draw functions
	{
		current = glfwGetTime();
		dt = current - total;
		total = current;
		if (dt > .16) dt = .16;


		if (newPath)
		{
			bool trying = true;
			lastGoal = newGoal;
			while (trying)
			{
				newGoal = rand() % g->getNumNodes();
				//newGoal = 800;
				for (int i = 0; i < g->getNumNodes(); i++)
					if (g->getadjacencyMatrix()[newGoal][i] > 0)
						trying = false;
			}
			e.m_path = Solver::solve(g->getNumNodes(), g->getadjacencyMatrix(), g->getPos(), lastGoal, newGoal);
			e.m_path = dfs.smoothPath(e.m_path, obstacles);

			lala.m_path = Solver::solve(g->getNumNodes(), g->getadjacencyMatrix(), g->getPos(), lastGoal, newGoal);
			lala.m_path = dfs.smoothPath(e.m_path, obstacles);
			newPath = false;
		}
		
		e.update(dt);
		lala.update(dt);

		e.draw(m, 7, vec4(1,1,1,1));
		lala.draw(m, 7, vec4(0,1,1,0));
		
		for (int j = 0; j < obstacles.size(); j++)
		{

			draw_rect(m, rect(obstacles[j]), vec4(0, 0, 1, 0));
		}

		for (int i = 1; i < e.m_path.size(); i++) //draw path
		{
			draw_line(m, line(e.m_path[i - 1], e.m_path[i]), vec4(0, 1, 0, 0));
		}

		if (e.m_targetIndex == e.m_path.size())
		{
			e.m_targetIndex = 0;
			newPath = true;
		}



	}
	//delete g;
	//closes the game loop
	closeContext(w);
}
Пример #5
0
bool OpenGLComponent::performRender()
{
    const ScopedLock sl (contextLock);

   #if JUCE_LINUX
    updateContext();
   #endif

    if (context != nullptr)
    {
        if (! makeCurrentRenderingTarget())
            return false;

        if (needToUpdateViewport)
        {
            needToUpdateViewport = false;
            glViewport (0, 0, getWidth(), getHeight());
        }

        renderOpenGL();

        if (needToRepaint && (flags & allowSubComponents) != 0)
        {
            needToRepaint = false;

            contextLock.exit(); // (MM must be locked before the context lock)
            MessageManagerLock mmLock (renderThread);
            contextLock.enter();

            if (! mmLock.lockWasGained())
                return false;

            // you mustn't set your own cached image object for an OpenGLComponent!
            jassert (dynamic_cast<OpenGLCachedComponentImage*> (getCachedComponentImage()) == cachedImage);

            const Rectangle<int> bounds (getLocalBounds());
            OpenGLFrameBuffer& frameBuffer = cachedImage->getFrameBuffer (bounds.getWidth(), bounds.getHeight());

            {
                RectangleList invalid (bounds);
                invalid.subtract (cachedImage->validArea);
                cachedImage->validArea = bounds;

                if (! invalid.isEmpty())
                {
                    jassert (getCurrentContext() != nullptr);

                    {
                        OpenGLGraphicsContext g (*getCurrentContext(), frameBuffer);
                        g.clipToRectangleList (invalid);

                        g.setFill (Colours::transparentBlack);
                        g.fillRect (bounds, true);
                        g.setFill (Colours::black);

                        paintSelf (g);
                    }

                    makeCurrentRenderingTarget();
                }
            }

            glEnable (GL_TEXTURE_2D);
            context->extensions.glActiveTexture (GL_TEXTURE0);
            glBindTexture (GL_TEXTURE_2D, frameBuffer.getTextureID());

            context->copyTexture (bounds, Rectangle<int> (bounds.getWidth(),
                                                          bounds.getHeight()));
            glBindTexture (GL_TEXTURE_2D, 0);
        }

        swapBuffers();
    }

    return true;
}
Пример #6
0
   void BeginRender(const Rect &inRect,bool inForHitTest)
   {
      if (!inForHitTest)
      {
         if (mContextId!=gTextureContextVersion)
         {
            updateContext();
         }

         #ifndef NME_GLES
         #ifndef SDL_OGL
         #ifndef GLFW_OGL
         wglMakeCurrent(mDC,mOGLCtx);
         #endif
         #endif
         #endif

         if (mHasZombie)
         {
            mHasZombie = false;
            if (mZombieTextures.size())
            {
               glDeleteTextures(mZombieTextures.size(),&mZombieTextures[0]);
               mZombieTextures.resize(0);
            }

            if (mZombieVbos.size())
            {
               glDeleteBuffers(mZombieVbos.size(),&mZombieVbos[0]);
               mZombieVbos.resize(0);
            }

            if (mZombiePrograms.size())
            {
               for(int i=0;i<mZombiePrograms.size();i++)
                  glDeleteProgram(mZombiePrograms[i]);
               mZombiePrograms.resize(0);
            }

            if (mZombieShaders.size())
            {
               for(int i=0;i<mZombieShaders.size();i++)
                  glDeleteShader(mZombieShaders[i]);
               mZombieShaders.resize(0);
            }

            if (mZombieFramebuffers.size())
            {
               glDeleteFramebuffers(mZombieFramebuffers.size(),&mZombieFramebuffers[0]);
               mZombieFramebuffers.resize(0);
            }

            if (mZombieRenderbuffers.size())
            {
               glDeleteRenderbuffers(mZombieRenderbuffers.size(),&mZombieRenderbuffers[0]);
               mZombieRenderbuffers.resize(0);
            }
         }


         // Force dirty
         mViewport.w = -1;
         SetViewport(inRect);


         glEnable(GL_BLEND);

        #ifdef WEBOS
         glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_FALSE);
         #endif

         mLineWidth = 99999;

         // printf("DrawArrays: %d, DrawBitmaps:%d  Buffers:%d\n", sgDrawCount, sgDrawBitmap, sgBufferCount );
         sgDrawCount = 0;
         sgDrawBitmap = 0;
      }
   }
Пример #7
0
void ScriptManager::updateContext(QScriptValue object) {
    updateContext(object.engine());
}
Пример #8
0
int Oomd::run() {
  if (!prepareRun()) {
    return 1;
  }

  uint64_t ticks = 0;
  uint64_t detector_ticks = 0;
  uint64_t killer_ticks = 0;

  XLOG(INFO) << "Running oomd";
  while (true) {
    if (need_tunables_reload) {
      tunables_->loadOverrides();
      tunables_->dump();
      need_tunables_reload = false;
    }
    updateTunables();

    const auto before = std::chrono::steady_clock::now();

    if (verbose_ && ++ticks % verbose_ticks_ == 0) {
      std::ostringstream oss;
      oss << "detectorticks=" << detector_ticks
          << " killticks=" << killer_ticks;
      OOMD_LOG(oss.str(), "oomd heartbeat");
    }

    for (auto& cgroup : cgroups_) {
      updateContext(cgroup->detector->getCgroupPath(), cgroup->context);

      ++detector_ticks;
      if (cgroup->detector->isOOM(cgroup->context)) {
        ++killer_ticks;
        if (cgroup->killer->tryToKillSomething(cgroup->context)) {
          std::this_thread::sleep_for(post_kill_delay_ / 2);
          cgroup->detector->postKill(cgroup->context);
          std::this_thread::sleep_for(post_kill_delay_ / 2);

          // Only kill 1 process system-wide per Tunable::INTERVAL.
          // We do this because oomd examines the system as a whole,
          // as opposed to an isolated per-cgroup manner
          break;
        }
      }
    }

    // Rotate cgroups_ so we have round robin for fairness
    std::rotate(cgroups_.begin(), cgroups_.begin() + 1, cgroups_.end());

    // We may have slept already, so recalculate
    const auto after = std::chrono::steady_clock::now();
    auto to_sleep = interval_ - (after - before);
    if (to_sleep < std::chrono::seconds(0)) {
      to_sleep = std::chrono::seconds(0);
    }

    std::this_thread::sleep_for(to_sleep);
  }

  return 0;
}
void CXTPCalendarController::OnEvent_DatePicker(XTP_NOTIFY_CODE Event, WPARAM wParam, LPARAM /*lParam*/)
{
    wParam;

    switch (Event)
    {
    case XTP_NC_DATEPICKERBEFOREGOMODAL:
        if (m_pDatePickerCtrl && m_pCalendarCtrl)
        {
            OnEvent_CalendarView(XTP_NC_CALENDARVIEWWASCHANGED, 0, 0);
        }
        break;
    case XTP_NC_DATEPICKERBUTTONCLICKED:
        DBG_TRACE_DP_NF(_T("OnEvent: DatePickerButtonClicked - ID = %u.     {CalendarController}. \n"), wParam);
        break;
    case XTP_NC_DATEPICKERMONTHCHANGED:
        m_DayInfoCache.UpActivePriority();
        break;
    case XTP_NC_DATEPICKERSELECTIONCHANGED:
        DBG_TRACE_DP_NF(_T("OnEvent: XTP_NC_DATEPICKERSELECTIONCHANGED.     {CalendarController}. \n"));
        if (m_pDatePickerCtrl && m_pCalendarCtrl && m_pCalendarCtrl->GetActiveView())
        {
            BOOL bFastMode = m_pCalendarCtrl->m_bSwitchToDayViewIfPickedSingleDay;
            BOOL bChanged = FALSE;

            COleDateTime dtFrom;
            COleDateTime dtTo;
            if (m_pDatePickerCtrl->GetSelRange(dtFrom, dtTo))
            {
                int nFirstDayOfWeekIndex = m_pDatePickerCtrl->GetFirstDayOfWeek();
                int nFirstDayOfWeek = dtFrom.GetDayOfWeek();
                BOOL bWeekStart = (nFirstDayOfWeekIndex == nFirstDayOfWeek);

                CXTPCalendarControl::CUpdateContext updateContext(m_pCalendarCtrl);

                int nSelRangeDays = CXTPCalendarUtils::GetTotalDays(dtTo - dtFrom) + 1;
                // count selected days
                int nSelDays = 0;
                COleDateTimeSpan spDay(1, 0, 0, 0);
                for (COleDateTime dtDay = dtFrom; dtDay <= dtTo; dtDay += spDay)
                {
                    if (m_pDatePickerCtrl->IsSelected(dtDay))
                        nSelDays++;
                }
                BOOL bDaysCont = (nSelRangeDays == nSelDays);
//LOGIC TO SELECT VIEW TYPE <<
                // Day view
                int eViewMode = XTP_SAFE_GET2(m_pCalendarCtrl, GetActiveView(), GetViewType(), xtpCalendarDayView);

                if (eViewMode == xtpCalendarTimeLineView)
                {
                    CXTPCalendarTimeLineView* pView = (CXTPCalendarTimeLineView* ) m_pCalendarCtrl->GetActiveView();
                    if (pView)
                    {
                        pView->SetStartViewDate(dtFrom);
                        if (nSelRangeDays == 1)
                            pView->SetTimeScaleID(xtpTSPID_Day);
                        else if (nSelRangeDays <= 5)
                            pView->SetTimeScaleID(xtpTSPID_WorkWeek);
                        else if (nSelRangeDays <= 7)
                            pView->SetTimeScaleID(xtpTSPID_Week);
                        else
                            pView->SetTimeScaleID(xtpTSPID_Month);
                    }

                    return;
                }

                if (nSelRangeDays <= nXTPMaxDayViewDays ||
                        !bDaysCont || !bWeekStart && nSelRangeDays <= 8)
                {
                    m_bAdjustingView = TRUE;

                    // to save WorkWeek view mode

                    //if (eViewMode != xtpCalendarWorkWeekView || nSelDays != 1)
                    if (bFastMode &&
                            ((eViewMode != xtpCalendarWorkWeekView)
                             && (eViewMode != xtpCalendarFullWeekView))
                            || nSelDays != 1)
                        eViewMode = xtpCalendarDayView;

                    if (eViewMode == xtpCalendarMonthView)
                    {
                        CXTPCalendarMonthView* pMonthView = DYNAMIC_DOWNCAST(CXTPCalendarMonthView, m_pCalendarCtrl->GetActiveView());
                        if (pMonthView)
                        {
                            pMonthView->SelectDay(dtFrom);
                            CXTPCalendarControl::CViewChangedContext viewChanged(m_pCalendarCtrl, xtpCalendarViewChangedLock);
                            COleDateTime dtBegin = dtFrom;
                            // Calculate weeks count
                            COleDateTime dtWeekFromBegin = pMonthView->GetGrid()->ShiftDateToCell_00(dtFrom);
                            COleDateTime dtWeekToEnd = pMonthView->GetGrid()->ShiftDateToCell_00(dtTo);
                            dtWeekToEnd += COleDateTimeSpan(7, 0, 0, 0);
                            int nSelectedWeeksRange = CXTPCalendarUtils::GetTotalDays(dtWeekToEnd - dtWeekFromBegin);

                            int nWeeks = nSelectedWeeksRange / 7;
                            nWeeks = max(XTP_CALENDAR_MONTHVIEW_SHOW_WEEKS_MIN, nWeeks);
                            nWeeks = min(XTP_CALENDAR_MONTHVIEW_SHOW_WEEKS_MAX, nWeeks);

                            pMonthView->GetGrid()->SetBeginDate(dtBegin);
                            pMonthView->GetGrid()->SetWeeksCount(nWeeks);

                            m_pCalendarCtrl->Populate();
                        }
                    }
                    else if ((eViewMode == xtpCalendarWorkWeekView)
                             || (eViewMode == xtpCalendarFullWeekView)
                             || (eViewMode == xtpCalendarWeekView))
                    {
                        CXTPCalendarDayView* pDayView = DYNAMIC_DOWNCAST(CXTPCalendarDayView, m_pCalendarCtrl->GetActiveView());
                        if (pDayView)
                        {
                            pDayView->UnselectAllEvents();

                            COleDateTime dtWWStart;
                            m_pCalendarCtrl->GetWorkDayStartTime(dtWWStart);
                            dtWWStart = CXTPCalendarUtils::UpdateDate(dtWWStart, dtFrom);

                            pDayView->SetSelection(dtWWStart, dtWWStart + pDayView->GetCellDuration());
                        }
                        else
                        {
                            CXTPCalendarWeekView* pWeekView = DYNAMIC_DOWNCAST(CXTPCalendarWeekView, m_pCalendarCtrl->GetActiveView());
                            if (pWeekView)
                            {
                                pWeekView->SelectDay(dtFrom);
                                pWeekView->SetBeginDate(dtFrom);
                                m_pCalendarCtrl->Populate();
                            }
                        }
                    }

                    //*** switch calendar view
                    m_pCalendarCtrl->SwitchActiveView((XTPCalendarViewType)eViewMode);
                    //***

                    CXTPCalendarDayView* pDayView = DYNAMIC_DOWNCAST(CXTPCalendarDayView, m_pCalendarCtrl->GetActiveView());

                    // DayView - set visible days
                    if (pDayView && eViewMode == xtpCalendarDayView)
                    {
                        COleDateTime dtSelStart, dtSelEnd;
                        BOOL bAllDay = FALSE;
                        BOOL bSel = pDayView->GetSelection(&dtSelStart, &dtSelEnd, &bAllDay);
                        if (bSel)
                        {
                            COleDateTimeSpan spSel = dtSelEnd - dtSelStart;
                            COleDateTimeSpan spSelMin = pDayView->GetCellDuration();
                            if (spSel < spSelMin)
                                bSel = FALSE;
                        }
                        if (!bSel)
                        {
                            m_pCalendarCtrl->GetWorkDayStartTime(dtSelStart);
                            dtSelEnd = dtSelStart + pDayView->GetCellDuration();
                            bAllDay = FALSE;
                        }
                        dtSelStart = CXTPCalendarUtils::UpdateDate(dtSelStart, dtFrom);
                        dtSelEnd = CXTPCalendarUtils::UpdateDate(dtSelEnd, dtFrom);

                        pDayView->ShowDay(dtFrom);

                        pDayView->SetSelection(dtSelStart, dtSelEnd, bAllDay);

                        // add other selected days to calendar view
                        for (COleDateTime dtDay(dtFrom + spDay); dtDay <= dtTo; dtDay += spDay)
                        {
                            if (m_pDatePickerCtrl->IsSelected(dtDay))
                                pDayView->AddDay(dtDay); // add it to Calendar View
                        }
                        m_pCalendarCtrl->Populate();
                    }
                    m_bAdjustingView = FALSE;

                    bChanged = TRUE;
                }
                // Week view
                else if (nSelRangeDays == 7 && bDaysCont)
                {
                    COleDateTime dtBegin = dtFrom;

                    m_bAdjustingView = TRUE;

                    if (m_pCalendarCtrl->m_bMultiColumnWeekMode)
                        m_pCalendarCtrl->SwitchActiveView(xtpCalendarFullWeekView);
                    else
                        m_pCalendarCtrl->SwitchActiveView(xtpCalendarWeekView);

                    CXTPCalendarWeekView* pWeekView = DYNAMIC_DOWNCAST(CXTPCalendarWeekView, m_pCalendarCtrl->GetActiveView());
                    if (pWeekView)
                    {
                        pWeekView->SetBeginDate(dtBegin);

                        m_pCalendarCtrl->Populate();
                    }
                    else if (m_pCalendarCtrl->m_bMultiColumnWeekMode)
                    {
                        CXTPCalendarDayView* pWeekDayView = DYNAMIC_DOWNCAST(CXTPCalendarDayView, m_pCalendarCtrl->GetActiveView());
                        if (pWeekDayView)
                        {
                            pWeekDayView->ShowDays(dtBegin, dtTo);

                            m_pCalendarCtrl->Populate();
                        }
                    }
                    m_bAdjustingView = FALSE;

                    bChanged = TRUE;
                }
                // Month view
                else
                {
                    ASSERT(nSelRangeDays == nSelDays && nSelRangeDays > 7);

                    m_bAdjustingView = TRUE;

                    m_pCalendarCtrl->SwitchActiveView(xtpCalendarMonthView);
                    CXTPCalendarMonthView* pMonthView = DYNAMIC_DOWNCAST(CXTPCalendarMonthView, m_pCalendarCtrl->GetActiveView());
                    if (pMonthView)
                    {
                        CXTPCalendarControl::CViewChangedContext viewChanged(m_pCalendarCtrl, xtpCalendarViewChangedLock);
                        COleDateTime dtBegin = dtFrom;
                        // Calculate weeks count
                        COleDateTime dtWeekFromBegin = pMonthView->GetGrid()->ShiftDateToCell_00(dtFrom);
                        COleDateTime dtWeekToEnd = pMonthView->GetGrid()->ShiftDateToCell_00(dtTo);
                        dtWeekToEnd += COleDateTimeSpan(7, 0, 0, 0);
                        int nSelectedWeeksRange = CXTPCalendarUtils::GetTotalDays(dtWeekToEnd - dtWeekFromBegin);

                        int nWeeks = nSelectedWeeksRange / 7;
                        nWeeks = max(XTP_CALENDAR_MONTHVIEW_SHOW_WEEKS_MIN, nWeeks);
                        nWeeks = min(XTP_CALENDAR_MONTHVIEW_SHOW_WEEKS_MAX, nWeeks);

                        pMonthView->GetGrid()->SetBeginDate(dtBegin);
                        pMonthView->GetGrid()->SetWeeksCount(nWeeks);

                        m_pCalendarCtrl->Populate();
                    }
                    m_bAdjustingView = FALSE;

                    bChanged = TRUE;
                }
//LOGIC TO SELECT VIEW TYPE <<
                if (bChanged)
                {
                    OnEvent_CalendarView(XTP_NC_CALENDARVIEWWASCHANGED, 0, XTP_CC_DONT_SCROLL_DP);

                    if (m_pDatePickerCtrl->IsModal())
                    {
                        m_pCalendarCtrl->Invalidate(FALSE);
                        m_pCalendarCtrl->RedrawControl();
                    }
                }
            }
        }
        break;
    default:
        ASSERT(FALSE);
    }
}
Пример #10
0
void CSimpleReport::Paste()
{
	if (IsVirtualMode())
		return;

	CWaitCursor _WC;

	CLIPFORMAT uCF_Records = (CLIPFORMAT)::RegisterClipboardFormat(XTPREPORTCTRL_CF_RECORDS);

	CXTPReportRecords arRecords;
	BOOL bTryPasteFromText = TRUE;

	// Retrieve text from the clipboard
	if (!OpenClipboard())
		return;

	if (::IsClipboardFormatAvailable(uCF_Records))
	{
		HGLOBAL hPasteData = ::GetClipboardData(uCF_Records);

		if (hPasteData)
		{
			bTryPasteFromText = FALSE;

			const int cErrTextSize = 1024;
			TCHAR szErrText[cErrTextSize + 1];

			CSharedFile fileSahred;
			fileSahred.SetHandle(hPasteData, FALSE);
			CArchive ar(&fileSahred, CArchive::load);

			try
			{
				CXTPPropExchangeArchive px(ar);
				BOOL bread = FALSE;
			#if _XTPLIB_VERSION_PREFIX == 1502
				bread = _ReadRecordsFromData(&px, arRecords);
			#else
				bread = _ReadRecodsFromData(&px, arRecords);
			#endif
				if (!bread)
				{
					arRecords.RemoveAll();
				}
			}
			catch(CArchiveException* pE)
			{
				if (pE->GetErrorMessage(szErrText, cErrTextSize))
				{
					TRACE(_T("EXCEPTION: CXTPReportControl::Paste() - %s\n"), szErrText);
				}
				pE->Delete();
			}
			catch(CFileException* pE)
			{
				if (pE->GetErrorMessage(szErrText, cErrTextSize))
				{
					TRACE(_T("EXCEPTION: CXTPReportControl::Paste() - %s\n"), szErrText);
				}
				pE->Delete();
			}
			catch(...)
			{
				TRACE(_T("EXCEPTION: CXTPReportControl::Paste() - Unhandled Exception!\n"));
			}

			//*********
			ar.Close(); // detach from file
			fileSahred.Detach(); //detach from data
			::GlobalUnlock(hPasteData); // unlock data
		}
	}

	UINT uCF_TText = sizeof(TCHAR) == 2 ? CF_UNICODETEXT : CF_TEXT;

	if (bTryPasteFromText && ::IsClipboardFormatAvailable(uCF_TText))
	{
		// Try to get text data from the clipboard
		HGLOBAL hglbPaste = ::GetClipboardData(uCF_TText);

		// Import Text data into the control
		if (hglbPaste != NULL)
		{
			TCHAR* lpszClipboard = (TCHAR*)GlobalLock(hglbPaste);
			BOOL bRead = FALSE;
		#if _XTPLIB_VERSION_PREFIX == 1502	 
			bRead = _ReadRecordsFromText(lpszClipboard, arRecords);
		#else
			bRead = _ReadRecodsFromText(lpszClipboard, arRecords);
		#endif
			if (!bRead)
			{
				arRecords.RemoveAll();
			}
			::GlobalUnlock(hglbPaste);
		}
	}

	::CloseClipboard();
	//////////////////////////////////////////////////////////////////////////

	CUpdateContext updateContext(this);

	// Add and Populate records
	CXTPReportRow* pRow = GetFocusedRow();
	if (pRow == NULL)
		return;

	int n = pRow->GetRecord()->GetIndex();
	int nRecordsCount = arRecords.GetCount();
	if (nRecordsCount > 0) {
		for (int i = nRecordsCount - 1; i >= 0; i--) {
			CXTPReportRecord* pRecord = arRecords.GetAt(i);
			if (pRecord) {
				CMDTARGET_ADDREF(pRecord);
				if (m_bAdd)
					GetRecords()->Add(arRecords.GetAt(i));
				else
					GetRecords()->InsertAt(n, arRecords.GetAt(i));
			}
		}
		Populate();
		_SelectRows(&arRecords);
	}
	m_bAdd = false;
}
Пример #11
0
 /// Standard constructor
 Geant4UserSteppingAction(Geant4Context* ctxt, Geant4SteppingActionSequence* seq)
   : Base(ctxt, seq) {
   updateContext(ctxt);
   configureFiber(ctxt);
 }
Пример #12
0
 /// Standard constructor
 Geant4UserGeneratorAction(Geant4Context* ctxt, Geant4GeneratorActionSequence* seq)
   : G4VUserPrimaryGeneratorAction(), Base(ctxt, seq) {
   updateContext(ctxt);
   configureFiber(ctxt);
 }
Пример #13
0
 /// Standard constructor
 Geant4UserEventAction(Geant4Context* ctxt, Geant4EventActionSequence* seq)
   : Base(ctxt, seq), runAction(0)  {
   updateContext(ctxt);
   configureFiber(ctxt);
 }