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
|
/*
** Copyright 2002, Double Precision Inc.
**
** See COPYING for distribution information.
*/
#ifndef cursesdialog_H
#define cursesdialog_H
#include "../curses/curses_config.h"
#include "cursescontainer.H"
#include <vector>
////////////////////////////////////////////////////////////////////////////
//
// A helper container that formats dialog screens.
//
// The CursesDialog contains a list of fields, and their corresponding labels.
// The labels are right aligned.
//
class CursesLabel;
class CursesField;
class CursesDialog : public CursesContainer {
std::vector< std::pair<CursesLabel *, Curses *> > prompts;
int max_label_width;
int max_field_width;
// To prevent a lot of extra work, quietly eat all WriteText()s
// until the dialog is complete.
int draw_flag;
public:
CursesDialog(CursesContainer *parent);
~CursesDialog();
// Calculate max size.
int getWidth() const;
int getHeight() const;
void draw();
// Add a new input field, and its corresponding prompt
// (either one may be NULL, both can be NULL to append some useful
// filler).
virtual void addPrompt(CursesLabel *label,
Curses *field);
virtual void addPrompt(CursesLabel *label,
Curses *field,
size_t atRow);
void delPrompt(CursesLabel *label);
void delPrompt(Curses *field);
private:
void delPrompt(std::vector< std::pair<CursesLabel *, Curses *> >::iterator p,
int row);
public:
void deleteChild(Curses *child);
bool writeText(const char *text, int row, int col,
const CursesAttr &attr) const;
bool writeText(const std::vector<unicode_char> &text, int row, int col,
const Curses::CursesAttr &attr) const;
};
#endif
|