Data update
This commit is contained in:
parent
8e4e15fa56
commit
72eb4943cb
1853 changed files with 35514 additions and 9441 deletions
|
|
@ -1,19 +1,63 @@
|
|||
import gintro/[glib, gobject, gtk, gio, cairo]
|
||||
import gtk2, glib2, cairo
|
||||
|
||||
const Colors = [[255.0, 255.0, 255.0], [0.0, 0.0, 0.0]]
|
||||
###############################################################################
|
||||
# Missing declarations needed for print operations.
|
||||
|
||||
#---------------------------------------------------------------------------------------------------
|
||||
when defined(win32):
|
||||
const lib = "libgtk-win32-2.0-0.dll"
|
||||
elif defined(macosx):
|
||||
const lib = "(libgtk-quartz-2.0.0.dylib|libgtk-x11-2.0.dylib)"
|
||||
else:
|
||||
const lib = "libgtk-x11-2.0.so(|.0)"
|
||||
|
||||
proc beginPrint(op: PrintOperation; printContext: PrintContext; data: pointer) =
|
||||
## Process signal "begin_print", that is set the number of pages to print.
|
||||
op.setNPages(1)
|
||||
# Missing type definitions.
|
||||
type
|
||||
PrintOperation = PObject
|
||||
PrintContext = PObject
|
||||
PrintOperationAction = enum
|
||||
PRINT_OPERATION_ACTION_PRINT_DIALOG
|
||||
PRINT_OPERATION_ACTION_PRINT
|
||||
PRINT_OPERATION_ACTION_PREVIEW
|
||||
PRINT_OPERATION_ACTION_EXPORT
|
||||
PrintOperationResult = enum
|
||||
PRINT_OPERATION_RESULT_ERROR
|
||||
PRINT_OPERATION_RESULT_APPLY
|
||||
PRINT_OPERATION_RESULT_CANCEL
|
||||
PRINT_OPERATION_RESULT_IN_PROGRESS
|
||||
|
||||
#---------------------------------------------------------------------------------------------------
|
||||
# Missing external procedures.
|
||||
proc print_operation_new(): PrintOperation {.cdecl,
|
||||
importc: "gtk_print_operation_new", dynlib: lib.}
|
||||
proc print_operation_run(op: PrintOperation; action: PrintOperationAction;
|
||||
parent: PWindow; error: pointer): PrintOperationResult {.cdecl,
|
||||
importc: "gtk_print_operation_run", dynlib: lib.}
|
||||
proc set_n_pages(op: PrintOperation; n: gint) {.cdecl,
|
||||
importc: "gtk_print_operation_set_n_pages", dynlib: lib.}
|
||||
proc get_cairo_context(printContext: PrintContext): ptr Context {.cdecl,
|
||||
importc: "gtk_print_context_get_cairo_context", dynlib: lib.}
|
||||
proc width(printContext: PrintContext): cdouble {.cdecl,
|
||||
importc: "gtk_print_context_get_width", dynlib: lib.}
|
||||
proc height(printContext: PrintContext): cdouble {.cdecl,
|
||||
importc: "gtk_print_context_get_height", dynlib: lib.}
|
||||
|
||||
proc drawPage(op: PrintOperation; printContext: PrintContext; pageNum: int; data: pointer) =
|
||||
## Draw a page.
|
||||
|
||||
let context = printContext.getCairoContext()
|
||||
###############################################################################
|
||||
|
||||
const Colors = [(1.0, 1.0, 1.0), (0.0, 0.0, 0.0)]
|
||||
|
||||
|
||||
proc beginPrint(op: PrintOperation; printContext: PrintContext;
|
||||
data: Pgpointer): gboolean {.cdecl.} =
|
||||
## Process "begin_print" signal.
|
||||
op.setNPages(1) # Print one page.
|
||||
result = true
|
||||
|
||||
|
||||
proc drawPage(op: PrintOperation; printContext: PrintContext;
|
||||
pageNum: int; data: Pgpointer): gboolean {.cdecl.} =
|
||||
## Process "draw_page" signal.
|
||||
|
||||
let context = printContext.get_cairo_context()
|
||||
let lineHeight = printContext.height / 4
|
||||
|
||||
var y = 0.0
|
||||
|
|
@ -22,7 +66,8 @@ proc drawPage(op: PrintOperation; printContext: PrintContext; pageNum: int; data
|
|||
var x = 0.0
|
||||
var colorIndex = 0
|
||||
while x < printContext.width:
|
||||
context.setSource(Colors[colorIndex])
|
||||
let (r, g, b) = Colors[colorIndex]
|
||||
context.setSourceRgb(r, g, b)
|
||||
context.moveTo(x, y)
|
||||
context.lineTo(x, y + lineHeight)
|
||||
context.stroke()
|
||||
|
|
@ -30,21 +75,13 @@ proc drawPage(op: PrintOperation; printContext: PrintContext; pageNum: int; data
|
|||
x += lineWidth
|
||||
y += lineHeight
|
||||
|
||||
#---------------------------------------------------------------------------------------------------
|
||||
result = true
|
||||
|
||||
proc activate(app: Application) =
|
||||
## Activate the application.
|
||||
|
||||
# Launch a print operation.
|
||||
let op = newPrintOperation()
|
||||
op.connect("begin_print", beginPrint, pointer(nil))
|
||||
op.connect("draw_page", drawPage, pointer(nil))
|
||||
nim_init()
|
||||
|
||||
# Run the print dialog.
|
||||
discard op.run(printDialog)
|
||||
|
||||
#———————————————————————————————————————————————————————————————————————————————————————————————————
|
||||
|
||||
let app = newApplication(Application, "Rosetta.Pinstripe")
|
||||
discard app.connect("activate", activate)
|
||||
discard app.run()
|
||||
# Print the pinstripe.
|
||||
let op = print_operation_new()
|
||||
discard op.g_signal_connect("begin_print", G_CALLBACK(begin_print), nil)
|
||||
discard op.g_signal_connect("draw_page", G_CALLBACK(draw_page), nil)
|
||||
discard op.print_operation_run(PRINT_OPERATION_ACTION_PRINT_DIALOG, nil, nil)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue