Update to hiro v100r1
This commit is contained in:
parent
127fa784cc
commit
252f89d17e
29 changed files with 82 additions and 82 deletions
|
@ -33,8 +33,8 @@ auto DropPathsOperation(id<NSDraggingInfo> sender) -> NSDragOperation {
|
|||
return NSDragOperationNone;
|
||||
}
|
||||
|
||||
auto DropPaths(id<NSDraggingInfo> sender) -> lstring {
|
||||
lstring paths;
|
||||
auto DropPaths(id<NSDraggingInfo> sender) -> string_vector {
|
||||
string_vector paths;
|
||||
NSPasteboard* pboard = [sender draggingPasteboard];
|
||||
if([[pboard types] containsObject:NSFilenamesPboardType]) {
|
||||
NSArray* files = [pboard propertyListForType:NSFilenamesPboardType];
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
}
|
||||
|
||||
-(BOOL) performDragOperation:(id<NSDraggingInfo>)sender {
|
||||
lstring paths = DropPaths(sender);
|
||||
auto paths = DropPaths(sender);
|
||||
if(!paths) return NO;
|
||||
canvas->doDrop(paths);
|
||||
return YES;
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
}
|
||||
|
||||
-(BOOL) performDragOperation:(id<NSDraggingInfo>)sender {
|
||||
lstring paths = DropPaths(sender);
|
||||
auto paths = DropPaths(sender);
|
||||
if(!paths) return NO;
|
||||
viewport->doDrop(paths);
|
||||
return YES;
|
||||
|
@ -53,8 +53,8 @@ auto pViewport::destruct() -> void {
|
|||
}
|
||||
}
|
||||
|
||||
auto pViewport::handle() const -> uintptr {
|
||||
return (uintptr)cocoaViewport;
|
||||
auto pViewport::handle() const -> uintptr_t {
|
||||
return (uintptr_t)cocoaViewport;
|
||||
}
|
||||
|
||||
auto pViewport::setDroppable(bool droppable) -> void {
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace hiro {
|
|||
struct pViewport : pWidget {
|
||||
Declare(Viewport, Widget)
|
||||
|
||||
auto handle() const -> uintptr;
|
||||
auto handle() const -> uintptr_t;
|
||||
auto setDroppable(bool droppable) -> void;
|
||||
|
||||
CocoaViewport* cocoaViewport = nullptr;
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
[item setTarget:self];
|
||||
[rootMenu addItem:item];
|
||||
|
||||
string result = nall::execute("defaults", "read", "/Library/Preferences/com.apple.security", "GKAutoRearm").strip();
|
||||
string result = nall::execute("defaults", "read", "/Library/Preferences/com.apple.security", "GKAutoRearm").output.strip();
|
||||
if(result != "0") {
|
||||
disableGatekeeperAutoRearm = [[[NSMenuItem alloc] initWithTitle:@"Disable Gatekeeper Auto-Rearm" action:@selector(menuDisableGatekeeperAutoRearm) keyEquivalent:@""] autorelease];
|
||||
[disableGatekeeperAutoRearm setTarget:self];
|
||||
|
@ -121,7 +121,7 @@
|
|||
}
|
||||
|
||||
-(BOOL) performDragOperation:(id<NSDraggingInfo>)sender {
|
||||
lstring paths = DropPaths(sender);
|
||||
auto paths = DropPaths(sender);
|
||||
if(!paths) return NO;
|
||||
window->doDrop(paths);
|
||||
return YES;
|
||||
|
@ -144,7 +144,7 @@
|
|||
[alert setMessageText:@"Disable Gatekeeper Auto-Rearm"];
|
||||
|
||||
nall::execute("sudo", "defaults", "write", "/Library/Preferences/com.apple.security", "GKAutoRearm", "-bool", "NO");
|
||||
if(nall::execute("defaults", "read", "/Library/Preferences/com.apple.security", "GKAutoRearm").strip() == "0") {
|
||||
if(nall::execute("defaults", "read", "/Library/Preferences/com.apple.security", "GKAutoRearm").output.strip() == "0") {
|
||||
[alert setAlertStyle:NSInformationalAlertStyle];
|
||||
[alert setInformativeText:@"Gatekeeper's automatic 30-day rearm behavior has been disabled successfully."];
|
||||
[disableGatekeeperAutoRearm setHidden:YES];
|
||||
|
|
|
@ -12,7 +12,7 @@ auto BrowserWindow::save() -> string {
|
|||
return pBrowserWindow::save(state);
|
||||
}
|
||||
|
||||
auto BrowserWindow::setFilters(const lstring& filters) -> type& {
|
||||
auto BrowserWindow::setFilters(const string_vector& filters) -> type& {
|
||||
state.filters = filters;
|
||||
return *this;
|
||||
}
|
||||
|
|
|
@ -16,13 +16,13 @@
|
|||
|
||||
using nall::function;
|
||||
using nall::image;
|
||||
using nall::lstring;
|
||||
using nall::maybe;
|
||||
using nall::nothing;
|
||||
using nall::set;
|
||||
using nall::shared_pointer;
|
||||
using nall::shared_pointer_weak;
|
||||
using nall::string;
|
||||
using nall::string_vector;
|
||||
using nall::vector;
|
||||
|
||||
namespace hiro {
|
||||
|
@ -477,14 +477,14 @@ struct BrowserWindow {
|
|||
auto directory() -> string;
|
||||
auto open() -> string;
|
||||
auto save() -> string;
|
||||
auto setFilters(const lstring& filters = {"*"}) -> type&;
|
||||
auto setFilters(const string_vector& filters = {"*"}) -> type&;
|
||||
auto setParent(sWindow parent) -> type&;
|
||||
auto setPath(const string& path = "") -> type&;
|
||||
auto setTitle(const string& title = "") -> type&;
|
||||
|
||||
//private:
|
||||
struct State {
|
||||
lstring filters;
|
||||
string_vector filters;
|
||||
sWindow parent;
|
||||
string path;
|
||||
string title;
|
||||
|
@ -667,7 +667,7 @@ struct mWindow : mObject {
|
|||
auto append(sStatusBar statusBar) -> type&;
|
||||
auto backgroundColor() const -> Color;
|
||||
auto doClose() const -> void;
|
||||
auto doDrop(lstring) const -> void;
|
||||
auto doDrop(string_vector) const -> void;
|
||||
auto doKeyPress(signed) const -> void;
|
||||
auto doKeyRelease(signed) const -> void;
|
||||
auto doMove() const -> void;
|
||||
|
@ -680,7 +680,7 @@ struct mWindow : mObject {
|
|||
auto menuBar() const -> MenuBar;
|
||||
auto modal() const -> bool;
|
||||
auto onClose(const function<void ()>& callback = {}) -> type&;
|
||||
auto onDrop(const function<void (lstring)>& callback = {}) -> type&;
|
||||
auto onDrop(const function<void (string_vector)>& callback = {}) -> type&;
|
||||
auto onKeyPress(const function<void (signed)>& callback = {}) -> type&;
|
||||
auto onKeyRelease(const function<void (signed)>& callback = {}) -> type&;
|
||||
auto onMove(const function<void ()>& callback = {}) -> type&;
|
||||
|
@ -717,7 +717,7 @@ struct mWindow : mObject {
|
|||
sMenuBar menuBar;
|
||||
bool modal = false;
|
||||
function<void ()> onClose;
|
||||
function<void (lstring)> onDrop;
|
||||
function<void (string_vector)> onDrop;
|
||||
function<void (signed)> onKeyPress;
|
||||
function<void (signed)> onKeyRelease;
|
||||
function<void ()> onMove;
|
||||
|
@ -989,14 +989,14 @@ struct mCanvas : mWidget {
|
|||
auto color() const -> Color;
|
||||
auto data() -> uint32_t*;
|
||||
auto droppable() const -> bool;
|
||||
auto doDrop(lstring names) const -> void;
|
||||
auto doDrop(string_vector names) const -> void;
|
||||
auto doMouseLeave() const -> void;
|
||||
auto doMouseMove(Position position) const -> void;
|
||||
auto doMousePress(Mouse::Button button) const -> void;
|
||||
auto doMouseRelease(Mouse::Button button) const -> void;
|
||||
auto gradient() const -> Gradient;
|
||||
auto icon() const -> image;
|
||||
auto onDrop(const function<void (lstring)>& callback = {}) -> type&;
|
||||
auto onDrop(const function<void (string_vector)>& callback = {}) -> type&;
|
||||
auto onMouseLeave(const function<void ()>& callback = {}) -> type&;
|
||||
auto onMouseMove(const function<void (Position)>& callback = {}) -> type&;
|
||||
auto onMousePress(const function<void (Mouse::Button)>& callback = {}) -> type&;
|
||||
|
@ -1015,7 +1015,7 @@ struct mCanvas : mWidget {
|
|||
bool droppable = false;
|
||||
Gradient gradient;
|
||||
image icon;
|
||||
function<void (lstring)> onDrop;
|
||||
function<void (string_vector)> onDrop;
|
||||
function<void ()> onMouseLeave;
|
||||
function<void (Position)> onMouseMove;
|
||||
function<void (Mouse::Button)> onMousePress;
|
||||
|
@ -1944,14 +1944,14 @@ struct mVerticalSlider : mWidget {
|
|||
struct mViewport : mWidget {
|
||||
Declare(Viewport)
|
||||
|
||||
auto doDrop(lstring names) const -> void;
|
||||
auto doDrop(string_vector names) const -> void;
|
||||
auto doMouseLeave() const -> void;
|
||||
auto doMouseMove(Position position) const -> void;
|
||||
auto doMousePress(Mouse::Button button) const -> void;
|
||||
auto doMouseRelease(Mouse::Button button) const -> void;
|
||||
auto droppable() const -> bool;
|
||||
auto handle() const -> uintptr_t;
|
||||
auto onDrop(const function<void (lstring)>& callback = {}) -> type&;
|
||||
auto onDrop(const function<void (string_vector)>& callback = {}) -> type&;
|
||||
auto onMouseLeave(const function<void ()>& callback = {}) -> type&;
|
||||
auto onMouseMove(const function<void (Position position)>& callback = {}) -> type&;
|
||||
auto onMousePress(const function<void (Mouse::Button)>& callback = {}) -> type&;
|
||||
|
@ -1961,7 +1961,7 @@ struct mViewport : mWidget {
|
|||
//private:
|
||||
struct State {
|
||||
bool droppable = false;
|
||||
function<void (lstring)> onDrop;
|
||||
function<void (string_vector)> onDrop;
|
||||
function<void ()> onMouseLeave;
|
||||
function<void (Position)> onMouseMove;
|
||||
function<void (Mouse::Button)> onMousePress;
|
||||
|
|
|
@ -234,14 +234,14 @@ struct Canvas : sCanvas {
|
|||
auto color() const { return self().color(); }
|
||||
auto data() { return self().data(); }
|
||||
auto droppable() const { return self().droppable(); }
|
||||
auto doDrop(lstring names) { return self().doDrop(names); }
|
||||
auto doDrop(string_vector names) { return self().doDrop(names); }
|
||||
auto doMouseLeave() const { return self().doMouseLeave(); }
|
||||
auto doMouseMove(Position position) const { return self().doMouseMove(position); }
|
||||
auto doMousePress(Mouse::Button button) const { return self().doMousePress(button); }
|
||||
auto doMouseRelease(Mouse::Button button) const { return self().doMouseRelease(button); }
|
||||
auto gradient() const { return self().gradient(); }
|
||||
auto icon() const { return self().icon(); }
|
||||
auto onDrop(const function<void (lstring)>& callback = {}) { return self().onDrop(callback), *this; }
|
||||
auto onDrop(const function<void (string_vector)>& callback = {}) { return self().onDrop(callback), *this; }
|
||||
auto onMouseLeave(const function<void ()>& callback = {}) { return self().onMouseLeave(callback), *this; }
|
||||
auto onMouseMove(const function<void (Position)>& callback = {}) { return self().onMouseMove(callback), *this; }
|
||||
auto onMousePress(const function<void (Mouse::Button)>& callback = {}) { return self().onMousePress(callback), *this; }
|
||||
|
@ -873,14 +873,14 @@ struct Viewport : sViewport {
|
|||
DeclareSharedWidget(Viewport)
|
||||
using internalType = mViewport;
|
||||
|
||||
auto doDrop(lstring names) const { return self().doDrop(names); }
|
||||
auto doDrop(string_vector names) const { return self().doDrop(names); }
|
||||
auto doMouseLeave() const { return self().doMouseLeave(); }
|
||||
auto doMouseMove(Position position) const { return self().doMouseMove(position); }
|
||||
auto doMousePress(Mouse::Button button) const { return self().doMousePress(button); }
|
||||
auto doMouseRelease(Mouse::Button button) const { return self().doMouseRelease(button); }
|
||||
auto droppable() const { return self().droppable(); }
|
||||
auto handle() const { return self().handle(); }
|
||||
auto onDrop(const function<void (lstring)>& callback = {}) { return self().onDrop(callback), *this; }
|
||||
auto onDrop(const function<void (string_vector)>& callback = {}) { return self().onDrop(callback), *this; }
|
||||
auto onMouseLeave(const function<void ()>& callback = {}) { return self().onMouseLeave(callback), *this; }
|
||||
auto onMouseMove(const function<void (Position)>& callback = {}) { return self().onMouseMove(callback), *this; }
|
||||
auto onMousePress(const function<void (Mouse::Button)>& callback = {}) { return self().onMousePress(callback), *this; }
|
||||
|
@ -937,7 +937,7 @@ struct Window : sWindow {
|
|||
auto append(sStatusBar statusBar) { return self().append(statusBar), *this; }
|
||||
auto backgroundColor() const { return self().backgroundColor(); }
|
||||
auto doClose() const { return self().doClose(); }
|
||||
auto doDrop(lstring names) const { return self().doDrop(names); }
|
||||
auto doDrop(string_vector names) const { return self().doDrop(names); }
|
||||
auto doKeyPress(signed key) const { return self().doKeyPress(key); }
|
||||
auto doKeyRelease(signed key) const { return self().doKeyRelease(key); }
|
||||
auto doMove() const { return self().doMove(); }
|
||||
|
@ -950,7 +950,7 @@ struct Window : sWindow {
|
|||
auto menuBar() const { return self().menuBar(); }
|
||||
auto modal() const { return self().modal(); }
|
||||
auto onClose(const function<void ()>& callback = {}) { return self().onClose(callback), *this; }
|
||||
auto onDrop(const function<void (lstring)>& callback = {}) { return self().onDrop(callback), *this; }
|
||||
auto onDrop(const function<void (string_vector)>& callback = {}) { return self().onDrop(callback), *this; }
|
||||
auto onKeyPress(const function<void (signed)>& callback = {}) { return self().onKeyPress(callback), *this; }
|
||||
auto onKeyRelease(const function<void (signed)>& callback = {}) { return self().onKeyRelease(callback), *this; }
|
||||
auto onMove(const function<void ()>& callback = {}) { return self().onMove(callback), *this; }
|
||||
|
|
|
@ -18,7 +18,7 @@ auto mCanvas::droppable() const -> bool {
|
|||
return state.droppable;
|
||||
}
|
||||
|
||||
auto mCanvas::doDrop(lstring names) const -> void {
|
||||
auto mCanvas::doDrop(string_vector names) const -> void {
|
||||
if(state.onDrop) return state.onDrop(names);
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ auto mCanvas::icon() const -> image {
|
|||
return state.icon;
|
||||
}
|
||||
|
||||
auto mCanvas::onDrop(const function<void (lstring)>& callback) -> type& {
|
||||
auto mCanvas::onDrop(const function<void (string_vector)>& callback) -> type& {
|
||||
state.onDrop = callback;
|
||||
return *this;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ auto mViewport::allocate() -> pObject* {
|
|||
|
||||
//
|
||||
|
||||
auto mViewport::doDrop(lstring names) const -> void {
|
||||
auto mViewport::doDrop(string_vector names) const -> void {
|
||||
if(state.onDrop) return state.onDrop(names);
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ auto mViewport::handle() const -> uintptr_t {
|
|||
return signal(handle);
|
||||
}
|
||||
|
||||
auto mViewport::onDrop(const function<void (lstring)>& callback) -> type& {
|
||||
auto mViewport::onDrop(const function<void (string_vector)>& callback) -> type& {
|
||||
state.onDrop = callback;
|
||||
return *this;
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ auto mWindow::doClose() const -> void {
|
|||
if(state.onClose) return state.onClose();
|
||||
}
|
||||
|
||||
auto mWindow::doDrop(lstring names) const -> void {
|
||||
auto mWindow::doDrop(string_vector names) const -> void {
|
||||
if(state.onDrop) return state.onDrop(names);
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ auto mWindow::onClose(const function<void ()>& callback) -> type& {
|
|||
return *this;
|
||||
}
|
||||
|
||||
auto mWindow::onDrop(const function<void (lstring)>& callback) -> type& {
|
||||
auto mWindow::onDrop(const function<void (string_vector)>& callback) -> type& {
|
||||
state.onDrop = callback;
|
||||
return *this;
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ struct BrowserDialogWindow {
|
|||
auto change() -> void;
|
||||
auto isFolder(const string& name) -> bool;
|
||||
auto isMatch(const string& name) -> bool;
|
||||
auto run() -> lstring;
|
||||
auto run() -> string_vector;
|
||||
auto setPath(string path) -> void;
|
||||
|
||||
private:
|
||||
|
@ -26,7 +26,7 @@ private:
|
|||
Button cancelButton{&controlLayout, Size{80, 0}, 5};
|
||||
|
||||
BrowserDialog::State& state;
|
||||
vector<lstring> filters;
|
||||
vector<string_vector> filters;
|
||||
};
|
||||
|
||||
//accept button clicked, or enter pressed on file name line edit
|
||||
|
@ -113,14 +113,14 @@ auto BrowserDialogWindow::isMatch(const string& name) -> bool {
|
|||
return false;
|
||||
}
|
||||
|
||||
auto BrowserDialogWindow::run() -> lstring {
|
||||
auto BrowserDialogWindow::run() -> string_vector {
|
||||
state.response.reset();
|
||||
|
||||
layout.setMargin(5);
|
||||
pathName.onActivate([&] { setPath(pathName.text()); });
|
||||
pathRefresh.setBordered(false).setIcon(Icon::Action::Refresh).onActivate([&] { setPath(state.path); });
|
||||
pathHome.setBordered(false).setIcon(Icon::Go::Home).onActivate([&] { setPath(Path::user()); });
|
||||
pathUp.setBordered(false).setIcon(Icon::Go::Up).onActivate([&] { setPath(dirname(state.path)); });
|
||||
pathUp.setBordered(false).setIcon(Icon::Go::Up).onActivate([&] { setPath(Location::dir(state.path)); });
|
||||
view.setBatchable(state.action == "openFiles").onActivate([&] { activate(); }).onChange([&] { change(); });
|
||||
filterList.setVisible(state.action != "selectFolder").onChange([&] { setPath(state.path); });
|
||||
for(auto& filter : state.filters) {
|
||||
|
@ -156,7 +156,7 @@ auto BrowserDialogWindow::run() -> lstring {
|
|||
|
||||
auto BrowserDialogWindow::setPath(string path) -> void {
|
||||
path.transform("\\", "/");
|
||||
if(!path.endsWith("/")) path.append("/");
|
||||
if((path || Path::root() == "/") && !path.endsWith("/")) path.append("/");
|
||||
pathName.setText(state.path = path);
|
||||
|
||||
view.reset();
|
||||
|
@ -197,7 +197,7 @@ auto BrowserDialog::openFile() -> string {
|
|||
return {};
|
||||
}
|
||||
|
||||
auto BrowserDialog::openFiles() -> lstring {
|
||||
auto BrowserDialog::openFiles() -> string_vector {
|
||||
state.action = "openFiles";
|
||||
if(!state.title) state.title = "Open Files";
|
||||
if(auto result = _run()) return result;
|
||||
|
@ -225,7 +225,7 @@ auto BrowserDialog::selectFolder() -> string {
|
|||
return {};
|
||||
}
|
||||
|
||||
auto BrowserDialog::setFilters(const lstring& filters) -> type& {
|
||||
auto BrowserDialog::setFilters(const string_vector& filters) -> type& {
|
||||
state.filters = filters;
|
||||
return *this;
|
||||
}
|
||||
|
@ -245,7 +245,7 @@ auto BrowserDialog::setTitle(const string& title) -> type& {
|
|||
return *this;
|
||||
}
|
||||
|
||||
auto BrowserDialog::_run() -> lstring {
|
||||
auto BrowserDialog::_run() -> string_vector {
|
||||
if(!state.path) state.path = Path::user();
|
||||
return BrowserDialogWindow(state).run();
|
||||
}
|
||||
|
|
|
@ -6,12 +6,12 @@ struct BrowserDialog {
|
|||
using type = BrowserDialog;
|
||||
|
||||
BrowserDialog();
|
||||
auto openFile() -> string; //one existing file
|
||||
auto openFiles() -> lstring; //any existing files or folders
|
||||
auto openFolder() -> string; //one existing folder
|
||||
auto saveFile() -> string; //one file
|
||||
auto selectFolder() -> string; //one existing folder
|
||||
auto setFilters(const lstring& filters = {}) -> type&;
|
||||
auto openFile() -> string; //one existing file
|
||||
auto openFiles() -> string_vector; //any existing files or folders
|
||||
auto openFolder() -> string; //one existing folder
|
||||
auto saveFile() -> string; //one file
|
||||
auto selectFolder() -> string; //one existing folder
|
||||
auto setFilters(const string_vector& filters = {}) -> type&;
|
||||
auto setParent(const sWindow& parent) -> type&;
|
||||
auto setPath(const string& path = "") -> type&;
|
||||
auto setTitle(const string& title = "") -> type&;
|
||||
|
@ -19,14 +19,14 @@ struct BrowserDialog {
|
|||
private:
|
||||
struct State {
|
||||
string action;
|
||||
lstring filters = {"*"};
|
||||
string_vector filters = {"*"};
|
||||
sWindow parent;
|
||||
string path;
|
||||
lstring response;
|
||||
string_vector response;
|
||||
string title;
|
||||
} state;
|
||||
|
||||
auto _run() -> lstring;
|
||||
auto _run() -> string_vector;
|
||||
|
||||
friend class BrowserDialogWindow;
|
||||
};
|
||||
|
|
|
@ -4,19 +4,19 @@ MessageDialog::MessageDialog(const string& text) {
|
|||
state.text = text;
|
||||
}
|
||||
|
||||
auto MessageDialog::error(const lstring& buttons) -> string {
|
||||
auto MessageDialog::error(const string_vector& buttons) -> string {
|
||||
state.buttons = buttons;
|
||||
state.icon = Icon::Prompt::Error;
|
||||
return _run();
|
||||
}
|
||||
|
||||
auto MessageDialog::information(const lstring& buttons) -> string {
|
||||
auto MessageDialog::information(const string_vector& buttons) -> string {
|
||||
state.buttons = buttons;
|
||||
state.icon = Icon::Prompt::Information;
|
||||
return _run();
|
||||
}
|
||||
|
||||
auto MessageDialog::question(const lstring& buttons) -> string {
|
||||
auto MessageDialog::question(const string_vector& buttons) -> string {
|
||||
state.buttons = buttons;
|
||||
state.icon = Icon::Prompt::Question;
|
||||
return _run();
|
||||
|
@ -37,7 +37,7 @@ auto MessageDialog::setTitle(const string& title) -> type& {
|
|||
return *this;
|
||||
}
|
||||
|
||||
auto MessageDialog::warning(const lstring& buttons) -> string {
|
||||
auto MessageDialog::warning(const string_vector& buttons) -> string {
|
||||
state.buttons = buttons;
|
||||
state.icon = Icon::Prompt::Warning;
|
||||
return _run();
|
||||
|
|
|
@ -4,17 +4,17 @@ struct MessageDialog {
|
|||
using type = MessageDialog;
|
||||
|
||||
MessageDialog(const string& text = "");
|
||||
auto error(const lstring& buttons = {"Ok"}) -> string;
|
||||
auto information(const lstring& buttons = {"Ok"}) -> string;
|
||||
auto question(const lstring& buttons = {"Yes", "No"}) -> string;
|
||||
auto error(const string_vector& buttons = {"Ok"}) -> string;
|
||||
auto information(const string_vector& buttons = {"Ok"}) -> string;
|
||||
auto question(const string_vector& buttons = {"Yes", "No"}) -> string;
|
||||
auto setParent(sWindow parent = {}) -> type&;
|
||||
auto setText(const string& text = "") -> type&;
|
||||
auto setTitle(const string& title = "") -> type&;
|
||||
auto warning(const lstring& buttons = {"Ok"}) -> string;
|
||||
auto warning(const string_vector& buttons = {"Ok"}) -> string;
|
||||
|
||||
private:
|
||||
struct State {
|
||||
lstring buttons;
|
||||
string_vector buttons;
|
||||
vector<uint8_t> icon;
|
||||
sWindow parent;
|
||||
string response;
|
||||
|
|
|
@ -2,11 +2,11 @@
|
|||
|
||||
namespace hiro {
|
||||
|
||||
static auto BrowserWindow_addFilters(GtkWidget* dialog, lstring filters) -> void {
|
||||
static auto BrowserWindow_addFilters(GtkWidget* dialog, string_vector filters) -> void {
|
||||
for(auto& filter : filters) {
|
||||
GtkFileFilter* gtkFilter = gtk_file_filter_new();
|
||||
gtk_file_filter_set_name(gtkFilter, filter);
|
||||
lstring patterns = filter.split("(", 1L)(1).trimRight(")", 1L).split(",").strip();
|
||||
auto patterns = filter.split("(", 1L)(1).trimRight(")", 1L).split(",").strip();
|
||||
for(auto& pattern : patterns) gtk_file_filter_add_pattern(gtkFilter, pattern);
|
||||
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), gtkFilter);
|
||||
}
|
||||
|
|
|
@ -36,11 +36,11 @@ static auto CreateImage(const image& icon, bool scale = false) -> GtkImage* {
|
|||
return gtkIcon;
|
||||
}
|
||||
|
||||
static auto DropPaths(GtkSelectionData* data) -> lstring {
|
||||
static auto DropPaths(GtkSelectionData* data) -> string_vector {
|
||||
gchar** uris = gtk_selection_data_get_uris(data);
|
||||
if(uris == nullptr) return {};
|
||||
|
||||
lstring paths;
|
||||
string_vector paths;
|
||||
for(unsigned n = 0; uris[n] != nullptr; n++) {
|
||||
gchar* pathname = g_filename_from_uri(uris[n], nullptr, nullptr);
|
||||
if(pathname == nullptr) continue;
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace hiro {
|
|||
static auto Canvas_drop(GtkWidget* widget, GdkDragContext* context, signed x, signed y,
|
||||
GtkSelectionData* data, unsigned type, unsigned timestamp, pCanvas* p) -> void {
|
||||
if(!p->state().droppable) return;
|
||||
lstring paths = DropPaths(data);
|
||||
auto paths = DropPaths(data);
|
||||
if(!paths) return;
|
||||
p->self().doDrop(paths);
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ struct pConsole : pWidget {
|
|||
GtkWidget* subWidget = nullptr;
|
||||
GtkTextBuffer* textBuffer = nullptr;
|
||||
string previousPrompt;
|
||||
lstring history;
|
||||
string_vector history;
|
||||
unsigned historyOffset = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -193,7 +193,7 @@ auto pIconView::_updateSelected() -> void {
|
|||
while(p) {
|
||||
auto path = (GtkTreePath*)p->data;
|
||||
char* pathString = gtk_tree_path_to_string(path);
|
||||
unsigned position = natural(pathString);
|
||||
unsigned position = toNatural(pathString);
|
||||
g_free(pathString);
|
||||
selected.append(position);
|
||||
p = p->next;
|
||||
|
|
|
@ -218,7 +218,7 @@ auto pTableView::_doContext() -> void {
|
|||
|
||||
auto pTableView::_doDataFunc(GtkTreeViewColumn* gtkColumn, GtkCellRenderer* renderer, GtkTreeIter* iter) -> void {
|
||||
auto path = gtk_tree_model_get_string_from_iter(gtkTreeModel, iter);
|
||||
auto row = natural(path);
|
||||
auto row = toNatural(path);
|
||||
g_free(path);
|
||||
|
||||
if(auto& header = state().header) {
|
||||
|
@ -271,7 +271,7 @@ auto pTableView::_doEdit(GtkCellRendererText* gtkCellRendererText, const char* p
|
|||
for(auto& column : header->state.columns) {
|
||||
if(auto delegate = column->self()) {
|
||||
if(gtkCellRendererText == GTK_CELL_RENDERER_TEXT(delegate->gtkCellText)) {
|
||||
auto row = natural(path);
|
||||
auto row = toNatural(path);
|
||||
if(auto item = self().item(row)) {
|
||||
if(auto cell = item->cell(column->offset())) {
|
||||
if(string{text} != cell->state.text) {
|
||||
|
@ -343,7 +343,7 @@ auto pTableView::_doToggle(GtkCellRendererToggle* gtkCellRendererToggle, const c
|
|||
for(auto& column : header->state.columns) {
|
||||
if(auto delegate = column->self()) {
|
||||
if(gtkCellRendererToggle == GTK_CELL_RENDERER_TOGGLE(delegate->gtkCellToggle)) {
|
||||
auto row = natural(path);
|
||||
auto row = toNatural(path);
|
||||
if(auto item = self().item(row)) {
|
||||
if(auto cell = item->cell(column->offset())) {
|
||||
cell->setChecked(!cell->checked());
|
||||
|
@ -371,7 +371,7 @@ auto pTableView::_updateSelected() -> void {
|
|||
GtkTreeIter iter;
|
||||
if(gtk_tree_model_get_iter(gtkTreeModel, &iter, (GtkTreePath*)p->data)) {
|
||||
char* pathname = gtk_tree_model_get_string_from_iter(gtkTreeModel, &iter);
|
||||
unsigned selection = natural(pathname);
|
||||
unsigned selection = toNatural(pathname);
|
||||
g_free(pathname);
|
||||
selected.append(selection);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ namespace hiro {
|
|||
static auto Viewport_dropEvent(GtkWidget* widget, GdkDragContext* context, signed x, signed y,
|
||||
GtkSelectionData* data, unsigned type, unsigned timestamp, pViewport* p) -> void {
|
||||
if(!p->state().droppable) return;
|
||||
lstring paths = DropPaths(data);
|
||||
auto paths = DropPaths(data);
|
||||
if(!paths) return;
|
||||
p->self().doDrop(paths);
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ static auto Window_configure(GtkWidget* widget, GdkEvent* event, pWindow* p) ->
|
|||
static auto Window_drop(GtkWidget* widget, GdkDragContext* context, signed x, signed y,
|
||||
GtkSelectionData* data, unsigned type, unsigned timestamp, pWindow* p) -> void {
|
||||
if(!p->state().droppable) return;
|
||||
lstring paths = DropPaths(data);
|
||||
auto paths = DropPaths(data);
|
||||
if(!paths) return;
|
||||
p->self().doDrop(paths);
|
||||
}
|
||||
|
|
|
@ -24,11 +24,11 @@ static auto CreateIcon(const image& icon, bool scale = false) -> QIcon {
|
|||
return QIcon(QPixmap::fromImage(qtImage));
|
||||
}
|
||||
|
||||
static auto DropPaths(QDropEvent* event) -> lstring {
|
||||
static auto DropPaths(QDropEvent* event) -> string_vector {
|
||||
QList<QUrl> urls = event->mimeData()->urls();
|
||||
if(urls.size() == 0) return {};
|
||||
|
||||
lstring paths;
|
||||
string_vector paths;
|
||||
for(auto n : range(urls.size())) {
|
||||
string path{urls[n].path().toUtf8().constData()};
|
||||
if(!path) continue;
|
||||
|
|
|
@ -33,7 +33,7 @@ void pListView::setCheckedNone() {
|
|||
void pListView::setForegroundColor(Color color) {
|
||||
}
|
||||
|
||||
void pListView::setHeaderText(const lstring& text) {
|
||||
void pListView::setHeaderText(const string_vector& text) {
|
||||
}
|
||||
|
||||
void pListView::setHeaderVisible(bool visible) {
|
||||
|
|
|
@ -19,7 +19,7 @@ static auto BrowserWindow_fileDialog(bool save, BrowserWindow::State& state) ->
|
|||
|
||||
string filters;
|
||||
for(auto& filter : state.filters) {
|
||||
lstring part = filter.split("(");
|
||||
auto part = filter.split("(");
|
||||
if(part.size() != 2) continue;
|
||||
part[1].trimRight(")", 1L);
|
||||
part[1].replace(" ", "");
|
||||
|
|
|
@ -38,11 +38,11 @@ static auto CreateRGB(const Color& color) -> COLORREF {
|
|||
return RGB(color.red(), color.green(), color.blue());
|
||||
}
|
||||
|
||||
static auto DropPaths(WPARAM wparam) -> lstring {
|
||||
static auto DropPaths(WPARAM wparam) -> string_vector {
|
||||
auto dropList = HDROP(wparam);
|
||||
auto fileCount = DragQueryFile(dropList, ~0u, nullptr, 0);
|
||||
|
||||
lstring paths;
|
||||
string_vector paths;
|
||||
for(auto n : range(fileCount)) {
|
||||
auto length = DragQueryFile(dropList, n, nullptr, 0);
|
||||
auto buffer = new wchar_t[length + 1];
|
||||
|
|
|
@ -17,7 +17,7 @@ auto pLabel::destruct() -> void {
|
|||
}
|
||||
|
||||
auto pLabel::minimumSize() const -> Size {
|
||||
auto size = pFont::size(hfont, state().text);
|
||||
auto size = pFont::size(self().font(true), state().text ? state().text : " ");
|
||||
return {size.width(), size.height()};
|
||||
}
|
||||
|
||||
|
|
|
@ -176,7 +176,7 @@ auto pWindow::onClose() -> void {
|
|||
}
|
||||
|
||||
auto pWindow::onDrop(WPARAM wparam) -> void {
|
||||
lstring paths = DropPaths(wparam);
|
||||
auto paths = DropPaths(wparam);
|
||||
if(paths) self().doDrop(paths);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue