mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-25 09:50:59 +00:00
78 lines
2.2 KiB
Plaintext
78 lines
2.2 KiB
Plaintext
#include <unistd.h>
|
|
#include <sys/sysctl.h>
|
|
#import <Cocoa/Cocoa.h>
|
|
#import <wx/osx/cocoa/dataview.h>
|
|
#import "GUI_Utils.hpp"
|
|
|
|
namespace Slic3r {
|
|
namespace GUI {
|
|
|
|
void dataview_remove_insets(wxDataViewCtrl* dv) {
|
|
NSScrollView* scrollview = (NSScrollView*) ((wxCocoaDataViewControl*)dv->GetDataViewPeer())->GetWXWidget();
|
|
NSOutlineView* outlineview = scrollview.documentView;
|
|
[outlineview setIntercellSpacing: NSMakeSize(0.0, 1.0)];
|
|
if (@available(macOS 11, *)) {
|
|
[outlineview setStyle:NSTableViewStylePlain];
|
|
}
|
|
}
|
|
|
|
void staticbox_remove_margin(wxStaticBox* sb) {
|
|
NSBox* nativeBox = (NSBox*)sb->GetHandle();
|
|
[nativeBox setBoxType:NSBoxCustom];
|
|
[nativeBox setBorderWidth:0];
|
|
}
|
|
|
|
// wxOSX SetShape only clears the window background; it cannot clip to a region. Clipping the
|
|
// window's view layer to a rounded rect is what actually rounds the opaque webview inside.
|
|
void set_window_corner_radius(wxWindow* win, int radius) {
|
|
if (!win)
|
|
return;
|
|
NSView* view = (NSView*)win->GetHandle();
|
|
if (!view)
|
|
return;
|
|
NSWindow* window = [view window];
|
|
[window setOpaque:NO];
|
|
[window setBackgroundColor:[NSColor clearColor]];
|
|
[view setWantsLayer:YES];
|
|
[[view layer] setCornerRadius:radius];
|
|
[[view layer] setMasksToBounds:YES];
|
|
}
|
|
|
|
bool is_debugger_present()
|
|
// Returns true if the current process is being debugged (either
|
|
// running under the debugger or has a debugger attached post facto).
|
|
// https://stackoverflow.com/a/2200786/3289421
|
|
{
|
|
int junk;
|
|
int mib[4];
|
|
struct kinfo_proc info;
|
|
size_t size;
|
|
|
|
// Initialize the flags so that, if sysctl fails for some bizarre
|
|
// reason, we get a predictable result.
|
|
|
|
info.kp_proc.p_flag = 0;
|
|
|
|
// Initialize mib, which tells sysctl the info we want, in this case
|
|
// we're looking for information about a specific process ID.
|
|
|
|
mib[0] = CTL_KERN;
|
|
mib[1] = KERN_PROC;
|
|
mib[2] = KERN_PROC_PID;
|
|
mib[3] = getpid();
|
|
|
|
// Call sysctl.
|
|
|
|
size = sizeof(info);
|
|
junk = sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, NULL, 0);
|
|
assert(junk == 0);
|
|
|
|
// We're being debugged if the P_TRACED flag is set.
|
|
|
|
return ( (info.kp_proc.p_flag & P_TRACED) != 0 );
|
|
}
|
|
|
|
}
|
|
}
|
|
|