~ubuntu-branches/ubuntu/karmic/photoprint/karmic

« back to all changes in this revision

Viewing changes to print.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Milan Zamazal
  • Date: 2007-05-01 16:32:13 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070501163213-ni1933khtg9fdvn5
Tags: 0.3.5-2
Move to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 
26
26
#include "imagesource/imagesource.h"
27
27
 
 
28
#include "support/generaldialogs.h"
 
29
 
28
30
#include "print.h"
29
31
 
30
32
#define USE16BITPRINTING
248
250
        if(!result)
249
251
        {
250
252
                writeerror=true;
251
 
                cerr << "cons->Write() returned " << result << endl;
 
253
                cerr << "cons->Write() returned " << result << endl;
252
254
        }
253
255
}
254
256
 
278
280
                        throw "Only RGB and CMYK images are currently supported!";
279
281
                        break;
280
282
        }
 
283
        stp_set_string_parameter(stpvars, "PrintingMode", "Color");
281
284
 
282
285
        this->xpos=xpos;
283
286
        this->ypos=ypos;
289
292
 
290
293
        consumer=output.GetConsumer();
291
294
 
 
295
        if(!consumer)
 
296
                return;
 
297
 
292
298
        stp_set_outfunc(stpvars, writefunc);
293
299
        stp_set_outdata(stpvars, consumer);
294
300
 
295
 
        cerr << "Done - merging vars" << endl;
296
 
 
297
301
        stp_vars_t *tmpvars=stp_vars_create_copy(stpvars);
298
302
        const stp_vars_t *current_vars = stp_printer_get_defaults(stp_get_printer(stpvars));
299
303
        stp_merge_printvars(tmpvars, current_vars);
300
304
 
301
 
        cerr << "Done - commencing print" << endl;
302
 
 
303
305
        writeerror=false;
304
306
 
305
307
//      Dump();
327
329
// Deal with borderless mode by adding the bleed area to the media size
328
330
// and reducing the negative margins to zero.
329
331
 
 
332
// Obsolete hack - but shouldn't cause problems now borderless is working
 
333
// properly in Gutenprint - so leave it for now:
330
334
// The bottom bleed is excessively large on the R300 - presumably because
331
335
// the driver just increases the form length to work around the lack of
332
336
// a true bleed option.
335
339
 
336
340
void GPrinter::GetImageableArea()
337
341
{
338
 
        stp_get_media_size(stpvars, &pagewidth, &pageheight);
 
342
//      pagewidth=pageheight=0;
 
343
//      stp_get_media_size(stpvars, &pagewidth, &pageheight);
 
344
 
 
345
//      cerr << "Media size returned: " << pagewidth << " by " << pageheight << endl;
 
346
 
 
347
        const char *papersize=stp_get_string_parameter(stpvars,"PageSize");
 
348
        if(papersize)
 
349
        {
 
350
                const stp_papersize_t *paper=stp_get_papersize_by_name(papersize);
 
351
                if(paper)
 
352
                {
 
353
                        if(paper->width)
 
354
                        {
 
355
                                pagewidth=minwidth=maxwidth=paper->width;
 
356
                                stp_set_page_width(stpvars,pagewidth);
 
357
                                cerr << "Width: " << pagewidth << endl;
 
358
                        }
 
359
                        else
 
360
                        {
 
361
                                int mw,mh,nw,nh;
 
362
                                stp_get_size_limit(stpvars,&mw,&mh,&nw,&nh);
 
363
                                minwidth=nw;
 
364
                                maxwidth=mw;
 
365
                                cerr << "Custom width..." << endl;
 
366
                        }
 
367
                        if(paper->height)
 
368
                        {
 
369
                                pageheight=minheight=maxheight=paper->height;
 
370
                                stp_set_page_height(stpvars,pageheight);
 
371
                                cerr << "Height: " << pageheight << endl;
 
372
                        }
 
373
                        else
 
374
                        {
 
375
                                int mw,mh,nw,nh;
 
376
                                stp_get_size_limit(stpvars,&mw,&mh,&nw,&nh);
 
377
                                minheight=nh;
 
378
                                maxheight=mh;
 
379
                                cerr << "Custom height..." << endl;
 
380
                        }
 
381
                }
 
382
        }
 
383
        else
 
384
        {
 
385
                pagewidth=pageheight=0;
 
386
                stp_get_media_size(stpvars, &pagewidth, &pageheight);
 
387
        }
339
388
 
340
389
        int l,r,t,b;
341
390
        stp_get_imageable_area(stpvars, &l, &r, &b, &t);
342
391
 
 
392
        cerr << "Imageable area from GP: L: " << l << ", R: " << r << ", T: " << t << ", B: " << b << endl;
 
393
 
343
394
        leftbleed=rightbleed=topbleed=bottombleed=0;
344
395
 
345
396
        // *** HACK ***
383
434
        cerr << "Right bleed: " << rightbleed << endl;
384
435
        cerr << "Top bleed: " << topbleed << endl;
385
436
        cerr << "Bottom bleed: " << bottombleed << endl;
 
437
 
 
438
        // HACK
 
439
        // There seems to be a problem with GutenPrint's setlocale() calls.
 
440
        cerr << "After reading papersize and margins: " << setlocale(LC_ALL,"") << endl;
 
441
}
 
442
 
 
443
 
 
444
void GPrinter::GetSizeLimits(int &minw,int &maxw,int &minh,int &maxh)
 
445
{
 
446
        minw=minwidth;
 
447
        maxw=maxwidth;
 
448
        minh=minheight;
 
449
        maxh=maxheight;
 
450
}
 
451
 
 
452
 
 
453
void GPrinter::SetCustomWidth(int w)
 
454
{
 
455
        stp_set_page_width(stpvars,w);
 
456
        pagewidth=w;
 
457
}
 
458
 
 
459
 
 
460
void GPrinter::SetCustomHeight(int h)
 
461
{
 
462
        stp_set_page_height(stpvars,h);
 
463
        pageheight=h;
386
464
}
387
465
 
388
466
 
389
467
GPrinter::GPrinter(PrintOutput &output,ConfigFile *ini,const char *section)
390
468
        : GPrinterSettings(output,ini,section), source(NULL), firstrow(0), firstpixel(0), progress(NULL)
391
469
{
392
 
        cerr << "GPrinter initialised" << endl;
393
470
        stpImage.rep=this;
394
471
}
395
472