@@ -28,8 +28,7 @@ class ftca_form : public nana::form
28
28
nana::place &plc{get_place ()};
29
29
const auto bg{nana::colors::white};
30
30
31
- nana::API::track_window_size (handle (), {600 , 185 }, false );
32
- caption (" File To C Array" );
31
+ caption (" File To C Array v1.1" );
33
32
bgcolor (bg);
34
33
35
34
div (" vert margin=15 < weight=20 <l_in weight=70><weight=15><l_inpath><weight=15><btn_in weight=20> >"
@@ -86,6 +85,22 @@ class ftca_form : public nana::form
86
85
prog.scheme ().gradient_fgcolor = nana::color{" #b7d3db" };
87
86
prog.scheme ().background = nana::color{" #e4e4e4" };
88
87
prog.scheme ().foreground = nana::color{" #64a3b5" };
88
+ prog.typeface ({typeface ().name (), 11 , nana::paint::font::font_style{800 }});
89
+ nana::drawing{prog}.draw ([this ] (nana::paint::graphics &graph)
90
+ {
91
+ auto caption{prog.caption ()};
92
+ if (!caption.empty ())
93
+ {
94
+ auto tsize{graph.text_extent_size (caption)};
95
+ auto gsize{graph.size ()};
96
+ nana::point pos{0 ,0 };
97
+ if (tsize.width < gsize.width )
98
+ pos.x = gsize.width /2 - tsize.width /2 ;
99
+ if (tsize.height < gsize.height )
100
+ pos.y = gsize.height /2 - tsize.height /2 ;
101
+ graph.string (pos, caption, nana::colors::white);
102
+ }
103
+ });
89
104
plc[" prog" ] << prog;
90
105
91
106
collocate ();
@@ -100,8 +115,8 @@ class ftca_form : public nana::form
100
115
inpath = res.front ();
101
116
if (inpath == outpath)
102
117
{
103
- outpath.replace_filename (std::wstring{ L " arr_" } + outpath.filename ().c_str ());
104
- outpath.replace_extension (L " hpp" );
118
+ outpath.replace_filename (" arr_" + outpath.filename ().u8string ());
119
+ outpath.replace_extension (" hpp" );
105
120
label_path_caption (l_outpath, outpath);
106
121
}
107
122
label_path_caption (l_inpath, inpath);
@@ -120,8 +135,8 @@ class ftca_form : public nana::form
120
135
outpath = res.front ();
121
136
if (inpath == outpath)
122
137
{
123
- outpath.replace_filename (std::wstring{ L " arr_" } + outpath.filename ().c_str ());
124
- outpath.replace_extension (L " hpp" );
138
+ outpath.replace_filename (" arr_" + outpath.filename ().u8string ());
139
+ outpath.replace_extension (" hpp" );
125
140
label_path_caption (l_outpath, outpath);
126
141
}
127
142
label_path_caption (l_outpath, outpath);
@@ -218,10 +233,11 @@ class ftca_form : public nana::form
218
233
while (insize % width) width /= 2 ;
219
234
auto buf{std::make_unique<char []>(width)};
220
235
const int prog_steps{568 };
236
+ prog.caption (" " );
221
237
prog.amount (prog_steps);
222
238
prog.value (0 );
223
239
uintmax_t prog_step{0 }, step_treshold{0 };
224
- if (insize >= 10000 )
240
+ if (insize >= 568 )
225
241
{
226
242
prog_step = insize / prog_steps;
227
243
step_treshold = prog_step;
@@ -232,7 +248,7 @@ class ftca_form : public nana::form
232
248
std::ofstream outfile{outpath};
233
249
if (!outfile.good ()) throw (std::exception{" Failed to open the output file!" });
234
250
235
- auto name{" arr_" + inpath.filename ().generic_u8string ()};
251
+ auto name{" arr_" + inpath.filename ().u8string ()};
236
252
for (auto &c : name) if (!isalnum (c)) c = ' _' ;
237
253
238
254
outfile << " #include <cstdint>\n\n " ;
@@ -260,6 +276,7 @@ class ftca_form : public nana::form
260
276
prog.inc ();
261
277
}
262
278
if (abort) { working = false ; return ; }
279
+ if (outfile.bad ()) throw (std::exception{" Failed trying to write to the output file!" });
263
280
}
264
281
265
282
if (infile.bad ()) throw (std::exception{" Failed trying to read the input file!" });
@@ -268,6 +285,8 @@ class ftca_form : public nana::form
268
285
if (line_chars_max) outfile << ' \n ' ;
269
286
outfile << " };" ;
270
287
btn_gen.caption (gen_text);
288
+ prog.caption (" Operation completed." );
289
+ prog.value (prog_steps);
271
290
working = false ;
272
291
}
273
292
@@ -281,4 +300,4 @@ class ftca_form : public nana::form
281
300
l.caption (L" ..." + std::wstring{p.c_str ()}.substr (offset));
282
301
}
283
302
}
284
- };
303
+ };
0 commit comments