Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
snuk182 committed Nov 29, 2017
1 parent ba23750 commit 9327dcf
Show file tree
Hide file tree
Showing 12 changed files with 1,556 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[package]
name = "plygui-win32"
version = "0.0.1"
authors = ["Serhii Plyhun <[email protected]>"]

[lib]
name = "plygui_win32"
path = "src/lib.rs"

[dependencies]
plygui = {version = "0.0.1", path = "../plygui"}
user32-sys = "~0.2"
gdi32-sys = "~0.2"
kernel32-sys = "~0.2"
comctl32-sys = "~0.2"
comdlg32-sys = "~0.2"
winapi = "~0.2"
lazy_static = "~0.2"
derive_builder = "~0.5"

[build-dependencies]
embed-resource = "~1.1"
5 changes: 5 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
extern crate embed_resource;

fn main() {
embed_resource::compile("plygui.rc");
}
33 changes: 33 additions & 0 deletions plygui.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1"
manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<assemblyIdentity version="1.0.0.0"
processorArchitecture="*" name="plygui.Plygui" type="win32" />
<description>Plygui</description>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32"
name="Microsoft.Windows.Common-Controls" version="6.0.0.0"
processorArchitecture="*" publicKeyToken="6595b64144ccf1df"
language="*" />
</dependentAssembly>
</dependency>

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" /> <!-- Windows Vista -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" /> <!-- Windows 7 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" /> <!-- Windows 8 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" /> <!-- Windows 8.1 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" /> <!-- Windows 10 -->
</application>
</compatibility>

<asmv3:application>
<asmv3:windowsSettings
xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>true</dpiAware>
</asmv3:windowsSettings>
</asmv3:application>
</assembly>

2 changes: 2 additions & 0 deletions plygui.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#define RT_MANIFEST 24
1 RT_MANIFEST "plygui.manifest"
1 change: 1 addition & 0 deletions rustfmt.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
max_width = 250
65 changes: 65 additions & 0 deletions src/application.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
use super::*;
use super::common::WindowsContainer;

use std::{mem, thread};

use plygui::{Id, UiApplication, UiWindow};

pub struct Application {
name: String,
windows: Vec<winapi::HWND>,
}

impl UiApplication for Application {
fn new_window(&mut self, title: &str, width: u16, height: u16, has_menu: bool) -> Box<UiWindow> {
let w = Window::new(title, width, height, has_menu);
unsafe {
self.windows.push(w.hwnd());
}
w
}
fn name(&self) -> &str {
self.name.as_str()
}
fn start(&mut self) {
for i in (0..self.windows.len()).rev() {
if i > 0 {
thread::spawn(move || {});
} else {
start_window(self.windows[i]);
}
}
}
}

impl Application {
pub fn with_name(name: &str) -> Box<Application> {
init_comctl();
Id::next();
Box::new(Application {
name: name.into(),
windows: Vec::with_capacity(1),
})
}
}

fn start_window(hwnd: winapi::HWND) {
let w: &mut Window = unsafe { mem::transmute(user32::GetWindowLongPtrW(hwnd, winapi::GWLP_USERDATA)) };
w.start();
}

fn init_comctl() {
unsafe {
let mut icc: winapi::INITCOMMONCONTROLSEX = mem::zeroed();
icc.dwSize = mem::size_of::<winapi::INITCOMMONCONTROLSEX>() as u32;
icc.dwICC = winapi::ICC_STANDARD_CLASSES
| winapi::ICC_LISTVIEW_CLASSES
| winapi::ICC_TAB_CLASSES
| winapi::ICC_PROGRESS_CLASS
| winapi::ICC_UPDOWN_CLASS
| winapi::ICC_BAR_CLASSES;
if comctl32::InitCommonControlsEx(&icc) == 0 {
common::log_error();
}
}
}
Loading

0 comments on commit 9327dcf

Please sign in to comment.