Пример #1
0
void Selection::Sort (GraphicView* views) {
/*
 * Note: this doesn't work if there are views in the selection from more than
 * one GraphicViews.
 */
    Iterator i;
    UList* cur;
    UList* newList = new UList;

    views->First(i);

    while (!views->Done(i) && !_ulist->IsEmpty()) {
        cur = _ulist->First();

        while (cur != _ulist->End()) {
            if (views->GetView(i) == View(cur)) {
                _ulist->Remove(cur);
                newList->Append(cur);
                break;
            } else {
                cur = cur->Next();
            }
        }
        views->Next(i);
    }
    if (!_ulist->IsEmpty()) {
        cerr << "warning: selection contained spurious element(s)\n";
    }
    delete _ulist;
    _ulist = newList;
}
Пример #2
0
void PostScriptView::ConstProcs (ostream& out) {
    UList* fonts = GetPSFonts();
    int nfonts = Count(fonts);

    out << "/IdrawDict " << (50 + nfonts) << " dict def\n";
    out << "IdrawDict begin\n\n";

    if (nfonts > 0) {
	for (const char** line = reencodeISO; *line != nil; ++line) {
	    out << *line << "\n";
	}

	for (UList* u = fonts->First(); u != fonts->End(); u = u->Next()) {
	    PSFont* font = GetFont(u);

	    // No way to check if the X font's encoding is iso8859-1, so...
	    if (strncmp(font->GetPrintFont(), "Symbol", 6) != 0) {
		out << "/" << font->GetPrintFont() << " reencodeISO def\n";
	    } else {
		out << "/" << font->GetPrintFont() << " dup findfont def\n";
	    }
	}
	out << "\n";
    }

    out << "/none null def\n";
    out << "/numGraphicParameters 17 def\n";
    out << "/stringLimit 65535 def\n\n";
}
Пример #3
0
static int Count (UList* list) {
    int i = 0;

    for (UList* u = list->First(); u != list->End(); u = u->Next()) {
        ++i;
    }
    return i;
}
Пример #4
0
static boolean Uncollected (const char* name, UList* fonts) {
    for (UList* u = fonts->First(); u != fonts->End(); u = u->Next()) {
        PSFont* font = (PSFont*) (*u)();

        if (strcmp(font->GetPrintFont(), name) == 0) {
            return false;
        }
    }
    return true;
}
Пример #5
0
OverlayView* OverlayComp::FindView (Viewer* viewer) {
    if (!_views) return nil;
    for (UList* u = _views->First(); u != _views->End(); u = u->Next()) {
	ComponentView* compview = View(u);
	if (compview->IsA(OVERLAY_VIEW) && 
	    ((OverlayView*)compview)->GetViewer() == viewer) 
	    return (OverlayView*)compview;
    }
    return nil;
}
Пример #6
0
UHashElem* UHashTable::Find (void* key) {
    int n = Hash(key);
    UList* slot = _slot[n];

    if (slot != nil) {
        for (UList* u = slot->First(); u != slot->End(); u = u->Next()) {
            UHashElem* elem = Elem(u);

            if (Equal(elem->GetKey(), key)) {
                return elem;
            }
        }
    }
    return nil;
}
Пример #7
0
Component* DrawIdrawComp::Copy () {
    DrawIdrawComp* comps = new DrawIdrawComp(GetPathName());
    if (attrlist()) comps->SetAttributeList(new AttributeList(attrlist()));
    Iterator i;
    First(i);
    while (!Done(i)) {
	comps->Append((GraphicComp*)GetComp(i)->Copy());
	Next(i);
    }
    for (UList* u = _graphedges->First(); u != _graphedges->End(); u = u->Next()) {
      EdgeComp* edgecomp = (EdgeComp*) (*u)();
      comps->AppendEdge(edgecomp);
    }
    return comps;
}
Пример #8
0
MultiLineObj* MultiLineObj::make_pts (const Coord* x, const Coord* y, int npts) {
    if (!_pts_by_n_enabled) {
        Coord *copyx, *copyy;
	ArrayDup(x, y, npts, copyx, copyy);
	MultiLineObj* mlo = new MultiLineObj(copyx, copyy, npts);
	mlo->_pts_made = 1;
	return mlo;
    }

    if (!_pts_by_n) {
	_pts_by_n = new UList*[_pts_by_n_size];
	for (int i=0; i<_pts_by_n_size; i++) 
	    _pts_by_n[i] = nil;
    }
    if (npts>=_pts_by_n_size) {
	int new_size = max(_pts_by_n_size*2, npts+1);
	UList** new_pts_by_n = new UList*[new_size];
	int i = 0;
	for (;i<_pts_by_n_size; i++) 
	    new_pts_by_n[i] = _pts_by_n[i];
	for (;i<new_size; i++) 
	    new_pts_by_n[i] = nil;
	delete _pts_by_n;
	_pts_by_n = new_pts_by_n;
	_pts_by_n_size = new_size;
    }

    if (_pts_by_n[npts]) {

	MultiLineObj temp_mlo((int*)x, (int*)y, npts);
	UList* ptr = _pts_by_n[npts]->First();
	while (ptr != _pts_by_n[npts]->End()) {
	    if (*(MultiLineObj*)(*ptr)() == temp_mlo) 
		return (MultiLineObj*)(*ptr)();
	    ptr = ptr->Next();
	}
    } else 
	_pts_by_n[npts] = new UList();
    
    Coord *copyx, *copyy;
    ArrayDup(x, y, npts, copyx, copyy);
    MultiLineObj* mlo = new MultiLineObj(copyx, copyy, npts);
    _pts_by_n[npts]->Append(mlo->_ulist = new UList(mlo));
    return mlo;
}
Пример #9
0
void OverlayComp::Interpret(Command* cmd) {
    Editor* ed = cmd->GetEditor();

    if (cmd->IsA(UNHIDE_VIEWS_CMD) || cmd->IsA(SENSITIZE_VIEWS_CMD)) {
	for (UList* u = _views->First(); u != _views->End(); u = u->Next()) {
	    ComponentView* compview = View(u);
	    if (compview->IsA(OVERLAY_VIEW)) {
		((OverlayView*)compview)->Sensitize();
		if (cmd->IsA(UNHIDE_VIEWS_CMD))
		  ((OverlayView*)compview)->Show();
	    }
	}
	Notify();
	
    } else {
      GraphicComp::Interpret(cmd);
    }
}
Пример #10
0
void UHashTable::Next (Iterator& i) {
    UHashElem* elem = GetElem(i);

    if (elem != nil) {
        int n = Hash(elem->GetKey());
        UList* u = UElem(i);
        u = u->Next();

        if (u == _slot[n]->End()) {
            for (int j = n+1; j < _nslots; ++j) {
                if (_slot[j] != nil) {
                    u = _slot[j]->First();
                    break;
                }
            }
        }
        i.SetValue(u);
    }
}
Пример #11
0
void Connector::Retransmit (Path* path) {
    if (path->Visited(this)) {
        return;
    }
    boolean forking = _cnxns->First() != _cnxns->Last(); // fork if > 1 cnxn
    path->Visit(this);
    
    for (UList* u = _cnxns->First(); u != _cnxns->End(); u = u->Next()) {
        Connector* peer = Conn(u);

        if (!path->Visited(peer)) {
            if (forking) {
                Path fork(path);
                Retransmit(peer, &fork);
            } else {
                Retransmit(peer, path);
            }
        }
    }
}
Пример #12
0
void PostScriptView::FontNames (ostream& out) {
    UList* fonts = GetPSFonts();
    const char* comment = "%%DocumentFonts:";
    int linelen = strlen(comment);
    out << comment;

    for (UList* u = fonts->First(); u != fonts->End(); u = u->Next()) {
	PSFont* font = GetFont(u);

	if (linelen + strlen(font->GetPrintFont()) + 2 <= MAXLINELEN) {
	    out << " ";
	    ++linelen;
	} else {
	    out << "\n%%+ ";
	    linelen = strlen("%%+ ");
	}
	out << font->GetPrintFont();
	linelen += strlen(font->GetPrintFont());
    }
    out << "\n";
}
Пример #13
0
void UHashTable::Unregister (void* key) {
    int n = Hash(key);
    UList* slot = _slot[n];

    if (slot != nil) {
        for (UList* u = slot->First(); u != slot->End(); u = u->Next()) {
            UHashElem* elem = Elem(u);

            if (Equal(elem->GetKey(), key)) {
                slot->Remove(u);
                delete elem;
                delete u;

		if (_slot[n]->IsEmpty()) {
		    delete _slot[n];
		    _slot[n] = nil;
		}
                break;
            }
        }
    }
}
Пример #14
0
void Component::Notify () {
    for (UList* u = _views->First(); u != _views->End(); u = u->Next()) {
	View(u)->Update();
    }
}
Пример #15
0
void StateVar::Notify () {
    for (UList* v = _views->First(); v != _views->End(); v = v->Next()) {
        view(v)->Update();
    }
}