ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/cf.schmorp.de/dclient/src/frontend/client/widgets.cpp
Revision: 1.5
Committed: Mon Oct 18 15:34:24 2010 UTC (16 years ago) by sf-pippijn
Branch: MAIN
Changes since 1.4: +41 -34 lines
Log Message:
first attempt to support maximising windows

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