mirror of
https://github.com/libretro/bsnes-libretro.git
synced 2024-11-23 08:59:40 +00:00
Update to v098r09 release.
byuu says: Changelog: - fixed major nall/vector/prepend bug - renamed hiro/ListView to hiro/TableView - added new hiro/ListView control which is a simplified abstraction of hiro/TableView - updated higan's cheat database window and icarus' scan dialog to use the new ListView control - compilation works once again on all platforms (Windows, Cocoa, GTK, Qt) - the loki skeleton compiles once again (removed nall/DSP references; updated port/device ID names) Small catch: need to capture layout resize events internally in Windows to call resizeColumns. For now, just resize the icarus window to get it to use the full window width for list view items.
This commit is contained in:
parent
0955295475
commit
6ae0abe3d3
@ -8,7 +8,7 @@ using namespace nall;
|
||||
|
||||
namespace Emulator {
|
||||
static const string Name = "higan";
|
||||
static const string Version = "098.08";
|
||||
static const string Version = "098.09";
|
||||
static const string Author = "byuu";
|
||||
static const string License = "GPLv3";
|
||||
static const string Website = "http://byuu.org/";
|
||||
|
@ -98,7 +98,7 @@ auto SDD1::mmcRead(uint24 addr) -> uint8 {
|
||||
//map address=00-3f,80-bf:8000-ffff
|
||||
//map address=c0-ff:0000-ffff
|
||||
auto SDD1::mcuromRead(uint24 addr, uint8 data) -> uint8 {
|
||||
//map address=00-3f,80-bf:8000-ffff mask=0x808000 => 00-1f:0000-ffff
|
||||
//map address=00-3f,80-bf:8000-ffff
|
||||
if(!addr.bit(22)) {
|
||||
if(!addr.bit(23) && addr.bit(21) && r4805.bit(7)) addr.bit(21) = 0; //20-3f:8000-ffff
|
||||
if( addr.bit(23) && addr.bit(21) && r4807.bit(7)) addr.bit(21) = 0; //a0-bf:8000-ffff
|
||||
|
@ -60,12 +60,7 @@ auto Program::videoRefresh(const uint32* data, uint pitch, uint width, uint heig
|
||||
}
|
||||
|
||||
auto Program::audioSample(int16 left, int16 right) -> void {
|
||||
int samples[] = {left, right};
|
||||
dsp.sample(samples);
|
||||
while(dsp.pending()) {
|
||||
dsp.read(samples);
|
||||
audio->sample(samples[0], samples[1]);
|
||||
}
|
||||
audio->sample(left, right);
|
||||
}
|
||||
|
||||
auto Program::inputPoll(uint port, uint device, uint input) -> int16 {
|
||||
@ -79,8 +74,8 @@ auto Program::inputPoll(uint port, uint device, uint input) -> int16 {
|
||||
}
|
||||
}
|
||||
|
||||
if(port == (uint)SFC::Device::Port::Controller1) {
|
||||
if(device == (uint)SFC::Device::ID::Gamepad) {
|
||||
if(port == (uint)SFC::Port::Controller1) {
|
||||
if(device == (uint)SFC::Device::Gamepad) {
|
||||
#define map(id, name) \
|
||||
case id: \
|
||||
if(auto code = keyboard->buttons().find(name)) { \
|
||||
|
@ -22,19 +22,15 @@ auto Program::loadMedia(Emulator::Interface::Media& media, string location) -> v
|
||||
emulator->set("Color Emulation", false);
|
||||
emulator->set("Scanline Emulation", false);
|
||||
|
||||
emulator->connect((uint)SFC::Device::Port::Controller1, (uint)SFC::Device::ID::Gamepad);
|
||||
emulator->connect((uint)SFC::Device::Port::Controller2, (uint)SFC::Device::ID::None);
|
||||
emulator->connect((uint)SFC::Device::Port::Expansion, (uint)SFC::Device::ID::None);
|
||||
Emulator::audio.reset();
|
||||
Emulator::audio.setFrequency(audio->get(Audio::Frequency).get<uint>());
|
||||
emulator->connect((uint)SFC::Port::Controller1, (uint)SFC::Device::Gamepad);
|
||||
emulator->connect((uint)SFC::Port::Controller2, (uint)SFC::Device::None);
|
||||
emulator->connect((uint)SFC::Port::Expansion, (uint)SFC::Device::None);
|
||||
|
||||
emulator->load(media.id);
|
||||
emulator->power();
|
||||
|
||||
dsp.setResampler(DSP::ResampleEngine::Sinc);
|
||||
dsp.setResamplerFrequency(96000.0);
|
||||
double inputRatio = emulator->audioFrequency() / emulator->videoFrequency();
|
||||
double outputRatio = 96000.0 / 60.0;
|
||||
dsp.setFrequency(inputRatio / outputRatio * 96000.0);
|
||||
|
||||
presentation->setTitle(emulator->title());
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,6 @@ struct Program : Emulator::Interface::Bind {
|
||||
auto path(uint group) -> string override;
|
||||
auto notify(string text) -> void override;
|
||||
|
||||
DSP dsp;
|
||||
vector<shared_pointer<HID::Device>> devices;
|
||||
vector<string> mediaPaths;
|
||||
vector<string> folderPaths;
|
||||
|
@ -15,7 +15,7 @@ HotkeySettings::HotkeySettings(TabFrame* parent) : TabFrameItem(parent) {
|
||||
});
|
||||
eraseButton.setText("Erase").onActivate([&] {
|
||||
if(auto item = mappingList.selected()) {
|
||||
inputManager->hotkeys[item->offset()]->unbind();
|
||||
inputManager->hotkeys[item.offset()]->unbind();
|
||||
refreshMappings();
|
||||
}
|
||||
});
|
||||
@ -26,16 +26,16 @@ HotkeySettings::HotkeySettings(TabFrame* parent) : TabFrameItem(parent) {
|
||||
|
||||
auto HotkeySettings::reloadMappings() -> void {
|
||||
mappingList.reset();
|
||||
mappingList.append(ListViewHeader().setVisible()
|
||||
.append(ListViewColumn().setText("Name"))
|
||||
.append(ListViewColumn().setText("Mapping").setExpandable())
|
||||
.append(ListViewColumn().setText("Device").setAlignment(1.0).setForegroundColor({0, 128, 0}))
|
||||
mappingList.append(TableViewHeader().setVisible()
|
||||
.append(TableViewColumn().setText("Name"))
|
||||
.append(TableViewColumn().setText("Mapping").setExpandable())
|
||||
.append(TableViewColumn().setText("Device").setAlignment(1.0).setForegroundColor({0, 128, 0}))
|
||||
);
|
||||
for(auto& hotkey : inputManager->hotkeys) {
|
||||
mappingList.append(ListViewItem()
|
||||
.append(ListViewCell().setText(hotkey->name))
|
||||
.append(ListViewCell())
|
||||
.append(ListViewCell())
|
||||
mappingList.append(TableViewItem()
|
||||
.append(TableViewCell().setText(hotkey->name))
|
||||
.append(TableViewCell())
|
||||
.append(TableViewCell())
|
||||
);
|
||||
}
|
||||
mappingList.resizeColumns();
|
||||
@ -44,8 +44,8 @@ auto HotkeySettings::reloadMappings() -> void {
|
||||
auto HotkeySettings::refreshMappings() -> void {
|
||||
uint position = 0;
|
||||
for(auto& hotkey : inputManager->hotkeys) {
|
||||
mappingList.item(position)->cell(1)->setText(hotkey->assignmentName());
|
||||
mappingList.item(position)->cell(2)->setText(hotkey->deviceName());
|
||||
mappingList.item(position).cell(1).setText(hotkey->assignmentName());
|
||||
mappingList.item(position).cell(2).setText(hotkey->deviceName());
|
||||
position++;
|
||||
}
|
||||
mappingList.resizeColumns();
|
||||
@ -55,7 +55,7 @@ auto HotkeySettings::assignMapping() -> void {
|
||||
inputManager->poll(); //clear any pending events first
|
||||
|
||||
if(auto item = mappingList.selected()) {
|
||||
activeMapping = inputManager->hotkeys[item->offset()];
|
||||
activeMapping = inputManager->hotkeys[item.offset()];
|
||||
settingsManager->layout.setEnabled(false);
|
||||
settingsManager->statusBar.setText({"Press a key or button to map [", activeMapping->name, "] ..."});
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ InputSettings::InputSettings(TabFrame* parent) : TabFrameItem(parent) {
|
||||
});
|
||||
eraseButton.setText("Erase").onActivate([&] {
|
||||
if(auto mapping = mappingList.selected()) {
|
||||
activeDevice().mappings[mapping->offset()]->unbind();
|
||||
activeDevice().mappings[mapping.offset()]->unbind();
|
||||
refreshMappings();
|
||||
}
|
||||
});
|
||||
@ -45,7 +45,7 @@ auto InputSettings::updateControls() -> void {
|
||||
assignMouse3.setVisible(false);
|
||||
|
||||
if(auto mapping = mappingList.selected()) {
|
||||
auto input = activeDevice().mappings[mapping->offset()];
|
||||
auto input = activeDevice().mappings[mapping.offset()];
|
||||
|
||||
if(input->isDigital()) {
|
||||
assignMouse1.setVisible().setText("Mouse Left");
|
||||
@ -92,16 +92,16 @@ auto InputSettings::reloadDevices() -> void {
|
||||
auto InputSettings::reloadMappings() -> void {
|
||||
eraseButton.setEnabled(false);
|
||||
mappingList.reset();
|
||||
mappingList.append(ListViewHeader().setVisible()
|
||||
.append(ListViewColumn().setText("Name"))
|
||||
.append(ListViewColumn().setText("Mapping").setExpandable())
|
||||
.append(ListViewColumn().setText("Device").setAlignment(1.0).setForegroundColor({0, 128, 0}))
|
||||
mappingList.append(TableViewHeader().setVisible()
|
||||
.append(TableViewColumn().setText("Name"))
|
||||
.append(TableViewColumn().setText("Mapping").setExpandable())
|
||||
.append(TableViewColumn().setText("Device").setAlignment(1.0).setForegroundColor({0, 128, 0}))
|
||||
);
|
||||
for(auto& mapping : activeDevice().mappings) {
|
||||
mappingList.append(ListViewItem()
|
||||
.append(ListViewCell().setText(mapping->name))
|
||||
.append(ListViewCell())
|
||||
.append(ListViewCell())
|
||||
mappingList.append(TableViewItem()
|
||||
.append(TableViewCell().setText(mapping->name))
|
||||
.append(TableViewCell())
|
||||
.append(TableViewCell())
|
||||
);
|
||||
}
|
||||
refreshMappings();
|
||||
@ -110,8 +110,8 @@ auto InputSettings::reloadMappings() -> void {
|
||||
auto InputSettings::refreshMappings() -> void {
|
||||
uint position = 0;
|
||||
for(auto& mapping : activeDevice().mappings) {
|
||||
mappingList.item(position)->cell(1)->setText(mapping->assignmentName());
|
||||
mappingList.item(position)->cell(2)->setText(mapping->deviceName());
|
||||
mappingList.item(position).cell(1).setText(mapping->assignmentName());
|
||||
mappingList.item(position).cell(2).setText(mapping->deviceName());
|
||||
position++;
|
||||
}
|
||||
mappingList.resizeColumns();
|
||||
|
@ -90,7 +90,7 @@ struct InputSettings : TabFrameItem {
|
||||
ComboButton emulatorList{&selectionLayout, Size{~0, 0}};
|
||||
ComboButton portList{&selectionLayout, Size{~0, 0}};
|
||||
ComboButton deviceList{&selectionLayout, Size{~0, 0}};
|
||||
ListView mappingList{&layout, Size{~0, ~0}};
|
||||
TableView mappingList{&layout, Size{~0, ~0}};
|
||||
HorizontalLayout controlLayout{&layout, Size{~0, 0}};
|
||||
Button assignMouse1{&controlLayout, Size{100, 0}};
|
||||
Button assignMouse2{&controlLayout, Size{100, 0}};
|
||||
@ -111,7 +111,7 @@ struct HotkeySettings : TabFrameItem {
|
||||
Timer timer;
|
||||
|
||||
VerticalLayout layout{this};
|
||||
ListView mappingList{&layout, Size{~0, ~0}};
|
||||
TableView mappingList{&layout, Size{~0, ~0}};
|
||||
HorizontalLayout controlLayout{&layout, Size{~0, 0}};
|
||||
Widget spacer{&controlLayout, Size{~0, 0}};
|
||||
Button resetButton{&controlLayout, Size{80, 0}};
|
||||
|
@ -3,17 +3,15 @@ CheatDatabase::CheatDatabase() {
|
||||
|
||||
layout.setMargin(5);
|
||||
selectAllButton.setText("Select All").onActivate([&] {
|
||||
for(auto& item : cheatList.items()) item.cell(0).setChecked(true);
|
||||
for(auto& item : cheatList.items()) item.setChecked(true);
|
||||
});
|
||||
unselectAllButton.setText("Unselect All").onActivate([&] {
|
||||
for(auto& item : cheatList.items()) item.cell(0).setChecked(false);
|
||||
for(auto& item : cheatList.items()) item.setChecked(false);
|
||||
});
|
||||
addCodesButton.setText("Add Codes").onActivate([&] { addCodes(); });
|
||||
|
||||
setSize({800, 400});
|
||||
setAlignment({0.5, 1.0});
|
||||
|
||||
onSize([&] { cheatList.resizeColumns(); });
|
||||
}
|
||||
|
||||
auto CheatDatabase::findCodes() -> void {
|
||||
@ -28,19 +26,13 @@ auto CheatDatabase::findCodes() -> void {
|
||||
|
||||
codes.reset();
|
||||
cheatList.reset();
|
||||
cheatList.append(ListViewHeader().setVisible(false)
|
||||
.append(ListViewColumn().setExpandable())
|
||||
);
|
||||
for(auto cheat : cartridge.find("cheat")) {
|
||||
codes.append(cheat["code"].text());
|
||||
cheatList.append(ListViewItem()
|
||||
.append(ListViewCell().setCheckable().setText(cheat["description"].text()))
|
||||
);
|
||||
cheatList.append(ListViewItem().setCheckable().setText(cheat["description"].text()));
|
||||
}
|
||||
|
||||
setTitle(cartridge["name"].text());
|
||||
setVisible();
|
||||
cheatList.resizeColumns();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -49,10 +41,10 @@ auto CheatDatabase::findCodes() -> void {
|
||||
|
||||
auto CheatDatabase::addCodes() -> void {
|
||||
for(auto& item : cheatList.items()) {
|
||||
if(!item.cell(0).checked()) continue;
|
||||
if(!item.checked()) continue;
|
||||
|
||||
string code = codes(item.offset(), "");
|
||||
string description = item.cell(0).text();
|
||||
string description = item.text();
|
||||
if(toolsManager->cheatEditor.addCode(code, description) == false) {
|
||||
MessageDialog().setParent(*this).setText("Free slots exhausted. Not all codes could be added.").warning();
|
||||
break;
|
||||
|
@ -3,20 +3,20 @@ CheatEditor::CheatEditor(TabFrame* parent) : TabFrameItem(parent) {
|
||||
setText("Cheat Editor");
|
||||
|
||||
layout.setMargin(5);
|
||||
cheatList.append(ListViewHeader().setVisible()
|
||||
.append(ListViewColumn().setText("Slot").setForegroundColor({0, 128, 0}).setAlignment(1.0))
|
||||
.append(ListViewColumn().setText("Code(s)"))
|
||||
.append(ListViewColumn().setText("Description").setExpandable())
|
||||
cheatList.append(TableViewHeader().setVisible()
|
||||
.append(TableViewColumn().setText("Slot").setForegroundColor({0, 128, 0}).setAlignment(1.0))
|
||||
.append(TableViewColumn().setText("Code(s)"))
|
||||
.append(TableViewColumn().setText("Description").setExpandable())
|
||||
);
|
||||
for(auto slot : range(Slots)) {
|
||||
cheatList.append(ListViewItem()
|
||||
.append(ListViewCell().setCheckable().setText(1 + slot))
|
||||
.append(ListViewCell())
|
||||
.append(ListViewCell())
|
||||
cheatList.append(TableViewItem()
|
||||
.append(TableViewCell().setCheckable().setText(1 + slot))
|
||||
.append(TableViewCell())
|
||||
.append(TableViewCell())
|
||||
);
|
||||
}
|
||||
cheatList.onChange([&] { doChangeSelected(); });
|
||||
cheatList.onToggle([&](ListViewCell cell) {
|
||||
cheatList.onToggle([&](TableViewCell cell) {
|
||||
cheats[cell.parent().offset()].enabled = cell.checked();
|
||||
synchronizeCodes();
|
||||
});
|
||||
|
@ -3,14 +3,14 @@ StateManager::StateManager(TabFrame* parent) : TabFrameItem(parent) {
|
||||
setText("State Manager");
|
||||
|
||||
layout.setMargin(5);
|
||||
stateList.append(ListViewHeader().setVisible()
|
||||
.append(ListViewColumn().setText("Slot").setForegroundColor({0, 128, 0}).setAlignment(1.0))
|
||||
.append(ListViewColumn().setText("Description").setExpandable())
|
||||
stateList.append(TableViewHeader().setVisible()
|
||||
.append(TableViewColumn().setText("Slot").setForegroundColor({0, 128, 0}).setAlignment(1.0))
|
||||
.append(TableViewColumn().setText("Description").setExpandable())
|
||||
);
|
||||
for(auto slot : range(Slots)) {
|
||||
stateList.append(ListViewItem()
|
||||
.append(ListViewCell().setText(1 + slot))
|
||||
.append(ListViewCell())
|
||||
stateList.append(TableViewItem()
|
||||
.append(TableViewCell().setText(1 + slot))
|
||||
.append(TableViewCell())
|
||||
);
|
||||
}
|
||||
stateList.onActivate([&] { doLoad(); });
|
||||
|
@ -36,7 +36,7 @@ struct CheatEditor : TabFrameItem {
|
||||
Cheat cheats[Slots];
|
||||
|
||||
VerticalLayout layout{this};
|
||||
ListView cheatList{&layout, Size{~0, ~0}};
|
||||
TableView cheatList{&layout, Size{~0, ~0}};
|
||||
HorizontalLayout codeLayout{&layout, Size{~0, 0}};
|
||||
Label codeLabel{&codeLayout, Size{70, 0}};
|
||||
LineEdit codeValue{&codeLayout, Size{~0, 0}};
|
||||
@ -64,7 +64,7 @@ struct StateManager : TabFrameItem {
|
||||
auto doErase() -> void;
|
||||
|
||||
VerticalLayout layout{this};
|
||||
ListView stateList{&layout, Size{~0, ~0}};
|
||||
TableView stateList{&layout, Size{~0, ~0}};
|
||||
HorizontalLayout descriptionLayout{&layout, Size{~0, 0}};
|
||||
Label descriptionLabel{&descriptionLayout, Size{70, 0}};
|
||||
LineEdit descriptionValue{&descriptionLayout, Size{~0, 0}};
|
||||
|
@ -1,6 +1,14 @@
|
||||
#define decimal CocoaDecimal
|
||||
#define decimal decimal_cocoa
|
||||
#define uint8 uint8_cocoa
|
||||
#define uint16 uint16_cocoa
|
||||
#define uint32 uint32_cocoa
|
||||
#define uint64 uint64_cocoa
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import <Carbon/Carbon.h>
|
||||
#undef decimal
|
||||
#undef uint8
|
||||
#undef uint16
|
||||
#undef uint32
|
||||
#undef uint64
|
||||
|
||||
#include <nall/run.hpp>
|
||||
|
@ -42,16 +42,16 @@
|
||||
#include "widget/horizontal-slider.cpp"
|
||||
#include "widget/label.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/radio-button.cpp"
|
||||
#include "widget/radio-label.cpp"
|
||||
#include "widget/tab-frame.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/vertical-scroll-bar.cpp"
|
||||
#include "widget/vertical-slider.cpp"
|
||||
|
@ -54,16 +54,16 @@ namespace hiro {
|
||||
#include "widget/horizontal-slider.hpp"
|
||||
#include "widget/label.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/radio-button.hpp"
|
||||
#include "widget/radio-label.hpp"
|
||||
#include "widget/tab-frame.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/vertical-scroll-bar.hpp"
|
||||
#include "widget/vertical-slider.hpp"
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
-(BOOL) performDragOperation:(id<NSDraggingInfo>)sender {
|
||||
lstring paths = DropPaths(sender);
|
||||
if(paths.empty()) return NO;
|
||||
if(!paths) return NO;
|
||||
canvas->doDrop(paths);
|
||||
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
hiro/cocoa/widget/table-view-cell.cpp
Normal file
50
hiro/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 {
|
||||
|
||||
struct pListViewCell : pObject {
|
||||
Declare(ListViewCell, Object)
|
||||
struct pTableViewCell : pObject {
|
||||
Declare(TableViewCell, Object)
|
||||
|
||||
auto setAlignment(Alignment alignment) -> void;
|
||||
auto setBackgroundColor(Color color) -> void;
|
||||
@ -13,8 +13,8 @@ struct pListViewCell : pObject {
|
||||
auto setIcon(const image& icon) -> void;
|
||||
auto setText(const string& text) -> void;
|
||||
|
||||
auto _grandparent() -> maybe<pListView&>;
|
||||
auto _parent() -> maybe<pListViewItem&>;
|
||||
auto _grandparent() -> maybe<pTableView&>;
|
||||
auto _parent() -> maybe<pTableViewItem&>;
|
||||
};
|
||||
|
||||
}
|
87
hiro/cocoa/widget/table-view-column.cpp
Normal file
87
hiro/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 {
|
||||
|
||||
struct pListViewColumn : pObject {
|
||||
Declare(ListViewColumn, Object)
|
||||
struct pTableViewColumn : pObject {
|
||||
Declare(TableViewColumn, Object)
|
||||
|
||||
auto setActive() -> void;
|
||||
auto setAlignment(Alignment alignment) -> void;
|
||||
@ -21,8 +21,8 @@ struct pListViewColumn : pObject {
|
||||
auto setVisible(bool visible) -> void override;
|
||||
auto setWidth(signed width) -> void;
|
||||
|
||||
auto _grandparent() -> maybe<pListView&>;
|
||||
auto _parent() -> maybe<pListViewHeader&>;
|
||||
auto _grandparent() -> maybe<pTableView&>;
|
||||
auto _parent() -> maybe<pTableViewHeader&>;
|
||||
};
|
||||
|
||||
}
|
38
hiro/cocoa/widget/table-view-header.cpp
Normal file
38
hiro/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
hiro/cocoa/widget/table-view-header.hpp
Normal file
17
hiro/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
hiro/cocoa/widget/table-view-item.cpp
Normal file
51
hiro/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 {
|
||||
|
||||
struct pListViewItem : pObject {
|
||||
Declare(ListViewItem, Object)
|
||||
struct pTableViewItem : pObject {
|
||||
Declare(TableViewItem, Object)
|
||||
|
||||
auto append(sListViewCell cell) -> void;
|
||||
auto remove(sListViewCell cell) -> void;
|
||||
auto append(sTableViewCell cell) -> void;
|
||||
auto remove(sTableViewCell cell) -> void;
|
||||
auto setAlignment(Alignment alignment) -> void;
|
||||
auto setBackgroundColor(Color color) -> void;
|
||||
auto setFocused() -> void;
|
||||
auto setForegroundColor(Color color) -> 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)]) {
|
||||
listView = &listViewReference;
|
||||
content = [[CocoaListViewContent alloc] initWithFrame:NSMakeRect(0, 0, 0, 0)];
|
||||
tableView = &tableViewReference;
|
||||
content = [[CocoaTableViewContent alloc] initWithFrame:NSMakeRect(0, 0, 0, 0)];
|
||||
|
||||
[self setDocumentView:content];
|
||||
[self setBorderType:NSBezelBorder];
|
||||
@ -34,7 +34,7 @@
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
-(CocoaListViewContent*) content {
|
||||
-(CocoaTableViewContent*) content {
|
||||
return content;
|
||||
}
|
||||
|
||||
@ -59,13 +59,13 @@
|
||||
[content removeTableColumn:[[content tableColumns] lastObject]];
|
||||
}
|
||||
|
||||
if(auto listViewHeader = listView->state.header) {
|
||||
for(auto& listViewColumn : listViewHeader->state.columns) {
|
||||
auto column = listViewColumn->offset();
|
||||
if(auto tableViewHeader = tableView->state.header) {
|
||||
for(auto& tableViewColumn : tableViewHeader->state.columns) {
|
||||
auto column = tableViewColumn->offset();
|
||||
|
||||
NSTableColumn* tableColumn = [[NSTableColumn alloc] initWithIdentifier:[[NSNumber numberWithInteger:column] stringValue]];
|
||||
NSTableHeaderCell* headerCell = [[NSTableHeaderCell alloc] initTextCell:[NSString stringWithUTF8String:listViewColumn->state.text]];
|
||||
CocoaListViewCell* dataCell = [[CocoaListViewCell alloc] initWith:*listView];
|
||||
NSTableHeaderCell* headerCell = [[NSTableHeaderCell alloc] initTextCell:[NSString stringWithUTF8String:tableViewColumn->state.text]];
|
||||
CocoaTableViewCell* dataCell = [[CocoaTableViewCell alloc] initWith:*tableView];
|
||||
|
||||
[dataCell setEditable:NO];
|
||||
|
||||
@ -79,13 +79,13 @@
|
||||
}
|
||||
|
||||
-(NSInteger) numberOfRowsInTableView:(NSTableView*)table {
|
||||
return listView->state.items.size();
|
||||
return tableView->state.items.size();
|
||||
}
|
||||
|
||||
-(id) tableView:(NSTableView*)table objectValueForTableColumn:(NSTableColumn*)tableColumn row:(NSInteger)row {
|
||||
if(auto listViewItem = listView->item(row)) {
|
||||
if(auto listViewCell = listViewItem->cell([[tableColumn identifier] integerValue])) {
|
||||
NSString* text = [NSString stringWithUTF8String:listViewCell->state.text];
|
||||
if(auto tableViewItem = tableView->item(row)) {
|
||||
if(auto tableViewCell = tableViewItem->cell([[tableColumn identifier] integerValue])) {
|
||||
NSString* text = [NSString stringWithUTF8String:tableViewCell->state.text];
|
||||
return @{ @"text":text }; //used by type-ahead
|
||||
}
|
||||
}
|
||||
@ -105,14 +105,14 @@
|
||||
}
|
||||
|
||||
-(void) tableViewSelectionDidChange:(NSNotification*)notification {
|
||||
for(auto& listViewItem : listView->state.items) {
|
||||
listViewItem->state.selected = listViewItem->offset() == [content selectedRow];
|
||||
for(auto& tableViewItem : tableView->state.items) {
|
||||
tableViewItem->state.selected = tableViewItem->offset() == [content selectedRow];
|
||||
}
|
||||
listView->doChange();
|
||||
tableView->doChange();
|
||||
}
|
||||
|
||||
-(IBAction) activate:(id)sender {
|
||||
listView->doActivate();
|
||||
tableView->doActivate();
|
||||
}
|
||||
|
||||
-(IBAction) doubleAction:(id)sender {
|
||||
@ -123,7 +123,7 @@
|
||||
|
||||
@end
|
||||
|
||||
@implementation CocoaListViewContent : NSTableView
|
||||
@implementation CocoaTableViewContent : NSTableView
|
||||
|
||||
-(void) keyDown:(NSEvent*)event {
|
||||
auto character = [[event characters] characterAtIndex:0];
|
||||
@ -139,11 +139,11 @@
|
||||
|
||||
@end
|
||||
|
||||
@implementation CocoaListViewCell : NSCell
|
||||
@implementation CocoaTableViewCell : NSCell
|
||||
|
||||
-(id) initWith:(hiro::mListView&)listViewReference {
|
||||
-(id) initWith:(hiro::mTableView&)tableViewReference {
|
||||
if(self = [super initTextCell:@""]) {
|
||||
listView = &listViewReference;
|
||||
tableView = &tableViewReference;
|
||||
buttonCell = [[NSButtonCell alloc] initTextCell:@""];
|
||||
[buttonCell setButtonType:NSSwitchButton];
|
||||
[buttonCell setControlSize:NSSmallControlSize];
|
||||
@ -159,27 +159,27 @@
|
||||
}
|
||||
|
||||
-(void) drawWithFrame:(NSRect)frame inView:(NSView*)view {
|
||||
if(auto listViewItem = listView->item([view rowAtPoint:frame.origin])) {
|
||||
if(auto listViewCell = listViewItem->cell([view columnAtPoint:frame.origin])) {
|
||||
if(auto tableViewItem = tableView->item([view rowAtPoint:frame.origin])) {
|
||||
if(auto tableViewCell = tableViewItem->cell([view columnAtPoint:frame.origin])) {
|
||||
NSColor* backgroundColor = nil;
|
||||
if([self isHighlighted]) backgroundColor = [NSColor alternateSelectedControlColor];
|
||||
else if(!listView->enabled(true)) backgroundColor = [NSColor controlBackgroundColor];
|
||||
else if(auto color = listViewCell->state.backgroundColor) backgroundColor = NSMakeColor(color);
|
||||
else if(!tableView->enabled(true)) backgroundColor = [NSColor controlBackgroundColor];
|
||||
else if(auto color = tableViewCell->state.backgroundColor) backgroundColor = NSMakeColor(color);
|
||||
else backgroundColor = [NSColor controlBackgroundColor];
|
||||
|
||||
[backgroundColor set];
|
||||
[NSBezierPath fillRect:frame];
|
||||
|
||||
if(listViewCell->state.checkable) {
|
||||
if(tableViewCell->state.checkable) {
|
||||
[buttonCell setHighlighted:YES];
|
||||
[buttonCell setState:(listViewCell->state.checked ? NSOnState : NSOffState)];
|
||||
[buttonCell setState:(tableViewCell->state.checked ? NSOnState : NSOffState)];
|
||||
[buttonCell drawWithFrame:frame inView:view];
|
||||
frame.origin.x += frame.size.height + 2;
|
||||
frame.size.width -= frame.size.height + 2;
|
||||
}
|
||||
|
||||
if(listViewCell->state.icon) {
|
||||
NSImage* image = NSMakeImage(listViewCell->state.icon, frame.size.height, frame.size.height);
|
||||
if(tableViewCell->state.icon) {
|
||||
NSImage* image = NSMakeImage(tableViewCell->state.icon, frame.size.height, frame.size.height);
|
||||
[[NSGraphicsContext currentContext] saveGraphicsState];
|
||||
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);
|
||||
@ -189,21 +189,21 @@
|
||||
frame.size.width -= frame.size.height + 2;
|
||||
}
|
||||
|
||||
if(listViewCell->state.text) {
|
||||
if(tableViewCell->state.text) {
|
||||
NSMutableParagraphStyle* paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
|
||||
paragraphStyle.alignment = NSTextAlignmentCenter;
|
||||
if(listViewCell->state.alignment.horizontal() < 0.333) paragraphStyle.alignment = NSTextAlignmentLeft;
|
||||
if(listViewCell->state.alignment.horizontal() > 0.666) paragraphStyle.alignment = NSTextAlignmentRight;
|
||||
if(tableViewCell->state.alignment.horizontal() < 0.333) paragraphStyle.alignment = NSTextAlignmentLeft;
|
||||
if(tableViewCell->state.alignment.horizontal() > 0.666) paragraphStyle.alignment = NSTextAlignmentRight;
|
||||
NSColor* foregroundColor = nil;
|
||||
if([self isHighlighted]) foregroundColor = [NSColor alternateSelectedControlTextColor];
|
||||
else if(!listView->enabled(true)) foregroundColor = [NSColor disabledControlTextColor];
|
||||
else if(auto color = listViewCell->state.foregroundColor) foregroundColor = NSMakeColor(color);
|
||||
else if(!tableView->enabled(true)) foregroundColor = [NSColor disabledControlTextColor];
|
||||
else if(auto color = tableViewCell->state.foregroundColor) foregroundColor = NSMakeColor(color);
|
||||
else foregroundColor = [NSColor textColor];
|
||||
NSString* text = [NSString stringWithUTF8String:listViewCell->state.text];
|
||||
NSString* text = [NSString stringWithUTF8String:tableViewCell->state.text];
|
||||
[text drawInRect:frame withAttributes:@{
|
||||
NSBackgroundColorAttributeName:backgroundColor,
|
||||
NSForegroundColorAttributeName:foregroundColor,
|
||||
NSFontAttributeName:hiro::pFont::create(listViewCell->font(true)),
|
||||
NSFontAttributeName:hiro::pFont::create(tableViewCell->font(true)),
|
||||
NSParagraphStyleAttributeName:paragraphStyle
|
||||
}];
|
||||
}
|
||||
@ -233,10 +233,10 @@
|
||||
NSPoint point = [view convertPointFromBase:[nextEvent locationInWindow]];
|
||||
NSRect rect = NSMakeRect(frame.origin.x, frame.origin.y, frame.size.height, frame.size.height);
|
||||
if(NSMouseInRect(point, rect, [view isFlipped])) {
|
||||
if(auto listViewItem = listView->item([view rowAtPoint:point])) {
|
||||
if(auto listViewCell = listViewItem->cell([view columnAtPoint:point])) {
|
||||
listViewCell->state.checked = !listViewCell->state.checked;
|
||||
listView->doToggle(listViewCell->instance);
|
||||
if(auto tableViewItem = tableView->item([view rowAtPoint:point])) {
|
||||
if(auto tableViewCell = tableViewItem->cell([view columnAtPoint:point])) {
|
||||
tableViewCell->state.checked = !tableViewCell->state.checked;
|
||||
tableView->doToggle(tableViewCell->instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -255,9 +255,9 @@
|
||||
|
||||
namespace hiro {
|
||||
|
||||
auto pListView::construct() -> void {
|
||||
auto pTableView::construct() -> void {
|
||||
@autoreleasepool {
|
||||
cocoaView = cocoaListView = [[CocoaListView alloc] initWith:self()];
|
||||
cocoaView = cocoaTableView = [[CocoaTableView alloc] initWith:self()];
|
||||
pWidget::construct();
|
||||
|
||||
setAlignment(state().alignment);
|
||||
@ -269,14 +269,14 @@ auto pListView::construct() -> void {
|
||||
}
|
||||
}
|
||||
|
||||
auto pListView::destruct() -> void {
|
||||
auto pTableView::destruct() -> void {
|
||||
@autoreleasepool {
|
||||
[cocoaView removeFromSuperview];
|
||||
[cocoaView release];
|
||||
}
|
||||
}
|
||||
|
||||
auto pListView::append(sListViewHeader header) -> void {
|
||||
auto pTableView::append(sTableViewHeader header) -> void {
|
||||
@autoreleasepool {
|
||||
[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 {
|
||||
[[cocoaView content] reloadData];
|
||||
}
|
||||
}
|
||||
|
||||
auto pListView::remove(sListViewHeader header) -> void {
|
||||
auto pTableView::remove(sTableViewHeader header) -> void {
|
||||
@autoreleasepool {
|
||||
[cocoaView reloadColumns];
|
||||
}
|
||||
}
|
||||
|
||||
auto pListView::remove(sListViewItem item) -> void {
|
||||
auto pTableView::remove(sTableViewItem item) -> void {
|
||||
@autoreleasepool {
|
||||
[[cocoaView content] reloadData];
|
||||
}
|
||||
}
|
||||
|
||||
auto pListView::resizeColumns() -> void {
|
||||
auto pTableView::resizeColumns() -> void {
|
||||
@autoreleasepool {
|
||||
if(auto& header = state().header) {
|
||||
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 {
|
||||
[[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);
|
||||
@autoreleasepool {
|
||||
[[cocoaView content] setEnabled:enabled];
|
||||
}
|
||||
}
|
||||
|
||||
auto pListView::setFont(const Font& font) -> void {
|
||||
auto pTableView::setFont(const Font& font) -> void {
|
||||
@autoreleasepool {
|
||||
[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;
|
||||
if(auto pListViewItem = self().item(row)) {
|
||||
if(auto pListViewCell = pListViewItem->cell(column)) {
|
||||
if(pListViewCell->state.checkable) {
|
||||
if(auto pTableViewItem = self().item(row)) {
|
||||
if(auto pTableViewCell = pTableViewItem->cell(column)) {
|
||||
if(pTableViewCell->state.checkable) {
|
||||
width += 24;
|
||||
}
|
||||
if(auto& icon = pListViewCell->state.icon) {
|
||||
if(auto& icon = pTableViewCell->state.icon) {
|
||||
width += icon.width() + 2;
|
||||
}
|
||||
if(auto& text = pListViewCell->state.text) {
|
||||
width += pFont::size(pListViewCell->font(true), text).width();
|
||||
if(auto& text = pTableViewCell->state.text) {
|
||||
width += pFont::size(pTableViewCell->font(true), text).width();
|
||||
}
|
||||
}
|
||||
}
|
||||
return width;
|
||||
}
|
||||
|
||||
auto pListView::_columnWidth(uint column) -> uint {
|
||||
auto pTableView::_columnWidth(uint column) -> uint {
|
||||
uint width = 8;
|
||||
if(auto& header = state().header) {
|
||||
if(auto pListViewColumn = header->column(column)) {
|
||||
if(auto& icon = pListViewColumn->state.icon) {
|
||||
if(auto pTableViewColumn = header->column(column)) {
|
||||
if(auto& icon = pTableViewColumn->state.icon) {
|
||||
width += icon.width() + 2;
|
||||
}
|
||||
if(auto& text = pListViewColumn->state.text) {
|
||||
width += pFont::size(pListViewColumn->font(true), text).width();
|
||||
if(auto& text = pTableViewColumn->state.text) {
|
||||
width += pFont::size(pTableViewColumn->font(true), text).width();
|
||||
}
|
||||
}
|
||||
}
|
||||
return width;
|
||||
}
|
||||
|
||||
auto pListView::_width(uint column) -> uint {
|
||||
auto pTableView::_width(uint column) -> uint {
|
||||
if(auto& header = state().header) {
|
||||
if(auto width = header->column(column).width()) return width;
|
||||
uint width = 1;
|
||||
@ -412,20 +412,20 @@ auto pListView::_width(uint column) -> uint {
|
||||
}
|
||||
|
||||
/*
|
||||
auto pListView::autoSizeColumns() -> void {
|
||||
auto pTableView::autoSizeColumns() -> void {
|
||||
@autoreleasepool {
|
||||
if(listView.state.checkable) {
|
||||
if(tableView.state.checkable) {
|
||||
NSTableColumn* tableColumn = [[cocoaView content] tableColumnWithIdentifier:@"check"];
|
||||
[tableColumn setWidth:20.0];
|
||||
}
|
||||
|
||||
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]];
|
||||
unsigned minimumWidth = pFont::size([[tableColumn headerCell] font], listView.state.headerText(column)).width + 4;
|
||||
for(unsigned row = 0; row < listView.state.text.size(); row++) {
|
||||
unsigned width = pFont::size([cocoaView font], listView.state.text(row)(column)).width + 2;
|
||||
if(listView.state.image(row)(height).empty() == false) width += height + 2;
|
||||
unsigned minimumWidth = pFont::size([[tableColumn headerCell] font], tableView.state.headerText(column)).width + 4;
|
||||
for(unsigned row = 0; row < tableView.state.text.size(); row++) {
|
||||
unsigned width = pFont::size([cocoaView font], tableView.state.text(row)(column)).width + 2;
|
||||
if(tableView.state.image(row)(height).empty() == false) width += height + 2;
|
||||
if(width > minimumWidth) minimumWidth = width;
|
||||
}
|
||||
[tableColumn setWidth:minimumWidth];
|
||||
@ -435,7 +435,7 @@ auto pListView::autoSizeColumns() -> void {
|
||||
}
|
||||
}
|
||||
|
||||
auto pListView::setSelected(bool selected) -> void {
|
||||
auto pTableView::setSelected(bool selected) -> void {
|
||||
@autoreleasepool {
|
||||
if(selected == false) {
|
||||
[[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 {
|
||||
[[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
|
||||
hiro::mListView* listView;
|
||||
CocoaListViewContent* content;
|
||||
hiro::mTableView* tableView;
|
||||
CocoaTableViewContent* content;
|
||||
NSFont* font;
|
||||
}
|
||||
-(id) initWith:(hiro::mListView&)listView;
|
||||
-(id) initWith:(hiro::mTableView&)tableView;
|
||||
-(void) dealloc;
|
||||
-(CocoaListViewContent*) content;
|
||||
-(CocoaTableViewContent*) content;
|
||||
-(NSFont*) font;
|
||||
-(void) setFont:(NSFont*)font;
|
||||
-(void) reloadColumns;
|
||||
@ -24,16 +24,16 @@
|
||||
-(IBAction) doubleAction:(id)sender;
|
||||
@end
|
||||
|
||||
@interface CocoaListViewContent : NSTableView {
|
||||
@interface CocoaTableViewContent : NSTableView {
|
||||
}
|
||||
-(void) keyDown:(NSEvent*)event;
|
||||
@end
|
||||
|
||||
@interface CocoaListViewCell : NSCell {
|
||||
hiro::mListView* listView;
|
||||
@interface CocoaTableViewCell : NSCell {
|
||||
hiro::mTableView* tableView;
|
||||
NSButtonCell* buttonCell;
|
||||
}
|
||||
-(id) initWith:(hiro::mListView&)listViewReference;
|
||||
-(id) initWith:(hiro::mTableView&)tableViewReference;
|
||||
-(NSString*) stringValue;
|
||||
-(void) drawWithFrame:(NSRect)frame inView:(NSView*)view;
|
||||
-(NSUInteger) hitTestForEvent:(NSEvent*)event inRect:(NSRect)frame ofView:(NSView*)view;
|
||||
@ -43,13 +43,13 @@
|
||||
|
||||
namespace hiro {
|
||||
|
||||
struct pListView : pWidget {
|
||||
Declare(ListView, Widget)
|
||||
struct pTableView : pWidget {
|
||||
Declare(TableView, Widget)
|
||||
|
||||
auto append(sListViewHeader header) -> void;
|
||||
auto append(sListViewItem item) -> void;
|
||||
auto remove(sListViewHeader header) -> void;
|
||||
auto remove(sListViewItem item) -> void;
|
||||
auto append(sTableViewHeader header) -> void;
|
||||
auto append(sTableViewItem item) -> void;
|
||||
auto remove(sTableViewHeader header) -> void;
|
||||
auto remove(sTableViewItem item) -> void;
|
||||
auto resizeColumns() -> void;
|
||||
auto setAlignment(Alignment alignment) -> void;
|
||||
auto setBackgroundColor(Color color) -> void;
|
||||
@ -63,7 +63,7 @@ struct pListView : pWidget {
|
||||
auto _columnWidth(uint column) -> uint;
|
||||
auto _width(uint column) -> uint;
|
||||
|
||||
CocoaListView* cocoaListView = nullptr;
|
||||
CocoaTableView* cocoaTableView = nullptr;
|
||||
};
|
||||
|
||||
}
|
@ -24,7 +24,7 @@
|
||||
|
||||
-(BOOL) performDragOperation:(id<NSDraggingInfo>)sender {
|
||||
lstring paths = DropPaths(sender);
|
||||
if(paths.empty()) return NO;
|
||||
if(!paths) return NO;
|
||||
viewport->doDrop(paths);
|
||||
return YES;
|
||||
}
|
||||
|
@ -122,7 +122,7 @@
|
||||
|
||||
-(BOOL) performDragOperation:(id<NSDraggingInfo>)sender {
|
||||
lstring paths = DropPaths(sender);
|
||||
if(paths.empty()) return NO;
|
||||
if(!paths) return NO;
|
||||
window->doDrop(paths);
|
||||
return YES;
|
||||
}
|
||||
|
@ -62,12 +62,12 @@
|
||||
#define Hiro_IconView
|
||||
#define Hiro_Label
|
||||
#define Hiro_LineEdit
|
||||
#define Hiro_ListView
|
||||
#define Hiro_ProgressBar
|
||||
#define Hiro_RadioButton
|
||||
#define Hiro_RadioLabel
|
||||
#define Hiro_SourceEdit
|
||||
#define Hiro_TabFrame
|
||||
#define Hiro_TableView
|
||||
#define Hiro_TextEdit
|
||||
#define Hiro_TreeView
|
||||
#define Hiro_VerticalScrollBar
|
||||
@ -89,10 +89,14 @@
|
||||
#undef Hiro_HexEdit
|
||||
#endif
|
||||
|
||||
#if defined(Hiro_TableView)
|
||||
#define Hiro_ListView
|
||||
#endif
|
||||
|
||||
#if defined(Hiro_Button) && defined(Hiro_Canvas) && defined(Hiro_Label)
|
||||
#define Hiro_MessageDialog
|
||||
#endif
|
||||
|
||||
#if defined(Hiro_Button) && defined(Hiro_ComboButton) && defined(Hiro_LineEdit) && defined(Hiro_ListView) && defined(Hiro_MessageDialog)
|
||||
#if defined(Hiro_Button) && defined(Hiro_ComboButton) && defined(Hiro_LineEdit) && defined(Hiro_TableView) && defined(Hiro_MessageDialog)
|
||||
#define Hiro_BrowserDialog
|
||||
#endif
|
||||
|
@ -86,17 +86,17 @@ namespace hiro {
|
||||
#include "widget/icon-view-item.cpp"
|
||||
#include "widget/label.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/radio-button.cpp"
|
||||
#include "widget/radio-label.cpp"
|
||||
#include "widget/source-edit.cpp"
|
||||
#include "widget/tab-frame.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/tree-view.cpp"
|
||||
#include "widget/tree-view-item.cpp"
|
||||
|
@ -67,17 +67,17 @@ Declare(IconView)
|
||||
Declare(IconViewItem)
|
||||
Declare(Label)
|
||||
Declare(LineEdit)
|
||||
Declare(ListView)
|
||||
Declare(ListViewHeader)
|
||||
Declare(ListViewColumn)
|
||||
Declare(ListViewItem)
|
||||
Declare(ListViewCell)
|
||||
Declare(ProgressBar)
|
||||
Declare(RadioButton)
|
||||
Declare(RadioLabel)
|
||||
Declare(SourceEdit)
|
||||
Declare(TabFrame)
|
||||
Declare(TabFrameItem)
|
||||
Declare(TableView)
|
||||
Declare(TableViewHeader)
|
||||
Declare(TableViewColumn)
|
||||
Declare(TableViewItem)
|
||||
Declare(TableViewCell)
|
||||
Declare(TextEdit)
|
||||
Declare(TreeView)
|
||||
Declare(TreeViewItem)
|
||||
@ -575,15 +575,15 @@ struct mObject {
|
||||
auto parentFrame(bool recursive = false) const -> mFrame*;
|
||||
auto parentIconView(bool recursive = false) const -> mIconView*;
|
||||
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 parentMenuBar(bool recursive = false) const -> mMenuBar*;
|
||||
auto parentPopupMenu(bool recursive = false) const -> mPopupMenu*;
|
||||
auto parentSizable(bool recursive = false) const -> mSizable*;
|
||||
auto parentTabFrame(bool recursive = false) const -> mTabFrame*;
|
||||
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 parentTreeViewItem(bool recursive = false) const -> mTreeViewItem*;
|
||||
auto parentWidget(bool recursive = false) const -> mWidget*;
|
||||
@ -1356,205 +1356,6 @@ struct mLineEdit : mWidget {
|
||||
};
|
||||
#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)
|
||||
struct mProgressBar : mWidget {
|
||||
Declare(ProgressBar)
|
||||
@ -1718,6 +1519,207 @@ struct mTabFrameItem : mObject {
|
||||
};
|
||||
#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)
|
||||
struct mTextEdit : mWidget {
|
||||
Declare(TextEdit)
|
||||
|
@ -130,36 +130,6 @@ auto mObject::parentLayout(bool recursive) const -> mLayout* {
|
||||
}
|
||||
#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)
|
||||
auto mObject::parentMenu(bool recursive) const -> mMenu* {
|
||||
if(auto menu = dynamic_cast<mMenu*>(parent())) return menu;
|
||||
@ -220,6 +190,36 @@ auto mObject::parentTabFrameItem(bool recursive) const -> mTabFrameItem* {
|
||||
}
|
||||
#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)
|
||||
auto mObject::parentTreeView(bool recursive) const -> mTreeView* {
|
||||
if(auto treeView = dynamic_cast<mTreeView*>(parent())) return treeView;
|
||||
|
@ -485,136 +485,6 @@ struct LineEdit : sLineEdit {
|
||||
};
|
||||
#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)
|
||||
struct ProgressBar : sProgressBar {
|
||||
DeclareSharedWidget(ProgressBar)
|
||||
@ -722,6 +592,138 @@ struct TabFrame : sTabFrame {
|
||||
};
|
||||
#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)
|
||||
struct TextEdit : sTextEdit {
|
||||
DeclareSharedWidget(TextEdit)
|
||||
|
@ -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
|
@ -1,17 +1,17 @@
|
||||
#if defined(Hiro_ListView)
|
||||
#if defined(Hiro_TableView)
|
||||
|
||||
auto mListViewCell::allocate() -> pObject* {
|
||||
return new pListViewCell(*this);
|
||||
auto mTableViewCell::allocate() -> pObject* {
|
||||
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(recursive) {
|
||||
if(auto parent = parentListViewItem()) {
|
||||
if(auto parent = parentTableViewItem()) {
|
||||
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(offset() < header->columnCount()) {
|
||||
if(auto column = header->state.columns[offset()]) {
|
||||
@ -26,12 +26,12 @@ auto mListViewCell::alignment(bool recursive) const -> Alignment {
|
||||
return {};
|
||||
}
|
||||
|
||||
auto mListViewCell::backgroundColor(bool recursive) const -> Color {
|
||||
auto mTableViewCell::backgroundColor(bool recursive) const -> Color {
|
||||
if(auto color = state.backgroundColor) return color;
|
||||
if(recursive) {
|
||||
if(auto parent = parentListViewItem()) {
|
||||
if(auto parent = parentTableViewItem()) {
|
||||
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(offset() < header->columnCount()) {
|
||||
if(auto column = header->state.columns[offset()]) {
|
||||
@ -46,20 +46,20 @@ auto mListViewCell::backgroundColor(bool recursive) const -> Color {
|
||||
return {};
|
||||
}
|
||||
|
||||
auto mListViewCell::checkable() const -> bool {
|
||||
auto mTableViewCell::checkable() const -> bool {
|
||||
return state.checkable;
|
||||
}
|
||||
|
||||
auto mListViewCell::checked() const -> bool {
|
||||
auto mTableViewCell::checked() const -> bool {
|
||||
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(recursive) {
|
||||
if(auto parent = parentListViewItem()) {
|
||||
if(auto parent = parentTableViewItem()) {
|
||||
if(auto font = parent->font()) return font;
|
||||
if(auto grandparent = parent->parentListView()) {
|
||||
if(auto grandparent = parent->parentTableView()) {
|
||||
if(auto header = grandparent->state.header) {
|
||||
if(offset() < header->columnCount()) {
|
||||
if(auto column = header->state.columns[offset()]) {
|
||||
@ -74,12 +74,12 @@ auto mListViewCell::font(bool recursive) const -> Font {
|
||||
return {};
|
||||
}
|
||||
|
||||
auto mListViewCell::foregroundColor(bool recursive) const -> Color {
|
||||
auto mTableViewCell::foregroundColor(bool recursive) const -> Color {
|
||||
if(auto color = state.foregroundColor) return color;
|
||||
if(recursive) {
|
||||
if(auto parent = parentListViewItem()) {
|
||||
if(auto parent = parentTableViewItem()) {
|
||||
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(offset() < header->columnCount()) {
|
||||
if(auto column = header->state.columns[offset()]) {
|
||||
@ -94,54 +94,54 @@ auto mListViewCell::foregroundColor(bool recursive) const -> Color {
|
||||
return state.foregroundColor;
|
||||
}
|
||||
|
||||
auto mListViewCell::icon() const -> image {
|
||||
auto mTableViewCell::icon() const -> image {
|
||||
return state.icon;
|
||||
}
|
||||
|
||||
auto mListViewCell::setAlignment(Alignment alignment) -> type& {
|
||||
auto mTableViewCell::setAlignment(Alignment alignment) -> type& {
|
||||
state.alignment = alignment;
|
||||
signal(setAlignment, alignment);
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mListViewCell::setBackgroundColor(Color color) -> type& {
|
||||
auto mTableViewCell::setBackgroundColor(Color color) -> type& {
|
||||
state.backgroundColor = color;
|
||||
signal(setBackgroundColor, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mListViewCell::setCheckable(bool checkable) -> type& {
|
||||
auto mTableViewCell::setCheckable(bool checkable) -> type& {
|
||||
state.checkable = checkable;
|
||||
signal(setCheckable, checkable);
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mListViewCell::setChecked(bool checked) -> type& {
|
||||
auto mTableViewCell::setChecked(bool checked) -> type& {
|
||||
setCheckable(true);
|
||||
state.checked = checked;
|
||||
signal(setChecked, checked);
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mListViewCell::setForegroundColor(Color color) -> type& {
|
||||
auto mTableViewCell::setForegroundColor(Color color) -> type& {
|
||||
state.foregroundColor = color;
|
||||
signal(setForegroundColor, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mListViewCell::setIcon(const image& icon) -> type& {
|
||||
auto mTableViewCell::setIcon(const image& icon) -> type& {
|
||||
state.icon = icon;
|
||||
signal(setIcon, icon);
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mListViewCell::setText(const string& text) -> type& {
|
||||
auto mTableViewCell::setText(const string& text) -> type& {
|
||||
state.text = text;
|
||||
signal(setText, text);
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mListViewCell::text() const -> string {
|
||||
auto mTableViewCell::text() const -> string {
|
||||
return state.text;
|
||||
}
|
||||
|
153
hiro/core/widget/table-view-column.cpp
Normal file
153
hiro/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
hiro/core/widget/table-view-header.cpp
Normal file
58
hiro/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
hiro/core/widget/table-view-item.cpp
Normal file
103
hiro/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* {
|
||||
return new pListView(*this);
|
||||
auto mTableView::allocate() -> pObject* {
|
||||
return new pTableView(*this);
|
||||
}
|
||||
|
||||
auto mListView::destruct() -> void {
|
||||
auto mTableView::destruct() -> void {
|
||||
for(auto& item : state.items) item->destruct();
|
||||
if(auto& header = state.header) header->destruct();
|
||||
mWidget::destruct();
|
||||
@ -12,11 +12,11 @@ auto mListView::destruct() -> void {
|
||||
|
||||
//
|
||||
|
||||
auto mListView::alignment() const -> Alignment {
|
||||
auto mTableView::alignment() const -> Alignment {
|
||||
return state.alignment;
|
||||
}
|
||||
|
||||
auto mListView::append(sListViewHeader header) -> type& {
|
||||
auto mTableView::append(sTableViewHeader header) -> type& {
|
||||
if(auto& header = state.header) remove(header);
|
||||
state.header = header;
|
||||
header->setParent(this, 0);
|
||||
@ -24,118 +24,118 @@ auto mListView::append(sListViewHeader header) -> type& {
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mListView::append(sListViewItem item) -> type& {
|
||||
auto mTableView::append(sTableViewItem item) -> type& {
|
||||
state.items.append(item);
|
||||
item->setParent(this, itemCount() - 1);
|
||||
signal(append, item);
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mListView::backgroundColor() const -> Color {
|
||||
auto mTableView::backgroundColor() const -> Color {
|
||||
return state.backgroundColor;
|
||||
}
|
||||
|
||||
auto mListView::batchable() const -> bool {
|
||||
auto mTableView::batchable() const -> bool {
|
||||
return state.batchable;
|
||||
}
|
||||
|
||||
auto mListView::batched() const -> vector<ListViewItem> {
|
||||
vector<ListViewItem> items;
|
||||
auto mTableView::batched() const -> vector<TableViewItem> {
|
||||
vector<TableViewItem> items;
|
||||
for(auto& item : state.items) {
|
||||
if(item->selected()) items.append(item);
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
auto mListView::bordered() const -> bool {
|
||||
auto mTableView::bordered() const -> bool {
|
||||
return state.bordered;
|
||||
}
|
||||
|
||||
auto mListView::doActivate() const -> void {
|
||||
auto mTableView::doActivate() const -> void {
|
||||
if(state.onActivate) return state.onActivate();
|
||||
}
|
||||
|
||||
auto mListView::doChange() const -> void {
|
||||
auto mTableView::doChange() const -> void {
|
||||
if(state.onChange) return state.onChange();
|
||||
}
|
||||
|
||||
auto mListView::doContext() const -> void {
|
||||
auto mTableView::doContext() const -> void {
|
||||
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);
|
||||
}
|
||||
|
||||
auto mListView::doSort(sListViewColumn column) const -> void {
|
||||
auto mTableView::doSort(sTableViewColumn column) const -> void {
|
||||
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);
|
||||
}
|
||||
|
||||
auto mListView::foregroundColor() const -> Color {
|
||||
auto mTableView::foregroundColor() const -> Color {
|
||||
return state.foregroundColor;
|
||||
}
|
||||
|
||||
auto mListView::header() const -> ListViewHeader {
|
||||
auto mTableView::header() const -> TableViewHeader {
|
||||
return state.header;
|
||||
}
|
||||
|
||||
auto mListView::item(unsigned position) const -> ListViewItem {
|
||||
auto mTableView::item(unsigned position) const -> TableViewItem {
|
||||
if(position < itemCount()) return state.items[position];
|
||||
return {};
|
||||
}
|
||||
|
||||
auto mListView::itemCount() const -> unsigned {
|
||||
auto mTableView::itemCount() const -> unsigned {
|
||||
return state.items.size();
|
||||
}
|
||||
|
||||
auto mListView::items() const -> vector<ListViewItem> {
|
||||
vector<ListViewItem> items;
|
||||
auto mTableView::items() const -> vector<TableViewItem> {
|
||||
vector<TableViewItem> items;
|
||||
for(auto& item : state.items) items.append(item);
|
||||
return items;
|
||||
}
|
||||
|
||||
auto mListView::onActivate(const function<void ()>& callback) -> type& {
|
||||
auto mTableView::onActivate(const function<void ()>& callback) -> type& {
|
||||
state.onActivate = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mListView::onChange(const function<void ()>& callback) -> type& {
|
||||
auto mTableView::onChange(const function<void ()>& callback) -> type& {
|
||||
state.onChange = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mListView::onContext(const function<void ()>& callback) -> type& {
|
||||
auto mTableView::onContext(const function<void ()>& callback) -> type& {
|
||||
state.onContext = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mListView::onEdit(const function<void (ListViewCell)>& callback) -> type& {
|
||||
auto mTableView::onEdit(const function<void (TableViewCell)>& callback) -> type& {
|
||||
state.onEdit = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mListView::onSort(const function<void (ListViewColumn)>& callback) -> type& {
|
||||
auto mTableView::onSort(const function<void (TableViewColumn)>& callback) -> type& {
|
||||
state.onSort = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mListView::onToggle(const function<void (ListViewCell)>& callback) -> type& {
|
||||
auto mTableView::onToggle(const function<void (TableViewCell)>& callback) -> type& {
|
||||
state.onToggle = callback;
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mListView::remove(sListViewHeader header) -> type& {
|
||||
auto mTableView::remove(sTableViewHeader header) -> type& {
|
||||
signal(remove, header);
|
||||
header->setParent();
|
||||
state.header.reset();
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mListView::remove(sListViewItem item) -> type& {
|
||||
auto mTableView::remove(sTableViewItem item) -> type& {
|
||||
signal(remove, item);
|
||||
state.items.remove(item->offset());
|
||||
for(auto n : range(item->offset(), itemCount())) {
|
||||
@ -145,55 +145,55 @@ auto mListView::remove(sListViewItem item) -> type& {
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mListView::reset() -> type& {
|
||||
auto mTableView::reset() -> type& {
|
||||
for(auto n : rrange(state.items)) remove(state.items[n]);
|
||||
if(auto& header = state.header) remove(header);
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mListView::resizeColumns() -> type& {
|
||||
auto mTableView::resizeColumns() -> type& {
|
||||
signal(resizeColumns);
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mListView::selected() const -> ListViewItem {
|
||||
auto mTableView::selected() const -> TableViewItem {
|
||||
for(auto& item : state.items) {
|
||||
if(item->selected()) return item;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
auto mListView::setAlignment(Alignment alignment) -> type& {
|
||||
auto mTableView::setAlignment(Alignment alignment) -> type& {
|
||||
state.alignment = alignment;
|
||||
signal(setAlignment, alignment);
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mListView::setBackgroundColor(Color color) -> type& {
|
||||
auto mTableView::setBackgroundColor(Color color) -> type& {
|
||||
state.backgroundColor = color;
|
||||
signal(setBackgroundColor, color);
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mListView::setBatchable(bool batchable) -> type& {
|
||||
auto mTableView::setBatchable(bool batchable) -> type& {
|
||||
state.batchable = batchable;
|
||||
signal(setBatchable, batchable);
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mListView::setBordered(bool bordered) -> type& {
|
||||
auto mTableView::setBordered(bool bordered) -> type& {
|
||||
state.bordered = bordered;
|
||||
signal(setBordered, bordered);
|
||||
return *this;
|
||||
}
|
||||
|
||||
auto mListView::setForegroundColor(Color color) -> type& {
|
||||
auto mTableView::setForegroundColor(Color color) -> type& {
|
||||
state.foregroundColor = color;
|
||||
signal(setForegroundColor, color);
|
||||
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();
|
||||
if(auto& header = state.header) header->destruct();
|
||||
mObject::setParent(parent, offset);
|
@ -18,7 +18,7 @@ private:
|
||||
Button pathRefresh{&pathLayout, Size{0, 0}, 0};
|
||||
Button pathHome{&pathLayout, Size{0, 0}, 0};
|
||||
Button pathUp{&pathLayout, Size{0, 0}, 0};
|
||||
ListView view{&layout, Size{~0, ~0}, 5};
|
||||
TableView view{&layout, Size{~0, ~0}, 5};
|
||||
HorizontalLayout controlLayout{&layout, Size{~0, 0}};
|
||||
ComboButton filterList{&controlLayout, Size{120, 0}, 5};
|
||||
LineEdit fileName{&controlLayout, Size{~0, 0}, 5};
|
||||
@ -30,7 +30,7 @@ private:
|
||||
};
|
||||
|
||||
//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 batched = view.batched();
|
||||
|
||||
@ -71,7 +71,7 @@ auto BrowserDialogWindow::accept() -> void {
|
||||
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 selectedItem = view.selected();
|
||||
|
||||
@ -89,7 +89,7 @@ auto BrowserDialogWindow::activate() -> void {
|
||||
accept();
|
||||
}
|
||||
|
||||
//list view item changed
|
||||
//table view item changed
|
||||
auto BrowserDialogWindow::change() -> void {
|
||||
fileName.setText("");
|
||||
if(state.action == "saveFile") {
|
||||
@ -162,8 +162,8 @@ auto BrowserDialogWindow::setPath(string path) -> void {
|
||||
pathName.setText(state.path = path);
|
||||
|
||||
view.reset();
|
||||
view.append(ListViewHeader().setVisible(false)
|
||||
.append(ListViewColumn().setExpandable())
|
||||
view.append(TableViewHeader().setVisible(false)
|
||||
.append(TableViewColumn().setExpandable())
|
||||
);
|
||||
|
||||
auto contents = directory::icontents(path);
|
||||
@ -174,8 +174,8 @@ auto BrowserDialogWindow::setPath(string path) -> void {
|
||||
content.rtrim("/");
|
||||
if(folderMode && isMatch(content)) continue;
|
||||
|
||||
view.append(ListViewItem()
|
||||
.append(ListViewCell().setText(content).setIcon(Icon::Emblem::Folder))
|
||||
view.append(TableViewItem()
|
||||
.append(TableViewCell().setText(content).setIcon(Icon::Emblem::Folder))
|
||||
);
|
||||
}
|
||||
|
||||
@ -184,8 +184,8 @@ auto BrowserDialogWindow::setPath(string path) -> void {
|
||||
content.rtrim("/");
|
||||
if(!isMatch(content)) continue;
|
||||
|
||||
view.append(ListViewItem()
|
||||
.append(ListViewCell().setText(content).setIcon(folderMode ? Icon::Action::Open : Icon::Emblem::File))
|
||||
view.append(TableViewItem()
|
||||
.append(TableViewCell().setText(content).setIcon(folderMode ? Icon::Action::Open : Icon::Emblem::File))
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,8 @@ namespace hiro {
|
||||
#include "fixed-layout.cpp"
|
||||
#include "horizontal-layout.cpp"
|
||||
#include "vertical-layout.cpp"
|
||||
#include "list-view-item.cpp"
|
||||
#include "list-view.cpp"
|
||||
#include "browser-dialog.cpp"
|
||||
#include "message-dialog.cpp"
|
||||
}
|
||||
|
@ -3,6 +3,8 @@ namespace hiro {
|
||||
#include "fixed-layout.hpp"
|
||||
#include "horizontal-layout.hpp"
|
||||
#include "vertical-layout.hpp"
|
||||
#include "list-view-item.hpp"
|
||||
#include "list-view.hpp"
|
||||
#include "shared.hpp"
|
||||
#include "browser-dialog.hpp"
|
||||
#include "message-dialog.hpp"
|
||||
|
49
hiro/extension/list-view-item.cpp
Normal file
49
hiro/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
hiro/extension/list-view-item.hpp
Normal file
24
hiro/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
hiro/extension/list-view.cpp
Normal file
51
hiro/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
hiro/extension/list-view.hpp
Normal file
27
hiro/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; }
|
||||
};
|
||||
#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
|
||||
|
@ -44,17 +44,17 @@
|
||||
#include "widget/icon-view-item.cpp"
|
||||
#include "widget/label.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/radio-button.cpp"
|
||||
#include "widget/radio-label.cpp"
|
||||
#include "widget/source-edit.cpp"
|
||||
#include "widget/tab-frame.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/tree-view.cpp"
|
||||
#include "widget/tree-view-item.cpp"
|
||||
|
@ -55,17 +55,17 @@ namespace hiro {
|
||||
#include "widget/icon-view-item.hpp"
|
||||
#include "widget/label.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/radio-button.hpp"
|
||||
#include "widget/radio-label.hpp"
|
||||
#include "widget/source-edit.hpp"
|
||||
#include "widget/tab-frame.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/tree-view.hpp"
|
||||
#include "widget/tree-view-item.hpp"
|
||||
|
@ -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 {
|
||||
|
||||
auto pListViewCell::construct() -> void {
|
||||
auto pTableViewCell::construct() -> void {
|
||||
_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();
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
auto pListViewCell::setText(const string& text) -> void {
|
||||
auto pTableViewCell::setText(const string& text) -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
auto pListViewCell::_grandparent() -> maybe<pListView&> {
|
||||
auto pTableViewCell::_grandparent() -> maybe<pTableView&> {
|
||||
if(auto parent = _parent()) return parent->_parent();
|
||||
return nothing;
|
||||
}
|
||||
|
||||
auto pListViewCell::_parent() -> maybe<pListViewItem&> {
|
||||
if(auto parent = self().parentListViewItem()) {
|
||||
auto pTableViewCell::_parent() -> maybe<pTableViewItem&> {
|
||||
if(auto parent = self().parentTableViewItem()) {
|
||||
if(auto self = parent->self()) return *self;
|
||||
}
|
||||
return nothing;
|
||||
}
|
||||
|
||||
auto pListViewCell::_setState() -> void {
|
||||
auto pTableViewCell::_setState() -> void {
|
||||
if(auto parent = _parent()) {
|
||||
if(auto grandparent = _grandparent()) {
|
||||
grandparent->lock();
|
@ -1,9 +1,9 @@
|
||||
#if defined(Hiro_ListView)
|
||||
#if defined(Hiro_TableView)
|
||||
|
||||
namespace hiro {
|
||||
|
||||
struct pListViewCell : pObject {
|
||||
Declare(ListViewCell, Object)
|
||||
struct pTableViewCell : pObject {
|
||||
Declare(TableViewCell, Object)
|
||||
|
||||
auto setAlignment(Alignment alignment) -> void;
|
||||
auto setBackgroundColor(Color color) -> void;
|
||||
@ -13,8 +13,8 @@ struct pListViewCell : pObject {
|
||||
auto setIcon(const image& icon) -> void;
|
||||
auto setText(const string& text) -> void;
|
||||
|
||||
auto _grandparent() -> maybe<pListView&>;
|
||||
auto _parent() -> maybe<pListViewItem&>;
|
||||
auto _grandparent() -> maybe<pTableView&>;
|
||||
auto _parent() -> maybe<pTableViewItem&>;
|
||||
auto _setState() -> void;
|
||||
};
|
||||
|
@ -1,8 +1,8 @@
|
||||
#if defined(Hiro_ListView)
|
||||
#if defined(Hiro_TableView)
|
||||
|
||||
namespace hiro {
|
||||
|
||||
auto pListViewColumn::construct() -> void {
|
||||
auto pTableViewColumn::construct() -> void {
|
||||
if(auto grandparent = _grandparent()) {
|
||||
auto handle = grandparent.data();
|
||||
unsigned offset = self().offset();
|
||||
@ -23,21 +23,21 @@ auto pListViewColumn::construct() -> void {
|
||||
gtkCellToggle = gtk_cell_renderer_toggle_new();
|
||||
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_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();
|
||||
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_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();
|
||||
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_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(gtkCellText), "edited", G_CALLBACK(ListView_edit), (gpointer)handle);
|
||||
g_signal_connect(G_OBJECT(gtkCellToggle), "toggled", G_CALLBACK(ListView_toggle), (gpointer)handle);
|
||||
g_signal_connect(G_OBJECT(gtkColumn), "clicked", G_CALLBACK(TableView_headerActivate), (gpointer)handle);
|
||||
g_signal_connect(G_OBJECT(gtkCellText), "edited", G_CALLBACK(TableView_edit), (gpointer)handle);
|
||||
g_signal_connect(G_OBJECT(gtkCellToggle), "toggled", G_CALLBACK(TableView_toggle), (gpointer)handle);
|
||||
|
||||
gtk_tree_view_append_column(grandparent->gtkTreeView, gtkColumn);
|
||||
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()) {
|
||||
gtk_tree_view_remove_column(grandparent->gtkTreeView, gtkColumn);
|
||||
gtkColumn = nullptr;
|
||||
@ -55,33 +55,33 @@ auto pListViewColumn::destruct() -> void {
|
||||
}
|
||||
}
|
||||
|
||||
auto pListViewColumn::setActive() -> void {
|
||||
auto pTableViewColumn::setActive() -> void {
|
||||
_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);
|
||||
}
|
||||
|
||||
auto pListViewColumn::setExpandable(bool expandable) -> void {
|
||||
auto pTableViewColumn::setExpandable(bool expandable) -> void {
|
||||
if(auto grandparent = _grandparent()) {
|
||||
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) {
|
||||
gtk_image_set_from_pixbuf(GTK_IMAGE(gtkHeaderIcon), CreatePixbuf(icon));
|
||||
} 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();
|
||||
}
|
||||
|
||||
auto pListViewColumn::setSortable(bool sortable) -> void {
|
||||
auto pTableViewColumn::setSortable(bool sortable) -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
auto pListViewColumn::setText(const string& text) -> void {
|
||||
auto pTableViewColumn::setText(const string& text) -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
auto pListViewColumn::setVisible(bool visible) -> void {
|
||||
auto pTableViewColumn::setVisible(bool visible) -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
auto pListViewColumn::setWidth(signed width) -> void {
|
||||
auto pTableViewColumn::setWidth(signed width) -> void {
|
||||
if(auto grandparent = _grandparent()) {
|
||||
grandparent->resizeColumns();
|
||||
}
|
||||
}
|
||||
|
||||
auto pListViewColumn::_grandparent() -> maybe<pListView&> {
|
||||
auto pTableViewColumn::_grandparent() -> maybe<pTableView&> {
|
||||
if(auto parent = _parent()) return parent->_parent();
|
||||
return nothing;
|
||||
}
|
||||
|
||||
auto pListViewColumn::_parent() -> maybe<pListViewHeader&> {
|
||||
if(auto parent = self().parentListViewHeader()) {
|
||||
auto pTableViewColumn::_parent() -> maybe<pTableViewHeader&> {
|
||||
if(auto parent = self().parentTableViewHeader()) {
|
||||
if(auto self = parent->self()) return *self;
|
||||
}
|
||||
return nothing;
|
||||
}
|
||||
|
||||
auto pListViewColumn::_setState() -> void {
|
||||
auto pTableViewColumn::_setState() -> void {
|
||||
if(auto grandparent = _grandparent()) {
|
||||
gtk_tree_view_set_search_column(grandparent->gtkTreeView, 3 * self().offset() + 2);
|
||||
gtk_tree_view_column_set_resizable(gtkColumn, state().resizable);
|
@ -1,9 +1,9 @@
|
||||
#if defined(Hiro_ListView)
|
||||
#if defined(Hiro_TableView)
|
||||
|
||||
namespace hiro {
|
||||
|
||||
struct pListViewColumn : pObject {
|
||||
Declare(ListViewColumn, Object)
|
||||
struct pTableViewColumn : pObject {
|
||||
Declare(TableViewColumn, Object)
|
||||
|
||||
auto setActive() -> void;
|
||||
auto setAlignment(Alignment alignment) -> void;
|
||||
@ -21,8 +21,8 @@ struct pListViewColumn : pObject {
|
||||
auto setVisible(bool visible) -> void override;
|
||||
auto setWidth(signed width) -> void;
|
||||
|
||||
auto _grandparent() -> maybe<pListView&>;
|
||||
auto _parent() -> maybe<pListViewHeader&>;
|
||||
auto _grandparent() -> maybe<pTableView&>;
|
||||
auto _parent() -> maybe<pTableViewHeader&>;
|
||||
auto _setState() -> void;
|
||||
|
||||
GtkTreeViewColumn* gtkColumn = nullptr;
|
41
hiro/gtk/widget/table-view-header.cpp
Normal file
41
hiro/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
hiro/gtk/widget/table-view-header.hpp
Normal file
18
hiro/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 {
|
||||
|
||||
auto pListViewItem::construct() -> void {
|
||||
auto pTableViewItem::construct() -> void {
|
||||
if(auto parent = _parent()) {
|
||||
parent->lock();
|
||||
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()) {
|
||||
parent->lock();
|
||||
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()) {
|
||||
GtkTreePath* path = gtk_tree_path_new_from_string(string{self().offset()});
|
||||
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();
|
||||
}
|
||||
|
||||
auto pListViewItem::_parent() -> maybe<pListView&> {
|
||||
if(auto parent = self().parentListView()) {
|
||||
auto pTableViewItem::_parent() -> maybe<pTableView&> {
|
||||
if(auto parent = self().parentTableView()) {
|
||||
if(auto self = parent->self()) return *self;
|
||||
}
|
||||
return nothing;
|
||||
}
|
||||
|
||||
auto pListViewItem::_setState() -> void {
|
||||
auto pTableViewItem::_setState() -> void {
|
||||
if(auto parent = _parent()) {
|
||||
parent->lock();
|
||||
if(state().selected) {
|
@ -1,19 +1,19 @@
|
||||
#if defined(Hiro_ListView)
|
||||
#if defined(Hiro_TableView)
|
||||
|
||||
namespace hiro {
|
||||
|
||||
struct pListViewItem : pObject {
|
||||
Declare(ListViewItem, Object)
|
||||
struct pTableViewItem : pObject {
|
||||
Declare(TableViewItem, Object)
|
||||
|
||||
auto append(sListViewCell cell) -> void;
|
||||
auto remove(sListViewCell cell) -> void;
|
||||
auto append(sTableViewCell cell) -> void;
|
||||
auto remove(sTableViewCell cell) -> void;
|
||||
auto setAlignment(Alignment alignment) -> void;
|
||||
auto setBackgroundColor(Color color) -> void;
|
||||
auto setFocused() -> void;
|
||||
auto setForegroundColor(Color color) -> void;
|
||||
auto setSelected(bool selected) -> void;
|
||||
|
||||
auto _parent() -> maybe<pListView&>;
|
||||
auto _parent() -> maybe<pTableView&>;
|
||||
auto _setState() -> void;
|
||||
|
||||
GtkTreeIter gtkIter;
|
@ -1,21 +1,21 @@
|
||||
#if defined(Hiro_ListView)
|
||||
#if defined(Hiro_TableView)
|
||||
|
||||
namespace hiro {
|
||||
|
||||
static auto ListView_activate(GtkTreeView*, GtkTreePath*, GtkTreeViewColumn*, pListView* p) -> void { return p->_doActivate(); }
|
||||
static auto ListView_buttonEvent(GtkTreeView* treeView, GdkEventButton* event, pListView* p) -> signed { return p->_doEvent(event); }
|
||||
static auto ListView_change(GtkTreeSelection*, pListView* 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 ListView_headerActivate(GtkTreeViewColumn* column, pListView* p) -> void { return p->_doHeaderActivate(column); }
|
||||
static auto ListView_mouseMoveEvent(GtkWidget*, GdkEvent*, pListView* p) -> signed { return p->_doMouseMove(); }
|
||||
static auto ListView_popup(GtkTreeView*, pListView* p) -> void { return p->_doContext(); }
|
||||
static auto TableView_activate(GtkTreeView*, GtkTreePath*, GtkTreeViewColumn*, pTableView* p) -> void { return p->_doActivate(); }
|
||||
static auto TableView_buttonEvent(GtkTreeView* treeView, GdkEventButton* event, pTableView* p) -> signed { return p->_doEvent(event); }
|
||||
static auto TableView_change(GtkTreeSelection*, pTableView* p) -> void { return p->_doChange(); }
|
||||
static auto TableView_edit(GtkCellRendererText* renderer, const char* path, const char* text, pTableView* p) -> void { return p->_doEdit(renderer, path, text); }
|
||||
static auto TableView_headerActivate(GtkTreeViewColumn* column, pTableView* p) -> void { return p->_doHeaderActivate(column); }
|
||||
static auto TableView_mouseMoveEvent(GtkWidget*, GdkEvent*, pTableView* p) -> signed { return p->_doMouseMove(); }
|
||||
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 ListView_toggle(GtkCellRendererToggle* toggle, const char* path, pListView* p) -> void { return p->_doToggle(toggle, path); }
|
||||
static auto TableView_dataFunc(GtkTreeViewColumn* column, GtkCellRenderer* renderer, GtkTreeModel* model, GtkTreeIter* iter, pTableView* p) -> void { return p->_doDataFunc(column, renderer, iter); }
|
||||
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);
|
||||
|
||||
auto pListView::construct() -> void {
|
||||
auto pTableView::construct() -> void {
|
||||
gtkWidget = gtk_scrolled_window_new(0, 0);
|
||||
gtkScrolledWindow = GTK_SCROLLED_WINDOW(gtkWidget);
|
||||
gtk_scrolled_window_set_policy(gtkScrolledWindow, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
||||
@ -35,38 +35,38 @@ auto pListView::construct() -> void {
|
||||
setFont(self().font(true));
|
||||
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-release-event", G_CALLBACK(ListView_buttonEvent), (gpointer)this);
|
||||
g_signal_connect(G_OBJECT(gtkTreeView), "motion-notify-event", G_CALLBACK(ListView_mouseMoveEvent), (gpointer)this);
|
||||
g_signal_connect(G_OBJECT(gtkTreeView), "popup-menu", G_CALLBACK(ListView_popup), (gpointer)this);
|
||||
g_signal_connect(G_OBJECT(gtkTreeView), "row-activated", G_CALLBACK(ListView_activate), (gpointer)this);
|
||||
g_signal_connect(G_OBJECT(gtkTreeSelection), "changed", G_CALLBACK(ListView_change), (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(TableView_buttonEvent), (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(TableView_popup), (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(TableView_change), (gpointer)this);
|
||||
|
||||
pWidget::construct();
|
||||
}
|
||||
|
||||
auto pListView::destruct() -> void {
|
||||
auto pTableView::destruct() -> void {
|
||||
gtk_widget_destroy(gtkWidgetChild);
|
||||
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);
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
if(auto& header = state().header) {
|
||||
@ -102,23 +102,23 @@ auto pListView::resizeColumns() -> void {
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
auto pListView::setFocused() -> void {
|
||||
auto pTableView::setFocused() -> void {
|
||||
//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
|
||||
lock();
|
||||
@ -128,18 +128,18 @@ auto pListView::setFocused() -> void {
|
||||
unlock();
|
||||
}
|
||||
|
||||
auto pListView::setFont(const Font& font) -> void {
|
||||
auto pTableView::setFont(const Font& font) -> void {
|
||||
if(auto& header = state().header) {
|
||||
if(auto self = header->self()) self->_setState();
|
||||
}
|
||||
}
|
||||
|
||||
auto pListView::setForegroundColor(Color color) -> void {
|
||||
auto pTableView::setForegroundColor(Color color) -> void {
|
||||
GdkColor gdkColor = CreateColor(color);
|
||||
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);
|
||||
if(auto& header = state().header) {
|
||||
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;
|
||||
if(auto item = self().item(_row)) {
|
||||
if(auto cell = item->cell(_column)) {
|
||||
@ -166,7 +166,7 @@ auto pListView::_cellWidth(unsigned _row, unsigned _column) -> unsigned {
|
||||
return width;
|
||||
}
|
||||
|
||||
auto pListView::_columnWidth(unsigned _column) -> unsigned {
|
||||
auto pTableView::_columnWidth(unsigned _column) -> unsigned {
|
||||
unsigned width = 8;
|
||||
if(auto& header = state().header) {
|
||||
if(auto column = header->column(_column)) {
|
||||
@ -181,7 +181,7 @@ auto pListView::_columnWidth(unsigned _column) -> unsigned {
|
||||
return width;
|
||||
}
|
||||
|
||||
auto pListView::_createModel() -> void {
|
||||
auto pTableView::_createModel() -> void {
|
||||
gtk_tree_view_set_model(gtkTreeView, nullptr);
|
||||
gtkListStore = nullptr;
|
||||
gtkTreeModel = nullptr;
|
||||
@ -204,19 +204,19 @@ auto pListView::_createModel() -> void {
|
||||
gtk_tree_view_set_model(gtkTreeView, gtkTreeModel);
|
||||
}
|
||||
|
||||
auto pListView::_doActivate() -> void {
|
||||
auto pTableView::_doActivate() -> void {
|
||||
if(!locked()) self().doActivate();
|
||||
}
|
||||
|
||||
auto pListView::_doChange() -> void {
|
||||
auto pTableView::_doChange() -> void {
|
||||
if(!locked()) _updateSelected();
|
||||
}
|
||||
|
||||
auto pListView::_doContext() -> void {
|
||||
auto pTableView::_doContext() -> void {
|
||||
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 row = natural(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) {
|
||||
for(auto& column : header->state.columns) {
|
||||
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;
|
||||
gtk_tree_view_get_path_at_pos(gtkTreeView, event->x, event->y, &path, nullptr, nullptr, nullptr);
|
||||
|
||||
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)
|
||||
if(path == nullptr && gtk_tree_selection_count_selected_rows(gtkTreeSelection) > 0) {
|
||||
for(auto& item : state().items) item->setSelected(false);
|
||||
@ -316,7 +316,7 @@ auto pListView::_doEvent(GdkEventButton* event) -> signed {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto pListView::_doHeaderActivate(GtkTreeViewColumn* gtkTreeViewColumn) -> void {
|
||||
auto pTableView::_doHeaderActivate(GtkTreeViewColumn* gtkTreeViewColumn) -> void {
|
||||
if(auto& header = state().header) {
|
||||
for(auto& column : header->state.columns) {
|
||||
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
|
||||
//so here we capture motion-notify-event, and if the selections have changed, invoke ListView::onChange
|
||||
auto pListView::_doMouseMove() -> signed {
|
||||
//so here we capture motion-notify-event, and if the selections have changed, invoke TableView::onChange
|
||||
auto pTableView::_doMouseMove() -> signed {
|
||||
if(gtk_tree_view_is_rubber_banding_active(gtkTreeView)) {
|
||||
if(!locked()) _updateSelected();
|
||||
}
|
||||
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) {
|
||||
for(auto& column : header->state.columns) {
|
||||
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
|
||||
//this prevents firing an onChange event when the actual selection has not changed
|
||||
//this is particularly important for the motion-notify-event binding
|
||||
auto pListView::_updateSelected() -> void {
|
||||
auto pTableView::_updateSelected() -> void {
|
||||
vector<unsigned> selected;
|
||||
|
||||
GList* list = gtk_tree_selection_get_selected_rows(gtkTreeSelection, >kTreeModel);
|
||||
@ -402,7 +402,7 @@ auto pListView::_updateSelected() -> void {
|
||||
if(!locked()) self().doChange();
|
||||
}
|
||||
|
||||
auto pListView::_width(unsigned column) -> unsigned {
|
||||
auto pTableView::_width(unsigned column) -> unsigned {
|
||||
if(auto& header = state().header) {
|
||||
if(auto width = header->column(column).width()) return width;
|
||||
unsigned width = 1;
|
@ -1,15 +1,15 @@
|
||||
#if defined(Hiro_ListView)
|
||||
#if defined(Hiro_TableView)
|
||||
|
||||
namespace hiro {
|
||||
|
||||
struct pListView : pWidget {
|
||||
Declare(ListView, Widget)
|
||||
struct pTableView : pWidget {
|
||||
Declare(TableView, Widget)
|
||||
|
||||
auto append(sListViewHeader column) -> void;
|
||||
auto append(sListViewItem item) -> void;
|
||||
auto append(sTableViewHeader column) -> void;
|
||||
auto append(sTableViewItem item) -> void;
|
||||
auto focused() const -> bool override;
|
||||
auto remove(sListViewHeader column) -> void;
|
||||
auto remove(sListViewItem item) -> void;
|
||||
auto remove(sTableViewHeader column) -> void;
|
||||
auto remove(sTableViewItem item) -> void;
|
||||
auto resizeColumns() -> void;
|
||||
auto setAlignment(Alignment alignment) -> void;
|
||||
auto setBackgroundColor(Color color) -> void;
|
@ -47,16 +47,16 @@
|
||||
#include "widget/icon-view.cpp"
|
||||
#include "widget/label.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/radio-button.cpp"
|
||||
#include "widget/radio-label.cpp"
|
||||
#include "widget/tab-frame.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/vertical-scroll-bar.cpp"
|
||||
#include "widget/vertical-slider.cpp"
|
||||
|
@ -48,16 +48,16 @@
|
||||
#include "widget/horizontal-slider.hpp"
|
||||
#include "widget/label.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/radio-button.hpp"
|
||||
#include "widget/radio-label.hpp"
|
||||
#include "widget/tab-frame.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/vertical-scroll-bar.hpp"
|
||||
#include "widget/vertical-slider.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.
|
||||
|
||||
@ -194,30 +196,6 @@ public slots:
|
||||
};
|
||||
#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)
|
||||
struct QtRadioLabel : public QRadioButton {
|
||||
Q_OBJECT
|
||||
@ -252,6 +230,30 @@ public slots:
|
||||
};
|
||||
#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)
|
||||
struct QtTextEdit : public QTextEdit {
|
||||
Q_OBJECT
|
||||
|
168
hiro/qt/qt.moc
168
hiro/qt/qt.moc
@ -1031,90 +1031,6 @@ int hiro::QtLineEdit::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
|
||||
}
|
||||
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[] = {
|
||||
|
||||
// content:
|
||||
@ -1337,6 +1253,90 @@ int hiro::QtTabFrame::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
|
||||
}
|
||||
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[] = {
|
||||
|
||||
// content:
|
||||
|
@ -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 {
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
auto pListViewCell::setBackgroundColor(Color color) -> void {
|
||||
auto pTableViewCell::setBackgroundColor(Color color) -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
auto pListViewCell::setCheckable(bool checkable) -> void {
|
||||
auto pTableViewCell::setCheckable(bool checkable) -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
auto pListViewCell::setChecked(bool checked) -> void {
|
||||
auto pTableViewCell::setChecked(bool checked) -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
auto pListViewCell::setFont(const string& font) -> void {
|
||||
auto pTableViewCell::setFont(const string& font) -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
auto pListViewCell::setForegroundColor(Color color) -> void {
|
||||
auto pTableViewCell::setForegroundColor(Color color) -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
auto pListViewCell::setIcon(const image& icon) -> void {
|
||||
auto pTableViewCell::setIcon(const image& icon) -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
auto pListViewCell::setText(const string& text) -> void {
|
||||
auto pTableViewCell::setText(const string& text) -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
auto pListViewCell::_parent() -> maybe<pListViewItem&> {
|
||||
if(auto parent = self().parentListViewItem()) {
|
||||
auto pTableViewCell::_parent() -> maybe<pTableViewItem&> {
|
||||
if(auto parent = self().parentTableViewItem()) {
|
||||
if(auto delegate = parent->self()) return *delegate;
|
||||
}
|
||||
return nothing;
|
||||
}
|
||||
|
||||
auto pListViewCell::_setState() -> void {
|
||||
auto pTableViewCell::_setState() -> void {
|
||||
if(auto parent = _parent()) {
|
||||
if(auto grandparent = parent->_parent()) {
|
||||
grandparent->lock();
|
@ -1,9 +1,9 @@
|
||||
#if defined(Hiro_ListView)
|
||||
#if defined(Hiro_TableView)
|
||||
|
||||
namespace hiro {
|
||||
|
||||
struct pListViewCell : pObject {
|
||||
Declare(ListViewCell, Object)
|
||||
struct pTableViewCell : pObject {
|
||||
Declare(TableViewCell, Object)
|
||||
|
||||
auto setAlignment(Alignment alignment) -> void;
|
||||
auto setBackgroundColor(Color color) -> void;
|
||||
@ -14,7 +14,7 @@ struct pListViewCell : pObject {
|
||||
auto setIcon(const image& icon) -> void;
|
||||
auto setText(const string& text) -> void;
|
||||
|
||||
auto _parent() -> maybe<pListViewItem&>;
|
||||
auto _parent() -> maybe<pTableViewItem&>;
|
||||
auto _setState() -> void;
|
||||
};
|
||||
|
99
hiro/qt/widget/table-view-column.cpp
Normal file
99
hiro/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 {
|
||||
|
||||
struct pListViewColumn : pObject {
|
||||
Declare(ListViewColumn, Object)
|
||||
struct pTableViewColumn : pObject {
|
||||
Declare(TableViewColumn, Object)
|
||||
|
||||
auto setActive() -> void;
|
||||
auto setAlignment(Alignment alignment) -> void;
|
||||
@ -21,7 +21,7 @@ struct pListViewColumn : pObject {
|
||||
auto setVisible(bool visible) -> void;
|
||||
auto setWidth(signed width) -> void;
|
||||
|
||||
auto _parent() -> maybe<pListViewHeader&>;
|
||||
auto _parent() -> maybe<pTableViewHeader&>;
|
||||
auto _setState() -> void;
|
||||
};
|
||||
|
43
hiro/qt/widget/table-view-header.cpp
Normal file
43
hiro/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
hiro/qt/widget/table-view-header.hpp
Normal file
18
hiro/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
hiro/qt/widget/table-view-item.cpp
Normal file
66
hiro/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 {
|
||||
|
||||
struct pListViewItem : pObject {
|
||||
Declare(ListViewItem, Object)
|
||||
struct pTableViewItem : pObject {
|
||||
Declare(TableViewItem, Object)
|
||||
|
||||
auto append(sListViewCell cell) -> void;
|
||||
auto remove(sListViewCell cell) -> void;
|
||||
auto append(sTableViewCell cell) -> void;
|
||||
auto remove(sTableViewCell cell) -> void;
|
||||
auto setAlignment(Alignment alignment) -> void;
|
||||
auto setBackgroundColor(Color color) -> void;
|
||||
auto setFont(const Font& font) -> void override;
|
||||
auto setForegroundColor(Color color) -> void;
|
||||
auto setSelected(bool selected) -> void;
|
||||
|
||||
auto _parent() -> maybe<pListView&>;
|
||||
auto _parent() -> maybe<pTableView&>;
|
||||
auto _setState() -> void;
|
||||
|
||||
QTreeWidgetItem* qtItem = nullptr;
|
@ -1,23 +1,23 @@
|
||||
#if defined(Hiro_ListView)
|
||||
#if defined(Hiro_TableView)
|
||||
|
||||
namespace hiro {
|
||||
|
||||
auto pListView::construct() -> void {
|
||||
qtWidget = qtListView = new QtListView(*this);
|
||||
qtListView->setAllColumnsShowFocus(true);
|
||||
qtListView->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
qtListView->setRootIsDecorated(false);
|
||||
qtListView->setHeaderHidden(true);
|
||||
qtListView->header()->setMovable(false);
|
||||
auto pTableView::construct() -> void {
|
||||
qtWidget = qtTableView = new QtTableView(*this);
|
||||
qtTableView->setAllColumnsShowFocus(true);
|
||||
qtTableView->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
qtTableView->setRootIsDecorated(false);
|
||||
qtTableView->setHeaderHidden(true);
|
||||
qtTableView->header()->setMovable(false);
|
||||
|
||||
qtListViewDelegate = new QtListViewDelegate(*this);
|
||||
qtListView->setItemDelegate(qtListViewDelegate);
|
||||
qtTableViewDelegate = new QtTableViewDelegate(*this);
|
||||
qtTableView->setItemDelegate(qtTableViewDelegate);
|
||||
|
||||
qtListView->connect(qtListView, SIGNAL(itemActivated(QTreeWidgetItem*, int)), SLOT(onActivate()));
|
||||
qtListView->connect(qtListView, SIGNAL(itemSelectionChanged()), SLOT(onChange()));
|
||||
qtListView->connect(qtListView, SIGNAL(customContextMenuRequested(const QPoint&)), SLOT(onContext()));
|
||||
qtListView->connect(qtListView->header(), SIGNAL(sectionClicked(int)), SLOT(onSort(int)));
|
||||
qtListView->connect(qtListView, SIGNAL(itemChanged(QTreeWidgetItem*, int)), SLOT(onToggle(QTreeWidgetItem*, int)));
|
||||
qtTableView->connect(qtTableView, SIGNAL(itemActivated(QTreeWidgetItem*, int)), SLOT(onActivate()));
|
||||
qtTableView->connect(qtTableView, SIGNAL(itemSelectionChanged()), SLOT(onChange()));
|
||||
qtTableView->connect(qtTableView, SIGNAL(customContextMenuRequested(const QPoint&)), SLOT(onContext()));
|
||||
qtTableView->connect(qtTableView->header(), SIGNAL(sectionClicked(int)), SLOT(onSort(int)));
|
||||
qtTableView->connect(qtTableView, SIGNAL(itemChanged(QTreeWidgetItem*, int)), SLOT(onToggle(QTreeWidgetItem*, int)));
|
||||
|
||||
setBackgroundColor(state().backgroundColor);
|
||||
setBatchable(state().batchable);
|
||||
@ -27,14 +27,14 @@ auto pListView::construct() -> void {
|
||||
pWidget::construct();
|
||||
}
|
||||
|
||||
auto pListView::destruct() -> void {
|
||||
delete qtListViewDelegate;
|
||||
delete qtListView;
|
||||
qtWidget = qtListView = nullptr;
|
||||
qtListViewDelegate = nullptr;
|
||||
auto pTableView::destruct() -> void {
|
||||
delete qtTableViewDelegate;
|
||||
delete qtTableView;
|
||||
qtWidget = qtTableView = nullptr;
|
||||
qtTableViewDelegate = nullptr;
|
||||
}
|
||||
|
||||
auto pListView::append(sListViewHeader header) -> void {
|
||||
auto pTableView::append(sTableViewHeader header) -> void {
|
||||
lock();
|
||||
if(auto self = header->self()) {
|
||||
self->_setState();
|
||||
@ -42,22 +42,22 @@ auto pListView::append(sListViewHeader header) -> void {
|
||||
unlock();
|
||||
}
|
||||
|
||||
auto pListView::append(sListViewItem item) -> void {
|
||||
auto pTableView::append(sTableViewItem item) -> void {
|
||||
lock();
|
||||
if(auto self = item->self()) {
|
||||
self->qtItem = new QTreeWidgetItem(qtListView);
|
||||
self->qtItem = new QTreeWidgetItem(qtTableView);
|
||||
self->_setState();
|
||||
}
|
||||
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();
|
||||
|
||||
if(auto& header = state().header) {
|
||||
@ -72,7 +72,7 @@ auto pListView::resizeColumns() -> void {
|
||||
}
|
||||
|
||||
signed maximumWidth = self().geometry().width() - 6;
|
||||
if(auto scrollBar = qtListView->verticalScrollBar()) {
|
||||
if(auto scrollBar = qtTableView->verticalScrollBar()) {
|
||||
if(scrollBar->isVisible()) maximumWidth -= scrollBar->geometry().width();
|
||||
}
|
||||
|
||||
@ -84,50 +84,50 @@ auto pListView::resizeColumns() -> void {
|
||||
for(auto column : range(header->columnCount())) {
|
||||
signed width = widths[column];
|
||||
if(header->column(column).expandable()) width += expandWidth;
|
||||
qtListView->setColumnWidth(column, width);
|
||||
qtTableView->setColumnWidth(column, width);
|
||||
}
|
||||
}
|
||||
|
||||
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) {
|
||||
QPalette palette = qtListView->palette();
|
||||
QPalette palette = qtTableView->palette();
|
||||
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)));
|
||||
qtListView->setPalette(palette);
|
||||
qtListView->setAutoFillBackground(true);
|
||||
qtTableView->setPalette(palette);
|
||||
qtTableView->setAutoFillBackground(true);
|
||||
} else {
|
||||
//todo: set default color
|
||||
}
|
||||
}
|
||||
|
||||
auto pListView::setBatchable(bool batchable) -> void {
|
||||
auto pTableView::setBatchable(bool batchable) -> void {
|
||||
lock();
|
||||
qtListView->setSelectionMode(batchable ? QAbstractItemView::ExtendedSelection : QAbstractItemView::SingleSelection);
|
||||
qtTableView->setSelectionMode(batchable ? QAbstractItemView::ExtendedSelection : QAbstractItemView::SingleSelection);
|
||||
unlock();
|
||||
}
|
||||
|
||||
auto pListView::setBordered(bool bordered) -> void {
|
||||
qtListView->repaint();
|
||||
auto pTableView::setBordered(bool bordered) -> void {
|
||||
qtTableView->repaint();
|
||||
}
|
||||
|
||||
auto pListView::setForegroundColor(Color color) -> void {
|
||||
auto pTableView::setForegroundColor(Color color) -> void {
|
||||
if(color) {
|
||||
QPalette palette = qtListView->palette();
|
||||
QPalette palette = qtTableView->palette();
|
||||
palette.setColor(QPalette::Text, QColor(color.red(), color.green(), color.blue()));
|
||||
qtListView->setPalette(palette);
|
||||
qtTableView->setPalette(palette);
|
||||
} else {
|
||||
//todo: set default color
|
||||
}
|
||||
}
|
||||
|
||||
//called on resize/show events
|
||||
auto pListView::_onSize() -> void {
|
||||
auto pTableView::_onSize() -> void {
|
||||
//resize columns only if at least one column is expandable
|
||||
if(auto& header = state().header) {
|
||||
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 width = header->column(column).width()) return width;
|
||||
unsigned width = 1;
|
||||
@ -150,12 +150,12 @@ auto pListView::_width(unsigned column) -> unsigned {
|
||||
return 1;
|
||||
}
|
||||
|
||||
auto pListView::_widthOfColumn(unsigned _column) -> unsigned {
|
||||
auto pTableView::_widthOfColumn(unsigned _column) -> unsigned {
|
||||
unsigned width = 8;
|
||||
if(auto& header = state().header) {
|
||||
if(auto column = header->column(_column)) {
|
||||
if(auto& icon = column->state.icon) {
|
||||
width += icon.width() + 2;
|
||||
width += icon.width() + 4;
|
||||
}
|
||||
if(auto& text = column->state.text) {
|
||||
width += pFont::size(column->font(true), text).width();
|
||||
@ -165,15 +165,15 @@ auto pListView::_widthOfColumn(unsigned _column) -> unsigned {
|
||||
return width;
|
||||
}
|
||||
|
||||
auto pListView::_widthOfCell(unsigned _row, unsigned _column) -> unsigned {
|
||||
auto pTableView::_widthOfCell(unsigned _row, unsigned _column) -> unsigned {
|
||||
unsigned width = 8;
|
||||
if(auto item = self().item(_row)) {
|
||||
if(auto cell = item->cell(_column)) {
|
||||
if(cell->state.checkable) {
|
||||
width += 16 + 2;
|
||||
width += 16 + 4;
|
||||
}
|
||||
if(auto& icon = cell->state.icon) {
|
||||
width += icon.width() + 2;
|
||||
width += icon.width() + 4;
|
||||
}
|
||||
if(auto& text = cell->state.text) {
|
||||
width += pFont::size(cell->font(true), text).width();
|
||||
@ -183,11 +183,11 @@ auto pListView::_widthOfCell(unsigned _row, unsigned _column) -> unsigned {
|
||||
return width;
|
||||
}
|
||||
|
||||
auto QtListView::onActivate() -> void {
|
||||
auto QtTableView::onActivate() -> void {
|
||||
if(!p.locked()) p.self().doActivate();
|
||||
}
|
||||
|
||||
auto QtListView::onChange() -> void {
|
||||
auto QtTableView::onChange() -> void {
|
||||
for(auto& item : p.state().items) {
|
||||
item->state.selected = false;
|
||||
if(auto self = item->self()) {
|
||||
@ -197,11 +197,11 @@ auto QtListView::onChange() -> void {
|
||||
if(!p.locked()) p.self().doChange();
|
||||
}
|
||||
|
||||
auto QtListView::onContext() -> void {
|
||||
auto QtTableView::onContext() -> void {
|
||||
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 column = header->column(columnNumber)) {
|
||||
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) {
|
||||
if(auto self = item->self()) {
|
||||
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);
|
||||
if(event->button() == Qt::RightButton) onContext();
|
||||
}
|
||||
|
||||
auto QtListView::resizeEvent(QResizeEvent* event) -> void {
|
||||
auto QtTableView::resizeEvent(QResizeEvent* event) -> void {
|
||||
QTreeWidget::resizeEvent(event);
|
||||
p._onSize();
|
||||
}
|
||||
|
||||
auto QtListView::showEvent(QShowEvent* event) -> void {
|
||||
auto QtTableView::showEvent(QShowEvent* event) -> void {
|
||||
QTreeWidget::showEvent(event);
|
||||
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);
|
||||
if(p.state().bordered) {
|
||||
QPen pen;
|
@ -1,14 +1,14 @@
|
||||
#if defined(Hiro_ListView)
|
||||
#if defined(Hiro_TableView)
|
||||
|
||||
namespace hiro {
|
||||
|
||||
struct pListView : pWidget {
|
||||
Declare(ListView, Widget)
|
||||
struct pTableView : pWidget {
|
||||
Declare(TableView, Widget)
|
||||
|
||||
auto append(sListViewHeader header) -> void;
|
||||
auto append(sListViewItem item) -> void;
|
||||
auto remove(sListViewHeader header) -> void;
|
||||
auto remove(sListViewItem item) -> void;
|
||||
auto append(sTableViewHeader header) -> void;
|
||||
auto append(sTableViewItem item) -> void;
|
||||
auto remove(sTableViewHeader header) -> void;
|
||||
auto remove(sTableViewItem item) -> void;
|
||||
auto resizeColumns() -> void;
|
||||
auto setAlignment(Alignment alignment) -> void;
|
||||
auto setBackgroundColor(Color color) -> void;
|
||||
@ -21,8 +21,8 @@ struct pListView : pWidget {
|
||||
auto _widthOfColumn(unsigned column) -> unsigned;
|
||||
auto _widthOfCell(unsigned row, unsigned column) -> unsigned;
|
||||
|
||||
QtListView* qtListView = nullptr;
|
||||
QtListViewDelegate* qtListViewDelegate = nullptr;
|
||||
QtTableView* qtTableView = nullptr;
|
||||
QtTableViewDelegate* qtTableViewDelegate = nullptr;
|
||||
};
|
||||
|
||||
}
|
@ -163,10 +163,10 @@ static auto Application_keyboardProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM
|
||||
if(msg == WM_KEYDOWN) {
|
||||
if(0);
|
||||
|
||||
#if defined(Hiro_ListView)
|
||||
else if(auto listView = dynamic_cast<mListView*>(object)) {
|
||||
#if defined(Hiro_TableView)
|
||||
else if(auto tableView = dynamic_cast<mTableView*>(object)) {
|
||||
if(wparam == VK_RETURN) {
|
||||
if(listView->selected()) return true; //returning true generates LVN_ITEMACTIVATE message
|
||||
if(tableView->selected()) return true; //returning true generates LVN_ITEMACTIVATE message
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -41,11 +41,11 @@
|
||||
#include "widget/horizontal-slider.cpp"
|
||||
#include "widget/label.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/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/progress-bar.cpp"
|
||||
#include "widget/radio-button.cpp"
|
||||
#include "widget/radio-label.cpp"
|
||||
|
@ -10,9 +10,9 @@ struct pWidget;
|
||||
struct AppMessage {
|
||||
enum : unsigned {
|
||||
None = WM_APP,
|
||||
ListView_doPaint,
|
||||
ListView_onActivate,
|
||||
ListView_onChange,
|
||||
TableView_doPaint,
|
||||
TableView_onActivate,
|
||||
TableView_onChange,
|
||||
};
|
||||
};
|
||||
|
||||
@ -70,16 +70,16 @@ static vector<wObject> windows;
|
||||
#include "widget/horizontal-slider.hpp"
|
||||
#include "widget/label.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/radio-button.hpp"
|
||||
#include "widget/radio-label.hpp"
|
||||
#include "widget/tab-frame.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/vertical-scroll-bar.hpp"
|
||||
#include "widget/vertical-slider.hpp"
|
||||
|
@ -298,31 +298,31 @@ static auto CALLBACK Shared_windowProc(WindowProc windowProc, HWND hwnd, UINT ms
|
||||
auto object = (mObject*)GetWindowLongPtr((HWND)header->hwndFrom, GWLP_USERDATA);
|
||||
if(!object) break;
|
||||
|
||||
#if defined(Hiro_ListView)
|
||||
if(auto listView = dynamic_cast<mListView*>(object)) {
|
||||
#if defined(Hiro_TableView)
|
||||
if(auto tableView = dynamic_cast<mTableView*>(object)) {
|
||||
if(header->code == LVN_ITEMACTIVATE) {
|
||||
listView->self()->onActivate(lparam);
|
||||
tableView->self()->onActivate(lparam);
|
||||
break;
|
||||
}
|
||||
if(header->code == LVN_ITEMCHANGED) {
|
||||
listView->self()->onChange(lparam);
|
||||
tableView->self()->onChange(lparam);
|
||||
break;
|
||||
}
|
||||
if(header->code == LVN_COLUMNCLICK) {
|
||||
if(isWindowCallback) listView->self()->onSort(lparam);
|
||||
if(isWindowCallback) tableView->self()->onSort(lparam);
|
||||
break;
|
||||
}
|
||||
if(header->code == NM_CLICK || header->code == NM_DBLCLK) {
|
||||
//onToggle performs the test to ensure the ListViewItem clicked was checkable
|
||||
if(isWindowCallback) listView->self()->onToggle(lparam);
|
||||
//onToggle performs the test to ensure the TableViewItem clicked was checkable
|
||||
if(isWindowCallback) tableView->self()->onToggle(lparam);
|
||||
break;
|
||||
}
|
||||
if(header->code == NM_RCLICK) {
|
||||
if(isWindowCallback) listView->self()->onContext(lparam);
|
||||
if(isWindowCallback) tableView->self()->onContext(lparam);
|
||||
break;
|
||||
}
|
||||
if(header->code == NM_CUSTOMDRAW) {
|
||||
return listView->self()->onCustomDraw(lparam);
|
||||
return tableView->self()->onCustomDraw(lparam);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -339,21 +339,21 @@ static auto CALLBACK Shared_windowProc(WindowProc windowProc, HWND hwnd, UINT ms
|
||||
break;
|
||||
}
|
||||
|
||||
#if defined(Hiro_ListView)
|
||||
case AppMessage::ListView_doPaint: {
|
||||
if(auto listView = (mListView*)lparam) {
|
||||
if(auto self = listView->self()) InvalidateRect(self->hwnd, nullptr, true);
|
||||
#if defined(Hiro_TableView)
|
||||
case AppMessage::TableView_doPaint: {
|
||||
if(auto tableView = (mTableView*)lparam) {
|
||||
if(auto self = tableView->self()) InvalidateRect(self->hwnd, nullptr, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case AppMessage::ListView_onActivate: {
|
||||
if(auto listView = (mListView*)lparam) listView->doActivate();
|
||||
case AppMessage::TableView_onActivate: {
|
||||
if(auto tableView = (mTableView*)lparam) tableView->doActivate();
|
||||
break;
|
||||
}
|
||||
|
||||
case AppMessage::ListView_onChange: {
|
||||
if(auto listView = (mListView*)lparam) listView->doChange();
|
||||
case AppMessage::TableView_onChange: {
|
||||
if(auto tableView = (mTableView*)lparam) tableView->doChange();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -151,7 +151,8 @@ auto pCanvas::_rasterize() -> void {
|
||||
}
|
||||
if(width <= 0 || height <= 0) return;
|
||||
|
||||
pixels.reallocate(width * height);
|
||||
pixels.reset();
|
||||
pixels.resize(width * height);
|
||||
|
||||
if(auto& icon = state().icon) {
|
||||
memory::copy(pixels.data(), icon.data(), width * height * sizeof(uint32));
|
||||
|
@ -1,72 +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 {
|
||||
_repaint();
|
||||
}
|
||||
|
||||
auto pListViewCell::setCheckable(bool checkable) -> void {
|
||||
_repaint();
|
||||
}
|
||||
|
||||
auto pListViewCell::setChecked(bool checked) -> void {
|
||||
_repaint();
|
||||
}
|
||||
|
||||
auto pListViewCell::setForegroundColor(Color color) -> void {
|
||||
_repaint();
|
||||
}
|
||||
|
||||
auto pListViewCell::setIcon(const image& icon) -> void {
|
||||
_repaint();
|
||||
}
|
||||
|
||||
auto pListViewCell::setText(const string& text) -> void {
|
||||
_repaint();
|
||||
}
|
||||
|
||||
auto pListViewCell::_parent() -> maybe<pListViewItem&> {
|
||||
if(auto parent = self().parentListViewItem()) {
|
||||
if(auto self = parent->self()) return *self;
|
||||
}
|
||||
return nothing;
|
||||
}
|
||||
|
||||
auto pListViewCell::_repaint() -> void {
|
||||
if(auto parent = _parent()) {
|
||||
if(auto listView = parent->_parent()) {
|
||||
//ListView uses a custom drawing routine; so we need to tell the control to repaint itself manually
|
||||
PostMessageOnce(listView->_parentHandle(), AppMessage::ListView_doPaint, 0, (LPARAM)&listView->reference);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto pListViewCell::_setState() -> void {
|
||||
if(auto item = _parent()) {
|
||||
if(auto parent = item->_parent()) {
|
||||
parent->lock();
|
||||
wchar_t text[] = L"";
|
||||
LVITEM lvItem;
|
||||
lvItem.mask = LVIF_TEXT;
|
||||
lvItem.iItem = item->self().offset();
|
||||
lvItem.iSubItem = self().offset();
|
||||
lvItem.pszText = text;
|
||||
ListView_SetItem(parent->hwnd, &lvItem);
|
||||
parent->unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#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
|
72
hiro/windows/widget/table-view-cell.cpp
Normal file
72
hiro/windows/widget/table-view-cell.cpp
Normal file
@ -0,0 +1,72 @@
|
||||
#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 {
|
||||
_repaint();
|
||||
}
|
||||
|
||||
auto pTableViewCell::setCheckable(bool checkable) -> void {
|
||||
_repaint();
|
||||
}
|
||||
|
||||
auto pTableViewCell::setChecked(bool checked) -> void {
|
||||
_repaint();
|
||||
}
|
||||
|
||||
auto pTableViewCell::setForegroundColor(Color color) -> void {
|
||||
_repaint();
|
||||
}
|
||||
|
||||
auto pTableViewCell::setIcon(const image& icon) -> void {
|
||||
_repaint();
|
||||
}
|
||||
|
||||
auto pTableViewCell::setText(const string& text) -> void {
|
||||
_repaint();
|
||||
}
|
||||
|
||||
auto pTableViewCell::_parent() -> maybe<pTableViewItem&> {
|
||||
if(auto parent = self().parentTableViewItem()) {
|
||||
if(auto self = parent->self()) return *self;
|
||||
}
|
||||
return nothing;
|
||||
}
|
||||
|
||||
auto pTableViewCell::_repaint() -> void {
|
||||
if(auto parent = _parent()) {
|
||||
if(auto tableView = parent->_parent()) {
|
||||
//TableView uses a custom drawing routine; so we need to tell the control to repaint itself manually
|
||||
PostMessageOnce(tableView->_parentHandle(), AppMessage::TableView_doPaint, 0, (LPARAM)&tableView->reference);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto pTableViewCell::_setState() -> void {
|
||||
if(auto item = _parent()) {
|
||||
if(auto parent = item->_parent()) {
|
||||
parent->lock();
|
||||
wchar_t text[] = L"";
|
||||
LVITEM lvItem;
|
||||
lvItem.mask = LVIF_TEXT;
|
||||
lvItem.iItem = item->self().offset();
|
||||
lvItem.iSubItem = self().offset();
|
||||
lvItem.pszText = text;
|
||||
ListView_SetItem(parent->hwnd, &lvItem);
|
||||
parent->unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -1,9 +1,9 @@
|
||||
#if defined(Hiro_ListView)
|
||||
#if defined(Hiro_TableView)
|
||||
|
||||
namespace hiro {
|
||||
|
||||
struct pListViewCell : pObject {
|
||||
Declare(ListViewCell, Object)
|
||||
struct pTableViewCell : pObject {
|
||||
Declare(TableViewCell, Object)
|
||||
|
||||
auto setAlignment(Alignment alignment) -> void;
|
||||
auto setBackgroundColor(Color color) -> void;
|
||||
@ -13,7 +13,7 @@ struct pListViewCell : pObject {
|
||||
auto setIcon(const image& icon) -> void;
|
||||
auto setText(const string& text) -> void;
|
||||
|
||||
auto _parent() -> maybe<pListViewItem&>;
|
||||
auto _parent() -> maybe<pTableViewItem&>;
|
||||
auto _repaint() -> void;
|
||||
auto _setState() -> void;
|
||||
};
|
@ -1,8 +1,8 @@
|
||||
#if defined(Hiro_ListView)
|
||||
#if defined(Hiro_TableView)
|
||||
|
||||
namespace hiro {
|
||||
|
||||
auto pListViewColumn::construct() -> void {
|
||||
auto pTableViewColumn::construct() -> void {
|
||||
if(auto grandparent = _grandparent()) {
|
||||
grandparent->lock();
|
||||
wchar_t text[] = L"";
|
||||
@ -17,7 +17,7 @@ auto pListViewColumn::construct() -> void {
|
||||
}
|
||||
}
|
||||
|
||||
auto pListViewColumn::destruct() -> void {
|
||||
auto pTableViewColumn::destruct() -> void {
|
||||
if(auto grandparent = _grandparent()) {
|
||||
grandparent->lock();
|
||||
ListView_DeleteColumn(grandparent->hwnd, self().offset());
|
||||
@ -25,65 +25,65 @@ auto pListViewColumn::destruct() -> void {
|
||||
}
|
||||
}
|
||||
|
||||
auto pListViewColumn::setActive() -> void {
|
||||
auto pTableViewColumn::setActive() -> void {
|
||||
//unsupported
|
||||
}
|
||||
|
||||
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 {
|
||||
//unsupported
|
||||
}
|
||||
|
||||
auto pListViewColumn::setExpandable(bool expandable) -> void {
|
||||
auto pTableViewColumn::setExpandable(bool expandable) -> void {
|
||||
}
|
||||
|
||||
auto pListViewColumn::setForegroundColor(Color color) -> void {
|
||||
auto pTableViewColumn::setForegroundColor(Color color) -> void {
|
||||
}
|
||||
|
||||
auto pListViewColumn::setHorizontalAlignment(double alignment) -> void {
|
||||
auto pTableViewColumn::setHorizontalAlignment(double alignment) -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
auto pListViewColumn::setIcon(const image& icon) -> void {
|
||||
auto pTableViewColumn::setIcon(const image& icon) -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
auto pListViewColumn::setResizable(bool resizable) -> void {
|
||||
auto pTableViewColumn::setResizable(bool resizable) -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
auto pListViewColumn::setSortable(bool sortable) -> void {
|
||||
auto pTableViewColumn::setSortable(bool sortable) -> void {
|
||||
}
|
||||
|
||||
auto pListViewColumn::setText(const string& text) -> void {
|
||||
auto pTableViewColumn::setText(const string& text) -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
auto pListViewColumn::setVerticalAlignment(double alignment) -> void {
|
||||
auto pTableViewColumn::setVerticalAlignment(double alignment) -> void {
|
||||
}
|
||||
|
||||
auto pListViewColumn::setWidth(signed width) -> void {
|
||||
auto pTableViewColumn::setWidth(signed width) -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
auto pListViewColumn::_grandparent() -> maybe<pListView&> {
|
||||
auto pTableViewColumn::_grandparent() -> maybe<pTableView&> {
|
||||
if(auto parent = _parent()) return parent->_parent();
|
||||
return nothing;
|
||||
}
|
||||
|
||||
auto pListViewColumn::_parent() -> maybe<pListViewHeader&> {
|
||||
if(auto parent = self().parentListViewHeader()) {
|
||||
auto pTableViewColumn::_parent() -> maybe<pTableViewHeader&> {
|
||||
if(auto parent = self().parentTableViewHeader()) {
|
||||
if(auto self = parent->self()) return *self;
|
||||
}
|
||||
return nothing;
|
||||
}
|
||||
|
||||
auto pListViewColumn::_setState() -> void {
|
||||
auto pTableViewColumn::_setState() -> void {
|
||||
if(auto grandparent = _grandparent()) {
|
||||
grandparent->lock();
|
||||
grandparent->_setIcons();
|
@ -1,9 +1,9 @@
|
||||
#if defined(Hiro_ListView)
|
||||
#if defined(Hiro_TableView)
|
||||
|
||||
namespace hiro {
|
||||
|
||||
struct pListViewColumn : pObject {
|
||||
Declare(ListViewColumn, Object)
|
||||
struct pTableViewColumn : pObject {
|
||||
Declare(TableViewColumn, Object)
|
||||
|
||||
auto setActive() -> void;
|
||||
auto setAlignment(Alignment alignment) -> void;
|
||||
@ -19,11 +19,11 @@ struct pListViewColumn : pObject {
|
||||
auto setVerticalAlignment(double alignment) -> void;
|
||||
auto setWidth(signed width) -> void;
|
||||
|
||||
auto _grandparent() -> maybe<pListView&>;
|
||||
auto _parent() -> maybe<pListViewHeader&>;
|
||||
auto _grandparent() -> maybe<pTableView&>;
|
||||
auto _parent() -> maybe<pTableViewHeader&>;
|
||||
auto _setState() -> void;
|
||||
|
||||
signed _width = 128; //computed width (via ListView::resizeColumns)
|
||||
signed _width = 128; //computed width (via TableView::resizeColumns)
|
||||
};
|
||||
|
||||
}
|
@ -1,32 +1,32 @@
|
||||
#if defined(Hiro_ListView)
|
||||
#if defined(Hiro_TableView)
|
||||
|
||||
namespace hiro {
|
||||
|
||||
auto pListViewHeader::construct() -> void {
|
||||
auto pTableViewHeader::construct() -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
auto pListViewHeader::destruct() -> void {
|
||||
auto pTableViewHeader::destruct() -> void {
|
||||
}
|
||||
|
||||
auto pListViewHeader::append(sListViewColumn column) -> void {
|
||||
auto pTableViewHeader::append(sTableViewColumn column) -> void {
|
||||
}
|
||||
|
||||
auto pListViewHeader::remove(sListViewColumn column) -> void {
|
||||
auto pTableViewHeader::remove(sTableViewColumn column) -> void {
|
||||
}
|
||||
|
||||
auto pListViewHeader::setVisible(bool visible) -> void {
|
||||
auto pTableViewHeader::setVisible(bool visible) -> void {
|
||||
_setState();
|
||||
}
|
||||
|
||||
auto pListViewHeader::_parent() -> maybe<pListView&> {
|
||||
if(auto parent = self().parentListView()) {
|
||||
auto pTableViewHeader::_parent() -> maybe<pTableView&> {
|
||||
if(auto parent = self().parentTableView()) {
|
||||
if(auto self = parent->self()) return *self;
|
||||
}
|
||||
return nothing;
|
||||
}
|
||||
|
||||
auto pListViewHeader::_setState() -> void {
|
||||
auto pTableViewHeader::_setState() -> void {
|
||||
if(auto parent = _parent()) {
|
||||
auto style = GetWindowLong(parent->hwnd, GWL_STYLE);
|
||||
self().visible() ? style &=~ LVS_NOCOLUMNHEADER : style |= LVS_NOCOLUMNHEADER;
|
18
hiro/windows/widget/table-view-header.hpp
Normal file
18
hiro/windows/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 {
|
||||
|
||||
auto pListViewItem::construct() -> void {
|
||||
auto pTableViewItem::construct() -> void {
|
||||
if(auto parent = _parent()) {
|
||||
parent->lock();
|
||||
wchar_t text[] = L"";
|
||||
@ -17,7 +17,7 @@ auto pListViewItem::construct() -> void {
|
||||
}
|
||||
}
|
||||
|
||||
auto pListViewItem::destruct() -> void {
|
||||
auto pTableViewItem::destruct() -> void {
|
||||
if(auto parent = _parent()) {
|
||||
parent->lock();
|
||||
ListView_DeleteItem(parent->hwnd, self().offset());
|
||||
@ -25,19 +25,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()) {
|
||||
parent->lock();
|
||||
ListView_SetItemState(parent->hwnd, self().offset(), LVIS_FOCUSED, LVIS_FOCUSED);
|
||||
@ -45,21 +45,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();
|
||||
}
|
||||
|
||||
auto pListViewItem::_parent() -> maybe<pListView&> {
|
||||
if(auto parent = self().parentListView()) {
|
||||
auto pTableViewItem::_parent() -> maybe<pTableView&> {
|
||||
if(auto parent = self().parentTableView()) {
|
||||
if(auto self = parent->self()) return *self;
|
||||
}
|
||||
return nothing;
|
||||
}
|
||||
|
||||
auto pListViewItem::_setState() -> void {
|
||||
auto pTableViewItem::_setState() -> void {
|
||||
if(auto parent = _parent()) {
|
||||
parent->lock();
|
||||
ListView_SetItemState(parent->hwnd, self().offset(), state().selected ? LVIS_SELECTED : 0, LVIS_SELECTED);
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user