summaryrefslogtreecommitdiffstats
path: root/src/libgui/register_view.cpp
blob: 40462a36c8b81a4ee4ca2c2c7fc4dd7ead42dd47 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/***************************************************************************
 *   Copyright (C) 2006 Nicolas Hadacek <hadacek@kde.org>                  *
 *                                                                         *
 *   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.                                   *
 ***************************************************************************/
#include "register_view.h"

#include <tqlayout.h>
#include <tqlabel.h>
#include <tqpushbutton.h>
#include <tqcheckbox.h>
#include <tdelocale.h>

#include "devices/base/device_group.h"
#include "devices/gui/device_group_ui.h"
#include "progs/base/prog_group.h"
#include "common/gui/misc_gui.h"
#include "main_global.h"
#include "editor_manager.h"
#include "gui_debug_manager.h"

//-----------------------------------------------------------------------------
Register::MainView::MainView(const TQString &title, const TQString &tag, TQWidget *parent)
  : DeviceEditor(title, tag, parent, "register_view"), _debugging(false)
{}

void Register::MainView::setDevice(bool force)
{
  bool oldDebugging = _debugging;
  _debugging = Main::programmerGroup().isDebugger();
  DeviceEditor::setDevice(force || oldDebugging!=_debugging);
}

TQWidget *Register::MainView::createView(const Device::Data *data, TQWidget *parent)
{
  if ( data==0 ) return new TQWidget(parent);
  Register::View *view = Device::groupui(*data).createRegisterView(parent);
  if (view) view->updateView();
  else {
    TQWidget *w = new TQWidget(parent);
    TQVBoxLayout *vbox = new TQVBoxLayout(w, 10, 10);
    TQLabel *label = new TQLabel(i18n("The selected device has no register."), w);
    vbox->addWidget(label);
    vbox->addStretch(1);
    return w;
  }
  return view;
}