ref: 3cbc44156098b3e1d2a5fce0bdb25aaa991efe2b
dir: /map.c/
#include <u.h>
#include <libc.h>
#include <draw.h>
#include <event.h>
#include <nate/nate.h>
#include <nate/n_window.h>
#include <nate/n_hbox.h>
#include <nate/n_vbox.h>
#include <nate/n_box.h>
#include <nate/n_label.h>
#include <nate/n_button.h>
#include <nate/n_image.h>
#include "dat.h"
#include "fns.h"
NWindow *mainwindow;
NImage *nimage;
Image *testimage;
void
inittestimage(void)
{
Image *r, *g;
testimage = allocimage(display, Rect(0, 0, 100, 100), screen->chan, 1, DWhite);
r = allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, DRed);
g = allocimage(display, Rect(0, 0, 1, 1), screen->chan, 1, DGreen);
draw(testimage, Rect(0, 0, 50, 50), r, nil, ZP);
draw(testimage, Rect(50, 50, 100, 100), g, nil, ZP);
freeimage(r);
freeimage(g);
}
void
eresized(int new)
{
if (new && getwindow(display, Refnone) < 0)
sysfatal("%r");
nateredraw();
}
int
exitclicked(Mouse, Nelem *el, void*)
{
exits(nil);
}
void
main(int argc, char **argv)
{
Event ev;
int z = 0;
char *url;
if (initdraw(nil, nil, "map") < 0)
sysfatal("%r");
einit(Emouse);
nateinit();
inittestimage();
NAssign(NWindow, &mainwindow, New_Window())
->MakeRoot()
->Slot(
New_VBox()
->Slot(
New_HBox()
->SizeToContent(1)
->Slot(
New_Button()
->SizeToContent(1)
->Border(1, display->black)
->Label("Exit")
->OnClick(exitclicked, nil)
)
->Slot(
New_Button()
->SizeToContent(1)
->Label("Test")
->Border(1, display->black)
)
)
->Slot(
New_Box()
->Border(1, display->black)
->Size(Pt(200, 300))
->Slot(
NAssign(NImage, &nimage, New_Image())
->Image(testimage)
)
)
->Slot(
New_Box()
->Border(1, display->black)
->Size(Pt(500, 30))
->Slot(
New_Label()
->Label("Status Line")
)
)
);
nateredraw();
for (;;) {
switch (event(&ev)) {
case Emouse:
if (ev.mouse.buttons & 4)
exits(nil);
else
natemouseevent(ev.mouse);
break;
}
}
GPos loc = getlocation();
GBundle bundle = getbundle(loc, z);
GProvider *prov = getprovider();
url = prov->formaturl(bundle);
print("%s\n", url);
}