File: Toplevel.cpp

package info (click to toggle)
sear 0.5.0-5
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 3,408 kB
  • ctags: 2,580
  • sloc: cpp: 14,902; sh: 10,890; makefile: 172
file content (54 lines) | stat: -rw-r--r-- 1,099 bytes parent folder | download
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
// This file may be redistributed and modified only under the terms of
// the GNU General Public License (See COPYING for details).
// Copyright (C) 2004 Alistair Riddoch

#include "gui/Toplevel.h"

#include "gui/Frame.h"
#include "gui/Workspace.h"
#include "gui/RootWindow.h"

#include <iostream>

namespace Sear {

static const int min_width = 20;
static const int min_height = 20;

Toplevel::Toplevel(const std::string & title) : m_contents(0),
                                                m_frame(new Frame()),
                                                m_title(title)
{
  m_frame->setSize(min_width, min_height);
}

Toplevel::~Toplevel()
{
}

void Toplevel::setContents(Widget * w)
{
  m_contents = w;
  addChild(w);
}

void Toplevel::setPos(int x, int y)
{
  m_frame->setPos(x, y);
}

void Toplevel::show()
{
  Workspace * ws = dynamic_cast<Workspace *>(m_parent);

  if (ws == 0) {
    std::cerr << "Toplevel parent is not a Workspace"
              << std::endl << std::flush;
    return;
  }

  RootWindow * rw = ws->getRootWindow();
  rw->addChild(m_frame);
}

} // namespace Sear