Update ErrorView.mc

Made the view scalable. Odd that it was not before.
This commit is contained in:
Philip Abbey
2023-12-21 16:47:21 +00:00
parent 332a10867d
commit 27b6b63a7a

View File

@ -53,14 +53,12 @@ class ErrorView extends ScalableView {
mDelegate = new ErrorDelegate(self);
// Convert the settings from % of screen size to pixels
mErrorIconMargin = pixelsForScreen(cSettings.get(:errorIconMargin) as Lang.Float);
mErrorIcon = Application.loadResource(Rez.Drawables.ErrorIcon) as Graphics.BitmapResource;
}
// Load your resources here
function onLayout(dc as Graphics.Dc) as Void {
mErrorIcon = Application.loadResource(Rez.Drawables.ErrorIcon) as Graphics.BitmapResource;
var w = dc.getWidth();
var h = dc.getHeight();
mTextArea = new WatchUi.TextArea({
:text => mText,
@ -68,22 +66,21 @@ class ErrorView extends ScalableView {
:font => Graphics.FONT_XTINY,
:justification => Graphics.TEXT_JUSTIFY_CENTER | Graphics.TEXT_JUSTIFY_VCENTER,
:locX => 0,
:locY => 83,
:locY => pixelsForScreen(20.0),
:width => w,
:height => h - 166
:height => pixelsForScreen(60.0)
});
}
// Update the view
function onUpdate(dc as Graphics.Dc) as Void {
var w = dc.getWidth();
var hw = w/2;
if(dc has :setAntiAlias) {
dc.setAntiAlias(true);
}
dc.setColor(Graphics.COLOR_WHITE, Graphics.COLOR_BLUE);
dc.clear();
dc.drawBitmap(hw - mErrorIcon.getWidth()/2, mErrorIconMargin, mErrorIcon);
dc.drawBitmap(w/2 - mErrorIcon.getWidth()/2, mErrorIconMargin, mErrorIcon);
mTextArea.draw(dc);
}