/** * Draw the full page, usually you would like to call this method * @param page The page to draw * @param cr Draw to thgis context * @param dontRenderEditingStroke false to draw currently drawing stroke * @param hideBackground true to hide the background */ void DocumentView::drawPage(PageRef page, cairo_t* cr, bool dontRenderEditingStroke, bool hideBackground) { XOJ_CHECK_TYPE(DocumentView); initDrawing(page, cr, dontRenderEditingStroke); bool backgroundVisible = page->isLayerVisible(0); if (!hideBackground && backgroundVisible) { drawBackground(); } if (!backgroundVisible) { drawTransparentBackgroundPattern(); } int layer = 0; for (Layer* l : *page->getLayers()) { if (!page->isLayerVisible(l)) { continue; } drawLayer(cr, l); layer++; } finializeDrawing(); }
int main() { struct Drawing d; struct Circle bottom; struct Circle middle; struct Circle top; initDrawing(&d, DRAWINGTYPE_BW, 200, 150, BW_BLACK); // draw a snowMan with height 90 pixels // Bottom circle has radius 20, center at 100, 80 // Middle circle has radius 15, center at 100, 45 // Top circle has radius 10, center at 100, 20 initCircle(&bottom, makePoint(100.0,80.0), 20.0); initCircle(&middle, makePoint(100.0,45.0), 15.0); initCircle(&top, makePoint(100.0,20.0), 10.0); fillCircle(&d,bottom,BW_WHITE); fillCircle(&d,middle,BW_WHITE); fillCircle(&d,top, BW_WHITE); writeFile(&d, FILENAME); return 0; }
int main() { struct Drawing d; // @@@ modify the values 400 and 150 to be the width/height // @@@ that you want initDrawing(&d, DRAWINGTYPE_COLOR, 400, 150, COLOR_WHITE); // @@@ call the drawing Routines. The values 100,100, 50, 20 // @@@ below are just example values // @@@ Draw each shape in at least two places in at least two // @@@ different sizes drawShape1(&d,makePoint(100,100),50,20); drawShape1(&d,makePoint(150,100),70,25); drawShape2(&d,makePoint(200,100),40,30); drawShape2(&d,makePoint(250,50),30,40); writeFile(&d, FILENAME); return 0; }
/////////////////////////////////////////////////////////////////////////////////////////// // // CS : PUBLIC void initUI(gchar *pWindowTitle, ST_PrinterStatus *pPrinterStatus, gboolean isPrinting, ENUM_OtherMessageID otherMsg) // IN : gchar *pWindowTitle : Window title string. // ST_PrinterStatus *pPrinterStatus : Information of printer status. // gboolean isPrinting : TRUE : Printing. // FALSE : Not printing. // ENUM_OtherMessageID otherMsg : Message ID except printer status message. // OUT : None. // RETURN : None. // PUBLIC void initUI(gchar *pWindowTitle, ST_PrinterStatus *pPrinterStatus, gboolean isPrinting, ENUM_OtherMessageID otherMsg) { #ifdef USE_libglade /*** Parameters start ***/ gchar gladeFileName[MAX_BUF_SIZE]; // Buffer for glade file name. ENUM_STSMessageID *pMessageID; // Pointer to array of message ID. gint i; // Counter. /*** Parameters end ***/ // Create full path of glade file name. memset (gladeFileName, 0, MAX_BUF_SIZE); strncpy(gladeFileName, STR_SHARE_DIRECTORY_NAME, (MAX_BUF_SIZE<(strlen(STR_SHARE_DIRECTORY_NAME)+strlen(GLADE_FILE_NAME)+1))? MAX_BUF_SIZE<(strlen(STR_SHARE_DIRECTORY_NAME)+strlen(GLADE_FILE_NAME)+1)); strcat(gladeFileName, "/"); strcat(gladeFileName, GLADE_FILE_NAME); // Show window. gXmlMainWnd = glade_xml_new(gladeFileName, STR_WINDOW_NAME_MAIN); // Set window title. setWindowTitle(STR_WINDOW_NAME_MAIN, pWindowTitle); // Initialize related cartridge area drawing handling. initDrawing(); // Disable [Cancel Printing] button. activateWidget(STR_MAIN_BUTTON_NAME_CANCEL, FALSE); if (isPrinting == FALSE) { // Not printing. // Initialize UI settings. (Without printer status.) updateUISettings(NULL, otherMsg, TRUE, TRUE, TRUE, TRUE); } else { // Printing. // Enable [Cancel Printing] button. if (pPrinterStatus->printInterface == ID_DEV_1284 ) activateWidget(STR_MAIN_BUTTON_NAME_CANCEL, TRUE); // Check messages. pMessageID = pPrinterStatus->pMessageID; for (i = 0; i < pPrinterStatus->messageNum; i++) { if (*pMessageID == ID_STS_MESSAGE_CARTRIDGE_UNSUPPORTED || *pMessageID == ID_STS_MESSAGE_OC_PAPER_OUT21 // ver.2.5 || *pMessageID == ID_STS_MESSAGE_OC_PAPER_OUT22 // ver.2.5 || *pMssageID == ID_STS_MESSAGE_OC_PAPER_JAM || *pMssageID == ID_STS_MESSAGE_OC_PAPER_JAM03 // ver.2.5 || *pMssageID == ID_STS_MESSAGE_OC_PAPER_JAM04 // ver.2.5 || *pMessageID == ID_STS_MESSAGE_OC_USBDEVICE // Ver.2.4 || *pMessageID == ID_STS_MESSAGE_OC_HEADALIGNMENT // Ver.2.4 ) { // Disable [Cancel Printing] button. activateWidget(STR_MAIN_BUTTON_NAME_CANCEL, FALSE); break; } pMessageID++; } // Initialize UI settings related with printer status. updateUISettings(pPrinterStatus, ID_OTHER_MESSAGE_NONE, TRUE, TRUE, TRUE, TRUE); } // Hide [Continue] button. showWidget(STR_MAIN_BUTTON_NAME_CONTINUE, FALSE); //for Ver.2.70 showWidget(STR_MAIN_BUTTON_NAME_CANCEL, FALSE); // Signal connect. glade_xml_signal_autoconnect(gXmlMainWnd); return; #else // use Gtk+-1.2 /*** Parameters start ***/ ENUM_STSMessageID *pMessageID; // Pointer to array of message ID. gint i; // Counter. // struct sigaction sa; /*** Parameters end ***/ // Show window. gMainWnd = create_mainWindow(); // Initialize related cartridge area drawing handling. initDrawing(); // Set window title. setWindowTitle(STR_WINDOW_NAME_MAIN, pWindowTitle); // Disable [Cancel Printing] button. activateWidget(STR_MAIN_BUTTON_NAME_CANCEL, FALSE); if (isPrinting == FALSE) { // Not printing. // Initialize UI settings. (Without printer status.) updateUISettings(NULL, otherMsg, TRUE, TRUE, TRUE, TRUE); } else { // Printing. // Enable [Cancel Printing] button. if (pPrinterStatus->printInterface == ID_DEV_1284 ) activateWidget(STR_MAIN_BUTTON_NAME_CANCEL, TRUE); // Check messages. pMessageID = pPrinterStatus->pMessageID; for (i = 0; i < pPrinterStatus->messageNum; i++) { if (*pMessageID == ID_STS_MESSAGE_CARTRIDGE_UNSUPPORTED || *pMessageID == ID_STS_MESSAGE_OC_PAPER_OUT21 // ver.2.5 || *pMessageID == ID_STS_MESSAGE_OC_PAPER_OUT22 // ver.2.5 || *pMessageID == ID_STS_MESSAGE_OC_PAPER_JAM || *pMessageID == ID_STS_MESSAGE_OC_PAPER_JAM03 // ver.2.5 || *pMessageID == ID_STS_MESSAGE_OC_PAPER_JAM04 // ver.2.5 || *pMessageID == ID_STS_MESSAGE_OC_USBDEVICE // Ver.2.4 || *pMessageID == ID_STS_MESSAGE_OC_HEADALIGNMENT // Ver.2.4 ) { // Disable [Cancel Printing] button. activateWidget(STR_MAIN_BUTTON_NAME_CANCEL, FALSE); break; } pMessageID++; } // Initialize UI settings related with printer status. updateUISettings(pPrinterStatus, ID_OTHER_MESSAGE_NONE, TRUE, TRUE, TRUE, TRUE); } // Hide [Continue] button. showWidget(STR_MAIN_BUTTON_NAME_CONTINUE, FALSE); //for Ver.2.70 showWidget(STR_MAIN_BUTTON_NAME_CANCEL, FALSE); // Show showWidget(STR_WINDOW_NAME_MAIN, TRUE); // Signal connect. // memset( &sa, 0, sizeof(sa)); // sa.sa_handler = sighand_term; // if( sigaction( SIGTERM, &sa, NULL) ) perror("sigaction"); return; #endif // USE_libglade }// End initUI