What is the best way in FMX to create a grid that supports bidimode and righttoleft languages
I have tried fmxrtl but it has many errors
Thanks
Is your app only for Windows ? If yes, I use a function to detect if it's a Bidi string and then use TTextLayout my test here
Else, try to use SKIA4Delphi (XE7+)Supporting right to left
I test an Android little app ScreenShot
procedure TForm1.Grid1DrawColumnCell(Sender: TObject; const Canvas: TCanvas;
const Column: TColumn; const Bounds: TRectF; const Row: Integer;
const Value: TValue; const State: TGridDrawStates);
begin
if (Column.Index=1) AND (Row>=1)
then begin
Canvas.Fill.Color:=TAlphaColors.Red;
Canvas.FillText(Bounds,Value.ToString,false,1,[TFillTextFlag.RightToLeft],TTextAlign.Leading);
end
else Column.DefaultDrawCell(Canvas,bounds,row,value,state);
end;
Related
I have 2 enums, const Option1 = z.enum(["option1"]) and const Option2 = z.enum(["option2"]).
I want to merge these two into z.ZodEnum<["option1", "option2"]>
The only way I came up with so far is
export const Options = z.enum([
...Option1.options,
...Option2.options,
]);
// Options.options is now ["option1", "option2"]
Is there any zod native way to do this?
the issue you're facing here is due to the type of the combined options.
const allOptions = [...Option1.options, ...Option2.options]
the inferred type of allOptions in this case is: ("option1" | "option2")[] and zod can't create an enum out of that.
however, if you define allOptions like this:
const allOptions = [...Option1.options, ...Option2.options] as const
then the inferred type of allOptions will be the tuple ["option1", "option2"] which is exactly what you want.
so, putting that all together, to combine the options, you'd say:
const Options = z.enum([...Option1.options, ...Option2.options] as const)
and the inferred type of Options will be z.ZodEnum<["option1", "option2"]>
InfernoJS gives a very interesting but unfortunately very brief sketch of a purely functional way to bootstrap an app:
import Inferno from 'inferno';
import { scan, map } from 'most';
...
const model$ = scan(update, 0, actions$);
const vNodes$ = map(view(actions$), model$);
const renderer = Inferno.createRenderer();
const runApp = () => scan(renderer, container, vNodes$).drain();
runApp();
Can anyone give a fully functional example of an app designed this way?
Here is an example: https://github.com/joshburgess/inferno-most-fp-demo
It's simply a functional counter but a good starting point nonetheless.
I am using wkhtmltopdf version 0.12.2.1 (with patched qt) to render my reactJs app! It worked fine, until I added the react-pdf-js lib to render the pdf generated inside my app. I followed the code described on react-pdf-js documentation (see https://www.npmjs.com/package/react-pdf-js) to make it work.
The pdf is rendered inside my page, and it looks pretty cool indeed. But when I try to run wkhtmltopdf again, to generate a pdf of any page of my app, the following error is returned:
desenv01#desenv01-PC:~$ wkhtmltopdf -O Landscape --print-media-type --debug-javascript http://localhost:3000/report/1 report.pdfLoading pages (1/6)
Warning: undefined:0 ReferenceError: Can't find variable: Float64Array
Warning: http://localhost:3000/assets/js/app.js:46789 SyntaxError: Parse error
Counting pages (2/6)
Resolving links (4/6)
Loading headers and footers (5/6)
Printing pages (6/6)
Done
Then, I went to my app.js to see what's on line 46789:
set href(href) {
clear.call(this);
parse.call(this, href);
},
get protocol() {
return this._scheme + ':';
},
set protocol(protocol) {
if (this._isInvalid)
return;
parse.call(this, protocol + ':', 'scheme start');
},
The error happens on the line that says parse.call(this, href);, which is part of pdf.combined.js script.
I could not find any solution online so I wondered if there is anyone who might know if I did something wrong or a way to work around it.
Thanks..
I ran into this using wkthmltopdf 12.3 and 12.4 because I have my IDE set to nag me for using var instead of let. The problem is the older Qt engine powering those versions of the program doesn't recognize new-style, ES6 keywords. Not sure if you can down-convert React. Otherwise you can try the bleeding edge versions which use a newer Qt.
I have same problem. I fixed it by modify some code that i think it is new in JS. let keyword (ES5) and template literals (ES6).
generateRandomColor= function () {
let maxVal = 0xFFFFFF; // 16777215
let randomNumber = Math.random() * maxVal;
randomNumber = Math.floor(randomNumber);
randomNumber = randomNumber.toString(16);
let randColor = randomNumber.padStart(6, 0);
return `#${randColor.toUpperCase()}`
}
I modify above code into below
generateRandomColor = function () {
var maxVal = 0xFFFFFF;
var randomNumber = Math.random() * maxVal;
randomNumber = Math.floor(randomNumber);
randomNumber = randomNumber.toString(16);
var randColor = randomNumber.padStart(6, 0);
return "#" + randColor.toUpperCase();
}
i have a problem with SHGetFileInfo. I am using FPC 2.6.2 with Lazarus 1.0.14, here is the code:
procedure x;
var
FI: SHFILEINFO;
icon: ticon;
begin
SHGetFileInfo('app.exe', 0, FI, SizeOf(FI), SHGFI_SYSICONINDEX or SHGFI_ICON or SHGFI_LARGEICON);
icon := TIcon.Create;
icon.Handle := FI.hIcon;
icon.SaveToFile('extracted.ico');
end;
The problem is it produces icon file with black background instead od transparent. Here is how it looks like:
http://i.imgur.com/5BF3xbT.jpg
When i compile the same code in Delphi, it works perfectly. Icon has transparent background.
I would appreciate if anyone could help me to solve this problem :-)
I have same problem time ago. LCL seems can't have full alpha support for TIcon, so you must use another similar component. I tried TKIcon and it works. You can find here http://www.tkweb.eu/en/delphicomp/kicon.html
I post a sample procedure to extract a icon. It is very simple.
procedure ExtractIconAndSave(xpath: string);
var
FileInfo: SHFILEINFO;
Icon: KIcon.TIcon; //Don't confused with Graphics.TIcon
begin
//Get icon handle
SHGetFileInfo(PChar(xpath), 0, FileInfo, SizeOf(FileInfo), SHGFI_SYSICONINDEX or SHGFI_ICON or SHGFI_LARGEICON);
//Check if SHGetFileInfo get the icon handle
if FileInfo.hIcon <> 0 then
begin
//Use kIcon's TIcon - It supports alpha 32bpp
Icon := KIcon.TIcon.Create;
try
//Load icon handle in TKIcon and save it in a file
Icon.LoadFromHandle(FileInfo.hIcon);
Icon.SaveToFile('extracted.ico');
finally
DestroyIcon(FileInfo.hIcon);
FreeAndNil(Icon);
end;
end;
end;
So I am developing this add-on using the MDN's Add-on Builder and need to connect with the SQLite Database. The connection gets created fine and insertion is fine as long as I am inserting values without binding parameters(that is, through executeSimpleSQL()). As soon as I use the createStatement() method to INSERT values, it does not work. Here's what I have done so far.
let file = FileUtils.getFile("Desk", ["my_db_file_name.sqlite"]);
let mDBConn = Services.storage.openDatabase(file);
mDBConn.executeSimpleSQL("CREATE TEMP TABLE IF NOT EXISTS element (rating VARCHAR(50))");
let stmt = mDBConn.createStatement("INSERT INTO element (rating) VALUES(:value)");
stmt.params.value = 13;
//mDBConn.executeSimpleSQL("INSERT INTO element (rating) VALUES(13)");
var statement = mDBConn.createStatement("SELECT * FROM element WHERE rating = :rat");
statement.params.rat = 13;
try {
while (statement.step()) {
let value = statement.row.rating;
console.log(value);
}
}
finally {
statement.reset();
}
Note that the SELECT statement with the bound parameters works fine, it's just the INSERT statement that's problematic.
Any ideas?
You forgot to call execute().