00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef BROWSERBOX_H
00023 #define BROWSERBOX_H
00024
00025 #include <list>
00026 #include <vector>
00027
00028 #include <guichan/mouselistener.hpp>
00029 #include <guichan/widget.hpp>
00030
00031 class LinkHandler;
00032
00033 struct BROWSER_LINK {
00034 int x1, x2, y1, y2;
00035 std::string link;
00036 std::string caption;
00037 };
00038
00043 class BrowserBox : public gcn::Widget, public gcn::MouseListener
00044 {
00045 public:
00049 BrowserBox(unsigned int mode = AUTO_SIZE, bool opaque = true);
00050
00054 ~BrowserBox();
00055
00059 void setLinkHandler(LinkHandler *linkHandler);
00060
00064 void setOpaque(bool opaque);
00065
00069 void setHighlightMode(unsigned int highMode);
00070
00074 void setMaxRow(int max) {mMaxRows = max; };
00075
00079 void disableLinksAndUserColors();
00080
00084 void addRow(const std::string &row);
00085
00089 void clearRows();
00090
00094 void mousePressed(gcn::MouseEvent &event);
00095 void mouseMoved(gcn::MouseEvent &event);
00096
00100 void draw(gcn::Graphics *graphics);
00101
00105 enum {
00106 AUTO_SIZE,
00107 AUTO_WRAP
00108 };
00109
00120 enum {
00121 RED = 0xff0000,
00122 GREEN = 0x009000,
00123 BLUE = 0x0000ff,
00124 ORANGE = 0xe0980e,
00125 YELLOW = 0xf1dc27,
00126 PINK = 0xff00d8,
00127 PURPLE = 0x8415e2,
00128 GRAY = 0x919191,
00129 BROWN = 0x8e4c17
00130 };
00131
00136 enum {
00137 UNDERLINE = 1,
00138 BACKGROUND = 2
00139 };
00140
00141 private:
00142 typedef std::list<std::string> TextRows;
00143 typedef TextRows::iterator TextRowIterator;
00144 TextRows mTextRows;
00145
00146 typedef std::vector<BROWSER_LINK> Links;
00147 typedef Links::iterator LinkIterator;
00148 Links mLinks;
00149
00150 LinkHandler *mLinkHandler;
00151 unsigned int mMode;
00152 unsigned int mHighMode;
00153 bool mOpaque;
00154 bool mUseLinksAndUserColors;
00155 int mSelectedLink;
00156 unsigned int mMaxRows;
00157 };
00158
00159 #endif