142 lines
9.9 KiB
Plaintext
142 lines
9.9 KiB
Plaintext
|
<!DOCTYPE html>
|
||
|
<html lang="en">
|
||
|
<head>
|
||
|
<meta charset="UTF-8">
|
||
|
<meta name="generator" content="TempleOS V5.03">
|
||
|
<meta name="viewport" content="width=device-width">
|
||
|
<link rel="stylesheet" href="/style/templeos.css">
|
||
|
<script src="/script/templeos.js"></script>
|
||
|
<style type="text/css">
|
||
|
.cF0{color:#000000;background-color:#ffffff;}
|
||
|
.cF1{color:#0000aa;background-color:#ffffff;}
|
||
|
.cF2{color:#00aa00;background-color:#ffffff;}
|
||
|
.cF3{color:#00aaaa;background-color:#ffffff;}
|
||
|
.cF4{color:#aa0000;background-color:#ffffff;}
|
||
|
.cF5{color:#aa00aa;background-color:#ffffff;}
|
||
|
.cF6{color:#aa5500;background-color:#ffffff;}
|
||
|
.cF7{color:#aaaaaa;background-color:#ffffff;}
|
||
|
.cF8{color:#555555;background-color:#ffffff;}
|
||
|
.cF9{color:#5555ff;background-color:#ffffff;}
|
||
|
.cFA{color:#55ff55;background-color:#ffffff;}
|
||
|
.cFB{color:#55ffff;background-color:#ffffff;}
|
||
|
.cFC{color:#ff5555;background-color:#ffffff;}
|
||
|
.cFD{color:#ff55ff;background-color:#ffffff;}
|
||
|
.cFE{color:#ffff55;background-color:#ffffff;}
|
||
|
.cFF{color:#ffffff;background-color:#ffffff;}
|
||
|
</style>
|
||
|
</head>
|
||
|
<body>
|
||
|
<pre id="content">
|
||
|
<a name="l1"></a><span class=cF2>/*This was done with <CTRL-SHIFT-L> 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="/Wb/Kernel/KernelA.HH.HTML#l3065"><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 30
|
||
|
<a name="l10"></a>#</span><span class=cF1>define</span><span class=cF0> SLIDER_SPACING 20
|
||
|
<a name="l11"></a>#</span><span class=cF1>define</span><span class=cF0> SLIDER_BORDER 2
|
||
|
<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>} sld;
|
||
|
<a name="l18"></a>
|
||
|
<a name="l19"></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="l20"></a>{
|
||
|
<a name="l21"></a> CSliderState *s=c->state;
|
||
|
<a name="l22"></a>
|
||
|
<a name="l23"></a> dc->color=</span><span class=cF3>LTRED</span><span class=cF0>;
|
||
|
<a name="l24"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc, c->left,c->top,SLIDER_SPACING*3+2,SLIDER_SPACING*2+SLIDER_RANGE);
|
||
|
<a name="l25"></a> dc->color=</span><span class=cF3>BLUE</span><span class=cF0>;
|
||
|
<a name="l26"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc, c->left+SLIDER_BORDER,c->top+SLIDER_BORDER,
|
||
|
<a name="l27"></a> SLIDER_SPACING*3+2-2*SLIDER_BORDER,
|
||
|
<a name="l28"></a> SLIDER_SPACING*2+SLIDER_RANGE-2*SLIDER_BORDER);
|
||
|
<a name="l29"></a> dc->color=</span><span class=cF3>BLACK</span><span class=cF0>;
|
||
|
<a name="l30"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc,c->left+1*SLIDER_SPACING+0,c->top+SLIDER_SPACING,
|
||
|
<a name="l31"></a> c->left+1*SLIDER_SPACING+0,c->top+SLIDER_SPACING+SLIDER_RANGE-1);
|
||
|
<a name="l32"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc,c->left+2*SLIDER_SPACING+1,c->top+SLIDER_SPACING,
|
||
|
<a name="l33"></a> c->left+2*SLIDER_SPACING+1,c->top+SLIDER_SPACING+SLIDER_RANGE-1);
|
||
|
<a name="l34"></a> dc->color=</span><span class=cF3>LTRED</span><span class=cF0>;
|
||
|
<a name="l35"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc,c->left+1*SLIDER_SPACING+0-</span><span class=cF3>FONT_WIDTH</span><span class=cF0>/2,
|
||
|
<a name="l36"></a> c->top+SLIDER_SPACING+SLIDER_RANGE+3,
|
||
|
<a name="l37"></a> </span><span class=cF6>"%d"</span><span class=cF0>,s->left_pos*10/SLIDER_RANGE);
|
||
|
<a name="l38"></a> </span><span class=cF5>GrPrint</span><span class=cF0>(dc,c->left+2*SLIDER_SPACING+1-</span><span class=cF3>FONT_WIDTH</span><span class=cF0>/2,
|
||
|
<a name="l39"></a> c->top+SLIDER_SPACING+SLIDER_RANGE+3,
|
||
|
<a name="l40"></a> </span><span class=cF6>"%d"</span><span class=cF0>,s->right_pos*10/SLIDER_RANGE);
|
||
|
<a name="l41"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc,c->left+1*SLIDER_SPACING+0-3,
|
||
|
<a name="l42"></a> c->top+SLIDER_SPACING+SLIDER_RANGE-1-s->left_pos-2,7,5);
|
||
|
<a name="l43"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc,c->left+2*SLIDER_SPACING+1-3,
|
||
|
<a name="l44"></a> c->top+SLIDER_SPACING+SLIDER_RANGE-1-s->right_pos-2,7,5);
|
||
|
<a name="l45"></a> dc->color=</span><span class=cF3>YELLOW</span><span class=cF0>;
|
||
|
<a name="l46"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc,c->left+1*SLIDER_SPACING+0-2,
|
||
|
<a name="l47"></a> c->top+SLIDER_SPACING+SLIDER_RANGE-1-s->left_pos-1,5,3);
|
||
|
<a name="l48"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc,c->left+2*SLIDER_SPACING+1-2,
|
||
|
<a name="l49"></a> c->top+SLIDER_SPACING+SLIDER_RANGE-1-s->right_pos-1,5,3);
|
||
|
<a name="l50"></a>}
|
||
|
<a name="l51"></a>
|
||
|
<a name="l52"></a></span><span class=cF1>U0</span><span class=cF0> UpdateDerivedCtrlSlider(</span><span class=cF9>CCtrl</span><span class=cF0> *c)
|
||
|
<a name="l53"></a>{
|
||
|
<a name="l54"></a> CSliderState *s=c->state;
|
||
|
<a name="l55"></a> c->left=c->win_task->pix_width/2-(SLIDER_SPACING*3+2)/2;
|
||
|
<a name="l56"></a> c->right=c->left+3*SLIDER_SPACING+2;
|
||
|
<a name="l57"></a> c->top=c->win_task->pix_height/2-(SLIDER_SPACING*2+SLIDER_RANGE)/2;
|
||
|
<a name="l58"></a> c->bottom=c->top+SLIDER_SPACING*2+SLIDER_RANGE;
|
||
|
<a name="l59"></a> s->left_pos=</span><span class=cF5>ClampI64</span><span class=cF0>(s->left_pos,0,SLIDER_RANGE-1);
|
||
|
<a name="l60"></a> s->right_pos=</span><span class=cF5>ClampI64</span><span class=cF0>(s->right_pos,0,SLIDER_RANGE-1);
|
||
|
<a name="l61"></a>}
|
||
|
<a name="l62"></a>
|
||
|
<a name="l63"></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="l64"></a>{
|
||
|
<a name="l65"></a> CSliderState *s=c->state;
|
||
|
<a name="l66"></a> </span><span class=cF1>if</span><span class=cF0> (x<c->left+1*SLIDER_SPACING+0+SLIDER_SPACING/2)
|
||
|
<a name="l67"></a> s->left_pos=SLIDER_RANGE-1-(y-</span><span class=cF7>(</span><span class=cF0>c->top+SLIDER_SPACING</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l68"></a> </span><span class=cF1>else</span><span class=cF0>
|
||
|
<a name="l69"></a> s->right_pos=SLIDER_RANGE-1-(y-</span><span class=cF7>(</span><span class=cF0>c->top+SLIDER_SPACING</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l70"></a> </span><span class=cF1>if</span><span class=cF0> (c->update_derived_vals)
|
||
|
<a name="l71"></a> (*c->update_derived_vals)(c);
|
||
|
<a name="l72"></a>}
|
||
|
<a name="l73"></a>
|
||
|
<a name="l74"></a></span><span class=cF9>CCtrl</span><span class=cF0> *SliderNew()
|
||
|
<a name="l75"></a>{
|
||
|
<a name="l76"></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="l77"></a> c->win_task=</span><span class=cF5>Fs</span><span class=cF0>;
|
||
|
<a name="l78"></a> c->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="l79"></a> c->type=</span><span class=cF3>CTRLT_GENERIC</span><span class=cF0>;
|
||
|
<a name="l80"></a> c->state=&sld;
|
||
|
<a name="l81"></a> </span><span class=cF5>MemSet</span><span class=cF0>(&sld,0,</span><span class=cF1>sizeof</span><span class=cF7>(</span><span class=cF0>CSliderState</span><span class=cF7>)</span><span class=cF0>);
|
||
|
<a name="l82"></a> c->draw_it=&DrawCtrlSlider;
|
||
|
<a name="l83"></a> c->left_click=&LeftClickSlider;
|
||
|
<a name="l84"></a> c->update_derived_vals=&UpdateDerivedCtrlSlider;
|
||
|
<a name="l85"></a> </span><span class=cF5>QueIns</span><span class=cF0>(c,</span><span class=cF5>Fs</span><span class=cF0>->last_ctrl);
|
||
|
<a name="l86"></a> </span><span class=cF5>TaskDerivedValsUpdate</span><span class=cF0>;
|
||
|
<a name="l87"></a> </span><span class=cF1>return</span><span class=cF0> c;
|
||
|
<a name="l88"></a>}
|
||
|
<a name="l89"></a>
|
||
|
<a name="l90"></a></span><span class=cF1>U0</span><span class=cF0> SliderDel(</span><span class=cF9>CCtrl</span><span class=cF0> *c)
|
||
|
<a name="l91"></a>{
|
||
|
<a name="l92"></a> </span><span class=cF5>QueRem</span><span class=cF0>(c);
|
||
|
<a name="l93"></a> </span><span class=cF5>Free</span><span class=cF0>(c);
|
||
|
<a name="l94"></a>}
|
||
|
<a name="l95"></a>
|
||
|
<a name="l96"></a></span><span class=cF2>//End of autocreated Code</span><span class=cF0>
|
||
|
<a name="l97"></a>
|
||
|
<a name="l98"></a></span><span class=cF1>U0</span><span class=cF0> Main()
|
||
|
<a name="l99"></a>{
|
||
|
<a name="l100"></a> </span><span class=cF6>"This is to demo ctrls.\n"</span><span class=cF0>;
|
||
|
<a name="l101"></a> </span><span class=cF9>CCtrl</span><span class=cF0> *c=SliderNew;
|
||
|
<a name="l102"></a> </span><span class=cF5>PressAKey</span><span class=cF0>;
|
||
|
<a name="l103"></a> </span><span class=cF6>"Left: %d Right: %d\n"</span><span class=cF0>,
|
||
|
<a name="l104"></a> sld.left_pos*10/SLIDER_RANGE,
|
||
|
<a name="l105"></a> sld.right_pos*10/SLIDER_RANGE;
|
||
|
<a name="l106"></a> SliderDel(c);
|
||
|
<a name="l107"></a> </span><span class=cF5>DocBottom</span><span class=cF0>;
|
||
|
<a name="l108"></a>}
|
||
|
<a name="l109"></a>
|
||
|
<a name="l110"></a>Main;
|
||
|
</span></pre></body>
|
||
|
</html>
|