From 68a128a4d94691c158897481370d6e2e7e96fe45 Mon Sep 17 00:00:00 2001 From: cxl Date: Sun, 18 Sep 2011 09:12:31 +0000 Subject: [PATCH] CtrlCore: PasteClip GetFormat, refactored Get (now equals to Get(GetFormat()), documented git-svn-id: svn://ultimatepp.org/upp/trunk@3882 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/CtrlCore/CtrlClip.cpp | 13 +- uppsrc/CtrlCore/CtrlCore.h | 13 +- uppsrc/CtrlCore/Win32Clip.cpp | 4 +- uppsrc/CtrlCore/src.tpp/PasteClip$en-us.tpp | 162 +++++++++++++++++++ uppsrc/CtrlCore/src.tpp/PasteClip$en-us.tppi | 12 ++ uppsrc/CtrlCore/src.tpp/all.i | 4 + 6 files changed, 190 insertions(+), 18 deletions(-) create mode 100644 uppsrc/CtrlCore/src.tpp/PasteClip$en-us.tpp create mode 100644 uppsrc/CtrlCore/src.tpp/PasteClip$en-us.tppi create mode 100644 uppsrc/CtrlCore/src.tpp/all.i diff --git a/uppsrc/CtrlCore/CtrlClip.cpp b/uppsrc/CtrlCore/CtrlClip.cpp index e538d6d53..713b457cd 100644 --- a/uppsrc/CtrlCore/CtrlClip.cpp +++ b/uppsrc/CtrlCore/CtrlClip.cpp @@ -60,19 +60,12 @@ bool PasteClip::Accept() bool PasteClip::Accept(const char *_fmt) { Vector f = Split(_fmt, ';'); - for(int i = 0; i < f.GetCount(); i++) { - if(IsAccepted() && fmt == f[i]) - return paste; + for(int i = 0; i < f.GetCount(); i++) if(IsAvailable(f[i])) { accepted = true; - if(paste) { - fmt = f[i]; - data = Get(f[i]); - return true; - } - break; + fmt = f[i]; + return paste; } - } return false; } diff --git a/uppsrc/CtrlCore/CtrlCore.h b/uppsrc/CtrlCore/CtrlCore.h index 31e855108..5742f19bd 100644 --- a/uppsrc/CtrlCore/CtrlCore.h +++ b/uppsrc/CtrlCore/CtrlCore.h @@ -220,7 +220,6 @@ class PasteClip { bool paste; bool accepted; String fmt; - String data; void GuiPlatformConstruct(); @@ -229,12 +228,14 @@ public: String Get(const char *fmt) const; bool Accept(); - bool Accept(const char *fmt); - String Get() const { return data; } - operator String() const { return data; } - String operator ~() const { return data; } - void Reject() { accepted = false; data.Clear(); } + bool Accept(const char *fmt); + String GetFormat() { return fmt; } + String Get() const { return Get(fmt); } + operator String() const { return Get(); } + String operator ~() const { return Get(); } + + void Reject() { accepted = false; } int GetAction() const { return action; } int GetAllowedActions() const { return allowed; } diff --git a/uppsrc/CtrlCore/Win32Clip.cpp b/uppsrc/CtrlCore/Win32Clip.cpp index b6b7864c8..683f905ee 100644 --- a/uppsrc/CtrlCore/Win32Clip.cpp +++ b/uppsrc/CtrlCore/Win32Clip.cpp @@ -253,7 +253,7 @@ String GetString(PasteClip& clip) String s = ~clip; return WString((const wchar *)~s, wstrlen((const wchar *)~s)).ToString(); } - if(clip.IsAvailable("text")) + if(clip.Accept("text")) return ~clip; return Null; } @@ -265,7 +265,7 @@ WString GetWString(PasteClip& clip) String s = ~clip; return WString((const wchar *)~s, wstrlen((const wchar *)~s)); } - if(clip.IsAvailable("text")) + if(clip.Accept("text")) return (~clip).ToWString(); return Null; } diff --git a/uppsrc/CtrlCore/src.tpp/PasteClip$en-us.tpp b/uppsrc/CtrlCore/src.tpp/PasteClip$en-us.tpp new file mode 100644 index 000000000..7ea994e83 --- /dev/null +++ b/uppsrc/CtrlCore/src.tpp/PasteClip$en-us.tpp @@ -0,0 +1,162 @@ +topic "struct ClipData : public Moveable "; +[2 $$0,0#00000000000000000000000000000000:Default] +[i448;a25;kKO9;2 $$1,0#37138531426314131252341829483380:class] +[l288;2 $$2,2#27521748481378242620020725143825:desc] +[0 $$3,0#96390100711032703541132217272105:end] +[H6;0 $$4,0#05600065144404261032431302351956:begin] +[i448;a25;kKO9;2 $$5,0#37138531426314131252341829483370:item] +[l288;a4;*@5;1 $$6,6#70004532496200323422659154056402:requirement] +[l288;i1121;b17;O9;~~~.1408;2 $$7,0#10431211400427159095818037425705:param] +[i448;b42;O9;2 $$8,8#61672508125594000341940100500538:tparam] +[b42;2 $$9,9#13035079074754324216151401829390:normal] +[{_} +[ {{10000@(113.42.0) [s0; [*@7;4 ClipData]]}}&] +[s3; &] +[s1;:ClipData`:`:struct: [@(0.0.255)3 struct][3 _][*3 ClipData][3 _:_][@(0.0.255)3 public][3 _][*@3;3 M +oveable][3 <][*3 ClipData][3 >_]&] +[s0; &] +[s0;%% This structure represents single datatype assigned to clip +operation (clipboard or drag`&drop). The final data transfered +via clip has always to be binary string, but as usually application +provides multiple formats (e.g. it can provide .png, .jpg and +.gif form Image) and conversion of source to final format can +be expensive, ClipData allows to store the source data in original +format accompanied with `'rendering`' function used to convert +it to final format.&] +[s0; &] +[ {{10000F(128)G(128)@1 [s0;%% [* Public Members]]}}&] +[s3; &] +[s5;:ClipData`:`:data: [_^Value^ Value]_[* data]&] +[s2;%% Source data.&] +[s3;%% &] +[s4; &] +[s5;:ClipData`:`:render: [_^String^ String]_(`*[* render])([@(0.0.255) const]_Value[@(0.0.255) `& +]_data)&] +[s2;%% Function to convert source [* data] to binary string.&] +[s3; &] +[s4; &] +[s5;:ClipData`:`:Render`(`)const: [_^String^ String]_[* Render]()_[@(0.0.255) const]&] +[s2;%% Equivalent to (`*render)(data).&] +[s3; &] +[ {{10000F(128)G(128)@1 [s0;%% [* Constructor detail]]}}&] +[s4; &] +[s5;:ClipData`:`:ClipData`(const Value`&`,String`(`*`)`(const Value`&`)`): [* ClipData]( +[@(0.0.255) const]_[_^Value^ Value][@(0.0.255) `&]_[*@3 data], [_^String^ String]_(`*[*@3 ren +der])([@(0.0.255) const]_Value[@(0.0.255) `&]_[*@3 data]))&] +[s2;%% Assigns [%-*@3 data] and [%-*@3 render] to respective member variables.&] +[s3;%% &] +[s4; &] +[s5;:ClipData`:`:ClipData`(const String`&`): [* ClipData]([@(0.0.255) const]_[_^String^ Str +ing][@(0.0.255) `&]_[*@3 data])&] +[s2;%% Assigns [%-*@3 data].to [* data ]and trivial `"string to string`" +(no conversion) rendering function to [* render.]&] +[s3;%% &] +[s4; &] +[s5;:ClipData`:`:ClipData`(`): [* ClipData]()&] +[s2;%% Assigns trivial `"string to string`" (no conversion) rendering +function to [* render.]&] +[s3; &] +[s1;@(0.0.255)3 &] +[s0; &] +[ {{10000@(113.42.0) [s0; [*@7;4 ClipData]]}}&] +[s0; &] +[s1;:PasteClip`:`:class: [@(0.0.255)3 class][3 _][*3 PasteClip]&] +[s2;%% This class represents data source and operation status in +clipboard or drag and drop operations (and also in X11 selection +operations).&] +[s3; &] +[s0;%% &] +[ {{10000F(128)G(128)@1 [s0;%% [* Public Member List]]}}&] +[s0; &] +[s5;:PasteClip`:`:IsAvailable`(const char`*`)const: [@(0.0.255) bool]_[* IsAvailable]([@(0.0.255) c +onst]_[@(0.0.255) char]_`*[*@3 fmt])_[@(0.0.255) const]&] +[s2;%% Returns true when data source offers data in format [%-*@3 fmt].&] +[s3;%% &] +[s4; &] +[s5;:PasteClip`:`:Get`(const char`*`)const: [_^String^ String]_[* Get]([@(0.0.255) const]_[@(0.0.255) c +har]_`*[*@3 fmt])_[@(0.0.255) const]&] +[s2;%% Returns binary data rendered in [%-*@3 fmt].&] +[s3;%% &] +[s4; &] +[s5;:PasteClip`:`:Accept`(`): [@(0.0.255) bool]_[* Accept]()&] +[s2;%% Sets the status of operation to accepted (target accepts data) +and returns true when target should [/ paste ]the source data into +target `- during drag`&drop operation, it returns false during +`'drag`' phase to alter appearance of mouse cursor (it should +show `'stop`' sign when drop is not possible) and `'true`' to +indicate drop operation.&] +[s3; &] +[s4; &] +[s5;:PasteClip`:`:Accept`(const char`*`): [@(0.0.255) bool]_[* Accept]([@(0.0.255) const]_[@(0.0.255) c +har]_`*[*@3 fmt])&] +[s2;%% Parameter [%-*@3 fmt] contains a list of format identifiers +separated by semicolon. If any of them is available in the PasteClip, +it is set to accepted status and accepted format is stored in +PasteClip (to be retrieved by GetFormat method later). If PasteClip +is in paste mode, method returns true. Note that Accept can return +false even if format is accepted `- this happens in `'drag`' +stage of drag`&drop operation to indicate that target is willing +to accept the data.&] +[s3;%% &] +[s4; &] +[s5;:PasteClip`:`:GetFormat`(`): [_^String^ String]_[* GetFormat]()&] +[s2;%% Returns a format accepted by the last Accept(fmt) method.&] +[s3; &] +[s4; &] +[s5;:PasteClip`:`:Get`(`)const: [_^String^ String]_[* Get]()_[@(0.0.255) const]&] +[s2;%% Same as Get(GetFormat()).&] +[s3; &] +[s4; &] +[s5;:PasteClip`:`:operator String`(`)const: [* operator_String]()_[@(0.0.255) const]&] +[s2;%% Same as Get().&] +[s3; &] +[s4; &] +[s5;:PasteClip`:`:operator`~`(`)const: [_^String^ String]_[@(0.0.255) operator]_`~()_[@(0.0.255) c +onst]&] +[s2;%% Same as Get().&] +[s3; &] +[s4; &] +[s5;:PasteClip`:`:Reject`(`): [@(0.0.255) void]_[* Reject]()&] +[s2;%% Sets PasteClip to rejected status. This can be called after +setting it to accepted status to revert the decision. Usually +this is used when decision has to take into account the content +of actual data to be pasted `- in that case data is Accepted +first, then after examination of data content, it can be rejected.&] +[s3; &] +[s4; &] +[s5;:PasteClip`:`:GetAction`(`)const: [@(0.0.255) int]_[* GetAction]()_[@(0.0.255) const]&] +[s2;%% Gets the proposed action of drag`&drop operation (one of DND`_COPY, +DND`_MOVE).&] +[s3; &] +[s4; &] +[s5;:PasteClip`:`:GetAllowedActions`(`)const: [@(0.0.255) int]_[* GetAllowedActions]()_[@(0.0.255) c +onst]&] +[s2;%% Returns the bitmask of allowed operations of drag`&drop operation +(DND`_COPY, DND`_MOVE).&] +[s3; &] +[s4; &] +[s5;:PasteClip`:`:SetAction`(int`): [@(0.0.255) void]_[* SetAction]([@(0.0.255) int]_[*@3 x]) +&] +[s2;%% Changes drop operation to [%-*@3 x]. This is used when proposed +operation is no suitable for particular drop target.&] +[s3;%% &] +[s4; &] +[s5;:PasteClip`:`:IsAccepted`(`)const: [@(0.0.255) bool]_[* IsAccepted]()_[@(0.0.255) const +]&] +[s2;%% Returns true if status is accepted.&] +[s3; &] +[s4; &] +[s5;:PasteClip`:`:IsQuery`(`)const: [@(0.0.255) bool]_[* IsQuery]()_[@(0.0.255) const]&] +[s2;%% Returns true if PasteClip represents drag phase (no pasting, +Accept returns false).&] +[s3; &] +[s4; &] +[s5;:PasteClip`:`:IsPaste`(`)const: [@(0.0.255) bool]_[* IsPaste]()_[@(0.0.255) const]&] +[s2;%% Returns true if PasteClip represents drop/paste phase (Accept +returns true).&] +[s3; &] +[s4; &] +[s5;:PasteClip`:`:PasteClip`(`): [* PasteClip]()&] +[s2;%% Default constructor.&] +[s3; &] +[s0;%% ] \ No newline at end of file diff --git a/uppsrc/CtrlCore/src.tpp/PasteClip$en-us.tppi b/uppsrc/CtrlCore/src.tpp/PasteClip$en-us.tppi new file mode 100644 index 000000000..745e8b9ef --- /dev/null +++ b/uppsrc/CtrlCore/src.tpp/PasteClip$en-us.tppi @@ -0,0 +1,12 @@ +TITLE("struct ClipData : public Moveable ") +COMPRESSED +120,156,181,89,11,111,219,70,18,254,43,139,186,177,37,67,101,249,212,243,112,112,144,52,57,227,46,77,26,247,138,59,8,140,184,162,86,210,54,20,201,114,151,114,140,32,254,237,55,179,187,124,232,97,91,62,180,129,97,201,203,217,217,249,102,190,121,44,51,117,201,247,223,219,61,251,204,126,226,223,248,53,91,210,50,145,225,148,251,254,112,66,221,96,242,249,159,239,71,19,220,239,192,126,111,224,120,195,192,115,124,183,15,191,28,207,113,3,215,243,157,161,59,242,135,158,55,180,199,113,66,133,8,167,137,59,28,170,77,110,207,61,115,7,129,235,12,252,161,63,116,188,193,208,133,189,174,109,187,246,192,13,28,223,27,186,193,120,193,68,28,78,109,16,247,224,140,81,223,27,217,142,109,15,28,199,246,220,129,237,5,190,227,120,46,168,112,7,174,99,7,99,150,46,194,233,63,250,19,220,224,35,168,160,15,166,247,65,155,239,219,160,29,183,249,158,227,217,174,23,56,163,160,63,158,179,21,79,143,65,10,158,132,52,176,199,92,178,141,65,68,253,201,229,85,48, +113,96,107,191,215,63,27,192,177,126,0,135,141,16,145,7,219,92,183,31,140,156,192,7,147,124,219,29,23,236,143,146,23,108,195,82,105,52,112,199,113,157,201,220,25,76,192,132,251,251,123,203,241,109,237,169,1,216,226,216,96,183,235,192,26,224,24,56,193,200,30,5,67,103,104,123,3,223,13,6,0,61,167,5,221,24,36,115,223,157,24,28,195,222,240,172,239,244,193,163,246,16,236,15,70,160,192,6,16,240,9,142,12,224,199,27,142,165,217,140,251,112,211,168,55,58,3,39,121,129,61,24,217,3,127,16,248,128,196,117,250,14,56,210,70,252,16,134,113,154,21,27,154,132,211,175,179,111,100,74,190,126,117,144,37,87,29,8,136,229,187,150,221,37,83,97,79,200,244,242,106,48,241,201,171,132,231,175,169,164,97,248,237,219,121,56,21,222,132,224,135,51,25,87,79,162,113,52,22,178,40,99,57,38,211,171,142,109,217,22,152,219,245,136,94,12,167,30,153,133,211,75,175,81,133,43,99,88,107,11,231,229,60,225,113,37,124,229,77,60,242,46,219,50,58,79, +24,46,254,237,64,195,223,103,33,26,98,107,123,236,201,139,23,228,215,53,23,230,212,178,96,164,96,121,193,4,196,9,22,121,186,74,24,89,192,94,121,151,51,2,132,230,171,148,45,136,204,72,12,74,73,150,179,130,74,158,165,164,131,127,207,51,90,44,72,86,144,69,65,87,209,249,162,200,242,174,5,250,25,89,242,148,38,74,17,145,5,77,197,146,21,160,102,203,169,214,179,166,130,208,228,150,222,9,84,61,103,100,14,242,197,29,90,5,38,244,200,188,148,112,56,41,69,73,147,228,142,208,60,7,212,250,224,188,200,182,28,210,134,108,32,89,121,14,230,46,49,80,96,125,135,89,43,139,112,73,98,90,139,17,43,71,125,214,239,249,138,208,116,65,172,21,95,170,13,228,122,67,87,172,171,22,227,44,221,178,66,160,246,108,73,68,86,22,49,67,187,52,8,173,94,41,5,67,217,151,156,165,130,111,89,175,118,51,32,73,178,91,133,68,200,12,60,42,193,1,70,139,242,0,7,189,5,95,181,181,209,56,206,54,57,77,57,120,229,150,203,53,137,46,10,72, +110,134,240,163,11,178,44,211,88,161,45,133,241,190,50,81,34,186,61,195,172,38,188,21,73,223,116,28,119,216,125,171,126,95,57,196,132,125,122,73,62,40,246,144,119,108,51,7,188,123,92,13,118,185,138,150,3,83,103,159,126,163,73,201,62,17,245,17,206,64,11,62,81,164,114,81,237,77,3,212,210,218,96,17,191,248,71,213,106,148,74,241,141,10,246,39,162,63,195,89,39,186,4,237,90,32,236,118,90,188,71,248,66,134,51,101,67,123,61,58,15,103,120,114,183,54,231,77,229,185,150,211,76,44,42,211,21,229,218,124,179,90,94,56,110,245,71,101,84,212,137,186,202,146,163,230,131,122,45,22,118,186,179,67,227,107,11,127,130,194,184,165,9,36,28,26,2,160,53,226,110,71,1,105,217,242,100,56,95,161,98,76,99,204,64,38,41,79,170,144,30,71,81,127,239,40,147,116,72,163,243,168,167,33,0,188,203,168,187,255,176,27,117,199,234,176,170,168,28,11,204,62,77,246,99,132,165,74,59,191,247,96,228,65,226,217,177,111,244,118,27,10,188,84,85,75, +144,233,139,31,234,199,42,207,205,130,57,5,189,15,133,47,103,192,151,45,35,27,149,20,100,75,11,142,213,84,156,66,230,125,135,26,63,158,159,232,178,61,55,60,2,238,81,108,22,0,49,220,38,33,226,4,117,80,105,19,18,125,167,249,173,43,147,50,237,59,210,73,179,86,193,235,146,186,236,52,69,71,235,211,15,172,240,89,126,56,64,126,104,250,95,97,157,105,182,237,78,121,88,22,79,237,221,118,221,187,63,80,33,25,62,70,144,106,190,219,235,221,102,230,171,90,119,45,223,100,187,106,182,74,172,221,104,85,172,76,89,194,136,53,125,85,64,235,45,5,182,140,131,6,171,36,177,199,54,226,208,244,112,145,38,34,195,45,255,113,28,34,88,194,180,163,26,169,118,85,209,213,227,217,221,130,252,139,3,107,119,61,20,236,121,232,90,188,220,66,17,194,244,169,50,34,94,211,2,171,74,85,54,91,20,159,103,89,162,170,102,107,219,241,76,105,47,129,190,112,102,202,197,114,35,195,71,75,237,71,6,19,142,162,92,201,200,237,154,165,59,142,207,150,48,149, +136,186,69,155,206,108,50,11,117,63,84,2,118,64,191,101,242,33,176,71,123,4,200,255,69,40,77,79,83,120,116,122,192,236,0,192,158,139,232,101,28,179,92,154,92,62,22,48,45,208,206,237,27,6,164,86,99,143,166,47,140,81,13,165,33,97,169,218,1,230,116,36,45,86,76,154,5,237,124,61,132,21,7,177,50,162,98,157,149,9,20,239,31,73,142,86,146,240,112,188,130,19,140,112,244,3,89,148,170,94,52,35,105,99,74,15,231,167,234,160,37,100,13,171,164,163,11,37,127,65,114,24,77,213,240,71,19,9,172,135,201,147,193,221,33,85,116,33,155,12,230,49,18,151,133,128,148,236,240,218,54,248,184,5,21,48,253,229,160,2,203,156,97,27,158,14,249,159,102,146,228,25,212,63,160,184,70,27,93,32,78,16,150,152,184,11,28,110,217,94,110,31,159,74,142,70,106,151,126,79,68,237,217,220,171,163,252,1,111,81,12,221,210,162,20,234,128,209,3,28,74,73,2,53,2,253,100,82,9,230,239,84,242,37,199,44,19,12,239,96,72,129,57,140,93,108, +195,227,44,1,140,228,122,9,254,184,195,77,16,214,13,58,139,86,197,0,185,139,177,174,33,171,240,225,221,133,201,29,82,25,210,169,74,88,173,85,38,8,61,147,171,68,168,21,1,13,213,173,3,168,80,112,182,213,70,65,98,190,209,155,0,227,58,91,144,4,204,45,186,202,196,102,39,87,181,89,51,113,147,45,224,26,96,164,219,252,181,200,207,153,196,123,0,40,211,110,87,215,7,45,98,136,7,199,166,132,47,91,134,214,182,3,137,37,182,141,53,178,47,85,7,214,252,4,172,43,197,197,99,252,222,97,147,58,221,164,5,40,187,229,73,98,186,173,62,72,249,246,177,177,125,191,204,105,239,152,186,240,80,109,211,66,237,218,80,149,39,218,186,251,104,156,224,116,180,1,154,99,229,166,14,48,170,107,60,122,2,255,85,237,61,165,222,62,90,63,111,128,212,120,219,4,201,78,141,160,211,237,158,96,128,246,60,20,131,122,130,174,141,185,36,213,195,153,177,230,116,43,158,115,116,116,255,132,11,90,71,86,123,32,191,239,255,92,107,62,178,223,97,234,56,236, +25,219,140,47,204,213,8,5,14,122,70,147,88,106,26,71,153,58,161,45,51,60,233,139,119,12,183,108,120,68,151,88,127,160,2,72,36,51,63,90,8,148,42,117,243,83,20,103,49,199,97,210,34,255,54,175,19,84,114,113,161,47,215,186,80,27,25,245,98,66,117,147,207,76,247,21,188,168,151,169,214,132,149,14,175,109,144,125,52,150,101,253,130,67,213,18,85,18,84,238,170,178,165,222,24,136,170,67,9,195,111,44,76,188,16,178,135,250,82,3,134,125,161,27,104,221,210,188,127,80,59,204,81,189,234,117,134,42,86,218,59,167,229,197,75,53,3,182,169,209,138,10,32,171,114,67,203,61,193,205,183,85,123,207,161,220,100,232,53,26,215,230,30,171,67,157,44,85,69,234,245,207,175,163,217,171,247,31,254,219,211,95,223,189,255,237,167,83,232,132,134,225,75,21,182,208,246,137,19,128,236,200,63,1,168,30,12,215,248,234,73,110,168,248,172,162,170,117,180,231,235,7,17,254,191,208,110,154,216,128,245,15,230,203,77,19,154,35,128,161,247,126,105,53,230,87, +107,154,174,152,32,135,221,192,52,234,47,161,73,166,29,214,215,209,108,182,168,97,133,136,146,75,213,129,161,98,3,177,11,201,227,50,161,133,214,175,91,202,73,77,3,38,123,67,251,7,226,215,190,3,24,201,83,35,135,99,34,180,207,234,190,212,180,207,19,98,112,45,126,41,89,113,247,180,81,74,236,153,22,53,37,173,125,225,195,251,155,158,45,241,138,139,197,66,189,232,52,211,193,206,76,122,10,139,174,133,250,243,105,4,74,236,207,65,144,229,63,234,185,199,224,216,179,29,119,159,98,122,243,71,245,182,160,185,54,183,218,131,249,239,24,109,171,126,201,117,112,139,13,255,7,121,222,65,51, + diff --git a/uppsrc/CtrlCore/src.tpp/all.i b/uppsrc/CtrlCore/src.tpp/all.i new file mode 100644 index 000000000..2290e78c4 --- /dev/null +++ b/uppsrc/CtrlCore/src.tpp/all.i @@ -0,0 +1,4 @@ +TOPIC("PasteClip$en-us") +#include "PasteClip$en-us.tppi" +END_TOPIC +