Advertisement
overloop

pure c wysiwyg winapi gui editor 2% done

Apr 4th, 2013
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 3.87 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  3. <head>
  4.     <title>title</title>
  5.     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6.     <meta name="description" content="" />
  7.     <meta name="keywords" content="" />
  8.     <meta name="robots" content="index,follow" />
  9.     <!-- <link rel="stylesheet" type="text/css" href="styles.css" /> -->
  10.     <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
  11.    
  12. <script type="text/javascript">
  13.  
  14. var num = 0;
  15.  
  16.  
  17.  
  18. function form_select(name,options) {
  19.     var s = "";
  20.     for (var i=0;i<options.length;i++) {
  21.         s = s + '<option selected="selected">' + options[i] + '</option>';
  22.     }
  23.     return '<select name="' + name + '">' + s + '</select>';
  24. }
  25.  
  26. function form_text(name,value,size,onchange) {
  27.  
  28.     if (onchange)
  29.         return '<input type="text" id="' + name + '" name="' + name + '" value="' + value + '" size="' + size + '" onchange="'+ onchange +'"/>';
  30.     else
  31.         return '<input type="text" id="' + name + '" name="' + name + '" value="' + value + '" size="' + size + '"/>';
  32. }
  33.  
  34. function form_checkbox(name,caption) {
  35.     return '<input type="checkbox" name="' + name + '" checked="checked" value="' + caption + '" />';
  36. }
  37.  
  38. function div_table(html) {
  39.     return '<table>' + html + '</table>';
  40. }
  41.  
  42. function table_tr(html,id) {
  43.     if (!id)
  44.         return '<tr>' + html + '</tr>';
  45.     else
  46.         return '<tr id="'+id+'">' + html + '</tr>';
  47. }
  48.  
  49. function tr_td(html) {
  50.     return '<td>' + html + '</td>';
  51. }
  52.  
  53. function onWidgetResize(id) {
  54.     //console.log(w);
  55.     //console.log(id);
  56.    
  57.     var x = document.forms["properties-form"]["pos-x" + id].value;
  58.     var y = document.forms["properties-form"]["pos-y" + id].value;
  59.     var w = document.forms["properties-form"]["pos-w" + id].value;
  60.     var h = document.forms["properties-form"]["pos-h" + id].value;
  61.    
  62.     $("#w" + id).css("width",w);
  63.     $("#w" + id).css("height",h);
  64.     $("#w" + id).css("top",y);
  65.     $("#w" + id).css("left",x);
  66.    
  67.    
  68. }
  69.  
  70. //type name id position anchors
  71. function widget(n) {
  72.     var types = ['form','button','edit','label'];
  73.     return table_tr(
  74.         tr_td(form_select('type'+n,types)) +
  75.         tr_td(form_text('name'+n,'',10)) +
  76.         tr_td(form_text('id'+n,'',10)) +
  77.        
  78.         tr_td(form_text('pos-x'+n,'0',3)) +
  79.         tr_td(form_text('pos-y'+n,'0',3)) +
  80.         tr_td(form_text('pos-w'+n,'0',3)) +
  81.         tr_td(form_text('pos-h'+n,'0',3)) +
  82.        
  83.         tr_td(form_checkbox('anc-l'+n,'l')) +
  84.         tr_td(form_checkbox('anc-t'+n,'t')) +
  85.         tr_td(form_checkbox('anc-r'+n,'r')) +
  86.         tr_td(form_checkbox('anc-b'+n,'b')) +
  87.        
  88.         '',
  89.         'r'+n
  90.         );
  91. }
  92.  
  93. function createWidget() {
  94.     var tr = $( widget(1) );
  95.     $("#properties-table").append( tr );
  96.    
  97.     $('#pos-x' + 1).bind('change', function() { onWidgetResize(1); } );
  98.     $('#pos-y' + 1).bind('change', function() { onWidgetResize(1); } );
  99.     $('#pos-w' + 1).bind('change', function() { onWidgetResize(1); } );
  100.     $('#pos-h' + 1).bind('change', function() { onWidgetResize(1); } );
  101.    
  102.     $("#widgets").append( $('<div id="w'+1+'" style="background-color: ' + lightColor() + '; position: relative; border: 1px solid black;"></div>') );
  103.    
  104. }
  105.  
  106. $(document).ready( function() {
  107.     $("#properties-form").css("background-color",lightColor());
  108.     createWidget();
  109. });
  110.  
  111. function lightColor() {
  112.   function c() {
  113.     var d = 20;
  114.     return Math.floor(Math.random()*d+256-d).toString(16);
  115.   }
  116.   return "#"+c()+c()+c();
  117. }
  118.  
  119. </script>
  120.    
  121. <style type="text/css">
  122. #properties-form {
  123.     position: absolute;
  124.     width: 600px;
  125.     height: 400px;
  126.     bottom: 0;
  127.     right: 0;
  128. }
  129.  
  130. </style>
  131.    
  132. </head>
  133. <body>
  134.    
  135. <div id="widgets">
  136.    
  137. </div>
  138.  
  139. <form id="properties-form">
  140.     <table id="properties-table">
  141.         <tr>
  142.             <!-- type name id position anchors -->
  143.         <th>widget</th><th>name</th><th>id</th><th colspan="4">position</th><th colspan="4">anchors</th>
  144.         </tr>
  145.     </table>
  146. </form>
  147.  
  148. </body>
  149. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement