ZealOS/docs/Demo/Graphics/Slider.CC.html
TomAwezome 1b75d91002 Fix Mount AHCI Port selection.
Add arg to SATARep to specify drive types to show.
Add checks in AHCIPortInit to verify port signatures, add helper method to get signatures from port.
2021-08-02 16:40:05 -04:00

147 lines
14 KiB
HTML
Executable file

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=US-ASCII">
<meta name="generator" content="ZealOS V0.13">
<style type="text/css">
body {background-color:#fef1f0;}
.cF0{color:#000000;background-color:#fef1f0;}
.cF1{color:#0148a4;background-color:#fef1f0;}
.cF2{color:#3b7901;background-color:#fef1f0;}
.cF3{color:#057c7e;background-color:#fef1f0;}
.cF4{color:#bb2020;background-color:#fef1f0;}
.cF5{color:#9e42ae;background-color:#fef1f0;}
.cF6{color:#b57901;background-color:#fef1f0;}
.cF7{color:#b2b6af;background-color:#fef1f0;}
.cF8{color:#555753;background-color:#fef1f0;}
.cF9{color:#678fbb;background-color:#fef1f0;}
.cFA{color:#82bc49;background-color:#fef1f0;}
.cFB{color:#0097a2;background-color:#fef1f0;}
.cFC{color:#e26a6a;background-color:#fef1f0;}
.cFD{color:#c671bc;background-color:#fef1f0;}
.cFE{color:#c7ab00;background-color:#fef1f0;}
.cFF{color:#fef1f0;background-color:#fef1f0;}
</style>
</head>
<body>
<pre style="font-family:monospace;font-size:12pt">
<a name="l1"></a><span class=cF2>/*This was done with &lt;CTRL-SHIFT-L&gt; template code.</span><span class=cF0>
<a name="l2"></a></span><span class=cF2>It's conceptually easy to do a ctrl,</span><span class=cF0>
<a name="l3"></a></span><span class=cF2>but tedious. You have complete freedom.</span><span class=cF0>
<a name="l4"></a>
<a name="l5"></a></span><span class=cF2>See </span><a href="https://zeal-operating-system.github.io/ZealOS/Kernel/KernelA.HH.html#l3776"><span class=cF4>CCtrl</span></a><span class=cF2>.</span><span class=cF0>
<a name="l6"></a></span><span class=cF2>*/</span><span class=cF0>
<a name="l7"></a>
<a name="l8"></a></span><span class=cF2>//Start of autocreated Code</span><span class=cF0>
<a name="l9"></a>#</span><span class=cF1>define</span><span class=cF0> SLIDER_RANGE </span><span class=cFE>30</span><span class=cF0>
<a name="l10"></a>#</span><span class=cF1>define</span><span class=cF0> SLIDER_SPACING </span><span class=cFE>20</span><span class=cF0>
<a name="l11"></a>#</span><span class=cF1>define</span><span class=cF0> SLIDER_BORDER </span><span class=cFE>2</span><span class=cF0>
<a name="l12"></a>
<a name="l13"></a></span><span class=cF1>class</span><span class=cF0> CSliderState
<a name="l14"></a>{
<a name="l15"></a> </span><span class=cF9>I64</span><span class=cF0> left_pos;
<a name="l16"></a> </span><span class=cF9>I64</span><span class=cF0> right_pos;
<a name="l17"></a>
<a name="l18"></a>} sld;
<a name="l19"></a>
<a name="l20"></a></span><span class=cF1>U0</span><span class=cF0> DrawCtrlSlider(</span><span class=cF9>CDC</span><span class=cF0> *dc, </span><span class=cF9>CCtrl</span><span class=cF0> *c)
<a name="l21"></a>{
<a name="l22"></a> CSliderState *s = c-&gt;state;
<a name="l23"></a>
<a name="l24"></a> dc-&gt;color = </span><span class=cF3>LTRED</span><span class=cF0>;
<a name="l25"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc, c-&gt;left, c-&gt;top, SLIDER_SPACING * </span><span class=cFE>3</span><span class=cF0> + </span><span class=cFE>2</span><span class=cF0>, SLIDER_SPACING * </span><span class=cFE>2</span><span class=cF0> + SLIDER_RANGE);
<a name="l26"></a> dc-&gt;color = </span><span class=cF3>BLUE</span><span class=cF0>;
<a name="l27"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc, c-&gt;left + SLIDER_BORDER, c-&gt;top + SLIDER_BORDER,
<a name="l28"></a> SLIDER_SPACING * </span><span class=cFE>3</span><span class=cF0> + </span><span class=cFE>2</span><span class=cF0> - </span><span class=cFE>2</span><span class=cF0> * SLIDER_BORDER,
<a name="l29"></a> SLIDER_SPACING * </span><span class=cFE>2</span><span class=cF0> + SLIDER_RANGE - </span><span class=cFE>2</span><span class=cF0> * SLIDER_BORDER);
<a name="l30"></a> dc-&gt;color = </span><span class=cF3>BLACK</span><span class=cF0>;
<a name="l31"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc, c-&gt;left + </span><span class=cFE>1</span><span class=cF0> * SLIDER_SPACING + </span><span class=cFE>0</span><span class=cF0>, c-&gt;top + SLIDER_SPACING,
<a name="l32"></a> c-&gt;left + </span><span class=cFE>1</span><span class=cF0> * SLIDER_SPACING + </span><span class=cFE>0</span><span class=cF0>, c-&gt;top + SLIDER_SPACING + SLIDER_RANGE - </span><span class=cFE>1</span><span class=cF0>);
<a name="l33"></a>
<a name="l34"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc, c-&gt;left + </span><span class=cFE>2</span><span class=cF0> * SLIDER_SPACING + </span><span class=cFE>1</span><span class=cF0>, c-&gt;top + SLIDER_SPACING,
<a name="l35"></a> c-&gt;left + </span><span class=cFE>2</span><span class=cF0> * SLIDER_SPACING + </span><span class=cFE>1</span><span class=cF0>, c-&gt;top + SLIDER_SPACING + SLIDER_RANGE - </span><span class=cFE>1</span><span class=cF0>);
<a name="l36"></a> dc-&gt;color = </span><span class=cF3>LTRED</span><span class=cF0>;
<a name="l37"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc, c-&gt;left + </span><span class=cFE>1</span><span class=cF0> * SLIDER_SPACING + </span><span class=cFE>0</span><span class=cF0> - </span><span class=cF3>FONT_WIDTH</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>,
<a name="l38"></a> c-&gt;top + SLIDER_SPACING + SLIDER_RANGE + </span><span class=cFE>3</span><span class=cF0>,
<a name="l39"></a> </span><span class=cF6>&quot;%d&quot;</span><span class=cF0>, s-&gt;left_pos * </span><span class=cFE>10</span><span class=cF0> / SLIDER_RANGE);
<a name="l40"></a>
<a name="l41"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc, c-&gt;left + </span><span class=cFE>2</span><span class=cF0> * SLIDER_SPACING + </span><span class=cFE>1</span><span class=cF0> - </span><span class=cF3>FONT_WIDTH</span><span class=cF0> / </span><span class=cFE>2</span><span class=cF0>,
<a name="l42"></a> c-&gt;top + SLIDER_SPACING + SLIDER_RANGE + </span><span class=cFE>3</span><span class=cF0>,
<a name="l43"></a> </span><span class=cF6>&quot;%d&quot;</span><span class=cF0>, s-&gt;right_pos * </span><span class=cFE>10</span><span class=cF0> / SLIDER_RANGE);
<a name="l44"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc, c-&gt;left + </span><span class=cFE>1</span><span class=cF0> * SLIDER_SPACING + </span><span class=cFE>0</span><span class=cF0> - </span><span class=cFE>3</span><span class=cF0>,
<a name="l45"></a> c-&gt;top + SLIDER_SPACING + SLIDER_RANGE - </span><span class=cFE>1</span><span class=cF0> - s-&gt;left_pos - </span><span class=cFE>2</span><span class=cF0>, </span><span class=cFE>7</span><span class=cF0>, </span><span class=cFE>5</span><span class=cF0>);
<a name="l46"></a>
<a name="l47"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc, c-&gt;left + </span><span class=cFE>2</span><span class=cF0> * SLIDER_SPACING + </span><span class=cFE>1</span><span class=cF0> - </span><span class=cFE>3</span><span class=cF0>,
<a name="l48"></a> c-&gt;top + SLIDER_SPACING + SLIDER_RANGE - </span><span class=cFE>1</span><span class=cF0> - s-&gt;right_pos - </span><span class=cFE>2</span><span class=cF0>, </span><span class=cFE>7</span><span class=cF0>, </span><span class=cFE>5</span><span class=cF0>);
<a name="l49"></a> dc-&gt;color = </span><span class=cF3>YELLOW</span><span class=cF0>;
<a name="l50"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc, c-&gt;left + </span><span class=cFE>1</span><span class=cF0> * SLIDER_SPACING + </span><span class=cFE>0</span><span class=cF0> - </span><span class=cFE>2</span><span class=cF0>,
<a name="l51"></a> c-&gt;top + SLIDER_SPACING + SLIDER_RANGE - </span><span class=cFE>1</span><span class=cF0> - s-&gt;left_pos - </span><span class=cFE>1</span><span class=cF0>, </span><span class=cFE>5</span><span class=cF0>, </span><span class=cFE>3</span><span class=cF0>);
<a name="l52"></a>
<a name="l53"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc, c-&gt;left + </span><span class=cFE>2</span><span class=cF0> * SLIDER_SPACING + </span><span class=cFE>1</span><span class=cF0> - </span><span class=cFE>2</span><span class=cF0>,
<a name="l54"></a> c-&gt;top + SLIDER_SPACING + SLIDER_RANGE - </span><span class=cFE>1</span><span class=cF0> - s-&gt;right_pos - </span><span class=cFE>1</span><span class=cF0>, </span><span class=cFE>5</span><span class=cF0>, </span><span class=cFE>3</span><span class=cF0>);
<a name="l55"></a>}
<a name="l56"></a>
<a name="l57"></a></span><span class=cF1>U0</span><span class=cF0> UpdateDerivedCtrlSlider(</span><span class=cF9>CCtrl</span><span class=cF0> *c)
<a name="l58"></a>{
<a name="l59"></a> CSliderState *s = c-&gt;state;
<a name="l60"></a>
<a name="l61"></a> c-&gt;left = c-&gt;win_task-&gt;pix_width / </span><span class=cFE>2</span><span class=cF0> - (SLIDER_SPACING * </span><span class=cFE>3</span><span class=cF0> + </span><span class=cFE>2</span><span class=cF0>) / </span><span class=cFE>2</span><span class=cF0>;
<a name="l62"></a> c-&gt;right = c-&gt;left + </span><span class=cFE>3</span><span class=cF0> * SLIDER_SPACING + </span><span class=cFE>2</span><span class=cF0>;
<a name="l63"></a> c-&gt;top = c-&gt;win_task-&gt;pix_height/</span><span class=cFE>2</span><span class=cF0> - (SLIDER_SPACING * </span><span class=cFE>2</span><span class=cF0> + SLIDER_RANGE) / </span><span class=cFE>2</span><span class=cF0>;
<a name="l64"></a> c-&gt;bottom = c-&gt;top + SLIDER_SPACING * </span><span class=cFE>2</span><span class=cF0> + SLIDER_RANGE;
<a name="l65"></a> s-&gt;left_pos = </span><span class=cF5>ClampI64</span><span class=cF0>(s-&gt;left_pos, </span><span class=cFE>0</span><span class=cF0>, SLIDER_RANGE - </span><span class=cFE>1</span><span class=cF0>);
<a name="l66"></a> s-&gt;right_pos = </span><span class=cF5>ClampI64</span><span class=cF0>(s-&gt;right_pos, </span><span class=cFE>0</span><span class=cF0>, SLIDER_RANGE - </span><span class=cFE>1</span><span class=cF0>);
<a name="l67"></a>}
<a name="l68"></a>
<a name="l69"></a></span><span class=cF1>U0</span><span class=cF0> LeftClickSlider(</span><span class=cF9>CCtrl</span><span class=cF0> *c, </span><span class=cF9>I64</span><span class=cF0> x, </span><span class=cF9>I64</span><span class=cF0> y, </span><span class=cF1>Bool</span><span class=cF0>)
<a name="l70"></a>{
<a name="l71"></a> CSliderState *s = c-&gt;state;
<a name="l72"></a>
<a name="l73"></a> </span><span class=cF1>if</span><span class=cF0> (x &lt; c-&gt;left + </span><span class=cFE>1</span><span class=cF0> * SLIDER_SPACING + </span><span class=cFE>0</span><span class=cF0> + SLIDER_SPACING / </span><span class=cFE>2</span><span class=cF0>)
<a name="l74"></a> s-&gt;left_pos = SLIDER_RANGE - </span><span class=cFE>1</span><span class=cF0> - (y - </span><span class=cF7>(</span><span class=cF0>c-&gt;top + SLIDER_SPACING</span><span class=cF7>)</span><span class=cF0>);
<a name="l75"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l76"></a> s-&gt;right_pos = SLIDER_RANGE - </span><span class=cFE>1</span><span class=cF0> - (y - </span><span class=cF7>(</span><span class=cF0>c-&gt;top + SLIDER_SPACING</span><span class=cF7>)</span><span class=cF0>);
<a name="l77"></a> </span><span class=cF1>if</span><span class=cF0> (c-&gt;update_derived_vals)
<a name="l78"></a> (*c-&gt;update_derived_vals)(c);
<a name="l79"></a>}
<a name="l80"></a>
<a name="l81"></a></span><span class=cF9>CCtrl</span><span class=cF0> *SliderNew()
<a name="l82"></a>{
<a name="l83"></a> </span><span class=cF9>CCtrl</span><span class=cF0> *c = </span><span class=cF5>CAlloc</span><span class=cF0>(</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF9>CCtrl</span><span class=cF7>)</span><span class=cF0>);
<a name="l84"></a>
<a name="l85"></a> c-&gt;win_task = </span><span class=cF5>Fs</span><span class=cF0>;
<a name="l86"></a> c-&gt;flags = </span><span class=cF3>CTRLF_SHOW</span><span class=cF0> | </span><span class=cF3>CTRLF_CAPTURE_LEFT_MS</span><span class=cF0>;
<a name="l87"></a> c-&gt;type = </span><span class=cF3>CTRLT_GENERIC</span><span class=cF0>;
<a name="l88"></a> c-&gt;state = &amp;sld;
<a name="l89"></a> </span><span class=cF5>MemSet</span><span class=cF0>(&amp;sld, </span><span class=cFE>0</span><span class=cF0>, </span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>CSliderState</span><span class=cF7>)</span><span class=cF0>);
<a name="l90"></a> c-&gt;draw_it = &amp;DrawCtrlSlider;
<a name="l91"></a> c-&gt;left_click = &amp;LeftClickSlider;
<a name="l92"></a> c-&gt;update_derived_vals = &amp;UpdateDerivedCtrlSlider;
<a name="l93"></a> </span><span class=cF5>QueueInsert</span><span class=cF0>(c, </span><span class=cF5>Fs</span><span class=cF0>-&gt;last_ctrl);
<a name="l94"></a> </span><span class=cF5>TaskDerivedValsUpdate</span><span class=cF0>;
<a name="l95"></a>
<a name="l96"></a> </span><span class=cF1>return</span><span class=cF0> c;
<a name="l97"></a>}
<a name="l98"></a>
<a name="l99"></a></span><span class=cF1>U0</span><span class=cF0> SliderDel(</span><span class=cF9>CCtrl</span><span class=cF0> *c)
<a name="l100"></a>{
<a name="l101"></a> </span><span class=cF5>QueueRemove</span><span class=cF0>(c);
<a name="l102"></a> </span><span class=cF5>Free</span><span class=cF0>(c);
<a name="l103"></a>}
<a name="l104"></a>
<a name="l105"></a></span><span class=cF2>//End of autocreated Code</span><span class=cF0>
<a name="l106"></a>
<a name="l107"></a></span><span class=cF1>U0</span><span class=cF0> Main()
<a name="l108"></a>{
<a name="l109"></a> </span><span class=cF6>&quot;This is to demo ctrls.\n&quot;</span><span class=cF0>;
<a name="l110"></a> </span><span class=cF9>CCtrl</span><span class=cF0> *c = SliderNew;
<a name="l111"></a>
<a name="l112"></a> </span><span class=cF5>PressAKey</span><span class=cF0>;
<a name="l113"></a> </span><span class=cF6>&quot;Left: %d Right: %d\n&quot;</span><span class=cF0>, sld.left_pos * </span><span class=cFE>10</span><span class=cF0> / SLIDER_RANGE, sld.right_pos * </span><span class=cFE>10</span><span class=cF0> / SLIDER_RANGE;
<a name="l114"></a> SliderDel(c);
<a name="l115"></a> </span><span class=cF5>DocBottom</span><span class=cF0>;
<a name="l116"></a>}
<a name="l117"></a>
<a name="l118"></a>Main;
</span></pre></body>
</html>