コード例 #1
0
ファイル: taskbar.c プロジェクト: no0p/windowlab
void lclick_taskbutton(Client *old_c, Client *c)
{
	if (old_c != NULL)
	{
		if (old_c->was_hidden)
		{
			hide(old_c);
		}
	}

	if (c->hidden)
	{
		unhide(c);
	}
	else
	{
		if (c->was_hidden)
		{
			hide(c);
		}
		else
		{
			raise_lower(c);
		}
	}
	check_focus(c);
}
コード例 #2
0
void WidgetFilter::unhide(QWidget *w)
{
    foreach (QWidget *child, w->findChildren<QWidget *>())
        unhide(child);

    w->removeEventFilter(this);
    w->update();
}
コード例 #3
0
	QuarkUnhideListView::QuarkUnhideListView (const QuarkComponents_t& components,
			ViewManager *viewMgr, ICoreProxy_ptr proxy, QWidget *parent)
	: Util::UnhideListViewBase (proxy,
			[&components, &proxy, viewMgr] (QStandardItemModel *model)
			{
				for (const auto& comp : components)
				{
					std::unique_ptr<QuarkManager> qm;
					try
					{
						qm.reset (new QuarkManager (comp, viewMgr, proxy));
					}
					catch (const std::exception& e)
					{
						qWarning () << Q_FUNC_INFO
								<< "error creating manager for quark"
								<< comp->Url_;
						continue;
					}

					const auto& manifest = qm->GetManifest ();

					auto item = new QStandardItem;
					item->setData (manifest.GetID (), Util::UnhideListModel::Roles::ItemClass);
					item->setData (manifest.GetName (), Util::UnhideListModel::Roles::ItemName);
					item->setData (manifest.GetDescription (), Util::UnhideListModel::Roles::ItemDescription);
					item->setData (Util::GetAsBase64Src (manifest.GetIcon ().pixmap (32, 32).toImage ()),
							Util::UnhideListModel::Roles::ItemIcon);
					model->appendRow (item);
				}
			},
			parent)
	, ViewManager_ (viewMgr)
	{
		for (const auto& comp : components)
		{
			try
			{
				const auto& manager = std::make_shared<QuarkManager> (comp, ViewManager_, proxy);
				const auto& manifest = manager->GetManifest ();
				ID2Component_ [manifest.GetID ()] = { comp, manager };
			}
			catch (const std::exception& e)
			{
				qWarning () << Q_FUNC_INFO
						<< "skipping component"
						<< comp->Url_
						<< ":"
						<< e.what ();
			}
		}

		connect (rootObject (),
				SIGNAL (itemUnhideRequested (QString)),
				this,
				SLOT (unhide (QString)),
				Qt::QueuedConnection);
	}
コード例 #4
0
ファイル: mainTrackerUI.cpp プロジェクト: aaronwhitesell/Moka
void MainTrackerUI::handleEvent(const trmb::Event &gameEvent)
{
	// ALW - Currently, fullscreen and windowed mode are the same.
	if (mFullscreen == gameEvent.getType() || mWindowed == gameEvent.getType())
	{
		repositionGUI();
	}
	else if (mBeginSimulationEvent == gameEvent.getType())
	{
		unhide();
	}
	else if (mBeginScoreboardEvent == gameEvent.getType())
	{
		hide();
	}
}
コード例 #5
0
	TabUnhideListView::TabUnhideListView (const QList<TabClassInfo>& tcs, ICoreProxy_ptr proxy, QWidget *parent)
	: QDeclarativeView (parent)
	, Model_ (new UnhideListModel (this))
	{
		new Util::UnhoverDeleteMixin (this);

		const auto& file = Util::GetSysPath (Util::SysPath::QML, "sb2", "TabUnhideListView.qml");
		if (file.isEmpty ())
		{
			qWarning () << Q_FUNC_INFO
					<< "file not found";
			deleteLater ();
			return;
		}

		setStyleSheet ("background: transparent");
		setWindowFlags (Qt::ToolTip);
		setAttribute (Qt::WA_TranslucentBackground);

		rootContext ()->setContextProperty ("unhideListModel", Model_);
		rootContext ()->setContextProperty ("colorProxy",
				new Util::ColorThemeProxy (proxy->GetColorThemeManager (), this));
		engine ()->addImageProvider ("ThemeIcons", new ThemeImageProvider (proxy));
		setSource (QUrl::fromLocalFile (file));

		for (const auto& tc : tcs)
		{
			auto item = new QStandardItem;
			item->setData (tc.TabClass_, UnhideListModel::Roles::TabClass);
			item->setData (tc.VisibleName_, UnhideListModel::Roles::TabName);
			item->setData (tc.Description_, UnhideListModel::Roles::TabDescription);
			item->setData (Util::GetAsBase64Src (tc.Icon_.pixmap (32, 32).toImage ()),
					UnhideListModel::Roles::TabIcon);
			Model_->appendRow (item);
		}

		connect (rootObject (),
				SIGNAL (closeRequested ()),
				this,
				SLOT (deleteLater ()));
		connect (rootObject (),
				SIGNAL (tabUnhideRequested (QString)),
				this,
				SLOT (unhide (QString)),
				Qt::QueuedConnection);
	}
コード例 #6
0
ファイル: client.c プロジェクト: mitake/mysevilwm
void remove_client(Client *c, int from_cleanup)
{
	Client *p = NULL;

	XGrabServer(dpy);
	XSetErrorHandler(ignore_xerror);

	if (c->name && c->name != null_str)
		XFree(c->name);

	if (from_cleanup)
		unhide(c, NO_RAISE);
	else if (!from_cleanup)
		set_wm_state(c, WithdrawnState);

	ungravitate(c);
	XReparentWindow(dpy, c->window, root, c->x, c->y);
	XRemoveFromSaveSet(dpy, c->window);
	XSetWindowBorderWidth(dpy, c->window, 1);

	XDestroyWindow(dpy, c->parent);

	if (head_client == c)
		head_client = c->next;
	else {
		for (p = head_client; p && p->next; p = p->next)
			if (p->next == c) p->next = c->next;
	}

	if (c->size)
		XFree(c->size);

	/* an enter event should set this up again */
	if (c == current) {
		current = NULL;
		if (prev_focused[c->vdesk] == c)
			prev_focused[c->vdesk] = NULL;
	}

	free(c);

	XSync(dpy, False);
	XSetErrorHandler(handle_xerror);
	XUngrabServer(dpy);
}
コード例 #7
0
	QuarkUnhideListView::QuarkUnhideListView (const QuarkComponents_t& components,
			ViewManager *viewMgr, ICoreProxy_ptr proxy, QWidget *parent)
	: Util::UnhideListViewBase (proxy, parent)
	, ViewManager_ (viewMgr)
	{
		QList<QStandardItem*> items;
		for (const auto& comp : components)
		{
			QuarkManager_ptr manager;
			try
			{
				manager.reset (new QuarkManager (comp, ViewManager_, proxy));
			}
			catch (const std::exception& e)
			{
				qWarning () << Q_FUNC_INFO
						<< "error creating manager for quark"
						<< comp->Url_;
				continue;
			}

			const auto& manifest = manager->GetManifest ();

			auto item = new QStandardItem;

			item->setData (manifest.GetID (), Util::UnhideListModel::Roles::ItemClass);
			item->setData (manifest.GetName (), Util::UnhideListModel::Roles::ItemName);
			item->setData (manifest.GetDescription (), Util::UnhideListModel::Roles::ItemDescription);
			item->setData (Util::GetAsBase64Src (manifest.GetIcon ().pixmap (32, 32).toImage ()),
					Util::UnhideListModel::Roles::ItemIcon);
			items << item;

			ID2Component_ [manifest.GetID ()] = { comp, manager };
		}

		Model_->invisibleRootItem ()->appendRows (items);

		connect (rootObject (),
				SIGNAL (itemUnhideRequested (QString)),
				this,
				SLOT (unhide (QString)),
				Qt::QueuedConnection);
	}
コード例 #8
0
ファイル: Client.C プロジェクト: nic0lae/freebsddistro
void Client::release()
{
    // assume wm called for this, and will remove me from its list itself

//    fprintf(stderr, "deleting client %p\n",this);

    if (m_window == None) {
	fprintf(stderr,
		"wm2: invalid parent in Client::release (released twice?)\n");
    }

    windowManager()->skipInRevert(this, m_revert);

//    fprintf(stderr, "deleting %lx\n",m_window);

    if (isHidden()) unhide(False);

    delete m_border;
    m_window = None;

    if (isActive()) {
	if (CONFIG_CLICK_TO_FOCUS) {
	    if (m_revert) {
		windowManager()->setActiveClient(m_revert);
		m_revert->activate();
	    } else windowManager()->setActiveClient(0);// windowManager()->clearFocus();
	} else {
	    windowManager()->setActiveClient(0);
	}
    }

    if (m_colormapWinCount > 0) {
	XFree((char *)m_colormapWindows);
	free((char *)m_windowColormaps); // not allocated through X
    }

    if (m_iconName) XFree(m_iconName);
    if (m_name)     XFree(m_name);
    if (m_label) free((void *)m_label);

    delete this;
}
コード例 #9
0
	TabUnhideListView::TabUnhideListView (const QList<TabClassInfo>& tcs,
			ICoreProxy_ptr proxy, QWidget *parent)
	: UnhideListViewBase (proxy, parent)
	{
		QList<QStandardItem*> items;
		for (const auto& tc : tcs)
		{
			auto item = new QStandardItem;
			item->setData (tc.TabClass_, Util::UnhideListModel::Roles::ItemClass);
			item->setData (tc.VisibleName_, Util::UnhideListModel::Roles::ItemName);
			item->setData (tc.Description_, Util::UnhideListModel::Roles::ItemDescription);
			item->setData (Util::GetAsBase64Src (tc.Icon_.pixmap (32, 32).toImage ()),
					Util::UnhideListModel::Roles::ItemIcon);
			items << item;
		}
		Model_->invisibleRootItem ()->appendRows (items);

		connect (rootObject (),
				SIGNAL (itemUnhideRequested (QString)),
				this,
				SLOT (unhide (QString)),
				Qt::QueuedConnection);
	}
コード例 #10
0
bool ContentsModel::setData(const QModelIndex &index, const QVariant &value, int role)
{
	if (index.column() == ColumnCheck && role == Qt::CheckStateRole) {
		if (model_->elements()[index.row()]->line_type() == 0)
			return false;
		
		int checkstate = value.toInt();

		if (checkstate == Qt::Unchecked) {
			checkTable_->remove(index.row());
			emit unhide(index);
		} else if (checkstate == Qt::Checked) {
			checkTable_->insert(index.row());
			emit hide(index);
		}

		emit dataChanged(index, ContentsModel::index(index.row(), ColumnCount - 1));
		
		return true;
	}

	return false;
}
コード例 #11
0
ファイル: creature.cpp プロジェクト: RealmsMud/RealmsCode
bool Creature::doFlee(bool magicTerror) {
    Monster* mThis = getAsMonster();
    Player* pThis = getAsPlayer();
    BaseRoom* oldRoom = getRoomParent(), *newRoom=0;
    UniqueRoom* uRoom=0;

    Exit*   exit=0;
    unsigned int n=0;

    if(isEffected("fear"))
        magicTerror = true;

    exit = getFleeableExit();
    if(!exit) {
        printColor("You couldn't find any place to run to!\n");
        if(pThis)
            pThis->setFleeing(false);
        return(0);
    }

    newRoom = getFleeableRoom(exit);
    if(!newRoom) {
        printColor("You failed to escape!\n");
        return(0);
    }


    switch(mrand(1,10)) {
    case 1:
        print("You run like a chicken.\n");
        break;
    case 2:
        print("You flee in terror.\n");
        break;
    case 3:
        print("You run screaming in horror.\n");
        break;
    case 4:
        print("You flee aimlessly in any direction you can.\n");
        break;
    case 5:
        print("You run screaming for your mommy.\n");
        break;
    case 6:
        print("You run as your life flashes before your eyes.\n");
        break;
    case 7:
        print("Your heart throbs as you attempt to escape death.\n");
        break;
    case 8:
        print("Colors and sounds mingle as you frantically flee.\n");
        break;
    case 9:
        print("Fear of death grips you as you flee in panic.\n");
        break;
    case 10:
        print("You run like a coward.\n");
        break;
    default:
        print("You run like a chicken.\n");
        break;
    }


    broadcast(getSock(), oldRoom, "%M flees to the %s^x.", this, exit->getCName());
    if(mThis) {
        mThis->diePermCrt();
        if(exit->doEffectDamage(this))
            return(2);
        mThis->deleteFromRoom();
        mThis->addToRoom(newRoom);
    } else if(pThis) {
        pThis->dropWeapons();
        pThis->checkDarkness();
        unhide();

        if(magicTerror)
            printColor("^rYou flee from unnatural fear!\n");

        Move::track(getUniqueRoomParent(), &currentLocation.mapmarker, exit, pThis, false);

        if(pThis->flagIsSet(P_ALIASING)) {
            pThis->getAlias()->deleteFromRoom();
            pThis->getAlias()->addToRoom(newRoom);
        }

        Move::update(pThis);
        pThis->statistics.flee();

        if(cClass == CreatureClass::PALADIN && deity != GRADIUS && !magicTerror && level >= 10) {
            n = level * 8;
            n = MIN<long>(experience, n);
            print("You lose %d experience for your cowardly retreat.\n", n);
            experience -= n;
        }

        if(exit->doEffectDamage(this))
            return(2);
        pThis->deleteFromRoom();
        pThis->addToRoom(newRoom);

        for(Monster* pet : pThis->pets) {
            if(pet && inSameRoom(pThis))
                broadcast(getSock(), oldRoom, "%M flees to the %s^x with its master.", pet, exit->getCName());
        }
    }
    exit->checkReLock(this, false);

    broadcast(getSock(), newRoom, "%M just fled rapidly into the room.", this);

    if(pThis) {

        pThis->doPetFollow();
        uRoom = newRoom->getAsUniqueRoom();
        if(uRoom)
            pThis->checkTraps(uRoom);


        if(Move::usePortal(pThis, oldRoom, exit))
            Move::deletePortal(oldRoom, exit);
    }

    return(1);
}
コード例 #12
0
ファイル: cursor32.cpp プロジェクト: fedor4ever/scummvm
void GfxCursor32::setView(const GuiResourceId viewId, const int16 loopNo, const int16 celNo) {
    hide();

    _cursorInfo.resourceId = viewId;
    _cursorInfo.loopNo = loopNo;
    _cursorInfo.celNo = celNo;

    if (_macCursorRemap.empty() && viewId != -1) {
        CelObjView view(viewId, loopNo, celNo);

        _hotSpot = view._displace;
        _width = view._width;
        _height = view._height;

        // SSCI never increased the size of cursors, but some of the cursors
        // in early SCI32 games were designed for low-resolution display mode
        // and so are kind of hard to pick out when running in high-resolution
        // mode.
        // To address this, we make some slight adjustments to cursor display
        // in these early games:
        // GK1: All the cursors are increased in size since they all appear to
        //      be designed for low-res display.
        // PQ4: We only make the cursors bigger if they are above a set
        //      threshold size because inventory items usually have a
        //      high-resolution cursor representation.
        bool pixelDouble = false;
        if (g_sci->_gfxFrameout->_isHiRes &&
                (g_sci->getGameId() == GID_GK1 ||
                 (g_sci->getGameId() == GID_PQ4 && _width <= 22 && _height <= 22))) {

            _width *= 2;
            _height *= 2;
            _hotSpot.x *= 2;
            _hotSpot.y *= 2;
            pixelDouble = true;
        }

        _cursor.data = (byte *)realloc(_cursor.data, _width * _height);
        _cursor.rect = Common::Rect(_width, _height);
        memset(_cursor.data, 255, _width * _height);
        _cursor.skipColor = 255;

        Buffer target(_width, _height, _cursor.data);
        if (pixelDouble) {
            view.draw(target, _cursor.rect, Common::Point(0, 0), false, 2, 2);
        } else {
            view.draw(target, _cursor.rect, Common::Point(0, 0), false);
        }
    } else if (!_macCursorRemap.empty() && viewId != -1) {
        // Mac cursor handling
        GuiResourceId viewNum = viewId;

        // Remap cursor view based on what the scripts have given us.
        for (uint32 i = 0; i < _macCursorRemap.size(); i++) {
            if (viewNum == _macCursorRemap[i]) {
                viewNum = (i + 1) * 0x100 + loopNo * 0x10 + celNo;
                break;
            }

            if (i == _macCursorRemap.size())
                error("Unmatched Mac cursor %d", viewNum);
        }

        _cursorInfo.resourceId = viewNum;

        Resource *resource = g_sci->getResMan()->findResource(ResourceId(kResourceTypeCursor, viewNum), false);

        if (!resource) {
            // The cursor resources often don't exist, this is normal behavior
            debug(0, "Mac cursor %d not found", viewNum);
            return;
        }
        Common::MemoryReadStream resStream(resource->data, resource->size);
        Graphics::MacCursor *macCursor = new Graphics::MacCursor();

        if (!macCursor->readFromStream(resStream)) {
            warning("Failed to load Mac cursor %d", viewNum);
            delete macCursor;
            return;
        }

        _hotSpot = Common::Point(macCursor->getHotspotX(), macCursor->getHotspotY());
        _width = macCursor->getWidth();
        _height = macCursor->getHeight();

        _cursor.data = (byte *)realloc(_cursor.data, _width * _height);
        memcpy(_cursor.data, macCursor->getSurface(), _width * _height);
        _cursor.rect = Common::Rect(_width, _height);
        _cursor.skipColor = macCursor->getKeyColor();

        // The cursor will be drawn on next refresh
        delete macCursor;
    } else {
        _hotSpot = Common::Point(0, 0);
        _width = _height = 1;
        _cursor.data = (byte *)realloc(_cursor.data, _width * _height);
        _cursor.rect = Common::Rect(_width, _height);
        *_cursor.data = _cursor.skipColor;
        _cursorBack.rect = _cursor.rect;
        _cursorBack.rect.clip(_vmapRegion.rect);
        if (!_cursorBack.rect.isEmpty()) {
            readVideo(_cursorBack);
        }
    }

    _cursorBack.data = (byte *)realloc(_cursorBack.data, _width * _height);
    _drawBuff1.data = (byte *)realloc(_drawBuff1.data, _width * _height);
    _drawBuff2.data = (byte *)realloc(_drawBuff2.data, _width * _height * 4);
    _savedVmapRegion.data = (byte *)realloc(_savedVmapRegion.data, _width * _height);

    unhide();
}
コード例 #13
0
ファイル: menu.c プロジェクト: tiago4orion/plan9port
void
button(XButtonEvent *e)
{
    int n, shift;
    Client *c;
    Window dw;
    ScreenInfo *s;

    curtime = e->time;
    s = getscreen(e->root);
    if(s == 0)
        return;
    c = getclient(e->window, 0);
    if(c) {
        if(debug) fprintf(stderr, "but: e x=%d y=%d c x=%d y=%d dx=%d dy=%d BORDR %d\n",
                              e->x, e->y, c->x, c->y, c->dx, c->dy, BORDER);
        if(borderorient(c, e->x, e->y) != BorderUnknown) {
            switch (e->button) {
            case Button1:
            case Button2:
                reshape(c, e->button, pull, e);
                return;
            case Button3:
                move(c, Button3);
                return;
            default:
                return;
            }
        }
        e->x += c->x - BORDER;
        e->y += c->y - BORDER;
    } else if(e->window != e->root) {
        if(debug) fprintf(stderr, "but no client: e x=%d y=%d\n",
                              e->x, e->y);
        XTranslateCoordinates(dpy, e->window, s->root, e->x, e->y,
                              &e->x, &e->y, &dw);
    }
    switch (e->button) {
    case Button1:
        if(c) {
            XMapRaised(dpy, c->parent);
            top(c);
            active(c);
        }
        return;
    case Button2:
        if(c) {
            XMapRaised(dpy, c->parent);
            active(c);
            XAllowEvents (dpy, ReplayPointer, curtime);
        } else if((e->state&(ShiftMask|ControlMask))==(ShiftMask|ControlMask)) {
            menuhit(e, &egg);
        } else if(numvirtuals > 1 && (n = menuhit(e, &b2menu)) > -1)
            button2(n);
        return;
    case Button3:
        break;
    case Button4:
        /* scroll up changes to previous virtual screen */
        if(!c && e->type == ButtonPress)
            if(numvirtuals > 1 && virt > 0)
                switch_to(virt - 1);
        return;
    case Button5:
        /* scroll down changes to next virtual screen */
        if(!c && e->type == ButtonPress)
            if(numvirtuals > 1 && virt < numvirtuals - 1)
                switch_to(virt + 1);
        return;
    default:
        return;
    }

    if(current && current->screen == s)
        cmapnofocus(s);
    switch (n = menuhit(e, &b3menu)) {
    case New:
        spawn(s, termFn);
        break;
    case Acme:
        spawn(s, editorFn);
        break;
    case Launcher:
        spawn(s, launcherFn);
        break;
    case Reshape:
        reshape(selectwin(1, 0, s), Button3, sweep, 0);
        break;
    case Move:
        move(selectwin(0, 0, s), Button3);
        break;
    case Delete:
        shift = 0;
        c = selectwin(1, &shift, s);
        delete(c, shift);
        break;
    case Hide:
        hide(selectwin(1, 0, s));
        break;
    default:	/* unhide window */
        unhide(n - B3FIXED, 1);
        break;
    case -1:	/* nothing */
        break;
    }
    if(current && current->screen == s)
        cmapfocus(current);
}
コード例 #14
0
ファイル: menu.c プロジェクト: nealey/9wm
void
button(XButtonEvent * e)
{
	int n, shift;
	Client *c;
	Window dw;
	ScreenInfo *s;

	curtime = e->time;
	s = getscreen(e->root);
	if (s == 0)
		return;
	c = getclient(e->window, 0);
	if (c) {
		e->x += c->x - BORDER + 1;
		e->y += c->y - BORDER + 1;
	} else if (e->window != e->root)
		XTranslateCoordinates(dpy, e->window, s->root, e->x, e->y, &e->x, &e->y, &dw);
	switch (e->button) {
	case Button1:
		if (c) {
			XMapRaised(dpy, c->parent);
			top(c);
			active(c);
		}
		return;
	case Button2:
		if ((e->state & (ShiftMask | ControlMask)) == (ShiftMask | ControlMask)) {
			menuhit(e, &egg);
		} else {
			spawn(s, "9wm-mm");
		}
		return;
	default:
		return;
	case Button3:
		break;
	}

	if (current && current->screen == s)
		cmapnofocus(s);
	switch (n = menuhit(e, &b3menu)) {
	case 0:		/* New */
		spawn(s, termprog);
		break;
	case 1:		/* Reshape */
		reshape(selectwin(1, 0, s));
		break;
	case 2:		/* Move */
		move(selectwin(0, 0, s));
		break;
	case 3:		/* Delete */
		shift = 0;
		c = selectwin(1, &shift, s);
		delete(c, shift);
		break;
	case 4:		/* Hide */
		hide(selectwin(1, 0, s));
		break;
	default:		/* unhide window */
		unhide(n - B3FIXED, 1);
		break;
	case -1:		/* nothing */
		break;
	}
	if (current && current->screen == s)
		cmapfocus(current);
}
コード例 #15
0
void WidgetFilter::unhide()
{
    QObject *s = sender();
    if (s->isWidgetType())
        unhide(qobject_cast<QWidget*>(s));
}
コード例 #16
0
ファイル: view.c プロジェクト: dancrossnyc/harvey
void
viewer(Document *dd)
{
	int i, fd, n, oldpage;
	int nxt;
	Menu menu, midmenu;
	Mouse m;
	Event e;
	Point dxy, oxy, xy0;
	Image *tmp;

	static char *fwditems[] = { "this page", "next page", "exit", 0 };
 	static char *miditems[] = {
 		"orig size",
 		"zoom in",
 		"fit window",
 		"rotate 90",
 		"upside down",
 		"",
 		"next",
 		"prev",
		"zerox",
 		"",
 		"reverse",
 		"discard",
 		"write",
 		"",
 		"quit",
 		0
 	};
	char *s;
	enum { Eplumb = 4 };
	Plumbmsg *pm;

	doc = dd;    /* save global for menuhit */
	ul = screen->r.min;
	einit(Emouse|Ekeyboard);
	if(doc->addpage != nil)
		eplumb(Eplumb, "image");

	esetcursor(&reading);

	/*
	 * im is a global pointer to the current image.
	 * eventually, i think we will have a layer between
	 * the display routines and the ps/pdf/whatever routines
	 * to perhaps cache and handle images of different
	 * sizes, etc.
	 */
	im = 0;
	page = reverse ? doc->npage-1 : 0;

	if(doc->fwdonly) {
		menu.item = fwditems;
		menu.gen = 0;
		menu.lasthit = 0;
	} else {
		menu.item = 0;
		menu.gen = menugen;
		menu.lasthit = 0;
	}

	midmenu.item = miditems;
	midmenu.gen = 0;
	midmenu.lasthit = Next;

	if(doc->docname != nil)
		setlabel(doc->docname);
	showpage(page, &menu);
	esetcursor(nil);

	nxt = 0;
	for(;;) {
		/*
		 * throughout, if doc->fwdonly is set, we restrict the functionality
		 * a fair amount.  we don't care about doc->npage anymore, and
		 * all that can be done is select the next page.
		 */
		unlockdisplay(display);
		i = eread(Emouse|Ekeyboard|Eplumb, &e);
		lockdisplay(display);
		switch(i){
		case Ekeyboard:
			if(e.kbdc <= 0xFF && isdigit(e.kbdc)) {
				nxt = nxt*10+e.kbdc-'0';
				break;
			} else if(e.kbdc != '\n')
				nxt = 0;
			switch(e.kbdc) {
			case 'r':	/* reverse page order */
				if(doc->fwdonly)
					break;
				reverse = !reverse;
				menu.lasthit = doc->npage-1-menu.lasthit;

				/*
				 * the theory is that if we are reversing the
				 * document order and are on the first or last
				 * page then we're just starting and really want
		 	 	 * to view the other end.  maybe the if
				 * should be dropped and this should happen always.
				 */
				if(page == 0 || page == doc->npage-1) {
					page = doc->npage-1-page;
					showpage(page, &menu);
				}
				break;
			case 'w':	/* write bitmap of current screen */
				esetcursor(&reading);
				s = writebitmap();
				if(s)
					string(screen, addpt(screen->r.min, Pt(5,5)), display->black, ZP,
						display->defaultfont, s);
				esetcursor(nil);
				flushimage(display, 1);
				break;
			case 'd':	/* remove image from working set */
				if(doc->rmpage && page < doc->npage) {
					if(doc->rmpage(doc, page) >= 0) {
						if(doc->npage < 0)
							wexits(0);
						if(page >= doc->npage)
							page = doc->npage-1;
						showpage(page, &menu);
					}
				}
				break;
			case 'q':
			case 0x04: /* ctrl-d */
				wexits(0);
			case 'u':
				if(im==nil)
					break;
				angle = (angle+180) % 360;
				showpage(page, &menu);
				break;
			case '-':
			case '\b':
			case Kleft:
				if(page > 0 && !doc->fwdonly) {
					--page;
					showpage(page, &menu);
				}
				break;
			case '\n':
				if(nxt) {
					nxt--;
					if(nxt >= 0 && nxt < doc->npage && !doc->fwdonly)
						showpage(page=nxt, &menu);
					nxt = 0;
					break;
				}
				goto Gotonext;
			case Kright:
			case ' ':
			Gotonext:
				if(doc->npage && ++page >= doc->npage && !doc->fwdonly)
					wexits(0);
				showpage(page, &menu);
				break;

			/*
			 * The upper y coordinate of the image is at ul.y in screen->r.
			 * Panning up means moving the upper left corner down.  If the
			 * upper left corner is currently visible, we need to go back a page.
			 */
			case Kup:
				if(screen->r.min.y <= ul.y && ul.y < screen->r.max.y){
					if(page > 0 && !doc->fwdonly){
						--page;
						showbottom = 1;
						showpage(page, &menu);
					}
				} else {
					i = Dy(screen->r)/2;
					if(i > 10)
						i -= 10;
					if(i+ul.y > screen->r.min.y)
						i = screen->r.min.y - ul.y;
					translate(Pt(0, i));
				}
				break;

			/*
			 * If the lower y coordinate is on the screen, we go to the next page.
			 * The lower y coordinate is at ul.y + Dy(im->r).
			 */
			case Kdown:
				i = ul.y + Dy(im->r);
				if(screen->r.min.y <= i && i <= screen->r.max.y){
					ul.y = screen->r.min.y;
					goto Gotonext;
				} else {
					i = -Dy(screen->r)/2;
					if(i < -10)
						i += 10;
					if(i+ul.y+Dy(im->r) <= screen->r.max.y)
						i = screen->r.max.y - Dy(im->r) - ul.y - 1;
					translate(Pt(0, i));
				}
				break;
			default:
				esetcursor(&query);
				sleep(1000);
				esetcursor(nil);
				break;
			}
			break;

		case Emouse:
			m = e.mouse;
			switch(m.buttons){
			case Left:
				oxy = m.xy;
				xy0 = oxy;
				do {
					dxy = subpt(m.xy, oxy);
					oxy = m.xy;
					translate(dxy);
					unlockdisplay(display);
					m = emouse();
					lockdisplay(display);
				} while(m.buttons == Left);
				if(m.buttons) {
					dxy = subpt(xy0, oxy);
					translate(dxy);
				}
				break;

			case Middle:
				if(doc->npage == 0)
					break;

				unlockdisplay(display);
				n = emenuhit(Middle, &m, &midmenu);
				lockdisplay(display);
				if(n == -1)
					break;
				switch(n){
				case Next: 	/* next */
					if(reverse)
						page--;
					else
						page++;
					if(page < 0) {
						if(reverse) return;
						else page = 0;
					}

					if((page >= doc->npage) && !doc->fwdonly)
						return;

					showpage(page, &menu);
					nxt = 0;
					break;
				case Prev:	/* prev */
					if(reverse)
						page++;
					else
						page--;
					if(page < 0) {
						if(reverse) return;
						else page = 0;
					}

					if((page >= doc->npage) && !doc->fwdonly && !reverse)
						return;

					showpage(page, &menu);
					nxt = 0;
					break;
				case Zerox:	/* prev */
					zerox();
					break;
				case Zin:	/* zoom in */
					{
						double delta;
						Rectangle r;

						r = egetrect(Middle, &m);
						if((rectclip(&r, rectaddpt(im->r, ul)) == 0) ||
							Dx(r) == 0 || Dy(r) == 0)
							break;
						/* use the smaller side to expand */
						if(Dx(r) < Dy(r))
							delta = (double)Dx(im->r)/(double)Dx(r);
						else
							delta = (double)Dy(im->r)/(double)Dy(r);

						esetcursor(&reading);
						tmp = xallocimage(display,
								Rect(0, 0, (int)((double)Dx(im->r)*delta), (int)((double)Dy(im->r)*delta)),
								im->chan, 0, DBlack);
						if(tmp == nil) {
							fprint(2, "out of memory during zoom: %r\n");
							wexits("memory");
						}
						resample(im, tmp);
						im = tmp;
						delayfreeimage(tmp);
						esetcursor(nil);
						ul = screen->r.min;
						redraw(screen);
						flushimage(display, 1);
						break;
					}
				case Fit:	/* fit */
					{
						double delta;
						Rectangle r;

						delta = (double)Dx(screen->r)/(double)Dx(im->r);
						if((double)Dy(im->r)*delta > Dy(screen->r))
							delta = (double)Dy(screen->r)/(double)Dy(im->r);

						r = Rect(0, 0, (int)((double)Dx(im->r)*delta), (int)((double)Dy(im->r)*delta));
						esetcursor(&reading);
						tmp = xallocimage(display, r, im->chan, 0, DBlack);
						if(tmp == nil) {
							fprint(2, "out of memory during fit: %r\n");
							wexits("memory");
						}
						resample(im, tmp);
						im = tmp;
						delayfreeimage(tmp);
						esetcursor(nil);
						ul = screen->r.min;
						redraw(screen);
						flushimage(display, 1);
						break;
					}
				case Rot:	/* rotate 90 */
					angle = (angle+90) % 360;
					showpage(page, &menu);
					break;
				case Upside: 	/* upside-down */
					angle = (angle+180) % 360;
					showpage(page, &menu);
					break;
				case Restore:	/* restore */
					showpage(page, &menu);
					break;
				case Reverse:	/* reverse */
					if(doc->fwdonly)
						break;
					reverse = !reverse;
					menu.lasthit = doc->npage-1-menu.lasthit;

					if(page == 0 || page == doc->npage-1) {
						page = doc->npage-1-page;
						showpage(page, &menu);
					}
					break;
				case Write: /* write */
					esetcursor(&reading);
					s = writebitmap();
					if(s)
						string(screen, addpt(screen->r.min, Pt(5,5)), display->black, ZP,
							display->defaultfont, s);
					esetcursor(nil);
					flushimage(display, 1);
					break;
				case Del: /* delete */
					if(doc->rmpage && page < doc->npage) {
						if(doc->rmpage(doc, page) >= 0) {
							if(doc->npage < 0)
								wexits(0);
							if(page >= doc->npage)
								page = doc->npage-1;
							showpage(page, &menu);
						}
					}
					break;
				case Exit:	/* exit */
					return;
				case Empty1:
				case Empty2:
				case Empty3:
					break;

				};



			case Right:
				if(doc->npage == 0)
					break;

				oldpage = page;
				unlockdisplay(display);
				n = emenuhit(RMenu, &m, &menu);
				lockdisplay(display);
				if(n == -1)
					break;

				if(doc->fwdonly) {
					switch(n){
					case 0:	/* this page */
						break;
					case 1:	/* next page */
						showpage(++page, &menu);
						break;
					case 2:	/* exit */
						return;
					}
					break;
				}

				if(n == doc->npage)
					return;
				else
					page = reverse ? doc->npage-1-n : n;

				if(oldpage != page)
					showpage(page, &menu);
				nxt = 0;
				break;
			}
			break;

		case Eplumb:
			pm = e.v;
			if(pm->ndata <= 0){
				plumbfree(pm);
				break;
			}
			if(plumbquit(pm))
				exits(nil);
			if(showdata(pm)) {
				s = estrdup("/tmp/pageplumbXXXXXXX");
				fd = opentemp(s);
				write(fd, pm->data, pm->ndata);
				/* lose fd reference on purpose; the file is open ORCLOSE */
			} else if(pm->data[0] == '/') {
				s = estrdup(pm->data);
			} else {
				s = emalloc(strlen(pm->wdir)+1+pm->ndata+1);
				sprint(s, "%s/%s", pm->wdir, pm->data);
				cleanname(s);
			}
			if((i = doc->addpage(doc, s)) >= 0) {
				page = i;
				unhide();
				showpage(page, &menu);
			}
			free(s);
			plumbfree(pm);
			break;
		}
	}
}
コード例 #17
0
ファイル: decyprt.c プロジェクト: DamiaX/Crypt-decrypt
int main(int argc, char *argv[])
{
  unhide(argv[1]);
  printf (argv[1]);
 }