* BUG: Printer.PaperWidth and Printer.PaperHeight should return the 
  expected values for predefined papers.


git-svn-id: svn://localhost/gambas/trunk@2833 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2010-03-27 08:14:06 +00:00
parent 7162466e05
commit ea3c59fcd9
2 changed files with 26 additions and 10 deletions

View file

@ -291,12 +291,11 @@ void gPrinter::setOrientation(int v)
gtk_print_settings_set_orientation(_settings, orient);
}
void gPrinter::setPaperModel(int v)
GtkPaperSize *gPrinter::getPaperSize()
{
GtkPaperSize *paper;
const char *name;
switch(v)
switch(_paper_size)
{
case GB_PRINT_A3: name = GTK_PAPER_NAME_A3; break;
case GB_PRINT_A4: name = GTK_PAPER_NAME_A4; break;
@ -305,20 +304,36 @@ void gPrinter::setPaperModel(int v)
case GB_PRINT_LETTER: name = GTK_PAPER_NAME_LETTER; break;
case GB_PRINT_EXECUTIVE: name = GTK_PAPER_NAME_EXECUTIVE; break;
case GB_PRINT_LEGAL: name = GTK_PAPER_NAME_LEGAL; break;
default: name = GTK_PAPER_NAME_A4; v = GB_PRINT_A4;
default: name = GTK_PAPER_NAME_A4; _paper_size = GB_PRINT_A4;
}
_paper_size = v;
return gtk_paper_size_new(name);
}
paper = gtk_paper_size_new(name);
void gPrinter::setPaperModel(int v)
{
GtkPaperSize *paper;
_paper_size = v;
paper = getPaperSize();
gtk_print_settings_set_paper_size(_settings, paper);
gtk_paper_size_free(paper);
}
void gPrinter::getPaperSize(double *width, double *height) const
void gPrinter::getPaperSize(double *width, double *height)
{
*width = gtk_print_settings_get_paper_width(_settings, GTK_UNIT_MM);
*height = gtk_print_settings_get_paper_height(_settings, GTK_UNIT_MM);
if (_paper_size == GB_PRINT_CUSTOM)
{
*width = gtk_print_settings_get_paper_width(_settings, GTK_UNIT_MM);
*height = gtk_print_settings_get_paper_height(_settings, GTK_UNIT_MM);
}
else
{
GtkPaperSize *paper = getPaperSize();
*width = gtk_paper_size_get_width(paper, GTK_UNIT_MM);
*height = gtk_paper_size_get_height(paper, GTK_UNIT_MM);
gtk_paper_size_free(paper);
}
}
void gPrinter::setPaperSize(double width, double height)

View file

@ -46,7 +46,7 @@ public:
int paperModel() const { return _paper_size; }
void setPaperModel(int v);
void getPaperSize(double *width, double *height) const;
void getPaperSize(double *width, double *height);
void setPaperSize(double width, double height);
bool collateCopies() const;
@ -94,6 +94,7 @@ public:
private:
bool run(bool configure);
GtkPaperSize *getPaperSize();
GtkPrintOperation *_operation;
GtkPrintSettings *_settings;