aboutsummaryrefslogtreecommitdiff
path: root/core/sys
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2019-01-02 20:51:48 +0000
committergingerBill <bill@gingerbill.org>2019-01-02 20:51:48 +0000
commit0546b5c218a877cd5debdd3aaf051ceaf29bd304 (patch)
tree7ce6162b341cadd27c3694a883eab60210b823e2 /core/sys
parent61a3e50d1bd5d51105d36b74600a049af0d76add (diff)
Add sys/win32/comdlg32.odin
Diffstat (limited to 'core/sys')
-rw-r--r--core/sys/win32/comdlg32.odin93
-rw-r--r--core/sys/win32/general.odin22
2 files changed, 105 insertions, 10 deletions
diff --git a/core/sys/win32/comdlg32.odin b/core/sys/win32/comdlg32.odin
new file mode 100644
index 000000000..790c9d598
--- /dev/null
+++ b/core/sys/win32/comdlg32.odin
@@ -0,0 +1,93 @@
+// +build windows
+package win32
+
+foreign import "system:comdlg32.lib"
+
+OFN_Hook_Proc :: #type proc "stdcall" (hdlg: Hwnd, msg: u32, wparam: Wparam, lparam: Lparam) -> Uint_Ptr;
+
+Open_File_Name_A :: struct {
+ struct_size: u32,
+ hwnd_owner: Hwnd,
+ instance: Hinstance,
+ filter: cstring,
+ custom_filter: cstring,
+ max_cust_filter: u32,
+ filter_index: u32,
+ file: cstring,
+ max_file: u32,
+ file_title: cstring,
+ max_file_title: u32,
+ initial_dir: cstring,
+ title: cstring,
+ flags: u32,
+ file_offset: u16,
+ file_extension: u16,
+ def_ext: cstring,
+ cust_data: Lparam,
+ hook: OFN_Hook_Proc,
+ template_name: cstring,
+ pv_reserved: rawptr,
+ dw_reserved: u32,
+ flags_ex: u32,
+}
+
+Open_File_Name_W :: struct {
+ struct_size: u32,
+ hwnd_owner: Hwnd,
+ instance: Hinstance,
+ filter: Wstring,
+ custom_filter: Wstring,
+ max_cust_filter: u32,
+ filter_index: u32,
+ file: Wstring,
+ max_file: u32,
+ file_title: Wstring,
+ max_file_title: u32,
+ initial_dir: Wstring,
+ title: Wstring,
+ flags: u32,
+ file_offset: u16,
+ file_extension: u16,
+ def_ext: Wstring,
+ cust_data: Lparam,
+ hook: OFN_Hook_Proc,
+ template_name: Wstring,
+ pv_reserved: rawptr,
+ dw_reserved: u32,
+ flags_ex: u32,
+}
+
+@(default_calling_convention = "c")
+foreign comdlg32 {
+ @(link_name="GetOpenFileNameA") get_open_file_name_a :: proc(arg1: ^Open_File_Name_A) -> Bool ---
+ @(link_name="GetOpenFileNameW") get_open_file_name_w :: proc(arg1: ^Open_File_Name_W) -> Bool ---
+
+ @(link_name="CommDlgExtendedError") comm_dlg_extended_error :: proc() -> u32 ---
+}
+
+OFN_ALLOWMULTISELECT :: 0x00000200;
+OFN_CREATEPROMPT :: 0x00002000;
+OFN_DONTADDTORECENT :: 0x02000000;
+OFN_ENABLEHOOK :: 0x00000020;
+OFN_ENABLEINCLUDENOTIFY :: 0x00400000;
+OFN_ENABLESIZING :: 0x00800000;
+OFN_ENABLETEMPLATE :: 0x00000040;
+OFN_ENABLETEMPLATEHANDLE :: 0x00000080;
+OFN_EXPLORER :: 0x00080000;
+OFN_EXTENSIONDIFFERENT :: 0x00000400;
+OFN_FILEMUSTEXIST :: 0x00001000;
+OFN_FORCESHOWHIDDEN :: 0x10000000;
+OFN_HIDEREADONLY :: 0x00000004;
+OFN_LONGNAMES :: 0x00200000;
+OFN_NOCHANGEDIR :: 0x00000008;
+OFN_NODEREFERENCELINKS :: 0x00100000;
+OFN_NOLONGNAMES :: 0x00040000;
+OFN_NONETWORKBUTTON :: 0x00020000;
+OFN_NOREADONLYRETURN :: 0x00008000;
+OFN_NOTESTFILECREATE :: 0x00010000;
+OFN_NOVALIDATE :: 0x00000100;
+OFN_OVERWRITEPROMPT :: 0x00000002;
+OFN_PATHMUSTEXIST :: 0x00000800;
+OFN_READONLY :: 0x00000001;
+OFN_SHAREAWARE :: 0x00004000;
+OFN_SHOWHELP :: 0x00000010;
diff --git a/core/sys/win32/general.odin b/core/sys/win32/general.odin
index 7a1841e61..c7e79860a 100644
--- a/core/sys/win32/general.odin
+++ b/core/sys/win32/general.odin
@@ -1,6 +1,9 @@
// +build windows
package win32
+Uint_Ptr :: distinct uint;
+Long_Ptr :: distinct int;
+
Handle :: distinct rawptr;
Hwnd :: distinct Handle;
Hdc :: distinct Handle;
@@ -16,18 +19,17 @@ Hmonitor :: distinct Handle;
Hrawinput :: distinct Handle;
Hresult :: distinct i32;
HKL :: distinct Handle;
-Wparam :: distinct uint;
-Lparam :: distinct int;
-Lresult :: distinct int;
+Wparam :: distinct Uint_Ptr;
+Lparam :: distinct Long_Ptr;
+Lresult :: distinct Long_Ptr;
Wnd_Proc :: distinct #type proc "c" (Hwnd, u32, Wparam, Lparam) -> Lresult;
Monitor_Enum_Proc :: distinct #type proc "std" (Hmonitor, Hdc, ^Rect, Lparam) -> bool;
-Uint_Ptr :: distinct uint;
-Long_Ptr :: distinct int;
+
Bool :: distinct b32;
-Wstring :: ^u16;
+Wstring :: distinct ^u16;
Point :: struct {
x, y: i32,
@@ -720,7 +722,7 @@ utf8_to_ucs2 :: proc(s: string, allocator := context.temp_allocator) -> []u16 {
text := make([]u16, n+1, allocator);
- n1 := multi_byte_to_wide_char(CP_UTF8, MB_ERR_INVALID_CHARS, cstring(&s[0]), i32(len(s)), &text[0], i32(n));
+ n1 := multi_byte_to_wide_char(CP_UTF8, MB_ERR_INVALID_CHARS, cstring(&s[0]), i32(len(s)), Wstring(&text[0]), i32(n));
if n1 == 0 {
delete(text, allocator);
return nil;
@@ -732,7 +734,7 @@ utf8_to_ucs2 :: proc(s: string, allocator := context.temp_allocator) -> []u16 {
}
utf8_to_wstring :: proc(s: string, allocator := context.temp_allocator) -> Wstring {
if res := utf8_to_ucs2(s, allocator); res != nil {
- return &res[0];
+ return Wstring(&res[0]);
}
return nil;
}
@@ -742,14 +744,14 @@ ucs2_to_utf8 :: proc(s: []u16, allocator := context.temp_allocator) -> string {
return "";
}
- n := wide_char_to_multi_byte(CP_UTF8, WC_ERR_INVALID_CHARS, &s[0], i32(len(s)), nil, 0, nil, nil);
+ n := wide_char_to_multi_byte(CP_UTF8, WC_ERR_INVALID_CHARS, Wstring(&s[0]), i32(len(s)), nil, 0, nil, nil);
if n == 0 {
return "";
}
text := make([]byte, n+1, allocator);
- n1 := wide_char_to_multi_byte(CP_UTF8, WC_ERR_INVALID_CHARS, &s[0], i32(len(s)), cstring(&text[0]), n, nil, nil);
+ n1 := wide_char_to_multi_byte(CP_UTF8, WC_ERR_INVALID_CHARS, Wstring(&s[0]), i32(len(s)), cstring(&text[0]), n, nil, nil);
if n1 == 0 {
delete(text, allocator);
return "";