1 /* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 package org
.libreoffice
.ui
;
5 import org
.libreoffice
.R
;
7 import android
.content
.Context
;
8 import android
.graphics
.Bitmap
;
9 import android
.graphics
.BitmapFactory
;
10 import android
.graphics
.Canvas
;
11 import android
.graphics
.Paint
;
12 import android
.graphics
.Rect
;
13 import android
.util
.AttributeSet
;
14 import android
.util
.Log
;
15 import android
.view
.View
;
17 public class PageView
extends View
{
19 private Paint mPaintBlack
;
20 private static final String LOGTAG
= "PageView";
22 public PageView(Context context
) {
24 bmp
= BitmapFactory
.decodeResource(getResources(), R
.drawable
.dummy_page
);
27 public PageView(Context context
, AttributeSet attrs
) {
28 super(context
, attrs
);
29 bmp
= BitmapFactory
.decodeResource(getResources(), R
.drawable
.dummy_page
);
30 Log
.d(LOGTAG
, bmp
.toString());
33 public PageView(Context context
, AttributeSet attrs
, int defStyle
) {
34 super(context
, attrs
, defStyle
);
35 bmp
= BitmapFactory
.decodeResource(getResources(), R
.drawable
.dummy_page
);//load a "page"
39 private void initialise(){
40 mPaintBlack
= new Paint();
41 mPaintBlack
.setARGB(255, 0, 0, 0);
42 Log
.d(LOGTAG
, " Doing some set-up");
45 public void setBitmap(Bitmap bmp
){
50 protected void onDraw(Canvas canvas
) {
52 Log
.d(LOGTAG
, "Draw");
53 Log
.d(LOGTAG
, Integer
.toString(bmp
.getHeight()));
55 int horizontalMargin
= (int) (canvas
.getWidth()*0.1);
56 //int verticalMargin = (int) (canvas.getHeight()*0.1);
57 int verticalMargin
= horizontalMargin
;
58 canvas
.drawBitmap(bmp
, new Rect(0, 0, bmp
.getWidth(), bmp
.getHeight()),
59 new Rect(horizontalMargin
,verticalMargin
,canvas
.getWidth()-horizontalMargin
,
60 canvas
.getHeight()-verticalMargin
),
64 canvas
.drawText(getContext().getString(R
.string
.bmp_null
), 100, 100, new Paint());
69 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */