QWidget* RangeProfilePlotManager::createWidget()
{
   DockWindow* pWindow = getDockWindow();
   VERIFYRV(pWindow, NULL);
   pWindow->attach(SIGNAL_NAME(Window, SessionItemDropped), Slot(this, &RangeProfilePlotManager::dropSessionItem));
   pWindow->enableSessionItemDrops(this);
   if (!Service<SessionManager>()->isSessionLoading())
   {
      mpPlot = Service<DesktopServices>()->createPlotWidget(getName(), CARTESIAN_PLOT);
   }
   if (mpPlot == NULL)
   {
      return NULL;
   }
   mpView = mpPlot->getPlot();
#pragma message(__FILE__ "(" STRING(__LINE__) ") : warning : If a SHALLOW_SELECTION selection mode is added " \
                                              "to plot view (OPTICKS-528), mpView should use it (tclarke)")
   mpMode = (mpView == NULL) ? NULL : mpView->getMouseMode("SelectionMode");
   if (mpMode == NULL)
   {
      return NULL;
   }
   mpView->getWidget()->installEventFilter(this);
   mpPlot->attach(SIGNAL_NAME(PlotWidget, AboutToShowContextMenu),
      Slot(this, &RangeProfilePlotManager::updateContextMenu));
   mpView->enableMouseMode(mpMode, true);
   mpView->setMouseMode(mpMode);

   return mpPlot->getWidget();
}
SpectralLibraryMatchResults::~SpectralLibraryMatchResults()
{
   Service<DesktopServices> pDesktop;

   // remove toolbar button and menu item
   QAction* pAction = getAction();
   if (pAction != NULL)
   {
      ToolBar* pToolBar = static_cast<ToolBar*>(pDesktop->getWindow("Spectral", TOOLBAR));
      if (pToolBar != NULL)
      {
         pToolBar->removeItem(pAction);
         MenuBar* pMenuBar = pToolBar->getMenuBar();
         if (pMenuBar != NULL)
         {
            pMenuBar->removeMenuItem(pAction);
         }
      }
   }

   // dockwindow should still exist so detach from it
   DockWindow* pWindow = getDockWindow();
   if (pWindow != NULL)
   {
      pWindow->detach(SIGNAL_NAME(DockWindow, AboutToShowContextMenu),
         Slot(this, &SpectralLibraryMatchResults::updateContextMenu));
   }
}
Exemplo n.º 3
0
void
DevicesConfigPanel::Prepare(ContainerWindow &parent, const PixelRect &rc)
{
  instance = this;
  LoadWindow(NULL, parent,
             Layout::landscape ? _T("IDR_XML_DEVICESCONFIGPANEL") :
                               _T("IDR_XML_DEVICESCONFIGPANEL_L"));

  current_device = 0;

  for (unsigned i = 0; i < NUMDEV; ++i)
    Profile::GetDeviceConfig(i, device_config[i]);

  DockWindow *dock = (DockWindow *)form.FindByName(_T("edit"));
  assert(dock != NULL);
  DeviceEditWidget *edit = new DeviceEditWidget(device_config[0]);
  dock->SetWidget(edit);

  WndListFrame *list = (WndListFrame *)form.FindByName(_T("list"));
  assert(list != NULL);
  list->SetPaintItemCallback(PaintDeviceListItem);
  list->SetLength(2);
  list->SetCursorCallback(DeviceListCursorCallback);

  LoadFormProperty(form, _T("prpSetSystemTimeFromGPS"),
                   CommonInterface::GetComputerSettings().set_system_time_from_gps);

  LoadFormProperty(form, _T("prpIgnoreNMEAChecksum"),
                   NMEAParser::ignore_checksum);
}
Exemplo n.º 4
0
bool MessageLogTestPlugin::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList)
{
   Service<DesktopServices> pDesktop;
   Service<UtilityServices> pUtility;

   DockWindow* pWindow = dynamic_cast<DockWindow*>(pDesktop->getWindow("Message Log Window", DOCK_WINDOW));
   pWindow->show();

   MessageLogMgr* pMgr = pUtility->getMessageLog();
   if (pMgr != NULL)
   {
      MessageLog* pLog = pMgr->getLog("Message Log Test Plugin");
      if (pLog != NULL)
      {
         pLog->createMessage("Added new test Message. Key and Component provided.", "Message Log Test Plugin",
            "message1", true, false);
         pLog->createMessage("This should be yellow. No Key or Component provided.", "", "", true, false);
         pLog->createStep("Added new test Step. Key and Component provided.", "Message Log Test Plugin", "step1",
            false);
         pLog->createStep("This should be yellow. No Key or Component provided.", "", "", false);
      }
   }

   return true;
}
QWidget* SpectralLibraryMatchResults::createWidget()
{
   mpTabWidget = new QTabWidget(getDockWindow()->getWidget());
   mpTabWidget->setTabPosition(QTabWidget::South);
   mpTabWidget->setTabShape(QTabWidget::Rounded);
   mpTabWidget->setMinimumHeight(100);

   // dockwindow should exist so attach to it
   DockWindow* pWindow = getDockWindow();
   if (pWindow != NULL)
   {

      pWindow->attach(SIGNAL_NAME(DockWindow, AboutToShowContextMenu),
         Slot(this, &SpectralLibraryMatchResults::updateContextMenu));

      // Connect to the session explorer now that the window has been created
      if (mpExplorer.get() == NULL)
      {
         Service<SessionExplorer> pExplorer;
         mpExplorer.reset(pExplorer.get());
      }

      // set location of the results window
#pragma message(__FILE__ "(" STRING(__LINE__) ") : warning : Replace this block when public method to locate DockWindow is available. (rforehan)")
      QMainWindow* pMainWindow = dynamic_cast<QMainWindow*>(Service<DesktopServices>()->getMainWidget());
      if (pMainWindow != NULL)
      {
         pMainWindow->addDockWidget(Qt::LeftDockWidgetArea, dynamic_cast<QDockWidget*>(pWindow), Qt::Vertical);
      }     
   }

   return mpTabWidget;
}
Exemplo n.º 6
0
  void Show(const PixelRect &rc) override {
    const Layout layout(rc, *waypoint);

    if (task_manager != nullptr)
      goto_button.MoveAndShow(layout.goto_button);

    if (!images.empty()) {
      magnify_button.MoveAndShow(layout.magnify_button);
      shrink_button.MoveAndShow(layout.shrink_button);
    }

    previous_button.MoveAndShow(layout.previous_button);
    next_button.MoveAndShow(layout.next_button);

    close_button.MoveAndShow(layout.close_button);

    info_dock.Move(layout.main);
    details_panel.Move(layout.main);
    details_text.Move(layout.details_text);
#ifdef HAVE_RUN_FILE
    if (!waypoint->files_external.empty())
      file_list.Move(layout.file_list);
#endif

    commands_dock.Move(layout.main);

    if (!images.empty())
      image_window.Move(layout.main);

    UpdatePage();
  }
Exemplo n.º 7
0
  void Move(const PixelRect &rc) override {
    const Layout layout(rc, waypoint);

    if (allow_navigation)
      goto_button.Move(layout.goto_button);

    if (!images.empty()) {
      magnify_button.Move(layout.magnify_button);
      shrink_button.Move(layout.shrink_button);
    }

    if (allow_navigation) {
      previous_button.Move(layout.previous_button);
      next_button.Move(layout.next_button);
    }

    close_button.Move(layout.close_button);

    info_dock.Move(layout.main);
    details_panel.Move(layout.main);
    details_text.Move(layout.details_text);
#ifdef HAVE_RUN_FILE
    if (!waypoint.files_external.empty())
      file_list.Move(layout.file_list);
#endif
    commands_dock.Move(layout.main);

    if (!images.empty())
      image_window.Move(layout.main);
  }
Exemplo n.º 8
0
void
WaypointDetailsWidget::UpdatePage()
{
  info_dock.SetVisible(page == 0);
  details_panel.SetVisible(page == 1);
  commands_dock.SetVisible(page == 2);

  bool image_page = page >= 3;
  if (!images.empty()) {
    image_window.SetVisible(image_page);
    magnify_button.SetVisible(image_page);
    shrink_button.SetVisible(image_page);
  }
}
Exemplo n.º 9
0
void AutoHideBar::ShowWindow()
{
    DockWindow* hiddenwindow = reinterpret_cast<DockWindow*>(tabs[active].dock);
    if(!hiddenwindow->IsOpen())
    {
        Size s  = hiddenwindow->GetSizeHint();
        Rect r  = GetScreenRect();
        Rect rr = r;
        switch(layout)
        {
        case LAYOUT_LEFT:
            rr.left	= r.right;
            s.cy = r.GetHeight();
#if defined(PLATFORM_X11)
            rr.right += 1;
#endif
            break;
        case LAYOUT_TOP:
            rr.top = r.bottom;
            s.cx = r.GetWidth();
#if defined(PLATFORM_X11)
            rr.bottom += 1;
#endif
            break;
        case LAYOUT_RIGHT:
            rr.right = r.left;
            s.cy = r.GetHeight();
#if defined(PLATFORM_X11)
            rr.left -= 1;
#endif
            break;
        case LAYOUT_BOTTOM:
            rr.bottom = r.top;
            s.cx = r.GetWidth();
#if defined(PLATFORM_X11)
            rr.top -= 1;
#endif
            break;

        }
        popup.SetRect(rr);
        popup.Add(hiddenwindow->SizePos());
        hiddenwindow->Ctrl::Show();
        popup.PopUp(GetOwner(), false, true, false, false);
        ctrl = hiddenwindow;
        Ctrl::ProcessEvents();
        AdjustSize(rr, s);
        Animate(popup, rr, GUIEFFECT_SLIDE);
    }
}
Exemplo n.º 10
0
  void Hide() override {
    if (task_manager != nullptr)
      goto_button.Hide();

    if (!images.empty()) {
      magnify_button.Hide();
      shrink_button.Hide();
    }

    previous_button.Hide();
    next_button.Hide();

    close_button.Hide();

    info_dock.Hide();
    details_panel.Hide();
    commands_dock.Hide();

    if (!images.empty())
      image_window.Hide();
  }
Exemplo n.º 11
0
  void MoveChildren(const Layout &layout) {
    waypoint_name.Move(layout.waypoint_name);
    waypoint_details.Move(layout.waypoint_details);
    waypoint_remove.Move(layout.waypoint_remove);
    waypoint_relocate.Move(layout.waypoint_relocate);

    type_label.Move(layout.type_label);
    change_type.Move(layout.change_type);
    map.Move(layout.map);
    properties_dock.Move(layout.properties);
    optional_starts.Move(layout.optional_starts);
    score_exit.Move(layout.score_exit);
  }
Exemplo n.º 12
0
void
TaskPointWidget::Prepare(ContainerWindow &parent, const PixelRect &rc)
{
  const Layout layout(rc, look);

  WindowStyle panel_style;
  panel_style.Hide();
  panel_style.Border();
  panel_style.ControlParent();

  ButtonWindowStyle button_style;
  button_style.TabStop();

  CheckBoxStyle check_box_style;
  check_box_style.TabStop();

  WindowStyle dock_style;
  dock_style.ControlParent();

  waypoint_panel.Create(parent, look, layout.waypoint_panel, panel_style);
  waypoint_name.Create(waypoint_panel, layout.waypoint_name);
  waypoint_details.Create(waypoint_panel, look.button, _("Details"),
                          layout.waypoint_details,
                          button_style, *this, DETAILS);
  waypoint_remove.Create(waypoint_panel, look.button, _("Remove"),
                         layout.waypoint_remove,
                         button_style, *this, REMOVE);
  waypoint_relocate.Create(waypoint_panel, look.button, _("Relocate"),
                           layout.waypoint_relocate,
                           button_style, *this, RELOCATE);

  tp_panel.Create(parent, look, layout.tp_panel, panel_style);

  type_label.Create(tp_panel, layout.type_label);
  change_type.Create(tp_panel, look.button, _("Change Type"),
                     layout.change_type,
                     button_style, *this, CHANGE_TYPE);
  map.Create(tp_panel, layout.map, WindowStyle(),
             [this](Canvas &canvas, const PixelRect &rc){
               PaintMap(canvas, rc);
             });
  properties_dock.Create(tp_panel, layout.properties, dock_style);
  optional_starts.Create(tp_panel, look.button, _("Enable Alternate Starts"),
                         layout.optional_starts, button_style,
                         *this, OPTIONAL_STARTS);
  score_exit.Create(tp_panel, look, _("Score exit"),
                    layout.score_exit, check_box_style,
                    *this, SCORE_EXIT);

  RefreshView();
}
Exemplo n.º 13
0
  void Hide() override {
    if (allow_navigation)
      goto_button.Hide();

    if (!images.empty()) {
      magnify_button.Hide();
      shrink_button.Hide();
    }

    if (allow_navigation) {
      previous_button.Hide();
      next_button.Hide();
    }

    close_button.Hide();

    info_dock.Hide();
    details_panel.Hide();
    commands_dock.Hide();

    if (!images.empty())
      image_window.Hide();
  }
Exemplo n.º 14
0
bool
TaskPointWidget::ReadValues()
{
  OrderedTaskPoint &tp = ordered_task.GetPoint(active_index);

  if (tp.GetType() == TaskPointType::AST) {
    const bool new_score_exit = score_exit.GetState();

    ASTPoint &ast = (ASTPoint &)tp;

    if (new_score_exit != ast.GetScoreExit()) {
      ast.SetScoreExit(new_score_exit);
      ordered_task.ClearName();
      task_modified = true;
    }
  }

  return properties_dock.SaveWidget(task_modified);
}
Exemplo n.º 15
0
   View* createView(const char* pName, const char* pType, DataElement* pElement)
   {
      if (pName == NULL || pType == NULL)
      {
         setLastError(SIMPLE_BAD_PARAMS);
         return NULL;
      }
      ViewType type(StringUtilities::fromXmlString<ViewType>(std::string(pType)));
      RasterElement* pRaster = dynamic_cast<RasterElement*>(pElement);
      if (type == SPATIAL_DATA_VIEW && pRaster == NULL)
      {
         setLastError(SIMPLE_BAD_PARAMS);
         return NULL;
      }
      WindowType windowType;
      switch(type)
      {
      case SPATIAL_DATA_VIEW:
         windowType = SPATIAL_DATA_WINDOW;
         break;
      case PRODUCT_VIEW:
         windowType = PRODUCT_WINDOW;
         break;
      case PLOT_VIEW:
         windowType = DOCK_WINDOW;
         break;
      }
      Window* pWindow = Service<DesktopServices>()->createWindow(std::string(pName), windowType);
      if (type == PLOT_VIEW)
      {
         DockWindow* pDockWindow = dynamic_cast<DockWindow*>(pWindow);
         if (pDockWindow != NULL)
         {
            PlotSetGroup* pPlotSetGroup = Service<DesktopServices>()->createPlotSetGroup();
            if (pPlotSetGroup == NULL)
            {
               Service<DesktopServices>()->deleteWindow(pDockWindow);
               setLastError(SIMPLE_OTHER_FAILURE);
               return NULL;
            }

            pDockWindow->setWidget(pPlotSetGroup->getWidget());
         }
      }
      View* pView = pWindow == NULL ? NULL : static_cast<ViewWindow*>(pWindow)->getView();
      if (pView == NULL)
      {
         if (Service<DesktopServices>()->getWindow(std::string(pName), windowType) != NULL)
         {
            setLastError(SIMPLE_EXISTS);
         }
         else
         {
            setLastError(SIMPLE_OTHER_FAILURE);
         }
         return NULL;
      }
      if (type == SPATIAL_DATA_VIEW)
      {
         SpatialDataView* pSdv = static_cast<SpatialDataView*>(pView);
         if (!pSdv->setPrimaryRasterElement(pRaster))
         {
            Service<DesktopServices>()->deleteWindow(pWindow);
            setLastError(SIMPLE_OTHER_FAILURE);
            return NULL;
         }
         { // scope
            UndoLock lock(pView);
            if (pSdv->createLayer(RASTER, pRaster) == NULL)
            {
               Service<DesktopServices>()->deleteWindow(pWindow);
               setLastError(SIMPLE_OTHER_FAILURE);
               return NULL;
            }
         }
      }
      setLastError(SIMPLE_NO_ERROR);
      return pView;
   }
Exemplo n.º 16
0
 void Unprepare() override {
   properties_dock.DeleteWidget();
 }
Exemplo n.º 17
0
void
TaskPointWidget::RefreshView()
{
  map.Invalidate();

  OrderedTaskPoint &tp = ordered_task.GetPoint(active_index);

  properties_dock.DeleteWidget();

  ObservationZonePoint &oz = tp.GetObservationZone();
  const bool is_fai_general =
    ordered_task.GetFactoryType() == TaskFactoryType::FAI_GENERAL;
  auto *properties_widget = CreateObservationZoneEditWidget(oz, is_fai_general);
  if (properties_widget != nullptr) {
    properties_widget->SetListener(this);
    properties_dock.SetWidget(properties_widget);
  } else
    properties_dock.SetWidget(new PanelWidget());

  type_label.SetCaption(OrderedTaskPointName(ordered_task.GetFactory().GetType(tp)));

  previous_button->SetEnabled(active_index > 0);
  next_button->SetEnabled(active_index < (ordered_task.TaskSize() - 1));

  optional_starts.SetVisible(active_index == 0);
  if (!ordered_task.HasOptionalStarts())
    optional_starts.SetCaption(_("Enable Alternate Starts"));
  else {
    StaticString<50> tmp;
    tmp.Format(_T("%s (%d)"), _("Edit Alternates"),
               ordered_task.GetOptionalStartPointCount());
    optional_starts.SetCaption(tmp);
  }

  if (tp.GetType() == TaskPointType::AST) {
    const ASTPoint &ast = (const ASTPoint &)tp;
    score_exit.Show();
    score_exit.SetState(ast.GetScoreExit());
  } else
    score_exit.Hide();

  StaticString<100> name_prefix_buffer, type_buffer;

  switch (tp.GetType()) {
  case TaskPointType::START:
    type_buffer = _("Start point");
    name_prefix_buffer = _T("Start: ");
    break;

  case TaskPointType::AST:
    type_buffer = _("Task point");
    name_prefix_buffer.Format(_T("%d: "), active_index);
    break;

  case TaskPointType::AAT:
    type_buffer = _("Assigned area point");
    name_prefix_buffer.Format(_T("%d: "), active_index);
    break;

  case TaskPointType::FINISH:
    type_buffer = _("Finish point");
    name_prefix_buffer = _T("Finish: ");
    break;

  default:
    gcc_unreachable();
  }

  dialog.SetCaption(type_buffer);

  {
    StaticString<100> buffer;
    buffer.Format(_T("%s %s"), name_prefix_buffer.c_str(),
                  tp.GetWaypoint().name.c_str());
    waypoint_name.SetCaption(buffer);
  }
}
Exemplo n.º 18
0
/**
 * Creates a control from the given XMLNode as a child of the given
 * parent.
 *
 * @param form the SubForm object
 * @param LookUpTable The parent CallBackTable
 * @param node The XMLNode that represents the control
 */
static Window *
LoadChild(SubForm &form, ContainerWindow &parent,
          const CallBackTableEntry *lookup_table, XMLNode node,
          int bottom_most,
          WindowStyle style)
{
  Window *window = NULL;

  // Determine name, coordinates, width, height
  // and caption of the control
  const TCHAR* name = GetName(node);
  const TCHAR* caption = GetCaption(node);
  PixelRect rc = parent.get_client_rect();
  ControlPosition pos = GetPosition(node, rc, bottom_most);
  if (!pos.no_scaling)
    pos.x = ScaleWidth(pos.x);

  ControlSize size = GetSize(node, rc, pos);
  if (!size.no_scaling)
    size.cx = ScaleWidth(size.cx);

  if (!StringToIntDflt(node.getAttribute(_T("Visible")), 1))
    style.Hide();

  if (StringToIntDflt(node.getAttribute(_T("Border")), 0))
    style.Border();

  rc.left = pos.x;
  rc.top = pos.y;
  rc.right = rc.left + size.cx;
  rc.bottom = rc.top + size.cy;

  bool expert = (StringToIntDflt(node.getAttribute(_T("Expert")), 0) == 1);

  // PropertyControl (WndProperty)
  if (StringIsEqual(node.getName(), _T("Edit"))) {
    // Determine the width of the caption field
    int caption_width = StringToIntDflt(node.getAttribute(_T("CaptionWidth")), 0);

    if (Layout::ScaleSupported())
      caption_width = Layout::Scale(caption_width);

    caption_width = ScaleWidth(caption_width);

    // Determine whether the control is multiline or readonly
    bool multi_line = StringToIntDflt(node.getAttribute(_T("MultiLine")), 0);
    bool read_only = StringToIntDflt(node.getAttribute(_T("ReadOnly")), 0);

    // Load the event callback properties
    WndProperty::DataChangeCallback_t data_notify_callback =
      (WndProperty::DataChangeCallback_t)
      GetCallBack(lookup_table, node, _T("OnDataNotify"));

    WindowControl::HelpCallback help_callback =
      (WindowControl::HelpCallback)
      GetCallBack(lookup_table, node, _T("OnHelp"));

    // Create the Property Control
    style.ControlParent();

    EditWindowStyle edit_style;
    edit_style.vertical_center();
    if (read_only)
      edit_style.read_only();
    else
      edit_style.TabStop();

    if (IsEmbedded() || Layout::scale_1024 < 2048)
      /* sunken edge doesn't fit well on the tiny screen of an
         embedded device */
      edit_style.Border();
    else
      edit_style.SunkenEdge();

    if (multi_line) {
      edit_style.multiline();
      edit_style.VerticalScroll();
    }

    WndProperty *property;
    window = property = new WndProperty(parent, *xml_dialog_look, caption, rc,
                                        caption_width, style, edit_style,
                                        data_notify_callback);

    // Set the help function event callback
    property->SetOnHelpCallback(help_callback);

    // Load the help text
    property->SetHelpText(StringToStringDflt(node.getAttribute(_T("Help")),
                                             NULL));

    // If the control has (at least) one DataField child control
    const XMLNode *data_field_node = node.getChildNode(_T("DataField"));
    if (data_field_node != NULL) {
      // -> Load the first DataField control
      DataField *data_field =
        LoadDataField(*data_field_node, lookup_table);

      if (data_field != NULL)
        // Tell the Property control about the DataField control
        property->SetDataField(data_field);
    }

  } else if (StringIsEqual(node.getName(), _T("TextEdit"))) {
    // Determine whether the control is multiline or readonly
    bool multi_line = StringToIntDflt(node.getAttribute(_T("MultiLine")), 0);
    bool read_only = StringToIntDflt(node.getAttribute(_T("ReadOnly")), 0);

    EditWindowStyle edit_style(style);
    if (read_only)
      edit_style.read_only();
    else
      edit_style.TabStop();

    if (IsEmbedded() || Layout::scale_1024 < 2048)
      /* sunken edge doesn't fit well on the tiny screen of an
         embedded device */
      edit_style.Border();
    else
      edit_style.SunkenEdge();

    if (multi_line) {
      edit_style.multiline();
      edit_style.VerticalScroll();
    }

    EditWindow *edit;
    window = edit = new EditWindow();
    edit->set(parent, pos.x, pos.y, size.cx, size.cy, edit_style);
    edit->InstallWndProc();
    edit->set_font(*xml_dialog_look->text_font);

  // ButtonControl (WndButton)
  } else if (StringIsEqual(node.getName(), _T("Button"))) {
    // Determine ClickCallback function
    WndButton::ClickNotifyCallback click_callback =
      (WndButton::ClickNotifyCallback)
      GetCallBack(lookup_table, node, _T("OnClick"));

    // Create the ButtonControl

    ButtonWindowStyle button_style(style);
    button_style.TabStop();
    button_style.multiline();

    window = new WndButton(parent, *xml_dialog_look, caption,
                           rc,
                           button_style, click_callback);

  } else if (StringIsEqual(node.getName(), _T("CheckBox"))) {
    // Determine click_callback function
    CheckBoxControl::ClickNotifyCallback click_callback =
      (CheckBoxControl::ClickNotifyCallback)
      GetCallBack(lookup_table, node, _T("OnClick"));

    // Create the CheckBoxControl

    style.TabStop();

    window = new CheckBoxControl(parent, *xml_dialog_look, caption,
                                 rc,
                                 style, click_callback);

  // SymbolButtonControl (WndSymbolButton) not used yet
  } else if (StringIsEqual(node.getName(), _T("SymbolButton"))) {
    // Determine ClickCallback function
    WndButton::ClickNotifyCallback click_callback =
      (WndButton::ClickNotifyCallback)
      GetCallBack(lookup_table, node, _T("OnClick"));

    // Create the SymbolButtonControl

    style.TabStop();

    window = new WndSymbolButton(parent, *xml_dialog_look, caption,
                                 rc,
                                 style, click_callback);

  // PanelControl (WndPanel)
  } else if (StringIsEqual(node.getName(), _T("Panel"))) {
    // Create the PanelControl

    style.ControlParent();

    PanelControl *frame = new PanelControl(parent, *xml_dialog_look,
                                           rc,
                                           style);

    window = frame;

    // Load children controls from the XMLNode
    LoadChildrenFromXML(form, *frame,
                        lookup_table, &node);

  // KeyboardControl
  } else if (StringIsEqual(node.getName(), _T("Keyboard"))) {
    KeyboardControl::OnCharacterCallback_t character_callback =
      (KeyboardControl::OnCharacterCallback_t)
      GetCallBack(lookup_table, node, _T("OnCharacter"));

    // Create the KeyboardControl
    KeyboardControl *kb =
      new KeyboardControl(parent, *xml_dialog_look,
                          pos.x, pos.y, size.cx, size.cy,
                          character_callback, style);

    window = kb;
  // DrawControl (WndOwnerDrawFrame)
  } else if (StringIsEqual(node.getName(), _T("Canvas"))) {
    // Determine DrawCallback function
    WndOwnerDrawFrame::OnPaintCallback_t paint_callback =
      (WndOwnerDrawFrame::OnPaintCallback_t)
      GetCallBack(lookup_table, node, _T("OnPaint"));

    // Create the DrawControl
    WndOwnerDrawFrame* canvas =
      new WndOwnerDrawFrame(parent, pos.x, pos.y, size.cx, size.cy,
                            style, paint_callback);

    window = canvas;

  // FrameControl (WndFrame)
  } else if (StringIsEqual(node.getName(), _T("Label"))){
    // Create the FrameControl
    WndFrame* frame = new WndFrame(parent, *xml_dialog_look,
                                   pos.x, pos.y, size.cx, size.cy,
                                   style);

    // Set the caption
    frame->SetCaption(caption);
    // Set caption color
    Color color;
    if (StringToColor(node.getAttribute(_T("CaptionColor")), color))
      frame->SetCaptionColor(color);

    window = frame;

  // ListBoxControl (WndListFrame)
  } else if (StringIsEqual(node.getName(), _T("List"))){
    // Determine ItemHeight of the list items
    UPixelScalar item_height =
      Layout::Scale(StringToIntDflt(node.getAttribute(_T("ItemHeight")), 18));

    // Create the ListBoxControl

    style.TabStop();

    if (IsEmbedded() || Layout::scale_1024 < 2048)
      /* sunken edge doesn't fit well on the tiny screen of an
         embedded device */
      style.Border();
    else
      style.SunkenEdge();

    window = new WndListFrame(parent, *xml_dialog_look,
                              pos.x, pos.y, size.cx, size.cy,
                              style,
                              item_height);

  // TabControl (Tabbed)
  } else if (StringIsEqual(node.getName(), _T("Tabbed"))) {
    // Create the TabControl

    style.ControlParent();

    TabbedControl *tabbed = new TabbedControl(parent,
                                              pos.x, pos.y, size.cx, size.cy,
                                              style);

    window = tabbed;

    for (auto i = node.begin(), end = node.end(); i != end; ++i) {
      // Load each child control from the child nodes
      Window *child = LoadChild(form, *tabbed,
                                lookup_table,
                                *i);
      if (child != NULL)
        tabbed->AddClient(child);
    }
  // TabBarControl (TabBar)
  } else if (StringIsEqual(node.getName(), _T("TabBar"))) {
    // Create the TabBarControl

    bool flip_orientation = false;
    if ( (Layout::landscape && StringToIntDflt(node.getAttribute(_T("Horizontal")), 0)) ||
         (!Layout::landscape && StringToIntDflt(node.getAttribute(_T("Vertical")), 0) ) )
      flip_orientation = true;

    style.ControlParent();
    TabBarControl *tabbar = new TabBarControl(parent, *xml_dialog_look,
                                              pos.x, pos.y, size.cx, size.cy,
                                              style, flip_orientation);
    window = tabbar;

    // TabMenuControl (TabMenu)
  } else if (StringIsEqual(node.getName(), _T("TabMenu"))) {
    // Create the TabMenuControl

    style.ControlParent();
    TabMenuControl *tabmenu = new TabMenuControl(parent,
                                                 /* XXX this cast is
                                                    an ugly hack!
                                                    Please rewrite: */
                                                 (WndForm &)form,
                                                 *xml_dialog_look, caption,
                                                 pos.x, pos.y, size.cx, size.cy,
                                                 style);
    window = tabmenu;

  } else if (StringIsEqual(node.getName(), _T("Custom"))) {
    // Create a custom Window object with a callback
    CreateWindowCallback_t create_callback =
        (CreateWindowCallback_t)GetCallBack(lookup_table, node, _T("OnCreate"));
    if (create_callback == NULL)
      return NULL;

    window = create_callback(parent, pos.x, pos.y, size.cx, size.cy, style);
  } else if (StringIsEqual(node.getName(), _T("Widget"))) {
    style.ControlParent();
    DockWindow *dock = new DockWindow();
    dock->set(parent, rc, style);
    window = dock;
  }

  if (window != NULL) {
    if (!StringIsEmpty(name))
      form.AddNamed(name, window);

    if (expert)
      form.AddExpert(window);

    form.AddDestruct(window);
  }

  return window;
}
Exemplo n.º 19
0
void PlotSetImp::updateContextMenu(Subject& subject, const string& signal, const boost::any& value)
{
   ContextMenu* pMenu = boost::any_cast<ContextMenu*>(value);
   if (pMenu == NULL)
   {
      return;
   }

   QObject* pParent = pMenu->getActionParent();
   vector<SessionItem*> items = pMenu->getSessionItems();

   if (items.empty() == true)
   {
      return;
   }

   bool bAddSeparator = false;
   bool bAddActivate = false;
   bool bAddDelete = false;
   string afterId;

   vector<DockWindow*> windowItems = pMenu->getSessionItems<DockWindow>();
   if (windowItems.size() == 1)
   {
      DockWindow* pDockWindow = windowItems.front();
      if (pDockWindow != NULL)
      {
         PlotSetGroup* pPlotSetGroup = dynamic_cast<PlotSetGroup*>(pDockWindow->getWidget());
         if (pPlotSetGroup != NULL)
         {
            if (dynamic_cast<PlotSetImp*>(pPlotSetGroup->getCurrentPlotSet()) == this)
            {
               bAddSeparator = true;
               bAddDelete = true;
            }
         }
      }
   }
   else if (dynamic_cast<SessionExplorer*>(&subject) != NULL)
   {
      // Make sure all of the selected session items for the menu are plot widgets
      vector<PlotWidget*> plots = pMenu->getSessionItems<PlotWidget>();
      if (plots.size() != items.size())
      {
         return;
      }

      // Make sure all selected plot widget items are contained in this plot set
      vector<PlotWidget*>::iterator iter;
      for (iter = plots.begin(); iter != plots.end(); ++iter)
      {
         PlotWidget* pPlot = *iter;
         if (pPlot != NULL)
         {
            if (containsPlot(pPlot) == false)
            {
               return;
            }
         }
      }

      // Check for only one selected plot widget item
      if (plots.size() == 1)
      {
         bAddSeparator = true;

         // Add an activate action if the selected plot widget is not currently active
         PlotWidget* pPlot = plots.front();
         if (pPlot != NULL)
         {
            if (pPlot != getCurrentPlot())
            {
               bAddActivate = true;
            }
         }
      }

      bAddDelete = true;
      afterId = APP_PLOTWIDGET_PRINT_ACTION;
   }

   // Separator
   if (bAddSeparator == true)
   {
      QAction* pSeparatorAction = new QAction(pParent);
      pSeparatorAction->setSeparator(true);
      pMenu->addActionAfter(pSeparatorAction, APP_PLOTSET_SEPARATOR_ACTION, afterId);

      if (afterId.empty() == false)
      {
         afterId = APP_PLOTSET_SEPARATOR_ACTION;
      }
   }

   // Activate
   if (bAddActivate == true)
   {
      QAction* pActivateAction = new QAction("&Activate", pParent);
      pActivateAction->setAutoRepeat(false);
      pActivateAction->setStatusTip("Activates the selected plot in the plot set");
      VERIFYNR(connect(pActivateAction, SIGNAL(triggered()), this, SLOT(activateSelectedPlot())));
      pMenu->addActionAfter(pActivateAction, APP_PLOTSET_ACTIVATE_ACTION, afterId);

      if (afterId.empty() == false)
      {
         afterId = APP_PLOTSET_ACTIVATE_ACTION;
      }
   }

   // Delete
   if (bAddDelete == true)
   {
      QAction* pDeleteAction = new QAction(QIcon(":/icons/Delete"), "&Delete", pParent);
      pDeleteAction->setAutoRepeat(false);
      VERIFYNR(connect(pDeleteAction, SIGNAL(triggered()), this, SLOT(destroyCurrentPlot())));
      pMenu->addActionAfter(pDeleteAction, APP_PLOTSET_DELETE_ACTION, afterId);
   }
}
Exemplo n.º 20
0
 gcc_pure
 DeviceEditWidget &GetEditWidget() {
   DockWindow *dock = (DockWindow *)form.FindByName(_T("edit"));
   assert(dock != NULL);
   return *(DeviceEditWidget *)dock->GetWidget();
 }
Exemplo n.º 21
0
void
WaypointDetailsWidget::Unprepare()
{
  info_dock.UnprepareWidget();
  commands_dock.UnprepareWidget();
}
Exemplo n.º 22
0
void
WaypointDetailsWidget::Prepare(ContainerWindow &parent, const PixelRect &rc)
{
  for (const auto &i : waypoint.files_embed) {
    if (images.full())
      break;

    try {
      if (!images.append().LoadFile(LocalPath(i.c_str())))
        images.shrink(images.size() - 1);
    } catch (const std::exception &e) {
      LogFormat("Failed to load %s: %s",
                (const char *)NarrowPathName(Path(i.c_str())),
                e.what());
      images.shrink(images.size() - 1);
    }
  }

  const Layout layout(rc, waypoint);

  WindowStyle dock_style;
  dock_style.Hide();
  dock_style.ControlParent();

  WindowStyle button_style;
  button_style.Hide();
  button_style.TabStop();

  if (allow_navigation)
    goto_button.Create(parent, look.button, _("GoTo"), layout.goto_button,
                       button_style, *this, GOTO);

  if (!images.empty()) {
    magnify_button.Create(parent, layout.magnify_button, button_style,
                          new SymbolButtonRenderer(look.button, _T("+")),
                          *this, MAGNIFY);
    shrink_button.Create(parent, layout.shrink_button, button_style,
                         new SymbolButtonRenderer(look.button, _T("-")),
                         *this, SHRINK);
  }

  if (allow_navigation) {
    previous_button.Create(parent, layout.previous_button, button_style,
                           new SymbolButtonRenderer(look.button, _T("<")),
                           *this, PREVIOUS);
    next_button.Create(parent, layout.next_button, button_style,
                       new SymbolButtonRenderer(look.button, _T(">")),
                       *this, NEXT);
  }

  close_button.Create(parent, look.button, _("Close"), layout.close_button,
                      button_style, dialog, mrOK);

  info_dock.Create(parent, layout.main, dock_style);
  info_dock.SetWidget(&info_widget);

  details_panel.Create(parent, look, layout.main, dock_style);
  details_text.Create(details_panel, layout.details_text);
  details_text.SetFont(look.text_font);
  details_text.SetText(waypoint.details.c_str());

#ifdef HAVE_RUN_FILE
  const unsigned num_files = std::distance(waypoint.files_external.begin(),
                                           waypoint.files_external.end());
  if (num_files > 0) {
    file_list.Create(details_panel, layout.file_list,
                     WindowStyle(), layout.file_list_item_height);
    file_list.SetItemRenderer(&file_list_handler);
    file_list.SetCursorHandler(&file_list_handler);
    file_list.SetLength(num_files);
  }
#endif

  commands_dock.Create(parent, layout.main, dock_style);
  commands_dock.SetWidget(&commands_widget);

  if (!images.empty())
    image_window.Create(parent, layout.main, dock_style,
                        [this](Canvas &canvas, const PixelRect &rc){
                          OnImagePaint(canvas, rc);
                        });

  last_page = 2 + images.size();
}