summaryrefslogtreecommitdiffstats
path: root/tdemdi/test/mainwidget.cpp
blob: 6438ff978c556df203853b2b7ebe96094f17ff71 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/***************************************************************************
                          mainwidget.cpp  -  description
                             -------------------
    begin                : Mon Nov 8 1999
    copyright            : (C) 1999 by Falk Brettschneider
    email                : falkbr@kdevelop.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 <tqlayout.h>
#include <tqmenubar.h>
#include <tqtoolbar.h>
#include <tqmultilineedit.h>
#include <tqlistview.h>
#include <tqfile.h>
#include <tdemdimainfrm.h>
#include <tdemditoolviewaccessor.h>

#include "mainwidget.h"

MainWidget::MainWidget(TQDomElement& dockConfig,KMdi::MdiMode mode)
: KMdiMainFrm(0L, "theMDIMainFrm",mode)
 ,m_dockConfig(dockConfig)
{
   setIDEAlModeStyle(1); // KDEV3

   dockManager->setReadDockConfigMode(KDockManager::RestoreAllDockwidgets);
   initMenu();

   if (m_dockConfig.hasChildNodes()) {
        readDockConfig(m_dockConfig);
   }

   TQMultiLineEdit* mle = new TQMultiLineEdit(0L,"theMultiLineEditWidget");
   mle->setText("This is a TQMultiLineEdit widget.");
   addToolWindow( mle, KDockWidget::DockBottom, m_pMdi, 70);

   TQMultiLineEdit* mle2 = new TQMultiLineEdit(0L,"theMultiLineEditWidget2");
   addToolWindow( mle2, KDockWidget::DockCenter, mle, 70);

   TQMultiLineEdit* mle3 = new TQMultiLineEdit(0L,"theMultiLineEditWidget3");
   addToolWindow( mle3, KDockWidget::DockCenter, mle, 70);

   TQMultiLineEdit* mle4 = new TQMultiLineEdit(0L,"theMultiLineEditWidget4");
   addToolWindow( mle4, KDockWidget::DockCenter, mle, 70);

   KMdiToolViewAccessor *tva=createToolWindow();
   tva->setWidgetToWrap(new TQMultiLineEdit(tva->wrapperWidget(),"theMultiLineEditWidget5"));
   tva->placeAndShow(KDockWidget::DockCenter,mle,70);   

   TQListView* lv = new TQListView(0L,"theListViewWidget");
#include "../res/filenew.xpm"
   lv->setIcon(filenew);
   lv->addColumn("Test", 50);
   lv->addColumn("KMDI", 70);
   new TQListViewItem(lv,TQString("test"),TQString("test"));
   addToolWindow( lv, KDockWidget::DockLeft, m_pMdi, 35, "1");

   TQListView* lv2 = new TQListView(0L,"theListViewWidget2");
   lv2->setIcon(filenew);
   lv2->addColumn("Test2", 50);
   lv2->addColumn("KMDI2", 70);
   new TQListViewItem(lv,TQString("test2"),TQString("test2"));
   addToolWindow( lv2, KDockWidget::DockCenter, lv, 35, "2");
   
   TQListView* lv3 = new TQListView(0L,"theListViewWidget3");
   lv3->setIcon(filenew);
   lv3->addColumn("Test3", 50);
   lv3->addColumn("KMDI3", 70);
   new TQListViewItem(lv,TQString("test3"),TQString("test3"));
   addToolWindow( lv3, KDockWidget::DockCenter, lv, 35, "3");

   dockManager->finishReadDockConfig();

   setMenuForSDIModeSysButtons( menuBar());
}

MainWidget::~MainWidget()
{
    writeDockConfig(m_dockConfig);
    TQDomDocument doc = m_dockConfig.ownerDocument();
    TQString s = doc.toString();
    TQFile f("/tmp/dc.txt");
    f.open(IO_ReadWrite);
    f.writeBlock(s.latin1(), s.length());
    f.close();
}

void MainWidget::initMenu()
{
   menuBar()->insertItem("&Window", windowMenu());
   menuBar()->insertItem("&Docking", dockHideShowMenu());
}

/** additionally fit the system menu button position to the menu position */
void MainWidget::resizeEvent( TQResizeEvent *pRSE)
{
   KMdiMainFrm::resizeEvent( pRSE);
   setSysButtonsAtMenuPosition();
}

RestartWidget::RestartWidget():TDEMainWindow()
{
    mdimode=KMdi::ChildframeMode;
    TQVBoxLayout* bl = new TQVBoxLayout(this);
    TQLabel* l = new TQLabel("This is for the testing of\nKMdiMainFrm::read/writeDockConfig().\n", this);
    TQCheckBox* b1 = new TQCheckBox("KMdiMainFrm close/restart", this);
    b1->toggle();
    TQObject::connect(b1, TQ_SIGNAL(stateChanged(int)), this, TQ_SLOT(onStateChanged(int)));
    bl->add(l);
    bl->add(b1);
    bl->setMargin(10);
    bl->activate();
    show();

    dockConfig = domDoc.createElement("dockConfig");
    domDoc.appendChild(dockConfig);
}

void RestartWidget::onStateChanged(int on)
{
    if (on) {
        m_w = new MainWidget(dockConfig,mdimode);
        m_w->resize(500,500);
        m_w->show();
    }
    else {
        mdimode=m_w->mdiMode();
        m_w->close();
        delete m_w;
    }

}

void RestartWidget::setWindow(MainWidget *w) {
        m_w=w;
}

#include "mainwidget.moc"