ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/cf.schmorp.de/dclient/src/frontend/client/widgets.cpp
Revision: 1.8
Committed: Sun Oct 24 20:31:53 2010 UTC (16 years ago) by sf-pippijn
Branch: MAIN
CVS Tags: HEAD
Changes since 1.7: +3 -3 lines
Log Message:
use EV and plain sockets instead of asio

File Contents

# Content
1 #include "dclient/widgets.h"
2 #include "dclient/widgets/inventory.h"
3 #include "dclient/widgets/map.h"
4 #include "dclient/widgets/query.h"
5 #include "dclient/widgets/stats.h"
6
7 #include <ndk/application.hh>
8 #include <ndk/frame.hh>
9
10 #include <csignal>
11
12 // stats height
13 static int const SH = 10;
14
15 using ndk::app;
16
17 void
18 widgets::repack ()
19 {
20 if (maximised)
21 {
22 maximised->move (4, 2, ndk::absolute);
23 maximised->resize (app->width () - 8, app->height () - 4);
24 }
25 else
26 {
27 map->move (0, 0, ndk::absolute);
28 map->resize (app->width () / 2, app->height () / 3 * 2);
29
30 info->move (map->right_x (), 0, ndk::absolute);
31 info->resize (app->width () - map->width (), map->height () - SH);
32
33 stats->move (info->x (), info->bottom_y (), ndk::absolute);
34 stats->resize (info->width (), SH);
35
36 input->move (map->x () + 2, map->bottom_y () + 1, ndk::absolute);
37 input->resize (map->width () + info->width () - 4);
38
39 inventory->move (map->x (), input->bottom_y () + 1, ndk::absolute);
40 inventory->resize (map->width (), app->height () - map->height () - 3);
41
42 container->move (stats->x (), inventory->y (), ndk::absolute);
43 container->resize (stats->width (), inventory->height ());
44
45 query->move ( (app->width () - query->width ()) / 2
46 , (app->height () - query->height ()) / 2
47 , ndk::absolute
48 );
49
50 query_input->resize (query->width () - 2);
51 query_input->move (query->x () + 1, query->bottom_y () - 2, ndk::absolute);
52 }
53 }
54
55 void
56 widgets::resize ()
57 {
58 repack ();
59
60 map->visualize ();
61 info->visualize ();
62 stats->visualize ();
63 inventory->visualize ();
64 container->visualize ();
65 }
66
67 widgets::widgets ()
68 : map (new map_widget)
69 , info (new ndk::text ("Info", nullptr, ndk::text::wrap))
70 , stats (new stats_widget)
71 , input (new ndk::edit)
72 , inventory (new inventory_widget)
73 , container (new inventory_widget)
74 , invmenu (new ndk::menu)
75 , query (new query_widget)
76 , query_input (new ndk::edit ("", query.get ()))
77 , maximised (nullptr)
78 {
79 query->resize (10, 5);
80
81 resize ();
82
83 map->focus ();
84 //invmenu->focus ();
85 }
86
87 widgets::~widgets ()
88 {
89 }