예제 #1
0
void MoveSelectionCommand::doApply()
{
    Selection selection = endingSelection();
    ASSERT(selection.isRange());

    Position pos = m_position;
    if (pos.isNull())
        return;
        
    // Update the position otherwise it may become invalid after the selection is deleted.
    Node *positionNode = m_position.node();
    int positionOffset = m_position.offset();
    Position selectionEnd = selection.end();
    int selectionEndOffset = selectionEnd.offset();    
    if (selectionEnd.node() == positionNode && selectionEndOffset < positionOffset) {
        positionOffset -= selectionEndOffset;
        Position selectionStart = selection.start();
        if (selectionStart.node() == positionNode) {
            positionOffset += selectionStart.offset();
        }
        pos = Position(positionNode, positionOffset);
    }

    deleteSelection(m_smartMove);

    // If the node for the destination has been removed as a result of the deletion,
    // set the destination to the ending point after the deletion.
    // Fixes: <rdar://problem/3910425> REGRESSION (Mail): Crash in ReplaceSelectionCommand; 
    //        selection is empty, leading to null deref
    if (!pos.node()->inDocument())
        pos = endingSelection().start();

    setEndingSelection(Selection(pos, endingSelection().affinity()));
    applyCommandToComposite(ReplaceSelectionCommand::create(positionNode->document(), m_fragment, true, m_smartMove));
}
예제 #2
0
void InsertTextCommand::input(const String &text, bool selectInsertedText)
{
    assert(text.find('\n') == -1);

    if (endingSelection().isNone())
        return;
    
    // Delete the current selection.
    if (endingSelection().isRange())
        deleteSelection(false, true, true);
    
    // Insert the character at the leftmost candidate.
    Position startPosition = endingSelection().start().upstream();
    deleteInsignificantText(startPosition.upstream(), startPosition.downstream());
    if (!startPosition.inRenderedContent())
        startPosition = startPosition.downstream();
        
    startPosition = positionAvoidingSpecialElementBoundary(startPosition);
    
    Position endPosition;
    
    if (text == "\t") {
        endPosition = insertTab(startPosition);
        startPosition = endPosition.previous();
        removeBlockPlaceholder(VisiblePosition(startPosition));
        m_charactersAdded += 1;
    } else {
        // Make sure the document is set up to receive text
        startPosition = prepareForTextInsertion(startPosition);
        removeBlockPlaceholder(VisiblePosition(startPosition));
        Text *textNode = static_cast<Text *>(startPosition.node());
        int offset = startPosition.offset();

        insertTextIntoNode(textNode, offset, text);
        endPosition = Position(textNode, offset + text.length());

        // The insertion may require adjusting adjacent whitespace, if it is present.
        rebalanceWhitespaceAt(endPosition);
        // Rebalancing on both sides isn't necessary if we've inserted a space.
        if (text != " ") 
            rebalanceWhitespaceAt(startPosition);
            
        m_charactersAdded += text.length();
    }

    setEndingSelection(Selection(startPosition, endPosition, DOWNSTREAM));

    // Handle the case where there is a typing style.
    // FIXME: Improve typing style.
    // See this bug: <rdar://problem/3769899> Implementation of typing style needs improvement
    CSSMutableStyleDeclaration* typingStyle = document()->frame()->typingStyle();
    RefPtr<CSSComputedStyleDeclaration> endingStyle = endPosition.computedStyle();
    endingStyle->diff(typingStyle);
    if (typingStyle && typingStyle->length() > 0)
        applyStyle(typingStyle);

    if (!selectInsertedText)
        setEndingSelection(endingSelection().end(), endingSelection().affinity());
}
void MainView::Select(int32 tab)
{
	TRACE();
	int32 selection=Selection();
	BTabView::Select(tab);
	(doc->GetEditorManager())->SetInactivePEditor(selection);
	(doc->GetEditorManager())->SetActivePEditor(tab);
}
예제 #4
0
void GraphicsWindow::DeleteSelection()
{
	if(Selection()) {
		ellipses.erase(selection);
		ClearSelection();
		InvalidateRect(m_hwnd, NULL, FALSE); // Redraw the scene without this item
	}
}
예제 #5
0
ContextMenu::ContextMenu(ScribusMainWindow *actionsParent, ScribusDoc* doc, double mx, double my, QWidget * parent) :
	QMenu(parent),
	m_Sel(Selection(this)),
	m_ScMW(actionsParent),
	m_doc(doc)
{
	createMenuItems_NoSelection(mx, my);
}
예제 #6
0
std::queue<Selection>& NewlineSelector::nextChar(std::queue<Selection>& selections
		, InputCharWrapper c)
{
	if(c.getChar() == '\n')
		selections.push((Selection(c.getPos(), (int)c.getPos()+1)));

	return selections;
}
예제 #7
0
void TimeTaggerDialog::unTag_action() {
	if (this==NULL)
		return;
	SelectionList listForRemoval;
	int i=findSelection(0,SELECTION_OUTSIDE);
	if (i>=0) {
		while (i>=0) {
			listForRemoval.append(Selection(tags[i].first,tags[i].second));
			tags.removeAt(i);
			i--;
			i=findSelection(i+1,SELECTION_OUTSIDE);
		}
	} else {
		QTextCursor c=text->textCursor();
		int start=c.selectionStart();
		int end=c.selectionEnd();
		int i=findSelection(0,SELECTION_OUTSIDEOVERLAP);
		if (i>=0) {
			listForRemoval.append(Selection(start,end-1));
		}
		while (i>=0) {
			if (tags[i].first>=start) {
				tags[i].first=end;
			} else {
				tags[i].second=start-1;
			}
			if (tags[i].first==tags[i].second) {
				tags.removeAt(i);
				i--;
			}
			i=findSelection(i+1,SELECTION_OUTSIDEOVERLAP);
		}
	}
	QTextCursor c=text->textCursor();
	for (int i=0;i<listForRemoval.size();i++) {
		c.setPosition(listForRemoval[i].first,QTextCursor::MoveAnchor);
		c.setPosition(listForRemoval[i].second+1,QTextCursor::KeepAnchor);
		text->setTextCursor(c);
		text->setTextBackgroundColor(Qt::white);
		text->setTextColor(Qt::black);
		text->setTextCursor(c);
	}
	c.clearSelection();
	text->setTextCursor(c);
}
예제 #8
0
static void prepareClipboardForImageDrag(Frame* src, Clipboard* clipboard, Element* node, const KURL& linkURL, const KURL& imageURL, const String& label)
{
    RefPtr<Range> range = src->document()->createRange();
    ExceptionCode ec = 0;
    range->selectNode(node, ec);
    ASSERT(ec == 0);
    src->selection()->setSelection(Selection(range.get(), DOWNSTREAM));           
    clipboard->declareAndWriteDragImage(node, !linkURL.isEmpty() ? linkURL : imageURL, label, src);
}
예제 #9
0
OpSelectiveLabFilter::OpSelectiveLabFilter(Process *parent) :
    Operator(OP_SECTION_COSMETIC, QT_TRANSLATE_NOOP("Operator", "Selective Lab Filter"), Operator::All, parent),
    m_selectiveLab(new OperatorParameterSelectiveLab("labSelection", tr("Selection"), tr("Selective Lab Filter"), 0, 0, false, 35, true, true, true, this)),
    m_saturation(new OperatorParameterSlider("saturation", tr("Saturation"), tr("Selective Lab Filter Saturation"), Slider::Percent, Slider::Linear, Slider::Real, 0, 2, 1, 0, 10, Slider::FilterNothing, this)),
    m_exposure(new OperatorParameterSlider("exposure", tr("Exposure"), tr("Selective Lab Filter Exposure"), Slider::ExposureValue, Slider::Logarithmic, Slider::Real, 1./(1<<8), 1<<8, 1, 1./(1<<16), 1<<16, Slider::FilterExposure, this)),
    m_exposureSelection(new OperatorParameterDropDown("exposureSelection", tr("Exposure zone"), this, SLOT(exposureSelection(int)))),
    m_exposureSelectionValue(Inside)
{
    m_exposureSelection->addOption(DF_TR_AND_C("Inside"), Inside, true);
    m_exposureSelection->addOption(DF_TR_AND_C("Outside"), Outside);

    addInput(new OperatorInput(tr("Images"), OperatorInput::Set, this));
    addOutput(new OperatorOutput(tr("Images"), this));
    addParameter(m_selectiveLab);
    addParameter(m_saturation);
    addParameter(m_exposure);
    addParameter(m_exposureSelection);
}

OpSelectiveLabFilter *OpSelectiveLabFilter::newInstance()
{
    return new OpSelectiveLabFilter(m_process);
}

OperatorWorker *OpSelectiveLabFilter::newWorker()
{
    return new WorkerSelectiveLabFilter(m_selectiveLab->hue(),
                                        m_selectiveLab->coverage(),
                                        m_saturation->value(),
                                        m_selectiveLab->strict(),
                                        m_exposure->value(),
                                        m_exposureSelectionValue==Inside, m_thread, this);
}

Algorithm *OpSelectiveLabFilter::getAlgorithm() const
{
    return new SelectiveLabFilter(m_selectiveLab->hue(),
                                  m_selectiveLab->coverage(),
                                  m_saturation->value(),
                                  m_selectiveLab->strict(),
                                  m_exposure->value(),
                                  m_exposureSelectionValue==Inside,
                                  false);
}

void OpSelectiveLabFilter::releaseAlgorithm(Algorithm *algo) const
{
    delete algo;
}

void OpSelectiveLabFilter::exposureSelection(int v)
{
    if ( m_exposureSelectionValue != v ) {
        m_exposureSelectionValue = Selection(v);
        setOutOfDate();
    }
}
	/** Does a hittest and selects the item at nx, ny if any. nx and ny are
	in client coordinates. Returns newly selected item, or NULL if there is
	not a tree item at the specified point.*/
	HTREEITEM			HitTestSelect(	VLONG nx,
										VLONG ny) const
	{
		HTREEITEM hItem = HitTest(nx, ny);

		if ( hItem )
			Selection(hItem);

		return hItem;
	}
예제 #11
0
void GraphicsWindow::MoveSelectionDown()
{
	// If we're not the first ellipsis to be drawn then swap us with the one before us
	if(Selection() && selection != ellipses.begin())
	{
		// Prev copies and returns an iterator for the previous position without effecting selection
		// Selection is maintained as the list contains the same elements so the iterators are not invalidated
		ellipses.splice(prev(selection), ellipses, selection);
	}
	InvalidateRect(m_hwnd, NULL, FALSE); // Redraw the newly layered scene
}
예제 #12
0
void GraphicsWindow::MoveSelectionUp()
{
	// End isn't the last element showing, the item before end is so check for that case
	if(Selection() && selection != prev(ellipses.end()) && selection != ellipses.end())
	{
		// Next copies and returns an iterator for the next position without effecting selection
		// Selection is maintained as the list contains the same elements so the iterators are not invalidated
		ellipses.splice(next(next(selection)), ellipses, selection);
	}
	InvalidateRect(m_hwnd, NULL, FALSE); // Redraw the newly layered scene
}
예제 #13
0
void BaseGrid::ClearMaps() {
	Selection old_selection(selection);

	index_line_map.clear();
	line_index_map.clear();
	selection.clear();
	yPos = 0;
	AdjustScrollbar();

	AnnounceSelectedSetChanged(Selection(), old_selection);
}
예제 #14
0
Selection
MultiSelection::getContainingSelection(size_t frame, bool defaultToFollowing) const
{
    // This scales very badly with the number of selections, but it's
    // more efficient for very small numbers of selections than a more
    // scalable method, and I think that may be what we need

    for (SelectionList::const_iterator i = m_selections.begin();
	 i != m_selections.end(); ++i) {

	if (i->contains(frame)) return *i;

	if (i->getStartFrame() > frame) {
	    if (defaultToFollowing) return *i;
	    else return Selection();
	}
    }

    return Selection();
}
예제 #15
0
파일: p0.cpp 프로젝트: NiNjA-CodE/csc-313
int main (int argc, char **argv)
{
    initscr ();
    noecho ();

    Welcome ();
    Selection (argc, argv);

    endwin ();

    return 0;
}
예제 #16
0
int CIFEventCraftWin::WindowSelection()
{
	int ret;
	
	
	ret = m_titleBar->Selection();
	if( ret == IF_LBDN ) return( IF_CTL_BEGIN_MOVING );
	ret = Selection();
	if( ret == IF_LBDN ) return( IF_CTL_SELECT );

	return( IF_CTL_NONE );
}
예제 #17
0
HRESULT GraphicsWindow::InsertEllipse(float x, float y)
{
    try
    {
		// Add a new ellipses to the end of the list
        selection = ellipses.insert(
            ellipses.end(), 
            std::shared_ptr<DrawableEllipse>(new DrawableEllipse()));

        Selection()->ellipse.point = ptMouse = D2D1::Point2F(x, y);
        Selection()->ellipse.radiusX = Selection()->ellipse.radiusY = 2.0f; 
        Selection()->color = D2D1::ColorF( colors[nextColor] );

        nextColor = (nextColor + 1) % ARRAYSIZE(colors);
    }
    catch (std::bad_alloc)
    {
        return E_OUTOFMEMORY;
    }
    return S_OK;
}
예제 #18
0
void FaceInstance::selectedChanged(const Selectable& selectable)
{
	if (selectable.isSelected())
	{
		Selection().push_back(this);
	}
	else
	{
		FaceInstanceSet::reverse_iterator found = std::find(Selection().rbegin(), Selection().rend(), this);

		// Emit an error if the instance is not in the list
		ASSERT_MESSAGE(found != Selection().rend(), "selection-tracking error");

		Selection().erase(--found.base());
	}

	if (m_selectionChanged)
	{
		m_selectionChanged(selectable);
	}
}
예제 #19
0
파일: main.c 프로젝트: P1B2-3/P1-Program
int main (void) {
    int k,i,n,p,q,sum = 0,fitsum = 0,b = 0,percent;
    int **array;
    int data[RUNS];
    time_t t;
    Exam_block_t *****schema_data;
    double tempPercent;

    srand((unsigned) time(&t)); /* seeder vores random */


    tempPercent =  RUNS / 100;
    percent = (int)tempPercent;

    schema_data = MakeSchema();

    array = Make_2D_Array_int(SCHEMA_SIZE, 1000);

    for (i = 0; i < RUNS; i++) {

        if(i == 0) {
            fprintf(stderr,"                                                                   %i%%",i );
            b++;
        }

        else if(i % percent == 0 && i != 0) {
            fprintf(stderr,"\r                                                                   %i%%",b);
            b++;
        }

        else if(i % percent == 0 && b == 100 ) {
            fprintf(stderr,"\r                                                                   %i%%\n",b );
        }

        Length(schema_data, array);
        CalcFitnessOneGeneration(schema_data, array);


        Selection(schema_data);

        data[i] = fitsum / SCHEMA_SIZE;

    }
    ResultDataOut(data);
    ResultOut(schema_data);
    Free2DArray_int(array, SCHEMA_SIZE);

    Free5DArray(schema_data);


    return 0;
}
void SwitcherModel::Next()
{
  last_index_ = index_;

  index_++;
  if (index_ >= applications_.size())
    index_ = 0;

  detail_selection = false;
  detail_selection_index = 0;
  row_index_ = 0;
  selection_changed.emit(Selection());
}
예제 #21
0
int CItem_ScrollWin::WindowSelection()
{
	int ret;

	ret = Selection();
	if( ret == IF_LBDN ) 
	{
		g_chatManager->SetInputState( INPUT_INDEX_ITEM_SCROLL_WINDOW_ID, 1 );
		g_chatManager->ChangeInputMessage( INPUT_INDEX_ITEM_SCROLL_WINDOW_ID );
		return( IF_CTL_SELECT );
	}

	return IF_CTL_NONE;
}
예제 #22
0
void
TabView::MouseDown(BPoint where)
{
	BTab* fadeTab = TabAt(0);
	BRect fadeTabFrame(TabFrame(0));
	BTab* modulesTab = TabAt(1);
	BRect modulesTabFrame(TabFrame(1));
	ModulesView* modulesView = dynamic_cast<ModulesView*>(modulesTab->View());

	if (fadeTab != NULL && Selection() != 0 && fadeTabFrame.Contains(where)
		&& modulesView != NULL) {
		// clicked on the fade tab
		modulesView->SaveState();
		modulesView->_CloseSaver();
	} else if (modulesTab != NULL && Selection() != 1
		&& modulesTabFrame.Contains(where) && modulesView != NULL) {
		// clicked on the modules tab
		BMessage message(kMsgSaverSelected);
		modulesView->MessageReceived(&message);
	}

	BTabView::MouseDown(where);
}
void SwitcherModel::Select(unsigned int index)
{
  unsigned int target = CLAMP(index, 0, applications_.size() - 1);

  if (target != index_)
  {
    last_index_ = index_;
    index_ = target;

    detail_selection = false;
    detail_selection_index = 0;
    selection_changed.emit(Selection());
  }
}
void SwitcherModel::Prev()
{
  last_index_ = index_;

  if (index_ > 0)
    index_--;
  else
    index_ = applications_.size() - 1;

  detail_selection = false;
  detail_selection_index = 0;
  row_index_ = 0;
  selection_changed.emit(Selection());
}
	/** Call to start drag and drop, including capturing the mouse.
	OnBeginDrag() does this for you if TVS_DISABLEDRAGDROP is not set. If
	bSelect is VTRUE, the item will be selected first, which is the default.*/
	virtual void		BeginDragDrop(	HTREEITEM	hItemDrag = NULL,
										VBOOL		bSelect = VTRUE)
	{
		/* A drag drop op should not already be happening!*/
		VASSERT(!m_bDragging)

		/* Set flag, capture, and reset last drop target (just for safety).*/
		m_bDragging =		VTRUE;
		m_hLastDropTarget = NULL;
		SetCapture();

		if ( bSelect )
			Selection(ItemOrSelection(hItemDrag));
	}
//================================================
void DynamicalGraph::Update() {
  int previous_diversity = Diversity();

  AddOneSpecies();
  Selection();

  int current_diversity = Diversity();
  int extinction_size = previous_diversity + 1 - current_diversity;

  // calculate histograms
  extinction_histo.Add( extinction_size );

  diversity_histo.Add( current_diversity );
}
예제 #27
0
void
ControlsView::VolumeTabView::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case B_NODE_MONITOR:
			switch (message->FindInt32("opcode")) {
				case B_DEVICE_MOUNTED:
					_AddVolume(message->FindInt32("new device"));
					break;

				case B_DEVICE_UNMOUNTED:
					_RemoveVolume(message->FindInt32("device"));
					break;
			}
			break;

		case kBtnCancel:
		case kBtnRescan:
			ViewForTab(Selection())->MessageReceived(message);
			break;

		case B_SIMPLE_DATA:
		case B_REFS_RECEIVED:
		{
			entry_ref ref;

			for (int i = 0; message->FindRef("refs", i, &ref) == B_OK; i++) {
				BEntry entry(&ref, true);
				BPath path;
				entry.GetPath(&path);
				dev_t device = dev_for_path(path.Path());

				for (int j = 0; VolumeTab* item = (VolumeTab*)TabAt(j); j++) {
					if (item->Volume()->Device() == device) {
						Select(j);
						((VolumeView*)(item->View()))->SetPath(path);
						break;
					}
				}
			}
			break;
		}

		default:
			BTabView::MessageReceived(message);
			break;
	}
}
예제 #28
0
void
Algorithm<T>::Init(int pCountOfIndividuals, 
									 int pCountOfChromosomes,
						       const std::vector<T>& pAllPossibleIndividuals,
						       TaskDefinition<T>* pTask)
{
	if (!m_isInitialized) {
		assert (pAllPossibleIndividuals.size() != 0);
		assert (m_countOfIndividuals <= pAllPossibleIndividuals.size());
		m_countOfIndividuals = pCountOfIndividuals;
		m_countOfChromosomes = pCountOfChromosomes;
		m_allPossibleIndividuals = pAllPossibleIndividuals;
        m_task = pTask;
		
		// 1. Randomly initialize population.
		RandomInitPopulation();

		while (true) {
			// 2. Calculate fitness values.
			CalculateObjectiveFunction();

			// 3. Calculate fitness value. 
			CalculateFitnessValue();

			// 4. Calculate fitness probability.
			CalculateFitnessProbability();

			// 5. Calculate cumulative probability.
			CalculateCumulativeProbability();

			// 6. Selection
			Selection();

			// 7. Extract Parents
			ExtractParents();

			// 8. Crossover
			Crossover();

			// 9. Mutation
			Mutation();

		}
		m_isInitialized = true;
	} else {
		std::cout << "Algorithm is already initialized." << std::endl;
	}
}
예제 #29
0
파일: DtWorkArea.C 프로젝트: juddy/edcde
void DtWorkArea::NotifySelected(BaseUI *obj)
{
   Container::NotifySelected(obj);

   if (_mainW->UIClass() != MAIN_WINDOW)
      return;

   BaseUI **selection;
   int n_items;
   Selection(&n_items, &selection);
   if (n_items)
      _mainW->actionsMenu->UpdateActions(n_items, selection[0]);
   else
      _mainW->actionsMenu->UpdateActions(n_items, NULL);
   delete []selection;
}
예제 #30
0
boolean StringBrowser::LeftButtonDown (Event& e) {
    boolean status = false;

    if (DoubleClicked(e)) {
        subject->SetValue(done[0]);
        status = true;

    } else if (uniqueSel) {
        if (Selections() == 0) {
            Select(Locate(e.x, e.y));
        } else {
            Unselect(Selection());
            if (!e.shift) {
                Select(Locate(e.x, e.y));
            }
        }

    } else {
        lastdot = lastmark = Locate(e.x, e.y);

        if (Selected(lastdot) && e.shift) {
            Unselect(lastdot);
            do {
                ScrollToView(e.x, e.y);
                UpdateSelection(lastdot, Locate(e.x, e.y), Plain);
                Poll(e);
            } while (e.leftmouse);

        } else {
            if (!e.shift) {
                UnselectAll();
            }
            Select(lastdot);
            do {
                ScrollToView(e.x, e.y);
                UpdateSelection(lastdot, Locate(e.x, e.y), highlight);
                Poll(e);
            } while (e.leftmouse);
        }
    }
    Note(e);
    if (singleClick) {
        subject->SetValue(done[0]);
        status = true;
    }
    return status;
}