All pastes #57736 Raw Edit

Zach

public cpp v1 · immutable
#57736 ·published 2006-05-21 20:48 UTC
rendered paste body
//-------------------------------------------////         Leet Converter Using FLTK         ////               by: Zach & Mole             ////-------------------------------------------//#include <FL/Fl.H>#include <FL/Fl_Window.H>#include <FL/Fl_Button.H>#include <FL/Fl_Input.H>#include <FL/Fl_Output.H>#include <cstdlib>                  #include <string.h>#include <iostream>#include <stdio.h>#include <map>#include <cctype>#include <algorithm>#include <locale>#define Zach '10s3R';#define Mole 'h4xz0r';using namespace std;//-------------------------------------------//  void copy_cb( Fl_Widget* , void* );  void close_cb( Fl_Widget* , void* );void clear_cb( Fl_Widget* , void* );void make_window();//-------------------------------------------//  class to_lower { public:  char operator() (char c) const             {       return tolower(c);     }};//-------------------------------------------//  map<string,string> setvals() {        map<string, string> replace;        replace["a"] = "4";        replace["b"] = "B";        replace["c"] = "C";        replace["d"] = "D";        replace["e"] = "3";        replace["f"] = "F";        replace["g"] = "G";        replace["h"] = "H";        replace["i"] = "I";        replace["k"] = "K";        replace["l"] = "1";        replace["m"] = "M";        replace["n"] = "N";        replace["o"] = "0";        replace["p"] = "P";        replace["q"] = "Q";        replace["r"] = "R";        replace["s"] = "S";        replace["t"] = "7";        replace["u"] = "U";        replace["v"] = "V";        replace["w"] = "W";        replace["x"] = "X";        replace["y"] = "Y";        return replace;}//-------------------------------------------// string convert(string get) {     map<string, string> replace;     replace = setvals();     string repl, key, temp;          string result = get;     while(!replace.empty()) {           key = (*replace.begin()).first;           repl = (*replace.begin()).second;           string::size_type loc;           temp = result;           std::transform(temp.begin(), temp.end(), temp.begin(), to_lower());           loc = temp.find( key, 0 );           while(loc != string::npos) {                 result.replace( loc, key.length(), repl );                 loc = result.find( key, 0 );           }           replace.erase(replace.begin());     }     return result;} //-------------------------------------------// int main() {   make_window();   return Fl::run();}//-------------------------------------------//void make_window() {    Fl_Window* win= new Fl_Window(550,200, "Leet Converter");   win->begin();            Fl_Button*  copy = new Fl_Button( 10, 150, 70, 30, "l33tify"); //child 0: 1st widget      Fl_Button*  clear = new Fl_Button(190, 150, 70, 30, "c134r"); //child 1: 2th widget      Fl_Input*   inp = new Fl_Input(100, 50, 400, 30, "Regular Text");//child 2: 3rd widget      Fl_Output*  out = new Fl_Output(100, 100, 400, 30, "leetificated");  //child 3: 4th widget      Fl_Button*  close = new Fl_Button(400, 150, 70, 30, "&3x17"); //child 4: 5th widget   win->end();   copy->callback(copy_cb);   close->callback(close_cb);   clear->callback(clear_cb);   win->show(); }//-------------------------------------------//void clear_cb( Fl_Widget* o , void* ) {   Fl_Button* b=(Fl_Button*)o;   Fl_Input* iw = (Fl_Input*) b -> parent() -> child(2);   Fl_Output* ow = (Fl_Output*) b -> parent() -> child(3);   ow->value("");   iw->value("");}//-------------------------------------------//void copy_cb( Fl_Widget* o , void* ) {   Fl_Button* b=(Fl_Button*)o;   Fl_Input* iw = (Fl_Input*) b -> parent() -> child(2);   Fl_Output* ow = (Fl_Output*) b -> parent() -> child(3);   ow->value(convert(iw->value()).c_str());}//-------------------------------------------//void close_cb( Fl_Widget* o, void*) { exit(0);}//-------------------------------------------//