ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/cf.schmorp.de/dclient/src/frontend/client/widgets.cpp
Revision: 1.7
Committed: Tue Oct 19 09:45:11 2010 UTC (16 years ago) by sf-pippijn
Branch: MAIN
Changes since 1.6: +6 -6 lines
Log Message:
- use wchar_t for single characters (glyphs and line drawing)
- merge ncurses and ndk wrappers
- simplify colour caching

File Contents

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