Skip to content

Commit

Permalink
Cargo doc auto deployment 2024-03-30 12:21:59.
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigocfd committed Mar 30, 2024
1 parent 00dca89 commit d2445f1
Show file tree
Hide file tree
Showing 30 changed files with 345 additions and 145 deletions.
2 changes: 1 addition & 1 deletion search-index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/winsafe/gui/events/tree_view_events.rs.html
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>
/// let wnd: gui::WindowMain; // initialized somewhere
/// let tree: gui::TreeView;
/// # let wnd = gui::WindowMain::new(gui::WindowMainOpts::default());
/// # let tree = gui::TreeView::new(&amp;wnd, gui::TreeViewOpts::default());
/// # let tree = gui::TreeView::&lt;()&gt;::new(&amp;wnd, gui::TreeViewOpts::default());
///
/// tree.on().tvn_sel_changed(
/// move |p: &amp;w::NMTREEVIEW| -&gt; w::AnyResult&lt;()&gt; {
Expand Down
2 changes: 1 addition & 1 deletion src/winsafe/gui/gui_traits.rs.html
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>

<span class="doccomment">/// A closeable popup parent window.
</span><span class="kw">pub trait </span>GuiParentPopup: GuiParent {
<span class="doccomment">/// Closes the window by posting a [`wm::close`](crate::msg::wm::Close)
<span class="doccomment">/// Closes the window by posting a [`WM_CLOSE`](crate::msg::wm::Close)
/// message. This is the safest way to close any popup window, because
/// you're able to process the
/// [`wm_close`](crate::prelude::GuiEvents::wm_close) event, just like if
Expand Down
38 changes: 19 additions & 19 deletions src/winsafe/gui/native_controls/iterators.rs.html
Original file line number Diff line number Diff line change
Expand Up @@ -737,14 +737,14 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>

<span class="comment">//------------------------------------------------------------------------------

</span><span class="kw">pub</span>(<span class="kw">in </span><span class="kw">crate</span>::gui) <span class="kw">struct </span>TreeViewItemIter&lt;<span class="lifetime">'a</span>&gt; {
owner: <span class="kw-2">&amp;</span><span class="lifetime">'a </span>TreeView,
current: <span class="prelude-ty">Option</span>&lt;TreeViewItem&lt;<span class="lifetime">'a</span>&gt;&gt;,
</span><span class="kw">pub</span>(<span class="kw">in </span><span class="kw">crate</span>::gui) <span class="kw">struct </span>TreeViewItemIter&lt;<span class="lifetime">'a</span>, T: <span class="lifetime">'static</span>&gt; {
owner: <span class="kw-2">&amp;</span><span class="lifetime">'a </span>TreeView&lt;T&gt;,
current: <span class="prelude-ty">Option</span>&lt;TreeViewItem&lt;<span class="lifetime">'a</span>, T&gt;&gt;,
relationship: co::TVGN,
}

<span class="kw">impl</span>&lt;<span class="lifetime">'a</span>&gt; Iterator <span class="kw">for </span>TreeViewItemIter&lt;<span class="lifetime">'a</span>&gt; {
<span class="kw">type </span>Item = TreeViewItem&lt;<span class="lifetime">'a</span>&gt;;
<span class="kw">impl</span>&lt;<span class="lifetime">'a</span>, T&gt; Iterator <span class="kw">for </span>TreeViewItemIter&lt;<span class="lifetime">'a</span>, T&gt; {
<span class="kw">type </span>Item = TreeViewItem&lt;<span class="lifetime">'a</span>, T&gt;;

<span class="kw">fn </span>next(<span class="kw-2">&amp;mut </span><span class="self">self</span>) -&gt; <span class="prelude-ty">Option</span>&lt;<span class="self">Self</span>::Item&gt; {
<span class="self">self</span>.current = <span class="kw">unsafe </span>{
Expand All @@ -753,7 +753,7 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>
relationship: <span class="self">self</span>.relationship,
hitem: <span class="self">self</span>.current.as_ref().map(|tvi| tvi.htreeitem()),
})
}.map(|hitem| <span class="self">self</span>.owner.items().get(hitem));
}.map(|hitem| <span class="self">self</span>.owner.items().get(<span class="kw-2">&amp;</span>hitem));

<span class="self">self</span>.current.as_ref()
.map(|tvi| TreeViewItem::new(
Expand All @@ -763,10 +763,10 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>
}
}

<span class="kw">impl</span>&lt;<span class="lifetime">'a</span>&gt; TreeViewItemIter&lt;<span class="lifetime">'a</span>&gt; {
<span class="kw">impl</span>&lt;<span class="lifetime">'a</span>, T&gt; TreeViewItemIter&lt;<span class="lifetime">'a</span>, T&gt; {
<span class="kw">pub</span>(<span class="kw">in </span><span class="kw">crate</span>::gui) <span class="kw">const fn </span>new(
owner: <span class="kw-2">&amp;</span><span class="lifetime">'a </span>TreeView,
current: <span class="prelude-ty">Option</span>&lt;TreeViewItem&lt;<span class="lifetime">'a</span>&gt;&gt;,
owner: <span class="kw-2">&amp;</span><span class="lifetime">'a </span>TreeView&lt;T&gt;,
current: <span class="prelude-ty">Option</span>&lt;TreeViewItem&lt;<span class="lifetime">'a</span>, T&gt;&gt;,
relationship: co::TVGN,
) -&gt; <span class="self">Self
</span>{
Expand All @@ -776,14 +776,14 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>

<span class="comment">//------------------------------------------------------------------------------

</span><span class="kw">pub</span>(<span class="kw">in </span><span class="kw">crate</span>::gui) <span class="kw">struct </span>TreeViewChildItemIter&lt;<span class="lifetime">'a</span>&gt; {
owner: <span class="kw-2">&amp;</span><span class="lifetime">'a </span>TreeView,
current: <span class="prelude-ty">Option</span>&lt;TreeViewItem&lt;<span class="lifetime">'a</span>&gt;&gt;,
</span><span class="kw">pub</span>(<span class="kw">in </span><span class="kw">crate</span>::gui) <span class="kw">struct </span>TreeViewChildItemIter&lt;<span class="lifetime">'a</span>, T: <span class="lifetime">'static</span>&gt; {
owner: <span class="kw-2">&amp;</span><span class="lifetime">'a </span>TreeView&lt;T&gt;,
current: <span class="prelude-ty">Option</span>&lt;TreeViewItem&lt;<span class="lifetime">'a</span>, T&gt;&gt;,
first_call: bool,
}

<span class="kw">impl</span>&lt;<span class="lifetime">'a</span>&gt; Iterator <span class="kw">for </span>TreeViewChildItemIter&lt;<span class="lifetime">'a</span>&gt; {
<span class="kw">type </span>Item = TreeViewItem&lt;<span class="lifetime">'a</span>&gt;;
<span class="kw">impl</span>&lt;<span class="lifetime">'a</span>, T&gt; Iterator <span class="kw">for </span>TreeViewChildItemIter&lt;<span class="lifetime">'a</span>, T&gt; {
<span class="kw">type </span>Item = TreeViewItem&lt;<span class="lifetime">'a</span>, T&gt;;

<span class="kw">fn </span>next(<span class="kw-2">&amp;mut </span><span class="self">self</span>) -&gt; <span class="prelude-ty">Option</span>&lt;<span class="self">Self</span>::Item&gt; {
<span class="kw">if </span><span class="self">self</span>.first_call { <span class="comment">// search for the first child
Expand All @@ -793,7 +793,7 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>
relationship: co::TVGN::CHILD,
hitem: <span class="self">self</span>.current.as_ref().map(|tvi| tvi.htreeitem()),
})
}.map(|hitem| <span class="self">self</span>.owner.items().get(hitem));
}.map(|hitem| <span class="self">self</span>.owner.items().get(<span class="kw-2">&amp;</span>hitem));

<span class="self">self</span>.first_call = <span class="bool-val">false</span>;

Expand All @@ -804,7 +804,7 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>
relationship: co::TVGN::NEXT,
hitem: <span class="self">self</span>.current.as_ref().map(|tvi| tvi.htreeitem()),
})
}.map(|hitem| <span class="self">self</span>.owner.items().get(hitem));
}.map(|hitem| <span class="self">self</span>.owner.items().get(<span class="kw-2">&amp;</span>hitem));
}

<span class="self">self</span>.current.as_ref()
Expand All @@ -815,10 +815,10 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>
}
}

<span class="kw">impl</span>&lt;<span class="lifetime">'a</span>&gt; TreeViewChildItemIter&lt;<span class="lifetime">'a</span>&gt; {
<span class="kw">impl</span>&lt;<span class="lifetime">'a</span>, T&gt; TreeViewChildItemIter&lt;<span class="lifetime">'a</span>, T&gt; {
<span class="kw">pub</span>(<span class="kw">in </span><span class="kw">crate</span>::gui) <span class="kw">fn </span>new(
owner: <span class="kw-2">&amp;</span><span class="lifetime">'a </span>TreeView,
current: <span class="prelude-ty">Option</span>&lt;TreeViewItem&lt;<span class="lifetime">'a</span>&gt;&gt;,
owner: <span class="kw-2">&amp;</span><span class="lifetime">'a </span>TreeView&lt;T&gt;,
current: <span class="prelude-ty">Option</span>&lt;TreeViewItem&lt;<span class="lifetime">'a</span>, T&gt;&gt;,
) -&gt; <span class="self">Self
</span>{
<span class="self">Self </span>{
Expand Down
14 changes: 8 additions & 6 deletions src/winsafe/gui/native_controls/list_view_items.rs.html
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>
<a href="#295" id="295">295</a>
<a href="#296" id="296">296</a>
<a href="#297" id="297">297</a>
<a href="#298" id="298">298</a>
</pre></div><pre class="rust"><code><span class="kw">use </span>std::any::TypeId;
<span class="kw">use </span>std::cell::RefCell;
<span class="kw">use </span>std::rc::Rc;
Expand Down Expand Up @@ -363,19 +364,20 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>
}

<span class="kw">let </span><span class="kw-2">mut </span>lvi = LVITEM::default();
lvi.mask = co::LVIF::TEXT | co::LVIF::PARAM;
lvi.iItem = <span class="number">0x0fff_ffff</span>; <span class="comment">// insert as the last item
</span>lvi.mask = co::LVIF::TEXT;

</span><span class="kw">if let </span><span class="prelude-val">Some</span>(icon_index) = icon_index { <span class="comment">// will it have an icon?
<span class="kw">let </span><span class="kw-2">mut </span>wtext = WString::from_str(texts[<span class="number">0</span>].as_ref()); <span class="comment">// text of 1st column
</span>lvi.set_pszText(<span class="prelude-val">Some</span>(<span class="kw-2">&amp;mut </span>wtext));

<span class="kw">if let </span><span class="prelude-val">Some</span>(icon_index) = icon_index { <span class="comment">// will it have an icon?
</span>lvi.mask |= co::LVIF::IMAGE;
lvi.iImage = icon_index <span class="kw">as _</span>;
}

<span class="kw">let </span><span class="kw-2">mut </span>wtext = WString::from_str(texts[<span class="number">0</span>].as_ref()); <span class="comment">// text of 1st column
</span>lvi.set_pszText(<span class="prelude-val">Some</span>(<span class="kw-2">&amp;mut </span>wtext));

<span class="kw">if </span>TypeId::of::&lt;T&gt;() != TypeId::of::&lt;()&gt;() { <span class="comment">// user defined an actual type?
</span><span class="kw">let </span>rc_data = Rc::new(RefCell::new(data));
</span>lvi.mask |= co::LVIF::PARAM;
<span class="kw">let </span>rc_data = Rc::new(RefCell::new(data));
lvi.lParam = Rc::into_raw(rc_data) <span class="kw">as _</span>;
}

Expand Down
86 changes: 73 additions & 13 deletions src/winsafe/gui/native_controls/tree_view.rs.html
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,40 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>
<a href="#255" id="255">255</a>
<a href="#256" id="256">256</a>
<a href="#257" id="257">257</a>
<a href="#258" id="258">258</a>
<a href="#259" id="259">259</a>
<a href="#260" id="260">260</a>
<a href="#261" id="261">261</a>
<a href="#262" id="262">262</a>
<a href="#263" id="263">263</a>
<a href="#264" id="264">264</a>
<a href="#265" id="265">265</a>
<a href="#266" id="266">266</a>
<a href="#267" id="267">267</a>
<a href="#268" id="268">268</a>
<a href="#269" id="269">269</a>
<a href="#270" id="270">270</a>
<a href="#271" id="271">271</a>
<a href="#272" id="272">272</a>
<a href="#273" id="273">273</a>
<a href="#274" id="274">274</a>
<a href="#275" id="275">275</a>
<a href="#276" id="276">276</a>
<a href="#277" id="277">277</a>
<a href="#278" id="278">278</a>
<a href="#279" id="279">279</a>
<a href="#280" id="280">280</a>
<a href="#281" id="281">281</a>
<a href="#282" id="282">282</a>
<a href="#283" id="283">283</a>
<a href="#284" id="284">284</a>
<a href="#285" id="285">285</a>
<a href="#286" id="286">286</a>
<a href="#287" id="287">287</a>
</pre></div><pre class="rust"><code><span class="kw">use </span>std::any::Any;
<span class="kw">use </span>std::marker::PhantomPinned;
<span class="kw">use </span>std::marker::{PhantomData, PhantomPinned};
<span class="kw">use </span>std::pin::Pin;
<span class="kw">use </span>std::rc::Rc;
<span class="kw">use </span>std::sync::Arc;

<span class="kw">use </span><span class="kw">crate</span>::co;
Expand All @@ -268,29 +299,40 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>
<span class="kw">use </span><span class="kw">crate</span>::msg::<span class="kw-2">*</span>;
<span class="kw">use </span><span class="kw">crate</span>::prelude::<span class="kw-2">*</span>;

<span class="kw">struct </span>Obj { <span class="comment">// actual fields of TreeView
<span class="kw">struct </span>Obj&lt;T&gt; { <span class="comment">// actual fields of TreeView
</span>base: BaseNativeControl,
events: TreeViewEvents,
_pin: PhantomPinned,
_data: PhantomData&lt;T&gt;,
}

<span class="comment">//------------------------------------------------------------------------------

</span><span class="doccomment">/// Native
/// [tree view](https://learn.microsoft.com/en-us/windows/win32/controls/tree-view-controls)
/// control.
</span><span class="attr">#[derive(Clone)]
</span><span class="kw">pub struct </span>TreeView(Pin&lt;Arc&lt;Obj&gt;&gt;);
///
/// The generic parameter specifies the type of the object that will be embedded
/// on each item – if you don't want to store anything, just use `()` as the
/// type. Internally, this storage is implemented with pointers in the item's
/// `LPARAM` fields.
</span><span class="kw">pub struct </span>TreeView&lt;T: <span class="lifetime">'static </span>= ()&gt;(Pin&lt;Arc&lt;Obj&lt;T&gt;&gt;&gt;);

<span class="kw">unsafe impl </span>Send <span class="kw">for </span>TreeView {}
<span class="kw">impl</span>&lt;T&gt; Clone <span class="kw">for </span>TreeView&lt;T&gt; { <span class="comment">// https://stackoverflow.com/q/39415052/6923555
</span><span class="kw">fn </span>clone(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="self">Self </span>{
<span class="self">Self</span>(<span class="self">self</span>.<span class="number">0</span>.clone())
}
}

<span class="kw">impl </span>AsRef&lt;BaseNativeControl&gt; <span class="kw">for </span>TreeView {
<span class="kw">unsafe impl</span>&lt;T&gt; Send <span class="kw">for </span>TreeView&lt;T&gt; {}

<span class="kw">impl</span>&lt;T&gt; AsRef&lt;BaseNativeControl&gt; <span class="kw">for </span>TreeView&lt;T&gt; {
<span class="kw">fn </span>as_ref(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="kw-2">&amp;</span>BaseNativeControl {
<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="number">0</span>.base
}
}

<span class="kw">impl </span>GuiWindow <span class="kw">for </span>TreeView {
<span class="kw">impl</span>&lt;T&gt; GuiWindow <span class="kw">for </span>TreeView&lt;T&gt; {
<span class="kw">fn </span>hwnd(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="kw-2">&amp;</span>HWND {
<span class="self">self</span>.<span class="number">0</span>.base.hwnd()
}
Expand All @@ -300,17 +342,17 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>
</span>}
}

<span class="kw">impl </span>GuiChild <span class="kw">for </span>TreeView {
<span class="kw">impl</span>&lt;T&gt; GuiChild <span class="kw">for </span>TreeView&lt;T&gt; {
<span class="kw">fn </span>ctrl_id(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; u16 {
<span class="self">self</span>.<span class="number">0</span>.base.ctrl_id()
}
}

<span class="kw">impl </span>GuiChildFocus <span class="kw">for </span>TreeView {}
<span class="kw">impl</span>&lt;T&gt; GuiChildFocus <span class="kw">for </span>TreeView&lt;T&gt; {}

<span class="kw">impl </span>GuiNativeControl <span class="kw">for </span>TreeView {}
<span class="kw">impl</span>&lt;T&gt; GuiNativeControl <span class="kw">for </span>TreeView&lt;T&gt; {}

<span class="kw">impl </span>GuiNativeControlEvents&lt;TreeViewEvents&gt; <span class="kw">for </span>TreeView {
<span class="kw">impl</span>&lt;T&gt; GuiNativeControlEvents&lt;TreeViewEvents&gt; <span class="kw">for </span>TreeView&lt;T&gt; {
<span class="kw">fn </span>on(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; <span class="kw-2">&amp;</span>TreeViewEvents {
<span class="kw">if </span><span class="kw-2">*</span><span class="self">self</span>.hwnd() != HWND::NULL {
<span class="macro">panic!</span>(<span class="string">"Cannot add events after the control creation."</span>);
Expand All @@ -321,7 +363,7 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>
}
}

<span class="kw">impl </span>TreeView {
<span class="kw">impl</span>&lt;T&gt; TreeView&lt;T&gt; {
<span class="doccomment">/// Instantiates a new `TreeView` object, to be created on the parent window
/// with
/// [`HWND::CreateWindowEx`](crate::prelude::user_Hwnd::CreateWindowEx).
Expand All @@ -341,6 +383,7 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>
base: BaseNativeControl::new(parent, ctrl_id),
events: TreeViewEvents::new(parent, ctrl_id),
_pin: PhantomPinned,
_data: PhantomData,
},
),
);
Expand All @@ -351,6 +394,7 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>
<span class="prelude-val">Ok</span>(())
});

new_self.default_message_handlers(parent.as_ref(), ctrl_id);
new_self
}

Expand All @@ -375,6 +419,7 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>
base: BaseNativeControl::new(parent, ctrl_id),
events: TreeViewEvents::new(parent, ctrl_id),
_pin: PhantomPinned,
_data: PhantomData,
},
),
);
Expand All @@ -385,6 +430,7 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>
<span class="prelude-val">Ok</span>(())
});

new_self.default_message_handlers(parent.as_ref(), ctrl_id);
new_self
}

Expand Down Expand Up @@ -413,9 +459,23 @@ <h2>Files</h2></div></nav><div class="sidebar-resizer"></div>
.add_to_layout_arranger(<span class="self">self</span>.hwnd(), opts_resz.resize_behavior())
}

<span class="kw">fn </span>default_message_handlers(<span class="kw-2">&amp;</span><span class="self">self</span>, parent: <span class="kw-2">&amp;</span>Base, ctrl_id: u16) {
<span class="kw">let </span>self2 = <span class="self">self</span>.clone();
parent.privileged_post_on().wm_notify(ctrl_id, co::TVN::DELETEITEM, <span class="kw">move </span>|<span class="kw">_</span>, p| {
<span class="kw">let </span>nmtv = <span class="kw">unsafe </span>{ p.cast_nmhdr::&lt;NMTREEVIEW&gt;() };
self2.items()
.get(<span class="kw-2">&amp;</span>nmtv.itemOld.hItem)
.data_lparam()
.map(|pdata| {
<span class="kw">let _ </span>= <span class="kw">unsafe </span>{ Rc::from_raw(pdata) }; <span class="comment">// free allocated LPARAM, if any
</span>});
<span class="prelude-val">Ok</span>(())
});
}

<span class="doccomment">/// Exposes the item methods.
</span><span class="attr">#[must_use]
</span><span class="kw">pub const fn </span>items(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; TreeViewItems&lt;<span class="lifetime">'_</span>&gt; {
</span><span class="kw">pub const fn </span>items(<span class="kw-2">&amp;</span><span class="self">self</span>) -&gt; TreeViewItems&lt;<span class="lifetime">'_</span>, T&gt; {
TreeViewItems::new(<span class="self">self</span>)
}

Expand Down
Loading

0 comments on commit d2445f1

Please sign in to comment.