Advertisement
overloop

winapi gui editor for pure c 3% done

Apr 4th, 2013
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5.20 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. ////////////////////////// UTILITY
  15.  
  16. function lightColor() {
  17.   function c() {
  18.     var d = 20;
  19.     return Math.floor(Math.random()*d+256-d).toString(16);
  20.   }
  21.   return "#"+c()+c()+c();
  22. }
  23.  
  24. ////////////////////////// HTML RENDER HELPERS
  25.  
  26. function form_select(name,options) {
  27.     var s = "";
  28.     for (var i=0;i<options.length;i++) {
  29.         s = s + '<option selected="selected">' + options[i] + '</option>';
  30.     }
  31.     return '<select name="' + name + '">' + s + '</select>';
  32. }
  33.  
  34. function form_text(name,value,size,onchange) {
  35.  
  36.     if (onchange)
  37.         return '<input type="text" id="' + name + '" name="' + name + '" value="' + value + '" size="' + size + '" onchange="'+ onchange +'"/>';
  38.     else
  39.         return '<input type="text" id="' + name + '" name="' + name + '" value="' + value + '" size="' + size + '"/>';
  40. }
  41.  
  42. function form_checkbox(name,caption) {
  43.     return '<input type="checkbox" name="' + name + '" checked="checked" value="' + caption + '" />';
  44. }
  45.  
  46. function div_table(html) {
  47.     return '<table>' + html + '</table>';
  48. }
  49.  
  50. function table_tr(html,id) {
  51.     if (!id)
  52.         return '<tr>' + html + '</tr>';
  53.     else
  54.         return '<tr id="'+id+'">' + html + '</tr>';
  55. }
  56.  
  57. function tr_td(html) {
  58.     return '<td>' + html + '</td>';
  59. }
  60.  
  61.  
  62.  
  63. ////////////////////////// MAIN
  64.  
  65. var num = 0;
  66.  
  67. var widgets = [];
  68.  
  69. $(document).ready( function() {
  70.     $("#properties-form").css("background-color",lightColor());
  71.     var w = new Widget();
  72.     w.init();
  73. });
  74.  
  75. ////////////////////////// HANDLERS
  76.  
  77. function widgetHandlerPos(event) {
  78.     var id = event.data.id;
  79.     var prop = event.data.prop;
  80.     var val = $("#pos_" + prop + id).val();
  81.    
  82.     widgets[id][prop] = val;
  83.    
  84.     switch (prop) {
  85.         case 'x' : $("#w" + id).css("left", val + "px"); break
  86.         case 'y' : $("#w" + id).css("top", val + "px"); break
  87.         case 'w' : $("#w" + id).css("width", val + "px"); break
  88.         case 'h' : $("#w" + id).css("height", val + "px"); break
  89.     }
  90. }
  91.  
  92. ////////////////////////// WIDGET
  93.  
  94. function Widget() {
  95.     this.id = 0;
  96.     this.x = 0;
  97.     this.y = 0;
  98.     this.w = 100;
  99.     this.h = 100;
  100. }
  101.  
  102. Widget.prototype.init = function(opt) {
  103.    
  104.     this.id = widgets.length;
  105.     widgets.push(this);
  106.    
  107.     function html_widget(widget) {
  108.         var types = ['form','button','edit','label'];
  109.         return table_tr(
  110.         tr_td(form_select('type'+widget.id,types)) +
  111.         tr_td(form_text('name'+widget.id,'',10)) +
  112.         tr_td(form_text('id'+widget.id,'',10)) +
  113.        
  114.         tr_td(form_text('pos_x'+widget.id,widget.x,3)) +
  115.         tr_td(form_text('pos_y'+widget.id,widget.y,3)) +
  116.         tr_td(form_text('pos_w'+widget.id,widget.w,3)) +
  117.         tr_td(form_text('pos_h'+widget.id,widget.h,3)) +
  118.        
  119.         tr_td(form_checkbox('anc_l'+widget.id,'l')) +
  120.         tr_td(form_checkbox('anc_t'+widget.id,'t')) +
  121.         tr_td(form_checkbox('anc_r'+widget.id,'r')) +
  122.         tr_td(form_checkbox('anc_b'+widget.id,'b')) +
  123.        
  124.         '',
  125.         'r'+widget.id
  126.         );
  127.     }
  128.    
  129.     var html = html_widget(this);
  130.     $("#properties-table").append( $(html) );
  131.    
  132.     var style = '' +
  133.     'width: ' + this.w + 'px;' +
  134.     'height: ' + this.h + 'px;' +
  135.     'top: ' + this.y + 'px;' +
  136.     'left: ' + this.x + 'px;' +
  137.     'background-color: ' + lightColor() + ';';
  138.    
  139.     $("#widgets").append( $('<div id="w' + this.id + '" class="widget" style="' + style + '"></div>') );
  140.    
  141.     $("#pos_x" + this.id).bind('change', {id : this.id, prop : 'x' }, widgetHandlerPos );
  142.     $("#pos_y" + this.id).bind('change', {id : this.id, prop : 'y' }, widgetHandlerPos );
  143.     $("#pos_w" + this.id).bind('change', {id : this.id, prop : 'w' }, widgetHandlerPos );
  144.     $("#pos_h" + this.id).bind('change', {id : this.id, prop : 'h' }, widgetHandlerPos );
  145. }
  146.  
  147.  
  148.  
  149.  
  150.  
  151. //type name id position anchors
  152.  
  153.  
  154. /*function createWidget() {
  155.     var tr = $( widget(1) );
  156.     $("#properties-table").append( tr );
  157.    
  158.     $('#pos-x' + 1).bind('change', function() { onWidgetResize(1); } );
  159.     $('#pos-y' + 1).bind('change', function() { onWidgetResize(1); } );
  160.     $('#pos-w' + 1).bind('change', function() { onWidgetResize(1); } );
  161.     $('#pos-h' + 1).bind('change', function() { onWidgetResize(1); } );
  162.    
  163.     $("#widgets").append( $('<div id="w'+1+'" style="background-color: ' + lightColor() + '; position: relative; border: 1px solid black;"></div>') );
  164.    
  165. }*/
  166.  
  167.  
  168.  
  169. </script>
  170.    
  171. <style type="text/css">
  172. #properties-form {
  173.     position: absolute;
  174.     width: 600px;
  175.     height: 400px;
  176.     bottom: 0;
  177.     right: 0;
  178. }
  179.  
  180. .widget {
  181.     position: relative;
  182.     border: 1px solid black;
  183. }
  184.  
  185. </style>
  186.    
  187. </head>
  188. <body>
  189.    
  190. <div id="widgets">
  191.    
  192. </div>
  193.  
  194. <form id="properties-form">
  195.     <table id="properties-table">
  196.         <tr><!-- type name id position anchors -->
  197.             <th>widget</th>
  198.             <th>name</th>
  199.             <th>id</th>
  200.             <th colspan="4">position</th>
  201.             <th colspan="4">anchors</th>
  202.         </tr>
  203.     </table>
  204. </form>
  205.  
  206. </body>
  207. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement