🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Untitled

posted in DruinkJournal
Published November 14, 2007
Advertisement
Another random gibber while I wait for CodeWarrior to compile...

I've been doing more to this MUD client. This time working on my subclassed RichEdit (DruinkEdit). It's basically exactly the same as a RichEdit, just some functionality is overridden.

Cool things my control can do out of the box:
  • Auto-formats text. You pass in TA2 tagged text, and the control displays it properly. No need to go through the constant mess of apply format, add text, apply next format, add more text, etc.
  • Can format URLs in any way, and doesn't break on Win98 (It used to have black URLs on a black background in some cases).
  • Has context menus!
  • Overrides paste to convert RTF text into TA2 tagged text, suitable for sending to the server.
  • Handles PML (Embedded XML data) tags automatically (TA protocol stuff).

    Here's the class interface for your amusement:
    //============================================================================// DruinkEdit.h - Overridden RichEdit window class//============================================================================#ifndef __DRUINKEDIT_H__#define __DRUINKEDIT_H__#include #include #include #include #define TA2BIT				0x80#define TA2BIT_ENABLE		0x40#define TA2BIT_BOLD			0x20#define TA2BIT_ITALIC		0x10#define TA2BIT_UNDERLINE	0x08#define TA2BIT_TEXTCOLOUR	0x04#define TA2BIT_STRIKEOUT	0x02#define TA2BIT_URL			0x01	// Used internally//============================================================================// Main classclass CDruinkEdit{public:	CDruinkEdit();	~CDruinkEdit() {Release();}	void Release();	// Only valid to call before control is created	void SetDefaultTextColour(COLORREF crText);	void SetDefaultBackColour(COLORREF crBack);	// General functions	bool Create(HINSTANCE hInstance, HWND hWndParent, DWORD x, DWORD y,		DWORD w, DWORD h, bool bReadOnly);	bool AddText(const std::string& strText);	void Clear();	void SetFont(const std::string& strFont, int nSize);	void SetURLFormat(BYTE byTA2Bits, COLORREF crText=0xffffffff, COLORREF crBack=0xffffffff);	std::string GetText() const;	void SetText(const std::string& str);	std::string GetNextPMLTag();	// Accessors	HWND GetWindow() const {return m_hWnd;}	bool WasEnterPressed() const {return m_bEnterPressed;}	bool HasPMLWaiting() const {return !m_vPMLTags.empty();}private:	// Snip};#endif // __DRUINKEDIT_H__
    I'll probably release the control once I'm done with it, since it's pretty useful, and has pleanty of examples on how to do stuff in it (Like handling popup menus, clipboard stuff, etc).

    I tinkered with making my own control completely, one which renders its own characters, but it ended up pretty complicated and buggy - and this was just for an output control, and input control would be even worse.

    Anyway, back to work...
  • Previous Entry Untitled
    Next Entry Untitled
    0 likes 0 comments

    Comments

    Nobody has left a comment. You can be the first!
    You must log in to join the conversation.
    Don't have a GameDev.net account? Sign up!
    Advertisement
    Advertisement