GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
MAP_VIEW(3) FreeBSD Library Functions Manual MAP_VIEW(3)

MAP_Vieweditor and display widget for Agar-MAP maps

#include <agar/core.h>
#include <agar/map.h>

The MAP_View widget renders the contents of a MAP(3) to the display. MAP_View also provides a map editor with an extensible set of map edition tools.

MAP_View *
(void *parent, MAP *map, Uint flags, AG_Toolbar *toolbar, AG_Statusbar *statbar);


void
(MAP_View *mv, int w, int h);


void
(MAP_View *mv, Uint zoom, int adj_offs);

The () function allocates, initializes, and attaches a MAP_View widget, displaying the given map. The flags may include:

MAP_VIEW_EDIT
Enable map edition tools.
MAP_VIEW_GRID
Display the standard tile grid.
MAP_VIEW_CENTER
When the widget is attached to a new map, center on its origin.
MAP_VIEW_NO_CURSOR
Disable the edition cursor.
MAP_VIEW_NO_BMPSCALE
Disable bitmap scaling on zoom.
MAP_VIEW_NO_BG
Disable background tiling.
MAP_VIEW_NO_NODESEL
Disable node selection functions.
MAP_VIEW_SHOW_ORIGIN
Draw a circle at the origin.

If toolbar is not NULL, the MAP_View will automatically create buttons in it for each tool registered with (). If statbar is not NULL, it will be used to display status information.

The () function arranges for the MAP_View to reserve enough space to display w by h nodes at the initial sizing stage.

The () function sets the scaling factor to zoom, given in % of the default tile geometry. If the adj_offs argument is nonzero, the camera is offset to preserve centering.

void
MAP_ViewSetSelection(MAP_View *mv, int x, int y, int w, int h);


int
(MAP_View *mv, int *x, int *y, int *w, int *h);

The () function sets the active selection to w by h nodes at map position x, y. MAP_ViewSetSelection() also disables any mouse selection in progress.

The () returns 1 if there is an active selection or 0 if there is none. If there is no selection, no value is written to x, y, w and h.

void
MAP_ViewRegTool(MAP_View *mv, const MAP_Tool *toolspec, void *arg);


void
(MAP_View *mv, MAP_Tool *tool);


void
(MAP_View *mv, void (*f)(MAP_View *mv, void *p));

The MAP_View widget provides a generic interface for tools that must accomplish diverse map operations. () registers a tool for use from a MAP_View. toolspec is assumed to point to a tool structure with the following fields properly initialized:

typedef struct map_tool {
	const char *name;     /* Name of the tool */
	const char *desc;     /* Short description */
	AG_StaticIcon *icon;  /* Icon (or NULL) */
	int cursor_index;     /* Static cursor (or -1) */

	void (*init)(MAP_Tool *t);
	void (*destroy)(MAP_Tool *t);
	int  (*load)(MAP_Tool *t, AG_DataSource *ds);
	int  (*save)(MAP_Tool *t, AG_DataSource *ds);
	int  (*cursor)(MAP_Tool *t, AG_Rect *r);
	void (*effect)(MAP_Tool *t, MAP_Node *n);
	int (*mousemotion)(MAP_Tool *t, int x, int y, int xrel,
	                  int yrel, int xo, int yo, int xorel,
			  int yorel, int button_state);
	int (*mousebuttondown)(MAP_Tool *t, int x, int y, int xoff,
	                       int yoff, int button);
	int (*mousebuttonup)(MAP_Tool *t, int x, int y, int xoff,
	                     int yoff, int button);
	int (*keydown)(MAP_Tool *t, int ksym, int kmod);
	int (*keyup)(MAP_Tool *t, int ksym, int kmod);
} MAP_Tool;

The (), (), () and () operations are used to initialize, free, save and restore any private data structures needed by the tool.

The () operation is expected to draw the current cursor at the screen coordinates given by the AG_Rect argument.

The () operation is executed on mouse click events, and on mouse motion events where the relative map (node) coordinates are >|1|. Typically, simple tools that perform node-specific operations such as the ‘stamp’ and ‘eraser’ tools will use this operation.

Tools that perform more complex operations (such as vector graphics manipulations) will generally use the lower-level (), (), (), () and () operations. If any of these functions return a value of 1, the given event will not be forwarded to the mouse/keyboard tool bindings and default operations.

The () function configures a default tool which will receive all events that have not been processed by the active tool or a mouse event binding.

The () function registers a function to invoke every time the MAP_View widget is redrawn.

The MAP_View widget generates the following events:

(int button, int x, int y, int xoff, int yoff)
The user double clicked over the given tile.

AG_DataSource(3), AG_Widget(3), AG_Window(3), MAP(3), MAP_Object(3), RG(3), SG_Intro(3)

The MAP_View widget first appeared in Agar 1.0.

December 21, 2022 Agar 1.7

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.