btrfs: Attempt to fix GCC2 build.
[haiku.git] / src / apps / launchbox / Panel.cpp
blobe179bf49ebbf22cbaf4c2851d118e2f7f4acf0be
1 /*
2 * Copyright 2006, Haiku.
3 * Distributed under the terms of the MIT License.
5 * Authors:
6 * Stephan Aßmus <superstippi@gmx.de>
7 */
9 #include "Panel.h"
11 #include <stdio.h>
13 #include <InterfaceDefs.h>
14 #include <Message.h>
15 #include <MessageFilter.h>
17 class EscapeFilter : public BMessageFilter {
18 public:
19 EscapeFilter(Panel* target)
20 : BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE),
21 fPanel(target)
24 virtual ~EscapeFilter()
27 virtual filter_result Filter(BMessage* message, BHandler** target)
29 filter_result result = B_DISPATCH_MESSAGE;
30 switch (message->what) {
31 case B_KEY_DOWN:
32 case B_UNMAPPED_KEY_DOWN: {
33 uint32 key;
34 if (message->FindInt32("raw_char", (int32*)&key) >= B_OK) {
35 if (key == B_ESCAPE) {
36 result = B_SKIP_MESSAGE;
37 fPanel->Cancel();
40 break;
42 default:
43 break;
45 return result;
47 private:
48 Panel* fPanel;
51 // constructor
52 Panel::Panel(BRect frame, const char* title,
53 window_type type, uint32 flags,
54 uint32 workspace)
55 : BWindow(frame, title, type, flags, workspace)
57 _InstallFilter();
60 // constructor
61 Panel::Panel(BRect frame, const char* title,
62 window_look look, window_feel feel,
63 uint32 flags, uint32 workspace)
64 : BWindow(frame, title, look, feel, flags, workspace)
66 _InstallFilter();
69 // destructor
70 Panel::~Panel()
74 // MessageReceived
75 void
76 Panel::Cancel()
78 PostMessage(B_QUIT_REQUESTED);
81 // _InstallFilter
82 void
83 Panel::_InstallFilter()
85 AddCommonFilter(new EscapeFilter(this));