[ NeznamTkoSam @ 11.02.2005. 17:58 ] @
Potrebno mi je vise fontova u FLTK, a kako vidim ima ih jako malo :(
[ Dejan Lozanovic @ 11.02.2005. 19:08 ] @
pogledaj test direktorijum unutra fltk biblioteke, imas tamo primer fonts, koji lepo ilisturuje rad da fontovima, metod labelfont kao argument uzima klasu font, znaci ovi predefinisani nisu svi fontovi.

FL_HELVETICA - Helvetica (or Arial) normal (0).
FL_HELVETICA_BOLD - Helvetica (or Arial) bold.
FL_HELVETICA_ITALIC - Helvetica (or Arial) oblique.
FL_HELVETICA_BOLD_ITALIC - Helvetica (or Arial) bold-oblique.
FL_COURIER - Courier normal.
FL_COURIER_BOLD - Courier bold.
FL_COURIER_ITALIC - Courier italic.
FL_COURIER_BOLD_ITALIC - Courier bold-italic.
FL_TIMES - Times roman.
FL_TIMES_BOLD - Times bold.
FL_TIMES_ITALIC - Times italic.
FL_TIMES_BOLD_ITALIC - Times bold-italic.
FL_SYMBOL - Standard symbol font.
FL_SCREEN - Default monospaced screen font.
FL_SCREEN_BOLD - Default monospaced bold screen font.
FL_ZAPF_DINGBATS - Zapf-dingbats font.
[ NeznamTkoSam @ 11.02.2005. 20:23 ] @
Molim te, mozes li mi dati link gdje je taj CIJELI popis fontova?
btw, kako da napravim vlastiti font?
[ Dejan Lozanovic @ 11.02.2005. 21:31 ] @
cekaj malo kako si ti skinuo uopste FLTK kao gotov paket ili kao iz source-a, fltk je pun primera svi primeri se nalaze unutar fltk direktorijuma pa ima direktorijum test.

I od tamo ti saljem source za fltk 2.0 i kako da dobijes listu svih fontova.
[ NeznamTkoSam @ 12.02.2005. 21:43 ] @
Pri kompajliranju dobivam gresku:

Compiler: Default compiler
Building Makefile: "C:\Documents and Settings\Glavina\Desktop\Nova mapa\Makefile.win"
Executing make...
make.exe -f "C:\Documents and Settings\Glavina\Desktop\Nova mapa\Makefile.win" all
g++.exe -c ../fonts.cxx -o ../fonts.o -I"C:/wxdev-cpp/include/c++/3.3.1" -I"C:/wxdev-cpp/include/c++/3.3.1/mingw32" -I"C:/wxdev-cpp/include/c++/3.3.1/backward" -I"C:/wxdev-cpp/lib/gcc-lib/mingw32/3.3.1/include" -I"C:/wxdev-cpp/include"

../fonts.cxx: In member function `virtual void FontDisplay::draw()':
../fonts.cxx:50: error: `Rectangle' undeclared in namespace `fltk'

make.exe: *** [../fonts.o] Error 1

Execution terminated
[ Dejan Lozanovic @ 13.02.2005. 10:26 ] @
Koju ferziju fltk biblioteke koristis ? onaj source od ranije je bio za fltk 2.0 a ovaj sada sto cu ti poslati je primer za fltk 1.1.x. Usput preporucujem da se prebacis na FLTK 2.0 jer on radi sa UNICODE znakovima, dok 1.1x mora da se patchuje da bi radio sa UTF-8.
[ NeznamTkoSam @ 13.02.2005. 19:47 ] @
Sada radi, hvala.
[ Dejan Lozanovic @ 14.02.2005. 08:37 ] @
znaci da imas staru i bajatu verziju fltk 1.1, moj savet je da odes na www.fltk.org i da tamo skines verziju 2.0, veruj mi isplati se.

Procedura je sledeca, prvo skines subversion program,
Code:

http://subversion.tigris.org/s...rojectDocumentList?folderID=91


zatim kreiras direktorijum gde zelis da se skine source pa onda u command promtu odes u taj direktorijum i kucas

Code:

svn co http://svn.easysw.com/public/fltk/fltk/trunk/ fltk


I nakon toga iskompajliras biblioteku, opet ostaje pitanje koji kompajler koristis :), ukoliko je u pitanju Visual C++ pogledaj odavde video tutorial kako da uradis to.

http://seriss.com/people/erco/fltk-videos/

u suprotnom procitaj readme fajlove, koliko vidim ima i gotove fajlove za pravljenje dev-c++ paketa.

Ujedno pogledaj i sajt

www.fltk.net naci ces tamo dosta korisnih linkova i dokumentaciju u CHM formatu :) pa uzivaj :)
[ leka @ 19.02.2005. 16:51 ] @
Imenjace, ne treba mu Subversion da bi skinuo sors ako nece. Na http://www.fltk.net moze skinuti svezi snapshot u vidu .tar.bz2 fajla... :) Pise: "FLTK 2.0.0 CVS Snapshots (latest FLTK2 source". Khm, moracu da izmenim sajt da pise "SVN Snapshots"... ;)
[ Dejan Lozanovic @ 19.02.2005. 17:09 ] @
Citat:
leka: Imenjace, ne treba mu Subversion da bi skinuo sors ako nece. Na http://www.fltk.net moze skinuti svezi snapshot u vidu .tar.bz2 fajla... :) Pise: "FLTK 2.0.0 CVS Snapshots (latest FLTK2 source". Khm, moracu da izmenim sajt da pise "SVN Snapshots"... ;)


Neazuran si :)
[ leka @ 19.02.2005. 20:46 ] @
Ma bitno je da krontab radi posao svake noci, i da pravi dobre pakete... :D - Sta pise tamo kao link nije preterano bitno. Btw. radim redizajn www.fltk.net-a i ubacujem par originalnih ideja.
[ NeznamTkoSam @ 17.03.2005. 18:15 ] @
Code:
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Button.H>

int font = 0;
Fl_Window *window;
Fl_Button *b;
Fl_Button *name;

void change_font(void*) {
    font++;
    b->labelfont(font);
    name->label(Fl::get_font_name((Fl_Font)font));
    b->redraw();
    name->redraw();
    Fl::repeat_timeout(0.3, change_font);
}

int main() {
    Fl::set_fonts("*");
    window = new Fl_Window(300, 180);
    window->begin();
    b = new Fl_Button(0, 0, 300, 100, "AaBbCcDdEe");
    b->labelfont(font);
    b->labelsize(30);
    name = new Fl_Button(0, 100, 300, 80);
    name->label(Fl::get_font_name((Fl_Font)font));
    window->end();
    window->show();
    Fl::add_timeout(0.3, change_font);
    return Fl::run();
}
[ leka @ 18.03.2005. 20:40 ] @
Kod nije moj - nalazi se u /test direktorijumu unutar FLTK sors stabla.
Umesto neosnovane tvrdnje da FLTK "ima jako malo fontova" (jos jedna u nizu), trebalo je malo proci kroz /test direktorijum FLTK-a i nauciti ponesto - ili kroz dokumentaciju gde o listanju fontova i prici o gore navedenim makroima (za fontove koji se najcesce koriste) imas na nekoliko mesta.
( U pitanju je FLTK 2.0 kod. )
Code:

#include <fltk/run.h>
#include <fltk/Window.h>
#include <fltk/Browser.h>
#include <fltk/CheckButton.h>
#include <fltk/draw.h>
#include <fltk/Font.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

fltk::Window *form;

class FontDisplay : public fltk::Widget {
  void draw();
public:
  fltk::Font* font; unsigned size; const char* encoding;
  FontDisplay(fltk::Box* B, int X, int Y, int W, int H, const char* L = 0) :
    fltk::Widget(X,Y,W,H,L) {box(B); font = 0; size = 14;}
};

fltk::Widget* id_box;

void FontDisplay::draw() {
  draw_box();
  fltk::push_clip(fltk::Rectangle(2,2,w()-2,h()-2));
  const char* saved_encoding = fltk::get_encoding();
  fltk::set_encoding(encoding);
  fltk::setfont(font, size);
  id_box->label(fltk::Font::current_name());
  id_box->redraw();
  fltk::setcolor(fltk::BLACK);
  char buffer[32];
  for (int Y = 1; Y < 8; Y++) {
    for (int X = 0; X < 32; X++) buffer[X] = (32*Y+X);
    fltk::drawtext(buffer, 32, 3, 3+(size+leading())*Y);
  }
  fltk::set_encoding(saved_encoding);
  fltk::pop_clip();
}

FontDisplay *textobj;

fltk::Browser *fontobj, *sizeobj, *encobj;

fltk::Font** fonts; // list returned by fltk

fltk::Group *button_group;
fltk::CheckButton* bold_button, *italic_button;

int pickedsize = 14;

void font_cb(fltk::Widget *, long) {
  int fn = fontobj->value();
//printf("font: %d    name: %s   bigname: %s\n", fn, fonts[fn]->name(), fonts[fn]->system_name());

  fltk::Font* f = fonts[fn];
  if (f->bold() == f) bold_button->deactivate();
  else bold_button->activate();
  if (f->italic() == f) italic_button->deactivate();
  else italic_button->activate();
  if (bold_button->value()) f = f->bold();
  if (italic_button->value()) f = f->italic();
  textobj->font = f;

  char saved[30];
  if (textobj->encoding)
    strncpy(saved, textobj->encoding, 29);
  else
    saved[0] = 0;
  encobj->clear();
  const char** encodings; int ne = f->encodings(encodings);
  int picked = -1;
  int iso8859 = 0;
  for (int i = 0; i < ne; i++) {
    encobj->add(encodings[i]);
    if (!strcmp(encodings[i], saved)) picked = i;
    if (!strcmp(encodings[i], fltk::get_encoding())) iso8859 = i;
  }
  if (picked < 0) picked = iso8859;
  textobj->encoding = encodings[picked];
  encobj->value(picked);

  sizeobj->clear();
  int *s; int n = f->sizes(s);
  if (!n) {
    // no sizes (this only happens on X)
    fltk::setfont(f, pickedsize);
    textobj->size = (int)fltk::getsize();
  } else if (s[0] == 0) {
    // many sizes;
    int j = 1;
    for (int i = 1; i<64 || i<s[n-1]; i++) {
      char buf[20];
      if (j < n && i==s[j]) {sprintf(buf,"@b;%d",i); j++;}
      else sprintf(buf,"%d",i);
      sizeobj->add(buf);
    }
    sizeobj->value(pickedsize-1);
    textobj->size = pickedsize;
  } else {
    // some sizes
    int w = 0;
    for (int i = 0; i < n; i++) {
      if (s[i]<=pickedsize) w = i;
      char buf[20];
      sprintf(buf,"@b;%d",s[i]);
      sizeobj->add(buf);
    }
    sizeobj->value(w);
    textobj->size = s[w];
  }
  encobj->redraw();
  sizeobj->redraw();
  textobj->redraw();
  button_group->redraw();
}

void encoding_cb(fltk::Widget *, long) {
  int i = encobj->value();
// CET - FIXME - new browser code has value starting from 0!
//  if (!i) return;
  textobj->encoding = encobj->child(i)->label();
  textobj->redraw();
}

void size_cb(fltk::Widget *, long) {
  int i = sizeobj->value();
// CET - FIXME - new browser code has value starting from 0!
//  if (!i) return;
  const char *c = sizeobj->child(i)->label();
  while (*c < '0' || *c > '9') c++;
  pickedsize = atoi(c);
  textobj->size = pickedsize;
  textobj->redraw();
}

void create_the_forms() {
  form = new fltk::Window(550,390);
  form->set_double_buffer();
  form->begin();
  id_box = new fltk::Widget(10, 172, 530, 15);
  id_box->box(fltk::ENGRAVED_BOX);
  id_box->labelsize(10);
  id_box->labelfont(fltk::COURIER);
  id_box->set_flag(fltk::ALIGN_INSIDE|fltk::ALIGN_CLIP|fltk::ALIGN_LEFT);
  textobj = new FontDisplay(fltk::ENGRAVED_BOX,10,10,530,160);
  textobj->clear_flag(fltk::ALIGN_MASK);
  textobj->set_flag(fltk::ALIGN_TOP|fltk::ALIGN_LEFT|fltk::ALIGN_INSIDE|fltk::ALIGN_CLIP);
  button_group = new fltk::Group(10, 190, 140, 20);
  button_group->begin();
  bold_button = new fltk::CheckButton(0, 0, 70, 20, "Bold");
  bold_button->labelfont(bold_button->labelfont()->bold());
  bold_button->callback(font_cb, 1);
  italic_button = new fltk::CheckButton(70, 0, 70, 20, "Italic");
  italic_button->labelfont(italic_button->labelfont()->italic());
  italic_button->callback(font_cb, 1);
  button_group->end();
  fontobj = new fltk::Browser(10, 210, 280, 170);
  fontobj->when(fltk::WHEN_CHANGED);
  fontobj->callback(font_cb);
  form->resizable(fontobj);
  encobj = new fltk::Browser(300, 210, 100, 170);
  encobj->when(fltk::WHEN_CHANGED);
  encobj->callback(encoding_cb, 1);
  sizeobj = new fltk::Browser(410, 210, 130, 170);
  sizeobj->when(fltk::WHEN_CHANGED);
  sizeobj->callback(size_cb);
  form->end();
}

#include <fltk/ask.h>

int main(int argc, char **argv) {
  create_the_forms();
  int numfonts = fltk::list_fonts(fonts);
  for (int i = 0; i < numfonts; i++) fontobj->add(fonts[i]->name());
  fontobj->value(0);
  textobj->encoding = fltk::get_encoding();
  font_cb(fontobj,0);
  form->show(argc,argv);
  return fltk::run();
}