mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
.reference
git-svn-id: svn://ultimatepp.org/upp/trunk@15691 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
da5f9a4251
commit
fe5cb795e8
4 changed files with 242 additions and 0 deletions
52
reference/FileTabsExample/FileTabsExample.h
Normal file
52
reference/FileTabsExample/FileTabsExample.h
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
#ifndef _FileTabsExample_FileTabsExample_h
|
||||
#define _FileTabsExample_FileTabsExample_h
|
||||
|
||||
#include <CtrlLib/CtrlLib.h>
|
||||
#include <TabBar/TabBar.h>
|
||||
using namespace Upp;
|
||||
|
||||
#define LAYOUTFILE <FileTabsExample/FileTabsExample.lay>
|
||||
#include <CtrlCore/lay.h>
|
||||
|
||||
class FileTabsExample : public WithFileTabsExampleLayout<TopWindow> {
|
||||
private:
|
||||
FileTabs bar[4];
|
||||
String barbackup;
|
||||
|
||||
public:
|
||||
FileTabsExample();
|
||||
|
||||
// TabBar events
|
||||
void OnCursor();
|
||||
bool OnCloseConfirm(Value v);
|
||||
bool OnCloseAllConfirm();
|
||||
// Buttons
|
||||
void OnAdd();
|
||||
void OnInsert();
|
||||
// Options
|
||||
void OnGrouping();
|
||||
void OnGroupSort();
|
||||
void OnValueSort();
|
||||
void OnKeySort();
|
||||
void OnSeparators();
|
||||
void OnStacking();
|
||||
void OnStackSort();
|
||||
void OnIcons();
|
||||
void OnPrompt();
|
||||
void OnAllAlign();
|
||||
void OnInactive();
|
||||
// Ctrl overloads
|
||||
virtual bool Key(dword key, int count);
|
||||
virtual void DragAndDrop(Point p, PasteClip& d);
|
||||
|
||||
struct MyValueOrder : public ValueOrder
|
||||
{
|
||||
virtual bool operator()(const Value& a, const Value& b) const { return (Random()%2); }
|
||||
};
|
||||
|
||||
StdValueOrder vo;
|
||||
MyValueOrder myvo;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
23
reference/FileTabsExample/FileTabsExample.lay
Normal file
23
reference/FileTabsExample/FileTabsExample.lay
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
LAYOUT(FileTabsExampleLayout, 660, 348)
|
||||
ITEM(Upp::EditString, fileinput, HSizePosZ(8, 72).TopPosZ(44, 20))
|
||||
ITEM(Upp::Button, addfile, SetLabel(t_("Add")).RightPosZ(4, 64).TopPosZ(44, 20))
|
||||
ITEM(Upp::Option, grouping, SetLabel(t_("Group tabs")).LeftPosZ(8, 132).TopPosZ(84, 16))
|
||||
ITEM(Upp::Option, keysort, SetLabel(t_("Sort tabs by key")).LeftPosZ(416, 132).TopPosZ(104, 16))
|
||||
ITEM(Upp::Option, valuesort, SetLabel(t_("Sort tabs by value")).LeftPosZ(416, 132).TopPosZ(84, 16))
|
||||
ITEM(Upp::Option, stacksort, SetLabel(t_("Sort stacks")).LeftPosZ(144, 132).TopPosZ(104, 16))
|
||||
ITEM(Upp::Option, groupsort, SetLabel(t_("Sort tabs by group")).LeftPosZ(8, 132).TopPosZ(104, 16))
|
||||
ITEM(Upp::Option, separators, SetLabel(t_("Visually seperate groups")).LeftPosZ(8, 132).TopPosZ(124, 16))
|
||||
ITEM(Upp::Option, stacking, SetLabel(t_("Stack tabs")).LeftPosZ(144, 132).TopPosZ(84, 16))
|
||||
ITEM(Upp::Option, normalicons, SetLabel(t_("Icons for normal tabs")).LeftPosZ(144, 132).TopPosZ(124, 16))
|
||||
ITEM(Upp::Option, stackedicons, SetLabel(t_("Icons for stacked tabs")).LeftPosZ(144, 132).TopPosZ(144, 16))
|
||||
ITEM(Upp::Option, prompt, SetLabel(t_("Prompt before tab close")).LeftPosZ(280, 132).TopPosZ(84, 16))
|
||||
ITEM(Upp::Option, inactive, SetLabel(t_("Show inactive tabs")).LeftPosZ(280, 132).TopPosZ(124, 16))
|
||||
ITEM(Upp::Option, allalign, SetLabel(t_("Show all alignments")).LeftPosZ(280, 132).TopPosZ(104, 16))
|
||||
ITEM(Upp::LabelBox, dv___14, SetLabel(t_("Options")).HSizePosZ(4, 0).TopPosZ(68, 96))
|
||||
ITEM(Upp::Label, selection, HSizePosZ(4, 4).TopPosZ(184, 19))
|
||||
ITEM(Upp::Label, dv___16, SetLabel(t_("Selected file (form top bar only):")).HSizePosZ(4, 4).TopPosZ(164, 19))
|
||||
ITEM(Upp::LabelBox, dv___17, SetLabel(t_("Add Files")).HSizePosZ(4, 0).TopPosZ(0, 68))
|
||||
ITEM(Upp::Label, dv___18, SetLabel(t_("- Drag files onto this window\n- Enter full paths below (files do not need to exist)")).HSizePosZ(8, 4).TopPosZ(12, 32))
|
||||
ITEM(Upp::Button, insert, SetLabel(t_("Insert")).LeftPosZ(4, 64).BottomPosZ(5, 24))
|
||||
END_LAYOUT
|
||||
|
||||
14
reference/FileTabsExample/FileTabsExample.upp
Normal file
14
reference/FileTabsExample/FileTabsExample.upp
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
description "TabBar and FileTabs example\377";
|
||||
|
||||
uses
|
||||
CtrlLib,
|
||||
TabBar;
|
||||
|
||||
file
|
||||
FileTabsExample.h,
|
||||
main.cpp,
|
||||
FileTabsExample.lay;
|
||||
|
||||
mainconfig
|
||||
"" = "GUI";
|
||||
|
||||
153
reference/FileTabsExample/main.cpp
Normal file
153
reference/FileTabsExample/main.cpp
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
#include "FileTabsExample.h"
|
||||
|
||||
#define FILE_LIMIT 5
|
||||
#define PACKAGE_LIMIT 5
|
||||
|
||||
FileTabsExample::FileTabsExample()
|
||||
{
|
||||
CtrlLayout(*this, "FileTabs Example");
|
||||
Sizeable().Zoomable();
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
bar[i].SetAlign((i+1) % 4);
|
||||
AddFrame(bar[0]);
|
||||
|
||||
bar[0].WhenAction << [=] { OnCursor(); };
|
||||
|
||||
addfile << [=] {
|
||||
if (!fileinput.GetLength()) return;
|
||||
for (int i = 0; i < 4; i++)
|
||||
bar[i].AddFile(~fileinput);
|
||||
};
|
||||
|
||||
insert << [=] {
|
||||
for(FindFile ff(GetHomeDirFile("*")); ff; ff++)
|
||||
for(int i = 0; i < 4; i++)
|
||||
bar[i].AddFile(ff.GetPath().ToWString());
|
||||
};
|
||||
|
||||
grouping << [=] {
|
||||
for (int i = 0; i < 4; i++)
|
||||
bar[i].Grouping(~grouping);
|
||||
};
|
||||
|
||||
groupsort << [=] {
|
||||
if(~groupsort)
|
||||
for (int i = 0; i < 4; i++)
|
||||
bar[i].SortGroups(true); //or specify own TabSort
|
||||
else
|
||||
for (int i = 0; i < 4; i++)
|
||||
bar[i].SortGroups(false);
|
||||
};
|
||||
|
||||
separators << [=] {
|
||||
for (int i = 0; i < 4; i++)
|
||||
bar[i].GroupSeparators(~separators);
|
||||
};
|
||||
|
||||
stacking << [=] {
|
||||
for (int i = 0; i < 4; i++)
|
||||
bar[i].Stacking(~stacking);
|
||||
};
|
||||
|
||||
normalicons ^= stackedicons ^= [=] {
|
||||
for (int i = 0; i < 4; i++)
|
||||
bar[i].FileIcons(~normalicons, ~stackedicons);
|
||||
};
|
||||
|
||||
prompt << [=] {
|
||||
if (prompt) {
|
||||
bar[0].ConfirmClose = [=](Value v) { return PromptOKCancel(Format("Close '\1%s\1'?", ~v)); };
|
||||
bar[0].ConfirmCloseAll = [=] { return PromptOKCancel("Close all tabs?"); };
|
||||
}
|
||||
else {
|
||||
bar[0].ConfirmClose.Clear();
|
||||
bar[0].ConfirmCloseAll.Clear();
|
||||
}
|
||||
};
|
||||
|
||||
allalign << [=] {
|
||||
if (allalign) {
|
||||
for (int i = 1; i < 4; i++)
|
||||
AddFrame(bar[i]);
|
||||
}
|
||||
else {
|
||||
for (int i = 0; i < 4; i++)
|
||||
bar[i].Remove();
|
||||
ClearFrames();
|
||||
AddFrame(bar[0]);
|
||||
}
|
||||
};
|
||||
|
||||
valuesort << [=] {
|
||||
keysort = false;
|
||||
if(~valuesort)
|
||||
for (int i = 0; i < 4; i++)
|
||||
bar[i].SortTabValues(vo);
|
||||
else
|
||||
for (int i = 0; i < 4; i++)
|
||||
bar[i].SortTabs(false);
|
||||
};
|
||||
|
||||
keysort << [=] {
|
||||
valuesort = false;
|
||||
if(~keysort)
|
||||
for (int i = 0; i < 4; i++)
|
||||
bar[i].SortTabKeys(vo);
|
||||
else
|
||||
for (int i = 0; i < 4; i++)
|
||||
bar[i].SortTabs(false);
|
||||
};
|
||||
|
||||
stacksort << [=] {
|
||||
if(~stacksort)
|
||||
for (int i = 0; i < 4; i++)
|
||||
bar[i].SortStacks(true);
|
||||
else
|
||||
for (int i = 0; i < 4; i++)
|
||||
bar[i].SortStacks(false);
|
||||
};
|
||||
|
||||
inactive << [=] {
|
||||
for (int i = 1; i < 4; i++)
|
||||
bar[i].InactiveDisabled(~inactive);
|
||||
};
|
||||
|
||||
grouping <<= true;
|
||||
inactive <<= true;
|
||||
normalicons <<= true;
|
||||
|
||||
insert.WhenAction();
|
||||
|
||||
OnCursor();
|
||||
}
|
||||
|
||||
void FileTabsExample::OnCursor()
|
||||
{
|
||||
if (bar[0].HasCursor())
|
||||
selection = (String)~bar[0];
|
||||
else
|
||||
selection = "No tab selected";
|
||||
}
|
||||
|
||||
bool FileTabsExample::Key(dword key, int count)
|
||||
{
|
||||
if (key == K_RETURN && fileinput.HasFocus()) {
|
||||
addfile.PseudoPush();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void FileTabsExample::DragAndDrop(Point p, PasteClip& d)
|
||||
{
|
||||
if (AcceptFiles(d))
|
||||
for (int i = 0; i < 4; i++)
|
||||
bar[i].AddFiles(GetFiles(d));
|
||||
}
|
||||
|
||||
GUI_APP_MAIN
|
||||
{
|
||||
FileTabsExample().Run();
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue