tbx  0.7.6
textdisplaywindow.h
1 /*
2  * tbx RISC OS toolbox library
3  *
4  * Copyright (C) 2012 Alan Buckley All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included
14  * in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  */
24 /*
25  * textdisplaywindow.h
26  *
27  * Created on: 2 Mar 2012
28  * Author: alanb
29  */
30 
31 #ifndef TBX_TEXTDISPLAYWINDOW_H_
32 #define TBX_TEXTDISPLAYWINDOW_H_
33 
34 #include <string>
35 #include <vector>
36 
37 #include "redrawlistener.h"
38 #include "hasbeenhiddenlistener.h"
39 #include "window.h"
40 #include "showfullspec.h"
41 
42 namespace tbx {
43 
59  public tbx::RedrawListener,
61 {
62 protected:
63  tbx::Window _window;
64 private:
65  std::string _text;
66  std::vector<int> _line_end;
67  tbx::BBox _text_bounds;
68  bool _delete_on_hide;
69  tbx::Command *_close_command;
70  bool _delete_close_command;
71 
72  virtual void redraw (const tbx::RedrawEvent &e);
73  virtual void has_been_hidden (const tbx::EventInfo &hidden_event);
74 
75  void create_window(const char *buttons,
76  int default_button, int cancel_button,
77  int button_width);
78  bool calc_line_ends(int max_width);
79 
80 public:
81  TextDisplayWindow(const std::string &text, const char *buttons,
82  int default_button = -1, int cancel_button = -1,
83  int button_width = 200);
84  virtual ~TextDisplayWindow();
85 
86  void title(const std::string &title);
90  tbx::Window window() {return _window;}
91 
92  void delete_on_hide();
93  void close_command(tbx::Command *close_command, bool delete_command = false);
94 
95  void show();
96  void show_as_menu();
97 };
98 
99 } /* namespace tbx */
100 #endif /* TEXTDISPLAYWINDOW_H_ */
tbx
A library for creating RISC OS toolbox applications.
Definition: abouttobeshownlistener.cc:35
tbx::TextDisplayWindow::title
void title(const std::string &title)
Set the title for the text display window.
Definition: textdisplaywindow.cc:90
tbx::TextDisplayWindow::window
tbx::Window window()
Get underlying window used for the message window.
Definition: textdisplaywindow.h:90
tbx::Window
The Window object represents a toolbox window.
Definition: window.h:70
tbx::TextDisplayWindow::show
void show()
Show the text display window.
Definition: textdisplaywindow.cc:129
tbx::TextDisplayWindow::~TextDisplayWindow
virtual ~TextDisplayWindow()
Destructor, delete close command if necessary.
Definition: textdisplaywindow.cc:79
tbx::HasBeenHiddenListener
Listener for an object has been hidden event.
Definition: hasbeenhiddenlistener.h:36
tbx::TextDisplayWindow
Class to show some text in a window in the centre of the screen, with an icon to the left and one or ...
Definition: textdisplaywindow.h:61
tbx::BBox
Class to represent a two dimensional bounding box.
Definition: bbox.h:38
tbx::TextDisplayWindow::show_as_menu
void show_as_menu()
Show the text display window as a menu.
Definition: textdisplaywindow.cc:142
tbx::RedrawListener
Redraw event listener.
Definition: redrawlistener.h:76
tbx::Command
Base class for commands in tbx.
Definition: command.h:37
tbx::TextDisplayWindow::delete_on_hide
void delete_on_hide()
Set up text display window to delete itself when it is hidden.
Definition: textdisplaywindow.cc:100
tbx::RedrawEvent
Event passed to redraw listener to give details on the area that needs a redraw.
Definition: redrawlistener.h:44
tbx::TextDisplayWindow::TextDisplayWindow
TextDisplayWindow(const std::string &text, const char *buttons, int default_button=-1, int cancel_button=-1, int button_width=200)
Construct a text display window with the given text and buttons.
Definition: textdisplaywindow.cc:62
tbx::TextDisplayWindow::close_command
void close_command(tbx::Command *close_command, bool delete_command=false)
Set command to be run when message window is closed.
Definition: textdisplaywindow.cc:116
tbx::EventInfo
Class to provide information on a toolbox event.
Definition: eventinfo.h:49