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

# 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 <ncurses/assert.hh>
11    
12     #include <csignal>
13    
14 sf-pippijn 1.1 // stats height
15     static int const SH = 10;
16    
17     using ndk::app;
18    
19     void
20     widgets::repack ()
21     {
22 sf-pippijn 1.5 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 sf-pippijn 1.1 }
56    
57     void
58     widgets::resize ()
59     {
60     repack ();
61 sf-pippijn 1.5
62 sf-pippijn 1.4 map->visualize ();
63 sf-pippijn 1.5 info->visualize ();
64 sf-pippijn 1.4 stats->visualize ();
65     inventory->visualize ();
66     container->visualize ();
67 sf-pippijn 1.1 }
68    
69     widgets::widgets ()
70     : map (new map_widget)
71 sf-pippijn 1.5 , info (new ndk::text_view)
72 sf-pippijn 1.1 , stats (new stats_widget)
73 sf-pippijn 1.5 , input (new ndk::edit)
74 sf-pippijn 1.1 , inventory (new inventory_widget)
75     , container (new inventory_widget)
76 sf-pippijn 1.5 , invmenu (new ndk::menu)
77 sf-pippijn 1.1 , query (new query_widget)
78 sf-pippijn 1.5 , query_input (new ndk::edit ("", query.get ()))
79     , maximised (nullptr)
80 sf-pippijn 1.1 {
81     query->resize (10, 5);
82    
83 sf-pippijn 1.4 resize ();
84 sf-pippijn 1.1
85 sf-pippijn 1.3 map->focus ();
86 sf-pippijn 1.5 //invmenu->focus ();
87 sf-pippijn 1.1 }
88    
89     widgets::~widgets ()
90     {
91     }