Added separator functionality for windows

This commit is contained in:
Ox Cart
2017-09-12 13:39:24 -05:00
parent ea13f57c7e
commit e82fd01f43
13 changed files with 34 additions and 18 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+1 -1
View File
@@ -102,7 +102,7 @@ func AddMenuItem(title string, tooltip string) *MenuItem {
// AddSeparator adds a separator bar to the menu
func AddSeparator() {
addSeparator()
addSeparator(atomic.AddInt32(&currentID, 1))
}
// SetTitle set the text to display on a menu item
+1 -1
View File
@@ -7,7 +7,7 @@ void setIcon(const char* iconBytes, int length);
void setTitle(char* title);
void setTooltip(char* tooltip);
void add_or_update_menu_item(int menuId, char* title, char* tooltip, short disabled, short checked);
void add_separator();
void add_separator(int menuId);
void hide_menu_item(int menuId);
void show_menu_item(int menuId);
void quit();
+8
View File
@@ -202,6 +202,14 @@ void add_or_update_menu_item(int menuId, wchar_t* title, wchar_t* tooltip, short
}
}
void add_separator(int menuId) {
InsertMenu(hTrayMenu, // parent menu
menuId, // position
MF_BYPOSITION | MF_SEPARATOR,
menuId, // identifier
NULL);
}
void hide_menu_item(int menuId) {
DeleteMenu(hTrayMenu, menuId, MF_BYCOMMAND);
}
+3 -2
View File
@@ -5,5 +5,6 @@ EXPORTS
setIcon @2
setTooltip @3
add_or_update_menu_item @4
hide_menu_item @5
quit @6
add_separator @5
hide_menu_item @6
quit @7
+2 -1
View File
@@ -8,6 +8,7 @@ extern "C" {
__declspec(dllexport) void __cdecl setIcon(const wchar_t* iconFile);
__declspec(dllexport) void __cdecl setTooltip(const wchar_t* tooltip);
__declspec(dllexport) void __cdecl add_or_update_menu_item(int menuId, wchar_t* title, wchar_t* tooltip, short disabled, short checked);
__declspec(dllexport) void __cdecl add_separator(int menuId);
__declspec(dllexport) void __cdecl hide_menu_item(int menuId);
__declspec(dllexport) void __cdecl quit();
}
}
+4 -3
View File
@@ -108,7 +108,7 @@
}
}
- (void) add_separator:id
- (void) add_separator:(NSNumber*) menuId
{
[menu addItem: [NSMenuItem separatorItem]];
}
@@ -183,8 +183,9 @@ void add_or_update_menu_item(int menuId, char* title, char* tooltip, short disab
runInMainThread(@selector(add_or_update_menu_item:), (id)item);
}
void add_separator() {
runInMainThread(@selector(add_separator:), NULL);
void add_separator(int menuId) {
NSNumber *mId = [NSNumber numberWithInt:menuId];
runInMainThread(@selector(add_separator:), (id)mId);
}
void hide_menu_item(int menuId) {
+2 -2
View File
@@ -60,8 +60,8 @@ func addOrUpdateMenuItem(item *MenuItem) {
)
}
func addSeparator() {
C.add_separator()
func addSeparator(id int32) {
C.add_separator(C.int(id))
}
func hideMenuItem(item *MenuItem) {
+5
View File
@@ -25,6 +25,7 @@ var (
_setTitle = mod.NewProc("setTitle")
_setTooltip = mod.NewProc("setTooltip")
_add_or_update_menu_item = mod.NewProc("add_or_update_menu_item")
_add_separator = mod.NewProc("add_separator")
_hide_menu_item = mod.NewProc("hide_menu_item")
)
@@ -132,6 +133,10 @@ func addOrUpdateMenuItem(item *MenuItem) {
)
}
func addSeparator(id int32) {
_add_separator.Call(uintptr(id))
}
func hideMenuItem(item *MenuItem) {
_hide_menu_item.Call(uintptr(item.id))
}
File diff suppressed because one or more lines are too long