Introduction
Menus, Toolbars, Dialog Boxes, Controls provide a way to execute commands and provide text input to apps. But I did not find a convenient way to output large amounts of text data. The doc/view separates the processing from the management of the window but there is still some work that needs to be done to output to the window.
So let be clear. A doc/view app has a few bars at the top of the window (e.g. Menu bar, Tool Bar, Tabs, etc.). At the bottom of the window is a status bar. The space in between is just empty. That is the area to which NotePad sends text information. Think of it as a pad of paper which has a finite width but infinite length. It has a vertical scroll bar, but no horizontal scroll bar.
NotePad does not manage the output so that a paragraph is displayed wrapping the text so that it is all visible in the window. But with some additonal work, it will wrap text output. The raw mode, if I can call it that, is just translating objects into text output. Of course the objects need to be amenable to text output.
NotePad is a class so there can be many objects. But the easiest way to use NotePad is with one global object called "notePad". It is defined in the NotePad header file. Here are some examples of using notePad:
notePad.clear();
notePad << _T("Line of text followed by a carriage return and line feed.") << nCrlf;
s.format(_T("This is an string with an integer following: "), i);
notePad << s << nCrlf;
notePad << _T("This is an string with an integer following: ") << i << nCrlf;
The last two lines output the same information. There are many features and I'll try to document all of them here. Once something is output it stays in the window until the notePad is cleared.
- notePad << tc; -- where tc is a constant tchar* (i.e. TCchar*), a c style string
- notePad << s; -- where stg is a String (my string class)
- notePad << cs; -- where cs is either a Cstring or CString
- notePad << bs; -- where bs is a bstr_t (i.e. a B string)
- notePad << tc; -- where tc is a character (char or Tchar)
- notePad << cs; -- where cs is a const char*
- notePad << v; -- where v is an int
- notePad << v; -- where v is a size_t (i.e. __int64)
- notePad << v; -- where v is a long
- notePad << v; -- where v is an unsigned long (ulong)
- notePad << v; -- where v is a double
- notePad << dt; -- where dt is a Date
- notePad << nSetTab(v); -- Sets a tab at the vth char position
- notePad << nSetRtab(v); -- Sets a tab such that the right end
of a tab word is at the tab position - notePad << nSetLMargin(v); -- Sets the left margin
- notePad << nSetWidth(v); -- Sets the minimum width of the next integer or double
- notePad << nSetPrec(v); -- Sets the number of digits after the decimal point of the next double
- notePad << nFSize(v); -- Sets the number of digits in a floating point
- notePad << nFFace(tc); -- Sets the font face (e.g. _T("Arial")), push the current font
- notePad << nClrTabs; -- Clear all tabs
- notePad << nTab; -- Insert a tab in the output, i.e move to next tab
- notePad << nCenter; -- Center the next phrase
- notePad << nRight; -- Right adjust phrase in the line
- notePad << nBeginLine; -- Begin underlining output
- notePad << nEndLine; -- End underlining output
- notePad << nCrlf; -- Output a carriage return and line feed
- notePad << nEndPage; -- End printer page
- notePad << nBold; -- Begin bold font output, push current font
- notePad << nItalic; -- Begin italic font output, push current font
- notePad << nUnderLine; -- Begin underline font, push current font
- notePad << nStrikeOut; -- Begin strike out font, push current font
- notePad << nFont; -- Pop previous font
If the operator "<<" is treated as a streaming operator then sending data to the notepad is a representation of the window output area. So multiple outputs may be placed on the same line or divided between two or more lines. For example:
void anExample {
Cstring mumble = _T(" *** Cstring test *** ");
CString foo = _T(" --- CString test --- ");
String goo = _T(" +++ String test +++ ");
bstr_t bs = _T(" ^^^ BString test ^^^ ");
notePad << _T(" *** TCchar* test *** ") << mumble << foo;
notePad << goo << bs << nCrlf;
notePad << _T("Next Line") << nCrlf; }
The anExample function would yield the following output in the window:
*** TCchar* test *** *** Cstring test *** --- CString test --- +++ String test +++ ^^^ BString test ^^^
Next Line
:More examples appear in a pdf file that you can find here. The code that produces the example is:
void TestAppDoc::notePadExamples() {
Cstring mumble = _T(" *** Cstring test *** ");
CString foo = _T(" --- CString test --- ");
String goo = _T(" +++ String test +++ ");
bstr_t bs = _T(" ^^^ BString test ^^^ ");
notePad << _T("Loaded ") << mumble << foo << goo << CbxCaption << _T(" into ComboBx") << nCrlf;
notePad << mumble << nCrlf;
notePad << foo << nCrlf;
notePad << goo << nCrlf;
notePad << bs << nCrlf;
}