- Main Page
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

# TextBuffer Class Reference

List of all members.

## Public Member Functions
| TextBuffer ()
| ~TextBuffer ()
int | GetNumberOfLines ()
void | SetHeightOfPage (int a_height)
void | SetEndOfPage (int a_value)
int | GetEndOfPage ()
void | IncrementEndOfPage ()
void | DecrementEndOfPage ()
void | JumpDownEndOfPage ()
void | JumpUpEndOfPage ()
G4bool | AppendString (char *a_string)
void | Draw (HDC a_hdc, RECT *a_rect)
## Private Attributes
G4String * | lines
int | linen
int | linei
int | endOfPage
int | heightOfPage
char | spaces [256]

## Detailed Description

Definition at line 55 of file G4UIWin32.cc.

## Constructor & Destructor Documentation

TextBuffer::TextBuffer | ( |  | ) |

Definition at line 81 of file G4UIWin32.cc.

References linen, lines, and spaces.

    00082  : linei(0),linen(TEXT_MAX_LINES),endOfPage(0),heightOfPage(12)
    00083 {
    00084   lines = new G4String[linen];
    00085   for(int count=0;count<256;count++) spaces[count] = ' ';
    00086 }

TextBuffer::~TextBuffer | ( |  | ) |

Definition at line 88 of file G4UIWin32.cc.

References lines.

    00089 {
    00090   delete [] lines;
    00091 }

## Member Function Documentation

int TextBuffer::GetNumberOfLines | ( |  | ) | `[inline]`

Definition at line 61 of file G4UIWin32.cc.

References linei.

    00061 { return linei;}

void TextBuffer::SetHeightOfPage | ( | int | a_height | ) | `[inline]`

Definition at line 62 of file G4UIWin32.cc.

References heightOfPage.

    00062 { heightOfPage = a_height; }

void TextBuffer::SetEndOfPage | ( | int | a_value | ) |

Definition at line 93 of file G4UIWin32.cc.

References endOfPage, and linei.

    00094 {
    00095   if( (a_value<0) || (a_value>=linei)) {
    00096     endOfPage = linei-1;
    00097   } else {
    00098     endOfPage = a_value;
    00099   }
    00100 }

int TextBuffer::GetEndOfPage | ( |  | ) | `[inline]`

Definition at line 64 of file G4UIWin32.cc.

References endOfPage.

    00064 { return endOfPage; }

void TextBuffer::IncrementEndOfPage | ( |  | ) |

Definition at line 102 of file G4UIWin32.cc.

References endOfPage, and linei.

    00103 {
    00104   endOfPage++;
    00105   if(endOfPage>=linei) endOfPage = linei-1;
    00106 }

void TextBuffer::DecrementEndOfPage | ( |  | ) |

Definition at line 108 of file G4UIWin32.cc.

References endOfPage.

    00109 {
    00110   endOfPage--;
    00111   if(endOfPage<0) endOfPage = 0;
    00112 }

void TextBuffer::JumpDownEndOfPage | ( |  | ) |

Definition at line 114 of file G4UIWin32.cc.

References endOfPage, heightOfPage, and linei.

    00115 {
    00116   endOfPage += heightOfPage;
    00117   if(endOfPage>=linei) endOfPage = linei-1;
    00118 }

void TextBuffer::JumpUpEndOfPage | ( |  | ) |

Definition at line 120 of file G4UIWin32.cc.

References endOfPage, and heightOfPage.

    00121 {
    00122   endOfPage -= heightOfPage;
    00123   if(endOfPage<0) endOfPage = 0;
    00124 }

G4bool TextBuffer::AppendString | ( | char * | a_string | ) |

Definition at line 126 of file G4UIWin32.cc.

References endOfPage, linei, linen, and lines.

    00127 {
    00128   G4bool value = false;
    00129   if( (a_string==NULL) || (a_string[0]=='\0') ) return value;
    00130   int length = strlen(a_string);
    00131   if(a_string[length-1]=='\n') {
    00132     lines[linei] += a_string;
    00133     lines[linei] = lines[linei].strip(G4String::trailing,'\n');
    00134     linei++;
    00135     value = true;
    00136   } else {
    00137     lines[linei] += a_string;
    00138   }
    00139   if(linei>=linen) {
    00140     for(int count=0;count<linen;count++) {
    00141       lines[count] = "";
    00142     }
    00143     linei = 0;
    00144   }
    00145   if(value==true) endOfPage = linei-1;
    00146   return value;
    00147 }

void TextBuffer::Draw | ( | HDC | a_hdc,
|  | RECT * | a_rect |
| ) |  |  |

Definition at line 149 of file G4UIWin32.cc.

References endOfPage, heightOfPage, linei, lines, and spaces.

    00150 {
    00151   TEXTMETRIC tm;
    00152   GetTextMetrics (a_hdc,&tm);
    00153   short charWidth = (short)tm.tmAveCharWidth;
    00154   short charHeight = (short)(tm.tmHeight + tm.tmExternalLeading);
    00155   for(int row=0;row<heightOfPage;row++) {
    00156     int rowi = endOfPage - row;
    00157     short y = (short)(a_rect->bottom - charHeight * (row + 1));
    00158     if((rowi>=0)&&(rowi<linei)) {
    00159       TextOut (a_hdc,0,y,(char*)spaces,256); //Clear text background first.
    00160       const char* string = lines[rowi].data();
    00161       if(string!=NULL) {
    00162         TextOut (a_hdc,0,y,(char*)string,strlen((char*)string));
    00163       }
    00164     }
    00165   }
    00166 }

## Member Data Documentation

G4String* TextBuffer::lines`[private]`

Definition at line 74 of file G4UIWin32.cc.

Referenced by AppendString(), Draw(), TextBuffer(), and ~TextBuffer().

int TextBuffer::linen`[private]`

Definition at line 75 of file G4UIWin32.cc.

Referenced by AppendString(), and TextBuffer().

int TextBuffer::linei`[private]`

Definition at line 76 of file G4UIWin32.cc.

Referenced by AppendString(), Draw(), GetNumberOfLines(), IncrementEndOfPage(), JumpDownEndOfPage(), and SetEndOfPage().

int TextBuffer::endOfPage`[private]`

Definition at line 77 of file G4UIWin32.cc.

Referenced by AppendString(), DecrementEndOfPage(), Draw(), GetEndOfPage(), IncrementEndOfPage(), JumpDownEndOfPage(), JumpUpEndOfPage(), and SetEndOfPage().

int TextBuffer::heightOfPage`[private]`

Definition at line 77 of file G4UIWin32.cc.

Referenced by Draw(), JumpDownEndOfPage(), JumpUpEndOfPage(), and SetHeightOfPage().

char TextBuffer::spaces[256]`[private]`

Definition at line 78 of file G4UIWin32.cc.

Referenced by Draw(), and TextBuffer().

The documentation for this class was generated from the following file:

- G4UIWin32.cc