-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
119 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#define UNICODE | ||
|
||
#include <windows.h> | ||
#include <shellapi.h> | ||
#include <winuser.h> | ||
|
||
static MENUITEMINFO mui_popup_menu_MENUITEMINFO (int id, bool def, bool disabled, bool checked, wchar_t* text) { | ||
MENUITEMINFO item; | ||
item.cbSize = sizeof(MENUITEMINFO); | ||
item.fMask = MIIM_ID | MIIM_TYPE | MIIM_STATE | MIIM_DATA; | ||
item.fType = 0; | ||
item.fState = 0; | ||
if (def){ | ||
item.fState |= MFS_DEFAULT; | ||
} | ||
if (disabled) { | ||
item.fState |= MFS_DISABLED; | ||
} | ||
if (checked) { | ||
item.fState |= MFS_CHECKED; | ||
} | ||
item.wID = id; | ||
item.dwTypeData = text; | ||
return item; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#define UNICODE | ||
|
||
#include <windows.h> | ||
#include <winuser.h> | ||
#include <stdio.h> | ||
|
||
int mui_window_top = 0; | ||
int mui_window_left = 0; | ||
int mui_window_bottom = 0; | ||
int mui_window_right = 0; | ||
|
||
static void mui_update_window_pos (HWND hwnd) { | ||
RECT pos; | ||
GetWindowRect(hwnd, &pos); | ||
mui_window_top = pos.top; | ||
mui_window_bottom = pos.bottom; | ||
mui_window_right = pos.right; | ||
mui_window_left = pos.left; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module mui | ||
|
||
#include "@VMODROOT/native/windows_shared_helper.h" | ||
#include "@VMODROOT/native/windows_popup_helper.h" | ||
|
||
fn C.CreatePopupMenu() voidptr | ||
fn C.InsertMenuItem(hmenu C.HMENU, id int, idk_wtd bool, item &C.MENUITEMINFO) | ||
fn C.TrackPopupMenu(hmenu C.HMENU, int, int, int, int, voidptr, int) int | ||
fn C.mui_popup_menu_MENUITEMINFO(id int, def bool, disabled bool, checked bool, text &u16) C.MENUITEMINFO | ||
fn C.DestroyMenu(hmenu C.HMENU) | ||
fn C.mui_update_window_pos(hwnd voidptr) | ||
|
||
fn (mut app Window) create_popup_menu(the_list []string, x int, y int) int { | ||
unsafe { | ||
mut hmenu := C.CreatePopupMenu() | ||
for id,w in the_list{ | ||
mut item := C.mui_popup_menu_MENUITEMINFO(id+1, false, false, false, w.to_wide()) | ||
C.InsertMenuItem(hmenu, id+1, true, &item) | ||
} | ||
C.mui_update_window_pos(app.window_handle()) | ||
output := C.TrackPopupMenu(hmenu, C.TPM_LEFTALIGN | C.TPM_RIGHTBUTTON | C.TPM_RETURNCMD | C.TPM_NONOTIFY, C.mui_window_left+x, C.mui_window_top+y, 0, app.window_handle(), C.NULL) | ||
C.DestroyMenu(hmenu) | ||
return output-1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,16 @@ | ||
module mui | ||
|
||
import os | ||
import os.font | ||
|
||
const ( | ||
text_cursor="│" | ||
os_font=font.default() | ||
text_cursor="|" | ||
os_font=get_os_font() | ||
) | ||
|
||
fn get_os_font()string{ | ||
if os.exists("C:/Windows/Fonts/segoeui.ttf"){ | ||
return "C:/Windows/Fonts/segoeui.ttf" | ||
} | ||
return font.default() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters