| 1 |
sf-pippijn |
1.1 |
/* frame.cc |
| 2 |
|
|
* This file is part of NDK++ library |
| 3 |
|
|
* Copyright (c) 2003,2004 by Stanislav Ievlev |
| 4 |
|
|
* |
| 5 |
|
|
* This file is covered by the GNU Library General Public License, |
| 6 |
|
|
* which should be included with libndk++ as the file COPYING. |
| 7 |
|
|
*/ |
| 8 |
|
|
|
| 9 |
sf-pippijn |
1.2 |
#include <ndk++/pen.hh> |
| 10 |
sf-pippijn |
1.1 |
#include <ndk++/frame.hh> |
| 11 |
|
|
#include <ndk++/palette.hh> |
| 12 |
|
|
|
| 13 |
|
|
|
| 14 |
|
|
ndk::frame::frame (std::string const &title, panel *parent) |
| 15 |
|
|
: panel (parent) |
| 16 |
|
|
, title_ (title) |
| 17 |
|
|
, active_ (false) |
| 18 |
|
|
{ |
| 19 |
|
|
events ()->on_system (slot (&frame::at_system, this)); |
| 20 |
|
|
} |
| 21 |
|
|
|
| 22 |
|
|
void |
| 23 |
|
|
ndk::frame::draw () |
| 24 |
|
|
{ |
| 25 |
|
|
panel::draw (); |
| 26 |
|
|
|
| 27 |
sf-pippijn |
1.2 |
pen p (*this); |
| 28 |
sf-pippijn |
1.1 |
p.clear (); |
| 29 |
|
|
|
| 30 |
sf-pippijn |
1.2 |
p.set_color (palette::instance ().find (active_ ? colors::frame1 : colors::frame2)->second); |
| 31 |
sf-pippijn |
1.1 |
p.frame (); |
| 32 |
|
|
if (!title_.empty ()) |
| 33 |
|
|
p.title (title_.substr (0, width () - 2)); |
| 34 |
sf-pippijn |
1.2 |
p.set_color (palette::instance ().find (colors::frame2)->second); |
| 35 |
sf-pippijn |
1.1 |
} |
| 36 |
|
|
|
| 37 |
|
|
int |
| 38 |
|
|
ndk::frame::padding () const |
| 39 |
|
|
{ |
| 40 |
|
|
return 1; |
| 41 |
|
|
} |
| 42 |
|
|
|
| 43 |
|
|
void |
| 44 |
|
|
ndk::frame::set_title (std::string const &title) |
| 45 |
|
|
{ |
| 46 |
|
|
title_ = title; |
| 47 |
|
|
} |
| 48 |
|
|
|
| 49 |
|
|
ndk::event::result |
| 50 |
|
|
ndk::frame::at_system (ndk::event const &ev) |
| 51 |
|
|
{ |
| 52 |
|
|
event::result res = event::ignored; |
| 53 |
|
|
|
| 54 |
|
|
if (!ev.sender_) |
| 55 |
|
|
{ |
| 56 |
|
|
active_ = engine::enter_focus == ev.type_; |
| 57 |
|
|
prepare (); |
| 58 |
|
|
res = event::accepted; |
| 59 |
|
|
} |
| 60 |
|
|
|
| 61 |
|
|
return res; |
| 62 |
|
|
} |