updated to v099r13 release
This commit is contained in:
parent
da448cdfc6
commit
127fa784cc
120 changed files with 2732 additions and 2042 deletions
|
@ -26,8 +26,8 @@ auto pBrowserWindow::open(BrowserWindow::State& state) -> string {
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
NSMutableArray* filters = [[NSMutableArray alloc] init];
|
NSMutableArray* filters = [[NSMutableArray alloc] init];
|
||||||
for(auto& rule : state.filters) {
|
for(auto& rule : state.filters) {
|
||||||
string pattern = rule.split("(", 1L)(1).rtrim(")", 1L);
|
string pattern = rule.split("(", 1L)(1).trimRight(")", 1L);
|
||||||
if(!pattern.empty()) [filters addObject:[NSString stringWithUTF8String:pattern]];
|
if(pattern) [filters addObject:[NSString stringWithUTF8String:pattern]];
|
||||||
}
|
}
|
||||||
NSOpenPanel* panel = [NSOpenPanel openPanel];
|
NSOpenPanel* panel = [NSOpenPanel openPanel];
|
||||||
if(state.title) [panel setTitle:[NSString stringWithUTF8String:state.title]];
|
if(state.title) [panel setTitle:[NSString stringWithUTF8String:state.title]];
|
||||||
|
@ -51,8 +51,8 @@ auto pBrowserWindow::save(BrowserWindow::State& state) -> string {
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
NSMutableArray* filters = [[NSMutableArray alloc] init];
|
NSMutableArray* filters = [[NSMutableArray alloc] init];
|
||||||
for(auto& rule : state.filters) {
|
for(auto& rule : state.filters) {
|
||||||
string pattern = rule.split("(", 1L)(1).rtrim(")", 1L);
|
string pattern = rule.split("(", 1L)(1).trimRight(")", 1L);
|
||||||
if(!pattern.empty()) [filters addObject:[NSString stringWithUTF8String:pattern]];
|
if(pattern) [filters addObject:[NSString stringWithUTF8String:pattern]];
|
||||||
}
|
}
|
||||||
NSSavePanel* panel = [NSSavePanel savePanel];
|
NSSavePanel* panel = [NSSavePanel savePanel];
|
||||||
if(state.title) [panel setTitle:[NSString stringWithUTF8String:state.title]];
|
if(state.title) [panel setTitle:[NSString stringWithUTF8String:state.title]];
|
||||||
|
|
|
@ -1,6 +1,22 @@
|
||||||
#define decimal CocoaDecimal
|
#define decimal decimal_cocoa
|
||||||
|
#define int8 int8_cocoa
|
||||||
|
#define int16 int16_cocoa
|
||||||
|
#define int32 int32_cocoa
|
||||||
|
#define int64 int64_cocoa
|
||||||
|
#define uint8 uint8_cocoa
|
||||||
|
#define uint16 uint16_cocoa
|
||||||
|
#define uint32 uint32_cocoa
|
||||||
|
#define uint64 uint64_cocoa
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
#import <Carbon/Carbon.h>
|
#import <Carbon/Carbon.h>
|
||||||
#undef decimal
|
#undef decimal
|
||||||
|
#undef int8
|
||||||
|
#undef int16
|
||||||
|
#undef int32
|
||||||
|
#undef int64
|
||||||
|
#undef uint8
|
||||||
|
#undef uint16
|
||||||
|
#undef uint32
|
||||||
|
#undef uint64
|
||||||
|
|
||||||
#include <nall/run.hpp>
|
#include <nall/run.hpp>
|
||||||
|
|
|
@ -42,16 +42,16 @@
|
||||||
#include "widget/horizontal-slider.cpp"
|
#include "widget/horizontal-slider.cpp"
|
||||||
#include "widget/label.cpp"
|
#include "widget/label.cpp"
|
||||||
#include "widget/line-edit.cpp"
|
#include "widget/line-edit.cpp"
|
||||||
#include "widget/list-view.cpp"
|
|
||||||
#include "widget/list-view-header.cpp"
|
|
||||||
#include "widget/list-view-column.cpp"
|
|
||||||
#include "widget/list-view-item.cpp"
|
|
||||||
#include "widget/list-view-cell.cpp"
|
|
||||||
#include "widget/progress-bar.cpp"
|
#include "widget/progress-bar.cpp"
|
||||||
#include "widget/radio-button.cpp"
|
#include "widget/radio-button.cpp"
|
||||||
#include "widget/radio-label.cpp"
|
#include "widget/radio-label.cpp"
|
||||||
#include "widget/tab-frame.cpp"
|
#include "widget/tab-frame.cpp"
|
||||||
#include "widget/tab-frame-item.cpp"
|
#include "widget/tab-frame-item.cpp"
|
||||||
|
#include "widget/table-view.cpp"
|
||||||
|
#include "widget/table-view-header.cpp"
|
||||||
|
#include "widget/table-view-column.cpp"
|
||||||
|
#include "widget/table-view-item.cpp"
|
||||||
|
#include "widget/table-view-cell.cpp"
|
||||||
#include "widget/text-edit.cpp"
|
#include "widget/text-edit.cpp"
|
||||||
#include "widget/vertical-scroll-bar.cpp"
|
#include "widget/vertical-scroll-bar.cpp"
|
||||||
#include "widget/vertical-slider.cpp"
|
#include "widget/vertical-slider.cpp"
|
||||||
|
|
|
@ -54,16 +54,16 @@ namespace hiro {
|
||||||
#include "widget/horizontal-slider.hpp"
|
#include "widget/horizontal-slider.hpp"
|
||||||
#include "widget/label.hpp"
|
#include "widget/label.hpp"
|
||||||
#include "widget/line-edit.hpp"
|
#include "widget/line-edit.hpp"
|
||||||
#include "widget/list-view.hpp"
|
|
||||||
#include "widget/list-view-header.hpp"
|
|
||||||
#include "widget/list-view-column.hpp"
|
|
||||||
#include "widget/list-view-item.hpp"
|
|
||||||
#include "widget/list-view-cell.hpp"
|
|
||||||
#include "widget/progress-bar.hpp"
|
#include "widget/progress-bar.hpp"
|
||||||
#include "widget/radio-button.hpp"
|
#include "widget/radio-button.hpp"
|
||||||
#include "widget/radio-label.hpp"
|
#include "widget/radio-label.hpp"
|
||||||
#include "widget/tab-frame.hpp"
|
#include "widget/tab-frame.hpp"
|
||||||
#include "widget/tab-frame-item.hpp"
|
#include "widget/tab-frame-item.hpp"
|
||||||
|
#include "widget/table-view.hpp"
|
||||||
|
#include "widget/table-view-header.hpp"
|
||||||
|
#include "widget/table-view-column.hpp"
|
||||||
|
#include "widget/table-view-item.hpp"
|
||||||
|
#include "widget/table-view-cell.hpp"
|
||||||
#include "widget/text-edit.hpp"
|
#include "widget/text-edit.hpp"
|
||||||
#include "widget/vertical-scroll-bar.hpp"
|
#include "widget/vertical-scroll-bar.hpp"
|
||||||
#include "widget/vertical-slider.hpp"
|
#include "widget/vertical-slider.hpp"
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
|
|
||||||
-(BOOL) performDragOperation:(id<NSDraggingInfo>)sender {
|
-(BOOL) performDragOperation:(id<NSDraggingInfo>)sender {
|
||||||
lstring paths = DropPaths(sender);
|
lstring paths = DropPaths(sender);
|
||||||
if(paths.empty()) return NO;
|
if(!paths) return NO;
|
||||||
canvas->doDrop(paths);
|
canvas->doDrop(paths);
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,50 +0,0 @@
|
||||||
#if defined(Hiro_ListView)
|
|
||||||
|
|
||||||
namespace hiro {
|
|
||||||
|
|
||||||
auto pListViewCell::construct() -> void {
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewCell::destruct() -> void {
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewCell::setAlignment(Alignment alignment) -> void {
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewCell::setBackgroundColor(Color color) -> void {
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewCell::setCheckable(bool checkable) -> void {
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewCell::setChecked(bool checked) -> void {
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewCell::setForegroundColor(Color color) -> void {
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewCell::setIcon(const image& icon) -> void {
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewCell::setText(const string& text) -> void {
|
|
||||||
@autoreleasepool {
|
|
||||||
if(auto pListView = _grandparent()) {
|
|
||||||
[[pListView->cocoaView content] reloadData];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewCell::_grandparent() -> maybe<pListView&> {
|
|
||||||
if(auto parent = _parent()) return parent->_parent();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewCell::_parent() -> maybe<pListViewItem&> {
|
|
||||||
if(auto parent = self().parentListViewItem()) {
|
|
||||||
if(auto self = parent->self()) return *self;
|
|
||||||
}
|
|
||||||
return nothing;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,87 +0,0 @@
|
||||||
#if defined(Hiro_ListView)
|
|
||||||
|
|
||||||
namespace hiro {
|
|
||||||
|
|
||||||
auto pListViewColumn::construct() -> void {
|
|
||||||
@autoreleasepool {
|
|
||||||
if(auto listView = _grandparent()) {
|
|
||||||
[listView->cocoaView reloadColumns];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewColumn::destruct() -> void {
|
|
||||||
@autoreleasepool {
|
|
||||||
if(auto listView = _grandparent()) {
|
|
||||||
[listView->cocoaView reloadColumns];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewColumn::setActive() -> void {
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewColumn::setAlignment(Alignment alignment) -> void {
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewColumn::setBackgroundColor(Color color) -> void {
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewColumn::setEditable(bool editable) -> void {
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewColumn::setExpandable(bool expandable) -> void {
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewColumn::setFont(const Font& font) -> void {
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewColumn::setForegroundColor(Color color) -> void {
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewColumn::setHorizontalAlignment(double alignment) -> void {
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewColumn::setIcon(const image& icon) -> void {
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewColumn::setResizable(bool resizable) -> void {
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewColumn::setSortable(bool sortable) -> void {
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewColumn::setText(const string& text) -> void {
|
|
||||||
@autoreleasepool {
|
|
||||||
if(auto pListView = _grandparent()) {
|
|
||||||
NSTableColumn* tableColumn = [[pListView->cocoaView content] tableColumnWithIdentifier:[[NSNumber numberWithInteger:self().offset()] stringValue]];
|
|
||||||
[[tableColumn headerCell] setStringValue:[NSString stringWithUTF8STring:text]];
|
|
||||||
[[pListView->cocoaView headerView] setNeedsDisplay:YES];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewColumn::setVerticalAlignment(double alignment) -> void {
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewColumn::setVisible(bool visible) -> void {
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewColumn::setWidth(signed width) -> void {
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewColumn::_grandparent() -> maybe<pListView&> {
|
|
||||||
if(auto parent = _parent()) return parent->_parent();
|
|
||||||
return nothing;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewColumn::_parent() -> maybe<pListViewHeader&> {
|
|
||||||
if(auto parent = self().parentListViewHeader()) {
|
|
||||||
if(auto self = parent->self()) return *self;
|
|
||||||
}
|
|
||||||
return nothing;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,38 +0,0 @@
|
||||||
#if defined(Hiro_ListView)
|
|
||||||
|
|
||||||
namespace hiro {
|
|
||||||
|
|
||||||
auto pListViewHeader::construct() -> void {
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewHeader::destruct() -> void {
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewHeader::append(sListViewColumn column) -> void {
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewHeader::remove(sListViewColumn column) -> void {
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewHeader::setVisible(bool visible) -> void {
|
|
||||||
@autoreleasepool {
|
|
||||||
if(auto pListView = _parent()) {
|
|
||||||
if(visible) {
|
|
||||||
[[pListView->cocoaView content] setHeaderView:[[[NSTableHeaderView alloc] init] autorelease]];
|
|
||||||
} else {
|
|
||||||
[[pListView->cocoaView content] setHeaderView:nil];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewHeader::_parent() -> maybe<pListView&> {
|
|
||||||
if(auto parent = self().parentListView()) {
|
|
||||||
if(auto self = parent->self()) return *self;
|
|
||||||
}
|
|
||||||
return nothing;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,17 +0,0 @@
|
||||||
#if defined(Hiro_ListView)
|
|
||||||
|
|
||||||
namespace hiro {
|
|
||||||
|
|
||||||
struct pListViewHeader : pObject {
|
|
||||||
Declare(ListViewHeader, Object)
|
|
||||||
|
|
||||||
auto append(sListViewColumn column) -> void;
|
|
||||||
auto remove(sListViewColumn column) -> void;
|
|
||||||
auto setVisible(bool visible) -> void override;
|
|
||||||
|
|
||||||
auto _parent() -> maybe<pListView&>;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,51 +0,0 @@
|
||||||
#if defined(Hiro_ListView)
|
|
||||||
|
|
||||||
namespace hiro {
|
|
||||||
|
|
||||||
auto pListViewItem::construct() -> void {
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewItem::destruct() -> void {
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewItem::append(sListViewCell cell) -> void {
|
|
||||||
@autoreleasepool {
|
|
||||||
if(auto listView = _parent()) {
|
|
||||||
[[listView->cocoaView content] reloadData];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewItem::remove(sListViewCell cell) -> void {
|
|
||||||
@autoreleasepool {
|
|
||||||
if(auto listView = _parent()) {
|
|
||||||
[[listView->cocoaView content] reloadData];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewItem::setAlignment(Alignment alignment) -> void {
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewItem::setBackgroundColor(Color color) -> void {
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewItem::setFocused() -> void {
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewItem::setForegroundColor(Color color) -> void {
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewItem::setSelected(bool selected) -> void {
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewItem::_parent() -> maybe<pListView&> {
|
|
||||||
if(auto parent = self().parentListView()) {
|
|
||||||
if(auto self = parent->self()) return *self;
|
|
||||||
}
|
|
||||||
return nothing;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
50
cocoa/widget/table-view-cell.cpp
Normal file
50
cocoa/widget/table-view-cell.cpp
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
#if defined(Hiro_TableView)
|
||||||
|
|
||||||
|
namespace hiro {
|
||||||
|
|
||||||
|
auto pTableViewCell::construct() -> void {
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewCell::destruct() -> void {
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewCell::setAlignment(Alignment alignment) -> void {
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewCell::setBackgroundColor(Color color) -> void {
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewCell::setCheckable(bool checkable) -> void {
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewCell::setChecked(bool checked) -> void {
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewCell::setForegroundColor(Color color) -> void {
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewCell::setIcon(const image& icon) -> void {
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewCell::setText(const string& text) -> void {
|
||||||
|
@autoreleasepool {
|
||||||
|
if(auto pTableView = _grandparent()) {
|
||||||
|
[[pTableView->cocoaView content] reloadData];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewCell::_grandparent() -> maybe<pTableView&> {
|
||||||
|
if(auto parent = _parent()) return parent->_parent();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewCell::_parent() -> maybe<pTableViewItem&> {
|
||||||
|
if(auto parent = self().parentTableViewItem()) {
|
||||||
|
if(auto self = parent->self()) return *self;
|
||||||
|
}
|
||||||
|
return nothing;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,9 +1,9 @@
|
||||||
#if defined(Hiro_ListView)
|
#if defined(Hiro_TableView)
|
||||||
|
|
||||||
namespace hiro {
|
namespace hiro {
|
||||||
|
|
||||||
struct pListViewCell : pObject {
|
struct pTableViewCell : pObject {
|
||||||
Declare(ListViewCell, Object)
|
Declare(TableViewCell, Object)
|
||||||
|
|
||||||
auto setAlignment(Alignment alignment) -> void;
|
auto setAlignment(Alignment alignment) -> void;
|
||||||
auto setBackgroundColor(Color color) -> void;
|
auto setBackgroundColor(Color color) -> void;
|
||||||
|
@ -13,8 +13,8 @@ struct pListViewCell : pObject {
|
||||||
auto setIcon(const image& icon) -> void;
|
auto setIcon(const image& icon) -> void;
|
||||||
auto setText(const string& text) -> void;
|
auto setText(const string& text) -> void;
|
||||||
|
|
||||||
auto _grandparent() -> maybe<pListView&>;
|
auto _grandparent() -> maybe<pTableView&>;
|
||||||
auto _parent() -> maybe<pListViewItem&>;
|
auto _parent() -> maybe<pTableViewItem&>;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
87
cocoa/widget/table-view-column.cpp
Normal file
87
cocoa/widget/table-view-column.cpp
Normal file
|
@ -0,0 +1,87 @@
|
||||||
|
#if defined(Hiro_TableView)
|
||||||
|
|
||||||
|
namespace hiro {
|
||||||
|
|
||||||
|
auto pTableViewColumn::construct() -> void {
|
||||||
|
@autoreleasepool {
|
||||||
|
if(auto tableView = _grandparent()) {
|
||||||
|
[tableView->cocoaView reloadColumns];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewColumn::destruct() -> void {
|
||||||
|
@autoreleasepool {
|
||||||
|
if(auto tableView = _grandparent()) {
|
||||||
|
[tableView->cocoaView reloadColumns];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewColumn::setActive() -> void {
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewColumn::setAlignment(Alignment alignment) -> void {
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewColumn::setBackgroundColor(Color color) -> void {
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewColumn::setEditable(bool editable) -> void {
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewColumn::setExpandable(bool expandable) -> void {
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewColumn::setFont(const Font& font) -> void {
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewColumn::setForegroundColor(Color color) -> void {
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewColumn::setHorizontalAlignment(double alignment) -> void {
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewColumn::setIcon(const image& icon) -> void {
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewColumn::setResizable(bool resizable) -> void {
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewColumn::setSortable(bool sortable) -> void {
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewColumn::setText(const string& text) -> void {
|
||||||
|
@autoreleasepool {
|
||||||
|
if(auto pTableView = _grandparent()) {
|
||||||
|
NSTableColumn* tableColumn = [[pTableView->cocoaView content] tableColumnWithIdentifier:[[NSNumber numberWithInteger:self().offset()] stringValue]];
|
||||||
|
[[tableColumn headerCell] setStringValue:[NSString stringWithUTF8STring:text]];
|
||||||
|
[[pTableView->cocoaView headerView] setNeedsDisplay:YES];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewColumn::setVerticalAlignment(double alignment) -> void {
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewColumn::setVisible(bool visible) -> void {
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewColumn::setWidth(signed width) -> void {
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewColumn::_grandparent() -> maybe<pTableView&> {
|
||||||
|
if(auto parent = _parent()) return parent->_parent();
|
||||||
|
return nothing;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewColumn::_parent() -> maybe<pTableViewHeader&> {
|
||||||
|
if(auto parent = self().parentTableViewHeader()) {
|
||||||
|
if(auto self = parent->self()) return *self;
|
||||||
|
}
|
||||||
|
return nothing;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,9 +1,9 @@
|
||||||
#if defined(Hiro_ListView)
|
#if defined(Hiro_TableView)
|
||||||
|
|
||||||
namespace hiro {
|
namespace hiro {
|
||||||
|
|
||||||
struct pListViewColumn : pObject {
|
struct pTableViewColumn : pObject {
|
||||||
Declare(ListViewColumn, Object)
|
Declare(TableViewColumn, Object)
|
||||||
|
|
||||||
auto setActive() -> void;
|
auto setActive() -> void;
|
||||||
auto setAlignment(Alignment alignment) -> void;
|
auto setAlignment(Alignment alignment) -> void;
|
||||||
|
@ -21,8 +21,8 @@ struct pListViewColumn : pObject {
|
||||||
auto setVisible(bool visible) -> void override;
|
auto setVisible(bool visible) -> void override;
|
||||||
auto setWidth(signed width) -> void;
|
auto setWidth(signed width) -> void;
|
||||||
|
|
||||||
auto _grandparent() -> maybe<pListView&>;
|
auto _grandparent() -> maybe<pTableView&>;
|
||||||
auto _parent() -> maybe<pListViewHeader&>;
|
auto _parent() -> maybe<pTableViewHeader&>;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
38
cocoa/widget/table-view-header.cpp
Normal file
38
cocoa/widget/table-view-header.cpp
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
#if defined(Hiro_TableView)
|
||||||
|
|
||||||
|
namespace hiro {
|
||||||
|
|
||||||
|
auto pTableViewHeader::construct() -> void {
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewHeader::destruct() -> void {
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewHeader::append(sTableViewColumn column) -> void {
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewHeader::remove(sTableViewColumn column) -> void {
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewHeader::setVisible(bool visible) -> void {
|
||||||
|
@autoreleasepool {
|
||||||
|
if(auto pTableView = _parent()) {
|
||||||
|
if(visible) {
|
||||||
|
[[pTableView->cocoaView content] setHeaderView:[[[NSTableHeaderView alloc] init] autorelease]];
|
||||||
|
} else {
|
||||||
|
[[pTableView->cocoaView content] setHeaderView:nil];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewHeader::_parent() -> maybe<pTableView&> {
|
||||||
|
if(auto parent = self().parentTableView()) {
|
||||||
|
if(auto self = parent->self()) return *self;
|
||||||
|
}
|
||||||
|
return nothing;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
17
cocoa/widget/table-view-header.hpp
Normal file
17
cocoa/widget/table-view-header.hpp
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
#if defined(Hiro_TableView)
|
||||||
|
|
||||||
|
namespace hiro {
|
||||||
|
|
||||||
|
struct pTableViewHeader : pObject {
|
||||||
|
Declare(TableViewHeader, Object)
|
||||||
|
|
||||||
|
auto append(sTableViewColumn column) -> void;
|
||||||
|
auto remove(sTableViewColumn column) -> void;
|
||||||
|
auto setVisible(bool visible) -> void override;
|
||||||
|
|
||||||
|
auto _parent() -> maybe<pTableView&>;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
51
cocoa/widget/table-view-item.cpp
Normal file
51
cocoa/widget/table-view-item.cpp
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
#if defined(Hiro_TableView)
|
||||||
|
|
||||||
|
namespace hiro {
|
||||||
|
|
||||||
|
auto pTableViewItem::construct() -> void {
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewItem::destruct() -> void {
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewItem::append(sTableViewCell cell) -> void {
|
||||||
|
@autoreleasepool {
|
||||||
|
if(auto tableView = _parent()) {
|
||||||
|
[[tableView->cocoaView content] reloadData];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewItem::remove(sTableViewCell cell) -> void {
|
||||||
|
@autoreleasepool {
|
||||||
|
if(auto tableView = _parent()) {
|
||||||
|
[[tableView->cocoaView content] reloadData];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewItem::setAlignment(Alignment alignment) -> void {
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewItem::setBackgroundColor(Color color) -> void {
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewItem::setFocused() -> void {
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewItem::setForegroundColor(Color color) -> void {
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewItem::setSelected(bool selected) -> void {
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewItem::_parent() -> maybe<pTableView&> {
|
||||||
|
if(auto parent = self().parentTableView()) {
|
||||||
|
if(auto self = parent->self()) return *self;
|
||||||
|
}
|
||||||
|
return nothing;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,19 +1,19 @@
|
||||||
#if defined(Hiro_ListView)
|
#if defined(Hiro_TableView)
|
||||||
|
|
||||||
namespace hiro {
|
namespace hiro {
|
||||||
|
|
||||||
struct pListViewItem : pObject {
|
struct pTableViewItem : pObject {
|
||||||
Declare(ListViewItem, Object)
|
Declare(TableViewItem, Object)
|
||||||
|
|
||||||
auto append(sListViewCell cell) -> void;
|
auto append(sTableViewCell cell) -> void;
|
||||||
auto remove(sListViewCell cell) -> void;
|
auto remove(sTableViewCell cell) -> void;
|
||||||
auto setAlignment(Alignment alignment) -> void;
|
auto setAlignment(Alignment alignment) -> void;
|
||||||
auto setBackgroundColor(Color color) -> void;
|
auto setBackgroundColor(Color color) -> void;
|
||||||
auto setFocused() -> void;
|
auto setFocused() -> void;
|
||||||
auto setForegroundColor(Color color) -> void;
|
auto setForegroundColor(Color color) -> void;
|
||||||
auto setSelected(bool selected) -> void;
|
auto setSelected(bool selected) -> void;
|
||||||
|
|
||||||
auto _parent() -> maybe<pListView&>;
|
auto _parent() -> maybe<pTableView&>;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,11 +1,11 @@
|
||||||
#if defined(Hiro_ListView)
|
#if defined(Hiro_TableView)
|
||||||
|
|
||||||
@implementation CocoaListView : NSScrollView
|
@implementation CocoaTableView : NSScrollView
|
||||||
|
|
||||||
-(id) initWith:(hiro::mListView&)listViewReference {
|
-(id) initWith:(hiro::mTableView&)tableViewReference {
|
||||||
if(self = [super initWithFrame:NSMakeRect(0, 0, 0, 0)]) {
|
if(self = [super initWithFrame:NSMakeRect(0, 0, 0, 0)]) {
|
||||||
listView = &listViewReference;
|
tableView = &tableViewReference;
|
||||||
content = [[CocoaListViewContent alloc] initWithFrame:NSMakeRect(0, 0, 0, 0)];
|
content = [[CocoaTableViewContent alloc] initWithFrame:NSMakeRect(0, 0, 0, 0)];
|
||||||
|
|
||||||
[self setDocumentView:content];
|
[self setDocumentView:content];
|
||||||
[self setBorderType:NSBezelBorder];
|
[self setBorderType:NSBezelBorder];
|
||||||
|
@ -34,7 +34,7 @@
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(CocoaListViewContent*) content {
|
-(CocoaTableViewContent*) content {
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,13 +59,13 @@
|
||||||
[content removeTableColumn:[[content tableColumns] lastObject]];
|
[content removeTableColumn:[[content tableColumns] lastObject]];
|
||||||
}
|
}
|
||||||
|
|
||||||
if(auto listViewHeader = listView->state.header) {
|
if(auto tableViewHeader = tableView->state.header) {
|
||||||
for(auto& listViewColumn : listViewHeader->state.columns) {
|
for(auto& tableViewColumn : tableViewHeader->state.columns) {
|
||||||
auto column = listViewColumn->offset();
|
auto column = tableViewColumn->offset();
|
||||||
|
|
||||||
NSTableColumn* tableColumn = [[NSTableColumn alloc] initWithIdentifier:[[NSNumber numberWithInteger:column] stringValue]];
|
NSTableColumn* tableColumn = [[NSTableColumn alloc] initWithIdentifier:[[NSNumber numberWithInteger:column] stringValue]];
|
||||||
NSTableHeaderCell* headerCell = [[NSTableHeaderCell alloc] initTextCell:[NSString stringWithUTF8String:listViewColumn->state.text]];
|
NSTableHeaderCell* headerCell = [[NSTableHeaderCell alloc] initTextCell:[NSString stringWithUTF8String:tableViewColumn->state.text]];
|
||||||
CocoaListViewCell* dataCell = [[CocoaListViewCell alloc] initWith:*listView];
|
CocoaTableViewCell* dataCell = [[CocoaTableViewCell alloc] initWith:*tableView];
|
||||||
|
|
||||||
[dataCell setEditable:NO];
|
[dataCell setEditable:NO];
|
||||||
|
|
||||||
|
@ -79,13 +79,13 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
-(NSInteger) numberOfRowsInTableView:(NSTableView*)table {
|
-(NSInteger) numberOfRowsInTableView:(NSTableView*)table {
|
||||||
return listView->state.items.size();
|
return tableView->state.items.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
-(id) tableView:(NSTableView*)table objectValueForTableColumn:(NSTableColumn*)tableColumn row:(NSInteger)row {
|
-(id) tableView:(NSTableView*)table objectValueForTableColumn:(NSTableColumn*)tableColumn row:(NSInteger)row {
|
||||||
if(auto listViewItem = listView->item(row)) {
|
if(auto tableViewItem = tableView->item(row)) {
|
||||||
if(auto listViewCell = listViewItem->cell([[tableColumn identifier] integerValue])) {
|
if(auto tableViewCell = tableViewItem->cell([[tableColumn identifier] integerValue])) {
|
||||||
NSString* text = [NSString stringWithUTF8String:listViewCell->state.text];
|
NSString* text = [NSString stringWithUTF8String:tableViewCell->state.text];
|
||||||
return @{ @"text":text }; //used by type-ahead
|
return @{ @"text":text }; //used by type-ahead
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,14 +105,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void) tableViewSelectionDidChange:(NSNotification*)notification {
|
-(void) tableViewSelectionDidChange:(NSNotification*)notification {
|
||||||
for(auto& listViewItem : listView->state.items) {
|
for(auto& tableViewItem : tableView->state.items) {
|
||||||
listViewItem->state.selected = listViewItem->offset() == [content selectedRow];
|
tableViewItem->state.selected = tableViewItem->offset() == [content selectedRow];
|
||||||
}
|
}
|
||||||
listView->doChange();
|
tableView->doChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) activate:(id)sender {
|
-(IBAction) activate:(id)sender {
|
||||||
listView->doActivate();
|
tableView->doActivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
-(IBAction) doubleAction:(id)sender {
|
-(IBAction) doubleAction:(id)sender {
|
||||||
|
@ -123,7 +123,7 @@
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation CocoaListViewContent : NSTableView
|
@implementation CocoaTableViewContent : NSTableView
|
||||||
|
|
||||||
-(void) keyDown:(NSEvent*)event {
|
-(void) keyDown:(NSEvent*)event {
|
||||||
auto character = [[event characters] characterAtIndex:0];
|
auto character = [[event characters] characterAtIndex:0];
|
||||||
|
@ -139,11 +139,11 @@
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation CocoaListViewCell : NSCell
|
@implementation CocoaTableViewCell : NSCell
|
||||||
|
|
||||||
-(id) initWith:(hiro::mListView&)listViewReference {
|
-(id) initWith:(hiro::mTableView&)tableViewReference {
|
||||||
if(self = [super initTextCell:@""]) {
|
if(self = [super initTextCell:@""]) {
|
||||||
listView = &listViewReference;
|
tableView = &tableViewReference;
|
||||||
buttonCell = [[NSButtonCell alloc] initTextCell:@""];
|
buttonCell = [[NSButtonCell alloc] initTextCell:@""];
|
||||||
[buttonCell setButtonType:NSSwitchButton];
|
[buttonCell setButtonType:NSSwitchButton];
|
||||||
[buttonCell setControlSize:NSSmallControlSize];
|
[buttonCell setControlSize:NSSmallControlSize];
|
||||||
|
@ -159,27 +159,27 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void) drawWithFrame:(NSRect)frame inView:(NSView*)view {
|
-(void) drawWithFrame:(NSRect)frame inView:(NSView*)view {
|
||||||
if(auto listViewItem = listView->item([view rowAtPoint:frame.origin])) {
|
if(auto tableViewItem = tableView->item([view rowAtPoint:frame.origin])) {
|
||||||
if(auto listViewCell = listViewItem->cell([view columnAtPoint:frame.origin])) {
|
if(auto tableViewCell = tableViewItem->cell([view columnAtPoint:frame.origin])) {
|
||||||
NSColor* backgroundColor = nil;
|
NSColor* backgroundColor = nil;
|
||||||
if([self isHighlighted]) backgroundColor = [NSColor alternateSelectedControlColor];
|
if([self isHighlighted]) backgroundColor = [NSColor alternateSelectedControlColor];
|
||||||
else if(!listView->enabled(true)) backgroundColor = [NSColor controlBackgroundColor];
|
else if(!tableView->enabled(true)) backgroundColor = [NSColor controlBackgroundColor];
|
||||||
else if(auto color = listViewCell->state.backgroundColor) backgroundColor = NSMakeColor(color);
|
else if(auto color = tableViewCell->state.backgroundColor) backgroundColor = NSMakeColor(color);
|
||||||
else backgroundColor = [NSColor controlBackgroundColor];
|
else backgroundColor = [NSColor controlBackgroundColor];
|
||||||
|
|
||||||
[backgroundColor set];
|
[backgroundColor set];
|
||||||
[NSBezierPath fillRect:frame];
|
[NSBezierPath fillRect:frame];
|
||||||
|
|
||||||
if(listViewCell->state.checkable) {
|
if(tableViewCell->state.checkable) {
|
||||||
[buttonCell setHighlighted:YES];
|
[buttonCell setHighlighted:YES];
|
||||||
[buttonCell setState:(listViewCell->state.checked ? NSOnState : NSOffState)];
|
[buttonCell setState:(tableViewCell->state.checked ? NSOnState : NSOffState)];
|
||||||
[buttonCell drawWithFrame:frame inView:view];
|
[buttonCell drawWithFrame:frame inView:view];
|
||||||
frame.origin.x += frame.size.height + 2;
|
frame.origin.x += frame.size.height + 2;
|
||||||
frame.size.width -= frame.size.height + 2;
|
frame.size.width -= frame.size.height + 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(listViewCell->state.icon) {
|
if(tableViewCell->state.icon) {
|
||||||
NSImage* image = NSMakeImage(listViewCell->state.icon, frame.size.height, frame.size.height);
|
NSImage* image = NSMakeImage(tableViewCell->state.icon, frame.size.height, frame.size.height);
|
||||||
[[NSGraphicsContext currentContext] saveGraphicsState];
|
[[NSGraphicsContext currentContext] saveGraphicsState];
|
||||||
NSRect targetRect = NSMakeRect(frame.origin.x, frame.origin.y, frame.size.height, frame.size.height);
|
NSRect targetRect = NSMakeRect(frame.origin.x, frame.origin.y, frame.size.height, frame.size.height);
|
||||||
NSRect sourceRect = NSMakeRect(0, 0, [image size].width, [image size].height);
|
NSRect sourceRect = NSMakeRect(0, 0, [image size].width, [image size].height);
|
||||||
|
@ -189,21 +189,21 @@
|
||||||
frame.size.width -= frame.size.height + 2;
|
frame.size.width -= frame.size.height + 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(listViewCell->state.text) {
|
if(tableViewCell->state.text) {
|
||||||
NSMutableParagraphStyle* paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
|
NSMutableParagraphStyle* paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
|
||||||
paragraphStyle.alignment = NSTextAlignmentCenter;
|
paragraphStyle.alignment = NSTextAlignmentCenter;
|
||||||
if(listViewCell->state.alignment.horizontal() < 0.333) paragraphStyle.alignment = NSTextAlignmentLeft;
|
if(tableViewCell->state.alignment.horizontal() < 0.333) paragraphStyle.alignment = NSTextAlignmentLeft;
|
||||||
if(listViewCell->state.alignment.horizontal() > 0.666) paragraphStyle.alignment = NSTextAlignmentRight;
|
if(tableViewCell->state.alignment.horizontal() > 0.666) paragraphStyle.alignment = NSTextAlignmentRight;
|
||||||
NSColor* foregroundColor = nil;
|
NSColor* foregroundColor = nil;
|
||||||
if([self isHighlighted]) foregroundColor = [NSColor alternateSelectedControlTextColor];
|
if([self isHighlighted]) foregroundColor = [NSColor alternateSelectedControlTextColor];
|
||||||
else if(!listView->enabled(true)) foregroundColor = [NSColor disabledControlTextColor];
|
else if(!tableView->enabled(true)) foregroundColor = [NSColor disabledControlTextColor];
|
||||||
else if(auto color = listViewCell->state.foregroundColor) foregroundColor = NSMakeColor(color);
|
else if(auto color = tableViewCell->state.foregroundColor) foregroundColor = NSMakeColor(color);
|
||||||
else foregroundColor = [NSColor textColor];
|
else foregroundColor = [NSColor textColor];
|
||||||
NSString* text = [NSString stringWithUTF8String:listViewCell->state.text];
|
NSString* text = [NSString stringWithUTF8String:tableViewCell->state.text];
|
||||||
[text drawInRect:frame withAttributes:@{
|
[text drawInRect:frame withAttributes:@{
|
||||||
NSBackgroundColorAttributeName:backgroundColor,
|
NSBackgroundColorAttributeName:backgroundColor,
|
||||||
NSForegroundColorAttributeName:foregroundColor,
|
NSForegroundColorAttributeName:foregroundColor,
|
||||||
NSFontAttributeName:hiro::pFont::create(listViewCell->font(true)),
|
NSFontAttributeName:hiro::pFont::create(tableViewCell->font(true)),
|
||||||
NSParagraphStyleAttributeName:paragraphStyle
|
NSParagraphStyleAttributeName:paragraphStyle
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
@ -233,10 +233,10 @@
|
||||||
NSPoint point = [view convertPointFromBase:[nextEvent locationInWindow]];
|
NSPoint point = [view convertPointFromBase:[nextEvent locationInWindow]];
|
||||||
NSRect rect = NSMakeRect(frame.origin.x, frame.origin.y, frame.size.height, frame.size.height);
|
NSRect rect = NSMakeRect(frame.origin.x, frame.origin.y, frame.size.height, frame.size.height);
|
||||||
if(NSMouseInRect(point, rect, [view isFlipped])) {
|
if(NSMouseInRect(point, rect, [view isFlipped])) {
|
||||||
if(auto listViewItem = listView->item([view rowAtPoint:point])) {
|
if(auto tableViewItem = tableView->item([view rowAtPoint:point])) {
|
||||||
if(auto listViewCell = listViewItem->cell([view columnAtPoint:point])) {
|
if(auto tableViewCell = tableViewItem->cell([view columnAtPoint:point])) {
|
||||||
listViewCell->state.checked = !listViewCell->state.checked;
|
tableViewCell->state.checked = !tableViewCell->state.checked;
|
||||||
listView->doToggle(listViewCell->instance);
|
tableView->doToggle(tableViewCell->instance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -255,9 +255,9 @@
|
||||||
|
|
||||||
namespace hiro {
|
namespace hiro {
|
||||||
|
|
||||||
auto pListView::construct() -> void {
|
auto pTableView::construct() -> void {
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
cocoaView = cocoaListView = [[CocoaListView alloc] initWith:self()];
|
cocoaView = cocoaTableView = [[CocoaTableView alloc] initWith:self()];
|
||||||
pWidget::construct();
|
pWidget::construct();
|
||||||
|
|
||||||
setAlignment(state().alignment);
|
setAlignment(state().alignment);
|
||||||
|
@ -269,14 +269,14 @@ auto pListView::construct() -> void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::destruct() -> void {
|
auto pTableView::destruct() -> void {
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
[cocoaView removeFromSuperview];
|
[cocoaView removeFromSuperview];
|
||||||
[cocoaView release];
|
[cocoaView release];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::append(sListViewHeader header) -> void {
|
auto pTableView::append(sTableViewHeader header) -> void {
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
[cocoaView reloadColumns];
|
[cocoaView reloadColumns];
|
||||||
|
|
||||||
|
@ -284,25 +284,25 @@ auto pListView::append(sListViewHeader header) -> void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::append(sListViewItem item) -> void {
|
auto pTableView::append(sTableViewItem item) -> void {
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
[[cocoaView content] reloadData];
|
[[cocoaView content] reloadData];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::remove(sListViewHeader header) -> void {
|
auto pTableView::remove(sTableViewHeader header) -> void {
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
[cocoaView reloadColumns];
|
[cocoaView reloadColumns];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::remove(sListViewItem item) -> void {
|
auto pTableView::remove(sTableViewItem item) -> void {
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
[[cocoaView content] reloadData];
|
[[cocoaView content] reloadData];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::resizeColumns() -> void {
|
auto pTableView::resizeColumns() -> void {
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
if(auto& header = state().header) {
|
if(auto& header = state().header) {
|
||||||
vector<int> widths;
|
vector<int> widths;
|
||||||
|
@ -333,71 +333,71 @@ auto pListView::resizeColumns() -> void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::setAlignment(Alignment alignment) -> void {
|
auto pTableView::setAlignment(Alignment alignment) -> void {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::setBackgroundColor(Color color) -> void {
|
auto pTableView::setBackgroundColor(Color color) -> void {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::setBatchable(bool batchable) -> void {
|
auto pTableView::setBatchable(bool batchable) -> void {
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
[[cocoaView content] setAllowsMultipleSelection:(batchable ? YES : NO)];
|
[[cocoaView content] setAllowsMultipleSelection:(batchable ? YES : NO)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::setBordered(bool bordered) -> void {
|
auto pTableView::setBordered(bool bordered) -> void {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::setEnabled(bool enabled) -> void {
|
auto pTableView::setEnabled(bool enabled) -> void {
|
||||||
pWidget::setEnabled(enabled);
|
pWidget::setEnabled(enabled);
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
[[cocoaView content] setEnabled:enabled];
|
[[cocoaView content] setEnabled:enabled];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::setFont(const Font& font) -> void {
|
auto pTableView::setFont(const Font& font) -> void {
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
[cocoaView setFont:pFont::create(font)];
|
[cocoaView setFont:pFont::create(font)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::setForegroundColor(Color color) -> void {
|
auto pTableView::setForegroundColor(Color color) -> void {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::_cellWidth(uint row, uint column) -> uint {
|
auto pTableView::_cellWidth(uint row, uint column) -> uint {
|
||||||
uint width = 8;
|
uint width = 8;
|
||||||
if(auto pListViewItem = self().item(row)) {
|
if(auto pTableViewItem = self().item(row)) {
|
||||||
if(auto pListViewCell = pListViewItem->cell(column)) {
|
if(auto pTableViewCell = pTableViewItem->cell(column)) {
|
||||||
if(pListViewCell->state.checkable) {
|
if(pTableViewCell->state.checkable) {
|
||||||
width += 24;
|
width += 24;
|
||||||
}
|
}
|
||||||
if(auto& icon = pListViewCell->state.icon) {
|
if(auto& icon = pTableViewCell->state.icon) {
|
||||||
width += icon.width() + 2;
|
width += icon.width() + 2;
|
||||||
}
|
}
|
||||||
if(auto& text = pListViewCell->state.text) {
|
if(auto& text = pTableViewCell->state.text) {
|
||||||
width += pFont::size(pListViewCell->font(true), text).width();
|
width += pFont::size(pTableViewCell->font(true), text).width();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::_columnWidth(uint column) -> uint {
|
auto pTableView::_columnWidth(uint column) -> uint {
|
||||||
uint width = 8;
|
uint width = 8;
|
||||||
if(auto& header = state().header) {
|
if(auto& header = state().header) {
|
||||||
if(auto pListViewColumn = header->column(column)) {
|
if(auto pTableViewColumn = header->column(column)) {
|
||||||
if(auto& icon = pListViewColumn->state.icon) {
|
if(auto& icon = pTableViewColumn->state.icon) {
|
||||||
width += icon.width() + 2;
|
width += icon.width() + 2;
|
||||||
}
|
}
|
||||||
if(auto& text = pListViewColumn->state.text) {
|
if(auto& text = pTableViewColumn->state.text) {
|
||||||
width += pFont::size(pListViewColumn->font(true), text).width();
|
width += pFont::size(pTableViewColumn->font(true), text).width();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::_width(uint column) -> uint {
|
auto pTableView::_width(uint column) -> uint {
|
||||||
if(auto& header = state().header) {
|
if(auto& header = state().header) {
|
||||||
if(auto width = header->column(column).width()) return width;
|
if(auto width = header->column(column).width()) return width;
|
||||||
uint width = 1;
|
uint width = 1;
|
||||||
|
@ -412,20 +412,20 @@ auto pListView::_width(uint column) -> uint {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
auto pListView::autoSizeColumns() -> void {
|
auto pTableView::autoSizeColumns() -> void {
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
if(listView.state.checkable) {
|
if(tableView.state.checkable) {
|
||||||
NSTableColumn* tableColumn = [[cocoaView content] tableColumnWithIdentifier:@"check"];
|
NSTableColumn* tableColumn = [[cocoaView content] tableColumnWithIdentifier:@"check"];
|
||||||
[tableColumn setWidth:20.0];
|
[tableColumn setWidth:20.0];
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned height = [[cocoaView content] rowHeight];
|
unsigned height = [[cocoaView content] rowHeight];
|
||||||
for(unsigned column = 0; column < max(1u, listView.state.headerText.size()); column++) {
|
for(unsigned column = 0; column < max(1u, tableView.state.headerText.size()); column++) {
|
||||||
NSTableColumn* tableColumn = [[cocoaView content] tableColumnWithIdentifier:[[NSNumber numberWithInteger:column] stringValue]];
|
NSTableColumn* tableColumn = [[cocoaView content] tableColumnWithIdentifier:[[NSNumber numberWithInteger:column] stringValue]];
|
||||||
unsigned minimumWidth = pFont::size([[tableColumn headerCell] font], listView.state.headerText(column)).width + 4;
|
unsigned minimumWidth = pFont::size([[tableColumn headerCell] font], tableView.state.headerText(column)).width + 4;
|
||||||
for(unsigned row = 0; row < listView.state.text.size(); row++) {
|
for(unsigned row = 0; row < tableView.state.text.size(); row++) {
|
||||||
unsigned width = pFont::size([cocoaView font], listView.state.text(row)(column)).width + 2;
|
unsigned width = pFont::size([cocoaView font], tableView.state.text(row)(column)).width + 2;
|
||||||
if(listView.state.image(row)(height).empty() == false) width += height + 2;
|
if(tableView.state.image(row)(height)) width += height + 2;
|
||||||
if(width > minimumWidth) minimumWidth = width;
|
if(width > minimumWidth) minimumWidth = width;
|
||||||
}
|
}
|
||||||
[tableColumn setWidth:minimumWidth];
|
[tableColumn setWidth:minimumWidth];
|
||||||
|
@ -435,7 +435,7 @@ auto pListView::autoSizeColumns() -> void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::setSelected(bool selected) -> void {
|
auto pTableView::setSelected(bool selected) -> void {
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
if(selected == false) {
|
if(selected == false) {
|
||||||
[[cocoaView content] deselectAll:nil];
|
[[cocoaView content] deselectAll:nil];
|
||||||
|
@ -443,7 +443,7 @@ auto pListView::setSelected(bool selected) -> void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::setSelection(unsigned selection) -> void {
|
auto pTableView::setSelection(unsigned selection) -> void {
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
[[cocoaView content] selectRowIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(selection, 1)] byExtendingSelection:NO];
|
[[cocoaView content] selectRowIndexes:[NSIndexSet indexSetWithIndexesInRange:NSMakeRange(selection, 1)] byExtendingSelection:NO];
|
||||||
}
|
}
|
|
@ -1,16 +1,16 @@
|
||||||
#if defined(Hiro_ListView)
|
#if defined(Hiro_TableView)
|
||||||
|
|
||||||
@class CocoaListViewContent;
|
@class CocoaTableViewContent;
|
||||||
|
|
||||||
@interface CocoaListView : NSScrollView <NSTableViewDelegate, NSTableViewDataSource> {
|
@interface CocoaTableView : NSScrollView <NSTableViewDelegate, NSTableViewDataSource> {
|
||||||
@public
|
@public
|
||||||
hiro::mListView* listView;
|
hiro::mTableView* tableView;
|
||||||
CocoaListViewContent* content;
|
CocoaTableViewContent* content;
|
||||||
NSFont* font;
|
NSFont* font;
|
||||||
}
|
}
|
||||||
-(id) initWith:(hiro::mListView&)listView;
|
-(id) initWith:(hiro::mTableView&)tableView;
|
||||||
-(void) dealloc;
|
-(void) dealloc;
|
||||||
-(CocoaListViewContent*) content;
|
-(CocoaTableViewContent*) content;
|
||||||
-(NSFont*) font;
|
-(NSFont*) font;
|
||||||
-(void) setFont:(NSFont*)font;
|
-(void) setFont:(NSFont*)font;
|
||||||
-(void) reloadColumns;
|
-(void) reloadColumns;
|
||||||
|
@ -24,16 +24,16 @@
|
||||||
-(IBAction) doubleAction:(id)sender;
|
-(IBAction) doubleAction:(id)sender;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface CocoaListViewContent : NSTableView {
|
@interface CocoaTableViewContent : NSTableView {
|
||||||
}
|
}
|
||||||
-(void) keyDown:(NSEvent*)event;
|
-(void) keyDown:(NSEvent*)event;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface CocoaListViewCell : NSCell {
|
@interface CocoaTableViewCell : NSCell {
|
||||||
hiro::mListView* listView;
|
hiro::mTableView* tableView;
|
||||||
NSButtonCell* buttonCell;
|
NSButtonCell* buttonCell;
|
||||||
}
|
}
|
||||||
-(id) initWith:(hiro::mListView&)listViewReference;
|
-(id) initWith:(hiro::mTableView&)tableViewReference;
|
||||||
-(NSString*) stringValue;
|
-(NSString*) stringValue;
|
||||||
-(void) drawWithFrame:(NSRect)frame inView:(NSView*)view;
|
-(void) drawWithFrame:(NSRect)frame inView:(NSView*)view;
|
||||||
-(NSUInteger) hitTestForEvent:(NSEvent*)event inRect:(NSRect)frame ofView:(NSView*)view;
|
-(NSUInteger) hitTestForEvent:(NSEvent*)event inRect:(NSRect)frame ofView:(NSView*)view;
|
||||||
|
@ -43,13 +43,13 @@
|
||||||
|
|
||||||
namespace hiro {
|
namespace hiro {
|
||||||
|
|
||||||
struct pListView : pWidget {
|
struct pTableView : pWidget {
|
||||||
Declare(ListView, Widget)
|
Declare(TableView, Widget)
|
||||||
|
|
||||||
auto append(sListViewHeader header) -> void;
|
auto append(sTableViewHeader header) -> void;
|
||||||
auto append(sListViewItem item) -> void;
|
auto append(sTableViewItem item) -> void;
|
||||||
auto remove(sListViewHeader header) -> void;
|
auto remove(sTableViewHeader header) -> void;
|
||||||
auto remove(sListViewItem item) -> void;
|
auto remove(sTableViewItem item) -> void;
|
||||||
auto resizeColumns() -> void;
|
auto resizeColumns() -> void;
|
||||||
auto setAlignment(Alignment alignment) -> void;
|
auto setAlignment(Alignment alignment) -> void;
|
||||||
auto setBackgroundColor(Color color) -> void;
|
auto setBackgroundColor(Color color) -> void;
|
||||||
|
@ -63,7 +63,7 @@ struct pListView : pWidget {
|
||||||
auto _columnWidth(uint column) -> uint;
|
auto _columnWidth(uint column) -> uint;
|
||||||
auto _width(uint column) -> uint;
|
auto _width(uint column) -> uint;
|
||||||
|
|
||||||
CocoaListView* cocoaListView = nullptr;
|
CocoaTableView* cocoaTableView = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
-(BOOL) performDragOperation:(id<NSDraggingInfo>)sender {
|
-(BOOL) performDragOperation:(id<NSDraggingInfo>)sender {
|
||||||
lstring paths = DropPaths(sender);
|
lstring paths = DropPaths(sender);
|
||||||
if(paths.empty()) return NO;
|
if(!paths) return NO;
|
||||||
viewport->doDrop(paths);
|
viewport->doDrop(paths);
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,7 +122,7 @@
|
||||||
|
|
||||||
-(BOOL) performDragOperation:(id<NSDraggingInfo>)sender {
|
-(BOOL) performDragOperation:(id<NSDraggingInfo>)sender {
|
||||||
lstring paths = DropPaths(sender);
|
lstring paths = DropPaths(sender);
|
||||||
if(paths.empty()) return NO;
|
if(!paths) return NO;
|
||||||
window->doDrop(paths);
|
window->doDrop(paths);
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,7 @@
|
||||||
#define Hiro_CheckButton
|
#define Hiro_CheckButton
|
||||||
#define Hiro_CheckLabel
|
#define Hiro_CheckLabel
|
||||||
#define Hiro_ComboButton
|
#define Hiro_ComboButton
|
||||||
|
#define Hiro_ComboEdit
|
||||||
#define Hiro_Console
|
#define Hiro_Console
|
||||||
#define Hiro_Frame
|
#define Hiro_Frame
|
||||||
#define Hiro_HexEdit
|
#define Hiro_HexEdit
|
||||||
|
@ -62,23 +63,22 @@
|
||||||
#define Hiro_IconView
|
#define Hiro_IconView
|
||||||
#define Hiro_Label
|
#define Hiro_Label
|
||||||
#define Hiro_LineEdit
|
#define Hiro_LineEdit
|
||||||
#define Hiro_ListView
|
|
||||||
#define Hiro_ProgressBar
|
#define Hiro_ProgressBar
|
||||||
#define Hiro_RadioButton
|
#define Hiro_RadioButton
|
||||||
#define Hiro_RadioLabel
|
#define Hiro_RadioLabel
|
||||||
#define Hiro_SourceEdit
|
#define Hiro_SourceEdit
|
||||||
#define Hiro_TabFrame
|
#define Hiro_TabFrame
|
||||||
|
#define Hiro_TableView
|
||||||
#define Hiro_TextEdit
|
#define Hiro_TextEdit
|
||||||
#define Hiro_TreeView
|
#define Hiro_TreeView
|
||||||
#define Hiro_VerticalScrollBar
|
#define Hiro_VerticalScrollBar
|
||||||
#define Hiro_VerticalSlider
|
#define Hiro_VerticalSlider
|
||||||
#define Hiro_Viewport
|
#define Hiro_Viewport
|
||||||
|
|
||||||
#define Hiro_FixedLayout
|
//platform-specific exclusions
|
||||||
#define Hiro_HorizontalLayout
|
|
||||||
#define Hiro_VerticalLayout
|
|
||||||
|
|
||||||
#if defined(HIRO_WINDOWS) || defined(HIRO_COCOA) || defined(HIRO_QT)
|
#if defined(HIRO_WINDOWS) || defined(HIRO_COCOA) || defined(HIRO_QT)
|
||||||
|
#undef Hiro_ComboEdit
|
||||||
#undef Hiro_Console
|
#undef Hiro_Console
|
||||||
#undef Hiro_IconView
|
#undef Hiro_IconView
|
||||||
#undef Hiro_SourceEdit
|
#undef Hiro_SourceEdit
|
||||||
|
@ -89,6 +89,16 @@
|
||||||
#undef Hiro_HexEdit
|
#undef Hiro_HexEdit
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
//extensions
|
||||||
|
|
||||||
|
#define Hiro_FixedLayout
|
||||||
|
#define Hiro_HorizontalLayout
|
||||||
|
#define Hiro_VerticalLayout
|
||||||
|
|
||||||
|
#if defined(Hiro_TableView)
|
||||||
|
#define Hiro_ListView
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(Hiro_Button) && defined(Hiro_Canvas) && defined(Hiro_Label)
|
#if defined(Hiro_Button) && defined(Hiro_Canvas) && defined(Hiro_Label)
|
||||||
#define Hiro_MessageDialog
|
#define Hiro_MessageDialog
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -48,7 +48,7 @@ auto mMenu::remove(sAction action) -> type& {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mMenu::reset() -> type& {
|
auto mMenu::reset() -> type& {
|
||||||
while(state.actions) remove(state.actions.last());
|
while(state.actions) remove(state.actions.right());
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,8 @@ namespace hiro {
|
||||||
#include "widget/check-label.cpp"
|
#include "widget/check-label.cpp"
|
||||||
#include "widget/combo-button.cpp"
|
#include "widget/combo-button.cpp"
|
||||||
#include "widget/combo-button-item.cpp"
|
#include "widget/combo-button-item.cpp"
|
||||||
|
#include "widget/combo-edit.cpp"
|
||||||
|
#include "widget/combo-edit-item.cpp"
|
||||||
#include "widget/console.cpp"
|
#include "widget/console.cpp"
|
||||||
#include "widget/frame.cpp"
|
#include "widget/frame.cpp"
|
||||||
#include "widget/hex-edit.cpp"
|
#include "widget/hex-edit.cpp"
|
||||||
|
@ -86,17 +88,17 @@ namespace hiro {
|
||||||
#include "widget/icon-view-item.cpp"
|
#include "widget/icon-view-item.cpp"
|
||||||
#include "widget/label.cpp"
|
#include "widget/label.cpp"
|
||||||
#include "widget/line-edit.cpp"
|
#include "widget/line-edit.cpp"
|
||||||
#include "widget/list-view.cpp"
|
|
||||||
#include "widget/list-view-header.cpp"
|
|
||||||
#include "widget/list-view-column.cpp"
|
|
||||||
#include "widget/list-view-item.cpp"
|
|
||||||
#include "widget/list-view-cell.cpp"
|
|
||||||
#include "widget/progress-bar.cpp"
|
#include "widget/progress-bar.cpp"
|
||||||
#include "widget/radio-button.cpp"
|
#include "widget/radio-button.cpp"
|
||||||
#include "widget/radio-label.cpp"
|
#include "widget/radio-label.cpp"
|
||||||
#include "widget/source-edit.cpp"
|
#include "widget/source-edit.cpp"
|
||||||
#include "widget/tab-frame.cpp"
|
#include "widget/tab-frame.cpp"
|
||||||
#include "widget/tab-frame-item.cpp"
|
#include "widget/tab-frame-item.cpp"
|
||||||
|
#include "widget/table-view.cpp"
|
||||||
|
#include "widget/table-view-header.cpp"
|
||||||
|
#include "widget/table-view-column.cpp"
|
||||||
|
#include "widget/table-view-item.cpp"
|
||||||
|
#include "widget/table-view-cell.cpp"
|
||||||
#include "widget/text-edit.cpp"
|
#include "widget/text-edit.cpp"
|
||||||
#include "widget/tree-view.cpp"
|
#include "widget/tree-view.cpp"
|
||||||
#include "widget/tree-view-item.cpp"
|
#include "widget/tree-view-item.cpp"
|
||||||
|
|
475
core/core.hpp
475
core/core.hpp
|
@ -4,6 +4,7 @@
|
||||||
#include <nall/function.hpp>
|
#include <nall/function.hpp>
|
||||||
#include <nall/image.hpp>
|
#include <nall/image.hpp>
|
||||||
#include <nall/maybe.hpp>
|
#include <nall/maybe.hpp>
|
||||||
|
#include <nall/path.hpp>
|
||||||
#include <nall/range.hpp>
|
#include <nall/range.hpp>
|
||||||
#include <nall/set.hpp>
|
#include <nall/set.hpp>
|
||||||
#include <nall/shared-pointer.hpp>
|
#include <nall/shared-pointer.hpp>
|
||||||
|
@ -58,6 +59,8 @@ Declare(CheckButton)
|
||||||
Declare(CheckLabel)
|
Declare(CheckLabel)
|
||||||
Declare(ComboButton)
|
Declare(ComboButton)
|
||||||
Declare(ComboButtonItem)
|
Declare(ComboButtonItem)
|
||||||
|
Declare(ComboEdit)
|
||||||
|
Declare(ComboEditItem)
|
||||||
Declare(Console)
|
Declare(Console)
|
||||||
Declare(Frame)
|
Declare(Frame)
|
||||||
Declare(HexEdit)
|
Declare(HexEdit)
|
||||||
|
@ -67,17 +70,17 @@ Declare(IconView)
|
||||||
Declare(IconViewItem)
|
Declare(IconViewItem)
|
||||||
Declare(Label)
|
Declare(Label)
|
||||||
Declare(LineEdit)
|
Declare(LineEdit)
|
||||||
Declare(ListView)
|
|
||||||
Declare(ListViewHeader)
|
|
||||||
Declare(ListViewColumn)
|
|
||||||
Declare(ListViewItem)
|
|
||||||
Declare(ListViewCell)
|
|
||||||
Declare(ProgressBar)
|
Declare(ProgressBar)
|
||||||
Declare(RadioButton)
|
Declare(RadioButton)
|
||||||
Declare(RadioLabel)
|
Declare(RadioLabel)
|
||||||
Declare(SourceEdit)
|
Declare(SourceEdit)
|
||||||
Declare(TabFrame)
|
Declare(TabFrame)
|
||||||
Declare(TabFrameItem)
|
Declare(TabFrameItem)
|
||||||
|
Declare(TableView)
|
||||||
|
Declare(TableViewHeader)
|
||||||
|
Declare(TableViewColumn)
|
||||||
|
Declare(TableViewItem)
|
||||||
|
Declare(TableViewCell)
|
||||||
Declare(TextEdit)
|
Declare(TextEdit)
|
||||||
Declare(TreeView)
|
Declare(TreeView)
|
||||||
Declare(TreeViewItem)
|
Declare(TreeViewItem)
|
||||||
|
@ -572,18 +575,19 @@ struct mObject {
|
||||||
auto offset() const -> signed;
|
auto offset() const -> signed;
|
||||||
auto parent() const -> mObject*;
|
auto parent() const -> mObject*;
|
||||||
auto parentComboButton(bool recursive = false) const -> mComboButton*;
|
auto parentComboButton(bool recursive = false) const -> mComboButton*;
|
||||||
|
auto parentComboEdit(bool recursive = false) const -> mComboEdit*;
|
||||||
auto parentFrame(bool recursive = false) const -> mFrame*;
|
auto parentFrame(bool recursive = false) const -> mFrame*;
|
||||||
auto parentIconView(bool recursive = false) const -> mIconView*;
|
auto parentIconView(bool recursive = false) const -> mIconView*;
|
||||||
auto parentLayout(bool recursive = false) const -> mLayout*;
|
auto parentLayout(bool recursive = false) const -> mLayout*;
|
||||||
auto parentListView(bool recursive = false) const -> mListView*;
|
|
||||||
auto parentListViewHeader(bool recursive = false) const -> mListViewHeader*;
|
|
||||||
auto parentListViewItem(bool recursive = false) const -> mListViewItem*;
|
|
||||||
auto parentMenu(bool recursive = false) const -> mMenu*;
|
auto parentMenu(bool recursive = false) const -> mMenu*;
|
||||||
auto parentMenuBar(bool recursive = false) const -> mMenuBar*;
|
auto parentMenuBar(bool recursive = false) const -> mMenuBar*;
|
||||||
auto parentPopupMenu(bool recursive = false) const -> mPopupMenu*;
|
auto parentPopupMenu(bool recursive = false) const -> mPopupMenu*;
|
||||||
auto parentSizable(bool recursive = false) const -> mSizable*;
|
auto parentSizable(bool recursive = false) const -> mSizable*;
|
||||||
auto parentTabFrame(bool recursive = false) const -> mTabFrame*;
|
auto parentTabFrame(bool recursive = false) const -> mTabFrame*;
|
||||||
auto parentTabFrameItem(bool recursive = false) const -> mTabFrameItem*;
|
auto parentTabFrameItem(bool recursive = false) const -> mTabFrameItem*;
|
||||||
|
auto parentTableView(bool recursive = false) const -> mTableView*;
|
||||||
|
auto parentTableViewHeader(bool recursive = false) const -> mTableViewHeader*;
|
||||||
|
auto parentTableViewItem(bool recursive = false) const -> mTableViewItem*;
|
||||||
auto parentTreeView(bool recursive = false) const -> mTreeView*;
|
auto parentTreeView(bool recursive = false) const -> mTreeView*;
|
||||||
auto parentTreeViewItem(bool recursive = false) const -> mTreeViewItem*;
|
auto parentTreeViewItem(bool recursive = false) const -> mTreeViewItem*;
|
||||||
auto parentWidget(bool recursive = false) const -> mWidget*;
|
auto parentWidget(bool recursive = false) const -> mWidget*;
|
||||||
|
@ -1116,6 +1120,61 @@ struct mComboButtonItem : mObject {
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(Hiro_ComboEdit)
|
||||||
|
struct mComboEdit : mWidget {
|
||||||
|
Declare(ComboEdit)
|
||||||
|
using mObject::remove;
|
||||||
|
|
||||||
|
auto append(sComboEditItem item) -> type&;
|
||||||
|
auto backgroundColor() const -> Color;
|
||||||
|
auto doActivate() const -> void;
|
||||||
|
auto doChange() const -> void;
|
||||||
|
auto foregroundColor() const -> Color;
|
||||||
|
auto item(uint position) const -> ComboEditItem;
|
||||||
|
auto itemCount() const -> uint;
|
||||||
|
auto items() const -> vector<ComboEditItem>;
|
||||||
|
auto onActivate(const function<void ()>& callback = {}) -> type&;
|
||||||
|
auto onChange(const function<void ()>& callback = {}) -> type&;
|
||||||
|
auto remove(sComboEditItem item) -> type&;
|
||||||
|
auto reset() -> type&;
|
||||||
|
auto setBackgroundColor(Color color = {}) -> type&;
|
||||||
|
auto setForegroundColor(Color color = {}) -> type&;
|
||||||
|
auto setParent(mObject* parent = nullptr, int offset = -1) -> type& override;
|
||||||
|
auto setText(const string& text = "") -> type&;
|
||||||
|
auto text() const -> string;
|
||||||
|
|
||||||
|
//private:
|
||||||
|
struct State {
|
||||||
|
Color backgroundColor;
|
||||||
|
Color foregroundColor;
|
||||||
|
vector<sComboEditItem> items;
|
||||||
|
function<void ()> onActivate;
|
||||||
|
function<void ()> onChange;
|
||||||
|
string text;
|
||||||
|
} state;
|
||||||
|
|
||||||
|
auto destruct() -> void override;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(Hiro_ComboEdit)
|
||||||
|
struct mComboEditItem : mObject {
|
||||||
|
Declare(ComboEditItem)
|
||||||
|
|
||||||
|
auto icon() const -> image;
|
||||||
|
auto remove() -> type& override;
|
||||||
|
auto setIcon(const image& icon = {}) -> type&;
|
||||||
|
auto setText(const string& text = "") -> type&;
|
||||||
|
auto text() const -> string;
|
||||||
|
|
||||||
|
//private:
|
||||||
|
struct State {
|
||||||
|
image icon;
|
||||||
|
string text;
|
||||||
|
} state;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(Hiro_Console)
|
#if defined(Hiro_Console)
|
||||||
struct mConsole : mWidget {
|
struct mConsole : mWidget {
|
||||||
Declare(Console)
|
Declare(Console)
|
||||||
|
@ -1356,205 +1415,6 @@ struct mLineEdit : mWidget {
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(Hiro_ListView)
|
|
||||||
struct mListView : mWidget {
|
|
||||||
Declare(ListView)
|
|
||||||
using mObject::remove;
|
|
||||||
|
|
||||||
auto alignment() const -> Alignment;
|
|
||||||
auto append(sListViewHeader column) -> type&;
|
|
||||||
auto append(sListViewItem item) -> type&;
|
|
||||||
auto backgroundColor() const -> Color;
|
|
||||||
auto batchable() const -> bool;
|
|
||||||
auto batched() const -> vector<ListViewItem>;
|
|
||||||
auto bordered() const -> bool;
|
|
||||||
auto doActivate() const -> void;
|
|
||||||
auto doChange() const -> void;
|
|
||||||
auto doContext() const -> void;
|
|
||||||
auto doEdit(sListViewCell cell) const -> void;
|
|
||||||
auto doSort(sListViewColumn column) const -> void;
|
|
||||||
auto doToggle(sListViewCell cell) const -> void;
|
|
||||||
auto foregroundColor() const -> Color;
|
|
||||||
auto header() const -> ListViewHeader;
|
|
||||||
auto item(unsigned position) const -> ListViewItem;
|
|
||||||
auto itemCount() const -> unsigned;
|
|
||||||
auto items() const -> vector<ListViewItem>;
|
|
||||||
auto onActivate(const function<void ()>& callback = {}) -> type&;
|
|
||||||
auto onChange(const function<void ()>& callback = {}) -> type&;
|
|
||||||
auto onContext(const function<void ()>& callback = {}) -> type&;
|
|
||||||
auto onEdit(const function<void (ListViewCell)>& callback = {}) -> type&;
|
|
||||||
auto onSort(const function<void (ListViewColumn)>& callback = {}) -> type&;
|
|
||||||
auto onToggle(const function<void (ListViewCell)>& callback = {}) -> type&;
|
|
||||||
auto remove(sListViewHeader column) -> type&;
|
|
||||||
auto remove(sListViewItem item) -> type&;
|
|
||||||
auto reset() -> type&;
|
|
||||||
auto resizeColumns() -> type&;
|
|
||||||
auto selected() const -> ListViewItem;
|
|
||||||
auto setAlignment(Alignment alignment = {}) -> type&;
|
|
||||||
auto setBackgroundColor(Color color = {}) -> type&;
|
|
||||||
auto setBatchable(bool batchable = true) -> type&;
|
|
||||||
auto setBordered(bool bordered = true) -> type&;
|
|
||||||
auto setForegroundColor(Color color = {}) -> type&;
|
|
||||||
auto setParent(mObject* parent = nullptr, signed offset = -1) -> type& override;
|
|
||||||
|
|
||||||
//private:
|
|
||||||
struct State {
|
|
||||||
unsigned activeColumn = 0;
|
|
||||||
Alignment alignment;
|
|
||||||
Color backgroundColor;
|
|
||||||
bool batchable = false;
|
|
||||||
bool bordered = false;
|
|
||||||
Color foregroundColor;
|
|
||||||
sListViewHeader header;
|
|
||||||
vector<sListViewItem> items;
|
|
||||||
function<void ()> onActivate;
|
|
||||||
function<void ()> onChange;
|
|
||||||
function<void ()> onContext;
|
|
||||||
function<void (ListViewCell)> onEdit;
|
|
||||||
function<void (ListViewColumn)> onSort;
|
|
||||||
function<void (ListViewCell)> onToggle;
|
|
||||||
} state;
|
|
||||||
|
|
||||||
auto destruct() -> void override;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(Hiro_ListView)
|
|
||||||
struct mListViewHeader : mObject {
|
|
||||||
Declare(ListViewHeader)
|
|
||||||
|
|
||||||
auto append(sListViewColumn column) -> type&;
|
|
||||||
auto column(unsigned position) const -> ListViewColumn;
|
|
||||||
auto columnCount() const -> unsigned;
|
|
||||||
auto columns() const -> vector<ListViewColumn>;
|
|
||||||
auto remove() -> type& override;
|
|
||||||
auto remove(sListViewColumn column) -> type&;
|
|
||||||
auto setParent(mObject* parent = nullptr, signed offset = -1) -> type& override;
|
|
||||||
|
|
||||||
//private:
|
|
||||||
struct State {
|
|
||||||
vector<sListViewColumn> columns;
|
|
||||||
} state;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(Hiro_ListView)
|
|
||||||
struct mListViewColumn : mObject {
|
|
||||||
Declare(ListViewColumn)
|
|
||||||
|
|
||||||
auto active() const -> bool;
|
|
||||||
auto alignment() const -> Alignment;
|
|
||||||
auto backgroundColor() const -> Color;
|
|
||||||
auto editable() const -> bool;
|
|
||||||
auto expandable() const -> bool;
|
|
||||||
auto foregroundColor() const -> Color;
|
|
||||||
auto horizontalAlignment() const -> double;
|
|
||||||
auto icon() const -> image;
|
|
||||||
auto remove() -> type& override;
|
|
||||||
auto resizable() const -> bool;
|
|
||||||
auto setActive() -> type&;
|
|
||||||
auto setAlignment(Alignment alignment = {}) -> type&;
|
|
||||||
auto setBackgroundColor(Color color = {}) -> type&;
|
|
||||||
auto setEditable(bool editable = true) -> type&;
|
|
||||||
auto setExpandable(bool expandable = true) -> type&;
|
|
||||||
auto setForegroundColor(Color color = {}) -> type&;
|
|
||||||
auto setHorizontalAlignment(double alignment = 0.0) -> type&;
|
|
||||||
auto setIcon(const image& icon = {}) -> type&;
|
|
||||||
auto setResizable(bool resizable = true) -> type&;
|
|
||||||
auto setSortable(bool sortable = true) -> type&;
|
|
||||||
auto setText(const string& text = "") -> type&;
|
|
||||||
auto setVerticalAlignment(double alignment = 0.5) -> type&;
|
|
||||||
auto setVisible(bool visible = true) -> type&;
|
|
||||||
auto setWidth(signed width = 0) -> type&;
|
|
||||||
auto sortable() const -> bool;
|
|
||||||
auto text() const -> string;
|
|
||||||
auto verticalAlignment() const -> double;
|
|
||||||
auto width() const -> signed;
|
|
||||||
|
|
||||||
//private:
|
|
||||||
struct State {
|
|
||||||
Alignment alignment;
|
|
||||||
Color backgroundColor;
|
|
||||||
bool editable = false;
|
|
||||||
bool expandable = false;
|
|
||||||
Color foregroundColor;
|
|
||||||
double horizontalAlignment = 0.0;
|
|
||||||
image icon;
|
|
||||||
bool resizable = true;
|
|
||||||
bool sortable = false;
|
|
||||||
string text;
|
|
||||||
double verticalAlignment = 0.5;
|
|
||||||
bool visible = true;
|
|
||||||
signed width = 0;
|
|
||||||
} state;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(Hiro_ListView)
|
|
||||||
struct mListViewItem : mObject {
|
|
||||||
Declare(ListViewItem)
|
|
||||||
|
|
||||||
auto alignment() const -> Alignment;
|
|
||||||
auto append(sListViewCell cell) -> type&;
|
|
||||||
auto backgroundColor() const -> Color;
|
|
||||||
auto cell(unsigned position) const -> ListViewCell;
|
|
||||||
auto cellCount() const -> unsigned;
|
|
||||||
auto cells() const -> vector<ListViewCell>;
|
|
||||||
auto foregroundColor() const -> Color;
|
|
||||||
auto remove() -> type& override;
|
|
||||||
auto remove(sListViewCell cell) -> type&;
|
|
||||||
auto selected() const -> bool;
|
|
||||||
auto setAlignment(Alignment alignment = {}) -> type&;
|
|
||||||
auto setBackgroundColor(Color color = {}) -> type&;
|
|
||||||
auto setFocused() -> type& override;
|
|
||||||
auto setForegroundColor(Color color = {}) -> type&;
|
|
||||||
auto setParent(mObject* parent = nullptr, signed offset = -1) -> type& override;
|
|
||||||
auto setSelected(bool selected = true) -> type&;
|
|
||||||
|
|
||||||
//private:
|
|
||||||
struct State {
|
|
||||||
Alignment alignment;
|
|
||||||
Color backgroundColor;
|
|
||||||
vector<sListViewCell> cells;
|
|
||||||
Color foregroundColor;
|
|
||||||
bool selected = false;
|
|
||||||
} state;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(Hiro_ListView)
|
|
||||||
struct mListViewCell : mObject {
|
|
||||||
Declare(ListViewCell)
|
|
||||||
|
|
||||||
auto alignment(bool recursive = false) const -> Alignment;
|
|
||||||
auto backgroundColor(bool recursive = false) const -> Color;
|
|
||||||
auto checkable() const -> bool;
|
|
||||||
auto checked() const -> bool;
|
|
||||||
auto font(bool recursive = false) const -> Font;
|
|
||||||
auto foregroundColor(bool recursive = false) const -> Color;
|
|
||||||
auto icon() const -> image;
|
|
||||||
auto setAlignment(Alignment alignment = {}) -> type&;
|
|
||||||
auto setBackgroundColor(Color color = {}) -> type&;
|
|
||||||
auto setCheckable(bool checkable = true) -> type&;
|
|
||||||
auto setChecked(bool checked = true) -> type&;
|
|
||||||
auto setForegroundColor(Color color = {}) -> type&;
|
|
||||||
auto setIcon(const image& icon = {}) -> type&;
|
|
||||||
auto setText(const string& text = "") -> type&;
|
|
||||||
auto text() const -> string;
|
|
||||||
|
|
||||||
//private:
|
|
||||||
struct State {
|
|
||||||
Alignment alignment;
|
|
||||||
Color backgroundColor;
|
|
||||||
bool checkable = false;
|
|
||||||
bool checked = false;
|
|
||||||
Color foregroundColor;
|
|
||||||
image icon;
|
|
||||||
string text;
|
|
||||||
} state;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(Hiro_ProgressBar)
|
#if defined(Hiro_ProgressBar)
|
||||||
struct mProgressBar : mWidget {
|
struct mProgressBar : mWidget {
|
||||||
Declare(ProgressBar)
|
Declare(ProgressBar)
|
||||||
|
@ -1718,6 +1578,207 @@ struct mTabFrameItem : mObject {
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(Hiro_TableView)
|
||||||
|
struct mTableView : mWidget {
|
||||||
|
Declare(TableView)
|
||||||
|
using mObject::remove;
|
||||||
|
|
||||||
|
auto alignment() const -> Alignment;
|
||||||
|
auto append(sTableViewHeader column) -> type&;
|
||||||
|
auto append(sTableViewItem item) -> type&;
|
||||||
|
auto backgroundColor() const -> Color;
|
||||||
|
auto batchable() const -> bool;
|
||||||
|
auto batched() const -> vector<TableViewItem>;
|
||||||
|
auto bordered() const -> bool;
|
||||||
|
auto doActivate() const -> void;
|
||||||
|
auto doChange() const -> void;
|
||||||
|
auto doContext() const -> void;
|
||||||
|
auto doEdit(sTableViewCell cell) const -> void;
|
||||||
|
auto doSort(sTableViewColumn column) const -> void;
|
||||||
|
auto doToggle(sTableViewCell cell) const -> void;
|
||||||
|
auto foregroundColor() const -> Color;
|
||||||
|
auto header() const -> TableViewHeader;
|
||||||
|
auto item(unsigned position) const -> TableViewItem;
|
||||||
|
auto itemCount() const -> unsigned;
|
||||||
|
auto items() const -> vector<TableViewItem>;
|
||||||
|
auto onActivate(const function<void ()>& callback = {}) -> type&;
|
||||||
|
auto onChange(const function<void ()>& callback = {}) -> type&;
|
||||||
|
auto onContext(const function<void ()>& callback = {}) -> type&;
|
||||||
|
auto onEdit(const function<void (TableViewCell)>& callback = {}) -> type&;
|
||||||
|
auto onSort(const function<void (TableViewColumn)>& callback = {}) -> type&;
|
||||||
|
auto onToggle(const function<void (TableViewCell)>& callback = {}) -> type&;
|
||||||
|
auto remove(sTableViewHeader column) -> type&;
|
||||||
|
auto remove(sTableViewItem item) -> type&;
|
||||||
|
auto reset() -> type&;
|
||||||
|
auto resizeColumns() -> type&;
|
||||||
|
auto selected() const -> TableViewItem;
|
||||||
|
auto setAlignment(Alignment alignment = {}) -> type&;
|
||||||
|
auto setBackgroundColor(Color color = {}) -> type&;
|
||||||
|
auto setBatchable(bool batchable = true) -> type&;
|
||||||
|
auto setBordered(bool bordered = true) -> type&;
|
||||||
|
auto setForegroundColor(Color color = {}) -> type&;
|
||||||
|
auto setParent(mObject* parent = nullptr, signed offset = -1) -> type& override;
|
||||||
|
|
||||||
|
//private:
|
||||||
|
struct State {
|
||||||
|
unsigned activeColumn = 0;
|
||||||
|
Alignment alignment;
|
||||||
|
Color backgroundColor;
|
||||||
|
bool batchable = false;
|
||||||
|
bool bordered = false;
|
||||||
|
Color foregroundColor;
|
||||||
|
sTableViewHeader header;
|
||||||
|
vector<sTableViewItem> items;
|
||||||
|
function<void ()> onActivate;
|
||||||
|
function<void ()> onChange;
|
||||||
|
function<void ()> onContext;
|
||||||
|
function<void (TableViewCell)> onEdit;
|
||||||
|
function<void (TableViewColumn)> onSort;
|
||||||
|
function<void (TableViewCell)> onToggle;
|
||||||
|
} state;
|
||||||
|
|
||||||
|
auto destruct() -> void override;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(Hiro_TableView)
|
||||||
|
struct mTableViewHeader : mObject {
|
||||||
|
Declare(TableViewHeader)
|
||||||
|
|
||||||
|
auto append(sTableViewColumn column) -> type&;
|
||||||
|
auto column(unsigned position) const -> TableViewColumn;
|
||||||
|
auto columnCount() const -> unsigned;
|
||||||
|
auto columns() const -> vector<TableViewColumn>;
|
||||||
|
auto remove() -> type& override;
|
||||||
|
auto remove(sTableViewColumn column) -> type&;
|
||||||
|
auto reset() -> type&;
|
||||||
|
auto setParent(mObject* parent = nullptr, signed offset = -1) -> type& override;
|
||||||
|
|
||||||
|
//private:
|
||||||
|
struct State {
|
||||||
|
vector<sTableViewColumn> columns;
|
||||||
|
} state;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(Hiro_TableView)
|
||||||
|
struct mTableViewColumn : mObject {
|
||||||
|
Declare(TableViewColumn)
|
||||||
|
|
||||||
|
auto active() const -> bool;
|
||||||
|
auto alignment() const -> Alignment;
|
||||||
|
auto backgroundColor() const -> Color;
|
||||||
|
auto editable() const -> bool;
|
||||||
|
auto expandable() const -> bool;
|
||||||
|
auto foregroundColor() const -> Color;
|
||||||
|
auto horizontalAlignment() const -> double;
|
||||||
|
auto icon() const -> image;
|
||||||
|
auto remove() -> type& override;
|
||||||
|
auto resizable() const -> bool;
|
||||||
|
auto setActive() -> type&;
|
||||||
|
auto setAlignment(Alignment alignment = {}) -> type&;
|
||||||
|
auto setBackgroundColor(Color color = {}) -> type&;
|
||||||
|
auto setEditable(bool editable = true) -> type&;
|
||||||
|
auto setExpandable(bool expandable = true) -> type&;
|
||||||
|
auto setForegroundColor(Color color = {}) -> type&;
|
||||||
|
auto setHorizontalAlignment(double alignment = 0.0) -> type&;
|
||||||
|
auto setIcon(const image& icon = {}) -> type&;
|
||||||
|
auto setResizable(bool resizable = true) -> type&;
|
||||||
|
auto setSortable(bool sortable = true) -> type&;
|
||||||
|
auto setText(const string& text = "") -> type&;
|
||||||
|
auto setVerticalAlignment(double alignment = 0.5) -> type&;
|
||||||
|
auto setVisible(bool visible = true) -> type&;
|
||||||
|
auto setWidth(signed width = 0) -> type&;
|
||||||
|
auto sortable() const -> bool;
|
||||||
|
auto text() const -> string;
|
||||||
|
auto verticalAlignment() const -> double;
|
||||||
|
auto width() const -> signed;
|
||||||
|
|
||||||
|
//private:
|
||||||
|
struct State {
|
||||||
|
Alignment alignment;
|
||||||
|
Color backgroundColor;
|
||||||
|
bool editable = false;
|
||||||
|
bool expandable = false;
|
||||||
|
Color foregroundColor;
|
||||||
|
double horizontalAlignment = 0.0;
|
||||||
|
image icon;
|
||||||
|
bool resizable = true;
|
||||||
|
bool sortable = false;
|
||||||
|
string text;
|
||||||
|
double verticalAlignment = 0.5;
|
||||||
|
bool visible = true;
|
||||||
|
signed width = 0;
|
||||||
|
} state;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(Hiro_TableView)
|
||||||
|
struct mTableViewItem : mObject {
|
||||||
|
Declare(TableViewItem)
|
||||||
|
|
||||||
|
auto alignment() const -> Alignment;
|
||||||
|
auto append(sTableViewCell cell) -> type&;
|
||||||
|
auto backgroundColor() const -> Color;
|
||||||
|
auto cell(unsigned position) const -> TableViewCell;
|
||||||
|
auto cellCount() const -> unsigned;
|
||||||
|
auto cells() const -> vector<TableViewCell>;
|
||||||
|
auto foregroundColor() const -> Color;
|
||||||
|
auto remove() -> type& override;
|
||||||
|
auto remove(sTableViewCell cell) -> type&;
|
||||||
|
auto reset() -> type&;
|
||||||
|
auto selected() const -> bool;
|
||||||
|
auto setAlignment(Alignment alignment = {}) -> type&;
|
||||||
|
auto setBackgroundColor(Color color = {}) -> type&;
|
||||||
|
auto setFocused() -> type& override;
|
||||||
|
auto setForegroundColor(Color color = {}) -> type&;
|
||||||
|
auto setParent(mObject* parent = nullptr, signed offset = -1) -> type& override;
|
||||||
|
auto setSelected(bool selected = true) -> type&;
|
||||||
|
|
||||||
|
//private:
|
||||||
|
struct State {
|
||||||
|
Alignment alignment;
|
||||||
|
Color backgroundColor;
|
||||||
|
vector<sTableViewCell> cells;
|
||||||
|
Color foregroundColor;
|
||||||
|
bool selected = false;
|
||||||
|
} state;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(Hiro_TableView)
|
||||||
|
struct mTableViewCell : mObject {
|
||||||
|
Declare(TableViewCell)
|
||||||
|
|
||||||
|
auto alignment(bool recursive = false) const -> Alignment;
|
||||||
|
auto backgroundColor(bool recursive = false) const -> Color;
|
||||||
|
auto checkable() const -> bool;
|
||||||
|
auto checked() const -> bool;
|
||||||
|
auto font(bool recursive = false) const -> Font;
|
||||||
|
auto foregroundColor(bool recursive = false) const -> Color;
|
||||||
|
auto icon() const -> image;
|
||||||
|
auto setAlignment(Alignment alignment = {}) -> type&;
|
||||||
|
auto setBackgroundColor(Color color = {}) -> type&;
|
||||||
|
auto setCheckable(bool checkable = true) -> type&;
|
||||||
|
auto setChecked(bool checked = true) -> type&;
|
||||||
|
auto setForegroundColor(Color color = {}) -> type&;
|
||||||
|
auto setIcon(const image& icon = {}) -> type&;
|
||||||
|
auto setText(const string& text = "") -> type&;
|
||||||
|
auto text() const -> string;
|
||||||
|
|
||||||
|
//private:
|
||||||
|
struct State {
|
||||||
|
Alignment alignment;
|
||||||
|
Color backgroundColor;
|
||||||
|
bool checkable = false;
|
||||||
|
bool checked = false;
|
||||||
|
Color foregroundColor;
|
||||||
|
image icon;
|
||||||
|
string text;
|
||||||
|
} state;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(Hiro_TextEdit)
|
#if defined(Hiro_TextEdit)
|
||||||
struct mTextEdit : mWidget {
|
struct mTextEdit : mWidget {
|
||||||
Declare(TextEdit)
|
Declare(TextEdit)
|
||||||
|
|
|
@ -41,7 +41,7 @@ auto mLayout::remove(sSizable sizable) -> type& {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mLayout::reset() -> type& {
|
auto mLayout::reset() -> type& {
|
||||||
while(state.sizables) remove(state.sizables.last());
|
while(state.sizables) remove(state.sizables.right());
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ auto mMenuBar::remove(sMenu menu) -> type& {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mMenuBar::reset() -> type& {
|
auto mMenuBar::reset() -> type& {
|
||||||
while(state.menus) remove(state.menus.last());
|
while(state.menus) remove(state.menus.right());
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,6 +100,16 @@ auto mObject::parentComboButton(bool recursive) const -> mComboButton* {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(Hiro_ComboEdit)
|
||||||
|
auto mObject::parentComboEdit(bool recursive) const -> mComboEdit* {
|
||||||
|
if(auto comboEdit = dynamic_cast<mComboEdit*>(parent())) return comboEdit;
|
||||||
|
if(recursive) {
|
||||||
|
if(auto object = parent()) return object->parentComboEdit(true);
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(Hiro_Frame)
|
#if defined(Hiro_Frame)
|
||||||
auto mObject::parentFrame(bool recursive) const -> mFrame* {
|
auto mObject::parentFrame(bool recursive) const -> mFrame* {
|
||||||
if(auto frame = dynamic_cast<mFrame*>(parent())) return frame;
|
if(auto frame = dynamic_cast<mFrame*>(parent())) return frame;
|
||||||
|
@ -130,36 +140,6 @@ auto mObject::parentLayout(bool recursive) const -> mLayout* {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(Hiro_ListView)
|
|
||||||
auto mObject::parentListView(bool recursive) const -> mListView* {
|
|
||||||
if(auto listView = dynamic_cast<mListView*>(parent())) return listView;
|
|
||||||
if(recursive) {
|
|
||||||
if(auto object = parent()) return object->parentListView(true);
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(Hiro_ListView)
|
|
||||||
auto mObject::parentListViewHeader(bool recursive) const -> mListViewHeader* {
|
|
||||||
if(auto listViewHeader = dynamic_cast<mListViewHeader*>(parent())) return listViewHeader;
|
|
||||||
if(recursive) {
|
|
||||||
if(auto object = parent()) return object->parentListViewHeader(true);
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(Hiro_ListView)
|
|
||||||
auto mObject::parentListViewItem(bool recursive) const -> mListViewItem* {
|
|
||||||
if(auto listViewItem = dynamic_cast<mListViewItem*>(parent())) return listViewItem;
|
|
||||||
if(recursive) {
|
|
||||||
if(auto object = parent()) return object->parentListViewItem(true);
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(Hiro_Menu)
|
#if defined(Hiro_Menu)
|
||||||
auto mObject::parentMenu(bool recursive) const -> mMenu* {
|
auto mObject::parentMenu(bool recursive) const -> mMenu* {
|
||||||
if(auto menu = dynamic_cast<mMenu*>(parent())) return menu;
|
if(auto menu = dynamic_cast<mMenu*>(parent())) return menu;
|
||||||
|
@ -220,6 +200,36 @@ auto mObject::parentTabFrameItem(bool recursive) const -> mTabFrameItem* {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(Hiro_TableView)
|
||||||
|
auto mObject::parentTableView(bool recursive) const -> mTableView* {
|
||||||
|
if(auto tableView = dynamic_cast<mTableView*>(parent())) return tableView;
|
||||||
|
if(recursive) {
|
||||||
|
if(auto object = parent()) return object->parentTableView(true);
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(Hiro_TableView)
|
||||||
|
auto mObject::parentTableViewHeader(bool recursive) const -> mTableViewHeader* {
|
||||||
|
if(auto tableViewHeader = dynamic_cast<mTableViewHeader*>(parent())) return tableViewHeader;
|
||||||
|
if(recursive) {
|
||||||
|
if(auto object = parent()) return object->parentTableViewHeader(true);
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(Hiro_TableView)
|
||||||
|
auto mObject::parentTableViewItem(bool recursive) const -> mTableViewItem* {
|
||||||
|
if(auto tableViewItem = dynamic_cast<mTableViewItem*>(parent())) return tableViewItem;
|
||||||
|
if(recursive) {
|
||||||
|
if(auto object = parent()) return object->parentTableViewItem(true);
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(Hiro_TreeView)
|
#if defined(Hiro_TreeView)
|
||||||
auto mObject::parentTreeView(bool recursive) const -> mTreeView* {
|
auto mObject::parentTreeView(bool recursive) const -> mTreeView* {
|
||||||
if(auto treeView = dynamic_cast<mTreeView*>(parent())) return treeView;
|
if(auto treeView = dynamic_cast<mTreeView*>(parent())) return treeView;
|
||||||
|
|
|
@ -45,7 +45,7 @@ auto mPopupMenu::remove(sAction action) -> type& {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mPopupMenu::reset() -> type& {
|
auto mPopupMenu::reset() -> type& {
|
||||||
while(state.actions) remove(state.actions.last());
|
while(state.actions) remove(state.actions.right());
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
300
core/shared.hpp
300
core/shared.hpp
|
@ -86,7 +86,7 @@ struct Group : sGroup {
|
||||||
template<typename T = Object> auto objects() const -> vector<T> {
|
template<typename T = Object> auto objects() const -> vector<T> {
|
||||||
vector<T> objects;
|
vector<T> objects;
|
||||||
for(auto object : self().objects()) {
|
for(auto object : self().objects()) {
|
||||||
if(auto cast = object.cast<T>()) objects.append(cast);
|
if(auto casted = object.cast<T>()) objects.append(casted);
|
||||||
}
|
}
|
||||||
return objects;
|
return objects;
|
||||||
}
|
}
|
||||||
|
@ -321,6 +321,42 @@ struct ComboButton : sComboButton {
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(Hiro_ComboEdit)
|
||||||
|
struct ComboEditItem : sComboEditItem {
|
||||||
|
DeclareSharedObject(ComboEditItem)
|
||||||
|
using internalType = mComboEditItem;
|
||||||
|
|
||||||
|
auto icon() const { return self().icon(); }
|
||||||
|
auto setIcon(const image& icon = {}) { return self().setIcon(icon), *this; }
|
||||||
|
auto setText(const string& text = "") { return self().setText(text), *this; }
|
||||||
|
auto text() const { return self().text(); }
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(Hiro_ComboEdit)
|
||||||
|
struct ComboEdit : sComboEdit {
|
||||||
|
DeclareSharedWidget(ComboEdit)
|
||||||
|
using internalType = mComboEdit;
|
||||||
|
|
||||||
|
auto append(sComboEditItem item) { return self().append(item), *this; }
|
||||||
|
auto backgroundColor() const { return self().backgroundColor(); }
|
||||||
|
auto doActivate() const { return self().doActivate(); }
|
||||||
|
auto doChange() const { return self().doChange(); }
|
||||||
|
auto foregroundColor() const { return self().foregroundColor(); }
|
||||||
|
auto item(uint position) const { return self().item(position); }
|
||||||
|
auto itemCount() const { return self().itemCount(); }
|
||||||
|
auto items() const { return self().items(); }
|
||||||
|
auto onActivate(const function<void ()>& callback = {}) { return self().onActivate(callback), *this; }
|
||||||
|
auto onChange(const function<void ()>& callback = {}) { return self().onChange(callback), *this; }
|
||||||
|
auto remove(sComboEditItem item) { return self().remove(item), *this; }
|
||||||
|
auto reset() { return self().reset(), *this; }
|
||||||
|
auto setBackgroundColor(Color color = {}) { return self().setBackgroundColor(color), *this; }
|
||||||
|
auto setForegroundColor(Color color = {}) { return self().setForegroundColor(color), *this; }
|
||||||
|
auto setText(const string& text = "") { return self().setText(text), *this; }
|
||||||
|
auto text() const { return self().text(); }
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(Hiro_Console)
|
#if defined(Hiro_Console)
|
||||||
struct Console : sConsole {
|
struct Console : sConsole {
|
||||||
DeclareSharedWidget(Console)
|
DeclareSharedWidget(Console)
|
||||||
|
@ -485,136 +521,6 @@ struct LineEdit : sLineEdit {
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(Hiro_ListView)
|
|
||||||
struct ListViewColumn : sListViewColumn {
|
|
||||||
DeclareSharedObject(ListViewColumn)
|
|
||||||
using internalType = mListViewColumn;
|
|
||||||
|
|
||||||
auto active() const { return self().active(); }
|
|
||||||
auto alignment() const { return self().alignment(); }
|
|
||||||
auto backgroundColor() const { return self().backgroundColor(); }
|
|
||||||
auto editable() const { return self().editable(); }
|
|
||||||
auto expandable() const { return self().expandable(); }
|
|
||||||
auto foregroundColor() const { return self().foregroundColor(); }
|
|
||||||
auto horizontalAlignment() const { return self().horizontalAlignment(); }
|
|
||||||
auto icon() const { return self().icon(); }
|
|
||||||
auto resizable() const { return self().resizable(); }
|
|
||||||
auto setActive() { return self().setActive(), *this; }
|
|
||||||
auto setAlignment(Alignment alignment = {}) { return self().setAlignment(alignment), *this; }
|
|
||||||
auto setBackgroundColor(Color color = {}) { return self().setBackgroundColor(color), *this; }
|
|
||||||
auto setEditable(bool editable = true) { return self().setEditable(editable), *this; }
|
|
||||||
auto setExpandable(bool expandable = true) { return self().setExpandable(expandable), *this; }
|
|
||||||
auto setForegroundColor(Color color = {}) { return self().setForegroundColor(color), *this; }
|
|
||||||
auto setIcon(const image& icon = {}) { return self().setIcon(icon), *this; }
|
|
||||||
auto setResizable(bool resizable = true) { return self().setResizable(resizable), *this; }
|
|
||||||
auto setSortable(bool sortable = true) { return self().setSortable(sortable), *this; }
|
|
||||||
auto setText(const string& text = "") { return self().setText(text), *this; }
|
|
||||||
auto setWidth(signed width = 0) { return self().setWidth(width), *this; }
|
|
||||||
auto sortable() const { return self().sortable(); }
|
|
||||||
auto text() const { return self().text(); }
|
|
||||||
auto verticalAlignment() const { return self().verticalAlignment(); }
|
|
||||||
auto width() const { return self().width(); }
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(Hiro_ListView)
|
|
||||||
struct ListViewHeader : sListViewHeader {
|
|
||||||
DeclareSharedObject(ListViewHeader)
|
|
||||||
using internalType = mListViewHeader;
|
|
||||||
|
|
||||||
auto append(sListViewColumn column) { return self().append(column), *this; }
|
|
||||||
auto column(unsigned position) const { return self().column(position); }
|
|
||||||
auto columnCount() const { return self().columnCount(); }
|
|
||||||
auto columns() const { return self().columns(); }
|
|
||||||
auto remove(sListViewColumn column) { return self().remove(column), *this; }
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(Hiro_ListView)
|
|
||||||
struct ListViewCell : sListViewCell {
|
|
||||||
DeclareSharedObject(ListViewCell)
|
|
||||||
using internalType = mListViewCell;
|
|
||||||
|
|
||||||
auto alignment() const { return self().alignment(); }
|
|
||||||
auto backgroundColor() const { return self().backgroundColor(); }
|
|
||||||
auto checkable() const { return self().checkable(); }
|
|
||||||
auto checked() const { return self().checked(); }
|
|
||||||
auto foregroundColor() const { return self().foregroundColor(); }
|
|
||||||
auto icon() const { return self().icon(); }
|
|
||||||
auto setAlignment(Alignment alignment = {}) { return self().setAlignment(alignment), *this; }
|
|
||||||
auto setBackgroundColor(Color color = {}) { return self().setBackgroundColor(color), *this; }
|
|
||||||
auto setCheckable(bool checkable = true) const { return self().setCheckable(checkable), *this; }
|
|
||||||
auto setChecked(bool checked = true) const { return self().setChecked(checked), *this; }
|
|
||||||
auto setForegroundColor(Color color = {}) { return self().setForegroundColor(color), *this; }
|
|
||||||
auto setIcon(const image& icon = {}) { return self().setIcon(icon), *this; }
|
|
||||||
auto setText(const string& text = "") { return self().setText(text), *this; }
|
|
||||||
auto text() const { return self().text(); }
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(Hiro_ListView)
|
|
||||||
struct ListViewItem : sListViewItem {
|
|
||||||
DeclareSharedObject(ListViewItem)
|
|
||||||
using internalType = mListViewItem;
|
|
||||||
|
|
||||||
auto alignment() const { return self().alignment(); }
|
|
||||||
auto append(sListViewCell cell) { return self().append(cell), *this; }
|
|
||||||
auto backgroundColor() const { return self().backgroundColor(); }
|
|
||||||
auto cell(unsigned position) const { return self().cell(position); }
|
|
||||||
auto cellCount() const { return self().cellCount(); }
|
|
||||||
auto cells() const { return self().cells(); }
|
|
||||||
auto foregroundColor() const { return self().foregroundColor(); }
|
|
||||||
auto remove(sListViewCell cell) { return self().remove(cell), *this; }
|
|
||||||
auto selected() const { return self().selected(); }
|
|
||||||
auto setAlignment(Alignment alignment = {}) { return self().setAlignment(alignment), *this; }
|
|
||||||
auto setBackgroundColor(Color color = {}) { return self().setBackgroundColor(color), *this; }
|
|
||||||
auto setForegroundColor(Color color = {}) { return self().setForegroundColor(color), *this; }
|
|
||||||
auto setSelected(bool selected = true) { return self().setSelected(selected), *this; }
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(Hiro_ListView)
|
|
||||||
struct ListView : sListView {
|
|
||||||
DeclareSharedWidget(ListView)
|
|
||||||
using internalType = mListView;
|
|
||||||
|
|
||||||
auto alignment() const { return self().alignment(); }
|
|
||||||
auto append(sListViewHeader header) { return self().append(header), *this; }
|
|
||||||
auto append(sListViewItem item) { return self().append(item), *this; }
|
|
||||||
auto backgroundColor() const { return self().backgroundColor(); }
|
|
||||||
auto batchable() const { return self().batchable(); }
|
|
||||||
auto batched() const { return self().batched(); }
|
|
||||||
auto bordered() const { return self().bordered(); }
|
|
||||||
auto doActivate() const { return self().doActivate(); }
|
|
||||||
auto doChange() const { return self().doChange(); }
|
|
||||||
auto doContext() const { return self().doContext(); }
|
|
||||||
auto doEdit(sListViewCell cell) const { return self().doEdit(cell); }
|
|
||||||
auto doSort(sListViewColumn column) const { return self().doSort(column); }
|
|
||||||
auto doToggle(sListViewCell cell) const { return self().doToggle(cell); }
|
|
||||||
auto foregroundColor() const { return self().foregroundColor(); }
|
|
||||||
auto header() const { return self().header(); }
|
|
||||||
auto item(unsigned position) const { return self().item(position); }
|
|
||||||
auto itemCount() const { return self().itemCount(); }
|
|
||||||
auto items() const { return self().items(); }
|
|
||||||
auto onActivate(const function<void ()>& callback = {}) { return self().onActivate(callback), *this; }
|
|
||||||
auto onChange(const function<void ()>& callback = {}) { return self().onChange(callback), *this; }
|
|
||||||
auto onContext(const function<void ()>& callback = {}) { return self().onContext(callback), *this; }
|
|
||||||
auto onEdit(const function<void (ListViewCell)>& callback = {}) { return self().onEdit(callback), *this; }
|
|
||||||
auto onSort(const function<void (ListViewColumn)>& callback = {}) { return self().onSort(callback), *this; }
|
|
||||||
auto onToggle(const function<void (ListViewCell)>& callback = {}) { return self().onToggle(callback), *this; }
|
|
||||||
auto remove(sListViewHeader header) { return self().remove(header), *this; }
|
|
||||||
auto remove(sListViewItem item) { return self().remove(item), *this; }
|
|
||||||
auto reset() { return self().reset(), *this; }
|
|
||||||
auto resizeColumns() { return self().resizeColumns(), *this; }
|
|
||||||
auto selected() const { return self().selected(); }
|
|
||||||
auto setAlignment(Alignment alignment = {}) { return self().setAlignment(alignment), *this; }
|
|
||||||
auto setBackgroundColor(Color color = {}) { return self().setBackgroundColor(color), *this; }
|
|
||||||
auto setBatchable(bool batchable = true) { return self().setBatchable(batchable), *this; }
|
|
||||||
auto setBordered(bool bordered = true) { return self().setBordered(bordered), *this; }
|
|
||||||
auto setForegroundColor(Color color = {}) { return self().setForegroundColor(color), *this; }
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(Hiro_ProgressBar)
|
#if defined(Hiro_ProgressBar)
|
||||||
struct ProgressBar : sProgressBar {
|
struct ProgressBar : sProgressBar {
|
||||||
DeclareSharedWidget(ProgressBar)
|
DeclareSharedWidget(ProgressBar)
|
||||||
|
@ -722,6 +628,138 @@ struct TabFrame : sTabFrame {
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(Hiro_TableView)
|
||||||
|
struct TableViewColumn : sTableViewColumn {
|
||||||
|
DeclareSharedObject(TableViewColumn)
|
||||||
|
using internalType = mTableViewColumn;
|
||||||
|
|
||||||
|
auto active() const { return self().active(); }
|
||||||
|
auto alignment() const { return self().alignment(); }
|
||||||
|
auto backgroundColor() const { return self().backgroundColor(); }
|
||||||
|
auto editable() const { return self().editable(); }
|
||||||
|
auto expandable() const { return self().expandable(); }
|
||||||
|
auto foregroundColor() const { return self().foregroundColor(); }
|
||||||
|
auto horizontalAlignment() const { return self().horizontalAlignment(); }
|
||||||
|
auto icon() const { return self().icon(); }
|
||||||
|
auto resizable() const { return self().resizable(); }
|
||||||
|
auto setActive() { return self().setActive(), *this; }
|
||||||
|
auto setAlignment(Alignment alignment = {}) { return self().setAlignment(alignment), *this; }
|
||||||
|
auto setBackgroundColor(Color color = {}) { return self().setBackgroundColor(color), *this; }
|
||||||
|
auto setEditable(bool editable = true) { return self().setEditable(editable), *this; }
|
||||||
|
auto setExpandable(bool expandable = true) { return self().setExpandable(expandable), *this; }
|
||||||
|
auto setForegroundColor(Color color = {}) { return self().setForegroundColor(color), *this; }
|
||||||
|
auto setIcon(const image& icon = {}) { return self().setIcon(icon), *this; }
|
||||||
|
auto setResizable(bool resizable = true) { return self().setResizable(resizable), *this; }
|
||||||
|
auto setSortable(bool sortable = true) { return self().setSortable(sortable), *this; }
|
||||||
|
auto setText(const string& text = "") { return self().setText(text), *this; }
|
||||||
|
auto setWidth(signed width = 0) { return self().setWidth(width), *this; }
|
||||||
|
auto sortable() const { return self().sortable(); }
|
||||||
|
auto text() const { return self().text(); }
|
||||||
|
auto verticalAlignment() const { return self().verticalAlignment(); }
|
||||||
|
auto width() const { return self().width(); }
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(Hiro_TableView)
|
||||||
|
struct TableViewHeader : sTableViewHeader {
|
||||||
|
DeclareSharedObject(TableViewHeader)
|
||||||
|
using internalType = mTableViewHeader;
|
||||||
|
|
||||||
|
auto append(sTableViewColumn column) { return self().append(column), *this; }
|
||||||
|
auto column(unsigned position) const { return self().column(position); }
|
||||||
|
auto columnCount() const { return self().columnCount(); }
|
||||||
|
auto columns() const { return self().columns(); }
|
||||||
|
auto remove(sTableViewColumn column) { return self().remove(column), *this; }
|
||||||
|
auto reset() { return self().reset(), *this; }
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(Hiro_TableView)
|
||||||
|
struct TableViewCell : sTableViewCell {
|
||||||
|
DeclareSharedObject(TableViewCell)
|
||||||
|
using internalType = mTableViewCell;
|
||||||
|
|
||||||
|
auto alignment() const { return self().alignment(); }
|
||||||
|
auto backgroundColor() const { return self().backgroundColor(); }
|
||||||
|
auto checkable() const { return self().checkable(); }
|
||||||
|
auto checked() const { return self().checked(); }
|
||||||
|
auto foregroundColor() const { return self().foregroundColor(); }
|
||||||
|
auto icon() const { return self().icon(); }
|
||||||
|
auto setAlignment(Alignment alignment = {}) { return self().setAlignment(alignment), *this; }
|
||||||
|
auto setBackgroundColor(Color color = {}) { return self().setBackgroundColor(color), *this; }
|
||||||
|
auto setCheckable(bool checkable = true) const { return self().setCheckable(checkable), *this; }
|
||||||
|
auto setChecked(bool checked = true) const { return self().setChecked(checked), *this; }
|
||||||
|
auto setForegroundColor(Color color = {}) { return self().setForegroundColor(color), *this; }
|
||||||
|
auto setIcon(const image& icon = {}) { return self().setIcon(icon), *this; }
|
||||||
|
auto setText(const string& text = "") { return self().setText(text), *this; }
|
||||||
|
auto text() const { return self().text(); }
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(Hiro_TableView)
|
||||||
|
struct TableViewItem : sTableViewItem {
|
||||||
|
DeclareSharedObject(TableViewItem)
|
||||||
|
using internalType = mTableViewItem;
|
||||||
|
|
||||||
|
auto alignment() const { return self().alignment(); }
|
||||||
|
auto append(sTableViewCell cell) { return self().append(cell), *this; }
|
||||||
|
auto backgroundColor() const { return self().backgroundColor(); }
|
||||||
|
auto cell(unsigned position) const { return self().cell(position); }
|
||||||
|
auto cellCount() const { return self().cellCount(); }
|
||||||
|
auto cells() const { return self().cells(); }
|
||||||
|
auto foregroundColor() const { return self().foregroundColor(); }
|
||||||
|
auto remove(sTableViewCell cell) { return self().remove(cell), *this; }
|
||||||
|
auto reset() { return self().reset(), *this; }
|
||||||
|
auto selected() const { return self().selected(); }
|
||||||
|
auto setAlignment(Alignment alignment = {}) { return self().setAlignment(alignment), *this; }
|
||||||
|
auto setBackgroundColor(Color color = {}) { return self().setBackgroundColor(color), *this; }
|
||||||
|
auto setForegroundColor(Color color = {}) { return self().setForegroundColor(color), *this; }
|
||||||
|
auto setSelected(bool selected = true) { return self().setSelected(selected), *this; }
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(Hiro_TableView)
|
||||||
|
struct TableView : sTableView {
|
||||||
|
DeclareSharedWidget(TableView)
|
||||||
|
using internalType = mTableView;
|
||||||
|
|
||||||
|
auto alignment() const { return self().alignment(); }
|
||||||
|
auto append(sTableViewHeader header) { return self().append(header), *this; }
|
||||||
|
auto append(sTableViewItem item) { return self().append(item), *this; }
|
||||||
|
auto backgroundColor() const { return self().backgroundColor(); }
|
||||||
|
auto batchable() const { return self().batchable(); }
|
||||||
|
auto batched() const { return self().batched(); }
|
||||||
|
auto bordered() const { return self().bordered(); }
|
||||||
|
auto doActivate() const { return self().doActivate(); }
|
||||||
|
auto doChange() const { return self().doChange(); }
|
||||||
|
auto doContext() const { return self().doContext(); }
|
||||||
|
auto doEdit(sTableViewCell cell) const { return self().doEdit(cell); }
|
||||||
|
auto doSort(sTableViewColumn column) const { return self().doSort(column); }
|
||||||
|
auto doToggle(sTableViewCell cell) const { return self().doToggle(cell); }
|
||||||
|
auto foregroundColor() const { return self().foregroundColor(); }
|
||||||
|
auto header() const { return self().header(); }
|
||||||
|
auto item(unsigned position) const { return self().item(position); }
|
||||||
|
auto itemCount() const { return self().itemCount(); }
|
||||||
|
auto items() const { return self().items(); }
|
||||||
|
auto onActivate(const function<void ()>& callback = {}) { return self().onActivate(callback), *this; }
|
||||||
|
auto onChange(const function<void ()>& callback = {}) { return self().onChange(callback), *this; }
|
||||||
|
auto onContext(const function<void ()>& callback = {}) { return self().onContext(callback), *this; }
|
||||||
|
auto onEdit(const function<void (TableViewCell)>& callback = {}) { return self().onEdit(callback), *this; }
|
||||||
|
auto onSort(const function<void (TableViewColumn)>& callback = {}) { return self().onSort(callback), *this; }
|
||||||
|
auto onToggle(const function<void (TableViewCell)>& callback = {}) { return self().onToggle(callback), *this; }
|
||||||
|
auto remove(sTableViewHeader header) { return self().remove(header), *this; }
|
||||||
|
auto remove(sTableViewItem item) { return self().remove(item), *this; }
|
||||||
|
auto reset() { return self().reset(), *this; }
|
||||||
|
auto resizeColumns() { return self().resizeColumns(), *this; }
|
||||||
|
auto selected() const { return self().selected(); }
|
||||||
|
auto setAlignment(Alignment alignment = {}) { return self().setAlignment(alignment), *this; }
|
||||||
|
auto setBackgroundColor(Color color = {}) { return self().setBackgroundColor(color), *this; }
|
||||||
|
auto setBatchable(bool batchable = true) { return self().setBatchable(batchable), *this; }
|
||||||
|
auto setBordered(bool bordered = true) { return self().setBordered(bordered), *this; }
|
||||||
|
auto setForegroundColor(Color color = {}) { return self().setForegroundColor(color), *this; }
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(Hiro_TextEdit)
|
#if defined(Hiro_TextEdit)
|
||||||
struct TextEdit : sTextEdit {
|
struct TextEdit : sTextEdit {
|
||||||
DeclareSharedWidget(TextEdit)
|
DeclareSharedWidget(TextEdit)
|
||||||
|
|
34
core/widget/combo-edit-item.cpp
Normal file
34
core/widget/combo-edit-item.cpp
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
#if defined(Hiro_ComboEdit)
|
||||||
|
|
||||||
|
auto mComboEditItem::allocate() -> pObject* {
|
||||||
|
return new pComboEditItem(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
auto mComboEditItem::icon() const -> image {
|
||||||
|
return state.icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mComboEditItem::remove() -> type& {
|
||||||
|
if(auto comboEdit = parentComboEdit()) comboEdit->remove(*this);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mComboEditItem::setIcon(const image& icon) -> type& {
|
||||||
|
state.icon = icon;
|
||||||
|
signal(setIcon, icon);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mComboEditItem::setText(const string& text) -> type& {
|
||||||
|
state.text = text;
|
||||||
|
signal(setText, text);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mComboEditItem::text() const -> string {
|
||||||
|
return state.text;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
107
core/widget/combo-edit.cpp
Normal file
107
core/widget/combo-edit.cpp
Normal file
|
@ -0,0 +1,107 @@
|
||||||
|
#if defined(Hiro_ComboEdit)
|
||||||
|
|
||||||
|
auto mComboEdit::allocate() -> pObject* {
|
||||||
|
return new pComboEdit(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mComboEdit::destruct() -> void {
|
||||||
|
mWidget::destruct();
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
auto mComboEdit::append(sComboEditItem item) -> type& {
|
||||||
|
state.items.append(item);
|
||||||
|
item->setParent(this, itemCount() - 1);
|
||||||
|
signal(append, item);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mComboEdit::backgroundColor() const -> Color {
|
||||||
|
return state.backgroundColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mComboEdit::doActivate() const -> void {
|
||||||
|
if(state.onActivate) return state.onActivate();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mComboEdit::doChange() const -> void {
|
||||||
|
if(state.onChange) return state.onChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mComboEdit::foregroundColor() const -> Color {
|
||||||
|
return state.foregroundColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mComboEdit::item(uint position) const -> ComboEditItem {
|
||||||
|
if(position < itemCount()) return state.items[position];
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mComboEdit::itemCount() const -> uint {
|
||||||
|
return state.items.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mComboEdit::items() const -> vector<ComboEditItem> {
|
||||||
|
vector<ComboEditItem> items;
|
||||||
|
for(auto& item : state.items) items.append(item);
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mComboEdit::onActivate(const function<void ()>& callback) -> type& {
|
||||||
|
state.onActivate = callback;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mComboEdit::onChange(const function<void ()>& callback) -> type& {
|
||||||
|
state.onChange = callback;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mComboEdit::remove(sComboEditItem item) -> type& {
|
||||||
|
signal(remove, item);
|
||||||
|
state.items.remove(item->offset());
|
||||||
|
for(auto n : range(item->offset(), itemCount())) {
|
||||||
|
state.items[n]->adjustOffset(-1);
|
||||||
|
}
|
||||||
|
item->setParent();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mComboEdit::reset() -> type& {
|
||||||
|
signal(reset);
|
||||||
|
for(auto& item : state.items) item->setParent();
|
||||||
|
state.items.reset();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mComboEdit::setBackgroundColor(Color color) -> type& {
|
||||||
|
state.backgroundColor = color;
|
||||||
|
signal(setBackgroundColor, color);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mComboEdit::setForegroundColor(Color color) -> type& {
|
||||||
|
state.foregroundColor = color;
|
||||||
|
signal(setForegroundColor, color);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mComboEdit::setParent(mObject* parent, int offset) -> type& {
|
||||||
|
for(auto& item : state.items) item->destruct();
|
||||||
|
mObject::setParent(parent, offset);
|
||||||
|
for(auto& item : state.items) item->setParent(this, item->offset());
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mComboEdit::setText(const string& text) -> type& {
|
||||||
|
state.text = text;
|
||||||
|
signal(setText, text);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mComboEdit::text() const -> string {
|
||||||
|
return state.text;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,153 +0,0 @@
|
||||||
#if defined(Hiro_ListView)
|
|
||||||
|
|
||||||
auto mListViewColumn::allocate() -> pObject* {
|
|
||||||
return new pListViewColumn(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
auto mListViewColumn::active() const -> bool {
|
|
||||||
if(auto listView = parentListView()) return listView->state.activeColumn == offset();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewColumn::alignment() const -> Alignment {
|
|
||||||
return state.alignment;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewColumn::backgroundColor() const -> Color {
|
|
||||||
return state.backgroundColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewColumn::editable() const -> bool {
|
|
||||||
return state.editable;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewColumn::expandable() const -> bool {
|
|
||||||
return state.expandable;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewColumn::foregroundColor() const -> Color {
|
|
||||||
return state.foregroundColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewColumn::horizontalAlignment() const -> double {
|
|
||||||
return state.horizontalAlignment;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewColumn::icon() const -> image {
|
|
||||||
return state.icon;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewColumn::remove() -> type& {
|
|
||||||
if(auto listView = parentListViewHeader()) listView->remove(*this);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewColumn::resizable() const -> bool {
|
|
||||||
return state.resizable;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewColumn::setActive() -> type& {
|
|
||||||
if(auto listView = parentListView()) listView->state.activeColumn = offset();
|
|
||||||
signal(setActive);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewColumn::setAlignment(Alignment alignment) -> type& {
|
|
||||||
state.alignment = alignment;
|
|
||||||
signal(setAlignment, alignment);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewColumn::setBackgroundColor(Color color) -> type& {
|
|
||||||
state.backgroundColor = color;
|
|
||||||
signal(setBackgroundColor, color);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewColumn::setEditable(bool editable) -> type& {
|
|
||||||
state.editable = editable;
|
|
||||||
signal(setEditable, editable);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewColumn::setExpandable(bool expandable) -> type& {
|
|
||||||
state.expandable = expandable;
|
|
||||||
signal(setExpandable, expandable);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewColumn::setForegroundColor(Color color) -> type& {
|
|
||||||
state.foregroundColor = color;
|
|
||||||
signal(setForegroundColor, color);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewColumn::setHorizontalAlignment(double alignment) -> type& {
|
|
||||||
alignment = max(0.0, min(1.0, alignment));
|
|
||||||
state.horizontalAlignment = alignment;
|
|
||||||
signal(setHorizontalAlignment, alignment);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewColumn::setIcon(const image& icon) -> type& {
|
|
||||||
state.icon = icon;
|
|
||||||
signal(setIcon, icon);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewColumn::setResizable(bool resizable) -> type& {
|
|
||||||
state.resizable = resizable;
|
|
||||||
signal(setResizable, resizable);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewColumn::setSortable(bool sortable) -> type& {
|
|
||||||
state.sortable = sortable;
|
|
||||||
signal(setSortable, sortable);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewColumn::setText(const string& text) -> type& {
|
|
||||||
state.text = text;
|
|
||||||
signal(setText, text);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewColumn::setVerticalAlignment(double alignment) -> type& {
|
|
||||||
alignment = max(0.0, min(1.0, alignment));
|
|
||||||
state.verticalAlignment = alignment;
|
|
||||||
signal(setVerticalAlignment, alignment);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewColumn::setVisible(bool visible) -> type& {
|
|
||||||
state.visible = visible;
|
|
||||||
signal(setVisible, visible);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewColumn::setWidth(signed width) -> type& {
|
|
||||||
state.width = max(0, width);
|
|
||||||
signal(setWidth, width);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewColumn::sortable() const -> bool {
|
|
||||||
return state.sortable;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewColumn::text() const -> string {
|
|
||||||
return state.text;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewColumn::verticalAlignment() const -> double {
|
|
||||||
return state.verticalAlignment;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewColumn::width() const -> signed {
|
|
||||||
return state.width;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,53 +0,0 @@
|
||||||
#if defined(Hiro_ListView)
|
|
||||||
|
|
||||||
auto mListViewHeader::allocate() -> pObject* {
|
|
||||||
return new pListViewHeader(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
auto mListViewHeader::append(sListViewColumn column) -> type& {
|
|
||||||
state.columns.append(column);
|
|
||||||
column->setParent(this, columnCount() - 1);
|
|
||||||
signal(append, column);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewHeader::column(unsigned position) const -> ListViewColumn {
|
|
||||||
if(position < columnCount()) return state.columns[position];
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewHeader::columnCount() const -> unsigned {
|
|
||||||
return state.columns.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewHeader::columns() const -> vector<ListViewColumn> {
|
|
||||||
vector<ListViewColumn> columns;
|
|
||||||
for(auto& column : state.columns) columns.append(column);
|
|
||||||
return columns;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewHeader::remove() -> type& {
|
|
||||||
if(auto listView = parentListView()) listView->remove(*this);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewHeader::remove(sListViewColumn column) -> type& {
|
|
||||||
signal(remove, column);
|
|
||||||
state.columns.remove(column->offset());
|
|
||||||
for(auto n : range(column->offset(), columnCount())) {
|
|
||||||
state.columns[n]->adjustOffset(-1);
|
|
||||||
}
|
|
||||||
column->setParent();
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewHeader::setParent(mObject* parent, signed offset) -> type& {
|
|
||||||
for(auto& column : state.columns) column->destruct();
|
|
||||||
mObject::setParent(parent, offset);
|
|
||||||
for(auto& column : state.columns) column->setParent(this, column->offset());
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,98 +0,0 @@
|
||||||
#if defined(Hiro_ListView)
|
|
||||||
|
|
||||||
auto mListViewItem::allocate() -> pObject* {
|
|
||||||
return new pListViewItem(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
auto mListViewItem::alignment() const -> Alignment {
|
|
||||||
return state.alignment;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewItem::append(sListViewCell cell) -> type& {
|
|
||||||
state.cells.append(cell);
|
|
||||||
cell->setParent(this, cellCount() - 1);
|
|
||||||
signal(append, cell);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewItem::backgroundColor() const -> Color {
|
|
||||||
return state.backgroundColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewItem::cell(unsigned position) const -> ListViewCell {
|
|
||||||
if(position < cellCount()) return state.cells[position];
|
|
||||||
return {};
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewItem::cellCount() const -> unsigned {
|
|
||||||
return state.cells.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewItem::cells() const -> vector<ListViewCell> {
|
|
||||||
vector<ListViewCell> cells;
|
|
||||||
for(auto& cell : state.cells) cells.append(cell);
|
|
||||||
return cells;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewItem::foregroundColor() const -> Color {
|
|
||||||
return state.foregroundColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewItem::remove() -> type& {
|
|
||||||
if(auto listView = parentListView()) listView->remove(*this);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewItem::remove(sListViewCell cell) -> type& {
|
|
||||||
signal(remove, cell);
|
|
||||||
state.cells.remove(cell->offset());
|
|
||||||
for(auto n : range(cell->offset(), cellCount())) {
|
|
||||||
state.cells[n]->adjustOffset(-1);
|
|
||||||
}
|
|
||||||
cell->setParent();
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewItem::selected() const -> bool {
|
|
||||||
return state.selected;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewItem::setAlignment(Alignment alignment) -> type& {
|
|
||||||
state.alignment = alignment;
|
|
||||||
signal(setAlignment, alignment);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewItem::setBackgroundColor(Color color) -> type& {
|
|
||||||
state.backgroundColor = color;
|
|
||||||
signal(setBackgroundColor, color);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewItem::setFocused() -> type& {
|
|
||||||
signal(setFocused);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewItem::setForegroundColor(Color color) -> type& {
|
|
||||||
state.foregroundColor = color;
|
|
||||||
signal(setForegroundColor, color);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewItem::setParent(mObject* parent, signed offset) -> type& {
|
|
||||||
for(auto& cell : state.cells) cell->destruct();
|
|
||||||
mObject::setParent(parent, offset);
|
|
||||||
for(auto& cell : state.cells) cell->setParent(this, cell->offset());
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto mListViewItem::setSelected(bool selected) -> type& {
|
|
||||||
state.selected = selected;
|
|
||||||
signal(setSelected, selected);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -77,7 +77,7 @@ auto mTabFrame::remove(sTabFrameItem item) -> type& {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mTabFrame::reset() -> type& {
|
auto mTabFrame::reset() -> type& {
|
||||||
while(state.items) remove(state.items.last());
|
while(state.items) remove(state.items.right());
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
#if defined(Hiro_ListView)
|
#if defined(Hiro_TableView)
|
||||||
|
|
||||||
auto mListViewCell::allocate() -> pObject* {
|
auto mTableViewCell::allocate() -> pObject* {
|
||||||
return new pListViewCell(*this);
|
return new pTableViewCell(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
auto mListViewCell::alignment(bool recursive) const -> Alignment {
|
auto mTableViewCell::alignment(bool recursive) const -> Alignment {
|
||||||
if(auto alignment = state.alignment) return alignment;
|
if(auto alignment = state.alignment) return alignment;
|
||||||
if(recursive) {
|
if(recursive) {
|
||||||
if(auto parent = parentListViewItem()) {
|
if(auto parent = parentTableViewItem()) {
|
||||||
if(auto alignment = parent->state.alignment) return alignment;
|
if(auto alignment = parent->state.alignment) return alignment;
|
||||||
if(auto grandparent = parent->parentListView()) {
|
if(auto grandparent = parent->parentTableView()) {
|
||||||
if(auto header = grandparent->state.header) {
|
if(auto header = grandparent->state.header) {
|
||||||
if(offset() < header->columnCount()) {
|
if(offset() < header->columnCount()) {
|
||||||
if(auto column = header->state.columns[offset()]) {
|
if(auto column = header->state.columns[offset()]) {
|
||||||
|
@ -26,12 +26,12 @@ auto mListViewCell::alignment(bool recursive) const -> Alignment {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListViewCell::backgroundColor(bool recursive) const -> Color {
|
auto mTableViewCell::backgroundColor(bool recursive) const -> Color {
|
||||||
if(auto color = state.backgroundColor) return color;
|
if(auto color = state.backgroundColor) return color;
|
||||||
if(recursive) {
|
if(recursive) {
|
||||||
if(auto parent = parentListViewItem()) {
|
if(auto parent = parentTableViewItem()) {
|
||||||
if(auto color = parent->state.backgroundColor) return color;
|
if(auto color = parent->state.backgroundColor) return color;
|
||||||
if(auto grandparent = parent->parentListView()) {
|
if(auto grandparent = parent->parentTableView()) {
|
||||||
if(auto header = grandparent->state.header) {
|
if(auto header = grandparent->state.header) {
|
||||||
if(offset() < header->columnCount()) {
|
if(offset() < header->columnCount()) {
|
||||||
if(auto column = header->state.columns[offset()]) {
|
if(auto column = header->state.columns[offset()]) {
|
||||||
|
@ -46,20 +46,20 @@ auto mListViewCell::backgroundColor(bool recursive) const -> Color {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListViewCell::checkable() const -> bool {
|
auto mTableViewCell::checkable() const -> bool {
|
||||||
return state.checkable;
|
return state.checkable;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListViewCell::checked() const -> bool {
|
auto mTableViewCell::checked() const -> bool {
|
||||||
return state.checkable && state.checked;
|
return state.checkable && state.checked;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListViewCell::font(bool recursive) const -> Font {
|
auto mTableViewCell::font(bool recursive) const -> Font {
|
||||||
if(auto font = mObject::font()) return font;
|
if(auto font = mObject::font()) return font;
|
||||||
if(recursive) {
|
if(recursive) {
|
||||||
if(auto parent = parentListViewItem()) {
|
if(auto parent = parentTableViewItem()) {
|
||||||
if(auto font = parent->font()) return font;
|
if(auto font = parent->font()) return font;
|
||||||
if(auto grandparent = parent->parentListView()) {
|
if(auto grandparent = parent->parentTableView()) {
|
||||||
if(auto header = grandparent->state.header) {
|
if(auto header = grandparent->state.header) {
|
||||||
if(offset() < header->columnCount()) {
|
if(offset() < header->columnCount()) {
|
||||||
if(auto column = header->state.columns[offset()]) {
|
if(auto column = header->state.columns[offset()]) {
|
||||||
|
@ -74,12 +74,12 @@ auto mListViewCell::font(bool recursive) const -> Font {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListViewCell::foregroundColor(bool recursive) const -> Color {
|
auto mTableViewCell::foregroundColor(bool recursive) const -> Color {
|
||||||
if(auto color = state.foregroundColor) return color;
|
if(auto color = state.foregroundColor) return color;
|
||||||
if(recursive) {
|
if(recursive) {
|
||||||
if(auto parent = parentListViewItem()) {
|
if(auto parent = parentTableViewItem()) {
|
||||||
if(auto color = parent->state.foregroundColor) return color;
|
if(auto color = parent->state.foregroundColor) return color;
|
||||||
if(auto grandparent = parent->parentListView()) {
|
if(auto grandparent = parent->parentTableView()) {
|
||||||
if(auto header = grandparent->state.header) {
|
if(auto header = grandparent->state.header) {
|
||||||
if(offset() < header->columnCount()) {
|
if(offset() < header->columnCount()) {
|
||||||
if(auto column = header->state.columns[offset()]) {
|
if(auto column = header->state.columns[offset()]) {
|
||||||
|
@ -94,54 +94,54 @@ auto mListViewCell::foregroundColor(bool recursive) const -> Color {
|
||||||
return state.foregroundColor;
|
return state.foregroundColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListViewCell::icon() const -> image {
|
auto mTableViewCell::icon() const -> image {
|
||||||
return state.icon;
|
return state.icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListViewCell::setAlignment(Alignment alignment) -> type& {
|
auto mTableViewCell::setAlignment(Alignment alignment) -> type& {
|
||||||
state.alignment = alignment;
|
state.alignment = alignment;
|
||||||
signal(setAlignment, alignment);
|
signal(setAlignment, alignment);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListViewCell::setBackgroundColor(Color color) -> type& {
|
auto mTableViewCell::setBackgroundColor(Color color) -> type& {
|
||||||
state.backgroundColor = color;
|
state.backgroundColor = color;
|
||||||
signal(setBackgroundColor, color);
|
signal(setBackgroundColor, color);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListViewCell::setCheckable(bool checkable) -> type& {
|
auto mTableViewCell::setCheckable(bool checkable) -> type& {
|
||||||
state.checkable = checkable;
|
state.checkable = checkable;
|
||||||
signal(setCheckable, checkable);
|
signal(setCheckable, checkable);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListViewCell::setChecked(bool checked) -> type& {
|
auto mTableViewCell::setChecked(bool checked) -> type& {
|
||||||
setCheckable(true);
|
setCheckable(true);
|
||||||
state.checked = checked;
|
state.checked = checked;
|
||||||
signal(setChecked, checked);
|
signal(setChecked, checked);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListViewCell::setForegroundColor(Color color) -> type& {
|
auto mTableViewCell::setForegroundColor(Color color) -> type& {
|
||||||
state.foregroundColor = color;
|
state.foregroundColor = color;
|
||||||
signal(setForegroundColor, color);
|
signal(setForegroundColor, color);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListViewCell::setIcon(const image& icon) -> type& {
|
auto mTableViewCell::setIcon(const image& icon) -> type& {
|
||||||
state.icon = icon;
|
state.icon = icon;
|
||||||
signal(setIcon, icon);
|
signal(setIcon, icon);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListViewCell::setText(const string& text) -> type& {
|
auto mTableViewCell::setText(const string& text) -> type& {
|
||||||
state.text = text;
|
state.text = text;
|
||||||
signal(setText, text);
|
signal(setText, text);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListViewCell::text() const -> string {
|
auto mTableViewCell::text() const -> string {
|
||||||
return state.text;
|
return state.text;
|
||||||
}
|
}
|
||||||
|
|
153
core/widget/table-view-column.cpp
Normal file
153
core/widget/table-view-column.cpp
Normal file
|
@ -0,0 +1,153 @@
|
||||||
|
#if defined(Hiro_TableView)
|
||||||
|
|
||||||
|
auto mTableViewColumn::allocate() -> pObject* {
|
||||||
|
return new pTableViewColumn(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
auto mTableViewColumn::active() const -> bool {
|
||||||
|
if(auto tableView = parentTableView()) return tableView->state.activeColumn == offset();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewColumn::alignment() const -> Alignment {
|
||||||
|
return state.alignment;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewColumn::backgroundColor() const -> Color {
|
||||||
|
return state.backgroundColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewColumn::editable() const -> bool {
|
||||||
|
return state.editable;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewColumn::expandable() const -> bool {
|
||||||
|
return state.expandable;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewColumn::foregroundColor() const -> Color {
|
||||||
|
return state.foregroundColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewColumn::horizontalAlignment() const -> double {
|
||||||
|
return state.horizontalAlignment;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewColumn::icon() const -> image {
|
||||||
|
return state.icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewColumn::remove() -> type& {
|
||||||
|
if(auto tableView = parentTableViewHeader()) tableView->remove(*this);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewColumn::resizable() const -> bool {
|
||||||
|
return state.resizable;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewColumn::setActive() -> type& {
|
||||||
|
if(auto tableView = parentTableView()) tableView->state.activeColumn = offset();
|
||||||
|
signal(setActive);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewColumn::setAlignment(Alignment alignment) -> type& {
|
||||||
|
state.alignment = alignment;
|
||||||
|
signal(setAlignment, alignment);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewColumn::setBackgroundColor(Color color) -> type& {
|
||||||
|
state.backgroundColor = color;
|
||||||
|
signal(setBackgroundColor, color);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewColumn::setEditable(bool editable) -> type& {
|
||||||
|
state.editable = editable;
|
||||||
|
signal(setEditable, editable);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewColumn::setExpandable(bool expandable) -> type& {
|
||||||
|
state.expandable = expandable;
|
||||||
|
signal(setExpandable, expandable);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewColumn::setForegroundColor(Color color) -> type& {
|
||||||
|
state.foregroundColor = color;
|
||||||
|
signal(setForegroundColor, color);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewColumn::setHorizontalAlignment(double alignment) -> type& {
|
||||||
|
alignment = max(0.0, min(1.0, alignment));
|
||||||
|
state.horizontalAlignment = alignment;
|
||||||
|
signal(setHorizontalAlignment, alignment);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewColumn::setIcon(const image& icon) -> type& {
|
||||||
|
state.icon = icon;
|
||||||
|
signal(setIcon, icon);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewColumn::setResizable(bool resizable) -> type& {
|
||||||
|
state.resizable = resizable;
|
||||||
|
signal(setResizable, resizable);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewColumn::setSortable(bool sortable) -> type& {
|
||||||
|
state.sortable = sortable;
|
||||||
|
signal(setSortable, sortable);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewColumn::setText(const string& text) -> type& {
|
||||||
|
state.text = text;
|
||||||
|
signal(setText, text);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewColumn::setVerticalAlignment(double alignment) -> type& {
|
||||||
|
alignment = max(0.0, min(1.0, alignment));
|
||||||
|
state.verticalAlignment = alignment;
|
||||||
|
signal(setVerticalAlignment, alignment);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewColumn::setVisible(bool visible) -> type& {
|
||||||
|
state.visible = visible;
|
||||||
|
signal(setVisible, visible);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewColumn::setWidth(signed width) -> type& {
|
||||||
|
state.width = max(0, width);
|
||||||
|
signal(setWidth, width);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewColumn::sortable() const -> bool {
|
||||||
|
return state.sortable;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewColumn::text() const -> string {
|
||||||
|
return state.text;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewColumn::verticalAlignment() const -> double {
|
||||||
|
return state.verticalAlignment;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewColumn::width() const -> signed {
|
||||||
|
return state.width;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
58
core/widget/table-view-header.cpp
Normal file
58
core/widget/table-view-header.cpp
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
#if defined(Hiro_TableView)
|
||||||
|
|
||||||
|
auto mTableViewHeader::allocate() -> pObject* {
|
||||||
|
return new pTableViewHeader(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
auto mTableViewHeader::append(sTableViewColumn column) -> type& {
|
||||||
|
state.columns.append(column);
|
||||||
|
column->setParent(this, columnCount() - 1);
|
||||||
|
signal(append, column);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewHeader::column(unsigned position) const -> TableViewColumn {
|
||||||
|
if(position < columnCount()) return state.columns[position];
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewHeader::columnCount() const -> unsigned {
|
||||||
|
return state.columns.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewHeader::columns() const -> vector<TableViewColumn> {
|
||||||
|
vector<TableViewColumn> columns;
|
||||||
|
for(auto& column : state.columns) columns.append(column);
|
||||||
|
return columns;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewHeader::remove() -> type& {
|
||||||
|
if(auto tableView = parentTableView()) tableView->remove(*this);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewHeader::remove(sTableViewColumn column) -> type& {
|
||||||
|
signal(remove, column);
|
||||||
|
state.columns.remove(column->offset());
|
||||||
|
for(auto n : range(column->offset(), columnCount())) {
|
||||||
|
state.columns[n]->adjustOffset(-1);
|
||||||
|
}
|
||||||
|
column->setParent();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewHeader::reset() -> type& {
|
||||||
|
for(auto n : rrange(state.columns)) remove(state.columns[n]);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewHeader::setParent(mObject* parent, signed offset) -> type& {
|
||||||
|
for(auto& column : state.columns) column->destruct();
|
||||||
|
mObject::setParent(parent, offset);
|
||||||
|
for(auto& column : state.columns) column->setParent(this, column->offset());
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
103
core/widget/table-view-item.cpp
Normal file
103
core/widget/table-view-item.cpp
Normal file
|
@ -0,0 +1,103 @@
|
||||||
|
#if defined(Hiro_TableView)
|
||||||
|
|
||||||
|
auto mTableViewItem::allocate() -> pObject* {
|
||||||
|
return new pTableViewItem(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
auto mTableViewItem::alignment() const -> Alignment {
|
||||||
|
return state.alignment;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewItem::append(sTableViewCell cell) -> type& {
|
||||||
|
state.cells.append(cell);
|
||||||
|
cell->setParent(this, cellCount() - 1);
|
||||||
|
signal(append, cell);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewItem::backgroundColor() const -> Color {
|
||||||
|
return state.backgroundColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewItem::cell(unsigned position) const -> TableViewCell {
|
||||||
|
if(position < cellCount()) return state.cells[position];
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewItem::cellCount() const -> unsigned {
|
||||||
|
return state.cells.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewItem::cells() const -> vector<TableViewCell> {
|
||||||
|
vector<TableViewCell> cells;
|
||||||
|
for(auto& cell : state.cells) cells.append(cell);
|
||||||
|
return cells;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewItem::foregroundColor() const -> Color {
|
||||||
|
return state.foregroundColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewItem::remove() -> type& {
|
||||||
|
if(auto tableView = parentTableView()) tableView->remove(*this);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewItem::remove(sTableViewCell cell) -> type& {
|
||||||
|
signal(remove, cell);
|
||||||
|
state.cells.remove(cell->offset());
|
||||||
|
for(auto n : range(cell->offset(), cellCount())) {
|
||||||
|
state.cells[n]->adjustOffset(-1);
|
||||||
|
}
|
||||||
|
cell->setParent();
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewItem::reset() -> type& {
|
||||||
|
for(auto n : rrange(state.cells)) remove(state.cells[n]);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewItem::selected() const -> bool {
|
||||||
|
return state.selected;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewItem::setAlignment(Alignment alignment) -> type& {
|
||||||
|
state.alignment = alignment;
|
||||||
|
signal(setAlignment, alignment);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewItem::setBackgroundColor(Color color) -> type& {
|
||||||
|
state.backgroundColor = color;
|
||||||
|
signal(setBackgroundColor, color);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewItem::setFocused() -> type& {
|
||||||
|
signal(setFocused);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewItem::setForegroundColor(Color color) -> type& {
|
||||||
|
state.foregroundColor = color;
|
||||||
|
signal(setForegroundColor, color);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewItem::setParent(mObject* parent, signed offset) -> type& {
|
||||||
|
for(auto& cell : state.cells) cell->destruct();
|
||||||
|
mObject::setParent(parent, offset);
|
||||||
|
for(auto& cell : state.cells) cell->setParent(this, cell->offset());
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mTableViewItem::setSelected(bool selected) -> type& {
|
||||||
|
state.selected = selected;
|
||||||
|
signal(setSelected, selected);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,10 +1,10 @@
|
||||||
#if defined(Hiro_ListView)
|
#if defined(Hiro_TableView)
|
||||||
|
|
||||||
auto mListView::allocate() -> pObject* {
|
auto mTableView::allocate() -> pObject* {
|
||||||
return new pListView(*this);
|
return new pTableView(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListView::destruct() -> void {
|
auto mTableView::destruct() -> void {
|
||||||
for(auto& item : state.items) item->destruct();
|
for(auto& item : state.items) item->destruct();
|
||||||
if(auto& header = state.header) header->destruct();
|
if(auto& header = state.header) header->destruct();
|
||||||
mWidget::destruct();
|
mWidget::destruct();
|
||||||
|
@ -12,11 +12,11 @@ auto mListView::destruct() -> void {
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
auto mListView::alignment() const -> Alignment {
|
auto mTableView::alignment() const -> Alignment {
|
||||||
return state.alignment;
|
return state.alignment;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListView::append(sListViewHeader header) -> type& {
|
auto mTableView::append(sTableViewHeader header) -> type& {
|
||||||
if(auto& header = state.header) remove(header);
|
if(auto& header = state.header) remove(header);
|
||||||
state.header = header;
|
state.header = header;
|
||||||
header->setParent(this, 0);
|
header->setParent(this, 0);
|
||||||
|
@ -24,118 +24,118 @@ auto mListView::append(sListViewHeader header) -> type& {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListView::append(sListViewItem item) -> type& {
|
auto mTableView::append(sTableViewItem item) -> type& {
|
||||||
state.items.append(item);
|
state.items.append(item);
|
||||||
item->setParent(this, itemCount() - 1);
|
item->setParent(this, itemCount() - 1);
|
||||||
signal(append, item);
|
signal(append, item);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListView::backgroundColor() const -> Color {
|
auto mTableView::backgroundColor() const -> Color {
|
||||||
return state.backgroundColor;
|
return state.backgroundColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListView::batchable() const -> bool {
|
auto mTableView::batchable() const -> bool {
|
||||||
return state.batchable;
|
return state.batchable;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListView::batched() const -> vector<ListViewItem> {
|
auto mTableView::batched() const -> vector<TableViewItem> {
|
||||||
vector<ListViewItem> items;
|
vector<TableViewItem> items;
|
||||||
for(auto& item : state.items) {
|
for(auto& item : state.items) {
|
||||||
if(item->selected()) items.append(item);
|
if(item->selected()) items.append(item);
|
||||||
}
|
}
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListView::bordered() const -> bool {
|
auto mTableView::bordered() const -> bool {
|
||||||
return state.bordered;
|
return state.bordered;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListView::doActivate() const -> void {
|
auto mTableView::doActivate() const -> void {
|
||||||
if(state.onActivate) return state.onActivate();
|
if(state.onActivate) return state.onActivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListView::doChange() const -> void {
|
auto mTableView::doChange() const -> void {
|
||||||
if(state.onChange) return state.onChange();
|
if(state.onChange) return state.onChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListView::doContext() const -> void {
|
auto mTableView::doContext() const -> void {
|
||||||
if(state.onContext) return state.onContext();
|
if(state.onContext) return state.onContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListView::doEdit(sListViewCell cell) const -> void {
|
auto mTableView::doEdit(sTableViewCell cell) const -> void {
|
||||||
if(state.onEdit) return state.onEdit(cell);
|
if(state.onEdit) return state.onEdit(cell);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListView::doSort(sListViewColumn column) const -> void {
|
auto mTableView::doSort(sTableViewColumn column) const -> void {
|
||||||
if(state.onSort) return state.onSort(column);
|
if(state.onSort) return state.onSort(column);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListView::doToggle(sListViewCell cell) const -> void {
|
auto mTableView::doToggle(sTableViewCell cell) const -> void {
|
||||||
if(state.onToggle) return state.onToggle(cell);
|
if(state.onToggle) return state.onToggle(cell);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListView::foregroundColor() const -> Color {
|
auto mTableView::foregroundColor() const -> Color {
|
||||||
return state.foregroundColor;
|
return state.foregroundColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListView::header() const -> ListViewHeader {
|
auto mTableView::header() const -> TableViewHeader {
|
||||||
return state.header;
|
return state.header;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListView::item(unsigned position) const -> ListViewItem {
|
auto mTableView::item(unsigned position) const -> TableViewItem {
|
||||||
if(position < itemCount()) return state.items[position];
|
if(position < itemCount()) return state.items[position];
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListView::itemCount() const -> unsigned {
|
auto mTableView::itemCount() const -> unsigned {
|
||||||
return state.items.size();
|
return state.items.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListView::items() const -> vector<ListViewItem> {
|
auto mTableView::items() const -> vector<TableViewItem> {
|
||||||
vector<ListViewItem> items;
|
vector<TableViewItem> items;
|
||||||
for(auto& item : state.items) items.append(item);
|
for(auto& item : state.items) items.append(item);
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListView::onActivate(const function<void ()>& callback) -> type& {
|
auto mTableView::onActivate(const function<void ()>& callback) -> type& {
|
||||||
state.onActivate = callback;
|
state.onActivate = callback;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListView::onChange(const function<void ()>& callback) -> type& {
|
auto mTableView::onChange(const function<void ()>& callback) -> type& {
|
||||||
state.onChange = callback;
|
state.onChange = callback;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListView::onContext(const function<void ()>& callback) -> type& {
|
auto mTableView::onContext(const function<void ()>& callback) -> type& {
|
||||||
state.onContext = callback;
|
state.onContext = callback;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListView::onEdit(const function<void (ListViewCell)>& callback) -> type& {
|
auto mTableView::onEdit(const function<void (TableViewCell)>& callback) -> type& {
|
||||||
state.onEdit = callback;
|
state.onEdit = callback;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListView::onSort(const function<void (ListViewColumn)>& callback) -> type& {
|
auto mTableView::onSort(const function<void (TableViewColumn)>& callback) -> type& {
|
||||||
state.onSort = callback;
|
state.onSort = callback;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListView::onToggle(const function<void (ListViewCell)>& callback) -> type& {
|
auto mTableView::onToggle(const function<void (TableViewCell)>& callback) -> type& {
|
||||||
state.onToggle = callback;
|
state.onToggle = callback;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListView::remove(sListViewHeader header) -> type& {
|
auto mTableView::remove(sTableViewHeader header) -> type& {
|
||||||
signal(remove, header);
|
signal(remove, header);
|
||||||
header->setParent();
|
header->setParent();
|
||||||
state.header.reset();
|
state.header.reset();
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListView::remove(sListViewItem item) -> type& {
|
auto mTableView::remove(sTableViewItem item) -> type& {
|
||||||
signal(remove, item);
|
signal(remove, item);
|
||||||
state.items.remove(item->offset());
|
state.items.remove(item->offset());
|
||||||
for(auto n : range(item->offset(), itemCount())) {
|
for(auto n : range(item->offset(), itemCount())) {
|
||||||
|
@ -145,55 +145,55 @@ auto mListView::remove(sListViewItem item) -> type& {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListView::reset() -> type& {
|
auto mTableView::reset() -> type& {
|
||||||
for(auto n : rrange(state.items)) remove(state.items[n]);
|
for(auto n : rrange(state.items)) remove(state.items[n]);
|
||||||
if(auto& header = state.header) remove(header);
|
if(auto& header = state.header) remove(header);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListView::resizeColumns() -> type& {
|
auto mTableView::resizeColumns() -> type& {
|
||||||
signal(resizeColumns);
|
signal(resizeColumns);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListView::selected() const -> ListViewItem {
|
auto mTableView::selected() const -> TableViewItem {
|
||||||
for(auto& item : state.items) {
|
for(auto& item : state.items) {
|
||||||
if(item->selected()) return item;
|
if(item->selected()) return item;
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListView::setAlignment(Alignment alignment) -> type& {
|
auto mTableView::setAlignment(Alignment alignment) -> type& {
|
||||||
state.alignment = alignment;
|
state.alignment = alignment;
|
||||||
signal(setAlignment, alignment);
|
signal(setAlignment, alignment);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListView::setBackgroundColor(Color color) -> type& {
|
auto mTableView::setBackgroundColor(Color color) -> type& {
|
||||||
state.backgroundColor = color;
|
state.backgroundColor = color;
|
||||||
signal(setBackgroundColor, color);
|
signal(setBackgroundColor, color);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListView::setBatchable(bool batchable) -> type& {
|
auto mTableView::setBatchable(bool batchable) -> type& {
|
||||||
state.batchable = batchable;
|
state.batchable = batchable;
|
||||||
signal(setBatchable, batchable);
|
signal(setBatchable, batchable);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListView::setBordered(bool bordered) -> type& {
|
auto mTableView::setBordered(bool bordered) -> type& {
|
||||||
state.bordered = bordered;
|
state.bordered = bordered;
|
||||||
signal(setBordered, bordered);
|
signal(setBordered, bordered);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListView::setForegroundColor(Color color) -> type& {
|
auto mTableView::setForegroundColor(Color color) -> type& {
|
||||||
state.foregroundColor = color;
|
state.foregroundColor = color;
|
||||||
signal(setForegroundColor, color);
|
signal(setForegroundColor, color);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mListView::setParent(mObject* parent, signed offset) -> type& {
|
auto mTableView::setParent(mObject* parent, signed offset) -> type& {
|
||||||
for(auto n : rrange(state.items)) state.items[n]->destruct();
|
for(auto n : rrange(state.items)) state.items[n]->destruct();
|
||||||
if(auto& header = state.header) header->destruct();
|
if(auto& header = state.header) header->destruct();
|
||||||
mObject::setParent(parent, offset);
|
mObject::setParent(parent, offset);
|
|
@ -57,11 +57,11 @@ auto mTreeViewItem::icon() const -> image {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mTreeViewItem::item(const string& path) const -> TreeViewItem {
|
auto mTreeViewItem::item(const string& path) const -> TreeViewItem {
|
||||||
if(path.empty()) return {};
|
if(!path) return {};
|
||||||
auto paths = path.split("/");
|
auto paths = path.split("/");
|
||||||
unsigned position = paths.takeFirst().natural();
|
unsigned position = paths.takeLeft().natural();
|
||||||
if(position >= itemCount()) return {};
|
if(position >= itemCount()) return {};
|
||||||
if(paths.empty()) return state.items[position];
|
if(!paths) return state.items[position];
|
||||||
return state.items[position]->item(paths.merge("/"));
|
return state.items[position]->item(paths.merge("/"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,11 +43,11 @@ auto mTreeView::foregroundColor() const -> Color {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto mTreeView::item(const string& path) const -> TreeViewItem {
|
auto mTreeView::item(const string& path) const -> TreeViewItem {
|
||||||
if(path.empty()) return {};
|
if(!path) return {};
|
||||||
auto paths = path.split("/");
|
auto paths = path.split("/");
|
||||||
unsigned position = paths.takeFirst().natural();
|
unsigned position = paths.takeLeft().natural();
|
||||||
if(position >= itemCount()) return {};
|
if(position >= itemCount()) return {};
|
||||||
if(paths.empty()) return state.items[position];
|
if(!paths) return state.items[position];
|
||||||
return state.items[position]->item(paths.merge("/"));
|
return state.items[position]->item(paths.merge("/"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,12 +30,12 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
//accept button clicked, or enter pressed on file name line edit
|
//accept button clicked, or enter pressed on file name line edit
|
||||||
//also called by list view activate after special case handling
|
//also called by table view activate after special case handling
|
||||||
auto BrowserDialogWindow::accept() -> void {
|
auto BrowserDialogWindow::accept() -> void {
|
||||||
auto batched = view.batched();
|
auto batched = view.batched();
|
||||||
|
|
||||||
if(state.action == "openFile" && batched) {
|
if(state.action == "openFile" && batched) {
|
||||||
string name = batched.first()->cell(0)->text();
|
string name = batched.left()->cell(0)->text();
|
||||||
if(isFolder(name)) return setPath({state.path, name});
|
if(isFolder(name)) return setPath({state.path, name});
|
||||||
state.response.append(string{state.path, name});
|
state.response.append(string{state.path, name});
|
||||||
}
|
}
|
||||||
|
@ -48,14 +48,14 @@ auto BrowserDialogWindow::accept() -> void {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(state.action == "openFolder" && batched) {
|
if(state.action == "openFolder" && batched) {
|
||||||
string name = batched.first()->cell(0)->text();
|
string name = batched.left()->cell(0)->text();
|
||||||
if(!isMatch(name)) return setPath({state.path, name});
|
if(!isMatch(name)) return setPath({state.path, name});
|
||||||
state.response.append(string{state.path, name, "/"});
|
state.response.append(string{state.path, name, "/"});
|
||||||
}
|
}
|
||||||
|
|
||||||
if(state.action == "saveFile") {
|
if(state.action == "saveFile") {
|
||||||
string name = fileName.text();
|
string name = fileName.text();
|
||||||
if(!name && batched) name = batched.first()->cell(0)->text();
|
if(!name && batched) name = batched.left()->cell(0)->text();
|
||||||
if(!name || isFolder(name)) return;
|
if(!name || isFolder(name)) return;
|
||||||
if(file::exists({state.path, name})) {
|
if(file::exists({state.path, name})) {
|
||||||
if(MessageDialog("File already exists; overwrite it?").question() != "Yes") return;
|
if(MessageDialog("File already exists; overwrite it?").question() != "Yes") return;
|
||||||
|
@ -64,14 +64,14 @@ auto BrowserDialogWindow::accept() -> void {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(state.action == "selectFolder" && batched) {
|
if(state.action == "selectFolder" && batched) {
|
||||||
string name = batched.first()->cell(0)->text();
|
string name = batched.left()->cell(0)->text();
|
||||||
if(isFolder(name)) state.response.append(string{state.path, name, "/"});
|
if(isFolder(name)) state.response.append(string{state.path, name, "/"});
|
||||||
}
|
}
|
||||||
|
|
||||||
if(state.response) window.setModal(false);
|
if(state.response) window.setModal(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
//list view item double-clicked, or enter pressed on selected list view item
|
//table view item double-clicked, or enter pressed on selected table view item
|
||||||
auto BrowserDialogWindow::activate() -> void {
|
auto BrowserDialogWindow::activate() -> void {
|
||||||
auto selectedItem = view.selected();
|
auto selectedItem = view.selected();
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ auto BrowserDialogWindow::activate() -> void {
|
||||||
accept();
|
accept();
|
||||||
}
|
}
|
||||||
|
|
||||||
//list view item changed
|
//table view item changed
|
||||||
auto BrowserDialogWindow::change() -> void {
|
auto BrowserDialogWindow::change() -> void {
|
||||||
fileName.setText("");
|
fileName.setText("");
|
||||||
if(state.action == "saveFile") {
|
if(state.action == "saveFile") {
|
||||||
|
@ -119,13 +119,13 @@ auto BrowserDialogWindow::run() -> lstring {
|
||||||
layout.setMargin(5);
|
layout.setMargin(5);
|
||||||
pathName.onActivate([&] { setPath(pathName.text()); });
|
pathName.onActivate([&] { setPath(pathName.text()); });
|
||||||
pathRefresh.setBordered(false).setIcon(Icon::Action::Refresh).onActivate([&] { setPath(state.path); });
|
pathRefresh.setBordered(false).setIcon(Icon::Action::Refresh).onActivate([&] { setPath(state.path); });
|
||||||
pathHome.setBordered(false).setIcon(Icon::Go::Home).onActivate([&] { setPath(userpath()); });
|
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(dirname(state.path)); });
|
||||||
view.setBatchable(state.action == "openFiles").onActivate([&] { activate(); }).onChange([&] { change(); });
|
view.setBatchable(state.action == "openFiles").onActivate([&] { activate(); }).onChange([&] { change(); });
|
||||||
filterList.setVisible(state.action != "selectFolder").onChange([&] { setPath(state.path); });
|
filterList.setVisible(state.action != "selectFolder").onChange([&] { setPath(state.path); });
|
||||||
for(auto& filter : state.filters) {
|
for(auto& filter : state.filters) {
|
||||||
auto part = filter.split("|", 1L);
|
auto part = filter.split("|", 1L);
|
||||||
filterList.append(ComboButtonItem().setText(part.first()));
|
filterList.append(ComboButtonItem().setText(part.left()));
|
||||||
}
|
}
|
||||||
fileName.setVisible(state.action == "saveFile").onActivate([&] { accept(); });
|
fileName.setVisible(state.action == "saveFile").onActivate([&] { accept(); });
|
||||||
acceptButton.onActivate([&] { accept(); });
|
acceptButton.onActivate([&] { accept(); });
|
||||||
|
@ -137,18 +137,16 @@ auto BrowserDialogWindow::run() -> lstring {
|
||||||
if(!state.filters) state.filters.append("All|*");
|
if(!state.filters) state.filters.append("All|*");
|
||||||
for(auto& filter : state.filters) {
|
for(auto& filter : state.filters) {
|
||||||
auto part = filter.split("|", 1L);
|
auto part = filter.split("|", 1L);
|
||||||
filters.append(part.last().split(":"));
|
filters.append(part.right().split(":"));
|
||||||
}
|
}
|
||||||
|
|
||||||
setPath(state.path);
|
setPath(state.path);
|
||||||
|
|
||||||
window.onClose([&] { window.setModal(false); });
|
window.onClose([&] { window.setModal(false); });
|
||||||
window.onSize([&] { view.resizeColumns(); });
|
|
||||||
window.setTitle(state.title);
|
window.setTitle(state.title);
|
||||||
window.setSize({640, 480});
|
window.setSize({640, 480});
|
||||||
window.setCentered(state.parent);
|
window.setCentered(state.parent);
|
||||||
window.setVisible();
|
window.setVisible();
|
||||||
view.resizeColumns();
|
|
||||||
view.setFocused();
|
view.setFocused();
|
||||||
window.setModal();
|
window.setModal();
|
||||||
window.setVisible(false);
|
window.setVisible(false);
|
||||||
|
@ -162,35 +160,29 @@ auto BrowserDialogWindow::setPath(string path) -> void {
|
||||||
pathName.setText(state.path = path);
|
pathName.setText(state.path = path);
|
||||||
|
|
||||||
view.reset();
|
view.reset();
|
||||||
view.append(ListViewHeader().setVisible(false)
|
|
||||||
.append(ListViewColumn().setExpandable())
|
|
||||||
);
|
|
||||||
|
|
||||||
auto contents = directory::icontents(path);
|
auto contents = directory::icontents(path);
|
||||||
bool folderMode = state.action == "openFolder";
|
bool folderMode = state.action == "openFolder";
|
||||||
|
|
||||||
for(auto content : contents) {
|
for(auto content : contents) {
|
||||||
if(!content.endsWith("/")) continue;
|
if(!content.endsWith("/")) continue;
|
||||||
content.rtrim("/");
|
content.trimRight("/");
|
||||||
if(folderMode && isMatch(content)) continue;
|
if(folderMode && isMatch(content)) continue;
|
||||||
|
|
||||||
view.append(ListViewItem()
|
view.append(ListViewItem().setText(content).setIcon(Icon::Emblem::Folder));
|
||||||
.append(ListViewCell().setText(content).setIcon(Icon::Emblem::Folder))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for(auto content : contents) {
|
for(auto content : contents) {
|
||||||
if(content.endsWith("/") != folderMode) continue; //file mode shows files; folder mode shows folders
|
if(content.endsWith("/") != folderMode) continue; //file mode shows files; folder mode shows folders
|
||||||
content.rtrim("/");
|
content.trimRight("/");
|
||||||
if(!isMatch(content)) continue;
|
if(!isMatch(content)) continue;
|
||||||
|
|
||||||
view.append(ListViewItem()
|
view.append(ListViewItem().setText(content).setIcon(folderMode ? Icon::Action::Open : Icon::Emblem::File));
|
||||||
.append(ListViewCell().setText(content).setIcon(folderMode ? Icon::Action::Open : Icon::Emblem::File))
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Application::processEvents();
|
Application::processEvents();
|
||||||
view.resizeColumns().setFocused().doChange();
|
view->resizeColumns(); //todo: on Windows, adding items may add vertical scrollbar; this hack corrects column width
|
||||||
|
view.setFocused().doChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -201,7 +193,7 @@ BrowserDialog::BrowserDialog() {
|
||||||
auto BrowserDialog::openFile() -> string {
|
auto BrowserDialog::openFile() -> string {
|
||||||
state.action = "openFile";
|
state.action = "openFile";
|
||||||
if(!state.title) state.title = "Open File";
|
if(!state.title) state.title = "Open File";
|
||||||
if(auto result = _run()) return result.first();
|
if(auto result = _run()) return result.left();
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,21 +207,21 @@ auto BrowserDialog::openFiles() -> lstring {
|
||||||
auto BrowserDialog::openFolder() -> string {
|
auto BrowserDialog::openFolder() -> string {
|
||||||
state.action = "openFolder";
|
state.action = "openFolder";
|
||||||
if(!state.title) state.title = "Open Folder";
|
if(!state.title) state.title = "Open Folder";
|
||||||
if(auto result = _run()) return result.first();
|
if(auto result = _run()) return result.left();
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
auto BrowserDialog::saveFile() -> string {
|
auto BrowserDialog::saveFile() -> string {
|
||||||
state.action = "saveFile";
|
state.action = "saveFile";
|
||||||
if(!state.title) state.title = "Save File";
|
if(!state.title) state.title = "Save File";
|
||||||
if(auto result = _run()) return result.first();
|
if(auto result = _run()) return result.left();
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
auto BrowserDialog::selectFolder() -> string {
|
auto BrowserDialog::selectFolder() -> string {
|
||||||
state.action = "selectFolder";
|
state.action = "selectFolder";
|
||||||
if(!state.title) state.title = "Select Folder";
|
if(!state.title) state.title = "Select Folder";
|
||||||
if(auto result = _run()) return result.first();
|
if(auto result = _run()) return result.left();
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,7 +246,7 @@ auto BrowserDialog::setTitle(const string& title) -> type& {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto BrowserDialog::_run() -> lstring {
|
auto BrowserDialog::_run() -> lstring {
|
||||||
if(!state.path) state.path = userpath();
|
if(!state.path) state.path = Path::user();
|
||||||
return BrowserDialogWindow(state).run();
|
return BrowserDialogWindow(state).run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,8 @@ namespace hiro {
|
||||||
#include "fixed-layout.cpp"
|
#include "fixed-layout.cpp"
|
||||||
#include "horizontal-layout.cpp"
|
#include "horizontal-layout.cpp"
|
||||||
#include "vertical-layout.cpp"
|
#include "vertical-layout.cpp"
|
||||||
|
#include "list-view-item.cpp"
|
||||||
|
#include "list-view.cpp"
|
||||||
#include "browser-dialog.cpp"
|
#include "browser-dialog.cpp"
|
||||||
#include "message-dialog.cpp"
|
#include "message-dialog.cpp"
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@ namespace hiro {
|
||||||
#include "fixed-layout.hpp"
|
#include "fixed-layout.hpp"
|
||||||
#include "horizontal-layout.hpp"
|
#include "horizontal-layout.hpp"
|
||||||
#include "vertical-layout.hpp"
|
#include "vertical-layout.hpp"
|
||||||
|
#include "list-view-item.hpp"
|
||||||
|
#include "list-view.hpp"
|
||||||
#include "shared.hpp"
|
#include "shared.hpp"
|
||||||
#include "browser-dialog.hpp"
|
#include "browser-dialog.hpp"
|
||||||
#include "message-dialog.hpp"
|
#include "message-dialog.hpp"
|
||||||
|
|
|
@ -26,7 +26,7 @@ auto mHorizontalLayout::minimumSize() const -> Size {
|
||||||
} else {
|
} else {
|
||||||
width += child.width;
|
width += child.width;
|
||||||
}
|
}
|
||||||
if(&child != &properties.last()) width += child.spacing;
|
if(&child != &properties.right()) width += child.spacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(auto n : range(sizableCount())) {
|
for(auto n : range(sizableCount())) {
|
||||||
|
@ -94,7 +94,7 @@ auto mHorizontalLayout::setGeometry(Geometry containerGeometry) -> type& {
|
||||||
for(auto& child : properties) {
|
for(auto& child : properties) {
|
||||||
if(child.width == Size::Maximum) maximumWidthCounter++;
|
if(child.width == Size::Maximum) maximumWidthCounter++;
|
||||||
if(child.width != Size::Maximum) minimumWidth += child.width;
|
if(child.width != Size::Maximum) minimumWidth += child.width;
|
||||||
if(&child != &properties.last()) minimumWidth += child.spacing;
|
if(&child != &properties.right()) minimumWidth += child.spacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(auto& child : properties) {
|
for(auto& child : properties) {
|
||||||
|
|
49
extension/list-view-item.cpp
Normal file
49
extension/list-view-item.cpp
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
#if defined(Hiro_ListView)
|
||||||
|
|
||||||
|
mListViewItem::mListViewItem() {
|
||||||
|
append(TableViewCell());
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mListViewItem::checkable() const -> bool {
|
||||||
|
return cell(0).checkable();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mListViewItem::checked() const -> bool {
|
||||||
|
return cell(0).checked();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mListViewItem::icon() const -> image {
|
||||||
|
return cell(0).icon();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mListViewItem::reset() -> type& {
|
||||||
|
mTableViewItem::reset();
|
||||||
|
append(TableViewCell());
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mListViewItem::setCheckable(bool checkable) -> type& {
|
||||||
|
cell(0).setCheckable(checkable);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mListViewItem::setChecked(bool checked) -> type& {
|
||||||
|
cell(0).setChecked(checked);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mListViewItem::setIcon(const image& icon) -> type& {
|
||||||
|
cell(0).setIcon(icon);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mListViewItem::setText(const string& text) -> type& {
|
||||||
|
cell(0).setText(text);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mListViewItem::text() const -> string {
|
||||||
|
return cell(0).text();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
24
extension/list-view-item.hpp
Normal file
24
extension/list-view-item.hpp
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
#if defined(Hiro_ListView)
|
||||||
|
|
||||||
|
struct ListViewItem;
|
||||||
|
struct mListViewItem;
|
||||||
|
using sListViewItem = shared_pointer<mListViewItem>;
|
||||||
|
|
||||||
|
struct mListViewItem : mTableViewItem {
|
||||||
|
using type = mListViewItem;
|
||||||
|
using mTableViewItem::append;
|
||||||
|
using mTableViewItem::remove;
|
||||||
|
|
||||||
|
mListViewItem();
|
||||||
|
auto checkable() const -> bool;
|
||||||
|
auto checked() const -> bool;
|
||||||
|
auto icon() const -> image;
|
||||||
|
auto reset() -> type&;
|
||||||
|
auto setCheckable(bool checkable) -> type&;
|
||||||
|
auto setChecked(bool checked) -> type&;
|
||||||
|
auto setIcon(const image& icon = {}) -> type&;
|
||||||
|
auto setText(const string& text) -> type&;
|
||||||
|
auto text() const -> string;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
51
extension/list-view.cpp
Normal file
51
extension/list-view.cpp
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
#if defined(Hiro_ListView)
|
||||||
|
|
||||||
|
mListView::mListView() {
|
||||||
|
mTableView::onToggle([&](TableViewCell cell) {
|
||||||
|
if(auto item = cell->parentTableViewItem()) {
|
||||||
|
if(auto shared = item->instance.acquire()) {
|
||||||
|
doToggle(ListViewItem{shared});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
append(TableViewHeader().setVisible(false).append(TableViewColumn().setExpandable()));
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mListView::batched() const -> vector<ListViewItem> {
|
||||||
|
auto batched = mTableView::batched();
|
||||||
|
vector<ListViewItem> result;
|
||||||
|
for(auto item : batched) result.append(ListViewItem{item});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mListView::doToggle(ListViewItem item) const -> void {
|
||||||
|
if(state.onToggle) state.onToggle(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mListView::item(uint position) const -> ListViewItem {
|
||||||
|
return ListViewItem{mTableView::item(position)};
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mListView::items() const -> vector<ListViewItem> {
|
||||||
|
auto items = mTableView::items();
|
||||||
|
vector<ListViewItem> result;
|
||||||
|
for(auto item : items) result.append(ListViewItem{item});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mListView::onToggle(const function<void (ListViewItem)>& callback) -> type& {
|
||||||
|
state.onToggle = callback;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mListView::reset() -> type& {
|
||||||
|
mTableView::reset();
|
||||||
|
append(TableViewHeader().setVisible(false).append(TableViewColumn().setExpandable()));
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto mListView::selected() const -> ListViewItem {
|
||||||
|
return ListViewItem{mTableView::selected()};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
27
extension/list-view.hpp
Normal file
27
extension/list-view.hpp
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
#if defined(Hiro_ListView)
|
||||||
|
|
||||||
|
struct ListView;
|
||||||
|
struct mListView;
|
||||||
|
using sListView = shared_pointer<mListView>;
|
||||||
|
|
||||||
|
struct mListView : mTableView {
|
||||||
|
using type = mListView;
|
||||||
|
using mTableView::append;
|
||||||
|
using mTableView::remove;
|
||||||
|
|
||||||
|
mListView();
|
||||||
|
auto batched() const -> vector<ListViewItem>;
|
||||||
|
auto doToggle(ListViewItem) const -> void;
|
||||||
|
auto item(uint position) const -> ListViewItem;
|
||||||
|
auto items() const -> vector<ListViewItem>;
|
||||||
|
auto onToggle(const function<void (ListViewItem)>& callback) -> type&;
|
||||||
|
auto reset() -> type& override;
|
||||||
|
auto selected() const -> ListViewItem;
|
||||||
|
|
||||||
|
//private:
|
||||||
|
struct State {
|
||||||
|
function<void (ListViewItem)> onToggle;
|
||||||
|
} state;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -33,3 +33,56 @@ struct VerticalLayout : sVerticalLayout {
|
||||||
auto setSpacing(signed spacing = 5) { return self().setSpacing(spacing), *this; }
|
auto setSpacing(signed spacing = 5) { return self().setSpacing(spacing), *this; }
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(Hiro_ListView)
|
||||||
|
struct ListViewItem : sListViewItem {
|
||||||
|
DeclareSharedObject(ListViewItem)
|
||||||
|
|
||||||
|
auto alignment() const { return self().alignment(); }
|
||||||
|
auto backgroundColor() const { return self().backgroundColor(); }
|
||||||
|
auto checkable() const { return self().checkable(); }
|
||||||
|
auto checked() const { return self().checked(); }
|
||||||
|
auto foregroundColor() const { return self().foregroundColor(); }
|
||||||
|
auto icon() const { return self().icon(); }
|
||||||
|
auto reset() { return self().reset(), *this; }
|
||||||
|
auto setAlignment(Alignment alignment = {}) { return self().setAlignment(alignment), *this; }
|
||||||
|
auto setBackgroundColor(Color color = {}) { return self().setBackgroundColor(color), *this; }
|
||||||
|
auto setCheckable(bool checkable = true) { return self().setCheckable(checkable), *this; }
|
||||||
|
auto setChecked(bool checked = true) { return self().setChecked(checked), *this; }
|
||||||
|
auto setForegroundColor(Color color = {}) { return self().setForegroundColor(color), *this; }
|
||||||
|
auto setIcon(const image& icon = {}) { return self().setIcon(icon), *this; }
|
||||||
|
auto setText(const string& text = "") { return self().setText(text), *this; }
|
||||||
|
auto text() const { return self().text(); }
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(Hiro_ListView)
|
||||||
|
struct ListView : sListView {
|
||||||
|
DeclareSharedWidget(ListView)
|
||||||
|
|
||||||
|
auto alignment() const { return self().alignment(); }
|
||||||
|
auto append(sListViewItem item) { return self().append(item), *this; }
|
||||||
|
auto backgroundColor() const { return self().backgroundColor(); }
|
||||||
|
auto batchable() const { return self().batchable(); }
|
||||||
|
auto batched() const { return self().batched(); }
|
||||||
|
auto doActivate() const { return self().doActivate(); }
|
||||||
|
auto doChange() const { return self().doChange(); }
|
||||||
|
auto doContext() const { return self().doContext(); }
|
||||||
|
auto doToggle(ListViewItem item) const { return self().doToggle(item); }
|
||||||
|
auto foregroundColor() const { return self().foregroundColor(); }
|
||||||
|
auto item(uint position) const { return self().item(position); }
|
||||||
|
auto itemCount() const { return self().itemCount(); }
|
||||||
|
auto items() const { return self().items(); }
|
||||||
|
auto onActivate(const function<void ()>& callback = {}) { return self().onActivate(callback), *this; }
|
||||||
|
auto onChange(const function<void ()>& callback = {}) { return self().onChange(callback), *this; }
|
||||||
|
auto onContext(const function<void ()>& callback = {}) { return self().onContext(callback), *this; }
|
||||||
|
auto onToggle(const function<void (ListViewItem)>& callback = {}) { return self().onToggle(callback), *this; }
|
||||||
|
auto remove(sListViewItem item) { return self().remove(item), *this; }
|
||||||
|
auto reset() { return self().reset(), *this; }
|
||||||
|
auto selected() { return self().selected(); }
|
||||||
|
auto setAlignment(Alignment alignment = {}) { return self().setAlignment(alignment), *this; }
|
||||||
|
auto setBackgroundColor(Color color = {}) { return self().setBackgroundColor(color), *this; }
|
||||||
|
auto setBatchable(bool batchable = true) { return self().setBatchable(batchable), *this; }
|
||||||
|
auto setForegroundColor(Color color = {}) { return self().setForegroundColor(color), *this; }
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
|
@ -35,7 +35,7 @@ auto mVerticalLayout::minimumSize() const -> Size {
|
||||||
} else {
|
} else {
|
||||||
height += child.height;
|
height += child.height;
|
||||||
}
|
}
|
||||||
if(&child != &properties.last()) height += child.spacing;
|
if(&child != &properties.right()) height += child.spacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {settings.margin * 2 + width, settings.margin * 2 + height};
|
return {settings.margin * 2 + width, settings.margin * 2 + height};
|
||||||
|
@ -94,7 +94,7 @@ auto mVerticalLayout::setGeometry(Geometry containerGeometry) -> type& {
|
||||||
for(auto& child : properties) {
|
for(auto& child : properties) {
|
||||||
if(child.height == Size::Maximum) maximumHeightCounter++;
|
if(child.height == Size::Maximum) maximumHeightCounter++;
|
||||||
if(child.height != Size::Maximum) minimumHeight += child.height;
|
if(child.height != Size::Maximum) minimumHeight += child.height;
|
||||||
if(&child != &properties.last()) minimumHeight += child.spacing;
|
if(&child != &properties.right()) minimumHeight += child.spacing;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(auto& child : properties) {
|
for(auto& child : properties) {
|
||||||
|
|
|
@ -6,7 +6,7 @@ static auto BrowserWindow_addFilters(GtkWidget* dialog, lstring filters) -> void
|
||||||
for(auto& filter : filters) {
|
for(auto& filter : filters) {
|
||||||
GtkFileFilter* gtkFilter = gtk_file_filter_new();
|
GtkFileFilter* gtkFilter = gtk_file_filter_new();
|
||||||
gtk_file_filter_set_name(gtkFilter, filter);
|
gtk_file_filter_set_name(gtkFilter, filter);
|
||||||
lstring patterns = filter.split("(", 1L)(1).rtrim(")", 1L).split(",").strip();
|
lstring patterns = filter.split("(", 1L)(1).trimRight(")", 1L).split(",").strip();
|
||||||
for(auto& pattern : patterns) gtk_file_filter_add_pattern(gtkFilter, pattern);
|
for(auto& pattern : patterns) gtk_file_filter_add_pattern(gtkFilter, pattern);
|
||||||
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), gtkFilter);
|
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), gtkFilter);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,8 @@
|
||||||
#include "widget/check-label.cpp"
|
#include "widget/check-label.cpp"
|
||||||
#include "widget/combo-button.cpp"
|
#include "widget/combo-button.cpp"
|
||||||
#include "widget/combo-button-item.cpp"
|
#include "widget/combo-button-item.cpp"
|
||||||
|
#include "widget/combo-edit.cpp"
|
||||||
|
#include "widget/combo-edit-item.cpp"
|
||||||
#include "widget/console.cpp"
|
#include "widget/console.cpp"
|
||||||
#include "widget/frame.cpp"
|
#include "widget/frame.cpp"
|
||||||
#include "widget/hex-edit.cpp"
|
#include "widget/hex-edit.cpp"
|
||||||
|
@ -44,17 +46,17 @@
|
||||||
#include "widget/icon-view-item.cpp"
|
#include "widget/icon-view-item.cpp"
|
||||||
#include "widget/label.cpp"
|
#include "widget/label.cpp"
|
||||||
#include "widget/line-edit.cpp"
|
#include "widget/line-edit.cpp"
|
||||||
#include "widget/list-view.cpp"
|
|
||||||
#include "widget/list-view-header.cpp"
|
|
||||||
#include "widget/list-view-column.cpp"
|
|
||||||
#include "widget/list-view-item.cpp"
|
|
||||||
#include "widget/list-view-cell.cpp"
|
|
||||||
#include "widget/progress-bar.cpp"
|
#include "widget/progress-bar.cpp"
|
||||||
#include "widget/radio-button.cpp"
|
#include "widget/radio-button.cpp"
|
||||||
#include "widget/radio-label.cpp"
|
#include "widget/radio-label.cpp"
|
||||||
#include "widget/source-edit.cpp"
|
#include "widget/source-edit.cpp"
|
||||||
#include "widget/tab-frame.cpp"
|
#include "widget/tab-frame.cpp"
|
||||||
#include "widget/tab-frame-item.cpp"
|
#include "widget/tab-frame-item.cpp"
|
||||||
|
#include "widget/table-view.cpp"
|
||||||
|
#include "widget/table-view-header.cpp"
|
||||||
|
#include "widget/table-view-column.cpp"
|
||||||
|
#include "widget/table-view-item.cpp"
|
||||||
|
#include "widget/table-view-cell.cpp"
|
||||||
#include "widget/text-edit.cpp"
|
#include "widget/text-edit.cpp"
|
||||||
#include "widget/tree-view.cpp"
|
#include "widget/tree-view.cpp"
|
||||||
#include "widget/tree-view-item.cpp"
|
#include "widget/tree-view-item.cpp"
|
||||||
|
|
|
@ -46,6 +46,8 @@ namespace hiro {
|
||||||
#include "widget/check-label.hpp"
|
#include "widget/check-label.hpp"
|
||||||
#include "widget/combo-button.hpp"
|
#include "widget/combo-button.hpp"
|
||||||
#include "widget/combo-button-item.hpp"
|
#include "widget/combo-button-item.hpp"
|
||||||
|
#include "widget/combo-edit.hpp"
|
||||||
|
#include "widget/combo-edit-item.hpp"
|
||||||
#include "widget/console.hpp"
|
#include "widget/console.hpp"
|
||||||
#include "widget/frame.hpp"
|
#include "widget/frame.hpp"
|
||||||
#include "widget/hex-edit.hpp"
|
#include "widget/hex-edit.hpp"
|
||||||
|
@ -55,17 +57,17 @@ namespace hiro {
|
||||||
#include "widget/icon-view-item.hpp"
|
#include "widget/icon-view-item.hpp"
|
||||||
#include "widget/label.hpp"
|
#include "widget/label.hpp"
|
||||||
#include "widget/line-edit.hpp"
|
#include "widget/line-edit.hpp"
|
||||||
#include "widget/list-view.hpp"
|
|
||||||
#include "widget/list-view-header.hpp"
|
|
||||||
#include "widget/list-view-column.hpp"
|
|
||||||
#include "widget/list-view-item.hpp"
|
|
||||||
#include "widget/list-view-cell.hpp"
|
|
||||||
#include "widget/progress-bar.hpp"
|
#include "widget/progress-bar.hpp"
|
||||||
#include "widget/radio-button.hpp"
|
#include "widget/radio-button.hpp"
|
||||||
#include "widget/radio-label.hpp"
|
#include "widget/radio-label.hpp"
|
||||||
#include "widget/source-edit.hpp"
|
#include "widget/source-edit.hpp"
|
||||||
#include "widget/tab-frame.hpp"
|
#include "widget/tab-frame.hpp"
|
||||||
#include "widget/tab-frame-item.hpp"
|
#include "widget/tab-frame-item.hpp"
|
||||||
|
#include "widget/table-view.hpp"
|
||||||
|
#include "widget/table-view-header.hpp"
|
||||||
|
#include "widget/table-view-column.hpp"
|
||||||
|
#include "widget/table-view-item.hpp"
|
||||||
|
#include "widget/table-view-cell.hpp"
|
||||||
#include "widget/text-edit.hpp"
|
#include "widget/text-edit.hpp"
|
||||||
#include "widget/tree-view.hpp"
|
#include "widget/tree-view.hpp"
|
||||||
#include "widget/tree-view-item.hpp"
|
#include "widget/tree-view-item.hpp"
|
||||||
|
|
|
@ -13,12 +13,12 @@ Settings::Settings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Settings::load() -> void {
|
auto Settings::load() -> void {
|
||||||
string path = {configpath(), "hiro/"};
|
string path = {Path::config(), "hiro/"};
|
||||||
Configuration::Document::load({path, "gtk.bml"});
|
Configuration::Document::load({path, "gtk.bml"});
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Settings::save() -> void {
|
auto Settings::save() -> void {
|
||||||
string path = {configpath(), "hiro/"};
|
string path = {Path::config(), "hiro/"};
|
||||||
directory::create(path, 0755);
|
directory::create(path, 0755);
|
||||||
Configuration::Document::save({path, "gtk.bml"});
|
Configuration::Document::save({path, "gtk.bml"});
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ static auto Canvas_drop(GtkWidget* widget, GdkDragContext* context, signed x, si
|
||||||
GtkSelectionData* data, unsigned type, unsigned timestamp, pCanvas* p) -> void {
|
GtkSelectionData* data, unsigned type, unsigned timestamp, pCanvas* p) -> void {
|
||||||
if(!p->state().droppable) return;
|
if(!p->state().droppable) return;
|
||||||
lstring paths = DropPaths(data);
|
lstring paths = DropPaths(data);
|
||||||
if(paths.empty()) return;
|
if(!paths) return;
|
||||||
p->self().doDrop(paths);
|
p->self().doDrop(paths);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@ auto pComboButtonItem::destruct() -> void {
|
||||||
|
|
||||||
auto pComboButtonItem::setIcon(const image& icon) -> void {
|
auto pComboButtonItem::setIcon(const image& icon) -> void {
|
||||||
if(auto parent = _parent()) {
|
if(auto parent = _parent()) {
|
||||||
auto size = pFont::size(self().font(true), " ").height();
|
|
||||||
auto pixbuf = CreatePixbuf(icon, true);
|
auto pixbuf = CreatePixbuf(icon, true);
|
||||||
gtk_list_store_set(parent->gtkListStore, >kIter, 0, pixbuf, -1);
|
gtk_list_store_set(parent->gtkListStore, >kIter, 0, pixbuf, -1);
|
||||||
}
|
}
|
||||||
|
|
33
gtk/widget/combo-edit-item.cpp
Normal file
33
gtk/widget/combo-edit-item.cpp
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#if defined(Hiro_ComboEdit)
|
||||||
|
|
||||||
|
namespace hiro {
|
||||||
|
|
||||||
|
auto pComboEditItem::construct() -> void {
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pComboEditItem::destruct() -> void {
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pComboEditItem::setIcon(const image& icon) -> void {
|
||||||
|
if(auto parent = _parent()) {
|
||||||
|
auto pixbuf = CreatePixbuf(icon, true);
|
||||||
|
gtk_list_store_set(parent->gtkListStore, >kIter, 0, pixbuf, -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pComboEditItem::setText(const string& text) -> void {
|
||||||
|
if(auto parent = _parent()) {
|
||||||
|
gtk_list_store_set(parent->gtkListStore, >kIter, 1, text.data(), -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pComboEditItem::_parent() -> maybe<pComboEdit&> {
|
||||||
|
if(auto parent = self().parentComboEdit()) {
|
||||||
|
if(auto self = parent->self()) return *self;
|
||||||
|
}
|
||||||
|
return nothing;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
18
gtk/widget/combo-edit-item.hpp
Normal file
18
gtk/widget/combo-edit-item.hpp
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#if defined(Hiro_ComboEdit)
|
||||||
|
|
||||||
|
namespace hiro {
|
||||||
|
|
||||||
|
struct pComboEditItem : pObject {
|
||||||
|
Declare(ComboEditItem, Object)
|
||||||
|
|
||||||
|
auto setIcon(const image& icon) -> void;
|
||||||
|
auto setText(const string& text) -> void;
|
||||||
|
|
||||||
|
auto _parent() -> maybe<pComboEdit&>;
|
||||||
|
|
||||||
|
GtkTreeIter gtkIter;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
115
gtk/widget/combo-edit.cpp
Normal file
115
gtk/widget/combo-edit.cpp
Normal file
|
@ -0,0 +1,115 @@
|
||||||
|
#if defined(Hiro_ComboEdit)
|
||||||
|
|
||||||
|
namespace hiro {
|
||||||
|
|
||||||
|
static auto ComboEdit_activate(GtkComboBox* comboBox, pComboEdit* p) -> void { p->self().doActivate(); }
|
||||||
|
static auto ComboEdit_change(GtkComboBox* comboBox, pComboEdit* p) -> void { p->_updateText(); }
|
||||||
|
|
||||||
|
auto pComboEdit::construct() -> void {
|
||||||
|
gtkListStore = gtk_list_store_new(2, GDK_TYPE_PIXBUF, G_TYPE_STRING);
|
||||||
|
gtkTreeModel = GTK_TREE_MODEL(gtkListStore);
|
||||||
|
gtkWidget = gtk_combo_box_new_with_model_and_entry(gtkTreeModel);
|
||||||
|
gtkComboBox = GTK_COMBO_BOX(gtkWidget);
|
||||||
|
|
||||||
|
gtk_cell_layout_clear(GTK_CELL_LAYOUT(gtkWidget));
|
||||||
|
gtkCellIcon = gtk_cell_renderer_pixbuf_new();
|
||||||
|
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(gtkWidget), gtkCellIcon, false);
|
||||||
|
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(gtkWidget), gtkCellIcon, "pixbuf", 0, nullptr);
|
||||||
|
gtkCellText = gtk_cell_renderer_text_new();
|
||||||
|
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(gtkWidget), gtkCellText, true);
|
||||||
|
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(gtkWidget), gtkCellText, "text", 1, nullptr);
|
||||||
|
|
||||||
|
//we must call gtk_combo_box_set_entry_text_column(1) in order for GtkComboBoxEntry to pull text
|
||||||
|
//however, this API call throws a Gtk-CRITICAL assertion that column 1 is not a cell renderer
|
||||||
|
//this is, however, incorrect. it *is* a renderer, and the API call works as expected
|
||||||
|
//so in order to suppress the error message, we redirect stderr to /dev/null temporarily
|
||||||
|
int stdErr = dup(STDERR_FILENO);
|
||||||
|
int devNull = open("/dev/null", 0);
|
||||||
|
dup2(devNull, STDERR_FILENO);
|
||||||
|
gtk_combo_box_set_entry_text_column(gtkComboBox, 1);
|
||||||
|
dup2(stdErr, STDERR_FILENO);
|
||||||
|
close(devNull);
|
||||||
|
close(stdErr);
|
||||||
|
|
||||||
|
setBackgroundColor(state().backgroundColor);
|
||||||
|
setForegroundColor(state().foregroundColor);
|
||||||
|
for(auto& item : state().items) append(item);
|
||||||
|
|
||||||
|
g_signal_connect(G_OBJECT(gtk_bin_get_child(GTK_BIN(gtkComboBox))), "activate", G_CALLBACK(ComboEdit_activate), (gpointer)this);
|
||||||
|
g_signal_connect(G_OBJECT(gtkWidget), "changed", G_CALLBACK(ComboEdit_change), (gpointer)this);
|
||||||
|
|
||||||
|
pWidget::construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pComboEdit::destruct() -> void {
|
||||||
|
gtk_widget_destroy(gtkWidget);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pComboEdit::append(sComboEditItem item) -> void {
|
||||||
|
lock();
|
||||||
|
if(auto self = item->self()) {
|
||||||
|
gtk_list_store_append(gtkListStore, &self->gtkIter);
|
||||||
|
self->setIcon(item->state.icon);
|
||||||
|
self->setText(item->state.text);
|
||||||
|
}
|
||||||
|
unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pComboEdit::minimumSize() const -> Size {
|
||||||
|
auto font = self().font(true);
|
||||||
|
int maximumWidth = 0;
|
||||||
|
for(auto& item : state().items) {
|
||||||
|
maximumWidth = max(maximumWidth,
|
||||||
|
(item->state.icon ? pFont::size(font, " ").height() + 2 : 0)
|
||||||
|
+ pFont::size(font, item->state.text).width()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return {maximumWidth + 40, pFont::size(font, " ").height() + 12};
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pComboEdit::remove(sComboEditItem item) -> void {
|
||||||
|
lock();
|
||||||
|
if(auto delegate = item->self()) {
|
||||||
|
gtk_list_store_remove(gtkListStore, &delegate->gtkIter);
|
||||||
|
}
|
||||||
|
unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pComboEdit::reset() -> void {
|
||||||
|
lock();
|
||||||
|
gtk_list_store_clear(gtkListStore);
|
||||||
|
unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pComboEdit::setBackgroundColor(Color color) -> void {
|
||||||
|
GdkColor gdkColor = CreateColor(color);
|
||||||
|
gtk_widget_modify_base(gtk_bin_get_child(GTK_BIN(gtkComboBox)), GTK_STATE_NORMAL, color ? &gdkColor : nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pComboEdit::setForegroundColor(Color color) -> void {
|
||||||
|
GdkColor gdkColor = CreateColor(color);
|
||||||
|
gtk_widget_modify_text(gtk_bin_get_child(GTK_BIN(gtkComboBox)), GTK_STATE_NORMAL, color ? &gdkColor : nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pComboEdit::setFont(const Font& font) -> void {
|
||||||
|
pWidget::setFont(font);
|
||||||
|
auto fontDescription = pFont::create(font);
|
||||||
|
g_object_set(G_OBJECT(gtkCellText), "font-desc", fontDescription, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pComboEdit::setText(const string& text) -> void {
|
||||||
|
lock();
|
||||||
|
gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(gtkComboBox))), text);
|
||||||
|
unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pComboEdit::_updateText() -> void {
|
||||||
|
string text = gtk_entry_get_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(gtkComboBox))));
|
||||||
|
if(text == state().text) return;
|
||||||
|
state().text = text;
|
||||||
|
if(!locked()) self().doChange();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
28
gtk/widget/combo-edit.hpp
Normal file
28
gtk/widget/combo-edit.hpp
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
#if defined(Hiro_ComboEdit)
|
||||||
|
|
||||||
|
namespace hiro {
|
||||||
|
|
||||||
|
struct pComboEdit : pWidget {
|
||||||
|
Declare(ComboEdit, Widget)
|
||||||
|
|
||||||
|
auto append(sComboEditItem item) -> void;
|
||||||
|
auto minimumSize() const -> Size override;
|
||||||
|
auto remove(sComboEditItem item) -> void;
|
||||||
|
auto reset() -> void;
|
||||||
|
auto setBackgroundColor(Color color) -> void;
|
||||||
|
auto setForegroundColor(Color color) -> void;
|
||||||
|
auto setFont(const Font& font) -> void override;
|
||||||
|
auto setText(const string& text) -> void;
|
||||||
|
|
||||||
|
auto _updateText() -> void;
|
||||||
|
|
||||||
|
GtkListStore* gtkListStore = nullptr;
|
||||||
|
GtkTreeModel* gtkTreeModel = nullptr;
|
||||||
|
GtkComboBox* gtkComboBox = nullptr;
|
||||||
|
GtkCellRenderer* gtkCellIcon = nullptr;
|
||||||
|
GtkCellRenderer* gtkCellText = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -83,7 +83,7 @@ auto pConsole::_keyPress(unsigned scancode, unsigned mask) -> bool {
|
||||||
gtk_text_buffer_insert(textBuffer, &end, string{"\n", state().prompt}, -1);
|
gtk_text_buffer_insert(textBuffer, &end, string{"\n", state().prompt}, -1);
|
||||||
self().doActivate(s);
|
self().doActivate(s);
|
||||||
if(s) history.prepend(s);
|
if(s) history.prepend(s);
|
||||||
if(history.size() > 128) history.removeLast();
|
if(history.size() > 128) history.removeRight();
|
||||||
historyOffset = 0;
|
historyOffset = 0;
|
||||||
_seekToEnd();
|
_seekToEnd();
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1,41 +0,0 @@
|
||||||
#if defined(Hiro_ListView)
|
|
||||||
|
|
||||||
namespace hiro {
|
|
||||||
|
|
||||||
auto pListViewHeader::construct() -> void {
|
|
||||||
_setState();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewHeader::destruct() -> void {
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewHeader::append(sListViewColumn column) -> void {
|
|
||||||
_setState();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewHeader::remove(sListViewColumn column) -> void {
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewHeader::setVisible(bool visible) -> void {
|
|
||||||
_setState();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewHeader::_parent() -> maybe<pListView&> {
|
|
||||||
if(auto parent = self().parentListView()) {
|
|
||||||
if(auto self = parent->self()) return *self;
|
|
||||||
}
|
|
||||||
return nothing;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewHeader::_setState() -> void {
|
|
||||||
if(auto parent = _parent()) {
|
|
||||||
gtk_tree_view_set_headers_visible(parent->gtkTreeView, self().visible());
|
|
||||||
for(auto& column : state().columns) {
|
|
||||||
if(auto self = column->self()) self->_setState();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,18 +0,0 @@
|
||||||
#if defined(Hiro_ListView)
|
|
||||||
|
|
||||||
namespace hiro {
|
|
||||||
|
|
||||||
struct pListViewHeader : pObject {
|
|
||||||
Declare(ListViewHeader, Object)
|
|
||||||
|
|
||||||
auto append(sListViewColumn column) -> void;
|
|
||||||
auto remove(sListViewColumn column) -> void;
|
|
||||||
auto setVisible(bool visible) -> void override;
|
|
||||||
|
|
||||||
auto _parent() -> maybe<pListView&>;
|
|
||||||
auto _setState() -> void;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,51 +1,51 @@
|
||||||
#if defined(Hiro_ListView)
|
#if defined(Hiro_TableView)
|
||||||
|
|
||||||
namespace hiro {
|
namespace hiro {
|
||||||
|
|
||||||
auto pListViewCell::construct() -> void {
|
auto pTableViewCell::construct() -> void {
|
||||||
_setState();
|
_setState();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewCell::destruct() -> void {
|
auto pTableViewCell::destruct() -> void {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewCell::setAlignment(Alignment alignment) -> void {
|
auto pTableViewCell::setAlignment(Alignment alignment) -> void {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewCell::setBackgroundColor(Color color) -> void {
|
auto pTableViewCell::setBackgroundColor(Color color) -> void {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewCell::setCheckable(bool checkable) -> void {
|
auto pTableViewCell::setCheckable(bool checkable) -> void {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewCell::setChecked(bool checked) -> void {
|
auto pTableViewCell::setChecked(bool checked) -> void {
|
||||||
_setState();
|
_setState();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewCell::setForegroundColor(Color color) -> void {
|
auto pTableViewCell::setForegroundColor(Color color) -> void {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewCell::setIcon(const image& icon) -> void {
|
auto pTableViewCell::setIcon(const image& icon) -> void {
|
||||||
_setState();
|
_setState();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewCell::setText(const string& text) -> void {
|
auto pTableViewCell::setText(const string& text) -> void {
|
||||||
_setState();
|
_setState();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewCell::_grandparent() -> maybe<pListView&> {
|
auto pTableViewCell::_grandparent() -> maybe<pTableView&> {
|
||||||
if(auto parent = _parent()) return parent->_parent();
|
if(auto parent = _parent()) return parent->_parent();
|
||||||
return nothing;
|
return nothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewCell::_parent() -> maybe<pListViewItem&> {
|
auto pTableViewCell::_parent() -> maybe<pTableViewItem&> {
|
||||||
if(auto parent = self().parentListViewItem()) {
|
if(auto parent = self().parentTableViewItem()) {
|
||||||
if(auto self = parent->self()) return *self;
|
if(auto self = parent->self()) return *self;
|
||||||
}
|
}
|
||||||
return nothing;
|
return nothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewCell::_setState() -> void {
|
auto pTableViewCell::_setState() -> void {
|
||||||
if(auto parent = _parent()) {
|
if(auto parent = _parent()) {
|
||||||
if(auto grandparent = _grandparent()) {
|
if(auto grandparent = _grandparent()) {
|
||||||
grandparent->lock();
|
grandparent->lock();
|
|
@ -1,9 +1,9 @@
|
||||||
#if defined(Hiro_ListView)
|
#if defined(Hiro_TableView)
|
||||||
|
|
||||||
namespace hiro {
|
namespace hiro {
|
||||||
|
|
||||||
struct pListViewCell : pObject {
|
struct pTableViewCell : pObject {
|
||||||
Declare(ListViewCell, Object)
|
Declare(TableViewCell, Object)
|
||||||
|
|
||||||
auto setAlignment(Alignment alignment) -> void;
|
auto setAlignment(Alignment alignment) -> void;
|
||||||
auto setBackgroundColor(Color color) -> void;
|
auto setBackgroundColor(Color color) -> void;
|
||||||
|
@ -13,8 +13,8 @@ struct pListViewCell : pObject {
|
||||||
auto setIcon(const image& icon) -> void;
|
auto setIcon(const image& icon) -> void;
|
||||||
auto setText(const string& text) -> void;
|
auto setText(const string& text) -> void;
|
||||||
|
|
||||||
auto _grandparent() -> maybe<pListView&>;
|
auto _grandparent() -> maybe<pTableView&>;
|
||||||
auto _parent() -> maybe<pListViewItem&>;
|
auto _parent() -> maybe<pTableViewItem&>;
|
||||||
auto _setState() -> void;
|
auto _setState() -> void;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#if defined(Hiro_ListView)
|
#if defined(Hiro_TableView)
|
||||||
|
|
||||||
namespace hiro {
|
namespace hiro {
|
||||||
|
|
||||||
auto pListViewColumn::construct() -> void {
|
auto pTableViewColumn::construct() -> void {
|
||||||
if(auto grandparent = _grandparent()) {
|
if(auto grandparent = _grandparent()) {
|
||||||
auto handle = grandparent.data();
|
auto handle = grandparent.data();
|
||||||
unsigned offset = self().offset();
|
unsigned offset = self().offset();
|
||||||
|
@ -23,21 +23,21 @@ auto pListViewColumn::construct() -> void {
|
||||||
gtkCellToggle = gtk_cell_renderer_toggle_new();
|
gtkCellToggle = gtk_cell_renderer_toggle_new();
|
||||||
gtk_tree_view_column_pack_start(gtkColumn, gtkCellToggle, false);
|
gtk_tree_view_column_pack_start(gtkColumn, gtkCellToggle, false);
|
||||||
gtk_tree_view_column_set_attributes(gtkColumn, gtkCellToggle, "active", 3 * offset + 0, nullptr);
|
gtk_tree_view_column_set_attributes(gtkColumn, gtkCellToggle, "active", 3 * offset + 0, nullptr);
|
||||||
gtk_tree_view_column_set_cell_data_func(gtkColumn, GTK_CELL_RENDERER(gtkCellToggle), (GtkTreeCellDataFunc)ListView_dataFunc, (gpointer)handle, nullptr);
|
gtk_tree_view_column_set_cell_data_func(gtkColumn, GTK_CELL_RENDERER(gtkCellToggle), (GtkTreeCellDataFunc)TableView_dataFunc, (gpointer)handle, nullptr);
|
||||||
|
|
||||||
gtkCellIcon = gtk_cell_renderer_pixbuf_new();
|
gtkCellIcon = gtk_cell_renderer_pixbuf_new();
|
||||||
gtk_tree_view_column_pack_start(gtkColumn, gtkCellIcon, false);
|
gtk_tree_view_column_pack_start(gtkColumn, gtkCellIcon, false);
|
||||||
gtk_tree_view_column_set_attributes(gtkColumn, gtkCellIcon, "pixbuf", 3 * offset + 1, nullptr);
|
gtk_tree_view_column_set_attributes(gtkColumn, gtkCellIcon, "pixbuf", 3 * offset + 1, nullptr);
|
||||||
gtk_tree_view_column_set_cell_data_func(gtkColumn, GTK_CELL_RENDERER(gtkCellIcon), (GtkTreeCellDataFunc)ListView_dataFunc, (gpointer)handle, nullptr);
|
gtk_tree_view_column_set_cell_data_func(gtkColumn, GTK_CELL_RENDERER(gtkCellIcon), (GtkTreeCellDataFunc)TableView_dataFunc, (gpointer)handle, nullptr);
|
||||||
|
|
||||||
gtkCellText = gtk_cell_renderer_text_new();
|
gtkCellText = gtk_cell_renderer_text_new();
|
||||||
gtk_tree_view_column_pack_start(gtkColumn, gtkCellText, true); //text must expand to cell width for horizontal alignment to work
|
gtk_tree_view_column_pack_start(gtkColumn, gtkCellText, true); //text must expand to cell width for horizontal alignment to work
|
||||||
gtk_tree_view_column_set_attributes(gtkColumn, gtkCellText, "text", 3 * offset + 2, nullptr);
|
gtk_tree_view_column_set_attributes(gtkColumn, gtkCellText, "text", 3 * offset + 2, nullptr);
|
||||||
gtk_tree_view_column_set_cell_data_func(gtkColumn, GTK_CELL_RENDERER(gtkCellText), (GtkTreeCellDataFunc)ListView_dataFunc, (gpointer)handle, nullptr);
|
gtk_tree_view_column_set_cell_data_func(gtkColumn, GTK_CELL_RENDERER(gtkCellText), (GtkTreeCellDataFunc)TableView_dataFunc, (gpointer)handle, nullptr);
|
||||||
|
|
||||||
g_signal_connect(G_OBJECT(gtkColumn), "clicked", G_CALLBACK(ListView_headerActivate), (gpointer)handle);
|
g_signal_connect(G_OBJECT(gtkColumn), "clicked", G_CALLBACK(TableView_headerActivate), (gpointer)handle);
|
||||||
g_signal_connect(G_OBJECT(gtkCellText), "edited", G_CALLBACK(ListView_edit), (gpointer)handle);
|
g_signal_connect(G_OBJECT(gtkCellText), "edited", G_CALLBACK(TableView_edit), (gpointer)handle);
|
||||||
g_signal_connect(G_OBJECT(gtkCellToggle), "toggled", G_CALLBACK(ListView_toggle), (gpointer)handle);
|
g_signal_connect(G_OBJECT(gtkCellToggle), "toggled", G_CALLBACK(TableView_toggle), (gpointer)handle);
|
||||||
|
|
||||||
gtk_tree_view_append_column(grandparent->gtkTreeView, gtkColumn);
|
gtk_tree_view_append_column(grandparent->gtkTreeView, gtkColumn);
|
||||||
gtk_widget_show_all(gtkHeader);
|
gtk_widget_show_all(gtkHeader);
|
||||||
|
@ -47,7 +47,7 @@ auto pListViewColumn::construct() -> void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewColumn::destruct() -> void {
|
auto pTableViewColumn::destruct() -> void {
|
||||||
if(auto grandparent = _grandparent()) {
|
if(auto grandparent = _grandparent()) {
|
||||||
gtk_tree_view_remove_column(grandparent->gtkTreeView, gtkColumn);
|
gtk_tree_view_remove_column(grandparent->gtkTreeView, gtkColumn);
|
||||||
gtkColumn = nullptr;
|
gtkColumn = nullptr;
|
||||||
|
@ -55,33 +55,33 @@ auto pListViewColumn::destruct() -> void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewColumn::setActive() -> void {
|
auto pTableViewColumn::setActive() -> void {
|
||||||
_setState();
|
_setState();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewColumn::setAlignment(Alignment alignment) -> void {
|
auto pTableViewColumn::setAlignment(Alignment alignment) -> void {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewColumn::setBackgroundColor(Color color) -> void {
|
auto pTableViewColumn::setBackgroundColor(Color color) -> void {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewColumn::setEditable(bool editable) -> void {
|
auto pTableViewColumn::setEditable(bool editable) -> void {
|
||||||
g_object_set(G_OBJECT(gtkCellText), "editable", editable ? true : false, nullptr);
|
g_object_set(G_OBJECT(gtkCellText), "editable", editable ? true : false, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewColumn::setExpandable(bool expandable) -> void {
|
auto pTableViewColumn::setExpandable(bool expandable) -> void {
|
||||||
if(auto grandparent = _grandparent()) {
|
if(auto grandparent = _grandparent()) {
|
||||||
grandparent->resizeColumns();
|
grandparent->resizeColumns();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewColumn::setFont(const Font& font) -> void {
|
auto pTableViewColumn::setFont(const Font& font) -> void {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewColumn::setForegroundColor(Color color) -> void {
|
auto pTableViewColumn::setForegroundColor(Color color) -> void {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewColumn::setIcon(const image& icon) -> void {
|
auto pTableViewColumn::setIcon(const image& icon) -> void {
|
||||||
if(icon) {
|
if(icon) {
|
||||||
gtk_image_set_from_pixbuf(GTK_IMAGE(gtkHeaderIcon), CreatePixbuf(icon));
|
gtk_image_set_from_pixbuf(GTK_IMAGE(gtkHeaderIcon), CreatePixbuf(icon));
|
||||||
} else {
|
} else {
|
||||||
|
@ -89,41 +89,41 @@ auto pListViewColumn::setIcon(const image& icon) -> void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewColumn::setResizable(bool resizable) -> void {
|
auto pTableViewColumn::setResizable(bool resizable) -> void {
|
||||||
_setState();
|
_setState();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewColumn::setSortable(bool sortable) -> void {
|
auto pTableViewColumn::setSortable(bool sortable) -> void {
|
||||||
_setState();
|
_setState();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewColumn::setText(const string& text) -> void {
|
auto pTableViewColumn::setText(const string& text) -> void {
|
||||||
_setState();
|
_setState();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewColumn::setVisible(bool visible) -> void {
|
auto pTableViewColumn::setVisible(bool visible) -> void {
|
||||||
_setState();
|
_setState();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewColumn::setWidth(signed width) -> void {
|
auto pTableViewColumn::setWidth(signed width) -> void {
|
||||||
if(auto grandparent = _grandparent()) {
|
if(auto grandparent = _grandparent()) {
|
||||||
grandparent->resizeColumns();
|
grandparent->resizeColumns();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewColumn::_grandparent() -> maybe<pListView&> {
|
auto pTableViewColumn::_grandparent() -> maybe<pTableView&> {
|
||||||
if(auto parent = _parent()) return parent->_parent();
|
if(auto parent = _parent()) return parent->_parent();
|
||||||
return nothing;
|
return nothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewColumn::_parent() -> maybe<pListViewHeader&> {
|
auto pTableViewColumn::_parent() -> maybe<pTableViewHeader&> {
|
||||||
if(auto parent = self().parentListViewHeader()) {
|
if(auto parent = self().parentTableViewHeader()) {
|
||||||
if(auto self = parent->self()) return *self;
|
if(auto self = parent->self()) return *self;
|
||||||
}
|
}
|
||||||
return nothing;
|
return nothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewColumn::_setState() -> void {
|
auto pTableViewColumn::_setState() -> void {
|
||||||
if(auto grandparent = _grandparent()) {
|
if(auto grandparent = _grandparent()) {
|
||||||
gtk_tree_view_set_search_column(grandparent->gtkTreeView, 3 * self().offset() + 2);
|
gtk_tree_view_set_search_column(grandparent->gtkTreeView, 3 * self().offset() + 2);
|
||||||
gtk_tree_view_column_set_resizable(gtkColumn, state().resizable);
|
gtk_tree_view_column_set_resizable(gtkColumn, state().resizable);
|
|
@ -1,9 +1,9 @@
|
||||||
#if defined(Hiro_ListView)
|
#if defined(Hiro_TableView)
|
||||||
|
|
||||||
namespace hiro {
|
namespace hiro {
|
||||||
|
|
||||||
struct pListViewColumn : pObject {
|
struct pTableViewColumn : pObject {
|
||||||
Declare(ListViewColumn, Object)
|
Declare(TableViewColumn, Object)
|
||||||
|
|
||||||
auto setActive() -> void;
|
auto setActive() -> void;
|
||||||
auto setAlignment(Alignment alignment) -> void;
|
auto setAlignment(Alignment alignment) -> void;
|
||||||
|
@ -21,8 +21,8 @@ struct pListViewColumn : pObject {
|
||||||
auto setVisible(bool visible) -> void override;
|
auto setVisible(bool visible) -> void override;
|
||||||
auto setWidth(signed width) -> void;
|
auto setWidth(signed width) -> void;
|
||||||
|
|
||||||
auto _grandparent() -> maybe<pListView&>;
|
auto _grandparent() -> maybe<pTableView&>;
|
||||||
auto _parent() -> maybe<pListViewHeader&>;
|
auto _parent() -> maybe<pTableViewHeader&>;
|
||||||
auto _setState() -> void;
|
auto _setState() -> void;
|
||||||
|
|
||||||
GtkTreeViewColumn* gtkColumn = nullptr;
|
GtkTreeViewColumn* gtkColumn = nullptr;
|
41
gtk/widget/table-view-header.cpp
Normal file
41
gtk/widget/table-view-header.cpp
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
#if defined(Hiro_TableView)
|
||||||
|
|
||||||
|
namespace hiro {
|
||||||
|
|
||||||
|
auto pTableViewHeader::construct() -> void {
|
||||||
|
_setState();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewHeader::destruct() -> void {
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewHeader::append(sTableViewColumn column) -> void {
|
||||||
|
_setState();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewHeader::remove(sTableViewColumn column) -> void {
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewHeader::setVisible(bool visible) -> void {
|
||||||
|
_setState();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewHeader::_parent() -> maybe<pTableView&> {
|
||||||
|
if(auto parent = self().parentTableView()) {
|
||||||
|
if(auto self = parent->self()) return *self;
|
||||||
|
}
|
||||||
|
return nothing;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewHeader::_setState() -> void {
|
||||||
|
if(auto parent = _parent()) {
|
||||||
|
gtk_tree_view_set_headers_visible(parent->gtkTreeView, self().visible());
|
||||||
|
for(auto& column : state().columns) {
|
||||||
|
if(auto self = column->self()) self->_setState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
18
gtk/widget/table-view-header.hpp
Normal file
18
gtk/widget/table-view-header.hpp
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#if defined(Hiro_TableView)
|
||||||
|
|
||||||
|
namespace hiro {
|
||||||
|
|
||||||
|
struct pTableViewHeader : pObject {
|
||||||
|
Declare(TableViewHeader, Object)
|
||||||
|
|
||||||
|
auto append(sTableViewColumn column) -> void;
|
||||||
|
auto remove(sTableViewColumn column) -> void;
|
||||||
|
auto setVisible(bool visible) -> void override;
|
||||||
|
|
||||||
|
auto _parent() -> maybe<pTableView&>;
|
||||||
|
auto _setState() -> void;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,8 +1,8 @@
|
||||||
#if defined(Hiro_ListView)
|
#if defined(Hiro_TableView)
|
||||||
|
|
||||||
namespace hiro {
|
namespace hiro {
|
||||||
|
|
||||||
auto pListViewItem::construct() -> void {
|
auto pTableViewItem::construct() -> void {
|
||||||
if(auto parent = _parent()) {
|
if(auto parent = _parent()) {
|
||||||
parent->lock();
|
parent->lock();
|
||||||
gtk_list_store_append(parent->gtkListStore, >kIter);
|
gtk_list_store_append(parent->gtkListStore, >kIter);
|
||||||
|
@ -11,7 +11,7 @@ auto pListViewItem::construct() -> void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewItem::destruct() -> void {
|
auto pTableViewItem::destruct() -> void {
|
||||||
if(auto parent = _parent()) {
|
if(auto parent = _parent()) {
|
||||||
parent->lock();
|
parent->lock();
|
||||||
gtk_list_store_remove(parent->gtkListStore, >kIter);
|
gtk_list_store_remove(parent->gtkListStore, >kIter);
|
||||||
|
@ -20,19 +20,19 @@ auto pListViewItem::destruct() -> void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewItem::append(sListViewCell cell) -> void {
|
auto pTableViewItem::append(sTableViewCell cell) -> void {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewItem::remove(sListViewCell cell) -> void {
|
auto pTableViewItem::remove(sTableViewCell cell) -> void {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewItem::setAlignment(Alignment alignment) -> void {
|
auto pTableViewItem::setAlignment(Alignment alignment) -> void {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewItem::setBackgroundColor(Color color) -> void {
|
auto pTableViewItem::setBackgroundColor(Color color) -> void {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewItem::setFocused() -> void {
|
auto pTableViewItem::setFocused() -> void {
|
||||||
if(auto parent = _parent()) {
|
if(auto parent = _parent()) {
|
||||||
GtkTreePath* path = gtk_tree_path_new_from_string(string{self().offset()});
|
GtkTreePath* path = gtk_tree_path_new_from_string(string{self().offset()});
|
||||||
gtk_tree_view_set_cursor(parent->gtkTreeView, path, nullptr, false);
|
gtk_tree_view_set_cursor(parent->gtkTreeView, path, nullptr, false);
|
||||||
|
@ -41,21 +41,21 @@ auto pListViewItem::setFocused() -> void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewItem::setForegroundColor(Color color) -> void {
|
auto pTableViewItem::setForegroundColor(Color color) -> void {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewItem::setSelected(bool selected) -> void {
|
auto pTableViewItem::setSelected(bool selected) -> void {
|
||||||
_setState();
|
_setState();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewItem::_parent() -> maybe<pListView&> {
|
auto pTableViewItem::_parent() -> maybe<pTableView&> {
|
||||||
if(auto parent = self().parentListView()) {
|
if(auto parent = self().parentTableView()) {
|
||||||
if(auto self = parent->self()) return *self;
|
if(auto self = parent->self()) return *self;
|
||||||
}
|
}
|
||||||
return nothing;
|
return nothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewItem::_setState() -> void {
|
auto pTableViewItem::_setState() -> void {
|
||||||
if(auto parent = _parent()) {
|
if(auto parent = _parent()) {
|
||||||
parent->lock();
|
parent->lock();
|
||||||
if(state().selected) {
|
if(state().selected) {
|
|
@ -1,19 +1,19 @@
|
||||||
#if defined(Hiro_ListView)
|
#if defined(Hiro_TableView)
|
||||||
|
|
||||||
namespace hiro {
|
namespace hiro {
|
||||||
|
|
||||||
struct pListViewItem : pObject {
|
struct pTableViewItem : pObject {
|
||||||
Declare(ListViewItem, Object)
|
Declare(TableViewItem, Object)
|
||||||
|
|
||||||
auto append(sListViewCell cell) -> void;
|
auto append(sTableViewCell cell) -> void;
|
||||||
auto remove(sListViewCell cell) -> void;
|
auto remove(sTableViewCell cell) -> void;
|
||||||
auto setAlignment(Alignment alignment) -> void;
|
auto setAlignment(Alignment alignment) -> void;
|
||||||
auto setBackgroundColor(Color color) -> void;
|
auto setBackgroundColor(Color color) -> void;
|
||||||
auto setFocused() -> void;
|
auto setFocused() -> void;
|
||||||
auto setForegroundColor(Color color) -> void;
|
auto setForegroundColor(Color color) -> void;
|
||||||
auto setSelected(bool selected) -> void;
|
auto setSelected(bool selected) -> void;
|
||||||
|
|
||||||
auto _parent() -> maybe<pListView&>;
|
auto _parent() -> maybe<pTableView&>;
|
||||||
auto _setState() -> void;
|
auto _setState() -> void;
|
||||||
|
|
||||||
GtkTreeIter gtkIter;
|
GtkTreeIter gtkIter;
|
|
@ -1,21 +1,21 @@
|
||||||
#if defined(Hiro_ListView)
|
#if defined(Hiro_TableView)
|
||||||
|
|
||||||
namespace hiro {
|
namespace hiro {
|
||||||
|
|
||||||
static auto ListView_activate(GtkTreeView*, GtkTreePath*, GtkTreeViewColumn*, pListView* p) -> void { return p->_doActivate(); }
|
static auto TableView_activate(GtkTreeView*, GtkTreePath*, GtkTreeViewColumn*, pTableView* p) -> void { return p->_doActivate(); }
|
||||||
static auto ListView_buttonEvent(GtkTreeView* treeView, GdkEventButton* event, pListView* p) -> signed { return p->_doEvent(event); }
|
static auto TableView_buttonEvent(GtkTreeView* treeView, GdkEventButton* event, pTableView* p) -> signed { return p->_doEvent(event); }
|
||||||
static auto ListView_change(GtkTreeSelection*, pListView* p) -> void { return p->_doChange(); }
|
static auto TableView_change(GtkTreeSelection*, pTableView* p) -> void { return p->_doChange(); }
|
||||||
static auto ListView_edit(GtkCellRendererText* renderer, const char* path, const char* text, pListView* p) -> void { return p->_doEdit(renderer, path, text); }
|
static auto TableView_edit(GtkCellRendererText* renderer, const char* path, const char* text, pTableView* p) -> void { return p->_doEdit(renderer, path, text); }
|
||||||
static auto ListView_headerActivate(GtkTreeViewColumn* column, pListView* p) -> void { return p->_doHeaderActivate(column); }
|
static auto TableView_headerActivate(GtkTreeViewColumn* column, pTableView* p) -> void { return p->_doHeaderActivate(column); }
|
||||||
static auto ListView_mouseMoveEvent(GtkWidget*, GdkEvent*, pListView* p) -> signed { return p->_doMouseMove(); }
|
static auto TableView_mouseMoveEvent(GtkWidget*, GdkEvent*, pTableView* p) -> signed { return p->_doMouseMove(); }
|
||||||
static auto ListView_popup(GtkTreeView*, pListView* p) -> void { return p->_doContext(); }
|
static auto TableView_popup(GtkTreeView*, pTableView* p) -> void { return p->_doContext(); }
|
||||||
|
|
||||||
static auto ListView_dataFunc(GtkTreeViewColumn* column, GtkCellRenderer* renderer, GtkTreeModel* model, GtkTreeIter* iter, pListView* p) -> void { return p->_doDataFunc(column, renderer, iter); }
|
static auto TableView_dataFunc(GtkTreeViewColumn* column, GtkCellRenderer* renderer, GtkTreeModel* model, GtkTreeIter* iter, pTableView* p) -> void { return p->_doDataFunc(column, renderer, iter); }
|
||||||
static auto ListView_toggle(GtkCellRendererToggle* toggle, const char* path, pListView* p) -> void { return p->_doToggle(toggle, path); }
|
static auto TableView_toggle(GtkCellRendererToggle* toggle, const char* path, pTableView* p) -> void { return p->_doToggle(toggle, path); }
|
||||||
|
|
||||||
//gtk_tree_view_set_rules_hint(gtkTreeView, true);
|
//gtk_tree_view_set_rules_hint(gtkTreeView, true);
|
||||||
|
|
||||||
auto pListView::construct() -> void {
|
auto pTableView::construct() -> void {
|
||||||
gtkWidget = gtk_scrolled_window_new(0, 0);
|
gtkWidget = gtk_scrolled_window_new(0, 0);
|
||||||
gtkScrolledWindow = GTK_SCROLLED_WINDOW(gtkWidget);
|
gtkScrolledWindow = GTK_SCROLLED_WINDOW(gtkWidget);
|
||||||
gtk_scrolled_window_set_policy(gtkScrolledWindow, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
gtk_scrolled_window_set_policy(gtkScrolledWindow, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
||||||
|
@ -35,38 +35,38 @@ auto pListView::construct() -> void {
|
||||||
setFont(self().font(true));
|
setFont(self().font(true));
|
||||||
setForegroundColor(state().foregroundColor);
|
setForegroundColor(state().foregroundColor);
|
||||||
|
|
||||||
g_signal_connect(G_OBJECT(gtkTreeView), "button-press-event", G_CALLBACK(ListView_buttonEvent), (gpointer)this);
|
g_signal_connect(G_OBJECT(gtkTreeView), "button-press-event", G_CALLBACK(TableView_buttonEvent), (gpointer)this);
|
||||||
g_signal_connect(G_OBJECT(gtkTreeView), "button-release-event", G_CALLBACK(ListView_buttonEvent), (gpointer)this);
|
g_signal_connect(G_OBJECT(gtkTreeView), "button-release-event", G_CALLBACK(TableView_buttonEvent), (gpointer)this);
|
||||||
g_signal_connect(G_OBJECT(gtkTreeView), "motion-notify-event", G_CALLBACK(ListView_mouseMoveEvent), (gpointer)this);
|
g_signal_connect(G_OBJECT(gtkTreeView), "motion-notify-event", G_CALLBACK(TableView_mouseMoveEvent), (gpointer)this);
|
||||||
g_signal_connect(G_OBJECT(gtkTreeView), "popup-menu", G_CALLBACK(ListView_popup), (gpointer)this);
|
g_signal_connect(G_OBJECT(gtkTreeView), "popup-menu", G_CALLBACK(TableView_popup), (gpointer)this);
|
||||||
g_signal_connect(G_OBJECT(gtkTreeView), "row-activated", G_CALLBACK(ListView_activate), (gpointer)this);
|
g_signal_connect(G_OBJECT(gtkTreeView), "row-activated", G_CALLBACK(TableView_activate), (gpointer)this);
|
||||||
g_signal_connect(G_OBJECT(gtkTreeSelection), "changed", G_CALLBACK(ListView_change), (gpointer)this);
|
g_signal_connect(G_OBJECT(gtkTreeSelection), "changed", G_CALLBACK(TableView_change), (gpointer)this);
|
||||||
|
|
||||||
pWidget::construct();
|
pWidget::construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::destruct() -> void {
|
auto pTableView::destruct() -> void {
|
||||||
gtk_widget_destroy(gtkWidgetChild);
|
gtk_widget_destroy(gtkWidgetChild);
|
||||||
gtk_widget_destroy(gtkWidget);
|
gtk_widget_destroy(gtkWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::append(sListViewHeader header) -> void {
|
auto pTableView::append(sTableViewHeader header) -> void {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::append(sListViewItem item) -> void {
|
auto pTableView::append(sTableViewItem item) -> void {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::focused() const -> bool {
|
auto pTableView::focused() const -> bool {
|
||||||
return GTK_WIDGET_HAS_FOCUS(gtkTreeView);
|
return GTK_WIDGET_HAS_FOCUS(gtkTreeView);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::remove(sListViewHeader header) -> void {
|
auto pTableView::remove(sTableViewHeader header) -> void {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::remove(sListViewItem item) -> void {
|
auto pTableView::remove(sTableViewItem item) -> void {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::resizeColumns() -> void {
|
auto pTableView::resizeColumns() -> void {
|
||||||
lock();
|
lock();
|
||||||
|
|
||||||
if(auto& header = state().header) {
|
if(auto& header = state().header) {
|
||||||
|
@ -102,23 +102,23 @@ auto pListView::resizeColumns() -> void {
|
||||||
unlock();
|
unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::setAlignment(Alignment alignment) -> void {
|
auto pTableView::setAlignment(Alignment alignment) -> void {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::setBackgroundColor(Color color) -> void {
|
auto pTableView::setBackgroundColor(Color color) -> void {
|
||||||
GdkColor gdkColor = CreateColor(color);
|
GdkColor gdkColor = CreateColor(color);
|
||||||
gtk_widget_modify_base(gtkWidgetChild, GTK_STATE_NORMAL, color ? &gdkColor : nullptr);
|
gtk_widget_modify_base(gtkWidgetChild, GTK_STATE_NORMAL, color ? &gdkColor : nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::setBatchable(bool batchable) -> void {
|
auto pTableView::setBatchable(bool batchable) -> void {
|
||||||
gtk_tree_selection_set_mode(gtkTreeSelection, batchable ? GTK_SELECTION_MULTIPLE : GTK_SELECTION_SINGLE);
|
gtk_tree_selection_set_mode(gtkTreeSelection, batchable ? GTK_SELECTION_MULTIPLE : GTK_SELECTION_SINGLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::setBordered(bool bordered) -> void {
|
auto pTableView::setBordered(bool bordered) -> void {
|
||||||
gtk_tree_view_set_grid_lines(gtkTreeView, bordered ? GTK_TREE_VIEW_GRID_LINES_BOTH : GTK_TREE_VIEW_GRID_LINES_NONE);
|
gtk_tree_view_set_grid_lines(gtkTreeView, bordered ? GTK_TREE_VIEW_GRID_LINES_BOTH : GTK_TREE_VIEW_GRID_LINES_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::setFocused() -> void {
|
auto pTableView::setFocused() -> void {
|
||||||
//gtk_widget_grab_focus() will select the first item if nothing is currently selected
|
//gtk_widget_grab_focus() will select the first item if nothing is currently selected
|
||||||
//this behavior is undesirable. detect selection state first, and restore if required
|
//this behavior is undesirable. detect selection state first, and restore if required
|
||||||
lock();
|
lock();
|
||||||
|
@ -128,18 +128,18 @@ auto pListView::setFocused() -> void {
|
||||||
unlock();
|
unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::setFont(const Font& font) -> void {
|
auto pTableView::setFont(const Font& font) -> void {
|
||||||
if(auto& header = state().header) {
|
if(auto& header = state().header) {
|
||||||
if(auto self = header->self()) self->_setState();
|
if(auto self = header->self()) self->_setState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::setForegroundColor(Color color) -> void {
|
auto pTableView::setForegroundColor(Color color) -> void {
|
||||||
GdkColor gdkColor = CreateColor(color);
|
GdkColor gdkColor = CreateColor(color);
|
||||||
gtk_widget_modify_text(gtkWidgetChild, GTK_STATE_NORMAL, color ? &gdkColor : nullptr);
|
gtk_widget_modify_text(gtkWidgetChild, GTK_STATE_NORMAL, color ? &gdkColor : nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::setGeometry(Geometry geometry) -> void {
|
auto pTableView::setGeometry(Geometry geometry) -> void {
|
||||||
pWidget::setGeometry(geometry);
|
pWidget::setGeometry(geometry);
|
||||||
if(auto& header = state().header) {
|
if(auto& header = state().header) {
|
||||||
for(auto& column : header->state.columns) {
|
for(auto& column : header->state.columns) {
|
||||||
|
@ -148,7 +148,7 @@ auto pListView::setGeometry(Geometry geometry) -> void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::_cellWidth(unsigned _row, unsigned _column) -> unsigned {
|
auto pTableView::_cellWidth(unsigned _row, unsigned _column) -> unsigned {
|
||||||
unsigned width = 8;
|
unsigned width = 8;
|
||||||
if(auto item = self().item(_row)) {
|
if(auto item = self().item(_row)) {
|
||||||
if(auto cell = item->cell(_column)) {
|
if(auto cell = item->cell(_column)) {
|
||||||
|
@ -166,7 +166,7 @@ auto pListView::_cellWidth(unsigned _row, unsigned _column) -> unsigned {
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::_columnWidth(unsigned _column) -> unsigned {
|
auto pTableView::_columnWidth(unsigned _column) -> unsigned {
|
||||||
unsigned width = 8;
|
unsigned width = 8;
|
||||||
if(auto& header = state().header) {
|
if(auto& header = state().header) {
|
||||||
if(auto column = header->column(_column)) {
|
if(auto column = header->column(_column)) {
|
||||||
|
@ -181,7 +181,7 @@ auto pListView::_columnWidth(unsigned _column) -> unsigned {
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::_createModel() -> void {
|
auto pTableView::_createModel() -> void {
|
||||||
gtk_tree_view_set_model(gtkTreeView, nullptr);
|
gtk_tree_view_set_model(gtkTreeView, nullptr);
|
||||||
gtkListStore = nullptr;
|
gtkListStore = nullptr;
|
||||||
gtkTreeModel = nullptr;
|
gtkTreeModel = nullptr;
|
||||||
|
@ -204,19 +204,19 @@ auto pListView::_createModel() -> void {
|
||||||
gtk_tree_view_set_model(gtkTreeView, gtkTreeModel);
|
gtk_tree_view_set_model(gtkTreeView, gtkTreeModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::_doActivate() -> void {
|
auto pTableView::_doActivate() -> void {
|
||||||
if(!locked()) self().doActivate();
|
if(!locked()) self().doActivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::_doChange() -> void {
|
auto pTableView::_doChange() -> void {
|
||||||
if(!locked()) _updateSelected();
|
if(!locked()) _updateSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::_doContext() -> void {
|
auto pTableView::_doContext() -> void {
|
||||||
if(!locked()) self().doContext();
|
if(!locked()) self().doContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::_doDataFunc(GtkTreeViewColumn* gtkColumn, GtkCellRenderer* renderer, GtkTreeIter* iter) -> void {
|
auto pTableView::_doDataFunc(GtkTreeViewColumn* gtkColumn, GtkCellRenderer* renderer, GtkTreeIter* iter) -> void {
|
||||||
auto path = gtk_tree_model_get_string_from_iter(gtkTreeModel, iter);
|
auto path = gtk_tree_model_get_string_from_iter(gtkTreeModel, iter);
|
||||||
auto row = natural(path);
|
auto row = natural(path);
|
||||||
g_free(path);
|
g_free(path);
|
||||||
|
@ -266,7 +266,7 @@ auto pListView::_doDataFunc(GtkTreeViewColumn* gtkColumn, GtkCellRenderer* rende
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::_doEdit(GtkCellRendererText* gtkCellRendererText, const char* path, const char* text) -> void {
|
auto pTableView::_doEdit(GtkCellRendererText* gtkCellRendererText, const char* path, const char* text) -> void {
|
||||||
if(auto& header = state().header) {
|
if(auto& header = state().header) {
|
||||||
for(auto& column : header->state.columns) {
|
for(auto& column : header->state.columns) {
|
||||||
if(auto delegate = column->self()) {
|
if(auto delegate = column->self()) {
|
||||||
|
@ -287,12 +287,12 @@ auto pListView::_doEdit(GtkCellRendererText* gtkCellRendererText, const char* pa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::_doEvent(GdkEventButton* event) -> signed {
|
auto pTableView::_doEvent(GdkEventButton* event) -> signed {
|
||||||
GtkTreePath* path = nullptr;
|
GtkTreePath* path = nullptr;
|
||||||
gtk_tree_view_get_path_at_pos(gtkTreeView, event->x, event->y, &path, nullptr, nullptr, nullptr);
|
gtk_tree_view_get_path_at_pos(gtkTreeView, event->x, event->y, &path, nullptr, nullptr, nullptr);
|
||||||
|
|
||||||
if(event->type == GDK_BUTTON_PRESS) {
|
if(event->type == GDK_BUTTON_PRESS) {
|
||||||
//when clicking in empty space below the last list view item; GTK+ does not deselect all items;
|
//when clicking in empty space below the last table view item; GTK+ does not deselect all items;
|
||||||
//below code enables this functionality, to match behavior with all other UI toolkits (and because it's very convenient to have)
|
//below code enables this functionality, to match behavior with all other UI toolkits (and because it's very convenient to have)
|
||||||
if(path == nullptr && gtk_tree_selection_count_selected_rows(gtkTreeSelection) > 0) {
|
if(path == nullptr && gtk_tree_selection_count_selected_rows(gtkTreeSelection) > 0) {
|
||||||
for(auto& item : state().items) item->setSelected(false);
|
for(auto& item : state().items) item->setSelected(false);
|
||||||
|
@ -316,7 +316,7 @@ auto pListView::_doEvent(GdkEventButton* event) -> signed {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::_doHeaderActivate(GtkTreeViewColumn* gtkTreeViewColumn) -> void {
|
auto pTableView::_doHeaderActivate(GtkTreeViewColumn* gtkTreeViewColumn) -> void {
|
||||||
if(auto& header = state().header) {
|
if(auto& header = state().header) {
|
||||||
for(auto& column : header->state.columns) {
|
for(auto& column : header->state.columns) {
|
||||||
if(auto delegate = column->self()) {
|
if(auto delegate = column->self()) {
|
||||||
|
@ -330,15 +330,15 @@ auto pListView::_doHeaderActivate(GtkTreeViewColumn* gtkTreeViewColumn) -> void
|
||||||
}
|
}
|
||||||
|
|
||||||
//GtkTreeView::cursor-changed and GtkTreeSelection::changed do not send signals for changes during rubber-banding selection
|
//GtkTreeView::cursor-changed and GtkTreeSelection::changed do not send signals for changes during rubber-banding selection
|
||||||
//so here we capture motion-notify-event, and if the selections have changed, invoke ListView::onChange
|
//so here we capture motion-notify-event, and if the selections have changed, invoke TableView::onChange
|
||||||
auto pListView::_doMouseMove() -> signed {
|
auto pTableView::_doMouseMove() -> signed {
|
||||||
if(gtk_tree_view_is_rubber_banding_active(gtkTreeView)) {
|
if(gtk_tree_view_is_rubber_banding_active(gtkTreeView)) {
|
||||||
if(!locked()) _updateSelected();
|
if(!locked()) _updateSelected();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::_doToggle(GtkCellRendererToggle* gtkCellRendererToggle, const char* path) -> void {
|
auto pTableView::_doToggle(GtkCellRendererToggle* gtkCellRendererToggle, const char* path) -> void {
|
||||||
if(auto& header = state().header) {
|
if(auto& header = state().header) {
|
||||||
for(auto& column : header->state.columns) {
|
for(auto& column : header->state.columns) {
|
||||||
if(auto delegate = column->self()) {
|
if(auto delegate = column->self()) {
|
||||||
|
@ -361,7 +361,7 @@ auto pListView::_doToggle(GtkCellRendererToggle* gtkCellRendererToggle, const ch
|
||||||
//if different, invoke the onChange callback unless locked, and cache current selection
|
//if different, invoke the onChange callback unless locked, and cache current selection
|
||||||
//this prevents firing an onChange event when the actual selection has not changed
|
//this prevents firing an onChange event when the actual selection has not changed
|
||||||
//this is particularly important for the motion-notify-event binding
|
//this is particularly important for the motion-notify-event binding
|
||||||
auto pListView::_updateSelected() -> void {
|
auto pTableView::_updateSelected() -> void {
|
||||||
vector<unsigned> selected;
|
vector<unsigned> selected;
|
||||||
|
|
||||||
GList* list = gtk_tree_selection_get_selected_rows(gtkTreeSelection, >kTreeModel);
|
GList* list = gtk_tree_selection_get_selected_rows(gtkTreeSelection, >kTreeModel);
|
||||||
|
@ -402,7 +402,7 @@ auto pListView::_updateSelected() -> void {
|
||||||
if(!locked()) self().doChange();
|
if(!locked()) self().doChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::_width(unsigned column) -> unsigned {
|
auto pTableView::_width(unsigned column) -> unsigned {
|
||||||
if(auto& header = state().header) {
|
if(auto& header = state().header) {
|
||||||
if(auto width = header->column(column).width()) return width;
|
if(auto width = header->column(column).width()) return width;
|
||||||
unsigned width = 1;
|
unsigned width = 1;
|
|
@ -1,15 +1,15 @@
|
||||||
#if defined(Hiro_ListView)
|
#if defined(Hiro_TableView)
|
||||||
|
|
||||||
namespace hiro {
|
namespace hiro {
|
||||||
|
|
||||||
struct pListView : pWidget {
|
struct pTableView : pWidget {
|
||||||
Declare(ListView, Widget)
|
Declare(TableView, Widget)
|
||||||
|
|
||||||
auto append(sListViewHeader column) -> void;
|
auto append(sTableViewHeader column) -> void;
|
||||||
auto append(sListViewItem item) -> void;
|
auto append(sTableViewItem item) -> void;
|
||||||
auto focused() const -> bool override;
|
auto focused() const -> bool override;
|
||||||
auto remove(sListViewHeader column) -> void;
|
auto remove(sTableViewHeader column) -> void;
|
||||||
auto remove(sListViewItem item) -> void;
|
auto remove(sTableViewItem item) -> void;
|
||||||
auto resizeColumns() -> void;
|
auto resizeColumns() -> void;
|
||||||
auto setAlignment(Alignment alignment) -> void;
|
auto setAlignment(Alignment alignment) -> void;
|
||||||
auto setBackgroundColor(Color color) -> void;
|
auto setBackgroundColor(Color color) -> void;
|
|
@ -133,10 +133,10 @@ auto pTreeView::_doDataFunc(GtkTreeViewColumn* column, GtkCellRenderer* renderer
|
||||||
auto parts = string{path}.split(":");
|
auto parts = string{path}.split(":");
|
||||||
g_free(path);
|
g_free(path);
|
||||||
|
|
||||||
auto item = self().item(parts.takeFirst().natural());
|
auto item = self().item(parts.takeLeft().natural());
|
||||||
if(!item) return;
|
if(!item) return;
|
||||||
while(parts) {
|
while(parts) {
|
||||||
item = item.item(parts.takeFirst().natural());
|
item = item.item(parts.takeLeft().natural());
|
||||||
if(!item) return;
|
if(!item) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ static auto Viewport_dropEvent(GtkWidget* widget, GdkDragContext* context, signe
|
||||||
GtkSelectionData* data, unsigned type, unsigned timestamp, pViewport* p) -> void {
|
GtkSelectionData* data, unsigned type, unsigned timestamp, pViewport* p) -> void {
|
||||||
if(!p->state().droppable) return;
|
if(!p->state().droppable) return;
|
||||||
lstring paths = DropPaths(data);
|
lstring paths = DropPaths(data);
|
||||||
if(paths.empty()) return;
|
if(!paths) return;
|
||||||
p->self().doDrop(paths);
|
p->self().doDrop(paths);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ static auto Window_drop(GtkWidget* widget, GdkDragContext* context, signed x, si
|
||||||
GtkSelectionData* data, unsigned type, unsigned timestamp, pWindow* p) -> void {
|
GtkSelectionData* data, unsigned type, unsigned timestamp, pWindow* p) -> void {
|
||||||
if(!p->state().droppable) return;
|
if(!p->state().droppable) return;
|
||||||
lstring paths = DropPaths(data);
|
lstring paths = DropPaths(data);
|
||||||
if(paths.empty()) return;
|
if(!paths) return;
|
||||||
p->self().doDrop(paths);
|
p->self().doDrop(paths);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ auto pWindow::construct() -> void {
|
||||||
|
|
||||||
//if program was given a name, try and set the window taskbar icon from one of the pixmaps folders
|
//if program was given a name, try and set the window taskbar icon from one of the pixmaps folders
|
||||||
if(!Application::state.name);
|
if(!Application::state.name);
|
||||||
else if(_setIcon({userpath(), ".local/share/icons/"}));
|
else if(_setIcon({Path::user(), ".local/share/icons/"}));
|
||||||
else if(_setIcon("/usr/local/share/pixmaps/"));
|
else if(_setIcon("/usr/local/share/pixmaps/"));
|
||||||
else if(_setIcon("/usr/share/pixmaps/"));
|
else if(_setIcon("/usr/share/pixmaps/"));
|
||||||
|
|
||||||
|
|
|
@ -47,16 +47,16 @@
|
||||||
#include "widget/icon-view.cpp"
|
#include "widget/icon-view.cpp"
|
||||||
#include "widget/label.cpp"
|
#include "widget/label.cpp"
|
||||||
#include "widget/line-edit.cpp"
|
#include "widget/line-edit.cpp"
|
||||||
#include "widget/list-view.cpp"
|
|
||||||
#include "widget/list-view-header.cpp"
|
|
||||||
#include "widget/list-view-column.cpp"
|
|
||||||
#include "widget/list-view-item.cpp"
|
|
||||||
#include "widget/list-view-cell.cpp"
|
|
||||||
#include "widget/progress-bar.cpp"
|
#include "widget/progress-bar.cpp"
|
||||||
#include "widget/radio-button.cpp"
|
#include "widget/radio-button.cpp"
|
||||||
#include "widget/radio-label.cpp"
|
#include "widget/radio-label.cpp"
|
||||||
#include "widget/tab-frame.cpp"
|
#include "widget/tab-frame.cpp"
|
||||||
#include "widget/tab-frame-item.cpp"
|
#include "widget/tab-frame-item.cpp"
|
||||||
|
#include "widget/table-view.cpp"
|
||||||
|
#include "widget/table-view-header.cpp"
|
||||||
|
#include "widget/table-view-column.cpp"
|
||||||
|
#include "widget/table-view-item.cpp"
|
||||||
|
#include "widget/table-view-cell.cpp"
|
||||||
#include "widget/text-edit.cpp"
|
#include "widget/text-edit.cpp"
|
||||||
#include "widget/vertical-scroll-bar.cpp"
|
#include "widget/vertical-scroll-bar.cpp"
|
||||||
#include "widget/vertical-slider.cpp"
|
#include "widget/vertical-slider.cpp"
|
||||||
|
|
|
@ -48,16 +48,16 @@
|
||||||
#include "widget/horizontal-slider.hpp"
|
#include "widget/horizontal-slider.hpp"
|
||||||
#include "widget/label.hpp"
|
#include "widget/label.hpp"
|
||||||
#include "widget/line-edit.hpp"
|
#include "widget/line-edit.hpp"
|
||||||
#include "widget/list-view.hpp"
|
|
||||||
#include "widget/list-view-header.hpp"
|
|
||||||
#include "widget/list-view-column.hpp"
|
|
||||||
#include "widget/list-view-item.hpp"
|
|
||||||
#include "widget/list-view-cell.hpp"
|
|
||||||
#include "widget/progress-bar.hpp"
|
#include "widget/progress-bar.hpp"
|
||||||
#include "widget/radio-button.hpp"
|
#include "widget/radio-button.hpp"
|
||||||
#include "widget/radio-label.hpp"
|
#include "widget/radio-label.hpp"
|
||||||
#include "widget/tab-frame.hpp"
|
#include "widget/tab-frame.hpp"
|
||||||
#include "widget/tab-frame-item.hpp"
|
#include "widget/tab-frame-item.hpp"
|
||||||
|
#include "widget/table-view.hpp"
|
||||||
|
#include "widget/table-view-header.hpp"
|
||||||
|
#include "widget/table-view-column.hpp"
|
||||||
|
#include "widget/table-view-item.hpp"
|
||||||
|
#include "widget/table-view-cell.hpp"
|
||||||
#include "widget/text-edit.hpp"
|
#include "widget/text-edit.hpp"
|
||||||
#include "widget/vertical-scroll-bar.hpp"
|
#include "widget/vertical-scroll-bar.hpp"
|
||||||
#include "widget/vertical-slider.hpp"
|
#include "widget/vertical-slider.hpp"
|
||||||
|
|
50
qt/qt.hpp
50
qt/qt.hpp
|
@ -1,3 +1,5 @@
|
||||||
|
//moc-qt4 -i -o qt.moc qt.hpp
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Qt requires moc in order to bind callbacks, which causes many complications.
|
Qt requires moc in order to bind callbacks, which causes many complications.
|
||||||
|
|
||||||
|
@ -194,30 +196,6 @@ public slots:
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(Hiro_ListView)
|
|
||||||
struct QtListView : public QTreeWidget {
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
QtListView(pListView& p) : p(p) {}
|
|
||||||
auto mousePressEvent(QMouseEvent*) -> void override;
|
|
||||||
auto resizeEvent(QResizeEvent*) -> void override;
|
|
||||||
auto showEvent(QShowEvent*) -> void override;
|
|
||||||
pListView& p;
|
|
||||||
public slots:
|
|
||||||
void onActivate();
|
|
||||||
void onChange();
|
|
||||||
void onContext();
|
|
||||||
void onSort(int column);
|
|
||||||
void onToggle(QTreeWidgetItem* item, int column);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct QtListViewDelegate : public QStyledItemDelegate {
|
|
||||||
QtListViewDelegate(pListView& p);
|
|
||||||
auto paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const -> void;
|
|
||||||
pListView& p;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(Hiro_RadioLabel)
|
#if defined(Hiro_RadioLabel)
|
||||||
struct QtRadioLabel : public QRadioButton {
|
struct QtRadioLabel : public QRadioButton {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -252,6 +230,30 @@ public slots:
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(Hiro_TableView)
|
||||||
|
struct QtTableView : public QTreeWidget {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
QtTableView(pTableView& p) : p(p) {}
|
||||||
|
auto mousePressEvent(QMouseEvent*) -> void override;
|
||||||
|
auto resizeEvent(QResizeEvent*) -> void override;
|
||||||
|
auto showEvent(QShowEvent*) -> void override;
|
||||||
|
pTableView& p;
|
||||||
|
public slots:
|
||||||
|
void onActivate();
|
||||||
|
void onChange();
|
||||||
|
void onContext();
|
||||||
|
void onSort(int column);
|
||||||
|
void onToggle(QTreeWidgetItem* item, int column);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct QtTableViewDelegate : public QStyledItemDelegate {
|
||||||
|
QtTableViewDelegate(pTableView& p);
|
||||||
|
auto paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const -> void;
|
||||||
|
pTableView& p;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(Hiro_TextEdit)
|
#if defined(Hiro_TextEdit)
|
||||||
struct QtTextEdit : public QTextEdit {
|
struct QtTextEdit : public QTextEdit {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
168
qt/qt.moc
168
qt/qt.moc
|
@ -1031,90 +1031,6 @@ int hiro::QtLineEdit::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
|
||||||
}
|
}
|
||||||
return _id;
|
return _id;
|
||||||
}
|
}
|
||||||
static const uint qt_meta_data_hiro__QtListView[] = {
|
|
||||||
|
|
||||||
// content:
|
|
||||||
6, // revision
|
|
||||||
0, // classname
|
|
||||||
0, 0, // classinfo
|
|
||||||
5, 14, // methods
|
|
||||||
0, 0, // properties
|
|
||||||
0, 0, // enums/sets
|
|
||||||
0, 0, // constructors
|
|
||||||
0, // flags
|
|
||||||
0, // signalCount
|
|
||||||
|
|
||||||
// slots: signature, parameters, type, tag, flags
|
|
||||||
17, 30, 30, 30, 0x0a,
|
|
||||||
31, 30, 30, 30, 0x0a,
|
|
||||||
42, 30, 30, 30, 0x0a,
|
|
||||||
54, 66, 30, 30, 0x0a,
|
|
||||||
73, 104, 30, 30, 0x0a,
|
|
||||||
|
|
||||||
0 // eod
|
|
||||||
};
|
|
||||||
|
|
||||||
static const char qt_meta_stringdata_hiro__QtListView[] = {
|
|
||||||
"hiro::QtListView\0onActivate()\0\0"
|
|
||||||
"onChange()\0onContext()\0onSort(int)\0"
|
|
||||||
"column\0onToggle(QTreeWidgetItem*,int)\0"
|
|
||||||
"item,column\0"
|
|
||||||
};
|
|
||||||
|
|
||||||
void hiro::QtListView::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
|
|
||||||
{
|
|
||||||
if (_c == QMetaObject::InvokeMetaMethod) {
|
|
||||||
Q_ASSERT(staticMetaObject.cast(_o));
|
|
||||||
QtListView *_t = static_cast<QtListView *>(_o);
|
|
||||||
switch (_id) {
|
|
||||||
case 0: _t->onActivate(); break;
|
|
||||||
case 1: _t->onChange(); break;
|
|
||||||
case 2: _t->onContext(); break;
|
|
||||||
case 3: _t->onSort((*reinterpret_cast< int(*)>(_a[1]))); break;
|
|
||||||
case 4: _t->onToggle((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
|
|
||||||
default: ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const QMetaObjectExtraData hiro::QtListView::staticMetaObjectExtraData = {
|
|
||||||
0, qt_static_metacall
|
|
||||||
};
|
|
||||||
|
|
||||||
const QMetaObject hiro::QtListView::staticMetaObject = {
|
|
||||||
{ &QTreeWidget::staticMetaObject, qt_meta_stringdata_hiro__QtListView,
|
|
||||||
qt_meta_data_hiro__QtListView, &staticMetaObjectExtraData }
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef Q_NO_DATA_RELOCATION
|
|
||||||
const QMetaObject &hiro::QtListView::getStaticMetaObject() { return staticMetaObject; }
|
|
||||||
#endif //Q_NO_DATA_RELOCATION
|
|
||||||
|
|
||||||
const QMetaObject *hiro::QtListView::metaObject() const
|
|
||||||
{
|
|
||||||
return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *hiro::QtListView::qt_metacast(const char *_clname)
|
|
||||||
{
|
|
||||||
if (!_clname) return 0;
|
|
||||||
if (!strcmp(_clname, qt_meta_stringdata_hiro__QtListView))
|
|
||||||
return static_cast<void*>(const_cast< QtListView*>(this));
|
|
||||||
return QTreeWidget::qt_metacast(_clname);
|
|
||||||
}
|
|
||||||
|
|
||||||
int hiro::QtListView::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
|
|
||||||
{
|
|
||||||
_id = QTreeWidget::qt_metacall(_c, _id, _a);
|
|
||||||
if (_id < 0)
|
|
||||||
return _id;
|
|
||||||
if (_c == QMetaObject::InvokeMetaMethod) {
|
|
||||||
if (_id < 5)
|
|
||||||
qt_static_metacall(this, _c, _id, _a);
|
|
||||||
_id -= 5;
|
|
||||||
}
|
|
||||||
return _id;
|
|
||||||
}
|
|
||||||
static const uint qt_meta_data_hiro__QtRadioLabel[] = {
|
static const uint qt_meta_data_hiro__QtRadioLabel[] = {
|
||||||
|
|
||||||
// content:
|
// content:
|
||||||
|
@ -1337,6 +1253,90 @@ int hiro::QtTabFrame::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
|
||||||
}
|
}
|
||||||
return _id;
|
return _id;
|
||||||
}
|
}
|
||||||
|
static const uint qt_meta_data_hiro__QtTableView[] = {
|
||||||
|
|
||||||
|
// content:
|
||||||
|
6, // revision
|
||||||
|
0, // classname
|
||||||
|
0, 0, // classinfo
|
||||||
|
5, 14, // methods
|
||||||
|
0, 0, // properties
|
||||||
|
0, 0, // enums/sets
|
||||||
|
0, 0, // constructors
|
||||||
|
0, // flags
|
||||||
|
0, // signalCount
|
||||||
|
|
||||||
|
// slots: signature, parameters, type, tag, flags
|
||||||
|
18, 31, 31, 31, 0x0a,
|
||||||
|
32, 31, 31, 31, 0x0a,
|
||||||
|
43, 31, 31, 31, 0x0a,
|
||||||
|
55, 67, 31, 31, 0x0a,
|
||||||
|
74, 105, 31, 31, 0x0a,
|
||||||
|
|
||||||
|
0 // eod
|
||||||
|
};
|
||||||
|
|
||||||
|
static const char qt_meta_stringdata_hiro__QtTableView[] = {
|
||||||
|
"hiro::QtTableView\0onActivate()\0\0"
|
||||||
|
"onChange()\0onContext()\0onSort(int)\0"
|
||||||
|
"column\0onToggle(QTreeWidgetItem*,int)\0"
|
||||||
|
"item,column\0"
|
||||||
|
};
|
||||||
|
|
||||||
|
void hiro::QtTableView::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
|
||||||
|
{
|
||||||
|
if (_c == QMetaObject::InvokeMetaMethod) {
|
||||||
|
Q_ASSERT(staticMetaObject.cast(_o));
|
||||||
|
QtTableView *_t = static_cast<QtTableView *>(_o);
|
||||||
|
switch (_id) {
|
||||||
|
case 0: _t->onActivate(); break;
|
||||||
|
case 1: _t->onChange(); break;
|
||||||
|
case 2: _t->onContext(); break;
|
||||||
|
case 3: _t->onSort((*reinterpret_cast< int(*)>(_a[1]))); break;
|
||||||
|
case 4: _t->onToggle((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
|
||||||
|
default: ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const QMetaObjectExtraData hiro::QtTableView::staticMetaObjectExtraData = {
|
||||||
|
0, qt_static_metacall
|
||||||
|
};
|
||||||
|
|
||||||
|
const QMetaObject hiro::QtTableView::staticMetaObject = {
|
||||||
|
{ &QTreeWidget::staticMetaObject, qt_meta_stringdata_hiro__QtTableView,
|
||||||
|
qt_meta_data_hiro__QtTableView, &staticMetaObjectExtraData }
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef Q_NO_DATA_RELOCATION
|
||||||
|
const QMetaObject &hiro::QtTableView::getStaticMetaObject() { return staticMetaObject; }
|
||||||
|
#endif //Q_NO_DATA_RELOCATION
|
||||||
|
|
||||||
|
const QMetaObject *hiro::QtTableView::metaObject() const
|
||||||
|
{
|
||||||
|
return QObject::d_ptr->metaObject ? QObject::d_ptr->metaObject : &staticMetaObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *hiro::QtTableView::qt_metacast(const char *_clname)
|
||||||
|
{
|
||||||
|
if (!_clname) return 0;
|
||||||
|
if (!strcmp(_clname, qt_meta_stringdata_hiro__QtTableView))
|
||||||
|
return static_cast<void*>(const_cast< QtTableView*>(this));
|
||||||
|
return QTreeWidget::qt_metacast(_clname);
|
||||||
|
}
|
||||||
|
|
||||||
|
int hiro::QtTableView::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
|
||||||
|
{
|
||||||
|
_id = QTreeWidget::qt_metacall(_c, _id, _a);
|
||||||
|
if (_id < 0)
|
||||||
|
return _id;
|
||||||
|
if (_c == QMetaObject::InvokeMetaMethod) {
|
||||||
|
if (_id < 5)
|
||||||
|
qt_static_metacall(this, _c, _id, _a);
|
||||||
|
_id -= 5;
|
||||||
|
}
|
||||||
|
return _id;
|
||||||
|
}
|
||||||
static const uint qt_meta_data_hiro__QtTextEdit[] = {
|
static const uint qt_meta_data_hiro__QtTextEdit[] = {
|
||||||
|
|
||||||
// content:
|
// content:
|
||||||
|
|
|
@ -13,12 +13,12 @@ Settings::Settings() {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Settings::load() -> void {
|
auto Settings::load() -> void {
|
||||||
string path{configpath(), "hiro/"};
|
string path{Path::config(), "hiro/"};
|
||||||
Configuration::Document::load({path, "qt.bml"});
|
Configuration::Document::load({path, "qt.bml"});
|
||||||
}
|
}
|
||||||
|
|
||||||
auto Settings::save() -> void {
|
auto Settings::save() -> void {
|
||||||
string path{configpath(), "hiro/"};
|
string path{Path::config(), "hiro/"};
|
||||||
directory::create(path, 0755);
|
directory::create(path, 0755);
|
||||||
Configuration::Document::save({path, "qt.bml"});
|
Configuration::Document::save({path, "qt.bml"});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,99 +0,0 @@
|
||||||
#if defined(Hiro_ListView)
|
|
||||||
|
|
||||||
namespace hiro {
|
|
||||||
|
|
||||||
auto pListViewColumn::construct() -> void {
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewColumn::destruct() -> void {
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewColumn::setActive() -> void {
|
|
||||||
//unsupported
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewColumn::setAlignment(Alignment alignment) -> void {
|
|
||||||
_setState();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewColumn::setBackgroundColor(Color color) -> void {
|
|
||||||
_setState();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewColumn::setEditable(bool editable) -> void {
|
|
||||||
//unsupported
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewColumn::setExpandable(bool expandable) -> void {
|
|
||||||
_setState();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewColumn::setFont(const Font& font) -> void {
|
|
||||||
_setState();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewColumn::setForegroundColor(Color color) -> void {
|
|
||||||
_setState();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewColumn::setHorizontalAlignment(double alignment) -> void {
|
|
||||||
_setState();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewColumn::setIcon(const image& icon) -> void {
|
|
||||||
//unsupported
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewColumn::setResizable(bool resizable) -> void {
|
|
||||||
_setState();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewColumn::setSortable(bool sortable) -> void {
|
|
||||||
_setState();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewColumn::setText(const string& text) -> void {
|
|
||||||
_setState();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewColumn::setVerticalAlignment(double alignment) -> void {
|
|
||||||
_setState();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewColumn::setVisible(bool visible) -> void {
|
|
||||||
_setState();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewColumn::setWidth(signed width) -> void {
|
|
||||||
_setState();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewColumn::_parent() -> maybe<pListViewHeader&> {
|
|
||||||
if(auto parent = self().parentListViewHeader()) {
|
|
||||||
if(auto delegate = parent->self()) return *delegate;
|
|
||||||
}
|
|
||||||
return nothing;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewColumn::_setState() -> void {
|
|
||||||
if(auto header = _parent()) {
|
|
||||||
if(auto parent = header->_parent()) {
|
|
||||||
parent->qtListView->header()->setResizeMode(self().offset(), state().resizable ? QHeaderView::Interactive : QHeaderView::Fixed);
|
|
||||||
bool clickable = false;
|
|
||||||
for(auto& column : header->state().columns) clickable |= column->state.sortable;
|
|
||||||
parent->qtListView->header()->setClickable(clickable);
|
|
||||||
parent->qtListView->headerItem()->setText(self().offset(), QString::fromUtf8(state().text));
|
|
||||||
parent->qtListView->setColumnHidden(self().offset(), !self().visible());
|
|
||||||
|
|
||||||
for(auto& item : parent->state().items) {
|
|
||||||
if(auto cell = item->cell(self().offset())) {
|
|
||||||
if(auto self = cell->self()) self->_setState();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,43 +0,0 @@
|
||||||
#if defined(Hiro_ListView)
|
|
||||||
|
|
||||||
namespace hiro {
|
|
||||||
|
|
||||||
auto pListViewHeader::construct() -> void {
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewHeader::destruct() -> void {
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewHeader::append(sListViewColumn column) -> void {
|
|
||||||
_setState();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewHeader::remove(sListViewColumn column) -> void {
|
|
||||||
_setState();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewHeader::setVisible(bool visible) -> void {
|
|
||||||
_setState();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewHeader::_parent() -> maybe<pListView&> {
|
|
||||||
if(auto parent = self().parentListView()) {
|
|
||||||
if(auto delegate = parent->self()) return *delegate;
|
|
||||||
}
|
|
||||||
return nothing;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewHeader::_setState() -> void {
|
|
||||||
if(auto parent = _parent()) {
|
|
||||||
//parent->qtListView->setAlternatingRowColors(self().columnCount() >= 2);
|
|
||||||
parent->qtListView->setColumnCount(self().columnCount());
|
|
||||||
parent->qtListView->setHeaderHidden(!self().visible());
|
|
||||||
for(auto& column : state().columns) {
|
|
||||||
if(auto self = column->self()) self->_setState();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,18 +0,0 @@
|
||||||
#if defined(Hiro_ListView)
|
|
||||||
|
|
||||||
namespace hiro {
|
|
||||||
|
|
||||||
struct pListViewHeader : pObject {
|
|
||||||
Declare(ListViewHeader, Object)
|
|
||||||
|
|
||||||
auto append(sListViewColumn column) -> void;
|
|
||||||
auto remove(sListViewColumn column) -> void;
|
|
||||||
auto setVisible(bool visible) -> void override;
|
|
||||||
|
|
||||||
auto _parent() -> maybe<pListView&>;
|
|
||||||
auto _setState() -> void;
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,64 +0,0 @@
|
||||||
#if defined(Hiro_ListView)
|
|
||||||
|
|
||||||
namespace hiro {
|
|
||||||
|
|
||||||
auto pListViewItem::construct() -> void {
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewItem::destruct() -> void {
|
|
||||||
if(auto parent = _parent()) parent->lock();
|
|
||||||
if(qtItem) {
|
|
||||||
delete qtItem;
|
|
||||||
qtItem = nullptr;
|
|
||||||
}
|
|
||||||
if(auto parent = _parent()) parent->unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewItem::append(sListViewCell cell) -> void {
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewItem::remove(sListViewCell cell) -> void {
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewItem::setAlignment(Alignment alignment) -> void {
|
|
||||||
_setState();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewItem::setBackgroundColor(Color color) -> void {
|
|
||||||
_setState();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewItem::setFont(const Font& font) -> void {
|
|
||||||
_setState();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewItem::setForegroundColor(Color color) -> void {
|
|
||||||
_setState();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewItem::setSelected(bool selected) -> void {
|
|
||||||
_setState();
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewItem::_parent() -> maybe<pListView&> {
|
|
||||||
if(auto parent = self().parentListView()) {
|
|
||||||
if(auto delegate = parent->self()) return *delegate;
|
|
||||||
}
|
|
||||||
return nothing;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto pListViewItem::_setState() -> void {
|
|
||||||
if(auto parent = _parent()) {
|
|
||||||
qtItem->setSelected(state().selected);
|
|
||||||
if(state().selected) {
|
|
||||||
parent->qtListView->setCurrentItem(qtItem);
|
|
||||||
}
|
|
||||||
for(auto& cell : state().cells) {
|
|
||||||
if(auto self = cell->self()) self->_setState();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,53 +1,53 @@
|
||||||
#if defined(Hiro_ListView)
|
#if defined(Hiro_TableView)
|
||||||
|
|
||||||
namespace hiro {
|
namespace hiro {
|
||||||
|
|
||||||
auto pListViewCell::construct() -> void {
|
auto pTableViewCell::construct() -> void {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewCell::destruct() -> void {
|
auto pTableViewCell::destruct() -> void {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewCell::setAlignment(Alignment alignment) -> void {
|
auto pTableViewCell::setAlignment(Alignment alignment) -> void {
|
||||||
_setState();
|
_setState();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewCell::setBackgroundColor(Color color) -> void {
|
auto pTableViewCell::setBackgroundColor(Color color) -> void {
|
||||||
_setState();
|
_setState();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewCell::setCheckable(bool checkable) -> void {
|
auto pTableViewCell::setCheckable(bool checkable) -> void {
|
||||||
_setState();
|
_setState();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewCell::setChecked(bool checked) -> void {
|
auto pTableViewCell::setChecked(bool checked) -> void {
|
||||||
_setState();
|
_setState();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewCell::setFont(const string& font) -> void {
|
auto pTableViewCell::setFont(const string& font) -> void {
|
||||||
_setState();
|
_setState();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewCell::setForegroundColor(Color color) -> void {
|
auto pTableViewCell::setForegroundColor(Color color) -> void {
|
||||||
_setState();
|
_setState();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewCell::setIcon(const image& icon) -> void {
|
auto pTableViewCell::setIcon(const image& icon) -> void {
|
||||||
_setState();
|
_setState();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewCell::setText(const string& text) -> void {
|
auto pTableViewCell::setText(const string& text) -> void {
|
||||||
_setState();
|
_setState();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewCell::_parent() -> maybe<pListViewItem&> {
|
auto pTableViewCell::_parent() -> maybe<pTableViewItem&> {
|
||||||
if(auto parent = self().parentListViewItem()) {
|
if(auto parent = self().parentTableViewItem()) {
|
||||||
if(auto delegate = parent->self()) return *delegate;
|
if(auto delegate = parent->self()) return *delegate;
|
||||||
}
|
}
|
||||||
return nothing;
|
return nothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListViewCell::_setState() -> void {
|
auto pTableViewCell::_setState() -> void {
|
||||||
if(auto parent = _parent()) {
|
if(auto parent = _parent()) {
|
||||||
if(auto grandparent = parent->_parent()) {
|
if(auto grandparent = parent->_parent()) {
|
||||||
grandparent->lock();
|
grandparent->lock();
|
|
@ -1,9 +1,9 @@
|
||||||
#if defined(Hiro_ListView)
|
#if defined(Hiro_TableView)
|
||||||
|
|
||||||
namespace hiro {
|
namespace hiro {
|
||||||
|
|
||||||
struct pListViewCell : pObject {
|
struct pTableViewCell : pObject {
|
||||||
Declare(ListViewCell, Object)
|
Declare(TableViewCell, Object)
|
||||||
|
|
||||||
auto setAlignment(Alignment alignment) -> void;
|
auto setAlignment(Alignment alignment) -> void;
|
||||||
auto setBackgroundColor(Color color) -> void;
|
auto setBackgroundColor(Color color) -> void;
|
||||||
|
@ -14,7 +14,7 @@ struct pListViewCell : pObject {
|
||||||
auto setIcon(const image& icon) -> void;
|
auto setIcon(const image& icon) -> void;
|
||||||
auto setText(const string& text) -> void;
|
auto setText(const string& text) -> void;
|
||||||
|
|
||||||
auto _parent() -> maybe<pListViewItem&>;
|
auto _parent() -> maybe<pTableViewItem&>;
|
||||||
auto _setState() -> void;
|
auto _setState() -> void;
|
||||||
};
|
};
|
||||||
|
|
99
qt/widget/table-view-column.cpp
Normal file
99
qt/widget/table-view-column.cpp
Normal file
|
@ -0,0 +1,99 @@
|
||||||
|
#if defined(Hiro_TableView)
|
||||||
|
|
||||||
|
namespace hiro {
|
||||||
|
|
||||||
|
auto pTableViewColumn::construct() -> void {
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewColumn::destruct() -> void {
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewColumn::setActive() -> void {
|
||||||
|
//unsupported
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewColumn::setAlignment(Alignment alignment) -> void {
|
||||||
|
_setState();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewColumn::setBackgroundColor(Color color) -> void {
|
||||||
|
_setState();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewColumn::setEditable(bool editable) -> void {
|
||||||
|
//unsupported
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewColumn::setExpandable(bool expandable) -> void {
|
||||||
|
_setState();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewColumn::setFont(const Font& font) -> void {
|
||||||
|
_setState();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewColumn::setForegroundColor(Color color) -> void {
|
||||||
|
_setState();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewColumn::setHorizontalAlignment(double alignment) -> void {
|
||||||
|
_setState();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewColumn::setIcon(const image& icon) -> void {
|
||||||
|
//unsupported
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewColumn::setResizable(bool resizable) -> void {
|
||||||
|
_setState();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewColumn::setSortable(bool sortable) -> void {
|
||||||
|
_setState();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewColumn::setText(const string& text) -> void {
|
||||||
|
_setState();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewColumn::setVerticalAlignment(double alignment) -> void {
|
||||||
|
_setState();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewColumn::setVisible(bool visible) -> void {
|
||||||
|
_setState();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewColumn::setWidth(signed width) -> void {
|
||||||
|
_setState();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewColumn::_parent() -> maybe<pTableViewHeader&> {
|
||||||
|
if(auto parent = self().parentTableViewHeader()) {
|
||||||
|
if(auto delegate = parent->self()) return *delegate;
|
||||||
|
}
|
||||||
|
return nothing;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewColumn::_setState() -> void {
|
||||||
|
if(auto header = _parent()) {
|
||||||
|
if(auto parent = header->_parent()) {
|
||||||
|
parent->qtTableView->header()->setResizeMode(self().offset(), state().resizable ? QHeaderView::Interactive : QHeaderView::Fixed);
|
||||||
|
bool clickable = false;
|
||||||
|
for(auto& column : header->state().columns) clickable |= column->state.sortable;
|
||||||
|
parent->qtTableView->header()->setClickable(clickable);
|
||||||
|
parent->qtTableView->headerItem()->setText(self().offset(), QString::fromUtf8(state().text));
|
||||||
|
parent->qtTableView->setColumnHidden(self().offset(), !self().visible());
|
||||||
|
|
||||||
|
for(auto& item : parent->state().items) {
|
||||||
|
if(auto cell = item->cell(self().offset())) {
|
||||||
|
if(auto self = cell->self()) self->_setState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,9 +1,9 @@
|
||||||
#if defined(Hiro_ListView)
|
#if defined(Hiro_TableView)
|
||||||
|
|
||||||
namespace hiro {
|
namespace hiro {
|
||||||
|
|
||||||
struct pListViewColumn : pObject {
|
struct pTableViewColumn : pObject {
|
||||||
Declare(ListViewColumn, Object)
|
Declare(TableViewColumn, Object)
|
||||||
|
|
||||||
auto setActive() -> void;
|
auto setActive() -> void;
|
||||||
auto setAlignment(Alignment alignment) -> void;
|
auto setAlignment(Alignment alignment) -> void;
|
||||||
|
@ -21,7 +21,7 @@ struct pListViewColumn : pObject {
|
||||||
auto setVisible(bool visible) -> void;
|
auto setVisible(bool visible) -> void;
|
||||||
auto setWidth(signed width) -> void;
|
auto setWidth(signed width) -> void;
|
||||||
|
|
||||||
auto _parent() -> maybe<pListViewHeader&>;
|
auto _parent() -> maybe<pTableViewHeader&>;
|
||||||
auto _setState() -> void;
|
auto _setState() -> void;
|
||||||
};
|
};
|
||||||
|
|
43
qt/widget/table-view-header.cpp
Normal file
43
qt/widget/table-view-header.cpp
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
#if defined(Hiro_TableView)
|
||||||
|
|
||||||
|
namespace hiro {
|
||||||
|
|
||||||
|
auto pTableViewHeader::construct() -> void {
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewHeader::destruct() -> void {
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewHeader::append(sTableViewColumn column) -> void {
|
||||||
|
_setState();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewHeader::remove(sTableViewColumn column) -> void {
|
||||||
|
_setState();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewHeader::setVisible(bool visible) -> void {
|
||||||
|
_setState();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewHeader::_parent() -> maybe<pTableView&> {
|
||||||
|
if(auto parent = self().parentTableView()) {
|
||||||
|
if(auto delegate = parent->self()) return *delegate;
|
||||||
|
}
|
||||||
|
return nothing;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewHeader::_setState() -> void {
|
||||||
|
if(auto parent = _parent()) {
|
||||||
|
//parent->qtTableView->setAlternatingRowColors(self().columnCount() >= 2);
|
||||||
|
parent->qtTableView->setColumnCount(self().columnCount());
|
||||||
|
parent->qtTableView->setHeaderHidden(!self().visible());
|
||||||
|
for(auto& column : state().columns) {
|
||||||
|
if(auto self = column->self()) self->_setState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
18
qt/widget/table-view-header.hpp
Normal file
18
qt/widget/table-view-header.hpp
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#if defined(Hiro_TableView)
|
||||||
|
|
||||||
|
namespace hiro {
|
||||||
|
|
||||||
|
struct pTableViewHeader : pObject {
|
||||||
|
Declare(TableViewHeader, Object)
|
||||||
|
|
||||||
|
auto append(sTableViewColumn column) -> void;
|
||||||
|
auto remove(sTableViewColumn column) -> void;
|
||||||
|
auto setVisible(bool visible) -> void override;
|
||||||
|
|
||||||
|
auto _parent() -> maybe<pTableView&>;
|
||||||
|
auto _setState() -> void;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
66
qt/widget/table-view-item.cpp
Normal file
66
qt/widget/table-view-item.cpp
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
#if defined(Hiro_TableView)
|
||||||
|
|
||||||
|
namespace hiro {
|
||||||
|
|
||||||
|
auto pTableViewItem::construct() -> void {
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewItem::destruct() -> void {
|
||||||
|
if(auto parent = _parent()) parent->lock();
|
||||||
|
if(qtItem) {
|
||||||
|
delete qtItem;
|
||||||
|
qtItem = nullptr;
|
||||||
|
}
|
||||||
|
if(auto parent = _parent()) parent->unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewItem::append(sTableViewCell cell) -> void {
|
||||||
|
_setState();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewItem::remove(sTableViewCell cell) -> void {
|
||||||
|
_setState();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewItem::setAlignment(Alignment alignment) -> void {
|
||||||
|
_setState();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewItem::setBackgroundColor(Color color) -> void {
|
||||||
|
_setState();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewItem::setFont(const Font& font) -> void {
|
||||||
|
_setState();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewItem::setForegroundColor(Color color) -> void {
|
||||||
|
_setState();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewItem::setSelected(bool selected) -> void {
|
||||||
|
_setState();
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewItem::_parent() -> maybe<pTableView&> {
|
||||||
|
if(auto parent = self().parentTableView()) {
|
||||||
|
if(auto delegate = parent->self()) return *delegate;
|
||||||
|
}
|
||||||
|
return nothing;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto pTableViewItem::_setState() -> void {
|
||||||
|
if(auto parent = _parent()) {
|
||||||
|
qtItem->setSelected(state().selected);
|
||||||
|
if(state().selected) {
|
||||||
|
parent->qtTableView->setCurrentItem(qtItem);
|
||||||
|
}
|
||||||
|
for(auto& cell : state().cells) {
|
||||||
|
if(auto self = cell->self()) self->_setState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,19 +1,19 @@
|
||||||
#if defined(Hiro_ListView)
|
#if defined(Hiro_TableView)
|
||||||
|
|
||||||
namespace hiro {
|
namespace hiro {
|
||||||
|
|
||||||
struct pListViewItem : pObject {
|
struct pTableViewItem : pObject {
|
||||||
Declare(ListViewItem, Object)
|
Declare(TableViewItem, Object)
|
||||||
|
|
||||||
auto append(sListViewCell cell) -> void;
|
auto append(sTableViewCell cell) -> void;
|
||||||
auto remove(sListViewCell cell) -> void;
|
auto remove(sTableViewCell cell) -> void;
|
||||||
auto setAlignment(Alignment alignment) -> void;
|
auto setAlignment(Alignment alignment) -> void;
|
||||||
auto setBackgroundColor(Color color) -> void;
|
auto setBackgroundColor(Color color) -> void;
|
||||||
auto setFont(const Font& font) -> void override;
|
auto setFont(const Font& font) -> void override;
|
||||||
auto setForegroundColor(Color color) -> void;
|
auto setForegroundColor(Color color) -> void;
|
||||||
auto setSelected(bool selected) -> void;
|
auto setSelected(bool selected) -> void;
|
||||||
|
|
||||||
auto _parent() -> maybe<pListView&>;
|
auto _parent() -> maybe<pTableView&>;
|
||||||
auto _setState() -> void;
|
auto _setState() -> void;
|
||||||
|
|
||||||
QTreeWidgetItem* qtItem = nullptr;
|
QTreeWidgetItem* qtItem = nullptr;
|
|
@ -1,23 +1,23 @@
|
||||||
#if defined(Hiro_ListView)
|
#if defined(Hiro_TableView)
|
||||||
|
|
||||||
namespace hiro {
|
namespace hiro {
|
||||||
|
|
||||||
auto pListView::construct() -> void {
|
auto pTableView::construct() -> void {
|
||||||
qtWidget = qtListView = new QtListView(*this);
|
qtWidget = qtTableView = new QtTableView(*this);
|
||||||
qtListView->setAllColumnsShowFocus(true);
|
qtTableView->setAllColumnsShowFocus(true);
|
||||||
qtListView->setContextMenuPolicy(Qt::CustomContextMenu);
|
qtTableView->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
qtListView->setRootIsDecorated(false);
|
qtTableView->setRootIsDecorated(false);
|
||||||
qtListView->setHeaderHidden(true);
|
qtTableView->setHeaderHidden(true);
|
||||||
qtListView->header()->setMovable(false);
|
qtTableView->header()->setMovable(false);
|
||||||
|
|
||||||
qtListViewDelegate = new QtListViewDelegate(*this);
|
qtTableViewDelegate = new QtTableViewDelegate(*this);
|
||||||
qtListView->setItemDelegate(qtListViewDelegate);
|
qtTableView->setItemDelegate(qtTableViewDelegate);
|
||||||
|
|
||||||
qtListView->connect(qtListView, SIGNAL(itemActivated(QTreeWidgetItem*, int)), SLOT(onActivate()));
|
qtTableView->connect(qtTableView, SIGNAL(itemActivated(QTreeWidgetItem*, int)), SLOT(onActivate()));
|
||||||
qtListView->connect(qtListView, SIGNAL(itemSelectionChanged()), SLOT(onChange()));
|
qtTableView->connect(qtTableView, SIGNAL(itemSelectionChanged()), SLOT(onChange()));
|
||||||
qtListView->connect(qtListView, SIGNAL(customContextMenuRequested(const QPoint&)), SLOT(onContext()));
|
qtTableView->connect(qtTableView, SIGNAL(customContextMenuRequested(const QPoint&)), SLOT(onContext()));
|
||||||
qtListView->connect(qtListView->header(), SIGNAL(sectionClicked(int)), SLOT(onSort(int)));
|
qtTableView->connect(qtTableView->header(), SIGNAL(sectionClicked(int)), SLOT(onSort(int)));
|
||||||
qtListView->connect(qtListView, SIGNAL(itemChanged(QTreeWidgetItem*, int)), SLOT(onToggle(QTreeWidgetItem*, int)));
|
qtTableView->connect(qtTableView, SIGNAL(itemChanged(QTreeWidgetItem*, int)), SLOT(onToggle(QTreeWidgetItem*, int)));
|
||||||
|
|
||||||
setBackgroundColor(state().backgroundColor);
|
setBackgroundColor(state().backgroundColor);
|
||||||
setBatchable(state().batchable);
|
setBatchable(state().batchable);
|
||||||
|
@ -27,14 +27,14 @@ auto pListView::construct() -> void {
|
||||||
pWidget::construct();
|
pWidget::construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::destruct() -> void {
|
auto pTableView::destruct() -> void {
|
||||||
delete qtListViewDelegate;
|
delete qtTableViewDelegate;
|
||||||
delete qtListView;
|
delete qtTableView;
|
||||||
qtWidget = qtListView = nullptr;
|
qtWidget = qtTableView = nullptr;
|
||||||
qtListViewDelegate = nullptr;
|
qtTableViewDelegate = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::append(sListViewHeader header) -> void {
|
auto pTableView::append(sTableViewHeader header) -> void {
|
||||||
lock();
|
lock();
|
||||||
if(auto self = header->self()) {
|
if(auto self = header->self()) {
|
||||||
self->_setState();
|
self->_setState();
|
||||||
|
@ -42,22 +42,22 @@ auto pListView::append(sListViewHeader header) -> void {
|
||||||
unlock();
|
unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::append(sListViewItem item) -> void {
|
auto pTableView::append(sTableViewItem item) -> void {
|
||||||
lock();
|
lock();
|
||||||
if(auto self = item->self()) {
|
if(auto self = item->self()) {
|
||||||
self->qtItem = new QTreeWidgetItem(qtListView);
|
self->qtItem = new QTreeWidgetItem(qtTableView);
|
||||||
self->_setState();
|
self->_setState();
|
||||||
}
|
}
|
||||||
unlock();
|
unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::remove(sListViewHeader header) -> void {
|
auto pTableView::remove(sTableViewHeader header) -> void {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::remove(sListViewItem item) -> void {
|
auto pTableView::remove(sTableViewItem item) -> void {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::resizeColumns() -> void {
|
auto pTableView::resizeColumns() -> void {
|
||||||
lock();
|
lock();
|
||||||
|
|
||||||
if(auto& header = state().header) {
|
if(auto& header = state().header) {
|
||||||
|
@ -72,7 +72,7 @@ auto pListView::resizeColumns() -> void {
|
||||||
}
|
}
|
||||||
|
|
||||||
signed maximumWidth = self().geometry().width() - 6;
|
signed maximumWidth = self().geometry().width() - 6;
|
||||||
if(auto scrollBar = qtListView->verticalScrollBar()) {
|
if(auto scrollBar = qtTableView->verticalScrollBar()) {
|
||||||
if(scrollBar->isVisible()) maximumWidth -= scrollBar->geometry().width();
|
if(scrollBar->isVisible()) maximumWidth -= scrollBar->geometry().width();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,50 +84,50 @@ auto pListView::resizeColumns() -> void {
|
||||||
for(auto column : range(header->columnCount())) {
|
for(auto column : range(header->columnCount())) {
|
||||||
signed width = widths[column];
|
signed width = widths[column];
|
||||||
if(header->column(column).expandable()) width += expandWidth;
|
if(header->column(column).expandable()) width += expandWidth;
|
||||||
qtListView->setColumnWidth(column, width);
|
qtTableView->setColumnWidth(column, width);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unlock();
|
unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::setAlignment(Alignment alignment) -> void {
|
auto pTableView::setAlignment(Alignment alignment) -> void {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::setBackgroundColor(Color color) -> void {
|
auto pTableView::setBackgroundColor(Color color) -> void {
|
||||||
if(color) {
|
if(color) {
|
||||||
QPalette palette = qtListView->palette();
|
QPalette palette = qtTableView->palette();
|
||||||
palette.setColor(QPalette::Base, QColor(color.red(), color.green(), color.blue()));
|
palette.setColor(QPalette::Base, QColor(color.red(), color.green(), color.blue()));
|
||||||
palette.setColor(QPalette::AlternateBase, QColor(max(0, (signed)color.red() - 17), max(0, (signed)color.green() - 17), max(0, (signed)color.blue() - 17)));
|
palette.setColor(QPalette::AlternateBase, QColor(max(0, (signed)color.red() - 17), max(0, (signed)color.green() - 17), max(0, (signed)color.blue() - 17)));
|
||||||
qtListView->setPalette(palette);
|
qtTableView->setPalette(palette);
|
||||||
qtListView->setAutoFillBackground(true);
|
qtTableView->setAutoFillBackground(true);
|
||||||
} else {
|
} else {
|
||||||
//todo: set default color
|
//todo: set default color
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::setBatchable(bool batchable) -> void {
|
auto pTableView::setBatchable(bool batchable) -> void {
|
||||||
lock();
|
lock();
|
||||||
qtListView->setSelectionMode(batchable ? QAbstractItemView::ExtendedSelection : QAbstractItemView::SingleSelection);
|
qtTableView->setSelectionMode(batchable ? QAbstractItemView::ExtendedSelection : QAbstractItemView::SingleSelection);
|
||||||
unlock();
|
unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::setBordered(bool bordered) -> void {
|
auto pTableView::setBordered(bool bordered) -> void {
|
||||||
qtListView->repaint();
|
qtTableView->repaint();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::setForegroundColor(Color color) -> void {
|
auto pTableView::setForegroundColor(Color color) -> void {
|
||||||
if(color) {
|
if(color) {
|
||||||
QPalette palette = qtListView->palette();
|
QPalette palette = qtTableView->palette();
|
||||||
palette.setColor(QPalette::Text, QColor(color.red(), color.green(), color.blue()));
|
palette.setColor(QPalette::Text, QColor(color.red(), color.green(), color.blue()));
|
||||||
qtListView->setPalette(palette);
|
qtTableView->setPalette(palette);
|
||||||
} else {
|
} else {
|
||||||
//todo: set default color
|
//todo: set default color
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//called on resize/show events
|
//called on resize/show events
|
||||||
auto pListView::_onSize() -> void {
|
auto pTableView::_onSize() -> void {
|
||||||
//resize columns only if at least one column is expandable
|
//resize columns only if at least one column is expandable
|
||||||
if(auto& header = state().header) {
|
if(auto& header = state().header) {
|
||||||
for(auto& column : header->state.columns) {
|
for(auto& column : header->state.columns) {
|
||||||
|
@ -136,7 +136,7 @@ auto pListView::_onSize() -> void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::_width(unsigned column) -> unsigned {
|
auto pTableView::_width(unsigned column) -> unsigned {
|
||||||
if(auto& header = state().header) {
|
if(auto& header = state().header) {
|
||||||
if(auto width = header->column(column).width()) return width;
|
if(auto width = header->column(column).width()) return width;
|
||||||
unsigned width = 1;
|
unsigned width = 1;
|
||||||
|
@ -150,12 +150,12 @@ auto pListView::_width(unsigned column) -> unsigned {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::_widthOfColumn(unsigned _column) -> unsigned {
|
auto pTableView::_widthOfColumn(unsigned _column) -> unsigned {
|
||||||
unsigned width = 8;
|
unsigned width = 8;
|
||||||
if(auto& header = state().header) {
|
if(auto& header = state().header) {
|
||||||
if(auto column = header->column(_column)) {
|
if(auto column = header->column(_column)) {
|
||||||
if(auto& icon = column->state.icon) {
|
if(auto& icon = column->state.icon) {
|
||||||
width += icon.width() + 2;
|
width += icon.width() + 4;
|
||||||
}
|
}
|
||||||
if(auto& text = column->state.text) {
|
if(auto& text = column->state.text) {
|
||||||
width += pFont::size(column->font(true), text).width();
|
width += pFont::size(column->font(true), text).width();
|
||||||
|
@ -165,15 +165,15 @@ auto pListView::_widthOfColumn(unsigned _column) -> unsigned {
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pListView::_widthOfCell(unsigned _row, unsigned _column) -> unsigned {
|
auto pTableView::_widthOfCell(unsigned _row, unsigned _column) -> unsigned {
|
||||||
unsigned width = 8;
|
unsigned width = 8;
|
||||||
if(auto item = self().item(_row)) {
|
if(auto item = self().item(_row)) {
|
||||||
if(auto cell = item->cell(_column)) {
|
if(auto cell = item->cell(_column)) {
|
||||||
if(cell->state.checkable) {
|
if(cell->state.checkable) {
|
||||||
width += 16 + 2;
|
width += 16 + 4;
|
||||||
}
|
}
|
||||||
if(auto& icon = cell->state.icon) {
|
if(auto& icon = cell->state.icon) {
|
||||||
width += icon.width() + 2;
|
width += icon.width() + 4;
|
||||||
}
|
}
|
||||||
if(auto& text = cell->state.text) {
|
if(auto& text = cell->state.text) {
|
||||||
width += pFont::size(cell->font(true), text).width();
|
width += pFont::size(cell->font(true), text).width();
|
||||||
|
@ -183,11 +183,11 @@ auto pListView::_widthOfCell(unsigned _row, unsigned _column) -> unsigned {
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto QtListView::onActivate() -> void {
|
auto QtTableView::onActivate() -> void {
|
||||||
if(!p.locked()) p.self().doActivate();
|
if(!p.locked()) p.self().doActivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto QtListView::onChange() -> void {
|
auto QtTableView::onChange() -> void {
|
||||||
for(auto& item : p.state().items) {
|
for(auto& item : p.state().items) {
|
||||||
item->state.selected = false;
|
item->state.selected = false;
|
||||||
if(auto self = item->self()) {
|
if(auto self = item->self()) {
|
||||||
|
@ -197,11 +197,11 @@ auto QtListView::onChange() -> void {
|
||||||
if(!p.locked()) p.self().doChange();
|
if(!p.locked()) p.self().doChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto QtListView::onContext() -> void {
|
auto QtTableView::onContext() -> void {
|
||||||
if(!p.locked()) p.self().doContext();
|
if(!p.locked()) p.self().doContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto QtListView::onSort(int columnNumber) -> void {
|
auto QtTableView::onSort(int columnNumber) -> void {
|
||||||
if(auto& header = p.state().header) {
|
if(auto& header = p.state().header) {
|
||||||
if(auto column = header->column(columnNumber)) {
|
if(auto column = header->column(columnNumber)) {
|
||||||
if(!p.locked() && column.sortable()) p.self().doSort(column);
|
if(!p.locked() && column.sortable()) p.self().doSort(column);
|
||||||
|
@ -209,7 +209,7 @@ auto QtListView::onSort(int columnNumber) -> void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto QtListView::onToggle(QTreeWidgetItem* qtItem, int column) -> void {
|
auto QtTableView::onToggle(QTreeWidgetItem* qtItem, int column) -> void {
|
||||||
for(auto& item : p.state().items) {
|
for(auto& item : p.state().items) {
|
||||||
if(auto self = item->self()) {
|
if(auto self = item->self()) {
|
||||||
if(qtItem == self->qtItem) {
|
if(qtItem == self->qtItem) {
|
||||||
|
@ -222,25 +222,25 @@ auto QtListView::onToggle(QTreeWidgetItem* qtItem, int column) -> void {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto QtListView::mousePressEvent(QMouseEvent* event) -> void {
|
auto QtTableView::mousePressEvent(QMouseEvent* event) -> void {
|
||||||
QTreeWidget::mousePressEvent(event);
|
QTreeWidget::mousePressEvent(event);
|
||||||
if(event->button() == Qt::RightButton) onContext();
|
if(event->button() == Qt::RightButton) onContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto QtListView::resizeEvent(QResizeEvent* event) -> void {
|
auto QtTableView::resizeEvent(QResizeEvent* event) -> void {
|
||||||
QTreeWidget::resizeEvent(event);
|
QTreeWidget::resizeEvent(event);
|
||||||
p._onSize();
|
p._onSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto QtListView::showEvent(QShowEvent* event) -> void {
|
auto QtTableView::showEvent(QShowEvent* event) -> void {
|
||||||
QTreeWidget::showEvent(event);
|
QTreeWidget::showEvent(event);
|
||||||
p._onSize();
|
p._onSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
QtListViewDelegate::QtListViewDelegate(pListView& p) : QStyledItemDelegate(p.qtListView), p(p) {
|
QtTableViewDelegate::QtTableViewDelegate(pTableView& p) : QStyledItemDelegate(p.qtTableView), p(p) {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto QtListViewDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const -> void {
|
auto QtTableViewDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const -> void {
|
||||||
QStyledItemDelegate::paint(painter, option, index);
|
QStyledItemDelegate::paint(painter, option, index);
|
||||||
if(p.state().bordered) {
|
if(p.state().bordered) {
|
||||||
QPen pen;
|
QPen pen;
|
|
@ -1,14 +1,14 @@
|
||||||
#if defined(Hiro_ListView)
|
#if defined(Hiro_TableView)
|
||||||
|
|
||||||
namespace hiro {
|
namespace hiro {
|
||||||
|
|
||||||
struct pListView : pWidget {
|
struct pTableView : pWidget {
|
||||||
Declare(ListView, Widget)
|
Declare(TableView, Widget)
|
||||||
|
|
||||||
auto append(sListViewHeader header) -> void;
|
auto append(sTableViewHeader header) -> void;
|
||||||
auto append(sListViewItem item) -> void;
|
auto append(sTableViewItem item) -> void;
|
||||||
auto remove(sListViewHeader header) -> void;
|
auto remove(sTableViewHeader header) -> void;
|
||||||
auto remove(sListViewItem item) -> void;
|
auto remove(sTableViewItem item) -> void;
|
||||||
auto resizeColumns() -> void;
|
auto resizeColumns() -> void;
|
||||||
auto setAlignment(Alignment alignment) -> void;
|
auto setAlignment(Alignment alignment) -> void;
|
||||||
auto setBackgroundColor(Color color) -> void;
|
auto setBackgroundColor(Color color) -> void;
|
||||||
|
@ -21,8 +21,8 @@ struct pListView : pWidget {
|
||||||
auto _widthOfColumn(unsigned column) -> unsigned;
|
auto _widthOfColumn(unsigned column) -> unsigned;
|
||||||
auto _widthOfCell(unsigned row, unsigned column) -> unsigned;
|
auto _widthOfCell(unsigned row, unsigned column) -> unsigned;
|
||||||
|
|
||||||
QtListView* qtListView = nullptr;
|
QtTableView* qtTableView = nullptr;
|
||||||
QtListViewDelegate* qtListViewDelegate = nullptr;
|
QtTableViewDelegate* qtTableViewDelegate = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
|
@ -8,8 +8,8 @@ auto pWindow::construct() -> void {
|
||||||
|
|
||||||
//if program was given a name, try and set the window taskbar icon to a matching pixmap image
|
//if program was given a name, try and set the window taskbar icon to a matching pixmap image
|
||||||
if(auto name = Application::state.name) {
|
if(auto name = Application::state.name) {
|
||||||
if(file::exists({userpath(), ".local/share/icons/", name, ".png"})) {
|
if(file::exists({Path::user(), ".local/share/icons/", name, ".png"})) {
|
||||||
qtWindow->setWindowIcon(QIcon(QString::fromUtf8(string{userpath(), ".local/share/icons/", name, ".png"})));
|
qtWindow->setWindowIcon(QIcon(QString::fromUtf8(string{Path::user(), ".local/share/icons/", name, ".png"})));
|
||||||
} else if(file::exists({"/usr/local/share/pixmaps/", name, ".png"})) {
|
} else if(file::exists({"/usr/local/share/pixmaps/", name, ".png"})) {
|
||||||
qtWindow->setWindowIcon(QIcon(QString::fromUtf8(string{"/usr/local/share/pixmaps/", name, ".png"})));
|
qtWindow->setWindowIcon(QIcon(QString::fromUtf8(string{"/usr/local/share/pixmaps/", name, ".png"})));
|
||||||
} else if(file::exists({"/usr/share/pixmaps/", name, ".png"})) {
|
} else if(file::exists({"/usr/share/pixmaps/", name, ".png"})) {
|
||||||
|
@ -195,10 +195,10 @@ auto pWindow::setVisible(bool visible) -> void {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if(widget.font().empty() && !window.state.widgetFont.empty()) {
|
if(!widget.font() && window.state.widgetFont) {
|
||||||
widget.setFont(window.state.widgetFont);
|
widget.setFont(window.state.widgetFont);
|
||||||
}
|
}
|
||||||
if(widget.font().empty()) widget.p.setFont(Font::sans(8));
|
if(!widget.font()) widget.p.setFont(Font::sans(8));
|
||||||
if(GetParentWidget(&widget)) {
|
if(GetParentWidget(&widget)) {
|
||||||
widget.p.qtWidget->setParent(GetParentWidget(&widget)->p.container(widget));
|
widget.p.qtWidget->setParent(GetParentWidget(&widget)->p.container(widget));
|
||||||
} else {
|
} else {
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue