/*
 * ProviewR   Open Source Process Control.
 * Copyright (C) 2005-2020 SSAB EMEA AB.
 *
 * This file is part of ProviewR.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with ProviewR. If not, see <http://www.gnu.org/licenses/>
 *
 * Linking ProviewR statically or dynamically with other modules is
 * making a combined work based on ProviewR. Thus, the terms and
 * conditions of the GNU General Public License cover the whole
 * combination.
 *
 * In addition, as a special exception, the copyright holders of
 * ProviewR give you permission to, from the build function in the
 * ProviewR Configurator, combine ProviewR with modules generated by the
 * ProviewR PLC Editor to a PLC program, regardless of the license
 * terms of these modules. You may copy and distribute the resulting
 * combined work under the terms of your choice, provided that every
 * copy of the combined work is accompanied by a complete copy of
 * the source code of ProviewR (the version used to produce the
 * combined work), being distributed under the terms of the GNU
 * General Public License plus this exception.
 */

#ifndef rt_xtt_main_h
#define rt_xtt_main_h

/* rt_xtt_main.h -- Simple navigator */

#include "xtt_xnav.h"

class CoWow;
class CoWowTimer;
class XttMethodToolbar;

class Xtt {
public:
  void* parent_ctx;
  char name[80];
  XNav* xnav;
  void* root_item;
  int input_open;
  int command_open;
  void (*india_ok_cb)(Xtt*, char*);
  qcom_sQid queid;
  CoWowTimer* timerid;
  CoWow* wow = NULL;
  pwr_tOName opplace_str;
  int quiet;
  int attach_audio;
  XttMethodToolbar* methodtoolbar;
  int select_opplace;
  int op_close_button;
  int no_advanceduser;
  int network_optimized;

  Xtt(int* argc, char** argv[], int* return_sts);
  virtual ~Xtt();
  virtual void message(char severity, const char* msg);
  virtual void open_input_dialog(const char* text, const char* title,
      const char* init_text, void (*ok_cb)(Xtt*, char*));
  virtual void set_prompt(const char* prompt);
  virtual void open_change_value();
  virtual void print();

  void list_opplace();
  static void opplace_selected_cb(void* ctx, char* text, int ok_pressed);

  void hotkey_activate_command(char* cmdp);
  static void hotkey_activate_toggledig(char* namep);
  static void hotkey_activate_setdig(char* namep);
  static void hotkey_activate_resetdig(char* namep);
  static void hotkey_activate_setvalue(char* namep, char *valuep);

  static void open_URL_cb(void* ctx, char* url);
  static void qcom_events(void* data);
  static void findregex_ok(Xtt* xtt, char* search_str);
  static void find_ok(Xtt* xtt, char* search_str);
  static void xtt_message_cb(void* ctx, char severity, const char* msg);
  static void close_ok(void* ctx, void* data);
  static void change_value(void* ctx);
  static void selection_changed(void* ctx);
  static int xnav_get_select(void* ctx, pwr_tAttrRef* attrref, int* is_attr);

  void activate_print();
  void activate_find();
  void activate_findregex();
  void activate_findnext();
  void activate_collapse();
  void activate_openobject();
  void activate_openplc();
  void activate_opengraph();
  void activate_collect_insert();
  void activate_advanceduser();
  void activate_zoom_in();
  void activate_zoom_out();
  void activate_help();
  void activate_help_navigator();
  void activate_help_project();
  void activate_help_proview();
  void activate_method(char* method, char* filter);

  static Xtt* hot_xtt;
  static xnav_sStartMenu alarm_menu[];
  static xnav_sStartMenu nethandler_menu[];
  static xnav_sStartMenu communication_menu[];
  static xnav_sStartMenu logging_menu[];
  static xnav_sStartMenu system_menu[];
  static xnav_sStartMenu root_menu[];
};

#endif