140 lines
10 KiB
HTML
Executable File
140 lines
10 KiB
HTML
Executable File
<!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>/*Done with <CTRL-SHIFT-L> template code</span><span class=cF0>
|
|
<a name="l2"></a></span><span class=cF2>that was modified.</span><span class=cF0>
|
|
<a name="l3"></a>
|
|
<a name="l4"></a></span><span class=cF2>This is an advanced demo that shows</span><span class=cF0>
|
|
<a name="l5"></a></span><span class=cF2>that you can place ctrls on the</span><span class=cF0>
|
|
<a name="l6"></a></span><span class=cF2>wall paper.</span><span class=cF0>
|
|
<a name="l7"></a>
|
|
<a name="l8"></a></span><span class=cF2>See </span><a href="/Wb/Demo/Graphics/Slider.HC.HTML#l1"><span class=cF4>::/Demo/Graphics/Slider.HC</span></a><span class=cF0>
|
|
<a name="l9"></a></span><span class=cF2>and </span><a href="/Wb/Demo/Graphics/WallPaperFish.HC.HTML#l1"><span class=cF4>::/Demo/Graphics/WallPaperFish.HC</span></a><span class=cF0>
|
|
<a name="l10"></a></span><span class=cF2>before messing with this program.</span><span class=cF0>
|
|
<a name="l11"></a>
|
|
<a name="l12"></a></span><span class=cF2>It must be "Adam Included".</span><span class=cF0>
|
|
<a name="l13"></a></span><span class=cF2>*/</span><span class=cF0>
|
|
<a name="l14"></a>
|
|
<a name="l15"></a>#</span><span class=cF1>define</span><span class=cF0> SLIDER_RANGE 30
|
|
<a name="l16"></a>#</span><span class=cF1>define</span><span class=cF0> SLIDER_SPACING 20
|
|
<a name="l17"></a>#</span><span class=cF1>define</span><span class=cF0> SLIDER_BORDER 2
|
|
<a name="l18"></a>
|
|
<a name="l19"></a></span><span class=cF1>class</span><span class=cF0> CSliderState
|
|
<a name="l20"></a>{
|
|
<a name="l21"></a> </span><span class=cF9>I64</span><span class=cF0> left_pos;
|
|
<a name="l22"></a> </span><span class=cF9>I64</span><span class=cF0> right_pos;
|
|
<a name="l23"></a>};
|
|
<a name="l24"></a>
|
|
<a name="l25"></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="l26"></a>{
|
|
<a name="l27"></a> CSliderState *s=c->state;
|
|
<a name="l28"></a>
|
|
<a name="l29"></a> dc->color=</span><span class=cF3>LTRED</span><span class=cF0>;
|
|
<a name="l30"></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="l31"></a> dc->color=</span><span class=cF3>BLUE</span><span class=cF0>;
|
|
<a name="l32"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc, c->left+SLIDER_BORDER,c->top+SLIDER_BORDER,
|
|
<a name="l33"></a> SLIDER_SPACING*3+2-2*SLIDER_BORDER,
|
|
<a name="l34"></a> SLIDER_SPACING*2+SLIDER_RANGE-2*SLIDER_BORDER);
|
|
<a name="l35"></a> dc->color=</span><span class=cF3>BLACK</span><span class=cF0>;
|
|
<a name="l36"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc,c->left+1*SLIDER_SPACING+0,c->top+SLIDER_SPACING,
|
|
<a name="l37"></a> c->left+1*SLIDER_SPACING+0,c->top+SLIDER_SPACING+SLIDER_RANGE-1);
|
|
<a name="l38"></a> </span><span class=cF5>GrLine</span><span class=cF0>(dc,c->left+2*SLIDER_SPACING+1,c->top+SLIDER_SPACING,
|
|
<a name="l39"></a> c->left+2*SLIDER_SPACING+1,c->top+SLIDER_SPACING+SLIDER_RANGE-1);
|
|
<a name="l40"></a> dc->color=</span><span class=cF3>LTRED</span><span class=cF0>;
|
|
<a name="l41"></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="l42"></a> c->top+SLIDER_SPACING+SLIDER_RANGE+3,
|
|
<a name="l43"></a> </span><span class=cF6>"%d"</span><span class=cF0>,s->left_pos*10/SLIDER_RANGE);
|
|
<a name="l44"></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="l45"></a> c->top+SLIDER_SPACING+SLIDER_RANGE+3,
|
|
<a name="l46"></a> </span><span class=cF6>"%d"</span><span class=cF0>,s->right_pos*10/SLIDER_RANGE);
|
|
<a name="l47"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc,c->left+1*SLIDER_SPACING+0-3,
|
|
<a name="l48"></a> c->top+SLIDER_SPACING+SLIDER_RANGE-1-s->left_pos-2,7,5);
|
|
<a name="l49"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc,c->left+2*SLIDER_SPACING+1-3,
|
|
<a name="l50"></a> c->top+SLIDER_SPACING+SLIDER_RANGE-1-s->right_pos-2,7,5);
|
|
<a name="l51"></a> dc->color=</span><span class=cF3>YELLOW</span><span class=cF0>;
|
|
<a name="l52"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc,c->left+1*SLIDER_SPACING+0-2,
|
|
<a name="l53"></a> c->top+SLIDER_SPACING+SLIDER_RANGE-1-s->left_pos-1,5,3);
|
|
<a name="l54"></a> </span><span class=cF5>GrRect</span><span class=cF0>(dc,c->left+2*SLIDER_SPACING+1-2,
|
|
<a name="l55"></a> c->top+SLIDER_SPACING+SLIDER_RANGE-1-s->right_pos-1,5,3);
|
|
<a name="l56"></a>}
|
|
<a name="l57"></a>
|
|
<a name="l58"></a></span><span class=cF1>U0</span><span class=cF0> UpdateDerivedCtrlSlider(</span><span class=cF9>CCtrl</span><span class=cF0> *c)
|
|
<a name="l59"></a>{
|
|
<a name="l60"></a> CSliderState *s=c->state;
|
|
<a name="l61"></a> c->left=c->win_task->pix_width/2-(SLIDER_SPACING*3+2)/2;
|
|
<a name="l62"></a> c->right=c->left+3*SLIDER_SPACING+2;
|
|
<a name="l63"></a> c->top=c->win_task->pix_height/2-(SLIDER_SPACING*2+SLIDER_RANGE)/2;
|
|
<a name="l64"></a> c->bottom=c->top+SLIDER_SPACING*2+SLIDER_RANGE;
|
|
<a name="l65"></a> s->left_pos=</span><span class=cF5>ClampI64</span><span class=cF0>(s->left_pos,0,SLIDER_RANGE-1);
|
|
<a name="l66"></a> s->right_pos=</span><span class=cF5>ClampI64</span><span class=cF0>(s->right_pos,0,SLIDER_RANGE-1);
|
|
<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->state;
|
|
<a name="l72"></a> </span><span class=cF1>if</span><span class=cF0> (x<c->left+1*SLIDER_SPACING+0+SLIDER_SPACING/2)
|
|
<a name="l73"></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="l74"></a> </span><span class=cF1>else</span><span class=cF0>
|
|
<a name="l75"></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="l76"></a> </span><span class=cF1>if</span><span class=cF0> (c->update_derived_vals)
|
|
<a name="l77"></a> (*c->update_derived_vals)(c);
|
|
<a name="l78"></a>}
|
|
<a name="l79"></a>
|
|
<a name="l80"></a></span><span class=cF9>CCtrl</span><span class=cF0> *SliderNew()
|
|
<a name="l81"></a>{
|
|
<a name="l82"></a> </span><span class=cF9>CCtrl</span><span class=cF0> *c;
|
|
<a name="l83"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Fs</span><span class=cF0>!=</span><span class=cFB>adam_task</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
|
|
<a name="l84"></a> </span><span class=cF6>"Must be Adam Included with SHIFT-F5.\n"</span><span class=cF0>
|
|
<a name="l85"></a> </span><span class=cF6>"(Would crash when code mem was freed.)\n"</span><span class=cF0>;
|
|
<a name="l86"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF3>NULL</span><span class=cF0>;
|
|
<a name="l87"></a> </span><span class=cF7>}</span><span class=cF0>
|
|
<a name="l88"></a> c=</span><span class=cF5>ACAlloc</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="l89"></a> c->win_task=</span><span class=cFB>sys_winmgr_task</span><span class=cF0>;
|
|
<a name="l90"></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="l91"></a> c->type=</span><span class=cF3>CTRLT_GENERIC</span><span class=cF0>;
|
|
<a name="l92"></a> c->state=</span><span class=cF5>ACAlloc</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="l93"></a> c->draw_it=&DrawCtrlSlider;
|
|
<a name="l94"></a> c->left_click=&LeftClickSlider;
|
|
<a name="l95"></a> c->update_derived_vals=&UpdateDerivedCtrlSlider;
|
|
<a name="l96"></a> </span><span class=cF5>QueIns</span><span class=cF0>(c,</span><span class=cFB>sys_winmgr_task</span><span class=cF0>->last_ctrl);
|
|
<a name="l97"></a> </span><span class=cF5>TaskDerivedValsUpdate</span><span class=cF0>;
|
|
<a name="l98"></a> </span><span class=cF1>return</span><span class=cF0> c;
|
|
<a name="l99"></a>}
|
|
<a name="l100"></a>
|
|
<a name="l101"></a></span><span class=cF1>U0</span><span class=cF0> SliderDel(</span><span class=cF9>CCtrl</span><span class=cF0> *c)
|
|
<a name="l102"></a>{
|
|
<a name="l103"></a> </span><span class=cF5>QueRem</span><span class=cF0>(c);
|
|
<a name="l104"></a> </span><span class=cF5>Free</span><span class=cF0>(c->state);
|
|
<a name="l105"></a> </span><span class=cF5>Free</span><span class=cF0>(c);
|
|
<a name="l106"></a>}
|
|
<a name="l107"></a>
|
|
<a name="l108"></a>SliderNew;
|
|
</span></pre></body>
|
|
</html>
|