1#[cfg(target_os = "windows")]
2use ponsic::{
3 graphics::context_2d::{Context2D, DrawText},
4 widgets::{Proc, Window},
5 *,
6};
7
8#[cfg(not(target_os = "windows"))]
9fn main() {}
10
11struct MyWindow {}
12impl Proc for MyWindow {
13 fn handle(&mut self, Events { event, .. }: Events) -> Return {
14 if let Event::Window(WindowEvent::Destroy) = event {
15 App::should_exit(0);
16 return Return::Finish;
17 }
18 Return::Default
19 }
20
21 fn draw(&mut self, context: ponsic::graphics::Context) {
22 let context: Context2D = context.into();
23 context.draw_text("Hello World", &mut Recti::new(10, 10, 100, 100), &[]);
24 }
25}
26
27#[cfg(target_os = "windows")]
28fn main() {
29 let window = Window::create(
30 Rect::from((Point::new(100, 100), Size::new(800, 600))),
31 "Hello World",
32 None,
33 MyWindow {},
34 )
35 .unwrap();
36
37 window.show();
38
39 while App::handle_event(true).unwrap() {}
40}