Project

General

Profile

detect the maximum screen size, divide screen

Added by Pedro Vicente 1 day ago

I have a WCompositeWidget class (map) that uses hardcoded width/height shown below


ApplicationMap::ApplicationMap(const Wt::WEnvironment& env)
  : WApplication(env)
{
  Wt::WMapbox* map = root()->addWidget(std::make_unique<Wt::WMapbox>());
  map->resize(1920, 1080);
}

I want to detect the maximum screen size and make 'map' occupy 80% of width with 20% at right being a control
panel to add widgets

what is the best way to achieve this
thx

full code at

https://github.com/pedro-vicente/wt.extra


Replies (1)

RE: detect the maximum screen size, divide screen - Added by Pedro Vicente 1 day ago

this code , based on examples, does not display the map entirely

https://www.webtoolkit.eu/widgets/layout/layout-managers

setTitle("DC 311 Service Requests Map");
useStyleSheet("nostro.css");

auto container = std::make_unique<Wt::WContainerWidget>();
container->setStyleClass("yellow-box");

auto hbox = container->setLayout(std::make_unique<Wt::WHBoxLayout>());

auto map = std::make_unique<Wt::WMapbox>();
map->setStyleClass("green-box");

hbox->addWidget(std::move(map), 1);

auto item = std::make_unique<Wt::WText>("Item 2");
item->setWidth(200);
item->setStyleClass("blue-box");
hbox->addWidget(std::move(item));

root()->addWidget(std::move(container));
    (1-1/1)