/***************************************************************** * * method :void WriteReportHeader(CRect inRect) * * parameters : * * returns : * * description: Write the default report header, which is a * simply the CompanyName centered across the page. You might * want to add the address, etc. * ****************************************************************/ void CEasyReport::WriteReportHeader(CRect inRect) { CTextBox *aBox = new CTextBox(&inRect, m_CompanyName, eCaptionFont, DT_CENTER); aBox->SetDocPtr(this); m_ReportItems.Add(aBox); }
/***************************************************************** * * method :void WritePageHeader(CRect inRect) * * parameters : * * returns : * * description: Write the default page header. By default, this * contains the report title (centered) and date field, * right aligned * ****************************************************************/ void CEasyReport::WritePageHeader(CRect inRect) { CRect aRect(inRect); CTextBox *aBox; aRect.bottom = aRect.top + GetHeadingFontSize().cy; aBox = new CTextBox(&aRect,m_ReportTitle,eColHeadingFont); aBox->SetDocPtr(this); m_ReportItems.Add(aBox); // make a text area 1/4 of the page width aRect.right = inRect.right; aRect.left = inRect.right - inRect.Width()/4; aBox = new CTextBox(&aRect, m_ReportDate, eColHeadingFont, DT_LEFT); aBox->SetDocPtr(this); m_ReportItems.Add(aBox); aRect.top = inRect.bottom-10; // 1mm from the bottom aRect.bottom = inRect.bottom; aRect.left = inRect.left; aRect.right = inRect.right; CHline *aLine = new CHline(&aRect,0); aLine->SetDocPtr(this); m_ReportItems.Add(aLine); }
void CTestMenu::testCTextBox() { CBox Box; Box.iX = g_settings.screen_StartX + 10; Box.iY = g_settings.screen_StartY + 10; Box.iWidth = g_settings.screen_EndX - g_settings.screen_StartX - 20; Box.iHeight = (g_settings.screen_EndY - g_settings.screen_StartY - 20)/2; CTextBox * textBox = new CTextBox(" ", NULL, CTextBox::SCROLL, &Box); std::string text = "neutrinoHD2 is cool :-)"; int pich = 246; //FIXME int picw = 162; //FIXME int lx = Box.iX + Box.iWidth - (picw + 20); int ly = Box.iY + 20; std::string fname; fname = PLUGINDIR "/netzkino/netzkino.png"; if(access(fname.c_str(), F_OK)) fname = ""; textBox->setText(&text, fname, lx, ly, picw, pich); textBox->paint(); sleep(3); delete textBox; textBox = NULL; }
//refresh and paint digit void CVolumeBar::paintVolumeBarDigit() { // digits CTextBox* ctb = vb_digit->getCTextBoxObject(); if (ctb) ctb->setFontUseDigitHeight(); // paint digit vb_digit->paint(CC_SAVE_SCREEN_NO); }
//scroll licens text void CImageInfo::ScrollLic(bool scrollDown) { if (cc_lic && (cc_lic->cctext)) { //get the textbox instance from infobox object and use CTexBbox scroll methods CTextBox* ctb = cc_lic->cctext->getCTextBoxObject(); if (ctb) { //ctb->enableBackgroundPaint(true); if (scrollDown) ctb->scrollPageDown(1); else ctb->scrollPageUp(1); //ctb->enableBackgroundPaint(false); } } }
/***************************************************************** * * method :void CEasyReport::AtTab(int inTabStop, const char *inText) * * parameters : inTabStop * char *inText: text to display * * returns : nothing * * description: If a tabular section is in place (ie if m_NumDataCols * is non-zero, then we assume that this is a text area and we write * out a paragraph. If a tabular section is in place, we write the * data into the indicated column. * * ****************************************************************/ void CEasyReport::AtTab(int inTabStop, const char *inText) { CRect aRect; if( m_NumDataCols == 0) { WriteParagraph(inText); } else { if( m_RedrawTblHdr ) { if( m_DataTop + m_TableHeadingHt + GetDataFontSize().cy > (GetBottomEdge() - m_PageFtrHt) ) EjectPage(false); if( !m_RepeatTblHdr ) WriteTableHeader(); m_RedrawTblHdr = false; } SetupRectForCol(inTabStop, aRect); CTextBox *aBox = new CTextBox(&aRect,inText,eDataFont); aBox->SetDocPtr(this); ASSERT( inTabStop < m_NumDataCols); switch( m_DataCols[inTabStop].m_align) { case CColInfo::eLeft: aBox->SetAlign(DT_LEFT); break; case CColInfo::eDecimal: case CColInfo::eRight: // for fixed width fonts, if you control the format of data, then // simply aligning the text right aligns the decimal places. For // propotional fonts, you will have to adjust the left edge of // the box. aBox->SetAlign(DT_RIGHT); break; case CColInfo::eCenter: aBox->SetAlign( DT_CENTER ); break; } m_ReportItems.Add( aBox ); } }
int CLuaInstCCText::CCTextGetLines(lua_State *L) { CLuaCCText *D = CCTextCheck(L, 1); if (!D) return 0; lua_Integer lines = 0; if (lua_gettop(L) == 2) { const char* Text = luaL_checkstring(L, 2); lines = (lua_Integer)CTextBox::getLines(Text); } else { CTextBox* ctb = D->ct->getCTextBoxObject(); if (ctb) lines = (lua_Integer)ctb->getLines(); } lua_pushinteger(L, lines); return 1; }
/***************************************************************** * * method :void CEasyReport::WriteTableHeader(void) * * parameters : * * returns : * * description: If a tabular section is in place, write the table * header. * ****************************************************************/ void CEasyReport::WriteTableHeader(void) { int i; CRect aRect; m_RedrawTblHdr = false; aRect.top = aRect.bottom = m_DataTop; aRect.bottom += m_TableHeadingHt; aRect.left= m_LeftMargin; for(i=0;i < m_NumDataCols; i++) { CColInfo *aCol = m_DataCols+i; aRect.right = aRect.left + aCol->m_CharCount * m_TextSizes[eDataFont].cx; CTextBox *aBox = new CTextBox(&aRect, aCol->m_Heading, eColHeadingFont); switch( aCol->m_align) { case CColInfo::eLeft: aBox->SetAlign(DT_LEFT); break; case CColInfo::eDecimal: case CColInfo::eRight: // for fixed width fonts, if you control the format of data, then // simply aligning the text right aligns the decimal places. For // propotional fonts, you will have to adjust the left edge of // the box. Decimal cols will be supported in a later version aBox->SetAlign(DT_RIGHT); break; case CColInfo::eCenter: aBox->SetAlign( DT_CENTER ); break; } aBox->SetDocPtr(this); m_ReportItems.Add(aBox); aRect.left = aRect.right; } m_DataTop += m_TableHeadingHt; }
int CLuaInstCCText::CCTextScroll(lua_State *L) { lua_assert(lua_istable(L,1)); CLuaCCText *D = CCTextCheck(L, 1); if (!D) return 0; std::string tmp = "true"; tableLookup(L, "dir", tmp); bool scrollDown = (tmp == "down" || tmp == "1"); lua_Integer pages = 1; tableLookup(L, "pages", pages); //get the textbox instance from lua object and use CTexBbox scroll methods CTextBox* ctb = D->ct->getCTextBoxObject(); if (ctb) { if (pages == -1) pages = ctb->getPages(); ctb->enableBackgroundPaint(true); if (scrollDown) ctb->scrollPageDown(pages); else ctb->scrollPageUp(pages); ctb->enableBackgroundPaint(false); } return 0; }
/***************************************************************** * * method :void WriteParagraph(const char *inText) * * parameters : inText: Long text which may be word wrapped * * returns : nothing * * description: Write a paragraph of text. If the text extends * beyond the right edge, the text is wrapped around. Note: This * function is not called directly, but through AtTab with tabs * set to NULL. * ****************************************************************/ void CEasyReport::WriteParagraph(const char *inText) { int aAbsBottom, aAbsWidth; int aCurPos, aLen, aRight; char aTempStr[128]; // non portable (should be TCHAR etc)! CRect aRect; CSize aSize; CTextBox *aBox; aRect.left = m_LeftMargin; aRect.right = m_PageWidth - m_RightMargin; aAbsBottom = m_PageHeight - ( m_BottomMargin + m_PageFtrHt ); aAbsWidth = m_PageWidth - ( m_LeftMargin + m_RightMargin); aLen = strlen(inText); aCurPos = 0; ::SelectObject(m_PrinterDC,(HFONT)m_Fonts[eTextFont]); ::SetTextCharacterExtra(m_PrinterDC,0); while(inText[aCurPos]) { if( m_DataTop + m_TextSizes[eTextFont].cy > aAbsBottom ) { EjectPage(false); aAbsBottom = m_PageHeight - ( m_BottomMargin + m_PageFtrHt ); } // see if the remainder of the string will fit into the right margin ::SetTextJustification(m_PrinterDC,0,0); ::GetTextExtentExPoint(m_PrinterDC, inText + aCurPos, aLen - aCurPos, aAbsWidth, &aRight,NULL, &aSize); if( inText[aCurPos+aRight] != 0 ) { while( inText [aCurPos + aRight ] != m_BreakChar ) { --aRight; if( aRight <= 0 ) { // Hopeless, the entire string is one big word ! ::GetTextExtentExPoint(m_PrinterDC, inText + aCurPos, aLen - aCurPos, aAbsWidth, &aRight,NULL, &aSize); --aRight; break; } } } ASSERT(aRight < sizeof(aTempStr)); // Warning ! this check is at compile time only ! strncpy( aTempStr, inText + aCurPos, aRight); aTempStr[aRight] = 0; aRect.top = m_DataTop; aRect.bottom = aRect.top + m_TextSizes[eTextFont].cy; aBox = new CTextBox(&aRect, aTempStr, eTextFont); aBox->SetDocPtr( this ); m_ReportItems.Add(aBox); if( inText[ aCurPos + aRight] == m_BreakChar) ++aRight; aCurPos += aRight; m_DataTop += m_TextSizes[eTextFont].cy; } }
void CComponentsFrmClock::initCCLockItems() { //prepare and set current time string initTimeString(); string s_time = cl_timestr; /* create label objects and add to container, ensure that count of items = count of chars (one char = one segment) * this is required for the case, if any time string format was changed */ if (v_cc_items.empty() || (v_cc_items.size() != s_time.size())){ //exit on empty time string if (s_time.empty()){ clear(); return; } //clean up possible old items before add new items clear(); //create new empty label objects, set some general properties and add to container for (size_t i = 0; i < s_time.size(); i++){ CComponentsLabel * lbl = new CComponentsLabel(); addCCItem(lbl); //background paint of item is not required lbl->doPaintBg(false); //preset corner properties of label item lbl->setCorner(max(0, corner_rad-fr_thickness), corner_type); //set text border to 0 lbl->setTextBorderWidth(0,0); } } /*calculate minimal separator width, we use char size of some possible chars * TODO: it's not really generic at the moment */ int minSepWidth = 0; string sep[] ={" ", ".", ":"}; for (size_t i = 0; i < sizeof(sep)/sizeof(sep[0]); i++) minSepWidth = max(cl_font->getRenderWidth(sep[i]), minSepWidth); //get minimal required dimensions for segements from current format string int w_text_min = max(cl_font->getRenderWidth(s_time), width); int h_text_min = max(cl_font->getHeight(), height); //init some temporary variables int x_tmp = x; int h_tmp = h_text_min; int y_tmp = y; //summary of all segments (labels) int w_segments = 0; /* modify available label items with current segment chars * we are using segments with only one char per segment, * these chars are predefined via format string */ for (size_t i = 0; i < v_cc_items.size(); i++) { //v_cc_items are only available as CComponent-items here, so we must cast them before CComponentsLabel *lbl = static_cast <CComponentsLabel*> (v_cc_items[i]); //add rounded corners only to 1st and last segment if (corner_type) { if (i == 0) lbl->setCornerType(corner_type & CORNER_LEFT);// 1st label item else if (i == v_cc_items.size()-1) lbl->setCornerType(corner_type & CORNER_RIGHT);// last label item else lbl->setCorner(0,CORNER_NONE);// inner items don't need round corners } //extract timestring segment (char) string stmp = s_time.substr(i, 1); int w_tmp = minSepWidth; //get width of current segment if (isdigit(stmp.at(0)) ) //check for digits, if true, we use digit width w_tmp = cl_font->getMaxDigitWidth(); else //not digit found, we use render width or minimal width w_tmp = max(cl_font->getRenderWidth(stmp), minSepWidth); //lbl->enablePaintCache(); //set size, text, color of current item lbl->setDimensionsAll(x_tmp, y_tmp, w_tmp, h_tmp); lbl->setColorAll(col_frame, col_body, col_shadow); lbl->forceTextPaint(cl_force_repaint); lbl->setText(stmp, CTextBox::CENTER, cl_font, cl_col_text, cl_font_style); //init background behavior of segment //printf("[CComponentsFrmClock] [%s - %d] paint_bg: [%d] gradient_mode = [%d], text save screen mode = [%d]\n", __func__, __LINE__, paint_bg, cc_body_gradient_enable, cc_txt_save_screen); lbl->doPaintBg(false); lbl->doPaintTextBoxBg(paint_bg); bool save_txt_screen = cc_txt_save_screen || (!paint_bg || cc_body_gradient_enable); lbl->enableTboxSaveScreen(save_txt_screen); #if 0 //use matching height for digits for better vertical centerring into form CTextBox* ctb = lbl->getCTextBoxObject(); if (ctb) ctb->setFontUseDigitHeight(); //ensure paint of text and label bg on changed text or painted form background bool force_txt_and_bg = (lbl->textChanged() || this->paint_bg); lbl->forceTextPaint(force_txt_and_bg); #endif //set xpos and width of item (segment) lbl->setWidth(w_tmp); x_tmp += w_tmp; //sum required width for clock (this) w_segments += w_tmp; h_text_min = max(lbl->getHeight(), height); height = max(lbl->getHeight(), height); } //set required width for clock (this) width = max(w_text_min, w_segments); //use first item as reference and set x and y position to the 1st segement item with definied alignment int x_lbl = width/2-w_segments/2; v_cc_items[0]->setXPos(x_lbl); int y_lbl = height/2-h_text_min/2; v_cc_items[0]->setYPos(y_lbl); //set all evaluated position values to all other segement items for (size_t i = 1; i < v_cc_items.size(); i++){ x_lbl += v_cc_items[i-1]->getWidth(); v_cc_items[i]->setPos(x_lbl, y_lbl); } }
void CComponentsFrmClock::initCCLockItems() { initTimeString(); string s_time = cl_timestr; //get minimal required height, width from raw text int min_text_w = (*getClockFont())->getRenderWidth(s_time, true);; int min_text_h = (*getClockFont())->getHeight(); height = max(height, min_text_h); width = max(width, min_text_w); int cl_x = 0; int cl_h = min_text_h; int cl_y = 0; int w_lbl_tmp = 0; //create label objects and add to container, ensure count of items = count of chars (one char = one segment) if (v_cc_items.size() != s_time.size()){ //clean up possible old items before add new items clear(); //create new empty label objects, set some general properties and add to container for (size_t i = 0; i < s_time.size(); i++){ CComponentsLabel * lbl = new CComponentsLabel(); addCCItem(lbl); //background paint of item is not required lbl->doPaintBg(false); //set corner properties of label item lbl->setCorner(corner_rad-fr_thickness, corner_type); //set text border to 0 lbl->setTextBorderWidth(0,0); } } //calculate minimal separator width, we use char size of some possible chars int minSepWidth = 0; string sep[] ={" ", ".", ":"}; for (size_t i = 0; i < sizeof(sep)/sizeof(sep[0]); i++) minSepWidth = max((*getClockFont())->getRenderWidth(sep[i], true), minSepWidth); //modify available label items with current segment chars for (size_t i = 0; i < v_cc_items.size(); i++) { //v_cc_items are only available as CComponent-items here, so we must cast them before CComponentsLabel *lbl = static_cast <CComponentsLabel*> (v_cc_items[i]); //add rounded corners only to 1st and last segment if (corner_type) { if (i == 0) lbl->setCornerType(corner_type & CORNER_LEFT);// 1st label item else if (i == v_cc_items.size()-1) lbl->setCornerType(corner_type & CORNER_RIGHT);// last label item else lbl->setCornerType(0);// inner items } //extract timestring segment (char) string stmp = s_time.substr(i, 1); //get width of current segment int wtmp = 0; if (isdigit(stmp.at(0)) ) //check for digits, if true, we use digit width wtmp = (*getClockFont())->getMaxDigitWidth(); else //not digit found, we use render width or minimal width wtmp = max((*getClockFont())->getRenderWidth(stmp, true), minSepWidth); //set size, text, color of current item lbl->setDimensionsAll(cl_x, cl_y, wtmp, cl_h); lbl->setTextColor(cl_col_text); lbl->setColorAll(col_frame, col_body, col_shadow); lbl->setText(stmp, CTextBox::CENTER, *getClockFont()); //use matching height for digits for better vertical centerring into form CTextBox* ctb = lbl->getCTextBoxObject(); if (ctb) ctb->setFontUseDigitHeight(); #if 0 //ensure paint of text and label bg on changed text or painted form background bool force_txt_and_bg = (lbl->textChanged() || this->paint_bg); lbl->forceTextPaint(force_txt_and_bg); #endif //set xpos of item cl_x += wtmp; lbl->setWidth(wtmp); //set current width for form w_lbl_tmp += wtmp; } //set required width width = max(width, w_lbl_tmp); initSegmentAlign(&w_lbl_tmp, &min_text_h); }