Exemple #1
0
  void set(const DialogLook &look, PixelRect _rc) {
    SingleWindow::set(_T("RunRenderOZ"), _T("RunRenderOZ"), _rc);

    const PixelRect rc = get_client_rect();

    WindowStyle with_border;
    with_border.Border();

    oz.set(*this, rc.right / 2, 0, rc.right - (rc.right / 2), rc.bottom,
           with_border);
    oz_window = &oz;

    const PixelRect list_rc = {
      0, 0, PixelScalar(rc.right / 2), PixelScalar(rc.bottom - 30),
    };

    type_list = new ListControl(*this, look, list_rc,
                                with_border, 25);
    type_list->SetPaintItemCallback(paint_oz_type_name);
    type_list->SetCursorCallback(oz_type_cursor_callback);
    type_list->SetLength(NUM_OZ_TYPES);

    PixelRect button_rc = rc;
    button_rc.right = (rc.left + rc.right) / 2;
    button_rc.top = button_rc.bottom - 30;
    close_button.set(*this, _T("Close"), ID_CLOSE, button_rc);

    oz.set_shape(ObservationZonePoint::LINE);

    type_list->SetFocus();
  }
void
dlgWaypointDetailsShowModal(SingleWindow &parent, const Waypoint &_waypoint,
                            bool allow_navigation)
{
    waypoint = &_waypoint;

    wf = LoadDialog(CallBackTable, parent,
                    Layout::landscape ? _T("IDR_XML_WAYPOINTDETAILS_L") :
                    _T("IDR_XML_WAYPOINTDETAILS"));
    assert(wf != NULL);

    LastUsedWaypoints::Add(_waypoint);

    UpdateCaption(waypoint->name.c_str(), waypoint->file_num);

    wf->SetKeyDownNotify(FormKeyDown);

    wInfo = (DockWindow *)wf->FindByName(_T("info"));
    assert(wInfo != NULL);
    wInfo->SetWidget(new WaypointInfoWidget(UIGlobals::GetDialogLook(),
                                            _waypoint));

    wCommand = (DockWindow *)wf->FindByName(_T("commands"));
    assert(wCommand != NULL);
    wCommand->SetWidget(new WaypointCommandsWidget(UIGlobals::GetDialogLook(),
                        wf, _waypoint,
                        protected_task_manager));
    wCommand->Hide();

    wDetails = wf->FindByName(_T("frmDetails"));
    assert(wDetails != NULL);

    ListControl *wFilesList = (ListControl *)wf->FindByName(_T("Files"));
    assert(wFilesList != NULL);

    EditWindow *wDetailsText = (EditWindow *)wf->FindByName(_T("Details"));
    assert(wDetailsText != NULL);
    wDetailsText->SetText(waypoint->details.c_str());

#ifdef ANDROID
    int num_files = std::distance(waypoint->files_external.begin(),
                                  waypoint->files_external.end());
    if (num_files > 0) {
        wFilesList->SetPaintItemCallback(OnFileListItemPaint);
        wFilesList->SetCursorCallback(OnFileListEnter);
        wFilesList->SetActivateCallback(OnFileListEnter);

        unsigned list_height = wFilesList->GetItemHeight() * std::min(num_files, 5);
        wFilesList->Resize(wFilesList->GetWidth(), list_height);
        wFilesList->SetLength(num_files);

        PixelRect rc = wDetailsText->GetPosition();
        rc.top += list_height;
        wDetailsText->Move(rc);
    } else
#endif
        wFilesList->Hide();

    wImage = (PaintWindow *)wf->FindByName(_T("frmImage"));
    assert(wImage != NULL);
    wMagnify = (WndButton *)wf->FindByName(_T("cmdMagnify"));
    assert(wMagnify != NULL);
    wShrink = (WndButton *)wf->FindByName(_T("cmdShrink"));
    assert(wShrink != NULL);

    if (!allow_navigation) {
        WndButton* butnav = (WndButton *)wf->FindByName(_T("cmdPrev"));
        assert(butnav != NULL);
        butnav->Hide();

        butnav = (WndButton *)wf->FindByName(_T("cmdNext"));
        assert(butnav != NULL);
        butnav->Hide();

        butnav = (WndButton *)wf->FindByName(_T("cmdGoto"));
        assert(butnav != NULL);
        butnav->Hide();
    }

    for (auto it = waypoint->files_embed.begin(),
            it_end = waypoint->files_embed.end();
            it != it_end && !images.full(); it++) {
        TCHAR path[MAX_PATH];
        LocalPath(path, it->c_str());
        if (!images.append().LoadFile(path))
            images.shrink(images.size() - 1);
    }

    page = 0;

    NextPage(0); // JMW just to turn proper pages on/off

    wf->ShowModal();

    delete wf;

    for (auto image = images.begin(); image < images.end(); image++)
        image->Reset();

    images.clear();
}